Commit 8e364314 by Tim Krones

Merge pull request #68 from open-craft/assessments-qa

Step Builder: Allow re-adding children after removing them and (un)lock unit navigation when appropriate
parents 3e8040bd df564718
...@@ -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();
......
function MentoringWithStepsEdit(runtime, element) { function MentoringWithStepsEdit(runtime, element) {
"use strict"; "use strict";
var $buttons = $('.add-xblock-component-button[data-category=sb-review-step]', element);
var blockIsPresent = function(klass) { var blockIsPresent = function(klass) {
return $('.xblock ' + klass).length > 0; return $('.xblock ' + klass).length > 0;
}; };
...@@ -18,16 +20,26 @@ function MentoringWithStepsEdit(runtime, element) { ...@@ -18,16 +20,26 @@ function MentoringWithStepsEdit(runtime, element) {
} }
}; };
var initButtons = function(dataCategory) { var updateButtons = function(buttons) {
var $buttons = $('.add-xblock-component-button[data-category='+dataCategory+']', element); buttons.each(function() {
$buttons.each(function() { var button = $(this);
updateButton($(this), blockIsPresent('.xblock-header-sb-review-step')); updateButton(button, blockIsPresent('.xblock-header-sb-review-step'));
}); });
};
var initButtons = function() {
updateButtons($buttons);
$buttons.on('click', disableButton); $buttons.on('click', disableButton);
}; };
initButtons('sb-review-step'); var resetButtons = function() {
var $disabledButtons = $buttons.filter('.disabled');
updateButtons($disabledButtons);
};
ProblemBuilderUtil.transformClarifications(element); ProblemBuilderUtil.transformClarifications(element);
StudioEditableXBlockMixin(runtime, element);
initButtons();
runtime.listenTo('deleted-child', resetButtons);
} }
function ReviewStepEdit(runtime, element) { function ReviewStepEdit(runtime, element) {
"use strict"; "use strict";
var $buttons = $('.add-xblock-component-button[data-category=pb-message]', element);
var blockIsPresent = function(klass) { var blockIsPresent = function(klass) {
return $('.xblock ' + klass).length > 0; return $('.xblock ' + klass).length > 0;
}; };
...@@ -18,17 +20,27 @@ function ReviewStepEdit(runtime, element) { ...@@ -18,17 +20,27 @@ function ReviewStepEdit(runtime, element) {
} }
}; };
var initButtons = function(dataCategory) { var updateButtons = function(buttons) {
var $buttons = $('.add-xblock-component-button[data-category='+dataCategory+']', element); buttons.each(function() {
$buttons.each(function() { var button = $(this);
var msg_type = $(this).data('boilerplate'); var msgType = button.data('boilerplate');
updateButton($(this), blockIsPresent('.submission-message.'+msg_type)); updateButton(button, blockIsPresent('.submission-message.'+msgType));
}); });
};
var initButtons = function() {
updateButtons($buttons);
$buttons.on('click', disableButton); $buttons.on('click', disableButton);
}; };
initButtons('pb-message'); var resetButtons = function() {
var $disabledButtons = $buttons.filter('.disabled');
updateButtons($disabledButtons);
};
ProblemBuilderUtil.transformClarifications(element); ProblemBuilderUtil.transformClarifications(element);
StudioEditableXBlockMixin(runtime, element);
initButtons();
runtime.listenTo('deleted-child', resetButtons);
} }
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