diff --git a/mod/quiz/yui/build/moodle-mod_quiz-util-slot/moodle-mod_quiz-util-slot-debug.js b/mod/quiz/yui/build/moodle-mod_quiz-util-slot/moodle-mod_quiz-util-slot-debug.js index a450f15f3e6..5653cef9c9e 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-util-slot/moodle-mod_quiz-util-slot-debug.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-util-slot/moodle-mod_quiz-util-slot-debug.js @@ -420,13 +420,23 @@ Y.Moodle.mod_quiz.util.slot = { if (requiresprevious) { link.set('title', M.util.get_string('questiondependencyremove', 'quiz', a)); link.setData('action', 'removedependency'); - icon.set('alt', M.util.get_string('questiondependsonprevious', 'quiz')); - icon.set('src', M.util.image_url('t/locked', 'moodle')); + window.require(['core/templates'], function(Templates) { + Templates.renderPix('t/locked', 'core', M.util.get_string('questiondependsonprevious', 'quiz')).then( + function(html) { + icon.replace(html); + } + ); + }); } else { link.set('title', M.util.get_string('questiondependencyadd', 'quiz', a)); link.setData('action', 'adddependency'); - icon.set('alt', M.util.get_string('questiondependencyfree', 'quiz')); - icon.set('src', M.util.image_url('t/unlocked', 'moodle')); + window.require(['core/templates'], function(Templates) { + Templates.renderPix('t/unlocked', 'core', M.util.get_string('questiondependencyfree', 'quiz')).then( + function(html) { + icon.replace(html); + } + ); + }); } } }; diff --git a/mod/quiz/yui/build/moodle-mod_quiz-util-slot/moodle-mod_quiz-util-slot-min.js b/mod/quiz/yui/build/moodle-mod_quiz-util-slot/moodle-mod_quiz-util-slot-min.js index 3881b844bd9..adbe179c7ea 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-util-slot/moodle-mod_quiz-util-slot-min.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-util-slot/moodle-mod_quiz-util-slot-min.js @@ -1 +1 @@ -YUI.add("moodle-mod_quiz-util-slot",function(e,t){e.namespace("Moodle.mod_quiz.util.slot"),e.Moodle.mod_quiz.util.slot={CSS:{SLOT:"slot",QUESTIONTYPEDESCRIPTION:"qtype_description",CANNOT_DEPEND:"question_dependency_cannot_depend"},CONSTANTS:{SLOTIDPREFIX:"slot-",QUESTION:M.util.get_string("question","moodle")},SELECTORS:{SLOT:"li.slot",INSTANCENAME:".instancename",NUMBER:"span.slotnumber",PAGECONTENT:"div#page-content",PAGEBREAK:"span.page_split_join_wrapper",ICON:".icon",QUESTIONTYPEDESCRIPTION:".qtype_description",SECTIONUL:"ul.section",DEPENDENCY_WRAPPER:".question_dependency_wrapper",DEPENDENCY_LINK:".question_dependency_wrapper .cm-edit-action",DEPENDENCY_ICON:".question_dependency_wrapper .icon"},getSlotFromComponent:function(t){return e.one(t).ancestor(this.SELECTORS.SLOT,!0)},getId:function(e){var t=e.get("id").replace(this.CONSTANTS.SLOTIDPREFIX,"");return t=parseInt(t,10),typeof t=="number"&&isFinite(t)?t:!1},getName:function(e){var t=e.one(this.SELECTORS.INSTANCENAME);return t?t.get("firstChild").get("data"):null},getNumber:function(e){if(!e)return!1;var t=e.one(this.SELECTORS.NUMBER).get("text").replace(this.CONSTANTS.QUESTION,"");return t=parseInt(t,10),typeof t=="number"&&isFinite(t)?t:!1},setNumber:function(e,t){var n=e.one(this.SELECTORS.NUMBER);n.setHTML(''+this.CONSTANTS.QUESTION+" "+t)},getSlots:function(){return e.all(this.SELECTORS.PAGECONTENT+" "+this.SELECTORS.SECTIONUL+" "+this.SELECTORS.SLOT)},getNumberedSlots:function(){var t=this.SELECTORS.PAGECONTENT+" "+this.SELECTORS.SECTIONUL;return t+=" "+this.SELECTORS.SLOT+":not("+this.SELECTORS.QUESTIONTYPEDESCRIPTION+")",e.all(t)},getPrevious:function(e){return e.previous(this.SELECTORS.SLOT)},getPreviousNumbered:function(e){var t=e.previous(this.SELECTORS.SLOT+":not("+this.SELECTORS.QUESTIONTYPEDESCRIPTION+")");if(t)return t;var n=e.ancestor("li.section").previous("li.section");while(n){var r=n.all(this.SELECTORS.SLOT+":not("+this.SELECTORS.QUESTIONTYPEDESCRIPTION+")");if(r.size()>0)return r.item(r.size()-1);n=n.previous("li.section")}return!1},reorderSlots:function(){var t=this.getSlots();t.each(function(t){if(!e.Moodle.mod_quiz.util.page.getPageFromSlot(t)){var n=t.next(e.Moodle.mod_quiz.util.page.SELECTORS.PAGE);t.swap(n)}var r=this.getPreviousNumbered(t),i=0;if(t.hasClass(this.CSS.QUESTIONTYPEDESCRIPTION))return;r&&(i=this.getNumber(r)),this.setNumber(t,i+1)},this)},updateOneSlotSections:function(){e.all(".mod-quiz-edit-content ul.slots li.section").each(function(e){e.all(this.SELECTORS.SLOT).size()>1?e.removeClass("only-has-one-slot"):e.addClass("only-has-one-slot")},this)},remove:function(t){var n=e.Moodle.mod_quiz.util.page.getPageFromSlot(t);t.remove();if(!e.Moodle.mod_quiz.util.page.isEmpty(n))return;e.Moodle.mod_quiz.util.page.remove(n)},getPageBreaks:function(){var t=this.SELECTORS.PAGECONTENT+" "+this.SELECTORS.SECTIONUL;return t+=" "+this.SELECTORS.SLOT+this.SELECTORS.PAGEBREAK,e.all(t)},getPageBreak:function(t){return e.one(t).one(this.SELECTORS.PAGEBREAK)},addPageBreak:function(t){var n=M.mod_quiz.resource_toolbox.get("config").addpageiconhtml;n=n.replace("%%SLOT%%",this.getNumber(t));var r=e.Node.create(n);return t.one("div").insert(r,"after"),r},removePageBreak:function(e){var t=this.getPageBreak(e);return t?(t.remove(),!0):!1},reorderPageBreaks:function(){var t=this.getSlots(),n=0;t.each(function(r,i){n++;var s=this.getPageBreak(r),o=r.next("li.activity");if(!o)return;s||(s=this.addPageBreak(r)),s&&i===t.size()-1&&this.removePageBreak(r);var u=s.get("childNodes").item(0),a="",f="";e.Moodle.mod_quiz.util.page.isPage(o)?(a="removepagebreak",f="e/remove_page_break"):(a="addpagebreak",f="e/insert_page_break"),u.set("title",M.util.get_string(a,"quiz")),u.setData("action",a);var l=u.one(this.SELECTORS.ICON);l.set("title",M.util.get_string(a,"quiz")),l.set("alt",M.util.get_string(a,"quiz")),l.set("src",M.util.image_url(f));var c=e.QueryString.parse(u.get("href"));c.slot=n;var h="";for(var p in c)h.length&&(h+="&"),h+=p+"="+c[p];u.set("href",h)},this)},updateAllDependencyIcons:function(){var e=this.getSlots(),t=0,n=null;e.each(function(e){t++,t==1||n.getData("canfinish")==="0"?e.one(this.SELECTORS.DEPENDENCY_WRAPPER).addClass(this.CSS.CANNOT_DEPEND):e.one(this.SELECTORS.DEPENDENCY_WRAPPER).removeClass(this.CSS.CANNOT_DEPEND),this.updateDependencyIcon(e,null),n=e},this)},updateDependencyIcon:function(e,t){var n=e.one(this.SELECTORS.DEPENDENCY_LINK),r=e.one(this.SELECTORS.DEPENDENCY_ICON),i=this.getPrevious(e),s={thisq:this.getNumber(e)};i&&(s.previousq=this.getNumber(i)),t===null&&(t=n.getData("action")==="removedependency"),t?(n.set("title",M.util.get_string("questiondependencyremove","quiz",s)),n.setData("action","removedependency"),r.set("alt",M.util.get_string("questiondependsonprevious","quiz")),r.set("src",M.util.image_url("t/locked","moodle"))):(n.set("title",M.util.get_string("questiondependencyadd","quiz",s)),n.setData("action","adddependency"),r.set("alt",M.util.get_string("questiondependencyfree","quiz")),r.set("src",M.util.image_url("t/unlocked","moodle")))}}},"@VERSION@",{requires:["node","moodle-mod_quiz-util-base"]}); +YUI.add("moodle-mod_quiz-util-slot",function(e,t){e.namespace("Moodle.mod_quiz.util.slot"),e.Moodle.mod_quiz.util.slot={CSS:{SLOT:"slot",QUESTIONTYPEDESCRIPTION:"qtype_description",CANNOT_DEPEND:"question_dependency_cannot_depend"},CONSTANTS:{SLOTIDPREFIX:"slot-",QUESTION:M.util.get_string("question","moodle")},SELECTORS:{SLOT:"li.slot",INSTANCENAME:".instancename",NUMBER:"span.slotnumber",PAGECONTENT:"div#page-content",PAGEBREAK:"span.page_split_join_wrapper",ICON:".icon",QUESTIONTYPEDESCRIPTION:".qtype_description",SECTIONUL:"ul.section",DEPENDENCY_WRAPPER:".question_dependency_wrapper",DEPENDENCY_LINK:".question_dependency_wrapper .cm-edit-action",DEPENDENCY_ICON:".question_dependency_wrapper .icon"},getSlotFromComponent:function(t){return e.one(t).ancestor(this.SELECTORS.SLOT,!0)},getId:function(e){var t=e.get("id").replace(this.CONSTANTS.SLOTIDPREFIX,"");return t=parseInt(t,10),typeof t=="number"&&isFinite(t)?t:!1},getName:function(e){var t=e.one(this.SELECTORS.INSTANCENAME);return t?t.get("firstChild").get("data"):null},getNumber:function(e){if(!e)return!1;var t=e.one(this.SELECTORS.NUMBER).get("text").replace(this.CONSTANTS.QUESTION,"");return t=parseInt(t,10),typeof t=="number"&&isFinite(t)?t:!1},setNumber:function(e,t){var n=e.one(this.SELECTORS.NUMBER);n.setHTML(''+this.CONSTANTS.QUESTION+" "+t)},getSlots:function(){return e.all(this.SELECTORS.PAGECONTENT+" "+this.SELECTORS.SECTIONUL+" "+this.SELECTORS.SLOT)},getNumberedSlots:function(){var t=this.SELECTORS.PAGECONTENT+" "+this.SELECTORS.SECTIONUL;return t+=" "+this.SELECTORS.SLOT+":not("+this.SELECTORS.QUESTIONTYPEDESCRIPTION+")",e.all(t)},getPrevious:function(e){return e.previous(this.SELECTORS.SLOT)},getPreviousNumbered:function(e){var t=e.previous(this.SELECTORS.SLOT+":not("+this.SELECTORS.QUESTIONTYPEDESCRIPTION+")");if(t)return t;var n=e.ancestor("li.section").previous("li.section");while(n){var r=n.all(this.SELECTORS.SLOT+":not("+this.SELECTORS.QUESTIONTYPEDESCRIPTION+")");if(r.size()>0)return r.item(r.size()-1);n=n.previous("li.section")}return!1},reorderSlots:function(){var t=this.getSlots();t.each(function(t){if(!e.Moodle.mod_quiz.util.page.getPageFromSlot(t)){var n=t.next(e.Moodle.mod_quiz.util.page.SELECTORS.PAGE);t.swap(n)}var r=this.getPreviousNumbered(t),i=0;if(t.hasClass(this.CSS.QUESTIONTYPEDESCRIPTION))return;r&&(i=this.getNumber(r)),this.setNumber(t,i+1)},this)},updateOneSlotSections:function(){e.all(".mod-quiz-edit-content ul.slots li.section").each(function(e){e.all(this.SELECTORS.SLOT).size()>1?e.removeClass("only-has-one-slot"):e.addClass("only-has-one-slot")},this)},remove:function(t){var n=e.Moodle.mod_quiz.util.page.getPageFromSlot(t);t.remove();if(!e.Moodle.mod_quiz.util.page.isEmpty(n))return;e.Moodle.mod_quiz.util.page.remove(n)},getPageBreaks:function(){var t=this.SELECTORS.PAGECONTENT+" "+this.SELECTORS.SECTIONUL;return t+=" "+this.SELECTORS.SLOT+this.SELECTORS.PAGEBREAK,e.all(t)},getPageBreak:function(t){return e.one(t).one(this.SELECTORS.PAGEBREAK)},addPageBreak:function(t){var n=M.mod_quiz.resource_toolbox.get("config").addpageiconhtml;n=n.replace("%%SLOT%%",this.getNumber(t));var r=e.Node.create(n);return t.one("div").insert(r,"after"),r},removePageBreak:function(e){var t=this.getPageBreak(e);return t?(t.remove(),!0):!1},reorderPageBreaks:function(){var t=this.getSlots(),n=0;t.each(function(r,i){n++;var s=this.getPageBreak(r),o=r.next("li.activity");if(!o)return;s||(s=this.addPageBreak(r)),s&&i===t.size()-1&&this.removePageBreak(r);var u=s.get("childNodes").item(0),a="",f="";e.Moodle.mod_quiz.util.page.isPage(o)?(a="removepagebreak",f="e/remove_page_break"):(a="addpagebreak",f="e/insert_page_break"),u.set("title",M.util.get_string(a,"quiz")),u.setData("action",a);var l=u.one(this.SELECTORS.ICON);l.set("title",M.util.get_string(a,"quiz")),l.set("alt",M.util.get_string(a,"quiz")),l.set("src",M.util.image_url(f));var c=e.QueryString.parse(u.get("href"));c.slot=n;var h="";for(var p in c)h.length&&(h+="&"),h+=p+"="+c[p];u.set("href",h)},this)},updateAllDependencyIcons:function(){var e=this.getSlots(),t=0,n=null;e.each(function(e){t++,t==1||n.getData("canfinish")==="0"?e.one(this.SELECTORS.DEPENDENCY_WRAPPER).addClass(this.CSS.CANNOT_DEPEND):e.one(this.SELECTORS.DEPENDENCY_WRAPPER).removeClass(this.CSS.CANNOT_DEPEND),this.updateDependencyIcon(e,null),n=e},this)},updateDependencyIcon:function(e,t){var n=e.one(this.SELECTORS.DEPENDENCY_LINK),r=e.one(this.SELECTORS.DEPENDENCY_ICON),i=this.getPrevious(e),s={thisq:this.getNumber(e)};i&&(s.previousq=this.getNumber(i)),t===null&&(t=n.getData("action")==="removedependency"),t?(n.set("title",M.util.get_string("questiondependencyremove","quiz",s)),n.setData("action","removedependency"),window.require(["core/templates"],function(e){e.renderPix("t/locked","core",M.util.get_string("questiondependsonprevious","quiz")).then(function(e){r.replace(e)})})):(n.set("title",M.util.get_string("questiondependencyadd","quiz",s)),n.setData("action","adddependency"),window.require(["core/templates"],function(e){e.renderPix("t/unlocked","core",M.util.get_string("questiondependencyfree","quiz")).then(function(e){r.replace(e)})}))}}},"@VERSION@",{requires:["node","moodle-mod_quiz-util-base"]}); diff --git a/mod/quiz/yui/build/moodle-mod_quiz-util-slot/moodle-mod_quiz-util-slot.js b/mod/quiz/yui/build/moodle-mod_quiz-util-slot/moodle-mod_quiz-util-slot.js index a450f15f3e6..5653cef9c9e 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-util-slot/moodle-mod_quiz-util-slot.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-util-slot/moodle-mod_quiz-util-slot.js @@ -420,13 +420,23 @@ Y.Moodle.mod_quiz.util.slot = { if (requiresprevious) { link.set('title', M.util.get_string('questiondependencyremove', 'quiz', a)); link.setData('action', 'removedependency'); - icon.set('alt', M.util.get_string('questiondependsonprevious', 'quiz')); - icon.set('src', M.util.image_url('t/locked', 'moodle')); + window.require(['core/templates'], function(Templates) { + Templates.renderPix('t/locked', 'core', M.util.get_string('questiondependsonprevious', 'quiz')).then( + function(html) { + icon.replace(html); + } + ); + }); } else { link.set('title', M.util.get_string('questiondependencyadd', 'quiz', a)); link.setData('action', 'adddependency'); - icon.set('alt', M.util.get_string('questiondependencyfree', 'quiz')); - icon.set('src', M.util.image_url('t/unlocked', 'moodle')); + window.require(['core/templates'], function(Templates) { + Templates.renderPix('t/unlocked', 'core', M.util.get_string('questiondependencyfree', 'quiz')).then( + function(html) { + icon.replace(html); + } + ); + }); } } }; diff --git a/mod/quiz/yui/src/util/js/slot.js b/mod/quiz/yui/src/util/js/slot.js index 9588adc9b59..8ef4a044a58 100644 --- a/mod/quiz/yui/src/util/js/slot.js +++ b/mod/quiz/yui/src/util/js/slot.js @@ -418,13 +418,23 @@ Y.Moodle.mod_quiz.util.slot = { if (requiresprevious) { link.set('title', M.util.get_string('questiondependencyremove', 'quiz', a)); link.setData('action', 'removedependency'); - icon.set('alt', M.util.get_string('questiondependsonprevious', 'quiz')); - icon.set('src', M.util.image_url('t/locked', 'moodle')); + window.require(['core/templates'], function(Templates) { + Templates.renderPix('t/locked', 'core', M.util.get_string('questiondependsonprevious', 'quiz')).then( + function(html) { + icon.replace(html); + } + ); + }); } else { link.set('title', M.util.get_string('questiondependencyadd', 'quiz', a)); link.setData('action', 'adddependency'); - icon.set('alt', M.util.get_string('questiondependencyfree', 'quiz')); - icon.set('src', M.util.image_url('t/unlocked', 'moodle')); + window.require(['core/templates'], function(Templates) { + Templates.renderPix('t/unlocked', 'core', M.util.get_string('questiondependencyfree', 'quiz')).then( + function(html) { + icon.replace(html); + } + ); + }); } } };