Commit 6a86b678 by Tim Krones

Disable "Try again" button if no attempts left.

parent c251a614
...@@ -980,7 +980,9 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes ...@@ -980,7 +980,9 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes
@XBlock.json_handler @XBlock.json_handler
def update_num_attempts(self, data, suffix=''): def update_num_attempts(self, data, suffix=''):
self.num_attempts += 1 self.num_attempts += 1
return {} return {
'num_attempts': self.num_attempts
}
@XBlock.json_handler @XBlock.json_handler
def try_again(self, data, suffix=''): def try_again(self, data, suffix=''):
......
...@@ -29,7 +29,10 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -29,7 +29,10 @@ function MentoringWithStepsBlock(runtime, element) {
function updateNumAttempts() { function updateNumAttempts() {
var handlerUrl = runtime.handlerUrl(element, 'update_num_attempts'); 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) { function handleResults(response) {
...@@ -163,6 +166,11 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -163,6 +166,11 @@ function MentoringWithStepsBlock(runtime, element) {
showAssessmentMessage(); showAssessmentMessage();
showReviewStep(); showReviewStep();
showAttempts(); 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) { 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