Commit f07502fe by Tim Krones

Redirect to review step when reloading page after submitting last step.

parent 433ce153
......@@ -865,6 +865,11 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes
child_isinstance(self, child_id, MentoringStepBlock)
]
@property
def has_review_step(self):
from .step import ReviewStepBlock
return any(child_isinstance(self, child_id, ReviewStepBlock) for child_id in self.children)
def student_view(self, context):
fragment = Fragment()
children_contents = []
......@@ -919,6 +924,9 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes
def update_active_step(self, new_value, suffix=''):
if new_value < len(self.steps):
self.active_step = new_value
elif new_value == len(self.steps):
if self.has_review_step:
self.active_step = -1
return {
'active_step': self.active_step
}
......
......@@ -10,6 +10,10 @@ function MentoringWithStepsBlock(runtime, element) {
return (activeStep === steps.length-1);
}
function atReviewStep() {
return (activeStep === -1);
}
function updateActiveStep(newValue) {
var handlerUrl = runtime.handlerUrl(element, 'update_active_step');
$.post(handlerUrl, JSON.stringify(newValue))
......@@ -64,14 +68,26 @@ function MentoringWithStepsBlock(runtime, element) {
function updateDisplay() {
cleanAll();
showActiveStep();
validateXBlock();
nextDOM.attr('disabled', 'disabled');
if (isLastStep()) {
reviewDOM.show();
if (atReviewStep()) {
showReviewStep();
} else {
showActiveStep();
validateXBlock();
nextDOM.attr('disabled', 'disabled');
if (isLastStep()) {
reviewDOM.show();
}
}
}
function showReviewStep() {
reviewStep.show();
submitDOM.hide();
nextDOM.hide();
tryAgainDOM.removeAttr('disabled');
tryAgainDOM.show();
}
function showActiveStep() {
var step = steps[activeStep];
$(step.element).show();
......
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