|
| 1 | +import datetime |
| 2 | + |
1 | 3 | # |
2 | 4 | # Unit Tests for DASHBOARD API endpoints |
3 | 5 | # Set up the environment variables |
@@ -97,6 +99,97 @@ def test_exercisemetrics(test_client, runestone_db_tools, test_user, test_user_1 |
97 | 99 | ) |
98 | 100 |
|
99 | 101 |
|
| 102 | +def test_grades(test_client, runestone_db_tools, test_user): |
| 103 | + course_4 = runestone_db_tools.create_course("test_course_1") |
| 104 | + test_student_1 = test_user("test_student_1", "password_1", course_4) |
| 105 | + test_student_1.logout() |
| 106 | + test_instructor_1 = test_user("test_instructor_1", "password_1", course_4) |
| 107 | + test_instructor_1.make_instructor() |
| 108 | + test_instructor_1.login() |
| 109 | + db = runestone_db_tools.db |
| 110 | + |
| 111 | + course_start_date = datetime.datetime.strptime( |
| 112 | + course_4.term_start_date, "%Y-%m-%d" |
| 113 | + ).date() |
| 114 | + |
| 115 | + start_date = course_start_date + datetime.timedelta(days=13) |
| 116 | + end_date = datetime.datetime.today().date() + datetime.timedelta(days=30) |
| 117 | + max_practice_days = 40 |
| 118 | + max_practice_questions = 400 |
| 119 | + day_points = 1 |
| 120 | + question_points = 0.2 |
| 121 | + questions_to_complete_day = 5 |
| 122 | + graded = 0 |
| 123 | + |
| 124 | + # set up practice - similar to test_instructor_practice_admin |
| 125 | + test_client.post( |
| 126 | + "admin/practice", |
| 127 | + data={ |
| 128 | + "StartDate": start_date, |
| 129 | + "EndDate": end_date, |
| 130 | + "graded": graded, |
| 131 | + "maxPracticeDays": max_practice_days, |
| 132 | + "maxPracticeQuestions": max_practice_questions, |
| 133 | + "pointsPerDay": day_points, |
| 134 | + "pointsPerQuestion": question_points, |
| 135 | + "questionsPerDay": questions_to_complete_day, |
| 136 | + "flashcardsCreationType": 2, |
| 137 | + "question_points": question_points, |
| 138 | + }, |
| 139 | + ) |
| 140 | + |
| 141 | + test_client.validate("dashboard/grades",) |
| 142 | + |
| 143 | + assert "Gradebook" in test_client.text |
| 144 | + |
| 145 | + |
| 146 | +def test_questiongrades_redirect( |
| 147 | + test_client, runestone_db_tools, test_user, test_user_1 |
| 148 | +): |
| 149 | + course_3 = runestone_db_tools.create_course( |
| 150 | + "test_course_3", base_course="test_course_1" |
| 151 | + ) |
| 152 | + test_instructor_1 = test_user("test_instructor_1", "password_1", course_3) |
| 153 | + test_instructor_1.make_instructor() |
| 154 | + |
| 155 | + test_instructor_1.login() |
| 156 | + |
| 157 | + test_client.validate("dashboard/questiongrades",) |
| 158 | + |
| 159 | + assert "Cannot call questiongrades directly" in test_client.text |
| 160 | + |
| 161 | + |
| 162 | +def test_questiongrades(test_assignment, test_client, test_user, test_user_1): |
| 163 | + # make a dummy student to do work |
| 164 | + student1 = test_user("student1", "password", test_user_1.course) |
| 165 | + student1.logout() |
| 166 | + |
| 167 | + test_user_1.make_instructor() |
| 168 | + test_user_1.login() |
| 169 | + |
| 170 | + # make dummy assignment |
| 171 | + my_ass = test_assignment("test_assignment", test_user_1.course) |
| 172 | + assignment_id = my_ass.assignment_id |
| 173 | + my_ass.addq_to_assignment(question="subc_b_fitb", points=10) |
| 174 | + my_ass.save_assignment() |
| 175 | + |
| 176 | + # record a grade for that student on an assignment |
| 177 | + sid = student1.username |
| 178 | + acid = "subc_b_fitb" |
| 179 | + grade = 5 |
| 180 | + comment = "OK job" |
| 181 | + res = test_client.validate( |
| 182 | + "assignments/record_grade", |
| 183 | + data=dict(sid=sid, acid=acid, grade=grade, comment=comment), |
| 184 | + ) |
| 185 | + |
| 186 | + res = test_user_1.test_client.validate( |
| 187 | + "dashboard/questiongrades", |
| 188 | + "Click on the question name to display or update the grade for any question.", |
| 189 | + data=dict(sid=sid, assignment_id=assignment_id), |
| 190 | + ) |
| 191 | + |
| 192 | + |
100 | 193 | # TODO: |
101 | 194 | # grades |
102 | 195 | # questiongrades |
|
0 commit comments