Tutorial: Moodle VPL Hello World -- Python
--D. Thiebaut (talk) 14:56, 10 June 2014 (EDT)
This tutorial illustrates how to setup a VPL activity that tests that a student submitted a Python program that prints out to the console the string "Hello World!\n". The tutorial illustrates how to setup evaluation of the program so that the student will get 0 or 100 points depending on whether his/her program output is correct or not.
- Login as Instructor for course where Python test is to be added
- Turn editing ON
Add New Activity
- Add new activity
- Set the following fields:
- Name: Hello World Test
- Short description: Hello World in Python 3
- Full description: You need to write a Python program that outputs the string "Hello World!" (without the quotes, and with a blank line afterwards) on the console.
- Submission period: pick today's date for Available from and a date that is in your future for Due date, and click on Enable
- Submission restrictions/Max number of files: 1, and leave all the other fields with their default values.
- Grade: Use Point, 100, and pick the category of grades this should fall in (You need to create categories first, i.e. quizzes, homework, exam, etc.)
- Save and display
VPL Administration
Setup the VPL system to test the students programs
- Concentrate now on the second down on the left:
- Test cases: Enter a name for the case, and what the output of the program is expected to be. The exact output should be between double quotes. Note that there is a return at the end of "Hello World!" which should be part of the output.
- Execution options: Run: Yes, Debug: No, Evaluate: Yes, Evaluate just on submission: No, Automatic Grade: Yes
- Requested files: hello.py. Just enter this file name, and nothing in the edit window. Click on Save.
Testing as Admin
- Test activity. Click on Edit and enter this simple program:
#! /usr/bin/python3.4
def main():
print( "Hello World!" )
main()
- Save
- Click on Run
- Close the console
- Click on Evaluate
- Verify that you get the message shown below, indicating that the program runs correctly and gets full mark.
+------------------------------+ | 1 test run/ 0 tests failed | +------------------------------+
Testing As A Student
- Log out from the Admin account
- Log in as a student registered to the class
- Select the class, and the topics containing the Hello World Test
- Click on Edit and enter this program in the editor (tabbed "hello.py"):
- Note that the student does not use the same organization as the Admin and doesn't use functions.
- Now that the student has seen his/her program runs correctly he/she can have the system evaluate it. Click on Evaluate
- Note that the student's program passed the test, and got a 100/100 grade.
This conclude this tutorial