Output matching with a runner

Sometime during the year you’re probably going to assign your students a lab where they’ll write code in one class and have a separate runner class. Fortunately, that’s pretty easy to do in ClassCube.

For this example we’re going to create a simple output matching lab assignment with two files. One is a class called PrintSquare where the student will implement a method to output a 5 by 5 grid of # symbols. The other is PrintSquareRunner which is already implemented to call the printSquare method inside the printSquare class.

Here are the two files that we’re going to load into ClassCube.

Problem Settings

We’re going to create a new problem and set grading to output matching.

ClassCube Problem Settings

You can set timeout and visibility to whatever you choose.

Given Code

Since we’re going to be using multiple files, we’re going to go ahead and turn off the starter code. When you do this you’ll get a notice to be sure to include editable files in your problem. That’s okay. We’ll do that in a bit.

Disable Given Code

You can paste your runner code in here if you want. It does need to be a full class though. The reason we’re not is so that we can hide the runner if you don’t want your students to see it.

Expected Output

Next step is to add the expected output. For this one it’s going to be a 5 by 5 square of # symbols like this.

Expected Output

Of course, change this to whatever you’re looking for with your lab.

Adding Files

Now it’s time to add the files. Click on the Problem Files tab. You should see a screen that looks like this.

Problem Files Tab

Click on the green Add File button and the screen should look like this.

Add File

Enter the full filename, including the extension, into the top field. The contents go in the large edit panel on the bottom.

If you’ve already created the file you can also drag and drop it onto the top section – the part with the filename field and toolbar buttons – and the filename and contents will fill in for you.

Do the same for the second file. If you’re using the same files as I am, it should look like this.

Problem Files Added

In this case I left the implementation of the printSquare method up to the student, but went ahead and implemented the main method in the PrintSquareRunner class. If you’d rather leave the runner unimplemented, you can do that as well.

Saving and Testing

Switch back to the Settings tab and click on the Save button. That should take you to the problem edit page.

Problem Editor

Notice that there’s a dropdown next to the Text button. This lists all files that are editable by the student. In this case it’s the PrintSquare.java and PrintSquareRunner.java files. They’re sorted alphabetically, so the PrintSquare.java file comes first.

Running

Now, it’s like any other problem. Your students type in their code and press the Test button. Since this is an output matching question the expected output will be compared to the output from the submitted code. If there’s a match

And, it doesn’t matter which file they currently have selected. All the files will be sent to our servers to get compiled.

Hiding the Runner

If you’d rather not show the runner to your students, that’s easy to do.

Go back and edit the problem and click on the Problem Files tab. Next to the filename there’s a set of 3 buttons. One is an eyeball. Click that one and it should turn gray and switch to an eyeball with a slash through it like this.

Hiding the runner

Now when your students attempt this problem the runner will not be visible. But, it will still get sent with their code to our servers for compilation and running.

Be sure that if you hide the runner it is fully implemented since it won’t be editable.

Which file runs?

And before I go, just a little background on how output matching problems work.

When the files are submitted ClassCube looks for a main method. All files are compiled, but the file with the main is run. Specifically, the first file with a main method is run. So you’ll want to make sure there’s not more than one main.

Trying it out

If you don’t already have a ClassCube account and would like to see this in action this problem is available as a practice problem.  The interface is slightly different on our public practice problems compare to inside of ClassCube, but the idea is the same.

Why ClassCube?

Are you spending too much time grading your students' source code?

ClassCube is an online tool for Computer Science teachers that allows you to create lab assignments for your students. They'll submit their code online and ClassCube will automatically grade it for you.

Teaching with ClassCube…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>