@@ -828,7 +828,7 @@ def test_grades_1(runestone_db_tools, test_user, tmp_path):
828828 test_user (
829829 "test_user_{}" .format (index ), "x" , course , last_name = "user_{}" .format (index )
830830 )
831- for index in range (3 )
831+ for index in range (4 )
832832 ]
833833
834834 def assert_passing (index , * args , ** kwargs ):
@@ -850,10 +850,10 @@ def assert_passing(index, *args, **kwargs):
850850 unittest_kwargs = dict (event = "unittest" , div_id = "units2" , course = course_name )
851851
852852 # *User 0*: no data supplied
853- # ----------------------------
853+ ## ----------------------------
854854
855855 # *User 1*: correct answers
856- # ---------------------------
856+ ## ---------------------------
857857 # It doesn't matter which user logs out, since all three users share the same client.
858858 logout = test_user_array [2 ].test_client .logout
859859 logout ()
@@ -867,7 +867,7 @@ def assert_passing(index, *args, **kwargs):
867867 assert_passing (1 , act = "percent:100:passed:2:failed:0" , ** unittest_kwargs )
868868
869869 # *User 2*: incorrect answers
870- # ----------------------------
870+ ## ----------------------------
871871 logout ()
872872 test_user_array [2 ].login ()
873873 # Add three shortanswer answers, to make sure the number of attempts is correctly recorded.
@@ -880,8 +880,12 @@ def assert_passing(index, *args, **kwargs):
880880 )
881881 assert_passing (2 , act = "percent:50:passed:1:failed:1" , ** unittest_kwargs )
882882
883+ # *User 3*: no data supplied, and no longer in course.
884+ ##----------------------------------------------------
885+ # Wait until the autograder is run to remove the student, so they will have a grade but not have any submissions.
886+
883887 # **Test the grades_report endpoint**
884- # ====================================
888+ ## ====================================
885889 tu = test_user_array [2 ]
886890
887891 def grades_report (assignment , * args , ** kwargs ):
@@ -934,8 +938,22 @@ def add_to_assignment(question_kwargs, points):
934938 tu .test_client .validate ("assignments/calculate_totals" , ** assignment_kwargs )
935939 )["success" ]
936940
941+ # Remove test user 3 from the course. They can't be removed from the current course, so create a new one then add this user to it.
942+ logout ()
943+ tu = test_user_array [3 ]
944+ tu .login ()
945+ new_course = runestone_db_tools .create_course ("random_course_name" )
946+ tu .update_profile (course_name = new_course .course_name , is_free = True )
947+ tu .coursechooser (new_course .course_name )
948+ tu .removecourse (course_name )
949+
937950 # **Test this assignment.**
938951 # ===========================
952+ # Log back in as the instructor.
953+ logout ()
954+ tu = test_user_array [2 ]
955+ tu .login ()
956+ # Now, we can get the report.
939957 grades = json .loads (grades_report (assignment_name ))
940958
941959 # Define a regex string comparison.
@@ -1017,18 +1035,20 @@ def __eq__(self, other):
10171035 ["test_user_0" , "user_0" , "test" , "test_user_0@foo.com" , 0.0 ],
10181036 ["test_user_1" , "user_1" , "test" , "test_user_1@foo.com" , 1.0 ],
10191037 ["test_user_2" , "user_2" , "test" , "test_user_2@foo.com" , 0.2 ],
1038+ ["test_user_3" , "user_3" , "test" , "test_user_3@foo.com" , 0.0 ],
10201039 ],
10211040 # Correct since the first 3 questions are all on the index page.
10221041 "mergeCells" : [{"col" : 5 , "colspan" : 3 , "row" : 1 , "rowspan" : 1 }],
10231042 "orig_data" : [
10241043 # User 0: not submitted.
10251044 [
1026- # The format is: ``[timestamp, score, answer, correct, num_attempts]``.
1027- [None , 0.0 , None , None , None ],
1028- [None , 0.0 , None , None , None ],
1029- [None , 0.0 , None , None , None ],
1030- [None , 0.0 , {}, None , None ],
1031- [None , 0.0 , "" , None , None ],
1045+ # The format is:
1046+ # ``[timestamp, score, answer, correct, num_attempts]``.
1047+ [None , 0.0 , None , None , None ], # shortanswer
1048+ [None , 0.0 , None , None , None ], # fillintheblank
1049+ [None , 0.0 , None , None , None ], # mchoice
1050+ [None , 0.0 , {}, None , None ], # lp_build
1051+ [None , 0.0 , "" , None , None ], # activecode
10321052 ],
10331053 # User 1: all correct.
10341054 [
@@ -1069,10 +1089,19 @@ def __eq__(self, other):
10691089 ],
10701090 [AlmostNow (), 2.0 , "percent:50:passed:1:failed:1" , False , 1 ],
10711091 ],
1092+ # User 3: not submitted.
1093+ [
1094+ # The format is:
1095+ [None , 0.0 , None , None , None ],
1096+ [None , 0.0 , None , None , None ],
1097+ [None , 0.0 , None , None , None ],
1098+ [None , 0.0 , {}, None , None ],
1099+ [None , 0.0 , "" , None , None ],
1100+ ],
10721101 ],
10731102 }
10741103
1075- # Note: on test failure, pytest will report as incorrect all the ``AlmostNow()`` and ``RegexEquals`` items, even though they make have actually compared as equal.
1104+ # Note: on test failure, pytest will report as incorrect all the ``AlmostNow()`` and ``RegexEquals`` items, even though they may have actually compared as equal.
10761105 assert grades == expected_grades
10771106
10781107 logout ()
0 commit comments