def update_assessment_transaction( self, email, assessment_type, new_answers, score): """Stores answer and updates user scores.""" student = Student.get_by_email(email) # It may be that old Student entities don't have user_id set; fix it. if not student.user_id: student.user_id = self.get_user().user_id() answers = StudentAnswersEntity.get_by_key_name(student.user_id) if not answers: answers = StudentAnswersEntity(key_name=student.user_id) answers.updated_on = datetime.datetime.now() utils.set_answer(answers, assessment_type, new_answers) assessment_type = store_score(student, assessment_type, score) student.put() answers.put() # Also record the event, which is useful for tracking multiple # submissions and history. models.EventEntity.record( 'submit-assessment', self.get_user(), json.dumps({ 'type': 'assessment-%s' % assessment_type, 'values': new_answers, 'location': 'AnswerHandler'})) return (student, assessment_type)
def update_assessment_transaction(self, email, assessment_type, new_answers, score): """Stores answer and updates user scores.""" student = Student.get_by_email(email) # It may be that old Student entities don't have user_id set; fix it. if not student.user_id: student.user_id = self.get_user().user_id() answers = StudentAnswersEntity.get_by_key_name(student.user_id) if not answers: answers = StudentAnswersEntity(key_name=student.user_id) answers.updated_on = datetime.datetime.now() utils.set_answer(answers, assessment_type, new_answers) assessment_type = store_score(student, assessment_type, score) student.put() answers.put() # Also record the event, which is useful for tracking multiple # submissions and history. models.EventEntity.record( 'submit-assessment', self.get_user(), json.dumps({ 'type': 'assessment-%s' % assessment_type, 'values': new_answers, 'location': 'AnswerHandler' })) return (student, assessment_type)
def update_simassessment_transaction(self, email, assessment_type, new_answers, score): """Stores answer and updates user scores. Args: email: the student's email address. assessment_type: the title of the assessment. new_answers: the latest set of answers supplied by the student. score: the numerical assessment score. Returns: the student instance. """ student = Student.get_enrolled_student_by_email(email) print student.is_transient course = self.get_course() # It may be that old Student entities don't have user_id set; fix it. if not student.user_id: student.user_id = self.get_user().user_id() answers = StudentAnswersEntity.get_by_key_name(student.user_id) if not answers: answers = StudentAnswersEntity(key_name=student.user_id) answers.updated_on = datetime.datetime.now() utils.set_answer(answers, assessment_type, new_answers) assessments.store_score(course, student, assessment_type, int(score)) student.put() answers.put()
def update_assessment_transaction(self, key_name, assessment_type, new_answers, score): """Stores answer and updates user scores. Args: email: the student's email address. assessment_type: the title of the assessment. new_answers: the latest set of answers supplied by the student. score: the numerical assessment score. Returns: the student instance. """ student = Student.get_by_key_name(key_name) if not student or not student.is_enrolled: raise Exception('Expected enrolled student with key_name "%s".', key_name) course = self.get_course() # It may be that old Student entities don't have user_id set; fix it. if not student.user_id: student.user_id = self.get_user().user_id() answers = StudentAnswersEntity.get_by_key_name(student.user_id) if not answers: answers = StudentAnswersEntity(key_name=student.user_id) answers.updated_on = datetime.datetime.now() utils.set_answer(answers, assessment_type, new_answers) store_score(course, student, assessment_type, score) student.put() answers.put() # Also record the event, which is useful for tracking multiple # submissions and history. models.EventEntity.record( 'submit-assessment', self.get_user(), transforms.dumps({ 'type': 'assessment-%s' % assessment_type, 'values': new_answers, 'location': 'AnswerHandler' })) return student
def update_assessment_transaction( self, key_name, assessment_type, new_answers, score): """Stores answer and updates user scores. Args: email: the student's email address. assessment_type: the title of the assessment. new_answers: the latest set of answers supplied by the student. score: the numerical assessment score. Returns: the student instance. """ student = Student.get_by_key_name(key_name) if not student or not student.is_enrolled: raise Exception( 'Expected enrolled student with key_name "%s".', key_name) course = self.get_course() # It may be that old Student entities don't have user_id set; fix it. if not student.user_id: student.user_id = self.get_user().user_id() answers = StudentAnswersEntity.get_by_key_name(student.user_id) if not answers: answers = StudentAnswersEntity(key_name=student.user_id) answers.updated_on = datetime.datetime.now() utils.set_answer(answers, assessment_type, new_answers) store_score(course, student, assessment_type, score) student.put() answers.put() # Also record the event, which is useful for tracking multiple # submissions and history. models.EventEntity.record( 'submit-assessment', self.get_user(), transforms.dumps({ 'type': 'assessment-%s' % assessment_type, 'values': new_answers, 'location': 'AnswerHandler'})) return student