From 74d767cddd87ac8d584a6e4a897a2fe2a1944008 Mon Sep 17 00:00:00 2001 From: Tanya Priyadarshini Date: Thu, 7 Feb 2019 13:24:21 -0800 Subject: [PATCH 1/5] Add an optional include to the bottom of the instructor dashboard While we may use it for other uses in the future, for now we're using it to pull in a custom Google Analytics script. --- .../instructor_dashboard_2/instructor_dashboard_2.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lms/templates/instructor/instructor_dashboard_2/instructor_dashboard_2.html b/lms/templates/instructor/instructor_dashboard_2/instructor_dashboard_2.html index ef67b41b8159..30df42ad1719 100644 --- a/lms/templates/instructor/instructor_dashboard_2/instructor_dashboard_2.html +++ b/lms/templates/instructor/instructor_dashboard_2/instructor_dashboard_2.html @@ -149,3 +149,5 @@

${ section_data <%static:require_module_async module_name="js/dateutil_factory" class_name="DateUtilFactory"> DateUtilFactory.transform(iterationKey=".localized-datetime"); + +<%static:optional_include_mako file="instructor/instructor_dashboard_bottom.html" is_theming_enabled="True" /> From be2b6067dae2b4e9e3fb55e31d23b26369e72def Mon Sep 17 00:00:00 2001 From: Giulio Gratta Date: Wed, 20 Feb 2019 12:04:22 -0800 Subject: [PATCH 2/5] Push version of Submit & Compare xblock to 0.7.0 Also adds syntax to make sure the correct version is installed. --- requirements/edx/stanford.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/edx/stanford.txt b/requirements/edx/stanford.txt index 4d12f218fe58..4c59b54b57b3 100644 --- a/requirements/edx/stanford.txt +++ b/requirements/edx/stanford.txt @@ -5,7 +5,7 @@ xblock-image-modal==0.4.2 -e git+https://github.com/Stanford-Online/xblock-free-text-response@release/v0.4.0#egg=xblock-free-text-response==0.4.0 -e git+https://github.com/Stanford-Online/xblock-grademe.git@v0.1.1#egg=grademebutton -e git+https://github.com/edx-solutions/xblock-ooyala.git@32d52edaa820dbdbf846d8a84f6bccbf0b9c8218#egg=xblock_ooyala_player-master --e git+https://github.com/Stanford-Online/xblock-submit-and-compare.git@release/0.6.2#egg=xblock-submit-and-compare +-e git+https://github.com/Stanford-Online/xblock-submit-and-compare.git@release/0.7.0#egg=xblock-submit-and-compare==0.7.0 -e git+https://github.com/Stanford-Online/xblock-mufi.git@release/0.2.1#egg=xblock_mufi-master -e git+https://github.com/Stanford-Online/edx-analytics-data-api-client.git@1b8260ce8dd6edb999fffc46b09f77c83f87e1f9#egg=edx-analytics-data-api-client -e git+https://github.com/Stanford-Online/xblock-inline-dropdown.git@release/0.2#egg=inline_dropdown From 1f75d296b43599f925d55d21cb3c1d7df01176a9 Mon Sep 17 00:00:00 2001 From: Kevin Luo Date: Tue, 26 Feb 2019 02:46:15 -0800 Subject: [PATCH 3/5] Fix search filter generator to search over all courses instead of none if no course provided --- lms/lib/courseware_search/lms_filter_generator.py | 9 ++++----- .../courseware_search/test/test_lms_filter_generator.py | 8 +++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lms/lib/courseware_search/lms_filter_generator.py b/lms/lib/courseware_search/lms_filter_generator.py index c2e33ab18b60..db599d999fae 100644 --- a/lms/lib/courseware_search/lms_filter_generator.py +++ b/lms/lib/courseware_search/lms_filter_generator.py @@ -28,11 +28,10 @@ def _enrollments_for_user(self, user): def field_dictionary(self, **kwargs): """ add course if provided otherwise add courses in which the user is enrolled in """ field_dictionary = super(LmsSearchFilterGenerator, self).field_dictionary(**kwargs) - if not kwargs.get('user'): - field_dictionary['course'] = [] - elif not kwargs.get('course_id'): - user_enrollments = self._enrollments_for_user(kwargs['user']) - field_dictionary['course'] = [unicode(enrollment.course_id) for enrollment in user_enrollments] + if kwargs.get('user'): + if not kwargs.get('course_id'): + user_enrollments = self._enrollments_for_user(kwargs['user']) + field_dictionary['course'] = [unicode(enrollment.course_id) for enrollment in user_enrollments] # if we have an org filter, only include results for this org filter course_org_filter = configuration_helpers.get_current_site_orgs() diff --git a/lms/lib/courseware_search/test/test_lms_filter_generator.py b/lms/lib/courseware_search/test/test_lms_filter_generator.py index 2f88a8bbd4b3..26a3ab619d52 100644 --- a/lms/lib/courseware_search/test/test_lms_filter_generator.py +++ b/lms/lib/courseware_search/test/test_lms_filter_generator.py @@ -1,6 +1,7 @@ """ Tests for the lms_filter_generator """ +from django.test.utils import override_settings from mock import Mock, patch from lms.lib.courseware_search.lms_filter_generator import LmsSearchFilterGenerator @@ -10,8 +11,9 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +@override_settings(SEARCH_FILTER_GENERATOR="lms.lib.courseware_search.lms_filter_generator.LmsSearchFilterGenerator") class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase): - """ Tests for search result processor """ + """ Tests for search filter generator """ def build_courses(self): """ @@ -80,12 +82,12 @@ def test_course_id_provided(self): def test_user_not_provided(self): """ - Tests that we get empty list of courses in case the user is not provided + Tests that we get empty dict in case the user is not provided """ field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters() self.assertIn('start_date', filter_dictionary) - self.assertEqual(0, len(field_dictionary['course'])) + self.assertEqual({}, field_dictionary) def test_excludes_site_org(self): """ From 4f23ed38716c2f082043603d0caf355348d6634f Mon Sep 17 00:00:00 2001 From: Kevin Luo Date: Tue, 26 Feb 2019 02:57:32 -0800 Subject: [PATCH 4/5] Use custom search filter generator to show course tiles for discovery search --- openedx/stanford/lms/envs/common.py | 1 + openedx/stanford/lms/lib/__init__.py | 0 .../lms/lib/courseware_search/__init__.py | 0 .../courseware_search/lms_filter_generator.py | 27 +++++++++++++++++++ requirements/edx/base.txt | 2 +- 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 openedx/stanford/lms/lib/__init__.py create mode 100644 openedx/stanford/lms/lib/courseware_search/__init__.py create mode 100644 openedx/stanford/lms/lib/courseware_search/lms_filter_generator.py diff --git a/openedx/stanford/lms/envs/common.py b/openedx/stanford/lms/envs/common.py index cd35fd3ebdf3..2c46b1ebd61b 100644 --- a/openedx/stanford/lms/envs/common.py +++ b/openedx/stanford/lms/envs/common.py @@ -114,6 +114,7 @@ # The following fields are available in the URL: {course_id} {student_id} PROGRESS_SUCCESS_BUTTON_URL = 'http:////{course_id}' PROGRESS_SUCCESS_BUTTON_TEXT_OVERRIDE = None +SEARCH_FILTER_GENERATOR = 'openedx.stanford.lms.lib.courseware_search.lms_filter_generator.TileSearchFilterGenerator' SHIB_REDIRECT_DOMAIN_WHITELIST = { # Mapping of hosts to a list of safe redirect domains from that host # (not including itself); e.g. diff --git a/openedx/stanford/lms/lib/__init__.py b/openedx/stanford/lms/lib/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/openedx/stanford/lms/lib/courseware_search/__init__.py b/openedx/stanford/lms/lib/courseware_search/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/openedx/stanford/lms/lib/courseware_search/lms_filter_generator.py b/openedx/stanford/lms/lib/courseware_search/lms_filter_generator.py new file mode 100644 index 000000000000..42ed8ef984e5 --- /dev/null +++ b/openedx/stanford/lms/lib/courseware_search/lms_filter_generator.py @@ -0,0 +1,27 @@ +""" +Custom override of SearchFilterGenerator to use course tiles for +discovery search. +""" +from search.filter_generator import SearchFilterGenerator + +from branding_stanford.models import TileConfiguration +from lms.lib.courseware_search.lms_filter_generator import LmsSearchFilterGenerator + + +class TileSearchFilterGenerator(LmsSearchFilterGenerator): + """ + SearchFilterGenerator for LMS Search. + """ + + def field_dictionary(self, **kwargs): + """ + Return field filter dictionary for search. + """ + field_dictionary = super(TileSearchFilterGenerator, self).field_dictionary(**kwargs) + if not kwargs.get('user'): + # Adds tile courses for discovery search + course_tiles_ids = TileConfiguration.objects.filter( + enabled=True, + ).values_list('course_id', flat=True).order_by('-change_date') + field_dictionary['course'] = list(course_tiles_ids) + return field_dictionary diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index dfd276786f86..10ed55fc9c42 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -58,7 +58,7 @@ edx-oauth2-provider==1.2.0 edx-opaque-keys==0.4.0 edx-organizations==0.4.4 edx-rest-api-client==1.7.1 -edx-search==1.0.1 +git+https://github.com/Stanford-Online/edx-search.git@e2aba4a30cf2dc6aa901799596161a59fa3e3baa#egg=edx-search==1.2.1 facebook-sdk==0.4.0 feedparser==5.1.3 firebase-token-generator==1.3.2 From 358c2b763b9e901151e832f5afbe1f47741597c6 Mon Sep 17 00:00:00 2001 From: Giulio Gratta Date: Wed, 20 Feb 2019 15:34:39 -0800 Subject: [PATCH 5/5] Add optional includes for Studio And make LMS header include match --- cms/templates/base.html | 1 + cms/templates/widgets/header.html | 2 ++ lms/templates/header.html | 1 + 3 files changed, 4 insertions(+) diff --git a/cms/templates/base.html b/cms/templates/base.html index 6bb12a52a098..c5224332657f 100644 --- a/cms/templates/base.html +++ b/cms/templates/base.html @@ -49,6 +49,7 @@ <%include file="widgets/segment-io.html" /> <%block name="header_extras"> + <%static:optional_include_mako file="head-extra.html" is_theming_enabled="True" /> diff --git a/cms/templates/widgets/header.html b/cms/templates/widgets/header.html index 8ed05dc00cd4..f8a7b81de1b6 100644 --- a/cms/templates/widgets/header.html +++ b/cms/templates/widgets/header.html @@ -6,6 +6,8 @@ from django.utils.translation import ugettext as _ from openedx.core.djangoapps.lang_pref.api import header_language_selector_is_enabled, released_languages %> +<%static:optional_include_mako file="header-pre.html" is_theming_enabled="True" /> +