From c6a02870e1fc7917134e794d60b559d349024789 Mon Sep 17 00:00:00 2001 From: Will Daly Date: Tue, 13 May 2014 11:53:58 -0400 Subject: [PATCH] Update instructor dash to support ora2 submissions API with opaque keys --- lms/djangoapps/instructor/enrollment.py | 4 ++-- .../instructor/tests/test_enrollment.py | 20 +++++++++---------- .../instructor/tests/test_legacy_reset.py | 10 +++------- lms/djangoapps/instructor/views/legacy.py | 4 ++-- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/lms/djangoapps/instructor/enrollment.py b/lms/djangoapps/instructor/enrollment.py index 67442f74ba..ce9cab4869 100644 --- a/lms/djangoapps/instructor/enrollment.py +++ b/lms/djangoapps/instructor/enrollment.py @@ -191,8 +191,8 @@ def reset_student_attempts(course_id, student, module_state_key, delete_module=F if delete_module: sub_api.reset_score( anonymous_id_for_user(student, course_id), - course_id, - module_state_key, + course_id.to_deprecated_string(), + module_state_key.to_deprecated_string(), ) module_to_reset = StudentModule.objects.get( diff --git a/lms/djangoapps/instructor/tests/test_enrollment.py b/lms/djangoapps/instructor/tests/test_enrollment.py index 8b09ff5331..4ce954ae2a 100644 --- a/lms/djangoapps/instructor/tests/test_enrollment.py +++ b/lms/djangoapps/instructor/tests/test_enrollment.py @@ -315,33 +315,31 @@ class TestInstructorEnrollmentStudentModule(TestCase): def test_delete_submission_scores(self): user = UserFactory() - course = CourseFactory.create() - problem_location = msk_from_problem_urlname( - course.id, - 'b3dce2586c9c4876b73e7f390e42ef8f', - block_type='openassessment' - ) + problem_location = self.course_key.make_usage_key('dummy', 'module') # Create a student module for the user StudentModule.objects.create( student=user, - course_id=course.id, + course_id=self.course_key, module_state_key=problem_location, state=json.dumps({}) ) # Create a submission and score for the student using the submissions API student_item = { - 'student_id': anonymous_id_for_user(user, course.id), - 'course_id': course.id, - 'item_id': problem_location, + 'student_id': anonymous_id_for_user(user, self.course_key), + 'course_id': self.course_key.to_deprecated_string(), + 'item_id': problem_location.to_deprecated_string(), 'item_type': 'openassessment' } submission = sub_api.create_submission(student_item, 'test answer') sub_api.set_score(submission['uuid'], 1, 2) # Delete student state using the instructor dash - reset_student_attempts(course.id, user, problem_location, delete_module=True) + reset_student_attempts( + self.course_key, user, problem_location, + delete_module=True + ) # Verify that the student's scores have been reset in the submissions API score = sub_api.get_score(student_item) diff --git a/lms/djangoapps/instructor/tests/test_legacy_reset.py b/lms/djangoapps/instructor/tests/test_legacy_reset.py index 4687fa2f7e..40875db38e 100644 --- a/lms/djangoapps/instructor/tests/test_legacy_reset.py +++ b/lms/djangoapps/instructor/tests/test_legacy_reset.py @@ -36,11 +36,7 @@ class InstructorResetStudentStateTest(ModuleStoreTestCase, LoginEnrollmentTestCa CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id) def test_delete_student_state_resets_scores(self): - problem_location = msk_from_problem_urlname( - self.course.id, - 'b3dce2586c9c4876b73e7f390e42ef8f', - block_type='openassessment' - ) + problem_location = self.course.id.make_usage_key('dummy', 'module') # Create a student module for the user StudentModule.objects.create( @@ -53,8 +49,8 @@ class InstructorResetStudentStateTest(ModuleStoreTestCase, LoginEnrollmentTestCa # Create a submission and score for the student using the submissions API student_item = { 'student_id': anonymous_id_for_user(self.student, self.course.id), - 'course_id': self.course.id, - 'item_id': problem_location, + 'course_id': self.course.id.to_deprecated_string(), + 'item_id': problem_location.to_deprecated_string(), 'item_type': 'openassessment' } submission = sub_api.create_submission(student_item, 'test answer') diff --git a/lms/djangoapps/instructor/views/legacy.py b/lms/djangoapps/instructor/views/legacy.py index 00efa1b8e5..9fdf3007e8 100644 --- a/lms/djangoapps/instructor/views/legacy.py +++ b/lms/djangoapps/instructor/views/legacy.py @@ -388,8 +388,8 @@ def instructor_dashboard(request, course_id): try: sub_api.reset_score( anonymous_id_for_user(student, course_key), - course_key, - module_state_key, + course_key.to_deprecated_string(), + module_state_key.to_deprecated_string(), ) except sub_api.SubmissionError: # Trust the submissions API to log the error