Tutorial Moodle VPL Rock-Paper-Scissors -- Python
- Moodle Version 2.7 + (Build: 20140529)
- VPL Version 3.0.1
- For details on how Moodle and VPL were installed, go to this page.
Here are the main settings for the new VPL activity:
Tips & Tricks
To generate the vpl_evaluate.cases file, I found that running the program first and capturing its output, and then using this text to generate the input and output sections of the vpl_evaluate.cases file is quick and simple.
- In the Administration box, click on Test activity, then Edit, and enter the solution program below:
computer = 0 user = 0 while abs( computer - user ) < 3: play = input( "> " ).upper().strip() if len( play ) != 2: continue cPick = play uPick = play if uPick == cPick: print( "Tie" ) continue pair = cPick + uPick if pair in [ "PR", "SP", "RS" ]: computer += 1 print( "Player 1 wins" ) continue else: user += 1 print( "Player 2 wins" ) if computer > user: print( "winner: Player 1 (%d to %d)" % ( computer, user ) ) else: print( "winner: Player 2 (%d to %d)" % ( user, computer ) )
- Save, and Evaluate
- Verify that the program runs and passes the two tests.