Commit 6d2c73ca by Chris Dodge Committed by Jonathan Piacenti

cdodge/fire-progress-on-html-module-render: modify the xmodule HTML to fire a…

cdodge/fire-progress-on-html-module-render: modify the xmodule HTML to fire a progress event to record the fact that the user visited that content
parent ead419f0
......@@ -74,6 +74,11 @@ class HtmlModuleMixin(HtmlFields, XModule):
css = {'scss': [resource_string(__name__, 'css/html/display.scss')]}
def get_html(self):
# cdodge: rendering the html module counts as "progress"
# unfortunately, we can't look at settings.FEATURES to make this switchable on/off since settings is a Django concept
# and not in scope in common/lib
self.system.publish(self, 'progress', {})
if self.system.anonymous_student_id:
return self.data.replace("%%USER_ID%%", self.system.anonymous_student_id)
return self.data
......
......@@ -460,6 +460,18 @@ def get_module_system_for_user(user, field_data_cache, # TODO # pylint: disabl
course_id,
descriptor.location,
)
# we can treat a grading event as a indication that a user
# "completed" an xBlock
if settings.FEATURES.get('MARK_PROGRESS_ON_GRADING_EVENT', False):
handle_progress_event(block, event_type, event)
def handle_progress_event(block, event_type, event):
"""
tie into the CourseCompletions datamodels that are exposed in the api_manager djangoapp
"""
user_id = event.get('user_id', user.id)
if not user_id:
return
# Send a signal out to any listeners who are waiting for score change
# events.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment