Tutorial: Moodle VPL Min of 3 -- Python

From DftWiki

Jump to: navigation, search

--D. Thiebaut (talk) 17:13, 10 June 2014 (EDT)



Contents

MoodleVPLLogo.png



Moodle VPL Tutorials



This tutorial builds up on the first tutorial of the series. Make sure you go through it before trying this one. In this tutorial we setup a VPL activity to test student Python programs that must input 3 numbers from the keyboard and output the smallest of the 3.

Setup


  • Moodle Version 2.7 + (Build: 20140529)
  • VPL Version 3.0.1
  • For details on how Moodle and VPL were installed, go to this page.



Step-By-Step


  • Log in as the instructor for the course on Moodle
  • Create a new VPL activity
  • 1 file max, set submission period, individual work, Grade of type point, 100 max, set category if necessary, Save and Display
  • Create new Test cases:
case = Test 1
input = 3
5
10
output = 3.0
case = Test 2
input = 3
3
3
output = 3.0
case = Test 3
input = 1000
-1000 
2000
output = -1000.0

  • Execution Options: Run: Yes, Debug: No, Evaluate: Yes, Evaluate just on submission: No, Automatic Grade: Yes.
  • Requested files: minOf3.py
  • Execution files: do not touch any of them. Only the vpl_evaluate.cases will have some contents.
  • Files to keep when running: Nothing checked.
  • Test activity: enter a program that correctly returns the smallest of three numbers:


def main():
    x = float( input( "> " ) )
    y = float( input( "> " ) )
    z = float( input( "> " ) )
    print( min( [x, y, z] ) )
   
main()


  • Save the program


Correct-Program Test


  • Try the Run and Evaluate options and verify that the program passes the 3 tests:

MoodleVPLMinOfThreeTest1.png


The student's program passes all 3 tests and the program gets a grade of 100/100.

Faulty-Program Test


  • Edit the program and introduce a logical error


def main():
    x = float( input( "> " ) )
    y = float( input( "> " ) )
    z = float( input( "> " ) )
    print( min( [x, x, z] ) )   # ERROR: y missing from list
   
main()


  • Evaluate the program

MoodleVPLMinOfThreeTest2.png


The student's program passes only 2 of the 3 tests and the program gets a grade of 66.67/100.


Testing a Program with a Syntax Error


  • Edit the program and introduce a syntax error


def main():
    x = float( input( "> " ) )
    y = float( input( "> " ) )
    z = float( input( "> " ) )
    print( min( [x, y, z] )    # ERROR: right ) missing
   
main()


  • Evaluate the program

MoodleVPLMinOfThreeTest3.png


The student's program crashes the first test, but still manages to get an erroneous score of 66.67/100.

Improved Grading


To correct this inconsistency, we need to modify the test cases and assign some grade reduction to each test. The new vpl_evaouate.cases looks like this:

case = Test 1
grade reduction = 5%
input = 3
5
10
output = 3.0

case = Test 2
grade reduction = 10%
input = 3
3
3
output = 3.0

case = Test 3
grade reduction = 85%
input = 1000
-1000
2000
output = -1000.0



MoodleVPLMinOfThreeImprovedGrading2.png


This is better, but we can improved the grading some more if we really wanted students to remove all syntax errors by assigning a grade reduction of 100% to each of the 3 tests.

100%-Off for Any Failed Test


Here is the revised vpl_evaluate.cases file:

case = Test 1
grade reduction = 100%
input = 3
5
10
output = 3.0

case = Test 2
grade reduction = 100%
input = 3
3
3
output = 3.0

case = Test 3
grade reduction = 100%
input = 1000
-1000
2000
output = -1000.0


And here is the result of the evaluation with the program that is missing a right parenthesis:


MoodleVPLMinOfThreeImprovedGrading3.png


We note that the score is now 0/100 for the program that contains a syntax error and cannot pass any of the tests. Unfortunately the message displayed (" 3 tests run/ 1 test failed ") is still not correct.


This concludes this tutorial