Commit c88d7a7c by Alan Boudreault

always use 4 spaces

parent c449576f
...@@ -2,8 +2,8 @@ function AnswerBlock(runtime, element) { ...@@ -2,8 +2,8 @@ function AnswerBlock(runtime, element) {
return { return {
init: function(options) { init: function(options) {
// register the child validator // register the child validator
$(':input', element).on('keyup', options.blockValidator); $(':input', element).on('keyup', options.blockValidator);
}, },
submit: function() { submit: function() {
...@@ -15,7 +15,7 @@ function AnswerBlock(runtime, element) { ...@@ -15,7 +15,7 @@ function AnswerBlock(runtime, element) {
$(element).find('.message').text((result || {}).error || ''); $(element).find('.message').text((result || {}).error || '');
checkmark.removeClass( checkmark.removeClass(
'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check' 'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check'
); );
if (result.completed) { if (result.completed) {
checkmark.addClass('checkmark-correct icon-ok fa-check'); checkmark.addClass('checkmark-correct icon-ok fa-check');
...@@ -31,7 +31,7 @@ function AnswerBlock(runtime, element) { ...@@ -31,7 +31,7 @@ function AnswerBlock(runtime, element) {
// return true if the answer is read only // return true if the answer is read only
var blockquote_ro = $('blockquote.answer.read_only', element); var blockquote_ro = $('blockquote.answer.read_only', element);
if (blockquote_ro.length > 0) if (blockquote_ro.length > 0)
return true; return true;
var input = $(':input', element), var input = $(':input', element),
input_value = input.val().replace(/^\s+|\s+$/gm,''), input_value = input.val().replace(/^\s+|\s+$/gm,''),
......
...@@ -55,7 +55,7 @@ function MentoringBlock(runtime, element) { ...@@ -55,7 +55,7 @@ function MentoringBlock(runtime, element) {
function getChildren(element) { function getChildren(element) {
if (!_.isUndefined(children)) if (!_.isUndefined(children))
return children; return children;
var children_dom = $('.xblock-light-child', element); var children_dom = $('.xblock-light-child', element);
children = []; children = [];
...@@ -106,7 +106,7 @@ function MentoringBlock(runtime, element) { ...@@ -106,7 +106,7 @@ function MentoringBlock(runtime, element) {
blockValidator: validateXBlock blockValidator: validateXBlock
}; };
_.each(children, function(child) { _.each(children, function(child) {
callIfExists(child, 'init', options); callIfExists(child, 'init', options);
}); });
...@@ -134,7 +134,7 @@ function MentoringBlock(runtime, element) { ...@@ -134,7 +134,7 @@ function MentoringBlock(runtime, element) {
var children = getChildren(element); var children = getChildren(element);
if ((data.max_attempts > 0) && (data.num_attempts >= data.max_attempts)) { if ((data.max_attempts > 0) && (data.num_attempts >= data.max_attempts)) {
is_valid = false; is_valid = false;
} }
else { else {
for (var i = 0; i < children.length; i++) { for (var i = 0; i < children.length; i++) {
......
// TODO: Split in two files // TODO: Split in two files
function MessageView(element) { function MessageView(element) {
return { return {
messageDOM: $('.feedback', element), messageDOM: $('.feedback', element),
allPopupsDOM: $('.choice-tips, .feedback', element), allPopupsDOM: $('.choice-tips, .feedback', element),
clearPopupEvents: function() { clearPopupEvents: function() {
this.allPopupsDOM.hide(); this.allPopupsDOM.hide();
$('.close', this.allPopupsDOM).off('click'); $('.close', this.allPopupsDOM).off('click');
}, },
showPopup: function(popupDOM) { showPopup: function(popupDOM) {
var self = this; var self = this;
this.clearPopupEvents(); this.clearPopupEvents();
// Set the width/height // Set the width/height
var tip = $('.tip', popupDOM)[0]; var tip = $('.tip', popupDOM)[0];
var data = $(tip).data(); var data = $(tip).data();
if (data && data.width) { if (data && data.width) {
popupDOM.css('width', data.width) popupDOM.css('width', data.width)
} else { } else {
popupDOM.css('width', '') popupDOM.css('width', '')
} }
if (data && data.height) { if (data && data.height) {
popupDOM.css('height', data.height); popupDOM.css('height', data.height);
} else { } else {
popupDOM.css('height', '') popupDOM.css('height', '')
} }
popupDOM.show(); popupDOM.show();
popupDOM.on('click', function() { popupDOM.on('click', function() {
self.clearPopupEvents(); self.clearPopupEvents();
}); });
}, },
showMessage: function(message) { showMessage: function(message) {
if (_.isString(message)) { if (_.isString(message)) {
this.messageDOM.html(message); this.messageDOM.html(message);
this.showPopup(this.messageDOM); this.showPopup(this.messageDOM);
} }
else { else {
this.showPopup(message); // already a DOM this.showPopup(message); // already a DOM
} }
}
} }
}
} }
function MCQBlock(runtime, element) { function MCQBlock(runtime, element) {
...@@ -66,7 +66,7 @@ function MCQBlock(runtime, element) { ...@@ -66,7 +66,7 @@ function MCQBlock(runtime, element) {
choiceTipsCloseDOM; choiceTipsCloseDOM;
choiceResultDOM.removeClass( choiceResultDOM.removeClass(
'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check' 'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check'
); );
if (result.completed && choiceInputDOM.val() === result.submission) { if (result.completed && choiceInputDOM.val() === result.submission) {
choiceResultDOM.addClass('checkmark-correct icon-ok fa-check'); choiceResultDOM.addClass('checkmark-correct icon-ok fa-check');
...@@ -75,17 +75,17 @@ function MCQBlock(runtime, element) { ...@@ -75,17 +75,17 @@ function MCQBlock(runtime, element) {
choiceResultDOM.addClass('checkmark-incorrect icon-exclamation fa-exclamation'); choiceResultDOM.addClass('checkmark-incorrect icon-exclamation fa-exclamation');
} }
var tips = _.find(result.tips, function(obj) { var tips = _.find(result.tips, function(obj) {
return obj.choice === choiceInputDOM.val(); return obj.choice === choiceInputDOM.val();
}); });
if (tips) { if (tips) {
choiceTipsDOM.html(tips.tips); choiceTipsDOM.html(tips.tips);
} }
choiceTipsCloseDOM = $('.close', choiceTipsDOM); choiceTipsCloseDOM = $('.close', choiceTipsDOM);
choiceResultDOM.off('click').on('click', function() { choiceResultDOM.off('click').on('click', function() {
if (choiceTipsDOM.html() != '') { if (choiceTipsDOM.html() != '') {
messageView.showMessage(choiceTipsDOM); messageView.showMessage(choiceTipsDOM);
} }
}); });
}); });
...@@ -96,15 +96,15 @@ function MCQBlock(runtime, element) { ...@@ -96,15 +96,15 @@ function MCQBlock(runtime, element) {
} }
else if (result.tips) { else if (result.tips) {
var tips = _.find(result.tips, function(obj) { var tips = _.find(result.tips, function(obj) {
return obj.choice === result.submission; return obj.choice === result.submission;
}); });
if (tips) { if (tips) {
messageView.showMessage(tips.tips); messageView.showMessage(tips.tips);
} else { } else {
messageView.clearPopupEvents(); messageView.clearPopupEvents();
} }
} }
} }
}; };
} }
...@@ -140,17 +140,17 @@ function MRQBlock(runtime, element) { ...@@ -140,17 +140,17 @@ function MRQBlock(runtime, element) {
choiceTipsCloseDOM; choiceTipsCloseDOM;
choiceResultDOM.removeClass( choiceResultDOM.removeClass(
'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check' 'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check'
); );
/* show hint if checked or max_attempts is disabled */ /* show hint if checked or max_attempts is disabled */
if (!hide_results && if (!hide_results &&
(result.completed || choiceInputDOM.prop('checked') || options.max_attempts <= 0)) { (result.completed || choiceInputDOM.prop('checked') || options.max_attempts <= 0)) {
if (choice.completed) { if (choice.completed) {
choiceResultDOM.addClass('checkmark-correct icon-ok fa-check'); choiceResultDOM.addClass('checkmark-correct icon-ok fa-check');
} else if (!choice.completed) { } else if (!choice.completed) {
choiceResultDOM.addClass('checkmark-incorrect icon-exclamation fa-exclamation'); choiceResultDOM.addClass('checkmark-incorrect icon-exclamation fa-exclamation');
} }
} }
choiceTipsDOM.html(choice.tips); choiceTipsDOM.html(choice.tips);
......
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