From 6cbb9cbca3617da89ffae3a888b10a5c5d9bbaf2 Mon Sep 17 00:00:00 2001 From: Kshitij Sobti Date: Wed, 4 Aug 2021 15:34:13 +0530 Subject: [PATCH] feat: Supply documentation links for course apps from the backend (#28327) Instead of hard-coding the "Learn More" and potentially other links for course apps in the course authoring MFEs this change loads those URLs from the django settings as part of each individual course app. --- cms/envs/common.py | 11 +++++++++++ lms/djangoapps/course_wiki/plugins/__init__.py | 3 +++ lms/djangoapps/courseware/plugins.py | 9 +++++++++ lms/djangoapps/edxnotes/plugins.py | 3 +++ lms/djangoapps/teams/plugins.py | 3 +++ lms/envs/common.py | 11 +++++++++++ openedx/core/djangoapps/course_apps/plugins.py | 5 +++++ .../core/djangoapps/course_apps/rest_api/v1/views.py | 2 ++ openedx/core/djangoapps/discussions/plugins.py | 4 ++++ 9 files changed, 51 insertions(+) diff --git a/cms/envs/common.py b/cms/envs/common.py index a864c8725e..d85a10222b 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -2452,3 +2452,14 @@ COURSE_OLX_VALIDATION_IGNORE_LIST = None ################# show account activate cta after register ######################## SHOW_ACTIVATE_CTA_POPUP_COOKIE_NAME = 'show-account-activation-popup' SHOW_ACCOUNT_ACTIVATION_CTA = False + +################# Documentation links for course apps ################# + +# pylint: disable=line-too-long +CALCULATOR_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/exercises_tools/calculator.html" +DISCUSSIONS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_components/create_discussion.html" +EDXNOTES_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/exercises_tools/notes.html" +PROGRESS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_assets/pages.html?highlight=progress#hiding-or-showing-the-wiki-or-progress-pages" +TEAMS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_features/teams/teams_setup.html" +TEXTBOOKS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_assets/textbooks.html" +WIKI_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_assets/course_wiki.html" diff --git a/lms/djangoapps/course_wiki/plugins/__init__.py b/lms/djangoapps/course_wiki/plugins/__init__.py index 9c0a78aa59..413c9bc32c 100644 --- a/lms/djangoapps/course_wiki/plugins/__init__.py +++ b/lms/djangoapps/course_wiki/plugins/__init__.py @@ -25,6 +25,9 @@ class WikiCourseApp(CourseApp): app_id = "wiki" name = _("Wiki") description = _("Enable learners to access, and collaborate on course related information.") + documentation_links = { + "learn_more_configuration": settings.WIKI_HELP_URL, + } @classmethod def is_available(cls, course_key: CourseKey) -> bool: # pylint: disable=unused-argument diff --git a/lms/djangoapps/courseware/plugins.py b/lms/djangoapps/courseware/plugins.py index 57169f3bf5..b75b730a3c 100644 --- a/lms/djangoapps/courseware/plugins.py +++ b/lms/djangoapps/courseware/plugins.py @@ -25,6 +25,9 @@ class ProgressCourseApp(CourseApp): app_id = "progress" name = _("Progress") description = _("Keep learners engaged and on track throughout the course.") + documentation_links = { + "learn_more_configuration": settings.PROGRESS_HELP_URL, + } @classmethod def is_available(cls, course_key: CourseKey) -> bool: @@ -69,6 +72,9 @@ class TextbooksCourseApp(CourseApp): app_id = "textbooks" name = _("Textbooks") description = _("Create and manage a library of course readings, textbooks, and chapters.") + documentation_links = { + "learn_more_configuration": settings.TEXTBOOKS_HELP_URL, + } @classmethod def is_available(cls, course_key: CourseKey) -> bool: # pylint: disable=unused-argument @@ -117,6 +123,9 @@ class CalculatorCourseApp(CourseApp): app_id = "calculator" name = _("Calculator") description = _("Provide an in-course calculator for simple and complex calculations.") + documentation_links = { + "learn_more_configuration": settings.CALCULATOR_HELP_URL, + } @classmethod def is_available(cls, course_key: CourseKey) -> bool: diff --git a/lms/djangoapps/edxnotes/plugins.py b/lms/djangoapps/edxnotes/plugins.py index 9df87219b5..0efec84952 100644 --- a/lms/djangoapps/edxnotes/plugins.py +++ b/lms/djangoapps/edxnotes/plugins.py @@ -54,6 +54,9 @@ class EdxNotesCourseApp(CourseApp): app_id = "edxnotes" name = _("Notes") description = _("Allow learners to highlight passages and make notes right in the course.") + documentation_links = { + "learn_more_configuration": settings.EDXNOTES_HELP_URL, + } @classmethod def is_available(cls, course_key: CourseKey) -> bool: # pylint: disable=unused-argument diff --git a/lms/djangoapps/teams/plugins.py b/lms/djangoapps/teams/plugins.py index 469656055c..d7ae91c17b 100644 --- a/lms/djangoapps/teams/plugins.py +++ b/lms/djangoapps/teams/plugins.py @@ -48,6 +48,9 @@ class TeamsCourseApp(CourseApp): app_id = "teams" name = _("Teams") description = _("Leverage teams to allow learners to connect by topic of interest.") + documentation_links = { + "learn_more_configuration": settings.TEAMS_HELP_URL, + } @classmethod def is_available(cls, course_key: CourseKey) -> bool: diff --git a/lms/envs/common.py b/lms/envs/common.py index a89e2bf992..852cabe999 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -4789,3 +4789,14 @@ SHOW_ACCOUNT_ACTIVATION_CTA = False ################# Settings for Chrome-specific origin trials ######## # Token for " Disable Different Origin Subframe Dialog Suppression" for http://localhost:18000 CHROME_DISABLE_SUBFRAME_DIALOG_SUPPRESSION_TOKEN = 'ArNBN7d1AkvMhJTGWXlJ8td/AN4lOokzOnqKRNkTnLqaqx0HpfYvmx8JePPs/emKh6O5fckx14LeZIGJ1AQYjgAAAABzeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjE4MDAwIiwiZmVhdHVyZSI6IkRpc2FibGVEaWZmZXJlbnRPcmlnaW5TdWJmcmFtZURpYWxvZ1N1cHByZXNzaW9uIiwiZXhwaXJ5IjoxNjM5NTI2Mzk5fQ==' # pylint: disable=line-too-long + +################# Documentation links for course apps ################# + +# pylint: disable=line-too-long +CALCULATOR_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/exercises_tools/calculator.html" +DISCUSSIONS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_components/create_discussion.html" +EDXNOTES_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/exercises_tools/notes.html" +PROGRESS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_assets/pages.html?highlight=progress#hiding-or-showing-the-wiki-or-progress-pages" +TEAMS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_features/teams/teams_setup.html" +TEXTBOOKS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_assets/textbooks.html" +WIKI_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_assets/course_wiki.html" diff --git a/openedx/core/djangoapps/course_apps/plugins.py b/openedx/core/djangoapps/course_apps/plugins.py index aa4f772b3d..183c7a2396 100644 --- a/openedx/core/djangoapps/course_apps/plugins.py +++ b/openedx/core/djangoapps/course_apps/plugins.py @@ -23,6 +23,11 @@ class CourseApp(ABC): name: str = "" # A description for the app. description: str = "" + # A map of documentation links for the app + documentation_links: Dict = { + # eg: + # "learn_more_configuration": "https://..." + } @classmethod @abstractmethod diff --git a/openedx/core/djangoapps/course_apps/rest_api/v1/views.py b/openedx/core/djangoapps/course_apps/rest_api/v1/views.py index 9b55caa95d..35bdb707f5 100644 --- a/openedx/core/djangoapps/course_apps/rest_api/v1/views.py +++ b/openedx/core/djangoapps/course_apps/rest_api/v1/views.py @@ -51,6 +51,7 @@ class CourseAppSerializer(serializers.Serializer): # pylint: disable=abstract-m name = serializers.CharField(read_only=True, help_text="Friendly name of the course app.") description = serializers.CharField(read_only=True, help_text="A friendly description of what the course app does.") legacy_link = serializers.URLField(required=False, help_text="A link to the course app in the legacy studio view.") + documentation_links = serializers.JSONField(required=True) allowed_operations = serializers.DictField( read_only=True, help_text="What all operations are supported by the app.", @@ -65,6 +66,7 @@ class CourseAppSerializer(serializers.Serializer): # pylint: disable=abstract-m "name": instance.name, "description": instance.description, "allowed_operations": instance.get_allowed_operations(course_key, request.user), + "documentation_links": instance.documentation_links, } if hasattr(instance, "legacy_link"): data["legacy_link"] = request.build_absolute_uri(instance.legacy_link(course_key)) diff --git a/openedx/core/djangoapps/discussions/plugins.py b/openedx/core/djangoapps/discussions/plugins.py index 3694b5cf25..74d8c843aa 100644 --- a/openedx/core/djangoapps/discussions/plugins.py +++ b/openedx/core/djangoapps/discussions/plugins.py @@ -3,6 +3,7 @@ Course app configuration for discussions. """ from typing import Dict, Optional +from django.conf import settings from django.contrib.auth import get_user_model from django.utils.translation import ugettext_noop as _ from opaque_keys.edx.keys import CourseKey @@ -21,6 +22,9 @@ class DiscussionCourseApp(CourseApp): app_id = "discussion" name = _("Discussion") description = _("Encourage participation and engagement in your course with discussions.") + documentation_links = { + "learn_more_configuration": settings.DISCUSSIONS_HELP_URL, + } @classmethod def is_available(cls, course_key: CourseKey) -> bool: