Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Add passing_users to course summary
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Fischer committed May 22, 2017
1 parent 5a85c45 commit 07851f0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions analytics_data_api/v0/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class CourseMetaSummaryEnrollment(BaseCourseModel):
count = models.IntegerField(null=False)
cumulative_count = models.IntegerField(null=False)
count_change_7_days = models.IntegerField(default=0)
passing_users = models.IntegerField(default=0)

class Meta(BaseCourseModel.Meta):
db_table = 'course_meta_summary_enrollment'
Expand Down
1 change: 1 addition & 0 deletions analytics_data_api/v0/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ class CourseMetaSummaryEnrollmentSerializer(ModelSerializerWithCreatedField, Dyn
count = serializers.IntegerField(default=0)
cumulative_count = serializers.IntegerField(default=0)
count_change_7_days = serializers.IntegerField(default=0)
passing_users = serializers.IntegerField(default=0)
enrollment_modes = serializers.SerializerMethodField()
programs = serializers.SerializerMethodField()

Expand Down
6 changes: 5 additions & 1 deletion analytics_data_api/v0/tests/views/test_course_summaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create_model(self, model_id, **kwargs):
start_time=datetime.datetime(2016, 10, 11, tzinfo=pytz.utc),
end_time=datetime.datetime(2016, 12, 18, tzinfo=pytz.utc),
pacing_type='instructor', availability=kwargs['availability'], enrollment_mode=mode,
count=5, cumulative_count=10, count_change_7_days=1, create=self.now,)
count=5, cumulative_count=10, count_change_7_days=1, passing_users=1, create=self.now,)
if 'programs' in kwargs and kwargs['programs']:
# Create a link from this course to a program
G(models.CourseProgramMetadata, course_id=model_id, program_id=CourseSamples.program_ids[0],
Expand Down Expand Up @@ -70,20 +70,23 @@ def expected_result(self, item_id, modes=None, availability='Current', programs=
('count', count_factor * num_modes),
('cumulative_count', cumulative_count_factor * num_modes),
('count_change_7_days', count_change_factor * num_modes),
('passing_users', count_change_factor * num_modes),
('enrollment_modes', {}),
])
summary['enrollment_modes'].update({
mode: {
'count': count_factor,
'cumulative_count': cumulative_count_factor,
'count_change_7_days': count_change_factor,
'passing_users': count_change_factor,
} for mode in modes
})
summary['enrollment_modes'].update({
mode: {
'count': 0,
'cumulative_count': 0,
'count_change_7_days': 0,
'passing_users': 0,
} for mode in set(enrollment_modes.ALL) - set(modes)
})
no_prof = summary['enrollment_modes'].pop(enrollment_modes.PROFESSIONAL_NO_ID)
Expand All @@ -92,6 +95,7 @@ def expected_result(self, item_id, modes=None, availability='Current', programs=
'count': prof['count'] + no_prof['count'],
'cumulative_count': prof['cumulative_count'] + no_prof['cumulative_count'],
'count_change_7_days': prof['count_change_7_days'] + no_prof['count_change_7_days'],
'passing_users': prof['passing_users'] + no_prof['passing_users'],
})
if programs:
summary['programs'] = [CourseSamples.program_ids[0]]
Expand Down
2 changes: 1 addition & 1 deletion analytics_data_api/v0/views/course_summaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CourseSummariesView(APIListView):
model = models.CourseMetaSummaryEnrollment
model_id_field = 'course_id'
programs_model = models.CourseProgramMetadata
count_fields = ('count', 'cumulative_count', 'count_change_7_days') # are initialized to 0 by default
count_fields = ('count', 'cumulative_count', 'count_change_7_days', 'passing_users') # are initialized to 0 by default
summary_meta_fields = ['catalog_course_title', 'catalog_course', 'start_time', 'end_time',
'pacing_type', 'availability'] # fields to extract from summary model

Expand Down

0 comments on commit 07851f0

Please sign in to comment.