Commit c251a614 by Tim Krones

Show info about number of attempts used if limited number of attempts available.

parent 177e01e2
......@@ -937,6 +937,8 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes
fragment.add_css_url(self.runtime.local_resource_url(self, 'public/css/problem-builder.css'))
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/mentoring_with_steps.js'))
fragment.add_resource(loader.load_unicode('templates/html/mentoring_attempts.html'), "text/html")
self.include_theme_files(fragment)
fragment.initialize_js('MentoringWithStepsBlock')
......
......@@ -4,7 +4,8 @@ function MentoringWithStepsBlock(runtime, element) {
function(c) { return c.element.className.indexOf('sb-step') > -1; }
);
var activeStep = $('.mentoring', element).data('active-step');
var reviewStep, checkmark, submitDOM, nextDOM, reviewDOM, tryAgainDOM, assessmentMessageDOM, submitXHR;
var attemptsTemplate = _.template($('#xblock-attempts-template').html());
var reviewStep, checkmark, submitDOM, nextDOM, reviewDOM, tryAgainDOM, assessmentMessageDOM, attemptsDOM, submitXHR;
function isLastStep() {
return (activeStep === steps.length-1);
......@@ -80,6 +81,7 @@ function MentoringWithStepsBlock(runtime, element) {
checkmark.removeClass('checkmark-incorrect icon-exclamation fa-exclamation');
hideAllSteps();
assessmentMessageDOM.html('');
attemptsDOM.html('');
}
function updateDisplay() {
......@@ -87,6 +89,7 @@ function MentoringWithStepsBlock(runtime, element) {
if (atReviewStep()) {
showAssessmentMessage();
showReviewStep();
showAttempts();
} else {
showActiveStep();
validateXBlock();
......@@ -111,6 +114,13 @@ function MentoringWithStepsBlock(runtime, element) {
tryAgainDOM.show();
}
function showAttempts() {
var data = attemptsDOM.data();
if (data.max_attempts > 0) {
attemptsDOM.html(attemptsTemplate(data));
} // Don't show attempts if unlimited attempts available (max_attempts === 0)
}
function showActiveStep() {
var step = steps[activeStep];
$(step.element).show();
......@@ -152,6 +162,7 @@ function MentoringWithStepsBlock(runtime, element) {
cleanAll();
showAssessmentMessage();
showReviewStep();
showAttempts();
}
function handleTryAgain(result) {
......@@ -195,6 +206,7 @@ function MentoringWithStepsBlock(runtime, element) {
tryAgainDOM.on('click', tryAgain);
assessmentMessageDOM = $('.assessment-message', element);
attemptsDOM = $('.attempts', element);
var options = {
onChange: onChange
......
......@@ -25,6 +25,11 @@
<input type="button" class="input-next" value="Next Step" disabled="disabled" />
<input type="button" class="input-review" value="Review grade" disabled="disabled" />
<input type="button" class="input-try-again" value="Try again" disabled="disabled" />
<div class="attempts"
data-max_attempts="{{ self.max_attempts }}" data-num_attempts="{{ self.num_attempts }}">
</div>
</div>
</div>
......
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