Commit df564718 by Tim Krones

Step Builder: Lock and unlock navigation when appropriate.

When navigation is locked, it is not possible to click arrow buttons to
navigate between existing units. This should be the case during
completion of an attempt.

When navigation is unlocked, users can click arrow buttons to navigate
between existing units. This should be the case when user has completed
an attempt, i.e., when they are reviewing their grade for the last
attempt.
parent 1ce056f7
...@@ -178,6 +178,11 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -178,6 +178,11 @@ function MentoringWithStepsBlock(runtime, element) {
function updateDisplay() { function updateDisplay() {
cleanAll(); cleanAll();
if (atReviewStep()) { if (atReviewStep()) {
// Tell supporting runtimes to enable navigation between units;
// user is currently not in the middle of an attempt
// so it makes sense for them to be able to leave the current unit by clicking arrow buttons
notify('navigation', {state: 'unlock'});
showReviewStep(); showReviewStep();
showAttempts(); showAttempts();
} else { } else {
...@@ -324,6 +329,11 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -324,6 +329,11 @@ function MentoringWithStepsBlock(runtime, element) {
} }
function showGrade() { function showGrade() {
// Tell supporting runtimes to enable navigation between units;
// user is currently not in the middle of an attempt
// so it makes sense for them to be able to leave the current unit by clicking arrow buttons
notify('navigation', {state: 'unlock'});
cleanAll(); cleanAll();
showReviewStep(); showReviewStep();
showAttempts(); showAttempts();
...@@ -343,6 +353,11 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -343,6 +353,11 @@ function MentoringWithStepsBlock(runtime, element) {
} }
function handleTryAgain(result) { function handleTryAgain(result) {
// Tell supporting runtimes to disable navigation between units;
// this keeps users from accidentally clicking arrow buttons
// and interrupting their experience with the current unit
notify('navigation', {state: 'lock'});
activeStep = result.active_step; activeStep = result.active_step;
clearSelections(); clearSelections();
updateDisplay(); updateDisplay();
...@@ -364,6 +379,13 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -364,6 +379,13 @@ function MentoringWithStepsBlock(runtime, element) {
submitXHR = $.post(handlerUrl, JSON.stringify({})).success(handleTryAgain); submitXHR = $.post(handlerUrl, JSON.stringify({})).success(handleTryAgain);
} }
function notify(name, data){
// Notification interface does not exist in the workbench.
if (runtime.notify) {
runtime.notify(name, data);
}
}
function initClickHandlers() { function initClickHandlers() {
$(document).on("click", function(event, ui) { $(document).on("click", function(event, ui) {
var target = $(event.target); var target = $(event.target);
...@@ -382,6 +404,11 @@ function MentoringWithStepsBlock(runtime, element) { ...@@ -382,6 +404,11 @@ function MentoringWithStepsBlock(runtime, element) {
} }
function initXBlockView() { function initXBlockView() {
// Tell supporting runtimes to disable navigation between units;
// this keeps users from accidentally clicking arrow buttons
// and interrupting their experience with the current unit
notify('navigation', {state: 'lock'});
// Hide steps until we're ready // Hide steps until we're ready
hideAllSteps(); hideAllSteps();
......
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