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