sprite = codesters.Sprite("hedgehog", 0, 75)
def interval():
sprite.turn_right(30)
sprite.move_forward(50)
# add any other actions...
stage.event_interval(interval, 0.5)
stage.wait(5)
question1 = MCQ(1,"","","","","","", "row")
question1.set_prompt("What's the best definition of an interval event?")
question1.set_choice_A("An event that runs continuously at specified intervals")
question1.set_choice_B("An event that runs when two sprites collide")
question1.set_choice_C("An event that runs only when the user press run")
question1.set_choice_D("An event runs when the user clicks on the stage")
question1.set_correct("A")
question2 = MCQ(2,"","","","","","", "row")
question2.set_prompt("How often is this interval event running?")
question2.set_choice_A("Every 5 seconds")
question2.set_choice_B("Every half second")
question2.set_choice_C("Every 2 seconds")
question2.set_choice_D("Every 1 second")
question2.set_correct("B")
question3 = MCQ(3,"","","","","","", "row")
question3.set_prompt("What's the best definition of a string?")
question3.set_choice_A("Text")
question3.set_choice_B("Anything surrounded by quotes")
question3.set_choice_C("A string of numbers")
question3.set_choice_D("Numbers with decimals")
question3.set_correct("A")
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)