From b7d420a29ed6f486648f455e192ba5c8d0df73bf Mon Sep 17 00:00:00 2001 From: Pooja Kulkarni <13742492+pkulkark@users.noreply.github.com> Date: Wed, 9 Feb 2022 19:58:48 +0530 Subject: [PATCH] * feat: Add completion progress bar to dashboard [SE-4473] Add completion progress bar to dashboard (#29271) --- .../xmodule/xmodule/js/src/sequence/display.js | 2 ++ common/lib/xmodule/xmodule/seq_module.py | 15 ++++++++++++++- lms/templates/courseware/courseware.html | 8 ++++++++ lms/templates/seq_module.html | 10 +++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/sequence/display.js b/common/lib/xmodule/xmodule/js/src/sequence/display.js index ef9991b702..8c48d29a77 100644 --- a/common/lib/xmodule/xmodule/js/src/sequence/display.js +++ b/common/lib/xmodule/xmodule/js/src/sequence/display.js @@ -425,6 +425,8 @@ } }); } + // Reload progress bar + this.$('#progress-frame').attr('src', this.$('#progress-frame').attr('src')); }; Sequence.prototype.mark_active = function(position) { diff --git a/common/lib/xmodule/xmodule/seq_module.py b/common/lib/xmodule/xmodule/seq_module.py index c71ffce6b3..e7dfdd1a0c 100644 --- a/common/lib/xmodule/xmodule/seq_module.py +++ b/common/lib/xmodule/xmodule/seq_module.py @@ -9,6 +9,7 @@ import collections import json import logging from datetime import datetime +from django.conf import settings from functools import reduce from lxml import etree @@ -21,7 +22,7 @@ from xblock.core import XBlock from xblock.exceptions import NoSuchServiceError from xblock.fields import Boolean, Integer, List, Scope, String -from edx_toggles.toggles import LegacyWaffleFlag +from edx_toggles.toggles import LegacyWaffleFlag, SettingDictToggle from xmodule.util.xmodule_django import add_webpack_to_fragment from xmodule.x_module import ( HTMLSnippet, @@ -65,6 +66,15 @@ TIMED_EXAM_GATING_WAFFLE_FLAG = LegacyWaffleFlag( # lint-amnesty, pylint: disab module_name=__name__, ) +# .. toggle_name: FEATURES['SHOW_PROGRESS_BAR'] +# .. toggle_implementation: SettingDictToggle +# .. toggle_default: False +# .. toggle_description: Set to True to show progress bar. +# .. toggle_use_cases: open_edx +# .. toggle_creation_date: 2022-02-09 +# .. toggle_target_removal_date: None +SHOW_PROGRESS_BAR = SettingDictToggle("FEATURES", "SHOW_PROGRESS_BAR", default=False, module_name=__name__) + class SequenceFields: # lint-amnesty, pylint: disable=missing-class-docstring has_children = True @@ -607,6 +617,9 @@ class SequenceBlock( fragment = Fragment() params = self._get_render_metadata(context, display_items, prereq_met, prereq_meta_info, banner_text, view, fragment) # lint-amnesty, pylint: disable=line-too-long + if SHOW_PROGRESS_BAR.is_enabled() and getattr(settings, 'COMPLETION_AGGREGATOR_URL', ''): + parent_block_id = self.get_parent().scope_ids.usage_id.block_id + params['chapter_completion_aggregator_url'] = '/'.join([settings.COMPLETION_AGGREGATOR_URL, str(self.course_id), parent_block_id]) + '/' fragment.add_content(self.runtime.service(self, 'mako').render_template("seq_module.html", params)) self._capture_full_seq_item_metrics(display_items) diff --git a/lms/templates/courseware/courseware.html b/lms/templates/courseware/courseware.html index 9700101c93..722368ffed 100644 --- a/lms/templates/courseware/courseware.html +++ b/lms/templates/courseware/courseware.html @@ -21,6 +21,8 @@ from openedx.features.course_experience import course_home_page_title, DISABLE_C settings.FEATURES.get('ENABLE_SPECIAL_EXAMS', False) and (course.enable_proctored_exams or course.enable_timed_exams) ) + + completion_aggregator_url = settings.COMPLETION_AGGREGATOR_URL if settings.FEATURES.get("SHOW_PROGRESS_BAR", False) else "" %> % if display_reset_dates_banner: @@ -241,6 +243,12 @@ ${HTML(fragment.foot_html())} ${sequence_title} % endif + % if settings.FEATURES.get("SHOW_PROGRESS_BAR", False): +
+ +
+ % endif diff --git a/lms/templates/seq_module.html b/lms/templates/seq_module.html index 7a7d6cadab..6a7aa6c7cc 100644 --- a/lms/templates/seq_module.html +++ b/lms/templates/seq_module.html @@ -1,5 +1,8 @@ <%page expression_filter="h"/> -<%! from django.utils.translation import pgettext, ugettext as _ %> +<%! + from django.utils.translation import pgettext, ugettext as _ + from django.conf import settings +%>
+ % if settings.FEATURES.get("SHOW_PROGRESS_BAR", False): +
+ +
+ % endif % for idx, item in enumerate(items):