stage.set_background("underwater")
speedy = codesters.Sprite("turtle2", -200, -200)
toothy = codesters.Sprite("shark2", 150, -50)
def up_key():
toothy.move_up(100)
stage.wait(.2)
toothy.move_down(100)
speedy.move_right(400)
speedy.flip_right_left()
speedy.move_left(400)
speedy.flip_right_left()
# add other actions...
stage.event_key("up", up_key)
stage.wait(3)
question1 = MCQ(1,"","","","","","", "row")
question1.set_prompt(" 1) What will happen when the event runs?")
question1.set_choice_A('Only the shark will move.')
question1.set_choice_B('Only the turtle will move.')
question1.set_choice_C('The shark and turtle will do the same actions.')
question1.set_choice_D('The shark and turtle will do different actions.')
question1.set_correct("D")
question2 = MCQ(2,"","","","","","", "row")
question2.set_prompt("2) Which line listens for the signal to run the event?")
question2.set_choice_A('stage.set_background("summer")')
question2.set_choice_B('def up_key():')
question2.set_choice_C('toothy.move_up(100)')
question2.set_choice_D('stage.event_key("up", up_key)')
question2.set_correct("D")
question3 = MCQ(3,"","","","","","", "row")
question3.set_prompt("3) What is the signal that will run this event?")
question3.set_choice_A('pressing the space bar')
question3.set_choice_B('pressing the up arrow key')
question3.set_choice_C('pressing the "a" key')
question3.set_choice_D('clicking run')
question3.set_correct("B")
repeat_test = True
stop_test = False
def test_script():
global repeat_test
global stop_test
try:
tval1 = question1.correct
except:
tval1 = "DNE"
try:
tval2 = question2.correct
except:
tval2 = "DNE"
try:
tval3 = question3.correct
except:
tval3 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == True, " ")
t1.add_failure(tval1 == False, "Q1 wrong")
t1.add_failure(tval1 == "DNE", " ")
t2 = TestObjective()
t2.add_success(tval2 == True, " ")
t2.add_failure(tval2 == False, "Q2 wrong")
t2.add_failure(tval2 == "DNE", " ")
t3 = TestObjective()
t3.add_success(tval3 == True, " ")
t3.add_failure(tval3 == False, "Q3 wrong")
t3.add_failure(tval3 == "DNE", " ")
tester = TestManager()
tester.add_test_list([t1, t2, t3])
tester.run_tests()
#tester.display_first_feedback()
if repeat_test == False:
stop_test = True
test_counter = 0
def repeat_tests():
global stop_test
global test_counter
if stop_test == False:
test_script()
if test_counter >= 100:
stop_test = True
stage.event_interval(repeat_tests, .2)
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)