Exemplo n.º 1
0
    def test_feedback_and_notify_instructor_pperm_masked_profile(self):

        # add view_participant_masked_profile pperm to instructor
        pp = ParticipationPermission(
            participation=self.instructor_participation,
            permission=pperm.view_participant_masked_profile)
        pp.save()
        self.instructor_participation.individual_permissions.set([pp])

        grade_data_extra_kwargs = {
            "feedback_text": 'test feedback',
            "notify": "on"
        }
        self.submit_page_human_grading_by_page_id_and_test(
            self.page_id, grade_data_extra_kwargs=grade_data_extra_kwargs)
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].reply_to, [])

        # Instructor also get the feedback email
        self.assertIn(self.course.notify_email, mail.outbox[0].recipients())

        # make sure the name (appellation) not in the email body, not the masked one
        self.assertNotIn(
            self.student_participation.user.get_email_appellation(),
            mail.outbox[0].body)
        self.assertNotIn(self.student_participation.user.get_masked_profile(),
                         mail.outbox[0].body)
        self.assertIn("Dear user", mail.outbox[0].body)
Exemplo n.º 2
0
    def test_notes_and_notify_ta_pperm_masked_profile(self):

        # add view_participant_masked_profile pperm to ta
        pp = ParticipationPermission(
            participation=self.ta_participation,
            permission=pperm.view_participant_masked_profile)
        pp.save()
        self.ta_participation.individual_permissions.set([pp])

        grade_data_extra_kwargs = {
            "notes": 'test notes',
            "notify_instructor": "on"
        }

        with self.temporarily_switch_to_user(self.ta_participation.user):
            self.submit_page_human_grading_by_page_id_and_test(
                self.page_id,
                grade_data_extra_kwargs=grade_data_extra_kwargs,
                force_login_instructor=False)
        self.assertEqual(len(mail.outbox), 1)
        self.assertIn(self.course.notify_email, mail.outbox[0].recipients())

        # make sure the name (appellation) not in the email body,
        # the masked one is used instead
        self.assertNotIn(
            self.student_participation.user.get_email_appellation(),
            mail.outbox[0].body)
        self.assertIn(self.student_participation.user.get_masked_profile(),
                      mail.outbox[0].body)
Exemplo n.º 3
0
    def test_notes_and_notify_ta_pperm_masked_profile(self):

        # add view_participant_masked_profile pperm to ta
        pp = ParticipationPermission(
            participation=self.ta_participation,
            permission=pperm.view_participant_masked_profile
        )
        pp.save()
        self.ta_participation.individual_permissions.set([pp])

        grade_data_extra_kwargs = {
            "notes": 'test notes',
            "notify_instructor": "on"}

        with self.temporarily_switch_to_user(self.ta_participation.user):
            self.submit_page_human_grading_by_page_id_and_test(
                self.page_id, grade_data_extra_kwargs=grade_data_extra_kwargs,
                force_login_instructor=False)
        self.assertEqual(len(mail.outbox), 1)
        self.assertIn(self.course.notify_email, mail.outbox[0].recipients())

        # make sure the name (appellation) not in the email body,
        # the masked one is used instead
        self.assertNotIn(
            self.student_participation.user.get_email_appellation(),
            mail.outbox[0].body)
        self.assertIn(
            self.student_participation.user.get_masked_profile(),
            mail.outbox[0].body)
Exemplo n.º 4
0
    def test_feedback_and_notify_instructor_pperm_masked_profile(self):

        # add view_participant_masked_profile pperm to instructor
        pp = ParticipationPermission(
            participation=self.instructor_participation,
            permission=pperm.view_participant_masked_profile
        )
        pp.save()
        self.instructor_participation.individual_permissions.set([pp])

        grade_data_extra_kwargs = {
            "feedback_text": 'test feedback',
            "notify": "on"}
        self.submit_page_human_grading_by_page_id_and_test(
            self.page_id, grade_data_extra_kwargs=grade_data_extra_kwargs)
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].reply_to, [])

        # Instructor also get the feedback email
        self.assertIn(self.course.notify_email, mail.outbox[0].recipients())

        # make sure the name (appellation) not in the email body, not the masked one
        self.assertNotIn(
            self.student_participation.user.get_email_appellation(),
            mail.outbox[0].body)
        self.assertNotIn(
            self.student_participation.user.get_masked_profile(),
            mail.outbox[0].body)
        self.assertIn("Dear user", mail.outbox[0].body)
Exemplo n.º 5
0
    def test_participation_with_update_permission(self):
        # Just to make sure it won't fail, Todo: assersion on form kwargs
        from course.models import ParticipationPermission
        pp = ParticipationPermission(participation=self.student_participation,
                                     permission=pperm.update_content)
        pp.save()
        self.student_participation.individual_permissions.set([pp])

        with self.temporarily_switch_to_user(self.student_participation.user):
            for command in versioning.ALLOWED_COURSE_REVISIOIN_COMMANDS:
                resp = self.post_update_course_content(
                    "some_commit_sha",
                    command=command,
                    force_login_instructor=False)
                self.assertEqual(resp.status_code, 200, command)
Exemplo n.º 6
0
    def test_participation_with_update_permission(self):
        # Just to make sure it won't fail, Todo: assersion on form kwargs
        from course.models import ParticipationPermission
        pp = ParticipationPermission(
            participation=self.student_participation,
            permission=pperm.update_content)
        pp.save()
        self.student_participation.individual_permissions.set([pp])

        with self.temporarily_switch_to_user(self.student_participation.user):
            for command in versioning.ALLOWED_COURSE_REVISIOIN_COMMANDS:
                resp = self.post_update_course_content(
                    "some_commit_sha", command=command,
                    force_login_instructor=False)
                self.assertEqual(resp.status_code, 200, command)
Exemplo n.º 7
0
    def save(self):
        # type: () -> Participation

        inst = super(EditParticipationForm, self).save()

        (ParticipationPermission.objects.filter(
            participation=self.instance).delete())

        pps = []
        for perm in self.cleaned_data["individual_permissions"]:
            pp = ParticipationPermission(participation=self.instance,
                                         permission=perm)
            pp.save()
            pps.append(pp)
        self.instance.individual_permissions.set(pps)

        return inst
Exemplo n.º 8
0
    def save(self):
        # type: () -> None

        super(EditParticipationForm, self).save()

        (ParticipationPermission.objects
                .filter(participation=self.instance)
                .delete())

        pps = []
        for perm in self.cleaned_data["individual_permissions"]:
            pp = ParticipationPermission(
                        participation=self.instance,
                        permission=perm)
            pp.save()
            pps.append(pp)
        self.instance.individual_permissions.set(pps)
Exemplo n.º 9
0
    def test_no_perm_to_post_grade(self):
        some_user = factories.UserFactory()
        his_participation = factories.ParticipationFactory(user=some_user,
                                                           course=self.course)
        from course.models import ParticipationPermission
        pp = ParticipationPermission(participation=his_participation,
                                     permission=pperm.view_gradebook)
        pp.save()
        his_participation.individual_permissions.set([pp])
        with self.temporarily_switch_to_user(some_user):
            resp = self.c.get(
                self.get_page_grading_url_by_page_id(self.page_id))
            self.assertEqual(resp.status_code, 200)

            grade_data = {"grade_points": "4", "released": "on"}
            resp = self.post_grade_by_page_id(self.page_id,
                                              grade_data,
                                              force_login_instructor=False)
            self.assertEqual(resp.status_code, 403)
Exemplo n.º 10
0
    def test_no_perm_to_post_grade(self):
        some_user = factories.UserFactory()
        his_participation = factories.ParticipationFactory(
            user=some_user, course=self.course)
        from course.models import ParticipationPermission
        pp = ParticipationPermission(
            participation=his_participation,
            permission=pperm.view_gradebook
        )
        pp.save()
        his_participation.individual_permissions.set([pp])
        with self.temporarily_switch_to_user(some_user):
            resp = self.c.get(
                self.get_page_grading_url_by_page_id(self.page_id))
            self.assertEqual(resp.status_code, 200)

            grade_data = {
                "grade_points": "4",
                "released": "on"
            }
            resp = self.post_grade_by_page_id(
                self.page_id, grade_data, force_login_instructor=False)
            self.assertEqual(resp.status_code, 403)