Ejemplo n.º 1
0
    def test_presentation_summary(self):

        self.submission.set_points(10, 10)
        self.submission.save()
        summary = UserCourseSummary(self.course_instance, self.user)
        self.assertEqual(summary.get_exercise_count(), 5)
        self.assertEqual(summary.get_max_points(), 400)
        self.assertEqual(summary.get_total_points(), 100)

        for s in summary.module_summaries:
            if s.module == self.course_module:
                msummary = s
                break
        self.assertEqual(msummary.get_exercise_count(), 3)
        self.assertEqual(msummary.get_max_points(), 200)
        self.assertEqual(msummary.get_total_points(), 100)
        self.assertFalse(msummary.is_passed())

        for s in summary.category_summaries:
            if s.category == self.learning_object_category:
                csummary = s
                break
        self.assertEqual(csummary.get_exercise_count(), 5)
        self.assertEqual(csummary.get_max_points(), 400)
        self.assertEqual(csummary.get_total_points(), 100)
        self.assertFalse(csummary.is_passed())
Ejemplo n.º 2
0
    def obj_get(self, request=None, **kwargs):
        results = {}
        course_instance = CourseInstance.objects.get(pk=kwargs["pk"])
        user_profile = UserProfile.objects.get(pk=kwargs["user"])
        course_summary = UserCourseSummary(course_instance, user_profile.user)
        results["user"] = user_profile.id
        results["course_instance"] = kwargs["pk"]
        summary = []

        for rnd in course_summary.module_summaries:
            exercise_summaries = []
            for ex_summary in rnd.exercise_summaries:
                tmp = {}
                tmp["exercise_id"] = ex_summary.exercise.id
                tmp["submission_count"] = ex_summary.submission_count
                tmp["completed_percentage"] = self._percentage(
                    ex_summary.get_total_points(), ex_summary.get_max_points())
                exercise_summaries.append(tmp)
            summary.append({
                "exercise_round_id":
                rnd.module.id,
                "completed_percentage":
                self._percentage(rnd.get_total_points(), rnd.get_max_points()),
                "closing_time":
                rnd.module.closing_time,
                "exercise_summaries":
                exercise_summaries
            })
        results["summary"] = summary
        return results
Ejemplo n.º 3
0
 def test_presentation_summary_empty(self):
     summary = UserCourseSummary(self.course_instance, self.user)
     self.assertEqual(summary.get_exercise_count(), 5)
     self.assertEqual(summary.get_max_points(), 400)
     self.assertEqual(summary.get_total_points(), 0)