Exemplo n.º 1
0
    def setUp(self):
        self.facility = FacilityFactory.create()
        # provision device to pass the setup_wizard middleware check
        provision_device()
        self.superuser = create_superuser(self.facility)
        self.user1 = FacilityUserFactory.create(facility=self.facility)
        self.user2 = FacilityUserFactory.create(facility=self.facility)

        # add admin to 1st facility
        self.admin = FacilityUserFactory.create(facility=self.facility)
        self.facility.add_admin(self.admin)

        # create logs for each user
        self.summary_logs = [ContentSummaryLogFactory.create(user=self.user1, content_id=uuid.uuid4().hex, channel_id=uuid.uuid4().hex) for _ in range(3)]
        [ContentSummaryLogFactory.create(user=self.user2, content_id=uuid.uuid4().hex, channel_id=uuid.uuid4().hex) for _ in range(2)]

        # create classroom, learner group, add user2
        self.classroom = ClassroomFactory.create(parent=self.facility)
        self.learner_group = LearnerGroupFactory.create(parent=self.classroom)
        self.learner_group.add_learner(self.user2)

        self.payload = {'user': self.user1.pk,
                        'content_id': uuid.uuid4().hex,
                        'channel_id': uuid.uuid4().hex,
                        'kind': "video",
                        'start_timestamp': str(datetime.datetime.now())}
    def setUp(self):
        # create DeviceOwner to pass the setup_wizard middleware check
        self.deviceowner = DeviceOwnerFactory.create()
        self.facility = FacilityFactory.create()
        self.user1 = FacilityUserFactory.create(facility=self.facility)
        self.user2 = FacilityUserFactory.create(facility=self.facility)

        # add admin to 1st facility
        self.admin = FacilityUserFactory.create(facility=self.facility)
        self.facility.add_admin(self.admin)

        # create logs for each user
        self.interaction_logs = [ContentSessionLogFactory.create(user=self.user1) for _ in range(3)]
        [ContentSessionLogFactory.create(user=self.user2) for _ in range(2)]

        # create classroom, learner group, add user2
        self.classroom = ClassroomFactory.create(parent=self.facility)
        self.learner_group = LearnerGroupFactory.create(parent=self.classroom)
        self.learner_group.add_learner(self.user2)

        self.payload = {'user': self.user1.pk,
                        'content_id': uuid.uuid4().hex,
                        'channel_id': uuid.uuid4().hex,
                        'kind': 'video',
                        'start_timestamp': str(datetime.datetime.now())}
Exemplo n.º 3
0
    def setUp(self):
        self.facility = FacilityFactory.create()
        # provision device to pass the setup_wizard middleware check
        provision_device()
        self.user1 = FacilityUserFactory.create(facility=self.facility)
        self.user2 = FacilityUserFactory.create(facility=self.facility)
        self.exam = Exam.objects.create(title="", channel_id="", question_count=1, collection=self.facility, creator=self.user2, active=True)
        self.examlog = ExamLog.objects.create(exam=self.exam, user=self.user1)
        [ExamAttemptLog.objects.create(
            item="d4623921a2ef5ddaa39048c0f7a6fe06",
            examlog=self.examlog,
            user=self.user1,
            content_id=uuid.uuid4().hex,
            channel_id=uuid.uuid4().hex,
            start_timestamp=str(datetime.datetime.now().replace(minute=x, hour=x, second=x)),
            end_timestamp=str(datetime.datetime.now().replace(minute=x, hour=x, second=x)),
            correct=0
        ) for x in range(3)]

        self.examattemptdata = {
            "item": "test",
            "start_timestamp": timezone.now(),
            "end_timestamp": timezone.now(),
            "correct": 0,
            "user": self.user1.pk,
            "examlog": self.examlog.pk,
            "content_id": "77b57a14a1f0466bb27ea7de8ff468be",
            "channel_id": "77b57a14a1f0466bb27ea7de8ff468be",
        }
 def setUp(self):
     # create DeviceOwner to pass the setup_wizard middleware check
     DeviceOwner.objects.create(username='******', password=123)
     self.facility = FacilityFactory.create()
     self.admin = FacilityUserFactory.create(facility=self.facility)
     self.user = FacilityUserFactory.create(facility=self.facility)
     self.interaction_logs = [ContentSessionLogFactory.create(user=self.user) for _ in range(3)]
     self.facility.add_admin(self.admin)
Exemplo n.º 5
0
 def setUp(self):
     provision_device()
     DatabaseIDModel.objects.create()
     self.facility = FacilityFactory.create()
     self.superuser = create_superuser(self.facility)
     self.client.login(username=self.superuser.username,
                       password=DUMMY_PASSWORD,
                       facility=self.facility)
Exemplo n.º 6
0
 def setUp(self):
     provision_device()
     self.facility = FacilityFactory.create()
     self.superuser = create_superuser(self.facility)
     self.user = FacilityUserFactory.create(facility=self.facility)
     self.client.login(username=self.superuser.username,
                       password=DUMMY_PASSWORD,
                       facility=self.facility)
Exemplo n.º 7
0
 def test_redirect_root_to_learn_if_logged_in(self):
     facility = FacilityFactory.create()
     do = create_superuser(facility)
     provision_device()
     self.client.login(username=do.username, password=DUMMY_PASSWORD)
     response = self.client.get("/")
     self.assertEqual(response.status_code, 302)
     self.assertEqual(response.get("location"), reverse('kolibri:learnplugin:learn'))
 def test_facility_log_filtering(self):
     response = self.client.login(username=self.deviceowner.username, password=DUMMY_PASSWORD)
     # add user3 to new facility
     self.facility2 = FacilityFactory.create()
     self.user3 = FacilityUserFactory.create(facility=self.facility2)
     [ContentSessionLogFactory.create(user=self.user3) for _ in range(1)]
     response = self.client.get(reverse('contentsessionlog-list'), data={"facility": self.facility2.id})
     expected_count = ContentSessionLog.objects.filter(user__facility_id=self.facility2.id).count()
     self.assertEqual(len(response.data), expected_count)
Exemplo n.º 9
0
 def test_facility_log_filtering(self):
     response = self.client.login(username=self.superuser.username, password=DUMMY_PASSWORD)
     # add user3 to new facility
     self.facility2 = FacilityFactory.create()
     self.user3 = FacilityUserFactory.create(facility=self.facility2)
     [ContentSummaryLogFactory.create(user=self.user3, content_id=uuid.uuid4().hex, channel_id=uuid.uuid4().hex) for _ in range(1)]
     response = self.client.get(reverse('contentsummarylog-list'), data={"facility": self.facility2.id})
     expected_count = ContentSummaryLog.objects.filter(user__facility_id=self.facility2.id).count()
     self.assertEqual(len(response.data), expected_count)
Exemplo n.º 10
0
 def test_redirect_root_to_learn_if_logged_in(self):
     facility = FacilityFactory.create()
     do = create_superuser(facility)
     provision_device()
     self.client.login(username=do.username, password=DUMMY_PASSWORD)
     response = self.client.get("/")
     self.assertEqual(response.status_code, 302)
     self.assertEqual(response.get("location"),
                      reverse('kolibri:learnplugin:learn'))
Exemplo n.º 11
0
 def setUp(self):
     self.facility = FacilityFactory.create()
     # provision device to pass the setup_wizard middleware check
     provision_device()
     self.admin = FacilityUserFactory.create(facility=self.facility)
     self.user = FacilityUserFactory.create(facility=self.facility)
     self.interaction_logs = [ContentSessionLogFactory.create(
         user=self.user,
         content_id=uuid.uuid4().hex,
         channel_id="6199dde695db4ee4ab392222d5af1e5c"
     ) for _ in range(3)]
     self.facility.add_admin(self.admin)
Exemplo n.º 12
0
 def setUp(self):
     # create DeviceOwner to pass the setup_wizard middleware check
     DeviceOwner.objects.create(username='******', password=123)
     self.facility = FacilityFactory.create()
     self.admin = FacilityUserFactory.create(facility=self.facility)
     self.user1 = FacilityUserFactory.create(facility=self.facility)
     self.summary_logs = [
         ContentSummaryLogFactory.create(user=self.user1,
                                         content_id=uuid.uuid4().hex,
                                         channel_id=uuid.uuid4().hex)
         for _ in range(3)
     ]
     self.facility.add_admin(self.admin)
    def setUp(self):
        # create DeviceOwner to pass the setup_wizard middleware check
        self.deviceowner = DeviceOwnerFactory.create()
        self.facility = FacilityFactory.create()
        self.user1 = FacilityUserFactory.create(facility=self.facility)
        self.user2 = FacilityUserFactory.create(facility=self.facility)

        # add admin to 1st facility
        self.admin = FacilityUserFactory.create(facility=self.facility)
        self.facility.add_admin(self.admin)

        # create logs for each user
        self.session_logs = [UserSessionLogFactory.create(user=self.user1) for _ in range(3)]
        [UserSessionLogFactory.create(user=self.user2) for _ in range(2)]

        # create classroom, learner group, add user2
        self.classroom = ClassroomFactory.create(parent=self.facility)
        self.learner_group = LearnerGroupFactory.create(parent=self.classroom)
        self.learner_group.add_learner(self.user2)
Exemplo n.º 14
0
    def setUp(self):
        self.facility = FacilityFactory.create()
        # provision device to pass the setup_wizard middleware check
        provision_device()
        self.user1 = FacilityUserFactory.create(facility=self.facility)
        self.user2 = FacilityUserFactory.create(facility=self.facility)
        self.exam = Exam.objects.create(title="", channel_id="", question_count=0, collection=self.facility, creator=self.user2, active=True)
        self.examlog = ExamLog.objects.create(exam=self.exam, user=self.user1)

        self.examattemptdata = {
            "item": "test",
            "start_timestamp": timezone.now(),
            "end_timestamp": timezone.now(),
            "correct": 0,
            "user": self.user1.pk,
            "examlog": self.examlog.pk,
            "content_id": "77b57a14a1f0466bb27ea7de8ff468be",
            "channel_id": "77b57a14a1f0466bb27ea7de8ff468be",
        }
Exemplo n.º 15
0
 def setUp(self):
     provision_device()
     DatabaseIDModel.objects.create()
     self.facility = FacilityFactory.create()
     self.superuser = create_superuser(self.facility)
     self.client.login(username=self.superuser.username, password=DUMMY_PASSWORD, facility=self.facility)
Exemplo n.º 16
0
 def setUp(self):
     provision_device()
     self.facility = FacilityFactory.create()
     self.superuser = create_superuser(self.facility)
     self.user = FacilityUserFactory.create(facility=self.facility)
     self.client.login(username=self.superuser.username, password=DUMMY_PASSWORD, facility=self.facility)