REVEM-74 Add program info to user-metadata
This commit is contained in:
@@ -215,12 +215,13 @@ class IndexQueryTestCase(ModuleStoreTestCase):
|
||||
NUM_PROBLEMS = 20
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 10, 179),
|
||||
(ModuleStoreEnum.Type.split, 4, 173),
|
||||
(ModuleStoreEnum.Type.mongo, 10, 180),
|
||||
(ModuleStoreEnum.Type.split, 4, 174),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_index_query_counts(self, store_type, expected_mongo_query_count, expected_mysql_query_count):
|
||||
# TODO: decrease query count as part of REVO-28
|
||||
# TODO: decrease query count as part of REVEM-106
|
||||
ContentTypeGatingConfig.objects.create(enabled=True, enabled_as_of=datetime(2018, 1, 1))
|
||||
with self.store.default_store(store_type):
|
||||
course = CourseFactory.create()
|
||||
@@ -1442,13 +1443,14 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
self.assertContains(resp, u"Download Your Certificate")
|
||||
|
||||
@ddt.data(
|
||||
(True, 56),
|
||||
(False, 55)
|
||||
(True, 57),
|
||||
(False, 56)
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_progress_queries_paced_courses(self, self_paced, query_count):
|
||||
"""Test that query counts remain the same for self-paced and instructor-paced courses."""
|
||||
# TODO: decrease query count as part of REVO-28
|
||||
# TODO: decrease query count as part of REVEM-106
|
||||
ContentTypeGatingConfig.objects.create(enabled=True, enabled_as_of=datetime(2018, 1, 1))
|
||||
self.setup_course(self_paced=self_paced)
|
||||
with self.assertNumQueries(query_count, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST), check_mongo_calls(1):
|
||||
@@ -1456,11 +1458,12 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ASSUME_ZERO_GRADE_IF_ABSENT_FOR_ALL_TESTS': False})
|
||||
@ddt.data(
|
||||
(False, 63, 43),
|
||||
(True, 55, 39)
|
||||
(False, 64, 44),
|
||||
(True, 56, 40)
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_progress_queries(self, enable_waffle, initial, subsequent):
|
||||
# TODO: decrease query count as part of REVEM-106
|
||||
ContentTypeGatingConfig.objects.create(enabled=True, enabled_as_of=datetime(2018, 1, 1))
|
||||
self.setup_course()
|
||||
with grades_waffle().override(ASSUME_ZERO_GRADE_IF_ABSENT, active=enable_waffle):
|
||||
|
||||
@@ -8,6 +8,8 @@ from courseware.date_summary import (
|
||||
verified_upgrade_deadline_link, verified_upgrade_link_is_valid
|
||||
)
|
||||
from xmodule.partitions.partitions_service import get_user_partition_groups, get_all_partitions_for_course
|
||||
from crum import get_current_request
|
||||
from openedx.core.djangoapps.programs.utils import ProgramDataExtender, ProgramProgressMeter
|
||||
|
||||
|
||||
def check_and_get_upgrade_link_and_date(user, enrollment=None, course=None):
|
||||
@@ -57,6 +59,9 @@ def get_experiment_user_metadata_context(course, user):
|
||||
# TODO: clean up as part of REVO-28 (START)
|
||||
has_non_audit_enrollments = None
|
||||
# TODO: clean up as part of REVO-28 (END)
|
||||
# TODO: clean up as part of REVEM-106 (START)
|
||||
program_key = None
|
||||
# TODO: clean up as part of REVEM-106 (END)
|
||||
try:
|
||||
# TODO: clean up as part of REVO-28 (START)
|
||||
user_enrollments = CourseEnrollment.objects.select_related('course').filter(user_id=user.id)
|
||||
@@ -69,6 +74,39 @@ def get_experiment_user_metadata_context(course, user):
|
||||
if enrollment.is_active:
|
||||
enrollment_mode = enrollment.mode
|
||||
enrollment_time = enrollment.created
|
||||
|
||||
# TODO: clean up as part of REVEM-106 (START)
|
||||
# get program data for this course
|
||||
request = get_current_request()
|
||||
if request:
|
||||
enrollment_list = [enrollment]
|
||||
meter = ProgramProgressMeter(request.site, user, enrollments=enrollment_list)
|
||||
if meter.engaged_programs and meter.engaged_programs[0]:
|
||||
org_name = None
|
||||
courses_not_started = 0
|
||||
courses_in_progress = 0
|
||||
courses_completed = 0
|
||||
program_data = meter.engaged_programs[0]
|
||||
program_data = ProgramDataExtender(program_data, user, mobile_only=False).extend()
|
||||
program_orgs = program_data.get('credit_backing_organizations')
|
||||
if program_orgs and program_orgs[0]:
|
||||
org = program_orgs[0]
|
||||
org_name = org.get('name')
|
||||
if meter.progress() and meter.progress()[0]:
|
||||
progress = meter.progress()[0]
|
||||
courses_not_started = progress.get('not_started')
|
||||
courses_in_progress = progress.get('in_progress')
|
||||
courses_completed = progress.get('completed')
|
||||
program_key = {
|
||||
'uuid': program_data.get('uuid'),
|
||||
'title': program_data.get('title'),
|
||||
'marketing_url': program_data.get('marketing_url'),
|
||||
'org_name': org_name,
|
||||
'courses_not_started': courses_not_started,
|
||||
'courses_in_progress': courses_in_progress,
|
||||
'courses_completed': courses_completed,
|
||||
}
|
||||
# TODO: clean up as part of REVEM-106 (END)
|
||||
except CourseEnrollment.DoesNotExist:
|
||||
pass # Not enrolled, used the default None values
|
||||
|
||||
@@ -102,4 +140,7 @@ def get_experiment_user_metadata_context(course, user):
|
||||
# TODO: clean up as part of REVO-28 (START)
|
||||
'has_non_audit_enrollments': has_non_audit_enrollments,
|
||||
# TODO: clean up as part of REVO-28 (END)
|
||||
# TODO: clean up as part of REVEM-106 (START)
|
||||
'program_key_fields': program_key,
|
||||
# TODO: clean up as part of REVEM-106 (END)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,10 @@ user_metadata = {
|
||||
'partition_groups',
|
||||
# TODO: clean up as part of REVO-28 (START)
|
||||
'has_non_audit_enrollments',
|
||||
# TODO: clean up as part of REtest_VO-28 (END)
|
||||
# TODO: clean up as part of REVO-28 (END)
|
||||
# TODO: clean up as part of REVEM-106 (START)
|
||||
'program_key_fields',
|
||||
# TODO: clean up as part of REVEM-106 (END)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,8 @@ class TestCourseHomePage(CourseHomePageTestCase):
|
||||
|
||||
# Fetch the view and verify the query counts
|
||||
# TODO: decrease query count as part of REVO-28
|
||||
with self.assertNumQueries(87, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
|
||||
# TODO: decrease query count as part of REVEM-106
|
||||
with self.assertNumQueries(88, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
|
||||
with check_mongo_calls(4):
|
||||
url = course_home_url(self.course)
|
||||
self.client.get(url)
|
||||
|
||||
@@ -130,7 +130,8 @@ class TestCourseUpdatesPage(SharedModuleStoreTestCase):
|
||||
|
||||
# Fetch the view and verify that the query counts haven't changed
|
||||
# TODO: decrease query count as part of REVO-28
|
||||
with self.assertNumQueries(53, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
|
||||
# TODO: decrease query count as part of REVEM-106
|
||||
with self.assertNumQueries(54, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
|
||||
with check_mongo_calls(4):
|
||||
url = course_updates_url(self.course)
|
||||
self.client.get(url)
|
||||
|
||||
Reference in New Issue
Block a user