Exemplo n.º 1
0
 def POST(self, worker_id):
     questions = {
         "age":0,
         "gender":0,
         "helpful":0,
         "accurate":0,
         "important":0,
         "control":0,
         "information":0,
         "effort":0,
         "elm_a":0,
         "elm_b":0,
         "elm_c":0
     }
     
     for q in questions:
         try:
             questions[q] = web.input()[q]
         except KeyError:
             continue
     
     if questions["age"] == "":
         questions["age"] = str(0)
     model.add_survey_responses(worker_id, questions)
     model.update_stage(worker_id)
     
     # redirect to the page final page
     raise web.seeother("/claim_code/" + worker_id)
Exemplo n.º 2
0
 def POST(self):
 
 	worker_id = web.input(worker_id='').worker_id
 	
 	#Check that they haven't already passed the quiz
 	
 	check = model.check_for_passed_quiz(worker_id)
 	if check:
 		raise web.seeother("/restore?worker_id=" + worker_id)
 
     
     answer_key = {
         "q1": "d",
         "q2": "c",
         "q3": "a",
         "q4": "c",
         "q5": "b",
         "q6": "d",
         "q7": "c",
         "q8": "d"
     }
     
     
     passed = True
     questions_answered = 0
     for i in range(1,9):
         try:
             question_number = "q" + str(i)
             answer = web.input()[question_number]
         except:
             continue
         
         if answer_key[question_number] == answer:
         	questions_answered += 1
             continue
         else:
             passed = False
             break
     if questions_answered < 3:
     	passed = False
             
     if passed:
         model.update_stage(worker_id)
         model.update_quiz_completed(worker_id)
         raise web.seeother('/play/' + worker_id + "/1")
     else:
         #redirect back to the instructions and record the failed try in the db
         model.view_instructions(worker_id)
         raise web.seeother('/instructions/' + worker_id)