Beispiel #1
0
 def test_post_realistic(self):
     self.create_relatedstudent('student1')
     relatedStudent2 = self.create_relatedstudent('student2')
     relatedStudent3 = self.create_relatedstudent('student3')
     self.create_feedbacks( # student1 fails because the total points is 12 
         (self.testhelper.sub_p1_a1_gstudent1, {'grade': '1/10', 'points': 1, 'is_passing_grade': False}),
         (self.testhelper.sub_p1_a2_gstudent1, {'grade': '1/10', 'points': 1, 'is_passing_grade': True}),
         (self.testhelper.sub_p1_a3_gstudent1, {'grade': '10/10', 'points': 10, 'is_passing_grade': True}),
         (self.testhelper.sub_p1_a4_gstudent1, {'grade': '100/100', 'points': 100, 'is_passing_grade': True}) # this assignment is not included in the calculation
     )
     self.create_feedbacks( # student2 qualifies
         (self.testhelper.sub_p1_a1_gstudent2, {'grade': '10/10', 'points': 10, 'is_passing_grade': True}),
         (self.testhelper.sub_p1_a2_gstudent2, {'grade': '10/10', 'points': 10, 'is_passing_grade': True}),
         (self.testhelper.sub_p1_a3_gstudent2, {'grade': '10/10', 'points': 10, 'is_passing_grade': True}),
         (self.testhelper.sub_p1_a4_gstudent2, {'grade': '0/100', 'points': 0, 'is_passing_grade': False}) # this assignment is not included in the calculation
     )
     self.create_feedbacks( # student3 qualifies because he has 21 points (which is the lower limit)
         (self.testhelper.sub_p1_a1_gstudent3, {'grade': '10/10', 'points': 10, 'is_passing_grade': True}),
         (self.testhelper.sub_p1_a2_gstudent3, {'grade': '10/10', 'points': 10, 'is_passing_grade': True}),
         (self.testhelper.sub_p1_a3_gstudent3, {'grade': '1/10', 'points': 1, 'is_passing_grade': False}),
         (self.testhelper.sub_p1_a4_gstudent3, {'grade': '0/100', 'points': 0, 'is_passing_grade': False})
     )
     response = self._postas('periodadmin',
         data = {
             'minimum_points': 21,
             'assignments': [str(self.testhelper.sub_p1_a1.id), str(self.testhelper.sub_p1_a2.id), str(self.testhelper.sub_p1_a3.id)]},
         querystring = {
             'periodid': self.testhelper.sub_p1.id,
             'pluginsessionid': 'tst'}
     )
     self.assertEqual(response.status_code, 302)
     previewdata = self.client.session[create_sessionkey('tst')]
     self.assertEqual(set(previewdata.passing_relatedstudentids),
         set([relatedStudent2.id, relatedStudent3.id]))
Beispiel #2
0
 def test_post_realistic(self):
     self.create_relatedstudent("student1")
     relatedStudent2 = self.create_relatedstudent("student2")
     relatedStudent3 = self.create_relatedstudent("student3")
     self.create_feedbacks(  # student1 Fails because of the F on a1 and a2
         (self.testhelper.sub_p1_a1_gstudent1, {"grade": "F", "points": 0, "is_passing_grade": False}),
         (self.testhelper.sub_p1_a2_gstudent1, {"grade": "F", "points": 0, "is_passing_grade": True}),
         (self.testhelper.sub_p1_a3_gstudent1, {"grade": "A", "points": 0, "is_passing_grade": True}),
     )
     self.create_feedbacks(  # student2 Passes all
         (self.testhelper.sub_p1_a1_gstudent2, {"grade": "A", "points": 0, "is_passing_grade": True}),
         (self.testhelper.sub_p1_a2_gstudent2, {"grade": "A", "points": 0, "is_passing_grade": True}),
         (self.testhelper.sub_p1_a3_gstudent2, {"grade": "A", "points": 0, "is_passing_grade": True}),
     )
     self.create_feedbacks(  # student3 passes a1 and a2, so he passes
         (self.testhelper.sub_p1_a1_gstudent3, {"grade": "A", "points": 0, "is_passing_grade": True}),
         (self.testhelper.sub_p1_a2_gstudent3, {"grade": "A", "points": 0, "is_passing_grade": True}),
         (self.testhelper.sub_p1_a3_gstudent3, {"grade": "F", "points": 0, "is_passing_grade": False}),
     )
     response = self._postas(
         "periodadmin",
         data={"assignments": [str(self.testhelper.sub_p1_a1.id)]},
         querystring={"periodid": self.testhelper.sub_p1.id, "pluginsessionid": "tst"},
     )
     self.assertEqual(response.status_code, 302)
     previewdata = self.client.session[create_sessionkey("tst")]
     self.assertEqual(set(previewdata.passing_relatedstudentids), set([relatedStudent2.id, relatedStudent3.id]))
Beispiel #3
0
 def get(self, request, id):
     pluginsessionid = self.request.GET.get("pluginsessionid", None)
     if not pluginsessionid:
         raise ErrorResponse(
             statuscodes.HTTP_400_BAD_REQUEST, {"detail": "``pluginsessionid`` is a required parameter"}
         )
     period = get_object_or_404(Period, pk=id)
     previewdata = self.request.session[create_sessionkey(pluginsessionid)]
     if not isinstance(previewdata, PreviewData):
         raise ErrorResponse(
             statuscodes.HTTP_400_BAD_REQUEST, {"detail": "The session data must be a PreviewData object."}
         )
     grouper = GroupsGroupedByRelatedStudentAndAssignment(period)
     return {"perioddata": grouper.serialize(), "pluginoutput": previewdata.serialize()}
Beispiel #4
0
 def test_realistic(self):
     self.create_relatedstudent("student1")
     relatedStudent2 = self.create_relatedstudent("student2")
     self.create_feedbacks(  # Fails because of the F
         (self.testhelper.sub_p1_a1_gstudent1, {"grade": "F", "points": 0, "is_passing_grade": False}),
         (self.testhelper.sub_p1_a2_gstudent1, {"grade": "A", "points": 0, "is_passing_grade": True}),
     )
     self.create_feedbacks(  # Passes all
         (self.testhelper.sub_p1_a1_gstudent2, {"grade": "A", "points": 0, "is_passing_grade": True}),
         (self.testhelper.sub_p1_a2_gstudent2, {"grade": "A", "points": 0, "is_passing_grade": True}),
     )
     response = self._getas("periodadmin", {"periodid": self.testhelper.sub_p1.id, "pluginsessionid": "tst"})
     self.assertEqual(response.status_code, 302)
     previewdata = self.client.session[create_sessionkey("tst")]
     self.assertEqual(previewdata.passing_relatedstudentids, [relatedStudent2.id])
Beispiel #5
0
 def _test_permsas(self, username):
     response = self._getas(username, {"periodid": self.testhelper.sub_p1.id, "pluginsessionid": "tst"})
     self.assertEqual(response.status_code, 302)
     previewdata = self.client.session[create_sessionkey("tst")]
     self.assertEqual(previewdata.passing_relatedstudentids, [])