Multiple Language Problems

A user recently got in touch and mentioned that they were creating essentially the same problem in both Java and Python and wondered if there was an easier way.  That got us thinking. It seems silly to have to create separate problems when all that’s different is the language.

Looking into our code there’s really not any difference in a Java or Python problem if you’re using Simple Testing or Output Matching. The only real difference is what you set the language drop down to when you create the problem. So we’ve added a Multiple option to the language drop down. Continue reading

Blocking browser refresh

Has one of your students accidentally pressed the F5 key while they’re working on code in ClassCube? I’d bet that it’s happened in your classroom even if you didn’t hear about it.

When they press F5, or Control R, it typically triggers a browser refresh. When your student is working on their code this causes the problem to reload, and any new code goes away. It’s really frustrating.

We’ve just added a new snippet of code to the editor that intercepts F5, Control F5 and Control R keystrokes and prompts to make sure that they actually want to refresh the browser. We didn’t want to block it entirely so the confirmation dialog seemed like a good compromise.

Refresh Blocked Dialog

A quick note though, this only blocks the keystroke when you’re actively in the editor. If you click off of the code editor then F5 and Ctrl-R work like they normally do and will refresh the page.  Continue reading

Update to Moodle Gist Filter Plugin

Small update to our Moodle Gist Filter plugin.

Now when you embed a gist with multiple files you’re also able to only embed single files.

If you’re pasting in the normal link from a gist it’ll still work the same way. All files from that gist will show up on your Moodle page. But, now if you only want to embed a single file you can add ?file=filename.ext to the end of the URL that you paste into Moodle and only that file will embed.

Gist embedded into Moodle post

You can find documentation on the Moodle Gist Filter plugin here, or view the source on GitHub.

ClassCube in Moodle Demo

Are you curious about what ClassCube looks like inside Moodle?

We’ve got you covered.

If you click over to you can see how well ClassCube and Moodle work together.

On the demo site you’ll be able to create an account and enroll in an example course. In that course you’ll find several examples of ClassCube problems embedded into Moodle.

Pseudocode practice quiz

Just learning to code? Is the language getting in your way? Give this pseudocode practice quiz a shot and see how well you think algorithmically.

What is output from the following code?

x = 10
sum = 0
loop while x > 3
   sum = sum + x
   x = x - 2
print sum

What is output from the following code?

x = 15
if x > 15 
   print "go"
if x < 20 
   print "stop"

What is output from the following code?

a = 2
loop while a < 10
   print a + " "
   a = a + 2

What is output from the following code?

x = 10
loop while x > 85
   x = x - 5
print x

What is output from the following code?

x = 20
loop while x > 10
   x = x - 4
print x

Question 1 of 5

Find nth Occurrence

Find nth Occurrence

This problem comes from a given, but unimplemented, method from the 2017 AP Computer Science exam called Phrase.

In one part you were tasked with replacing the \(n^{th}\) occurrence of one string within another string. And they gave you a method findNthOccurrence to help you out.

But the implementation for findNthOccurrence was not shown. So for this coding challenge, that's you job.

As an example, the call findNthOccurrence( "dogdogdogdog", "dog", 2 ) should return 3 because the 2nd "dog" starts at index 3. findNthOccurrence( "dogdogdogdog", "dog", 3 ) would return 6.

If find does not occur in str the method should return -1. Likewise if there is no \(n^{th}\) occurrence the method should also return -1.

findNthOccurrence("dogdogdogdog", "dog", 1) => 0
findNthOccurrence("dogcatdogdodgdogddd", "dog", 3) => 13
findNthOccurrence("dogdogdog", "dag", 1) => -1
findNthOccurrence("catcatcat", "dog", 3) => -1
findNthOccurrence("fishchickendogcatplatypus", "chicken", 5) => -1