diff --git a/lms/djangoapps/instructor/views.py b/lms/djangoapps/instructor/views.py index e65f358e38..4008802276 100644 --- a/lms/djangoapps/instructor/views.py +++ b/lms/djangoapps/instructor/views.py @@ -190,24 +190,36 @@ def instructor_dashboard(request, course_id): student_to_reset=User.objects.get(username=unique_student_identifier) msg+="Found a single student to reset. " except: - msg+="Couldn't find student to reset. " + student_to_reset=None + msg+="Couldn't find student with that email or username. " - # find the module in question - try: - module_to_reset=StudentModule.objects.get(student_id=student_to_reset.id, course_id=course_id, module_state_key__iendswith="/problem/"+problem_to_reset) - msg+="Found module to reset. " - except Exception as e: - msg+="Couldn't find module to reset. " + if student_to_reset is not None: + # find the module in question + try: + module_to_reset=StudentModule.objects.get(student_id=student_to_reset.id, course_id=course_id, module_state_key__iendswith="/problem/"+problem_to_reset) + msg+="Found module to reset. " + except Exception as e: + msg+="Couldn't find module with that urlname. " # modify the problem's state try: # load the state json problem_state=json.loads(module_to_reset.state) + old_number_of_attempts=problem_state["attempts"] problem_state["attempts"]=0 # save module_to_reset.state=json.dumps(problem_state) module_to_reset.save() + track.views.server_track(request, + '{instructor} reset attempts from {old_attempts} to 0 for {student} on problem {problem} in {course}'.format( + old_attempts=old_number_of_attempts, + student=student_to_reset, + problem=module_to_reset.module_state_key, + instructor=request.user, + course=course_id), + {}, + page='idashboard') msg+="Module state successfully reset!" except: msg+="Couldn't reset module state. "