Ejemplo n.º 1
0
 def setUp(self):
     self.facility = Facility.objects.create()
     user = FacilityUser.objects.create(username="******",
                                        facility=self.facility)
     Membership.objects.create(collection=self.facility, user=user)
     ContentSessionLogFactory.create(user=user,
                                     content_id=uuid.uuid4().hex,
                                     channel_id=uuid.uuid4().hex)
Ejemplo n.º 2
0
 def setUpTestData(cls):
     cls.facility = Facility.objects.create()
     cls.facility_2 = Facility.objects.create()
     cls.user = FacilityUser.objects.create(username="******", facility=cls.facility)
     Membership.objects.create(collection=cls.facility, user=cls.user)
     ContentSessionLogFactory.create(
         user=cls.user, content_id=uuid.uuid4().hex, channel_id=uuid.uuid4().hex
     )
Ejemplo n.º 3
0
 def setUp(self):
     facility, superuser = setup_device()
     ContentSessionLogFactory.create(content_id=uuid.uuid4().hex,
                                     channel_id=uuid.uuid4().hex)
     for classroom in [
             ClassroomFactory.create(parent=facility) for _ in range(3)
     ]:
         for group in [
                 LearnerGroupFactory.create(parent=classroom)
                 for _ in range(3)
         ]:
             user = FacilityUserFactory.create(facility=facility)
             auth_models.Membership.objects.create(collection=group,
                                                   user=user)
             ContentSessionLogFactory.create(user=user,
                                             content_id=uuid.uuid4().hex,
                                             channel_id=uuid.uuid4().hex)
             ContentSummaryLogFactory.create(user=user,
                                             content_id=uuid.uuid4().hex,
                                             channel_id=uuid.uuid4().hex)
             UserSessionLogFactory.create(user=user)
Ejemplo n.º 4
0
    def test_parse_attemptslog_create_on_new_attempt_with_no_notification(
        self, save_notifications, create_notification
    ):
        log = ContentSessionLogFactory(
            user=self.user1, content_id=uuid.uuid4().hex, channel_id=uuid.uuid4().hex
        )
        now = local_now()
        masterylog = MasteryLog.objects.create(
            summarylog=self.summarylog1,
            user=self.user1,
            start_timestamp=now,
            mastery_level=1,
            complete=True,
        )
        interactions = [{"type": "answer", "correct": 0} for _ in range(3)]
        attemptlog1 = AttemptLog.objects.create(
            masterylog=masterylog,
            sessionlog=log,
            user=self.user1,
            start_timestamp=now,
            end_timestamp=now,
            time_spent=1.0,
            complete=True,
            correct=1,
            hinted=False,
            error=False,
            interaction_history=[interactions[0]],
        )
        parse_attemptslog(attemptlog1)
        assert save_notifications.called
        create_notification.assert_any_call(
            NotificationObjectType.Resource,
            NotificationEventType.Started,
            attemptlog1.user_id,
            self.classroom.id,
            assignment_collections=[self.classroom.id],
            lesson_id=self.lesson_id,
            contentnode_id=self.node_1.id,
            timestamp=attemptlog1.start_timestamp,
        )

        create_notification.assert_any_call(
            NotificationObjectType.Lesson,
            NotificationEventType.Started,
            attemptlog1.user_id,
            self.classroom.id,
            assignment_collections=[self.classroom.id],
            lesson_id=self.lesson_id,
            timestamp=attemptlog1.start_timestamp,
        )
Ejemplo n.º 5
0
    def test_parse_attemptslog_update_attempt_with_three_wrong_attempts_no_started(
        self, save_notifications, create_notification
    ):
        log = ContentSessionLogFactory(
            user=self.user1, content_id=uuid.uuid4().hex, channel_id=uuid.uuid4().hex
        )
        now = local_now()
        masterylog = MasteryLog.objects.create(
            summarylog=self.summarylog1,
            user=self.user1,
            start_timestamp=now,
            mastery_level=1,
            complete=True,
        )
        interactions = [{"type": "answer", "correct": 0}]
        AttemptLog.objects.create(
            masterylog=masterylog,
            sessionlog=log,
            user=self.user1,
            start_timestamp=now,
            end_timestamp=now,
            time_spent=1.0,
            complete=True,
            correct=0,
            hinted=False,
            error=False,
            interaction_history=interactions,
        )

        AttemptLog.objects.create(
            masterylog=masterylog,
            sessionlog=log,
            user=self.user1,
            start_timestamp=now,
            end_timestamp=now,
            time_spent=1.0,
            complete=True,
            correct=0,
            hinted=False,
            error=False,
            interaction_history=interactions,
        )
        # more than 3 attempts will trigger the help notification
        interactions.append({"type": "answer", "correct": 0})
        attemptlog3 = AttemptLog.objects.create(
            masterylog=masterylog,
            sessionlog=log,
            user=self.user1,
            start_timestamp=now,
            end_timestamp=now,
            time_spent=1.0,
            complete=True,
            correct=0,
            hinted=False,
            error=False,
            interaction_history=interactions,
        )
        parse_attemptslog(attemptlog3)
        assert save_notifications.called
        create_notification.assert_any_call(
            NotificationObjectType.Resource,
            NotificationEventType.Help,
            attemptlog3.user_id,
            self.classroom.id,
            assignment_collections=[self.classroom.id],
            lesson_id=self.lesson_id,
            contentnode_id=self.node_1.id,
            reason=HelpReason.Multiple,
            timestamp=attemptlog3.start_timestamp,
        )

        create_notification.assert_any_call(
            NotificationObjectType.Resource,
            NotificationEventType.Started,
            attemptlog3.user_id,
            self.classroom.id,
            assignment_collections=[self.classroom.id],
            lesson_id=self.lesson_id,
            contentnode_id=self.node_1.id,
            timestamp=attemptlog3.start_timestamp,
        )