View on GitHub

REPL

The Learning Hub for UoL's Online CS Students

Go back to the main page

Table of contents


ITP1 - Reported problems, tips and additional instructions

This page is about the Introduction to programming I module.

Sleuth

General Sleuth Issues

Spotlight Effect on Firefox

Be aware that Sleuth cases involving a spotlight effect (302 and 801) will not work on Firefox out of the box, like they work in any webkit based browser (like Google Chrome and Safari).

Easiest workaround is commenting out the line at the bottom that says blendMode(DARKEST) and uncommenting it again before submitting the case. Changing it to blendMode(LIGHTEST) should work at least to be able to see where the spotlight is.

Syntax error due to console.log()

If you get this message when submitting a case:

There is an error in your code ...
Error in compile SyntaxError: Unexpected token )

Remove all of your debugging statements that are using console.log().

Function parentheses

If you get this message when submitting a case:

TypeError: studentFunctionCodeString.search is not a function

You need to ensure that any function being declared does not have a space between the function name and the argument. For example:

function myFunc() // Grader should accept this
function myFunc () // Grader might not accept this

Variable assignment

Rookie

101, Stage 3

Use only fill() and rect() commands. You can adjust opacity with fill() by adding a fourth value as follows:

fill(R, G, B, A);

where R, G and B stand for red, green, blue and can have values from 0 to 255 and A is optional alpha. In this case, a value of about 100 is fine so you can see through the shape being drawn.

201, Stage 4


Pro

601, All stages

When required to draw at the various locations of crimes and sightings, take note of the following:

601, Stage 4

Where possible matches need to be pushed into a separate array after comparing dates and distances, take note that some conditions could be too strict resulting in zero matches, which could at first seem like an error in your code. In such cases, if you submit, the grader will accept the empty array as long as the logic was implemented correctly.

701, All stages

Witnesses sometimes give details relating to features or characteristics for which no properties are defined in the object arrays. It is usually not required to check for these. If problematic, get suspended to get a new case.

701, Stage 4

Some versions of this stage have misspelled words which prevent the student from solving the case. If you encounter the words plasic or nerveous, you need to make sure that your solution searches for plastic or nervous instead. Some other variations along those lines with other misspelled words may exist but haven’t been reported yet.

702, All stages

Probably the trickiest of all the Sleuth cases. Instructions are not always explicitly clear and require insight into objects and functions.

702, Stage 1

There is a bug in the instructions, stating that you need to: Get your car on the road by completing the </DRIVE_NAME/> function below.

The function that requires editing is called Move_Car() (or similar).

702, Stage 2

Hardest part is to implement the function to check/search a vehicle ahead by comparing the passed variable’s (detective car object) distance/km/miles property against the ones in the array. There are several ways to do this, but the grader may not always like what you’re doing. Some guidance here:

You need to check each object in the array to confirm using if-statement(s) that:

Note that the distance/km/miles_travelled property is increasing towards the top of the screen, opposite to the regular y-coordinate. Since debugging the array might be tricky, consider adding a text readout to each car using a variation of:

text(Vehicles[i].Distance, Vehicles[i].X, Vehicles[i].Y); //debug

Once implemented correctly, remember the logic, as you will likely need to create similar functions things in the stages ahead.

702, Stage 4

“My suspect’s car didn’t have enough space to pull out in front of me before speeding off, so the chase wouldn’t work as expected. I deliberately got myself suspended so I could grab another case, and it worked fine.” (reported by @dannycallaghan)

801, All stages

More spotlight stages, which may cause Firefox users to not see the spotlights. To get it to work, refer to Spotlight effect on Firefox.

Tips:

801, Stage 3-4

Many students waste time here trying to spot patterns in the audience members based on their appearance. The information about the seat numbers of gang/perpetrators is already defined in an array. It appears that any information given about appearance (hats, retro glasses, etc.) is merely to confirm that you have used the array to traverse the seats in the correct manner and not to actually identify gang members.

801, Stage 4

Here the challenge is to traverse a two-dimensional array using a normal (one-dimensional) array. There are different ways to approach this, but these work:

It appears that the grader is looking for two simple nested for-loops in the solution, so more elegant ways involving math to convert your 1D iterator into two 2D co-ordinates does not work, even when all gang members are correctly identified. This, for example, was not accepted by the grader:

for (var i = 0; i < suspect.length; i++)
operaFolks[floor(i/10)][i%10].recognised = (suspect[i]);

802, Stage 1

Tip: You can comment out the line if (frameCount % 7 == 0) in order to speed up the deck spread sequence. It might save some time during testing.

802, Stage 2

Random function

“They ask you to create an array of random integers between two values. The random() function in p5.js includes the lower number, but excludes the upper number. So if you do random(5,9), it might well generate a 5, but never a 9.

I incremented the upper value by one so it’d actually generate values between the two numbers requested, but the puzzle actually expects you to just naively slot the two values into random and not fix the bug.” (reported by Peter Houlihan)

802, Stage 3

Tip: When comparing cards, you can’t simply compare objects against each other as the objects may be structured differently. Rather consider the properties of the different objects in the arrays and compare similar properties against one another.

802, Stage 4


Game Project

Audio

AudioContext not allowed to start

When implementing audio on your project, you could get an error similar to this from the browser:

The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.

This is just a browser feature to prevent websites from playing sounds without user input. Ensure that your user presses a button or clicks the mouse before you attempt to play audio.

Refer to: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#webaudio

Audio resources not loading

Some users have reported CORS-related problems when trying to launch the audio template provided. This could occur on the file:/// protocol due to Cross-Origin policy restrictions. Ensure that you launch the index.html file from a local web server and not through a file explorer.

Alternatively you can use the Live Server extension in VSCode.

These functions will automatically create a local server for testing and you can confirm this by checking that the address in your browser address starts with localhost or http:// and not file:///


Coursera Material

Week 1

Video: 2D coordinate system

Week 3

Practice quiz: Using the console and debugging syntax errors

Week 7

Lesson 4.1 Video: Conditional statements using ==

Lesson 4.2 Practice quiz: Introducing types: String, Number, Boolean

Practice quiz: Conditionals with types