The University's Moodle instance has the Virtual Programming lab (VPL) plugin installed. This is a powerful tool that allows you to edit, run and automatically assess code online. In-depth documentation is available in the VPL manual and on the UIS website. This page highlights how to use it for running automated tick assessment in the department.
Overview of how it works
VPL has a Moodle component, which handles submissions, grading, etc, and an execution server component that handles the actual code assessment. The Moodle component runs on the UIS Moodle server, and the execution server(s) run on Ubuntu VMs in the department, running the VPL jail system software. Each course (or each lecturer) using VPL has a dedicated VM.
The process of assessment is as follows:
- The student submits some code to Moodle.
- The VPL Moodle component selects one of the execution servers using built-in load balancing.
- The code is packaged up along with an assessment script and sent to the selected execution server.
- The server creates a sandboxed session and runs the shell script.
- Any text that the script prints out to the console is packaged up and sent back to Moodle.
- The Moodle component scans the returned text for special markers.
In general, automated assessment can only test whether the code functions as it should, in terms of giving correct output. It is difficult to verify that a particular algorithm has been used (or not used), nor can it test whether the code is well written (in terms of layout, comments, etc).
The current model is that a student must pass the automated checker (receiving a mark of 0.5). Then they should have a short (~5 minute) ticking session where a ticker (a PhD student, post doc or UTO familiar with the exercise) should assess whether they understand the code (primary goal) and whether it could be improved (secondary goal). If the ticker is satisfied, they should upgrade the tick to 1.0.
The following interpretations are used in the gradebook:
- [blank] - No attempt made to grade (i.e. never submitted)
- 0.0 - Attempts made but code not passed
- 0.5 - Code passed all tests but is awaiting ticking session to confirm tick
- 1.0 - Tick awarded
Create a VPL activity
Requesting a VPL virtual machine
If you don’t already have one, email IT services to request a VM to host your VPL jail. Your VPL VM will usually be named "svr-CRSID-vpl.cl.cam.ac.uk". The OS installation and basic VPL jail system setup will be done for you, but deploying the test scripts needed by your course and any other customisation of the environment is your responsibility.
Tips for setting up your VPL VM:
- Don't touch /jail; VPL manages it for you automatically and will reset its contents to a virtual clone of the root filesystem periodically.
- After creating or modifying any file that you will use from VPL, you may need to restart VPL to rebuild the jail using "sudo systemctl restart vpl-jail-system"; see the VPL documentation for more info.
- VPL generally blocks access to /home from within the jail, so put your scripts elsewhere. /local is one option.
NB: the old VPL servers named svr-vpl-exe-* are no longer usable as of 2025 due to incompatible changes to the central Moodle installation; svr-vpl-exe-dev remains online so that lecturers can retrieve their old code but the live execution servers svr-vpl-exe-1..5 are decommissioned.
Create a VPL activity in Moodle
To create a new VPL activity in Moodle:
- Go to the Moodle course, and turn on Edit mode.
- Click Add an activity or resource, and select Virtual programming lab.
- Enter a name (this will be displayed in the grade book).
- Click Save and display.
Recommended settings
These settings are recommended to use for ticks, though they can be changed if required. Anything not listed here can be left as the default. Edit them within Moodle, by clicking on the tick activity and then selecting the required tab:
Settings
- Submissions period: add due date
- Submission restrictions: add maximum number of files that students are required to submit
- Grade: Maximum grade = 1, grade to pass = 1
Execution options
- Run script: autodetect
- Debug script: autodetect
- Evaluate: Yes (this sets whether the tick submission is automatically graded on submission)
- Evaluate on submission: Yes
- Automatic grade: Yes
Maximum execution resources limits
- Edit these if you get errors when testing due to time outs or out of memory.
Local execution servers
- IT Services will probably have configured the VPL
jail system on your VM with a random token string for security;
configure the execution server using that string as instructed - for
example:
https://svr-spqr2-vpl.cl.cam.ac.uk/TOKEN_STRING_HERE
Creating an Evaluation Script
Assessment of code proceeds in one of two ways: either you set up some unit tests using VPL's simple test language, or you create a custom script.
The custom evaluation script needs to run on the execution servers, take the student’s submitted code, and return text to the console describing the test results. The VPL Moodle component will parse the output text for the following delimiters:
- Lines starting with "Comment :=>>" are comment lines that are reproduced for the student to see in their submission output.
- A line starting "Grade :=>>" assigns a grade to the student in the gradebook
- If outputting a lot of comment text you can section it using headings. To make a heading use: "Comment :=>>-" (i.e. with a minus/dash at the end of the marker).
- Other lines (without a delimiter) are stored in Moodle for admin diagnostics, but not delivered to the student.
Note that your assessment script ought to check that the submitted code doesn't do something nefarious, like output "Grade :=>> 1"
To create an evaluation script:
- Go to your VPL activity, and then select Execution files tab under More.
- Click the vpl_evaluate.sh tab, and enter the evaluation script.
Note that the purpose of vpl_evaluate.sh is to generate an executable file vpl_execution than is run during the automated assessment; you therefore need to print your script to file.
Here is a sample vpl_evaluate.sh used for the IA ML exercises:
#! /bin/bash cat > vpl_execution << 'EOF' #! /bin/bash /usr/share/CST-VPL/curr/bin/ml-unit-tester.sh ex1 curr PreArrivalML 1.0 EOF chmod +x vpl_execution
This redirects the testing to the /usr/share/CST-VPL/curr/bin/ml-unit-tester.sh script, which is used to test ML. ML VPL test script
Similarly, this is used for the Java testing:
#! /bin/bash cat > vpl_execution << 'EOF' #! /bin/bash /usr/share/CST-VPL/curr/bin/java-unit-tester.sh ex3 curr PreArrivalJava 1.0 EOF chmod +x vpl_execution
The details are available at the Java test script page.
Tips on writing your own scripts:
- It's best to limit the files to known filenames rather than freeform submissions
- Check for attempts to fool the ticker (e.g. returning VPL grades)
- Limit the amount of feedback returned to a student via "Comment :=>>", as large amounts of feedback can cause the Moodle gradebook to crash, especially if feedback is produced during a loop.
The ML and Java testers linked to above have now been through a lot of testing and are probably your first port of call for those languages.
Testing your code works
To test your evaluation code works, you can test it using some example code to represent a student submission:
- Go to your VPL activity. Make sure that the Local execution server is set to https://svr-vpl-exe-dev.cl.cam.ac.uk
- Click the Test activity tab, and either upload a file using Submission, or go to Edit and enter or paste in your submission.
- The submission should be graded automatically. If it doesn’t, go to the Grade tab and click evaluate.
Verify that your evaluation code works as expected. On the Submission view tab, there should be a grade recorded for this submission.
Automated Assessment Gotcha: Locked/Overridden Grades
Note that if you import a grade, the associated cell in the online gradebook turns orange. This indicates that the value has been set manually and locks it from being edited by any activity other than another manual change. In the context we imagine you are using here, this is unimportant. However, if you have an activity that auto-grades (say a Virtual Programming Lab) and you decide to do an import for some reason, be aware that the activity will not be able to change the gradebook cells that you set.
Example scenario: You do a mass import of grades for tick 1, which is subjectively assessed by humans outside of moodle. Your import happens to assign 0 to all students for tick 2 simply because they haven't done it yet. But tick 2 is assessed automatically via Moodle. What will happen is that the tick 2 activity will be unable to write into the tick 2 entries in the gradebook, and they will have 0 whatever happens. This can be fixed by editing the gradebook activity and mass-unticking the Override option for tick 2. You can then tell VPL to reprocess all submissions and the grades will propagate into the gradebook.