Exemple #1
0
 def test_regression_4606_no_contentsessions(self):
     ContentSessionLog.objects.all().delete()
     facility = self.facilities[0]
     # will raise an exception if we haven't addressed https://github.com/learningequality/kolibri/issues/4606
     actual = extract_facility_statistics(facility)
     assert actual["f"] == "2018-10-11"
     assert actual["l"] == "2019-10-11"
Exemple #2
0
 def test_extract_facility_statistics(self):
     facility = self.facilities[0]
     actual = extract_facility_statistics(facility)
     facility_id_hash = actual.pop("fi")
     # just assert the beginning hex values of the facility id don't match
     self.assertFalse(facility_id_hash.startswith(facility.id[:3]))
     expected = {
         "s": {
             "preset": facility_presets.default,
             "learner_can_edit_username": True,
             "learner_can_edit_name": True,
             "learner_can_edit_password": True,
             "learner_can_sign_up": True,
             "learner_can_delete_account": True,
             "learner_can_login_with_no_password": False,
             "show_download_button_in_learn": True,
             "allow_guest_access": True,
         },
         "lc": 20,  # learners_count
         "llc": 20,  # learner_login_count
         "cc": 1,  # coaches_count
         "clc": 1,  # coach_login_count
         "f": "2018-10-11",  # first interaction
         "l": "2019-10-11",  # last interaction
         "ss": 20,  # summarylog_started
         "sc": 20,  # summarylog_complete
         "sk": {content_kinds.EXERCISE: 20, content_kinds.VIDEO: 20},  # sess_kinds
         "lec": 1,  # lesson_count
         "ec": 1,  # exam_count
         "elc": 20,  # exam_log_count
         "alc": 20,  # att_log_count
         "ealc": 20,  # exam_att_log_count
         "suc": 20,  # sess_user_count
         "sac": 20,  # sess_anon_count
         "sut": 20,  # sess_user_time
         "sat": 20,  # sess_anon_time
     }
     assert actual == expected
Exemple #3
0
    def test_extract_facility_statistics(self):
        provision_device(allow_guest_access=True)
        facility = self.facilities[0]
        actual = extract_facility_statistics(facility)
        facility_id_hash = actual.pop("fi")
        birth_year_list_learners = [
            int(year) for year in FacilityUser.objects.filter(
                roles__isnull=True).values_list("birth_year", flat=True)
        ]
        # just assert the beginning hex values of the facility id don't match
        self.assertFalse(facility_id_hash.startswith(facility.id[:3]))
        demo_stats = calculate_list_stats(birth_year_list_learners)
        expected = {
            "s": {
                "preset": facility_presets.default,
                "learner_can_edit_username": True,
                "learner_can_edit_name": True,
                "learner_can_edit_password": True,
                "learner_can_sign_up": True,
                "learner_can_delete_account": True,
                "learner_can_login_with_no_password": False,
                "show_download_button_in_learn": True,
                "allow_guest_access": True,
                "registered": False,
            },
            "lc": 20,  # learners_count
            "llc": 20,  # learner_login_count
            "cc": 1,  # coaches_count
            "clc": 1,  # coach_login_count
            "f": "2018-10-11",  # first interaction
            "l": "2019-10-11",  # last interaction
            "ss": 20,  # summarylog_started
            "sc": 20,  # summarylog_complete
            "sk": {
                content_kinds.EXERCISE: 20,
                content_kinds.VIDEO: 20
            },  # sess_kinds
            "lec": 1,  # lesson_count
            "ec": 1,  # exam_count
            "elc": 20,  # exam_log_count
            "alc": 20,  # att_log_count
            "ealc": 20,  # exam_att_log_count
            "suc": 20,  # sess_user_count
            "sac": 20,  # sess_anon_count
            "sut": 20,  # sess_user_time
            "sat": 20,  # sess_anon_time
            "dsl": {
                "bys": {
                    "a": demo_stats["mean"],
                    "sd": demo_stats["std"],
                    "ts": 20,
                    "d": 0,
                    "ns": 0,
                },
                "gc": {
                    gender: FacilityUser.objects.filter(gender=gender).count()
                    for (gender, _) in demographics.choices
                    if FacilityUser.objects.filter(gender=gender).exists()
                },
            },  # demographic_stats_learner
            "dsnl": {},  # demographic_stats_non_learner
            "crc": 1,  # class_count
            "grc": 0,  # group_count
            "sacnv": 20,  # sess_anon_count_no_visitor_id
            "uwl": 20,  # users_with_logs
            "vwl": 0,  # anon_visitors_with_logs
            "dis": {
                "Android,9/Chrome Mobile,86": 20
            },  # device info
        }

        assert actual == expected