Esempio n. 1
0
 def get_relatedstudents_that_qualify_for_exam(self, period):
     passing_relatedstudentsids = []
     grouper = GroupsGroupedByRelatedStudentAndAssignment(period)
     for aggregated_relstudentinfo in grouper.iter_relatedstudents_with_results():
         if self.student_qualifies_for_exam(aggregated_relstudentinfo):
             passing_relatedstudentsids.append(aggregated_relstudentinfo.relatedstudent.id)
     return passing_relatedstudentsids
Esempio n. 2
0
 def test_iter_students_with_feedback_that_is_candidate_but_not_in_related(self):
     self._add_bad_feedback(self.testhelper.sub_p1_a1_stud1)
     grouper = GroupsGroupedByRelatedStudentAndAssignment(self.testhelper.sub_p1)
     ignored = list(grouper.iter_students_with_feedback_that_is_candidate_but_not_in_related())
     self.assertEquals(len(ignored), 1)
     grouplists = list(ignored[0].iter_groups_by_assignment())
     self.assertEquals(len(grouplists), 3) # Should match the number of assignments
     self.assertEquals(grouplists[0][0].feedback.grade, '0/100')
Esempio n. 3
0
 def test_iter_relatedstudents_with_results(self):
     self._add_bad_feedback(self.testhelper.sub_p1_a1_stud1)
     self.testhelper.sub_p1.relatedstudent_set.create(user=self.testhelper.student1)
     grouper = GroupsGroupedByRelatedStudentAndAssignment(self.testhelper.sub_p1)
     results = list(grouper.iter_relatedstudents_with_results())
     self.assertEqual(len(results), 1)
     student1info = results[0]
     grouplists = list(student1info.iter_groups_by_assignment())
     self.assertEqual(len(grouplists), 3)  # Should match the number of assignments
     self.assertEqual(grouplists[0].get_best_gradestring(), '0/100')
Esempio n. 4
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)]
     grouper = GroupsGroupedByRelatedStudentAndAssignment(period)
     return {
         'perioddata': grouper.serialize(),
         'pluginoutput': previewdata
     }
Esempio n. 5
0
 def test_iter_students_that_is_candidate_but_not_in_related(self):
     grouper = GroupsGroupedByRelatedStudentAndAssignment(self.testhelper.sub_p1)
     ignored = list(grouper.iter_students_that_is_candidate_but_not_in_related())
     self.assertEquals(len(ignored), 4)
     student1_info = None
     for aggregated_relstudentinfo in ignored:
         if aggregated_relstudentinfo.user == self.testhelper.student1:
             student1_info = aggregated_relstudentinfo
             break
     grouplists = list(student1_info.iter_groups_by_assignment())
     self.assertEquals(len(grouplists), 3) # Should match the number of assignments
     self.assertEquals(len(grouplists[0]), 1)
     self.assertEquals(grouplists[0][0].feedback, None)
Esempio n. 6
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()}
Esempio n. 7
0
    def _get_instance(self, id):
        try:
            qry = Period.objects.select_related("parentnode")
            period = qry.get(id=id)
        except Period.DoesNotExist:
            raise ErrorResponse(
                statuscodes.HTTP_404_NOT_FOUND, {"detail": "The period with ID {id} does not exist".format(id=id)}
            )

        self._permissioncheck(period)

        statusQry = period.qualifiedforexams_status.all()
        if len(statusQry) == 0:
            raise ErrorResponse(statuscodes.HTTP_404_NOT_FOUND, {"detail": "The period has no statuses"})

        grouper = GroupsGroupedByRelatedStudentAndAssignment(period)
        out = self._serialize_period(period)
        out.update(
            {"perioddata": grouper.serialize(), "statuses": [self._serialize_status(status) for status in statusQry]}
        )
        return out
Esempio n. 8
0
    def _get_instance(self, id):
        try:
            qry = Period.objects.select_related('parentnode')
            period = qry.get(id=id)
        except Period.DoesNotExist:
            raise ErrorResponse(statuscodes.HTTP_404_NOT_FOUND,
                {'detail': 'The period with ID {id} does not exist'.format(id=id)})

        self._permissioncheck(period)

        statusQry = period.qualifiedforexams_status.all()
        if statusQry.count() == 0:
            raise ErrorResponse(statuscodes.HTTP_404_NOT_FOUND,
                {'detail': 'The period has no statuses'})
        statusQry = statusQry.select_related(
                'period', 'user', 'user__devilryuserprofile')

        grouper = GroupsGroupedByRelatedStudentAndAssignment(period)
        out = self._serialize_period(period)
        out.update({
            'perioddata': grouper.serialize(),
            'statuses': [self._serialize_status(status) for status in statusQry]
        })
        return out
Esempio n. 9
0
 def test_iter_relatedstudents_with_results_multi(self):
     self.testhelper.sub_p1.relatedstudent_set.create(user=self.testhelper.student1)
     self.testhelper.sub_p1.relatedstudent_set.create(user=self.testhelper.student2)
     grouper = GroupsGroupedByRelatedStudentAndAssignment(self.testhelper.sub_p1)
     results = list(grouper.iter_relatedstudents_with_results())
     self.assertEqual(len(results), 2)
Esempio n. 10
0
 def test_iter_students_with_feedback_that_is_candidate_but_not_in_related_none(self):
     grouper = GroupsGroupedByRelatedStudentAndAssignment(self.testhelper.sub_p1)
     self.assertEquals(len(list(grouper.iter_students_with_feedback_that_is_candidate_but_not_in_related())), 0)
     self.assertEquals(len(list(grouper.iter_relatedstudents_with_results())), 0)
Esempio n. 11
0
 def test_iter_assignments(self):
     grouper = GroupsGroupedByRelatedStudentAndAssignment(self.testhelper.sub_p1)
     shortnames = [assignment.short_name for assignment in grouper.iter_assignments()]
     self.assertEquals(shortnames, ['a1', 'a2', 'a3'])
 def get(self, request, id=None):
     period = Period.objects.get(id=id) # NOTE: We know the period exists because of IsPeriodAdmin
     grouper = GroupsGroupedByRelatedStudentAndAssignment(period)
     return grouper.serialize()