def on_success(self, cid, score, solution_clip_name, clicks, hits): #Create a new test and save the score hpt = HazardPerceptionTest() hpt.uid = str(self.current_user.id) hpt.cid = cid hpt.score = score hpt.save() #Update user's points self.current_user.update_points(score) if self.is_xhr: if clicks==0: clicks+=1 # Avoid ZeroDivisionError html = self.render_string("ui-modules/complete-video.html", clip=solution_clip_name, score=score, accuracy=float(hits)/clicks) self.xhr_response.update({"html": html}) self.write(self.xhr_response)