def test_get_single_peer_grading_item(self): for i in xrange(0,settings.MIN_TO_USE_PEER): test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub.save() handle_submission(test_sub) test_grader = test_util.get_grader("IN") test_grader.submission=test_sub test_grader.save() test_sub.state = SubmissionState.finished test_sub.previous_grader_type = "IN" test_sub.posted_results_back_to_queue = True test_sub.save() test_sub = test_util.get_sub("PE", ALTERNATE_STUDENT, LOCATION, "PE") test_sub.save() handle_submission(test_sub) test_sub.is_duplicate = False test_sub.save() found, grading_item = peer_grading_util.get_single_peer_grading_item(LOCATION, STUDENT_ID) log.info(grading_item) self.assertEqual(found, True) subs_graded = peer_grading_util.peer_grading_submissions_graded_for_location(LOCATION,"1")
def test_get_single_peer_grading_item(self): for i in xrange(0, settings.MIN_TO_USE_PEER): test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub.save() handle_submission(test_sub) test_grader = test_util.get_grader("IN") test_grader.submission = test_sub test_grader.save() test_sub.state = SubmissionState.finished test_sub.previous_grader_type = "IN" test_sub.posted_results_back_to_queue = True test_sub.save() test_sub = test_util.get_sub("PE", ALTERNATE_STUDENT, LOCATION, "PE") test_sub.save() handle_submission(test_sub) test_sub.is_duplicate = False test_sub.save() found, grading_item = peer_grading_util.get_single_peer_grading_item( LOCATION, STUDENT_ID) log.info(grading_item) self.assertEqual(found, True) subs_graded = peer_grading_util.peer_grading_submissions_graded_for_location( LOCATION, "1")
def get_next_submission(request): """ Gets next submission from controller for peer grading. Input: Get request with the following keys: grader_id - Student id of the grader location - The problem id to get peer grading for. """ if request.method != "GET": log.debug("Improper request method") raise Http404 grader_id = request.GET.get("grader_id") location = request.GET.get("location") if not grader_id or not location: error_message = "Failed to find needed keys 'grader_id' and 'location'" log.debug(error_message) return util._error_response(error_message, _INTERFACE_VERSION) (found, sub_id) = peer_grading_util.get_single_peer_grading_item( location, grader_id) if not found: error_message = "You have completed all of the existing peer grading or there are no more submissions waiting to be peer graded." log.debug(error_message) return util._error_response(error_message, _INTERFACE_VERSION) try: sub = Submission.objects.get(id=int(sub_id)) except: log.debug("Could not find submission with id {0}".format(sub_id)) return util._error_response("Error getting grading.", _INTERFACE_VERSION) if sub.state != SubmissionState.being_graded: log.debug( "Submission with id {0} has incorrect internal state {1}.".format( sub_id, sub.state)) return util._error_response("Error getting grading.", _INTERFACE_VERSION) response = { 'submission_id': sub_id, 'submission_key': sub.xqueue_submission_key, 'student_response': sub.student_response, 'prompt': sub.prompt, 'rubric': sub.rubric, 'max_score': sub.max_score, } #log.debug(response) return util._success_response(response, _INTERFACE_VERSION)
def get_next_submission(request): """ Gets next submission from controller for peer grading. Input: Get request with the following keys: grader_id - Student id of the grader location - The problem id to get peer grading for. """ if request.method != "GET": log.debug("Improper request method") raise Http404 grader_id = request.GET.get("grader_id") location = request.GET.get("location") if not grader_id or not location: error_message="Failed to find needed keys 'grader_id' and 'location'" log.debug(error_message) return util._error_response(error_message, _INTERFACE_VERSION) (found, sub_id) = peer_grading_util.get_single_peer_grading_item(location, grader_id) if not found: error_message="You have completed all of the existing peer grading or there are no more submissions waiting to be peer graded." log.debug(error_message) return util._error_response(error_message, _INTERFACE_VERSION) try: sub = Submission.objects.get(id=int(sub_id)) except: log.debug("Could not find submission with id {0}".format(sub_id)) return util._error_response("Error getting grading.", _INTERFACE_VERSION) if sub.state != SubmissionState.being_graded: log.debug("Submission with id {0} has incorrect internal state {1}.".format(sub_id, sub.state)) return util._error_response("Error getting grading.", _INTERFACE_VERSION) response = { 'submission_id': sub_id, 'submission_key': sub.xqueue_submission_key, 'student_response': sub.student_response, 'prompt': sub.prompt, 'rubric': sub.rubric, 'max_score': sub.max_score, } #log.debug(response) return util._success_response(response, _INTERFACE_VERSION)