Beispiel #1
0
    def test_grade_change(self):
        gopp = factories.GradingOpportunityFactory(course=self.course2)

        factories.GradeChangeFactory(
            opportunity=gopp,
            participation=self.course2_student_participation,
            flow_session=self.course2_sessions[0],
            points=5)

        # a gchange without percentage
        factories.GradeChangeFactory(
            opportunity=gopp,
            participation=self.course2_student_participation,
            flow_session=None)

        self.navigate_admin_view_by_model(models.GradeChange)
Beispiel #2
0
    def test_has_last_grades_points_updated(self):
        factories.GradeChangeFactory(
            **self.gc(opportunity=self.gopp, points=86.66))
        factories.GradeChangeFactory(
            **self.gc(opportunity=self.gopp, points=88))
        gchanges = models.GradeChange.objects.all()
        self.assertEqual(gchanges.count(), 2)

        with open(os.path.join(CSV_PATH, 'test_import_csv.csv'),
                  'rb') as csv_file:
            resp = self.post_import_grades(csv_file, feedback_column="")
            self.assertContains(
                resp, "test_student in test-course as student: points updated")

            self.assertEqual(resp.status_code, 200)
            gchanges = models.GradeChange.objects.all()
            self.assertEqual(gchanges.count(), 3)
            gchange = gchanges.last()
            self.assertEqual(float(gchange.points), float(86.66))
Beispiel #3
0
    def test_clean_fail(self):
        course2 = factories.CourseFactory(identifier="another-course")
        opportunity3 = factories.GradingOpportunityFactory(course=course2,
                                                           identifier="gopp3")
        gc = factories.GradeChangeFactory(opportunity=opportunity3,
                                          participation=self.participation)

        with self.assertRaises(ValidationError) as cm:
            gc.clean()

        expected_error_msg = ("Participation and opportunity must live "
                              "in the same course")
        self.assertIn(expected_error_msg, str(cm.exception))
Beispiel #4
0
    def test_has_last_grades_state_not_graded(self):
        factories.GradeChangeFactory(**self.gc(opportunity=self.gopp,
                                               points=None,
                                               max_points=100,
                                               comment="not grades",
                                               state=g_state.grading_started))
        gchanges = models.GradeChange.objects.all()
        self.assertEqual(gchanges.count(), 1)

        with open(os.path.join(CSV_PATH, 'test_import_csv.csv'),
                  'rb') as csv_file:
            resp = self.post_import_grades(csv_file)

            self.assertEqual(resp.status_code, 200)
            gchanges = models.GradeChange.objects.all()
            self.assertEqual(gchanges.count(), 2)
            gchange = gchanges.last()
            self.assertEqual(float(gchange.points), float(86.66))
Beispiel #5
0
    def test_has_last_grades_multiple_attrs_updated(self):
        factories.GradeChangeFactory(**self.gc(opportunity=self.gopp,
                                               points=85,
                                               max_points=90,
                                               comment="first grades"))
        gchanges = models.GradeChange.objects.all()
        self.assertEqual(gchanges.count(), 1)

        with open(os.path.join(CSV_PATH, 'test_import_csv.csv'),
                  'rb') as csv_file:
            resp = self.post_import_grades(csv_file)
            self.assertContains(
                resp,
                "test_student in test-course as student: points, max_points, "
                "comment updated")

            self.assertEqual(resp.status_code, 200)
            gchanges = models.GradeChange.objects.all()
            self.assertEqual(gchanges.count(), 2)
            gchange = gchanges.last()
            self.assertEqual(float(gchange.points), float(86.66))
Beispiel #6
0
 def test_clean(self):
     gc = factories.GradeChangeFactory(opportunity=self.opportunity1,
                                       participation=self.participation)
     gc.clean()
Beispiel #7
0
 def test_unicode(self):
     gc1 = factories.GradeChangeFactory(opportunity=self.opportunity1,
                                        participation=self.participation)
     self.assertIsNotNone(str(gc1))