feat: add reset option to Randomized Content Block

This makes the reset button to refresh the contents of a Randomized
Content Block (RCB) without reloading the full page by fetching a new
set of problems in the "reset" response and replacing the DOM contents.

The reset button returns the student view as a string and the client
uses the HtmlUtils package to replace the contents and reinitializes the
XBlock.

This allows students to use the RCB as a flash card system.

Co-authored-by: tinumide <tinuade@opencraft.com>
This commit is contained in:
Arunmozhi
2021-09-01 13:47:39 +00:00
committed by Agrendalath
parent dae0de89dd
commit 2b39da69b9
5 changed files with 116 additions and 2 deletions

View File

@@ -635,6 +635,17 @@ html.video-fullscreen {
border-bottom: 1px solid #ddd;
margin-bottom: ($baseline*0.75);
padding: 0 0 15px;
.problem-reset-btn-wrapper {
position: relative;
.problem-reset-btn {
&:hover,
&:focus,
&:active {
color: $primary;
}
}
}
}
.vert > .xblock-student_view.is-hidden,

View File

@@ -69,6 +69,12 @@ from openedx.core.djangolib.markup import HTML
% endfor
</div>
% if reset_button:
<div class="problem-reset-btn-wrapper">
<button type="button" class="problem-reset-btn btn-link" data-value="${_('Reset Problems')}"><span aria-hidden="true">${_('Reset Problems')}</span><span class="sr">${_("Reset Problems")}</span></button>
</div>
% endif
<%static:require_module_async module_name="js/dateutil_factory" class_name="DateUtilFactory">
DateUtilFactory.transform('.localized-datetime');
</%static:require_module_async>