Commit e074693f by Tyler Hallada

Changes to match implementation of GradesService

parent a76cbb49
......@@ -58,7 +58,7 @@ SHOW_EXPIRY_MESSAGE_DURATION = 1 * 60 # duration within which expiry message is
APPROVED_STATUS = 'approved'
REJECTED_GRADE_OVERRIDE_SCORE = 0
REJECTED_GRADE_OVERRIDE_EARNED = 0.0
def create_exam(course_id, content_id, exam_name, time_limit_mins, due_date=None,
......@@ -897,11 +897,13 @@ def update_attempt_status(exam_id, user_id, to_status,
'Overriding exam subsection grade for '
'user_id {user_id} on {course_id} for '
'content_id {content_id}. Override '
'score: {score}'.format(
'earned_all: {earned_all}, '
'earned_graded: {earned_graded}.'.format(
user_id=exam_attempt_obj.user_id,
course_id=exam['course_id'],
content_id=exam_attempt_obj.proctored_exam.content_id,
score=REJECTED_GRADE_OVERRIDE_SCORE
earned_all=REJECTED_GRADE_OVERRIDE_EARNED,
earned_graded=REJECTED_GRADE_OVERRIDE_EARNED
)
)
log.info(log_msg)
......@@ -910,7 +912,8 @@ def update_attempt_status(exam_id, user_id, to_status,
user_id=exam_attempt_obj.user_id,
course_key_or_id=exam['course_id'],
subsection=exam_attempt_obj.proctored_exam.content_id,
score=REJECTED_GRADE_OVERRIDE_SCORE
earned_all=REJECTED_GRADE_OVERRIDE_EARNED,
earned_graded=REJECTED_GRADE_OVERRIDE_EARNED
)
# call service to get course name.
......
......@@ -928,11 +928,14 @@ class ProctoredExamApiTests(ProctoredExamTestCase):
)
grades_service = get_runtime_service('grades')
grades_status = grades_service.get_subsection_grade(user_id=self.user.id,
course_key_or_id=exam_attempt.proctored_exam.course_id,
subsection=exam_attempt.proctored_exam.content_id)
self.assertEqual(grades_status, 0)
grades = grades_service.get_subsection_grade(user_id=self.user.id,
course_key_or_id=exam_attempt.proctored_exam.course_id,
subsection=exam_attempt.proctored_exam.content_id)
self.assertEqual(grades, {
'earned_all': 0.0,
'earned_graded': 0.0
})
@ddt.data(
(ProctoredExamStudentAttemptStatus.declined, ProctoredExamStudentAttemptStatus.eligible),
......
......@@ -187,6 +187,9 @@ class MockGradesService(object):
"""Returns entered grade override for key (user_id + course_key + subsection) or None"""
return self.grades.get(str(user_id) + str(course_key_or_id) + str(subsection))
def override_subsection_grade(self, user_id, course_key_or_id, subsection, score):
"""Sets grade override score for key (user_id + course_key + subsection)"""
self.grades[str(user_id) + str(course_key_or_id) + str(subsection)] = score
def override_subsection_grade(self, user_id, course_key_or_id, subsection, earned_all=None, earned_graded=None):
"""Sets grade override earned points for key (user_id + course_key + subsection)"""
self.grades[str(user_id) + str(course_key_or_id) + str(subsection)] = {
'earned_all': earned_all,
'earned_graded': earned_graded
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment