Commit 68f5b96b by Xavier Antoviaque

Merge pull request #58 from aboudreault/html-tip-fix

Fix html tip display issue and an issue related to publish_event
parents 5a365759 9bbaee77
......@@ -13,6 +13,15 @@ function MentoringBlock(runtime, element) {
}
}
function setContent(dom, content) {
dom.html('');
dom.append(content);
var template = $('#light-child-template', dom).html();
if (template) {
dom.append(template);
}
}
function renderAttempts() {
var data = $('.attempts', element).data();
$('.attempts', element).html(attemptsTemplate(data));
......@@ -36,7 +45,7 @@ function MentoringBlock(runtime, element) {
children_dom.push(child_dom);
children.push(child);
if (typeof child !== 'undefined') {
child = child(runtime, child_dom);
child = child(runtime, child_dom, mentoring);
child.name = $(child_dom).attr('name');
children[children.length-1] = child;
}
......@@ -75,6 +84,7 @@ function MentoringBlock(runtime, element) {
var mentoring = {
callIfExists: callIfExists,
setContent: setContent,
renderAttempts: renderAttempts,
renderDependency: renderDependency,
readChildren: readChildren,
......@@ -83,7 +93,8 @@ function MentoringBlock(runtime, element) {
displayChild: displayChild,
displayChildren: displayChildren,
getChildByName: getChildByName,
step: step
step: step,
event_url: runtime.handlerUrl(element, 'publish_event')
}
if (data.mode === 'standard') {
......
......@@ -22,11 +22,7 @@ function MentoringStandardView(runtime, element, mentoring) {
mentoring.renderAttempts();
// Messages should only be displayed upon hitting 'submit', not on page reload
messagesDOM.append(results.message);
var template = $('#light-child-template', messagesDOM).html();
if (template) {
messagesDOM.append(template);
}
mentoring.setContent(messagesDOM, results.message);
if (messagesDOM.html().trim()) {
messagesDOM.prepend('<div class="title1">Feedback</div>');
messagesDOM.show();
......
// TODO: Split in two files
function MessageView(element) {
function MessageView(element, mentoring) {
return {
messageDOM: $('.feedback', element),
allPopupsDOM: $('.choice-tips, .feedback', element),
......@@ -32,7 +32,7 @@ function MessageView(element) {
function publish_event(data) {
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'publish_event'),
url: mentoring.event_url,
data: JSON.stringify(data)
});
}
......@@ -47,7 +47,7 @@ function MessageView(element) {
},
showMessage: function(message) {
if (_.isString(message)) {
this.messageDOM.html(message);
mentoring.setContent(this.messageDOM, message)
this.showPopup(this.messageDOM);
}
else {
......@@ -63,7 +63,7 @@ function MessageView(element) {
}
}
function MCQBlock(runtime, element) {
function MCQBlock(runtime, element, mentoring) {
return {
mode: null,
init: function(options) {
......@@ -85,7 +85,7 @@ function MCQBlock(runtime, element) {
if (this.mode === 'assessment')
return;
var messageView = MessageView(element);
var messageView = MessageView(element, mentoring);
messageView.clearResult();
var choiceInputs = $('.choice input', element);
......@@ -135,7 +135,7 @@ function MCQBlock(runtime, element) {
},
clearResult: function() {
MessageView(element).clearResult();
MessageView(element, mentoring).clearResult();
},
validate: function(){
......@@ -148,7 +148,7 @@ function MCQBlock(runtime, element) {
};
}
function MRQBlock(runtime, element) {
function MRQBlock(runtime, element, mentoring) {
return {
mode: null,
init: function(options) {
......@@ -170,7 +170,7 @@ function MRQBlock(runtime, element) {
if (this.mode === 'assessment')
return;
var messageView = MessageView(element);
var messageView = MessageView(element, mentoring);
if (result.message) {
messageView.showMessage('<div class="message-content">' + result.message + '</div>'+
......@@ -209,7 +209,7 @@ function MRQBlock(runtime, element) {
},
clearResult: function() {
MessageView(element).clearResult();
MessageView(element, mentoring).clearResult();
},
validate: function(){
......
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