@transaction.non_atomic_requests
@require_POST
@ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
@require_level('instructor')
@require_post_params(problem_to_reset='problem urlname to reset')
@common_exceptions_400
def rescore_problem(request, course_id):
 course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)
 problem_to_reset = strip_if_string(request.POST.get('problem_to_reset'))
 student_identifier = request.POST.get('unique_student_identifier', None)
 student = None
 if (student_identifier is not None):
  student = get_student_from_identifier(student_identifier)
 all_students = _get_boolean_param(request, 'all_students')
 only_if_higher = _get_boolean_param(request, 'only_if_higher')
 if (not (problem_to_reset and (all_students or student))):
  return HttpResponseBadRequest('Missing query parameters.')
 if (all_students and student):
  return HttpResponseBadRequest('Cannot rescore with all_students and unique_student_identifier.')
 try:
  module_state_key = course_id.make_usage_key_from_deprecated_string(problem_to_reset)
 except InvalidKeyError:
  return HttpResponseBadRequest('Unable to parse problem id')
 response_payload = {'problem_to_reset': problem_to_reset}
 if student:
  response_payload['student'] = student_identifier
  lms.djangoapps.instructor_task.api.submit_rescore_problem_for_student(request, module_state_key, student, only_if_higher)
 elif all_students:
  lms.djangoapps.instructor_task.api.submit_rescore_problem_for_all_students(request, module_state_key, only_if_higher)
 else:
  return HttpResponseBadRequest()
 response_payload['task'] = 'created'
 return JsonResponse(response_payload)

@ transaction . non_atomic_requests @ require_POST @ ensure_csrf_cookie @ cache_control ( no_cache = True , no_store = True , must_revalidate = True ) @ require_level ( 'instructor' ) @ require_post_params ( problem_to_reset = 'problem urlname to reset' ) @ common_exceptions_400 def rescore_problem ( request , course_id ) : course_id = SlashSeparatedCourseKey . from_deprecated_string ( course_id ) problem_to_reset = strip_if_string ( request . POST . get ( 'problem_to_reset' ) ) student_identifier = request . POST . get ( 'unique_student_identifier' , None ) student = None if ( student_identifier is not None ) : student = get_student_from_identifier ( student_identifier ) all_students = _get_boolean_param ( request , 'all_students' ) only_if_higher = _get_boolean_param ( request , 'only_if_higher' ) if ( not ( problem_to_reset and ( all_students or student ) ) ) : return HttpResponseBadRequest ( 'Missing query parameters.' ) if ( all_students and student ) : return HttpResponseBadRequest ( 'Cannot rescore with all_students and unique_student_identifier.' ) try : module_state_key = course_id . make_usage_key_from_deprecated_string ( problem_to_reset ) except InvalidKeyError : return HttpResponseBadRequest ( 'Unable to parse problem id' ) response_payload = { 'problem_to_reset' : problem_to_reset } if student : response_payload [ 'student' ] = student_identifier lms . djangoapps . instructor_task . api . submit_rescore_problem_for_student ( request , module_state_key , student , only_if_higher ) elif all_students : lms . djangoapps . instructor_task . api . submit_rescore_problem_for_all_students ( request , module_state_key , only_if_higher ) else : return HttpResponseBadRequest ( ) response_payload [ 'task' ] = 'created' return JsonResponse ( response_payload )
rescores a problem in a course .