Creating Coding Assignments Using Assign2

Published on: 2023-05-16 by Edufide

This article describes how instructors can create coding assignments in Assign2 using fast images. Fast images are the supported method for programming assessments: students upload code, Assign2 sends the submission to a prebuilt grading environment, and the autograder returns scores and feedback without requiring a custom image build.

Current supported method: Use a fast image for Python, C and C++, or Java. Custom Docker image builds are no longer part of the supported coding-assignment setup workflow.

Create the Assignment Link

For each coding assignment, add an Assign2 tool activity to your course through your Learning Management System (LMS). This option is typically found under External Tools.

Open the new Assign2 activity and choose Programming Assessment as the assessment type.

Select Programming Assessment in Assign2

Configure Fast-Image Settings

Complete the programming assessment setup form. The key choice is the BASE IMAGE, which selects the prebuilt environment used to run the autograder.

Programming assessment setup with the fast image dropdown open

Supported Fast Images

  • Python 3.11: Use for Python autograders and Python student submissions.

  • C and C++: Use for C or C++ submissions. This uses the universal fast-image runner.

  • Java 17: Use for Java submissions and Java-oriented autograders.

Required Settings

  • ASSIGNMENT NAME: Enter the name students and instructors will see.

  • BASE IMAGE: Select the fast image that matches the assignment language.

  • AUTOGRADER FILE: Upload the instructor autograder as a .zip file. Assign2 validates the file after upload.

  • TEST SUBMISSION FILE: Upload a known sample student submission zip so you can verify the autograder before creating the assignment.

  • AUTOGRADER POINTS: Set the number of points awarded by the automated tests.

  • DUE DATE: Set the submission deadline.

Optional Settings

  • Enable Manual Grading: Add a manually graded component in addition to the autograder score.

  • Allow late submissions: Permit submissions after the due date.

  • Enable Group Submission: Allow students to submit as groups and set a group-size limit.

Completed fast-image coding assignment setup form

Prepare the Autograder Zip File

The autograder zip contains the scripts, tests, and configuration needed to grade student submissions. Fast images run the autograder in a Linux environment with this directory layout:

  • /tmp/autograder/source: extracted autograder files.

  • /tmp/autograder/submission: extracted student submission files.

  • /tmp/autograder/results/results.json: the results file Assign2 reads after grading.

Recommended Zip Structure

autograder.zip
├── config.json
├── run_autograder
├── run_tests.py
├── setup.sh
└── tests/
  └── test_example.py

Some autograders use a custom grade.py or another test runner instead of run_tests.py. That is fine as long as run_autograder creates results.json in the expected location.

config.json

Include a language value so the fast-image runner can prepare files correctly.

{
"language": "python"
}

Common language values are python, c, cpp, and java.

run_autograder

This is the main script Assign2 runs. It should copy the student submission into the working directory, run the tests, and write the results file.

#!/usr/bin/env bash
cp /tmp/autograder/submission/*.py /tmp/autograder/source/ 2>/dev/null
cd /tmp/autograder/source
python3 run_tests.py

Results File Format

The autograder must create /tmp/autograder/results/results.json. A typical result looks like this:

{
"score": 8,
"max_score": 10,
"output": "Autograder completed.",
"visibility": "visible",
"tests": [
  {
    "name": "Basic functionality",
    "score": 5,
    "max_score": 5,
    "status": "passed",
    "output": "Passed",
    "visibility": "visible"
  },
  {
    "name": "Edge cases",
    "score": 3,
    "max_score": 5,
    "status": "failed",
    "output": "Failed on empty input",
    "visibility": "visible"
  }
]
}

Path Compatibility

Some older autograders write to /autograder/results/results.json. The universal runner maps those paths to Assign2’s Lambda environment for C and C++ assignments. For maximum compatibility, prefer /tmp/autograder paths in new autograders.

Test the Autograder

Before creating the assignment, upload a test submission zip and click Test Autograder. Assign2 runs the autograder using the selected fast image and displays the returned score, output, and test-level feedback.

Successful fast-image autograder test results

If the test fails, check the output shown in the dialog. Common issues include missing files in the student zip, incorrect paths in run_autograder, or a results file written to the wrong location.

Sample Autograders

The following sample autograders can be used to test the fast-image workflow. Each sample includes an instructor autograder.zip and one or more student submission zips.

Python Samples

C Samples

C++ Samples

Java Samples