Creating Problems

Introduction

As a teacher, at some point you’re going to want to start creating your own problems in ClassCube. The good news is that we’ve tried to make it as easy as possible to build your own problems, while still leaving enough that you’ll be able to have your students work on pretty much anything you’re looking for.

Getting Started

First step in creating a new problem is to go to the Library and click on the green Add Problem button on the top right corner.

Add problem screen shot
Click on the Green Button

Clicking on the Add Problem button will take you to the screen where you’ll be able to create new problems.

Editing Questions

There’s a lot going on on this screen. We’ll break it down into pieces below the screen shot.

Question editing screen
Question editing screen

Question Title

This is the name that will be displayed to your student in the question library. You’ll also see this when you’re looking at student submissions.

Short Description

Give your students a bit more information about the question. This shows up on the list in the library problem list, but isn’t used anywhere else.

Category

Categories are used to separate problems into groups. Think of them like units; loops, branching, etc.

If you don’t see a good category for the problem you’re working on, click on the green plus and you can create your own. In general though it’s better to try and use the existing categories. That way your problems will mix in with the existing problems in that category for your students.

Tags

A tag is similar to the category in that tags are used to organize problems. The difference is that while a problem can be in a single category, it can have multiple tags.

As an example of the differences, let’s say that you’re creating a problem that has the following solution.

public int findLargest( int[] nums ) {
    int lg = Integer.MIN_VALUE;
    for ( int n: nums ) {
        if ( n > lg ) {
            lg = n;
        }
    }
    return lg;
}

You’re probably going to give your students this assignment while you’re teaching loops. So you’d likely put it in the Loops category.

But, there’s a lot more going on. You might tag this problem with foreach, if, array, Integer Class, or any other number of tags.

You can create new tags by just typing them into the field. But, like categories, you want to look and see if there’s already an existing tag to use rather than creating your own.

Question Text

This is the set of instructions that your students will see when they attempt a problem.

Question Text Editor
Question Text Editor

On the edit tab you’re able to type in Markdown formatted text to explain the problem task to your students. If you have a markdown file already on your computer you can also drag and drop it onto the editor.

The preview tab will show you what your instructions will look like after it’s formatted.

On the far right there’s an icon that will toggle the editor to full screen. When using the full screen editor your markdown will be on the left and the preview on the right so that you can see what the instructions will look like as you type.

Given Code

If you want to give your students a starter stub of code you can enter it here.

Looking back at the example code solution above, you’d probably enter something like this for starter code.

public int findLargest( int[] nums ) {

}

This is what your students will see when they first start the problem.

If you’re going to be attaching editable files to your problem, more on that later, you can change the Show toggle so that this doesn’t show up as something that your students can edit. You do need to set it to hide though. Otherwise you wouldn’t have a way to start your students with a totally blank slate.

Java Classes

Notice that the example above isn’t wrapped in a class. For simpler assignments you can just type in a method. When the code is compiled, ClassCube will wrap the method in a class using the default Java imports that you have set in your options.

If you’d rather, you can fill in the starter code as a full class. Or, you can leave that as a task for your students.

Test Data

What you want in the test data field depends on what grading type you’ve set on the right side of the screen.

Simple Grading

For simple grading you’ll enter a series of test cases, each on their own line. When your student submits their solutions ClassCube will take your test cases and automatically build a unit test for you.

This is by far the easiest way to create tests.

Let’s say that you have the following method that should take two int parameters and return the sum.

public int addEm( int a, int b ) {

}

To build a set of simple test cases you might enter the following into the test data field.

1, 2, 3
5, 7, 12
20, 30, 50

Each line is a test case. This example will have 3 tests. For the first it will call addEm(1, 2) and check that the return value is 3. The second test will call addEm(5, 7) and check that the return value is 12. The third test checks that addEm(20, 30) returns 50

Data Types

To build the test cases, ClassCube needs to know the data types. But it’s pretty smart about it. Depending on what you’re wanting to test, you need to format it a bit.

Data Type Notes
String Wrap strings in double quotes.
char Wrap chars in single quotes. This only matters in Java though. If you’re writing a simple test case for Python and wrap data in single quotes it’s treated the same as a double quote.
boolean Either true or false, without quotes. You can also use just t or f. Case doesn’t matter.
int Any numeric value without a decimal is treated as an int. For Java, notice that this is an int. If you need long you’ll need to write a full JUnit test case.
double ClassCube assumes that any numeric value with a decimal is a double. Same as ints, if you want to use a decimal type other than double you’ll need to create a full JUnit test case.

Arrays

You can also use arrays in your test cases. Let’s look at another example. This time it’s going to be the same as the findLargest example from above.

public int findLargest( int[] nums ) {

}

In this case we might enter the following test cases.

[1,2,3,4], 4
[6, 4, 8, 1, 3, 4], 8
[int], 0

Each array is wrapped in square brackets. Just like above, the first part of the line is the data to pass in. The last token is the expected value.

Empty arrays are a bit of a special case. Notice the last line [int]. This tells ClassCube that you want to pass in an empty int array. Since there’s no data, there needs to be something in the array so that we know what type to create.

And, to answer your next question, yes you can build matrices or any xD array. [[1,2], [2,3], [3,4]] would get sent in as an int matrix.

Unit Testing

If simple tests are not enough for you, you can write full JUnit tests and enter the code in the test data field.

If you’re going to write JUnit tests, you’ll probably want to write them in your IDE and then copy and paste them into ClassCube once you’ve got everything working. You can either drag and drop the file onto the test data field or attach the test file on the Attached Files tab (more on that later).

And if you are going to write your own test cases, ClassCube uses JUnit version 4 so be sure you’re targeting that version.

Output Matching

The last option is to check that the output from the student’s code matches what’s expected. Of course, this assumes that they’re writing code that outputs.

For output matching, enter the expected output into the test data field. When your student runs their code, ClassCube will compare their output to the expected output and show them how it matches line-by-line.

A couple of notes. First, any trailing white space is trimmed before checking. So if the student prints an extra blank line or 1,000 blank lines at the end of their solution it won’t matter. Blank lines in the middle do count though. And second, each line has any trailing white space trimmed off.

Question Settings

Depending on settings, some of these may not be visible.

Language

You can currently set your problem to either Java or Python. We’ve got adding other languages on our future feature list. If you’ve got a personal favorite, let us know in the support forums.

Grading

Specifies how ClassCube will grade problems. See the section on test data above for more on grading types.

Timeout

Number of seconds that code is allowed to run before it is considered a failure.

The default is 10 seconds, which should be more than enough for almost all cases. You can increase the limit, but only up to 30 seconds. Anything longer might cause issues on our servers.

When a submission fails because of a timeout it is displayed as 0% and will not show any results from individual tests.

Test Timeout

If you’re using Simple Grading, this is the amount of time in milliseconds before an individual test is considered a failure.

This is not used for output matching or unit testing.

Visibility

You can decide who has access to your problems. There may be cases where you want your students to be able to freely access problems you create. Or, you may want to limit the problem so that your students can only access through a valid assignment link.

Visibility Notes
Private Your students can use this problem, but only if you create an assignment for them. The problem will not show up in their problem library.
My Students The problem will show up in your students library where they can attempt it freely. You’ll also be able to create assignments for the problem.
Shared Assignments Any teachers that you are sharing with as a cohort can create assignments for their students, but their students do not see the problem in their library.
Shared Any teachers that you are sharing with can create assignments. The problem will also show up in their students’ libraries where they can freely attempt the problem.

Attached Files

I can hear you thinking, what about data files? How about late in the year when students need to work with multiple files? We’ve got you covered.

Attached File
Attached File

There’s a second tab on the question editing screen where you can attach files. Any files added here will go with your student’s code when it’s compiled.

To add a file, click on the green Add File button on the botton of the tab. That’ll bring up a panel where you can edit the file. There’s a field on top for the filename and a larger field where you can edit the contents. If you already have the file then you can drag and drop it on top of the filename field and the contents will load. You can also drag and drop binary files if you need a JAR file or other files to work with.

File Options

On the right side of each file panel are 3 icons.

The first is an arrow so that you can toggle the edit field for the file. This is handy if you’ve got large files and don’t want to have to scroll so much.

The second is an eyeball to toggle visibility. When a file is visible your student will be able to see it while they are working on a problem. Sometimes you want that, sometimes you don’t. Maybe you have a data file and you don’t want the contents visible. Or, you can use hidden files to add multiple JUnit test files. If a file is visible to your student it is also editable.

And the third is a trash can so you can remove files if you change your mind.

Discuss This

Please visit our support forums if you have questions about this page.