def wipe(): clear_non_admin_users() CourseEnrollment.objects.all().delete() StudentModule.objects.all().delete() CourseOverview.objects.all().delete() CourseDailyMetrics.objects.all().delete() SiteDailyMetrics.objects.all().delete() LearnerCourseGradeMetrics.all().delete()
def test_create(self): obj = LearnerCourseGradeMetrics(**self.create_rec) assert str(obj) == '{} {} {} {}'.format( None, self.create_rec['date_for'], self.create_rec['user'].username, self.create_rec['course_id'])
def test_completed_ids_for_site(self): """ Example data ``` {'course_id': u'course-v1:StarFleetAcademy+SFA2+2161', 'user_id': 1} ``` """ lcgm_data = create_sample_completed_lcgm(self.site, user_count=2, course_count=2) # Build lcgm w/out completion LearnerCourseGradeMetrics(site=self.site, sections_possible=2, sections_worked=1) data = LearnerCourseGradeMetrics.objects.completed_ids_for_site(self.site) # Check we have our expected data expected = [(a.id, b) for a in lcgm_data['users'] for b in lcgm_data['course_ids']] results = [(rec['user_id'], rec['course_id']) for rec in data] assert set(results) == set(expected)
def test_progress_details(self): obj = LearnerCourseGradeMetrics(**self.create_rec) assert obj.progress_details == self.grade_data
def test_progress_percent_zero_sections_possible(self): create_rec = self.create_rec.copy() create_rec['sections_possible'] = 0 obj = LearnerCourseGradeMetrics(**create_rec) assert obj.progress_percent == 0.0
def test_progress_percent(self): expected = (self.grade_data['sections_worked'] / self.grade_data['sections_possible']) obj = LearnerCourseGradeMetrics(**self.create_rec) assert obj.progress_percent == expected