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() pl = peer_grading_util.PeerLocation(LOCATION, STUDENT_ID) found, grading_item = pl.next_item() self.assertEqual(found, True) pl = peer_grading_util.PeerLocation(LOCATION,"1") subs_graded = pl.graded()
def test_get_peer_grading_notifications(self): test_sub = test_util.get_sub("PE", ALTERNATE_STUDENT, LOCATION, "PE") test_sub.save() handle_submission(test_sub) test_sub.next_grader_type = "PE" test_sub.is_duplicate = False test_sub.save() test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub.save() handle_submission(test_sub) test_sub.next_grader_type = "PE" test_sub.is_duplicate = False test_sub.save() success, student_needs_to_peer_grade = peer_grading_util.get_peer_grading_notifications(COURSE_ID, ALTERNATE_STUDENT) self.assertEqual(success, True) self.assertEqual(student_needs_to_peer_grade, True)
def test_get_peer_grading_notifications(self): test_sub = test_util.get_sub("PE", ALTERNATE_STUDENT, LOCATION, "PE") test_sub.save() handle_submission(test_sub) test_sub.next_grader_type = "PE" test_sub.is_duplicate = False test_sub.save() test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub.save() handle_submission(test_sub) test_sub.next_grader_type = "PE" test_sub.is_duplicate = False test_sub.save() pc = peer_grading_util.PeerCourse(COURSE_ID, ALTERNATE_STUDENT) success, student_needs_to_peer_grade = pc.notifications() self.assertEqual(success, True) self.assertEqual(student_needs_to_peer_grade, True)
def test_subs_to_peer_grading(self): submission = test_util.get_sub( "BC", STUDENT_ID, LOCATION, course_id=COURSE_ID, preferred_grader_type="PE", student_response="This is answer." ) submission.preferred_grader_type = "NA" submission.save() handle_submission(submission) submission = Submission.objects.get(id=submission.id) self.assertEqual( submission.state, SubmissionState.waiting_to_be_graded ) self.assertEqual(submission.preferred_grader_type, "PE") self.assertEqual(submission.next_grader_type, "IN") # Skipping submission from instructor to ML. set_instructor_grading_item_back_to_preferred_grader(submission.id) submission = Submission.objects.get(id=submission.id) submission.next_grader_type = "ML" submission.save() # Divert skipped submission to peer grading. update_subs_skipped_by_instructor(COURSE_ID, dry_run=False) # Next grader type should be PE. submission = Submission.objects.get(id=submission.id) self.assertEqual(submission.next_grader_type, "PE") peer_location = PeerLocation(student_id="123", location=LOCATION) pending_submissions = peer_location.pending() self.assertEqual(pending_submissions.count(), 1)
def handle(self, *args, **options): """ Read from file """ if len(args) != 2: raise Exception("Not enough input arguments!") number, location = args number = int(number) valid_location_dicts = Submission.objects.all().values( 'location').distinct() valid_locations = [vld['location'] for vld in valid_location_dicts] if location not in valid_locations: raise Exception( "Cannot find location in the available locations. Available locations are: {0}" .format(valid_locations)) if number < COUNT_MIN or number > COUNT_MAX: raise Exception( "Input number is too large or too small. Must be over {0} and under {1}." .format(COUNT_MIN, COUNT_MAX)) sub_count = Submission.objects.filter(location=location).count() if number >= sub_count: raise Exception( "You specified too high a number of copies. Only {0} submissions exist for location {1}." .format(sub_count, location)) slice_start = random.randint(0, sub_count - number - 1) subs = Submission.objects.filter( location=location)[slice_start:(slice_start + number)] last_sub = Submission.objects.filter( location=location).order_by('-date_modified')[0] preferred_grader_type = last_sub.preferred_grader_type log.info( "Copying {0} submissions from location {1}. Starting from number {2}." .format(number, location, slice_start)) for sub in subs: #Set these to none to copy the submission sub.pk = None sub.id = None #Reset basic information sub.student_id = COPIED_STUDENT_ID sub.state = SubmissionState.waiting_to_be_graded if sub.preferred_grader_type == "NA": sub.preferred_grader_type = preferred_grader_type if sub.preferred_grader_type == "IN": sub.preferred_grader_type = preferred_grader_type if sub.grader_settings == "": sub.grader_settings = GRADER_SETTINGS[ sub.preferred_grader_type] sub.previous_grader_type = "NA" sub.next_grader_type = "BC" sub.xqueue_submission_id = "" sub.xqueue_submission_key = "" sub.skip_basic_checks = False sub.save() #Run basic checks on the sub handle_submission(sub) #Ensure that submission is not marked as a duplicate sub.is_duplicate = False sub.is_plagiarized = False sub.duplicate_submission_id = None sub.save() log.info("Done copying submissions.") transaction.commit_unless_managed()
def handle(self, *args, **options): """ Read from file """ if len(args)!=2: raise Exception("Not enough input arguments!") number, location= args number = int(number) valid_location_dicts = Submission.objects.all().values('location').distinct() valid_locations = [vld['location'] for vld in valid_location_dicts] if location not in valid_locations: raise Exception("Cannot find location in the available locations. Available locations are: {0}".format(valid_locations)) if number < COUNT_MIN or number> COUNT_MAX: raise Exception("Input number is too large or too small. Must be over {0} and under {1}.".format(COUNT_MIN, COUNT_MAX)) sub_count = Submission.objects.filter(location=location).count() if number >= sub_count: raise Exception("You specified too high a number of copies. Only {0} submissions exist for location {1}.".format(sub_count, location)) slice_start = random.randint(0, sub_count - number -1) subs = Submission.objects.filter(location=location)[slice_start:(slice_start+number)] last_sub = Submission.objects.filter(location=location).order_by('-date_modified')[0] preferred_grader_type = last_sub.preferred_grader_type log.info("Copying {0} submissions from location {1}. Starting from number {2}.".format(number, location, slice_start)) for sub in subs: #Set these to none to copy the submission sub.pk = None sub.id = None #Reset basic information sub.student_id = COPIED_STUDENT_ID sub.state = SubmissionState.waiting_to_be_graded if sub.preferred_grader_type == "NA": sub.preferred_grader_type = preferred_grader_type if sub.preferred_grader_type == "IN": sub.preferred_grader_type = preferred_grader_type if sub.grader_settings == "": sub.grader_settings = GRADER_SETTINGS[sub.preferred_grader_type] sub.previous_grader_type = "NA" sub.next_grader_type = "BC" sub.xqueue_submission_id = "" sub.xqueue_submission_key = "" sub.skip_basic_checks = False sub.save() #Run basic checks on the sub handle_submission(sub) #Ensure that submission is not marked as a duplicate sub.is_duplicate = False sub.is_plagiarized = False sub.duplicate_submission_id = None sub.save() log.info("Done copying submissions.") transaction.commit_unless_managed()