Commit 6a86b678 by Tim Krones

Disable "Try again" button if no attempts left.

parent c251a614
......@@ -980,7 +980,9 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes
@XBlock.json_handler
def update_num_attempts(self, data, suffix=''):
self.num_attempts += 1
return {}
return {
'num_attempts': self.num_attempts
}
@XBlock.json_handler
def try_again(self, data, suffix=''):
......
......@@ -29,7 +29,10 @@ function MentoringWithStepsBlock(runtime, element) {
function updateNumAttempts() {
var handlerUrl = runtime.handlerUrl(element, 'update_num_attempts');
$.post(handlerUrl, JSON.stringify({}));
$.post(handlerUrl, JSON.stringify({}))
.success(function(response) {
attemptsDOM.data('num_attempts', response.num_attempts);
});
}
function handleResults(response) {
......@@ -163,6 +166,11 @@ function MentoringWithStepsBlock(runtime, element) {
showAssessmentMessage();
showReviewStep();
showAttempts();
// Disable "Try again" button if no attempts left
var data = attemptsDOM.data();
if (data.max_attempts > 0 && data.num_attempts >= data.max_attempts) {
tryAgainDOM.attr("disabled", "disabled");
}
}
function handleTryAgain(result) {
......
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