def test_reviewers_with_authors_sent_feedback_different_activities(self):
        num_previous = 2
        self.make_feedback_received_records(num_previous)

        reviewers_with_notified_authors = [
            r.assessor_id for r in self.pairings
            if r.assessee_id in self.previously_sent
        ]

        pairing_activity_id = self.fake.random.randint(1, 9999)
        self.create_preexisting_review_pairings(pairing_activity_id,
                                                self.students,
                                                check_db_before_run=False)

        pairing_activity = MagicMock(id=pairing_activity_id)

        self.obj = FeedbackStatusRepository(self.dao, self.activity,
                                            pairing_activity)

        # try with all students to make it easy to check missing
        result = self.obj.reviewers_with_authors_sent_feedback

        self.assertEqual(
            num_previous, len(result),
            "Correct number of records returned when pairing activity id is different"
        )
        for sid in result:
            self.assertIn(
                sid, reviewers_with_notified_authors,
                "Returned for previously notified authors when pairing activity id is different"
            )
Ejemplo n.º 2
0
    def add_reviews(self, data_dict, component, student_id):
        # Note: can't do in similar way to invitations since invited to metareview and received ca feedback
        # use different activities. The invitation is for the upcoming one which provides feedback
        # on the previous one

        # set to none so won't overwrite on next time through
        fb_fieldname = None

        if isinstance(component, DiscussionForum):
            fb_fieldname = 'received_discussion_feedback'

        if fb_fieldname is not None:
            fr = FeedbackStatusRepository(self.dao, component)
            data_dict[fb_fieldname] = pd.to_datetime(
                fr.received_at(student_id))
Ejemplo n.º 3
0
    def __init__( self, course=None, unit=None, is_test=None, send=True, **kwargs ):
        """
        :param course:
        :param unit:
        :param is_test:
        :param send: Whether to actually send the messages
        """
        super().__init__( course, unit, is_test, send, **kwargs )
        # The activity whose results we are going to be doing something with
        self.activity = unit.metareview

        # The activity which we are telling the student about
        # self.activity_notifying_about = unit.metareview

        # In sending the metareview results to the reviewer we are
        # telling the about the feedback on the review
        self.activity_feedback_on = unit.review

        # The activity_inviting_to_complete whose id is used to store review pairings for the whole SKAA
        self.activity_for_review_pairings = unit.initial_work

        self._initialize()

        self.feedback_status_repo = FeedbackStatusRepository(self.dao, self.activity_feedback_on, self.activity_for_review_pairings)

        self.statusRepos = [self.feedback_status_repo]

        self.associations = [ ]
    def setUp(self):
        self.config_for_test()
        self.unit = unit_factory()
        self.activity = self.unit.discussion_forum
        self.activity_id = self.activity.id

        self.dao = SqliteDAO()
        self.session = self.dao.session
        self.create_new_and_preexisting_students()
        self.create_preexisting_review_pairings(self.activity_id,
                                                self.students)

        # ids of authors previously notified
        self.previously_sent = []
        # ids of reviewers corresponding to previously notified authors

        self.obj = FeedbackStatusRepository(self.dao, self.activity)
    def __init__(self,
                 course=None,
                 unit=None,
                 is_test=None,
                 send=True,
                 **kwargs):
        """
        :param course:
        :param unit:
        :param is_test:
        :param send: Whether to actually send the messages
        """
        super().__init__(course, unit, is_test, send, **kwargs)

        # The activity whose results we are going to be doing something with
        self.activity = unit.discussion_review

        # The activity which we are sending feedback about
        self.activity_notifying_about = unit.discussion_review

        # The activity whose id is used to store review pairings for the whole SKAA
        # We use the discussion review so that the association repo records,
        # invite status records and feedback status records will have the same
        # id, which makes reasoning about them easier
        self.activity_for_review_pairings = unit.discussion_review

        # did it this way for unit 2; leaving commented version in case have to go back
        # self.activity_for_review_pairings = unit.discussion_forum

        self.associations = []

        self._initialize()

        self.feedback_status_repo = FeedbackStatusRepository(
            self.dao, self.activity_notifying_about)
        self.statusRepos = [self.feedback_status_repo]
class TestFeedbackStatusRepository(TestingBase):
    def setUp(self):
        self.config_for_test()
        self.unit = unit_factory()
        self.activity = self.unit.discussion_forum
        self.activity_id = self.activity.id

        self.dao = SqliteDAO()
        self.session = self.dao.session
        self.create_new_and_preexisting_students()
        self.create_preexisting_review_pairings(self.activity_id,
                                                self.students)

        # ids of authors previously notified
        self.previously_sent = []
        # ids of reviewers corresponding to previously notified authors

        self.obj = FeedbackStatusRepository(self.dao, self.activity)

    def test_record(self):
        # Using id as input
        result = self.obj.record(self.student_ids[0])
        self.assertIsInstance(result, FeedbackReceivedRecord,
                              "Correct type returned")
        self.assertEqual(self.student_ids[0], result.student_id,
                         "Correct id set")
        self.assertIsNotNone(result.sent_at, "Timestamp automatically added")

        # Using student object as input
        result = self.obj.record(self.students[1])
        self.assertIsInstance(result, FeedbackReceivedRecord,
                              "Correct type returned")
        self.assertEqual(self.students[1].id, result.student_id,
                         "Correct id set")
        self.assertIsNotNone(result.sent_at, "Timestamp automatically added")

    def test_has_received(self):
        num_previous = 2
        self.make_feedback_received_records(num_previous)
        self.assertEqual(num_previous, len(self.previously_sent))

        others = [
            sid for sid in self.student_ids if sid not in self.previously_sent
        ]

        # Check
        for sid in self.previously_sent:
            self.assertTrue(self.obj.has_received(sid),
                            "Returns true for notified students")

        for sid in others:
            self.assertFalse(self.obj.has_received(sid),
                             "Returns false for non-notified students")

    def test_previously_received(self):
        num_previous = 2
        self.make_feedback_received_records(num_previous)
        others = [
            sid for sid in self.student_ids if sid not in self.previously_sent
        ]

        # call
        result = self.obj.previously_received

        # Check
        for r in result:
            self.assertIsInstance(r, FeedbackReceivedRecord,
                                  "Returns expected object")
            self.assertIn(r.student_id, self.previously_sent,
                          "id in previously sent")
            self.assertNotIn(r.student_id, others, "no unexpected returned")

    def test_previously_received_ids(self):
        num_previous = 2
        self.make_feedback_received_records(num_previous)
        others = [
            sid for sid in self.student_ids if sid not in self.previously_sent
        ]

        # call
        result = self.obj.previously_received_ids

        # Check
        for r in result:
            self.assertIsInstance(r, int, "Returns expected type")
            self.assertIn(r, self.previously_sent, "id in previously sent")
            self.assertNotIn(r, others, "no unexpected returned")

    def test_get(self):
        num_previous = 2
        self.make_feedback_received_records(num_previous)
        self.assertEqual(num_previous, len(self.previously_sent))

        # call
        others = [
            sid for sid in self.student_ids if sid not in self.previously_sent
        ]

        for sid in others:
            result = self.obj.get(sid)
            self.assertIsNone(result, "Returns none for unsent")

        for sid in self.previously_sent:
            result = self.obj.get(sid)
            self.assertIsInstance(result, FeedbackReceivedRecord,
                                  "Correct type returned")
            self.assertEqual(result.student_id, sid, "Correct sid")
            self.assertIsNotNone(result.sent_at, "Timestamp not empty")

    def test_reviewers_with_authors_sent_feedback(self):
        num_previous = 2
        self.make_feedback_received_records(num_previous)
        self.assertEqual(num_previous, len(self.previously_sent))

        reviewers_with_notified_authors = [
            r.assessor_id for r in self.pairings
            if r.assessee_id in self.previously_sent
        ]

        # ra = self.session.query(ReviewAssociation).all()
        # fb = self.session.query(FeedbackReceivedRecord).all()

        # try with all students to make it easy to check missing
        result = self.obj.reviewers_with_authors_sent_feedback

        self.assertEqual(num_previous, len(result),
                         "Correct number of records returned")
        for sid in result:
            self.assertIn(sid, reviewers_with_notified_authors,
                          "Returned for previously notified authors")

        # self.create_preexisting_review_pairings(self.activity_id, self.students)

    def test_reviewers_with_authors_sent_feedback_different_activities(self):
        num_previous = 2
        self.make_feedback_received_records(num_previous)

        reviewers_with_notified_authors = [
            r.assessor_id for r in self.pairings
            if r.assessee_id in self.previously_sent
        ]

        pairing_activity_id = self.fake.random.randint(1, 9999)
        self.create_preexisting_review_pairings(pairing_activity_id,
                                                self.students,
                                                check_db_before_run=False)

        pairing_activity = MagicMock(id=pairing_activity_id)

        self.obj = FeedbackStatusRepository(self.dao, self.activity,
                                            pairing_activity)

        # try with all students to make it easy to check missing
        result = self.obj.reviewers_with_authors_sent_feedback

        self.assertEqual(
            num_previous, len(result),
            "Correct number of records returned when pairing activity id is different"
        )
        for sid in result:
            self.assertIn(
                sid, reviewers_with_notified_authors,
                "Returned for previously notified authors when pairing activity id is different"
            )

    def test_reviewers_with_notified_authors(self):
        num_previous = 2
        self.make_feedback_received_records(num_previous)
        self.assertEqual(num_previous, len(self.previously_sent))

        reviewers_with_notified_authors = [
            r.assessor_id for r in self.pairings
            if r.assessee_id in self.previously_sent
        ]

        # ra = self.session.query(ReviewAssociation).all()
        # fb = self.session.query(FeedbackReceivedRecord).all()

        # try with all students to make it easy to check missing
        result = self.obj.reviewers_with_authors_sent_feedback

        self.assertEqual(num_previous, len(result),
                         "Correct number of records returned")
        for sid in result:
            self.assertIn(sid, reviewers_with_notified_authors,
                          "Returned for previously notified authors")

    def test_remove_reviewers_with_notified_authors(self):
        num_previous = 2
        self.make_feedback_received_records(num_previous)
        self.assertEqual(num_previous, len(self.previously_sent))

        reviewers_with_notified_authors = [
            r.assessor_id for r in self.pairings
            if r.assessee_id in self.previously_sent
        ]

        # ra = self.session.query(ReviewAssociation).all()
        # fb = self.session.query(FeedbackReceivedRecord).all()

        # try with all students to make it easy to check missing
        result = self.obj.remove_reviewers_with_notified_authors(self.students)

        self.assertEqual(
            len(self.student_ids) - num_previous, len(result),
            "Correct number of records returned")
        for sid in result:
            self.assertNotIn(sid, reviewers_with_notified_authors,
                             "Author not previously notified")