def test_get_next_submission_true(self): test_sub = test_util.get_sub("PE", "1", LOCATION, "PE") test_sub.save() grader = test_util.get_grader("BC") grader.submission = test_sub grader.grader_id = "2" grader.save() for i in xrange(0,settings.MIN_TO_USE_PEER): test_sub = test_util.get_sub("PE", "1", LOCATION, "PE") test_sub.save() grader = test_util.get_grader("IN") grader.submission = test_sub grader.save() test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub.save() content = self.c.get( GET_NEXT, data={'grader_id' : STUDENT_ID, "location" : LOCATION}, ) body = json.loads(content.content) self.assertEqual(body['success'], True)
def test_submission_location(self): Submission.objects.all().delete() test_sub = test_util.get_sub("IN", STUDENT_ID, LOCATION) test_sub.save() test_sub2 = test_util.get_sub("PE", STUDENT_ID, LOCATION) test_sub2.state = SubmissionState.finished test_sub2.previous_grader_type = "PE" test_sub2.save() test_grader_in = test_util.get_grader("IN") test_grader_in.submission = test_sub2 test_grader_in.save() test_grader_pe = test_util.get_grader("PE") test_grader_pe.submission = test_sub2 test_grader_pe.save() sl = StaffLocation(LOCATION) self.assertEqual(sl.location_submissions().count(), 2) self.assertEqual(sl.all_pending_count(), 1) self.assertEqual(sl.graded_count(), 1) self.assertEqual(sl.pending_count(), 1) self.assertEqual(len(sl.graded_submission_text()), 1) test_sub2.delete() next_item_id = sl.item_to_score()[1] self.assertEqual(next_item_id, test_sub.id) test_sub = Submission.objects.get(id=next_item_id) self.assertEqual(test_sub.state, SubmissionState.being_graded) test_sub.state = SubmissionState.waiting_to_be_graded test_sub.save() self.assertEqual(sl.next_item()[1], test_sub.id)
def test_get_next_submission_true(self): test_sub = test_util.get_sub("PE", "1", LOCATION, "PE") test_sub.save() grader = test_util.get_grader("BC") grader.submission = test_sub grader.grader_id = "2" grader.save() pl = peer_grading_util.PeerLocation(LOCATION, "1") control = SubmissionControl(pl.latest_submission()) for i in xrange(0, control.minimum_to_use_peer): test_sub = test_util.get_sub("PE", "1", LOCATION, "PE") test_sub.save() grader = test_util.get_grader("IN") grader.submission = test_sub grader.save() test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub.save() content = self.c.get( GET_NEXT, data={'grader_id' : STUDENT_ID, "location" : LOCATION}, ) body = json.loads(content.content) self.assertEqual(body['success'], True)
def test_submission_course(self): Submission.objects.all().delete() test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, preferred_grader_type="PE") test_sub.save() test_grader = test_util.get_grader("BC") test_grader.submission = test_sub test_grader.save() test_sub2 = test_util.get_sub("PE", ALTERNATE_STUDENT, LOCATION, preferred_grader_type="PE") test_sub2.save() test_grader2 = test_util.get_grader("BC") test_grader2.submission = test_sub2 test_grader2.save() sc = peer_grading_util.PeerCourse(COURSE_ID, STUDENT_ID) success, needs_to_grade = sc.notifications() self.assertTrue(needs_to_grade) self.assertEqual(sc.submitted().count(), 1)
def test_submission_location(self): Submission.objects.all().delete() test_sub=test_util.get_sub("IN",STUDENT_ID, LOCATION) test_sub.save() test_sub2=test_util.get_sub("PE",STUDENT_ID, LOCATION) test_sub2.state = SubmissionState.finished test_sub2.previous_grader_type = "PE" test_sub2.save() test_grader_in=test_util.get_grader("IN") test_grader_in.submission=test_sub2 test_grader_in.save() test_grader_pe=test_util.get_grader("PE") test_grader_pe.submission=test_sub2 test_grader_pe.save() sl = StaffLocation(LOCATION) self.assertEqual(sl.location_submissions().count(),2) self.assertEqual(sl.all_pending_count(),1) self.assertEqual(sl.graded_count(),1) self.assertEqual(sl.pending_count(),1) self.assertEqual(len(sl.graded_submission_text()),1) test_sub2.delete() next_item_id = sl.item_to_score()[1] self.assertEqual(next_item_id ,test_sub.id) test_sub = Submission.objects.get(id=next_item_id) self.assertEqual(test_sub.state,SubmissionState.being_graded) test_sub.state = SubmissionState.waiting_to_be_graded test_sub.save() self.assertEqual(sl.next_item()[1],test_sub.id)
def test_get_next_submission_true(self): test_sub = test_util.get_sub("PE", "1", LOCATION, "PE") test_sub.save() grader = test_util.get_grader("BC") grader.submission = test_sub grader.grader_id = "2" grader.save() pl = peer_grading_util.PeerLocation(LOCATION, "1") control = SubmissionControl(pl.latest_submission()) for i in xrange(0, control.minimum_to_use_peer): test_sub = test_util.get_sub("PE", "1", LOCATION, "PE") test_sub.save() grader = test_util.get_grader("IN") grader.submission = test_sub grader.save() test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub.save() content = self.c.get( GET_NEXT, data={ 'grader_id': STUDENT_ID, "location": LOCATION }, ) body = json.loads(content.content) self.assertEqual(body['success'], True)
def test_get_next_get_finished_subs(self): Submission.objects.all().delete() all_students = [STUDENT_ID, ALTERNATE_STUDENT, STUDENT3] # setup 3 submissions from 3 students, passed basic check submissions = [] for student in all_students: test_sub = test_util.get_sub("PE", student, LOCATION, preferred_grader_type="PE") test_sub.next_grader_type="PE" test_sub.is_duplicate=False test_sub.save() submissions.append(test_sub) bc_grader = test_util.get_grader("BC") bc_grader.submission = test_sub bc_grader.save() # have them each grade the other two and call that finished for student in all_students: for submission in Submission.objects.all().exclude(student_id=student): test_grader = test_util.get_grader("PE") test_grader.grader_id = student test_grader.submission = submission test_grader.save() for sub in submissions: sub.state = SubmissionState.finished sub.posted_results_back_to_queue = True sub.save() pls = [] for student in all_students: pls.append(peer_grading_util.PeerLocation(LOCATION, student)) # check that each student graded 2, and so no submissions are pending for pl in pls: self.assertEqual(pl.graded_count(),2) self.assertEqual(pl.pending_count(),0) # check that next_item() cannot returns a submission because each of these students # has graded the submissions by the other 2 students found, _ = pl.next_item() self.assertFalse(found) # now a 4th student comes along and submits. They should get something to grade despite nothing pending student4 = "10" test_sub = test_util.get_sub("PE", student4, LOCATION, preferred_grader_type="PE") test_sub.next_grader_type="PE" test_sub.is_duplicate=False test_sub.control_fields=json.dumps({'peer_grade_finished_submissions_when_none_pending': True}) test_sub.save() pl4 = peer_grading_util.PeerLocation(LOCATION, student4) self.assertEqual(pl4.pending_count(),0) found, next_sub_id = pl4.next_item() self.assertTrue(found) student4_sub_to_grade = Submission.objects.get(id=next_sub_id) self.assertIn(student4_sub_to_grade, submissions) self.assertEqual(student4_sub_to_grade.state, SubmissionState.being_graded)
def _message_submission(self, success, score=None, submission_id=None): sub = test_util.get_sub("IN", STUDENT_ID, LOCATION) sub.save() grade = test_util.get_grader("IN") grade.submission = sub grade.save() grader_id = grade.grader_id if submission_id is None: submission_id = sub.id message = { 'grader_id': grader_id, 'submission_id': submission_id, 'feedback': "This is test feedback", 'student_info': test_util.get_student_info(STUDENT_ID), } if score is not None: message['score'] = score content = { 'xqueue_header': test_util.get_xqueue_header(), 'xqueue_body': json.dumps(message), } content = self.c.post(SUBMIT_MESSAGE_URL, content) body = json.loads(content.content) self.assertEqual(body['success'], success)
def test_unicode_rubric(self): test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE", rubric=UNICODE_RUBRIC_XML) test_sub.save() scores = [0, 1] for i in xrange(0, settings.PEER_GRADER_COUNT): grader = test_util.get_grader("PE") grader.submission = test_sub grader.save() success, rubric = rubric_functions.generate_rubric_object( grader, scores, UNICODE_RUBRIC_XML) self.assertEqual(success, True) rubric.save() test_sub.state = "F" test_sub.previous_grader_type = "PE" test_sub.save() all_graders = test_sub.get_all_successful_scores_and_feedback() self.assertEqual(all_graders['grader_type'], "PE")
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 _message_submission(self, success, score=None, submission_id=None): sub = test_util.get_sub("IN",STUDENT_ID,LOCATION) sub.save() grade=test_util.get_grader("IN") grade.submission=sub grade.save() grader_id = grade.grader_id if submission_id is None: submission_id = sub.id message = { 'grader_id': grader_id, 'submission_id': submission_id, 'feedback': "This is test feedback", 'student_info': test_util.get_student_info(STUDENT_ID), } if score is not None: message['score'] = score content = { 'xqueue_header': test_util.get_xqueue_header(), 'xqueue_body': json.dumps(message), } content = self.c.post( SUBMIT_MESSAGE_URL, content ) body = json.loads(content.content) self.assertEqual(body['success'], success)
def test_course_data_real(self): """ Test to ensure that generating data for a course results in proper csv output. """ submission_count = 100 # Generate our submissions and grade them. for i in xrange(0, submission_count): sub = test_util.get_sub("IN", STUDENT_ID, LOCATION, course_id=COURSE) sub.save() grade = test_util.get_grader("IN") grade.submission = sub grade.save() # Generate the data file and get the filename. data_filename = self.get_course_data_file(COURSE) with open(data_filename, 'rb') as data_file: # Ensure that we have data. data = data_file.read() self.assertGreater(len(data), 0) data_file.seek(0) reader = csv.reader(data_file, delimiter=',', doublequote=True, quoting=csv.QUOTE_MINIMAL) rows = [] for row in reader: rows.append(row) # The number of rows should equal the number of submissions plus one for the header row. self.assertEqual(len(rows), submission_count + 1)
def test_create_xqueue_header_and_body(self): test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub.save() grader = test_util.get_grader("BC", status_code = GraderStatus.failure) grader.submission = test_sub grader.save() xqueue_header, xqueue_body = util.create_xqueue_header_and_body(test_sub) self.assertIsInstance(xqueue_header, dict) self.assertIsInstance(xqueue_body, dict)
def test_submission_location_rescore(self): Submission.objects.all().delete() test_sub=test_util.get_sub("IN",STUDENT_ID, LOCATION) test_sub.save() test_grader = test_util.get_grader("BC") test_grader.submission = test_sub test_grader.save() test_grader = test_util.get_grader("ML") test_grader.submission = test_sub test_grader.save() sl = StaffLocation(LOCATION) rescore = sl.item_to_rescore()[1] self.assertEqual(rescore,test_sub.id)
def test_submission_location_rescore(self): Submission.objects.all().delete() test_sub = test_util.get_sub("IN", STUDENT_ID, LOCATION) test_sub.save() test_grader = test_util.get_grader("BC") test_grader.submission = test_sub test_grader.save() test_grader = test_util.get_grader("ML") test_grader.submission = test_sub test_grader.save() sl = StaffLocation(LOCATION) rescore = sl.item_to_rescore()[1] self.assertEqual(rescore, test_sub.id)
def test_submission_location(self): Submission.objects.all().delete() test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, preferred_grader_type="PE") test_sub.save() test_grader = test_util.get_grader("BC") test_grader.submission = test_sub test_grader.save() pl = peer_grading_util.PeerLocation(LOCATION, STUDENT_ID) self.assertEqual(pl.submitted_count(), 1) self.assertEqual(pl.required_count(), settings.REQUIRED_PEER_GRADING_PER_STUDENT) test_sub2 = test_util.get_sub("PE", ALTERNATE_STUDENT, LOCATION, preferred_grader_type="PE") test_sub2.save() test_grader2 = test_util.get_grader("BC") test_grader2.submission = test_sub2 test_grader2.save() self.assertEqual(pl.pending_count(), 1) found, next_item_id = pl.next_item() self.assertEqual(next_item_id, test_sub2.id) test_sub2 = Submission.objects.get(id=next_item_id) self.assertEqual(SubmissionState.being_graded, test_sub2.state) test_grader3 = test_util.get_grader("PE") test_grader3.submission = test_sub2 test_grader3.grader_id = STUDENT_ID test_grader3.save() self.assertEqual(pl.graded_count(), 1) self.assertEqual(pl.pending_count(), 0)
def test_submission_course(self): Submission.objects.all().delete() test_sub=test_util.get_sub("PE",STUDENT_ID, LOCATION, preferred_grader_type="PE") test_sub.save() test_grader = test_util.get_grader("BC") test_grader.submission = test_sub test_grader.save() test_sub2=test_util.get_sub("PE",ALTERNATE_STUDENT, LOCATION, preferred_grader_type="PE") test_sub2.save() test_grader2 = test_util.get_grader("BC") test_grader2.submission = test_sub2 test_grader2.save() sc = peer_grading_util.PeerCourse(COURSE_ID, STUDENT_ID) success, needs_to_grade = sc.notifications() self.assertTrue(needs_to_grade) self.assertEqual(sc.submitted().count(),1)
def test_get_duplicate_scores_and_feedback(self): """ Want to test that a submission with a single BC grade returns that grade, but a submission with BCs and multiple PEs returns the PE grade set (this situation happens with duplicates) """ sub1 = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") sub1.save() sub1_bc = test_util.get_grader("BC", score=1) sub1_bc.submission = sub1 sub1_bc.save() sub2 = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") sub2.is_duplicate_checked = True sub2.state = "F" sub2.save() sub2_bc = test_util.get_grader("BC", score=1) sub2_bc.submission = sub2 sub2_bc.save() for pe_score in [2, 3, 4]: pe = test_util.get_grader("PE", score=pe_score) pe.submission = sub2 pe.save() dup2 = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") dup2.is_duplicate = True dup2.duplicate_submission_id = sub2.id dup2.save() expire_submissions.check_if_grading_finished_for_duplicates() fb1 = sub1.get_all_successful_scores_and_feedback() fb2 = sub2.get_all_successful_scores_and_feedback() fb_dup2 = dup2.get_all_successful_scores_and_feedback() self.assertEquals(fb1['score'], 1) self.assertEquals(set(fb2['score']), set([2,3,4])) self.assertEquals(set(fb_dup2['score']), set([2,3,4]))
def test_get_duplicate_scores_and_feedback(self): """ Want to test that a submission with a single BC grade returns that grade, but a submission with BCs and multiple PEs returns the PE grade set (this situation happens with duplicates) """ sub1 = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") sub1.save() sub1_bc = test_util.get_grader("BC", score=1) sub1_bc.submission = sub1 sub1_bc.save() sub2 = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") sub2.is_duplicate_checked = True sub2.state = "F" sub2.save() sub2_bc = test_util.get_grader("BC", score=1) sub2_bc.submission = sub2 sub2_bc.save() for pe_score in [2, 3, 4]: pe = test_util.get_grader("PE", score=pe_score) pe.submission = sub2 pe.save() dup2 = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") dup2.is_duplicate = True dup2.duplicate_submission_id = sub2.id dup2.save() expire_submissions.check_if_grading_finished_for_duplicates() fb1 = sub1.get_all_successful_scores_and_feedback() fb2 = sub2.get_all_successful_scores_and_feedback() fb_dup2 = dup2.get_all_successful_scores_and_feedback() self.assertEquals(fb1['score'], 1) self.assertEquals(set(fb2['score']), set([2, 3, 4])) self.assertEquals(set(fb_dup2['score']), set([2, 3, 4]))
def test_submission_location(self): Submission.objects.all().delete() test_sub=test_util.get_sub("PE",STUDENT_ID, LOCATION, preferred_grader_type="PE") test_sub.save() test_grader = test_util.get_grader("BC") test_grader.submission = test_sub test_grader.save() pl = peer_grading_util.PeerLocation(LOCATION,STUDENT_ID) self.assertEqual(pl.submitted_count(),1) self.assertEqual(pl.required_count(), settings.REQUIRED_PEER_GRADING_PER_STUDENT) test_sub2=test_util.get_sub("PE",ALTERNATE_STUDENT, LOCATION, preferred_grader_type="PE") test_sub2.save() test_grader2 = test_util.get_grader("BC") test_grader2.submission = test_sub2 test_grader2.save() self.assertEqual(pl.pending_count(),1) found, next_item_id = pl.next_item() self.assertEqual(next_item_id, test_sub2.id) test_sub2 = Submission.objects.get(id=next_item_id) self.assertEqual(SubmissionState.being_graded, test_sub2.state) test_grader3 = test_util.get_grader("PE") test_grader3.submission = test_sub2 test_grader3.grader_id = STUDENT_ID test_grader3.save() self.assertEqual(pl.graded_count(),1) self.assertEqual(pl.pending_count(),0)
def test_reset_failed_subs_in_basic_check(self): test_sub = test_util.get_sub("IN", STUDENT_ID, LOCATION) test_sub.save() grader = test_util.get_grader("BC", status_code = GraderStatus.failure) grader.submission = test_sub grader.save() success = expire_submissions.reset_failed_subs_in_basic_check() self.assertTrue(success) graders = test_sub.grader_set.all() success_grader = graders[1] self.assertEqual(success_grader.status_code, GraderStatus.success)
def test_reset_failed_subs_in_basic_check(self): test_sub = test_util.get_sub("IN", STUDENT_ID, LOCATION) test_sub.save() grader = test_util.get_grader("BC", status_code=GraderStatus.failure) grader.submission = test_sub grader.save() success = expire_submissions.reset_failed_subs_in_basic_check() self.assertTrue(success) graders = test_sub.grader_set.all() success_grader = graders[1] self.assertEqual(success_grader.status_code, GraderStatus.success)
def test_check_if_grading_finished_for_duplicates(self): test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub.save() handle_submission(test_sub) sl = StaffLocation(LOCATION) control = SubmissionControl(sl.latest_submission()) for i in xrange(0, control.minimum_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_sub2 = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub2.save() handle_submission(test_sub2) self.assertTrue(test_sub2.is_duplicate) success = expire_submissions.check_if_grading_finished_for_duplicates() self.assertEqual(success, True) test_sub2.is_duplicate = False test_sub2.save() test_sub3 = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub3.is_duplicate = False test_sub3.save() self.assertEqual(test_sub3.is_duplicate, False) test_sub3.has_been_duplicate_checked = False test_sub3.save() expire_submissions.mark_student_duplicate_submissions() test_sub3 = Submission.objects.get(id=test_sub3.id) self.assertEqual(test_sub3.is_duplicate,True) test_sub3.duplicate_submission_id = None test_sub3.is_plagiarized = False test_sub3.save() expire_submissions.add_in_duplicate_ids() test_sub3 = Submission.objects.get(id=test_sub3.id) self.assertTrue(test_sub3.duplicate_submission_id is not None)
def test_check_if_grading_finished_for_duplicates(self): test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub.save() handle_submission(test_sub) sl = StaffLocation(LOCATION) control = SubmissionControl(sl.latest_submission()) for i in xrange(0, control.minimum_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_sub2 = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub2.save() handle_submission(test_sub2) self.assertTrue(test_sub2.is_duplicate) success = expire_submissions.check_if_grading_finished_for_duplicates() self.assertEqual(success, True) test_sub2.is_duplicate = False test_sub2.save() test_sub3 = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub3.is_duplicate = False test_sub3.save() self.assertEqual(test_sub3.is_duplicate, False) test_sub3.has_been_duplicate_checked = False test_sub3.save() expire_submissions.mark_student_duplicate_submissions() test_sub3 = Submission.objects.get(id=test_sub3.id) self.assertEqual(test_sub3.is_duplicate, True) test_sub3.duplicate_submission_id = None test_sub3.is_plagiarized = False test_sub3.save() expire_submissions.add_in_duplicate_ids() test_sub3 = Submission.objects.get(id=test_sub3.id) self.assertTrue(test_sub3.duplicate_submission_id is not None)
def test_check_if_grading_finished_for_duplicates(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_sub2 = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub2.save() handle_submission(test_sub2) self.assertTrue(test_sub2.is_duplicate) success = expire_submissions.check_if_grading_finished_for_duplicates() self.assertEqual(success, True) test_sub2.is_duplicate = False test_sub2.save() test_sub3 = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub3.is_duplicate = False test_sub3.save() self.assertEqual(test_sub3.is_duplicate, False) expire_submissions.mark_student_duplicate_submissions() test_sub3 = Submission.objects.get(id=test_sub3.id) self.assertEqual(test_sub3.is_duplicate,True) test_sub3.duplicate_submission_id = None test_sub3.is_plagiarized = False test_sub3.save() expire_submissions.add_in_duplicate_ids() test_sub3 = Submission.objects.get(id=test_sub3.id) self.assertTrue(test_sub3.duplicate_submission_id is not None)
def test_unicode_rubric(self): test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE", rubric=UNICODE_RUBRIC_XML) test_sub.save() scores = [0,1] for i in xrange(0, settings.PEER_GRADER_COUNT): grader = test_util.get_grader("PE") grader.submission = test_sub grader.save() success, rubric = rubric_functions.generate_rubric_object(grader, scores, UNICODE_RUBRIC_XML) self.assertEqual(success, True) rubric.save() test_sub.state = "F" test_sub.previous_grader_type = "PE" test_sub.save() all_graders = test_sub.get_all_successful_scores_and_feedback() self.assertEqual(all_graders['grader_type'], "PE")
def _message_submission(self, success, score=None, submission_id=None): sub = test_util.get_sub("IN", STUDENT_ID, LOCATION) sub.save() grade = test_util.get_grader("IN") grade.submission = sub grade.save() grader_id = grade.grader_id if submission_id is None: submission_id = sub.id message = { "grader_id": grader_id, "submission_id": submission_id, "feedback": "This is test feedback", "student_info": test_util.get_student_info(STUDENT_ID), } if score is not None: message["score"] = score content = {"xqueue_header": test_util.get_xqueue_header(), "xqueue_body": json.dumps(message)} content = self.c.post(SUBMIT_MESSAGE_URL, content) body = json.loads(content.content) self.assertEqual(body["success"], success)
def test_get_next_get_finished_subs(self): Submission.objects.all().delete() all_students = [STUDENT_ID, ALTERNATE_STUDENT, STUDENT3] # setup 3 submissions from 3 students, passed basic check submissions = [] for student in all_students: test_sub = test_util.get_sub("PE", student, LOCATION, preferred_grader_type="PE") test_sub.next_grader_type = "PE" test_sub.is_duplicate = False test_sub.save() submissions.append(test_sub) bc_grader = test_util.get_grader("BC") bc_grader.submission = test_sub bc_grader.save() # have them each grade the other two and call that finished for student in all_students: for submission in Submission.objects.all().exclude( student_id=student): test_grader = test_util.get_grader("PE") test_grader.grader_id = student test_grader.submission = submission test_grader.save() for sub in submissions: sub.state = SubmissionState.finished sub.posted_results_back_to_queue = True sub.save() pls = [] for student in all_students: pls.append(peer_grading_util.PeerLocation(LOCATION, student)) # check that each student graded 2, and so no submissions are pending for pl in pls: self.assertEqual(pl.graded_count(), 2) self.assertEqual(pl.pending_count(), 0) # check that next_item() cannot returns a submission because each of these students # has graded the submissions by the other 2 students found, _ = pl.next_item() self.assertFalse(found) # now a 4th student comes along and submits. They should get something to grade despite nothing pending student4 = "10" test_sub = test_util.get_sub("PE", student4, LOCATION, preferred_grader_type="PE") test_sub.next_grader_type = "PE" test_sub.is_duplicate = False test_sub.control_fields = json.dumps( {'peer_grade_finished_submissions_when_none_pending': True}) test_sub.save() pl4 = peer_grading_util.PeerLocation(LOCATION, student4) self.assertEqual(pl4.pending_count(), 0) found, next_sub_id = pl4.next_item() self.assertTrue(found) student4_sub_to_grade = Submission.objects.get(id=next_sub_id) self.assertIn(student4_sub_to_grade, submissions) self.assertEqual(student4_sub_to_grade.state, SubmissionState.being_graded)