Commit 95c94869 by Tim Krones

Don't show "Try again" button if no review step present; show message

about number of submissions used instead.
parent 8f86a2e2
...@@ -19,6 +19,14 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -19,6 +19,14 @@ function MentoringWithStepsBlock(runtime, element) {
return reviewStep.length > 0; return reviewStep.length > 0;
} }
function someAttemptsLeft() {
var data = attemptsDOM.data();
if (data.max_attempts === 0) { // Unlimited number of attempts available
return true;
}
return (data.num_attempts < data.max_attempts);
}
function updateActiveStep(newValue) { function updateActiveStep(newValue) {
var handlerUrl = runtime.handlerUrl(element, 'update_active_step'); var handlerUrl = runtime.handlerUrl(element, 'update_active_step');
$.post(handlerUrl, JSON.stringify(newValue)) $.post(handlerUrl, JSON.stringify(newValue))
...@@ -60,8 +68,12 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -60,8 +68,12 @@ function MentoringWithStepsBlock(runtime, element) {
if (reviewStepPresent()) { if (reviewStepPresent()) {
reviewDOM.removeAttr('disabled'); reviewDOM.removeAttr('disabled');
} else { } else {
if (someAttemptsLeft()) {
tryAgainDOM.removeAttr('disabled'); tryAgainDOM.removeAttr('disabled');
tryAgainDOM.show(); tryAgainDOM.show();
} else {
showAttempts();
}
} }
} }
} }
...@@ -168,8 +180,7 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -168,8 +180,7 @@ function MentoringWithStepsBlock(runtime, element) {
showReviewStep(); showReviewStep();
showAttempts(); showAttempts();
// Disable "Try again" button if no attempts left // Disable "Try again" button if no attempts left
var data = attemptsDOM.data(); if (!someAttemptsLeft()) {
if (data.max_attempts > 0 && data.num_attempts >= data.max_attempts) {
tryAgainDOM.attr("disabled", "disabled"); tryAgainDOM.attr("disabled", "disabled");
} }
} }
......
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