From c2f7bfe368e16e8930234bd288984f4dea3acfe0 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 31 Oct 2018 07:14:42 +0100 Subject: [PATCH] Using bigger wrappers for MathJax. This improves speed by a lot, around 2-3 times faster. --- amd/build/core.min.js | 2 +- amd/build/instructor.min.js | 2 +- amd/src/core.js | 8 +++----- amd/src/instructor.js | 3 +-- templates/edit_question_list.mustache | 8 +++----- templates/quiz.mustache | 4 ++-- templates/report.mustache | 12 ++++-------- version.php | 4 ++-- 8 files changed, 17 insertions(+), 26 deletions(-) diff --git a/amd/build/core.min.js b/amd/build/core.min.js index aae3c41..f6cd088 100644 --- a/amd/build/core.min.js +++ b/amd/build/core.min.js @@ -1 +1 @@ -"use strict";var _createClass=function(){function e(e,t){for(var n=0;n0&&t<-e)&&(e>1?this.startAttempt(e+t):this.startAttempt(0),!0):(this.countdownInterval=setInterval(function(){return n.onCountdownTick(e)},1e3),!0))}},{key:"onTimerEnding",value:function(){this.isRunning=!1,this.quiz.role.onTimerEnding()}},{key:"onTimerTick",value:function(){var e=(new Date).getTime();if(e>this.endTime)this.hideTimer(),this.onTimerEnding();else{var t=parseInt((this.endTime-e)/1e3);this.quiz.role.onTimerTick(t)}}},{key:"startAttempt",value:function(e){var t=this;Quiz.hide(Quiz.info),this.refresh(),this.isRunning=!0,0!==(e=parseInt(e))&&(this.quiz.role.onTimerTick(e),this.endTime=(new Date).getTime()+1e3*e,this.timerInterval=setInterval(function(){return t.onTimerTick()},1e3))}}],[{key:"isLoaded",value:function(){return""!==Question.box.html()}},{key:"box",get:function(){return $("#jazzquiz_question_box")}},{key:"timer",get:function(){return $("#jazzquiz_question_timer")}},{key:"form",get:function(){return $("#jazzquiz_question_form")}}]),Question}(),Quiz=function(){function e(t){_classCallCheck(this,e),this.state="",this.isNewState=!1,this.question=new Question(this),this.role=new t(this),this.events={notrunning:"onNotRunning",preparing:"onPreparing",running:"onRunning",reviewing:"onReviewing",sessionclosed:"onSessionClosed",voting:"onVoting"}}return _createClass(e,[{key:"changeQuizState",value:function(e,t){this.isNewState=this.state!==e,this.state=e,this.role.onStateChange(e);var n=this.events[e];this.role[n](t)}},{key:"poll",value:function(e){var t=this;Ajax.get("info",{},function(n){t.changeQuizState(n.status,n),setTimeout(function(){return t.poll(e)},e)})}}],[{key:"hide",value:function(e){e.addClass("hidden")}},{key:"show",value:function(e){e.removeClass("hidden")}},{key:"uncheck",value:function(e){e.children(".fa").removeClass("fa-check-square-o").addClass("fa-square-o")}},{key:"check",value:function(e){e.children(".fa").removeClass("fa-square-o").addClass("fa-check-square-o")}},{key:"renderAllMathjax",value:function(){Y.fire(M.core.event.FILTER_CONTENT_UPDATED,{nodes:new Y.NodeList(document.getElementsByClassName("jazzquiz-latex-wrapper"))})}},{key:"addMathjaxElement",value:function(t,n){t.html(''+n+""),e.renderAllMathjax()}},{key:"renderMaximaEquation",value:function(t,n){null!==document.getElementById(n)&&(void 0===cache[t]?Ajax.get("stack",{input:encodeURIComponent(t)},function(t){cache[t.original]=t.latex,e.addMathjaxElement($("#"+n),t.latex)}):e.addMathjaxElement($("#"+n),cache[t]))}},{key:"main",get:function(){return $("#jazzquiz")}},{key:"info",get:function(){return $("#jazzquiz_info_container")}},{key:"responded",get:function(){return $("#jazzquiz_responded_container")}},{key:"responses",get:function(){return $("#jazzquiz_responses_container")}},{key:"responseInfo",get:function(){return $("#jazzquiz_response_info_container")}}]),e}();function setText(e,t,n,i){n=void 0!==n?n:"jazzquiz",i=void 0!==i?i:[],$.when(mString.get_string(t,n,i)).done(function(t){return Quiz.show(e.html(t))})}return{initialize:function(e,t,n,i,s){session.courseModuleId=e,session.activityId=t,session.sessionId=n,session.attemptId=i,session.sessionKey=s},Quiz:Quiz,Question:Question,Ajax:Ajax,setText:setText}}); \ No newline at end of file +"use strict";var _createClass=function(){function e(e,t){for(var n=0;n0&&t<-e)&&(e>1?this.startAttempt(e+t):this.startAttempt(0),!0):(this.countdownInterval=setInterval(function(){return n.onCountdownTick(e)},1e3),!0))}},{key:"onTimerEnding",value:function(){this.isRunning=!1,this.quiz.role.onTimerEnding()}},{key:"onTimerTick",value:function(){var e=(new Date).getTime();if(e>this.endTime)this.hideTimer(),this.onTimerEnding();else{var t=parseInt((this.endTime-e)/1e3);this.quiz.role.onTimerTick(t)}}},{key:"startAttempt",value:function(e){var t=this;Quiz.hide(Quiz.info),this.refresh(),this.isRunning=!0,0!==(e=parseInt(e))&&(this.quiz.role.onTimerTick(e),this.endTime=(new Date).getTime()+1e3*e,this.timerInterval=setInterval(function(){return t.onTimerTick()},1e3))}}],[{key:"isLoaded",value:function(){return""!==Question.box.html()}},{key:"box",get:function(){return $("#jazzquiz_question_box")}},{key:"timer",get:function(){return $("#jazzquiz_question_timer")}},{key:"form",get:function(){return $("#jazzquiz_question_form")}}]),Question}(),Quiz=function(){function e(t){_classCallCheck(this,e),this.state="",this.isNewState=!1,this.question=new Question(this),this.role=new t(this),this.events={notrunning:"onNotRunning",preparing:"onPreparing",running:"onRunning",reviewing:"onReviewing",sessionclosed:"onSessionClosed",voting:"onVoting"}}return _createClass(e,[{key:"changeQuizState",value:function(e,t){this.isNewState=this.state!==e,this.state=e,this.role.onStateChange(e);var n=this.events[e];this.role[n](t)}},{key:"poll",value:function(e){var t=this;Ajax.get("info",{},function(n){t.changeQuizState(n.status,n),setTimeout(function(){return t.poll(e)},e)})}}],[{key:"hide",value:function(e){e.addClass("hidden")}},{key:"show",value:function(e){e.removeClass("hidden")}},{key:"uncheck",value:function(e){e.children(".fa").removeClass("fa-check-square-o").addClass("fa-square-o")}},{key:"check",value:function(e){e.children(".fa").removeClass("fa-square-o").addClass("fa-check-square-o")}},{key:"renderAllMathjax",value:function(){mEvent.notifyFilterContentUpdated(document.getElementsByClassName("jazzquiz-response-container"))}},{key:"addMathjaxElement",value:function(t,n){t.html(''+n+""),e.renderAllMathjax()}},{key:"renderMaximaEquation",value:function(t,n){null!==document.getElementById(n)&&(void 0===cache[t]?Ajax.get("stack",{input:encodeURIComponent(t)},function(t){cache[t.original]=t.latex,e.addMathjaxElement($("#"+n),t.latex)}):e.addMathjaxElement($("#"+n),cache[t]))}},{key:"main",get:function(){return $("#jazzquiz")}},{key:"info",get:function(){return $("#jazzquiz_info_container")}},{key:"responded",get:function(){return $("#jazzquiz_responded_container")}},{key:"responses",get:function(){return $("#jazzquiz_responses_container")}},{key:"responseInfo",get:function(){return $("#jazzquiz_response_info_container")}}]),e}();function setText(e,t,n,i){n=void 0!==n?n:"jazzquiz",i=void 0!==i?i:[],$.when(mString.get_string(t,n,i)).done(function(t){return Quiz.show(e.html(t))})}return{initialize:function(e,t,n,i,s){session.courseModuleId=e,session.activityId=t,session.sessionId=n,session.attemptId=i,session.sessionKey=s},Quiz:Quiz,Question:Question,Ajax:Ajax,setText:setText}}); \ No newline at end of file diff --git a/amd/build/instructor.min.js b/amd/build/instructor.min.js index 05c0f9d..7060cdf 100644 --- a/amd/build/instructor.min.js +++ b/amd/build/instructor.min.js @@ -1 +1 @@ -"use strict";var _createClass=function(){function e(e,t){for(var s=0;s').children("h4"),"showing_vote_results"),s.responseInfo.append('
'),r(e("#review_show_normal_results"),"click_to_show_original_results"),o.remove()):"current_response"===t&&0===o.length&&(r(s.responseInfo.html('

').children("h4"),"showing_original_results"),s.responseInfo.append('
'),r(e("#review_show_vote_results"),"click_to_show_vote_results"),n.remove())}}else s.hide(s.responseInfo)}},{key:"createBarGraph",value:function(t,n,o,r,i){var a=document.getElementById(o);if(null!==a){for(var u=0,l=0,c=0;cl&&(l=d)}0===u&&(u=1),i&&(a.innerHTML="");for(var h=0;h'+t[v].count+"",y=z.insertCell(0);y.onclick=function(){e(this).parent().toggleClass("selected-vote-option")};var k=z.insertCell(1);k.classList.add("bar"),k.id=n+"_bar_"+w,k.innerHTML='
'+q+"
";var C=n+"_latex_"+w;y.innerHTML='',s.addMathjaxElement(e("#"+C),t[v].response),"stack"===t[v].qtype&&s.renderMaximaEquation(t[v].response,C)}else{var b=a.rows[m];b.dataset.row_i=w,b.dataset.response_i=v,b.dataset.percent=_,b.dataset.count=t[v].count;var j=b.classList.contains("outside");_>15&&j?b.classList.remove("outside"):_<15&&!j&&b.classList.add("outside");var R=document.getElementById(n+"_count_"+w);null!==R&&(R.innerHTML=t[v].count);var Q=document.getElementById(n+"_bar_"+w);null!==Q&&(Q.firstElementChild.style.width=_+"%")}}}}},{key:"set",value:function(n,o,i,a,u,l,c){if(void 0!==i){if(0===i.length)return s.show(s.responded),void r(s.responded.find("h4"),"a_out_of_b_responded","jazzquiz",{a:0,b:this.totalStudents});switch(u){case"shortanswer":for(var d=0;d';s.show(e("#"+n).html(w))}this.createBarGraph(this.currentResponses,"current_response",o,l,c),t.sortBarGraph(o)}}},{key:"refresh",value:function(t){var n=this;o.get("get_results",{},function(o){n.quiz.question.hasVotes=o.has_votes,n.totalStudents=parseInt(o.total_students),n.set("jazzquiz_responses_container","current_responses_wrapper",o.responses,o.responded,o.question_type,"results",t),o.merge_count>0?s.show(e("#jazzquiz_undo_merge")):s.hide(e("#jazzquiz_undo_merge"))})}},{key:"refreshVotes",value:function(){var e=this;if(!this.showResponses&&"reviewing"!==this.quiz.state)return s.hide(s.responseInfo),void s.hide(s.responses);o.get("get_vote_results",{},function(n){var o=n.answers,i="wrapper_vote_responses",a=[];for(var u in e.respondedCount=0,e.totalStudents=parseInt(n.total_students),o)o.hasOwnProperty(u)&&(a.push({response:o[u].attempt,count:o[u].finalcount,qtype:o[u].qtype,slot:o[u].slot}),e.respondedCount+=parseInt(o[u].finalcount));if(r(s.responded.find("h4"),"a_out_of_b_voted","jazzquiz",{a:e.respondedCount,b:e.totalStudents}),null===document.getElementById(i)){s.show(s.responses.html('
'))}e.createBarGraph(a,"vote_response",i,"vote",!1),t.sortBarGraph(i)})}}],[{key:"sortBarGraph",value:function(e){var t=document.getElementById(e);if(null!==t)for(var s=!0;s;){s=!1;for(var n=0;n1?r(n,"x_students_have_joined","jazzquiz",e.student_count):r(n,"no_students_have_joined"),s.show(t.control("startquiz").parent())}},{key:"onPreparing",value:function(e){s.hide(t.side),r(s.info,"instructions_for_instructor");var n=["improvise","jump","fullscreen","quit"];e.slot0&&e.delay<-e.questiontime&&this.endQuestion(),this.responses.refresh(!t.isMerging)):this.quiz.question.startCountdown(e.questiontime,e.delay)&&(this.quiz.question.isRunning=!0)}},{key:"onReviewing",value:function(e){s.show(t.side);var o=["answer","repoll","fullscreen","improvise","jump","quit"];this.allowVote&&o.push("vote"),e.slot');s.addMathjaxElement(d,l[c].name),d.data({time:l[c].time,"question-id":l[c].questionid,"jazzquiz-question-id":l[c].jazzquizquestionid}),d.data("test",1),d.on("click",function(){var t=e(this).data("question-id"),s=e(this).data("time"),n=e(this).data("jazzquiz-question-id");o.jumpQuestion(t,s,n),a.html("").removeClass("active"),i.removeClass("active").data("isclosed","yes")}),a.append(d)}}):i.data("isclosed",""))}},{key:"runVoting",value:function(){var e=t.getSelectedAnswersForVote(),s={questions:encodeURIComponent(JSON.stringify(e))};o.post("run_voting",s,function(){})}},{key:"startQuestion",value:function(e,t,n,r){var i=this;s.hide(s.info),this.responses.clear(),o.post("start_question",{method:e,questionid:t,questiontime:n,jazzquizquestionid:r},function(e){return i.quiz.question.startCountdown(e.questiontime,e.delay)})}},{key:"jumpQuestion",value:function(e,t,s){this.startQuestion("jump",e,t,s)}},{key:"repollQuestion",value:function(){this.startQuestion("repoll",0,0,0)}},{key:"nextQuestion",value:function(){this.startQuestion("next",0,0,0)}},{key:"closeSession",value:function(){s.hide(e("#jazzquiz_undo_merge")),s.hide(n.box),s.hide(t.controls),r(s.info,"closing_session"),o.post("close_session",{},function(){return r(s.info,"session_closed")})}},{key:"showCorrectAnswer",value:function(){var e=this;if(this.isShowingCorrectAnswer)return s.hide(t.correctAnswer),s.uncheck(t.control("answer")),void(this.isShowingCorrectAnswer=!1);o.get("get_right_response",{},function(n){var o=''+n.right_answer+"";s.show(t.correctAnswer.html(o)),s.renderAllMathjax(),s.check(t.control("answer")),e.isShowingCorrectAnswer=!0})}}],[{key:"addHotkeys",value:function(s){var n=function(n){s.hasOwnProperty(n)&&(s[n]={action:s[n],repeat:!1},e(document).on("keydown",function(o){if(!s[n].repeat&&!o.ctrlKey&&String.fromCharCode(o.which).toLowerCase()===n){var r=e(":focus").prop("tagName");if(void 0===r||"input"!==(r=r.toLowerCase())&&"textarea"!==r){o.preventDefault(),s[n].repeat=!0;var i=t.control(s[n].action);i.length&&!i.prop("disabled")&&i.click()}}}),e(document).on("keyup",function(e){String.fromCharCode(e.which).toLowerCase()===n&&(s[n].repeat=!1)}))};for(var o in s)n(o)}},{key:"addEvents",value:function(s){var n=function(n){s.hasOwnProperty(n)&&e(document).on("click","#jazzquiz_control_"+n,function(){t.enableControls([]),s[n]()})};for(var o in s)n(o)}},{key:"control",value:function(t){return e("#jazzquiz_control_"+t)}},{key:"getSelectedAnswersForVote",value:function(){var t=[];return e(".selected-vote-option").each(function(e,s){t.push({text:s.dataset.response,count:s.dataset.count})}),t}},{key:"enableControls",value:function(e){t.controlButtons.children("button").each(function(t,s){var n=s.getAttribute("id").replace("jazzquiz_control_","");s.disabled=-1===e.indexOf(n)})}},{key:"showFullscreenView",value:function(){s.main.hasClass("jazzquiz-fullscreen")?t.closeFullscreenView():(document.documentElement.style.overflowY="hidden",s.main.addClass("jazzquiz-fullscreen"))}},{key:"closeFullscreenView",value:function(){document.documentElement.style.overflowY="auto",s.main.removeClass("jazzquiz-fullscreen")}},{key:"closeQuestionListMenu",value:function(s,n){var o="#jazzquiz_"+n+"_menu";e(s.target).closest(o).length||(e(o).html("").removeClass("active"),t.control(n).removeClass("active"))}},{key:"addReportEventHandlers",value:function(){e(document).on("click","#report_overview_controls button",function(){var t=e(this).data("action");"attendance"===t?(e("#report_overview_responded").fadeIn(),e("#report_overview_responses").fadeOut()):"responses"===t&&(e("#report_overview_responses").fadeIn(),e("#report_overview_responded").fadeOut())})}},{key:"controls",get:function(){return e("#jazzquiz_controls_box")}},{key:"controlButtons",get:function(){return t.controls.find(".quiz-control-buttons")}},{key:"side",get:function(){return e("#jazzquiz_side_container")}},{key:"correctAnswer",get:function(){return e("#jazzquiz_correct_answer_container")}},{key:"isMerging",get:function(){return 0!==e(".merge-from").length}}]),t}();return{initialize:function(e,t,n){var o=new s(a);o.role.totalQuestions=e,t?(a.addReportEventHandlers(),o.role.responses.showResponses=!0,n.forEach(function(e){var t="jazzquiz_wrapper_responses_"+e.num,s="responses_wrapper_table_"+e.num,n="report_"+e.num;o.role.responses.set(t,s,e.responses,void 0,e.type,n,!1)})):o.poll(500)}}}); \ No newline at end of file +"use strict";var _createClass=function(){function e(e,t){for(var s=0;s').children("h4"),"showing_vote_results"),s.responseInfo.append('
'),r(e("#review_show_normal_results"),"click_to_show_original_results"),o.remove()):"current_response"===t&&0===o.length&&(r(s.responseInfo.html('

').children("h4"),"showing_original_results"),s.responseInfo.append('
'),r(e("#review_show_vote_results"),"click_to_show_vote_results"),n.remove())}}else s.hide(s.responseInfo)}},{key:"createBarGraph",value:function(t,n,o,r,i){var a=document.getElementById(o);if(null!==a){for(var u=0,l=0,c=0;cl&&(l=d)}0===u&&(u=1),i&&(a.innerHTML="");for(var h=0;h'+t[v].count+"",y=z.insertCell(0);y.onclick=function(){e(this).parent().toggleClass("selected-vote-option")};var k=z.insertCell(1);k.classList.add("bar"),k.id=n+"_bar_"+w,k.innerHTML='
'+q+"
";var C=n+"_latex_"+w;y.innerHTML='',s.addMathjaxElement(e("#"+C),t[v].response),"stack"===t[v].qtype&&s.renderMaximaEquation(t[v].response,C)}else{var b=a.rows[m];b.dataset.row_i=w,b.dataset.response_i=v,b.dataset.percent=_,b.dataset.count=t[v].count;var j=b.classList.contains("outside");_>15&&j?b.classList.remove("outside"):_<15&&!j&&b.classList.add("outside");var R=document.getElementById(n+"_count_"+w);null!==R&&(R.innerHTML=t[v].count);var Q=document.getElementById(n+"_bar_"+w);null!==Q&&(Q.firstElementChild.style.width=_+"%")}}}}},{key:"set",value:function(n,o,i,a,u,l,c){if(void 0!==i){if(0===i.length)return s.show(s.responded),void r(s.responded.find("h4"),"a_out_of_b_responded","jazzquiz",{a:0,b:this.totalStudents});switch(u){case"shortanswer":for(var d=0;d';s.show(e("#"+n).html(w))}this.createBarGraph(this.currentResponses,"current_response",o,l,c),t.sortBarGraph(o)}}},{key:"refresh",value:function(t){var n=this;o.get("get_results",{},function(o){n.quiz.question.hasVotes=o.has_votes,n.totalStudents=parseInt(o.total_students),n.set("jazzquiz_responses_container","current_responses_wrapper",o.responses,o.responded,o.question_type,"results",t),o.merge_count>0?s.show(e("#jazzquiz_undo_merge")):s.hide(e("#jazzquiz_undo_merge"))})}},{key:"refreshVotes",value:function(){var e=this;if(!this.showResponses&&"reviewing"!==this.quiz.state)return s.hide(s.responseInfo),void s.hide(s.responses);o.get("get_vote_results",{},function(n){var o=n.answers,i="wrapper_vote_responses",a=[];for(var u in e.respondedCount=0,e.totalStudents=parseInt(n.total_students),o)o.hasOwnProperty(u)&&(a.push({response:o[u].attempt,count:o[u].finalcount,qtype:o[u].qtype,slot:o[u].slot}),e.respondedCount+=parseInt(o[u].finalcount));if(r(s.responded.find("h4"),"a_out_of_b_voted","jazzquiz",{a:e.respondedCount,b:e.totalStudents}),null===document.getElementById(i)){s.show(s.responses.html('
'))}e.createBarGraph(a,"vote_response",i,"vote",!1),t.sortBarGraph(i)})}}],[{key:"sortBarGraph",value:function(e){var t=document.getElementById(e);if(null!==t)for(var s=!0;s;){s=!1;for(var n=0;n1?r(n,"x_students_have_joined","jazzquiz",e.student_count):r(n,"no_students_have_joined"),s.show(t.control("startquiz").parent())}},{key:"onPreparing",value:function(e){s.hide(t.side),r(s.info,"instructions_for_instructor");var n=["improvise","jump","fullscreen","quit"];e.slot0&&e.delay<-e.questiontime&&this.endQuestion(),this.responses.refresh(!t.isMerging)):this.quiz.question.startCountdown(e.questiontime,e.delay)&&(this.quiz.question.isRunning=!0)}},{key:"onReviewing",value:function(e){s.show(t.side);var o=["answer","repoll","fullscreen","improvise","jump","quit"];this.allowVote&&o.push("vote"),e.slot');s.addMathjaxElement(d,l[c].name),d.data({time:l[c].time,"question-id":l[c].questionid,"jazzquiz-question-id":l[c].jazzquizquestionid}),d.data("test",1),d.on("click",function(){var t=e(this).data("question-id"),s=e(this).data("time"),n=e(this).data("jazzquiz-question-id");o.jumpQuestion(t,s,n),a.html("").removeClass("active"),i.removeClass("active").data("isclosed","yes")}),a.append(d)}}):i.data("isclosed",""))}},{key:"runVoting",value:function(){var e=t.getSelectedAnswersForVote(),s={questions:encodeURIComponent(JSON.stringify(e))};o.post("run_voting",s,function(){})}},{key:"startQuestion",value:function(e,t,n,r){var i=this;s.hide(s.info),this.responses.clear(),o.post("start_question",{method:e,questionid:t,questiontime:n,jazzquizquestionid:r},function(e){return i.quiz.question.startCountdown(e.questiontime,e.delay)})}},{key:"jumpQuestion",value:function(e,t,s){this.startQuestion("jump",e,t,s)}},{key:"repollQuestion",value:function(){this.startQuestion("repoll",0,0,0)}},{key:"nextQuestion",value:function(){this.startQuestion("next",0,0,0)}},{key:"closeSession",value:function(){s.hide(e("#jazzquiz_undo_merge")),s.hide(n.box),s.hide(t.controls),r(s.info,"closing_session"),o.post("close_session",{},function(){return r(s.info,"session_closed")})}},{key:"showCorrectAnswer",value:function(){var e=this;if(this.isShowingCorrectAnswer)return s.hide(t.correctAnswer),s.uncheck(t.control("answer")),void(this.isShowingCorrectAnswer=!1);o.get("get_right_response",{},function(n){s.show(t.correctAnswer.html(n.right_answer)),s.renderAllMathjax(),s.check(t.control("answer")),e.isShowingCorrectAnswer=!0})}}],[{key:"addHotkeys",value:function(s){var n=function(n){s.hasOwnProperty(n)&&(s[n]={action:s[n],repeat:!1},e(document).on("keydown",function(o){if(!s[n].repeat&&!o.ctrlKey&&String.fromCharCode(o.which).toLowerCase()===n){var r=e(":focus").prop("tagName");if(void 0===r||"input"!==(r=r.toLowerCase())&&"textarea"!==r){o.preventDefault(),s[n].repeat=!0;var i=t.control(s[n].action);i.length&&!i.prop("disabled")&&i.click()}}}),e(document).on("keyup",function(e){String.fromCharCode(e.which).toLowerCase()===n&&(s[n].repeat=!1)}))};for(var o in s)n(o)}},{key:"addEvents",value:function(s){var n=function(n){s.hasOwnProperty(n)&&e(document).on("click","#jazzquiz_control_"+n,function(){t.enableControls([]),s[n]()})};for(var o in s)n(o)}},{key:"control",value:function(t){return e("#jazzquiz_control_"+t)}},{key:"getSelectedAnswersForVote",value:function(){var t=[];return e(".selected-vote-option").each(function(e,s){t.push({text:s.dataset.response,count:s.dataset.count})}),t}},{key:"enableControls",value:function(e){t.controlButtons.children("button").each(function(t,s){var n=s.getAttribute("id").replace("jazzquiz_control_","");s.disabled=-1===e.indexOf(n)})}},{key:"showFullscreenView",value:function(){s.main.hasClass("jazzquiz-fullscreen")?t.closeFullscreenView():(document.documentElement.style.overflowY="hidden",s.main.addClass("jazzquiz-fullscreen"))}},{key:"closeFullscreenView",value:function(){document.documentElement.style.overflowY="auto",s.main.removeClass("jazzquiz-fullscreen")}},{key:"closeQuestionListMenu",value:function(s,n){var o="#jazzquiz_"+n+"_menu";e(s.target).closest(o).length||(e(o).html("").removeClass("active"),t.control(n).removeClass("active"))}},{key:"addReportEventHandlers",value:function(){e(document).on("click","#report_overview_controls button",function(){var t=e(this).data("action");"attendance"===t?(e("#report_overview_responded").fadeIn(),e("#report_overview_responses").fadeOut()):"responses"===t&&(e("#report_overview_responses").fadeIn(),e("#report_overview_responded").fadeOut())})}},{key:"controls",get:function(){return e("#jazzquiz_controls_box")}},{key:"controlButtons",get:function(){return t.controls.find(".quiz-control-buttons")}},{key:"side",get:function(){return e("#jazzquiz_side_container")}},{key:"correctAnswer",get:function(){return e("#jazzquiz_correct_answer_container")}},{key:"isMerging",get:function(){return 0!==e(".merge-from").length}}]),t}();return{initialize:function(e,t,n){var o=new s(a);o.role.totalQuestions=e,t?(a.addReportEventHandlers(),o.role.responses.showResponses=!0,n.forEach(function(e){var t="jazzquiz_wrapper_responses_"+e.num,s="responses_wrapper_table_"+e.num,n="report_"+e.num;o.role.responses.set(t,s,e.responses,void 0,e.type,n,!1)})):o.poll(500)}}}); \ No newline at end of file diff --git a/amd/src/core.js b/amd/src/core.js index d839110..c1322ee 100755 --- a/amd/src/core.js +++ b/amd/src/core.js @@ -21,7 +21,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define(['jquery', 'core/config', 'core/str', 'core/yui'], function ($, mConfig, mString, Y) { +define(['jquery', 'core/config', 'core/str', 'core/yui', 'core/event'], function ($, mConfig, mString, Y, mEvent) { // Contains the needed values for using the ajax script. let session = { @@ -320,9 +320,7 @@ define(['jquery', 'core/config', 'core/str', 'core/yui'], function ($, mConfig, * Triggers a dynamic content update event, which MathJax listens to. */ static renderAllMathjax() { - Y.fire(M.core.event.FILTER_CONTENT_UPDATED, { - nodes: new Y.NodeList(document.getElementsByClassName('jazzquiz-latex-wrapper')) - }); + mEvent.notifyFilterContentUpdated(document.getElementsByClassName('jazzquiz-response-container')); } /** @@ -331,7 +329,7 @@ define(['jquery', 'core/config', 'core/str', 'core/yui'], function ($, mConfig, * @param {string} latex */ static addMathjaxElement($target, latex) { - $target.html('' + latex + ''); + $target.html('' + latex + ''); Quiz.renderAllMathjax(); } diff --git a/amd/src/instructor.js b/amd/src/instructor.js index a650aad..ba00cb8 100755 --- a/amd/src/instructor.js +++ b/amd/src/instructor.js @@ -884,8 +884,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) { return; } Ajax.get('get_right_response', {}, data => { - const answer = '' + data.right_answer + ''; - Quiz.show(Instructor.correctAnswer.html(answer)); + Quiz.show(Instructor.correctAnswer.html(data.right_answer)); Quiz.renderAllMathjax(); Quiz.check(Instructor.control('answer')); this.isShowingCorrectAnswer = true; diff --git a/templates/edit_question_list.mustache b/templates/edit_question_list.mustache index 1ba92c5..336d1c7 100755 --- a/templates/edit_question_list.mustache +++ b/templates/edit_question_list.mustache @@ -1,4 +1,4 @@ -
+

{{# str }} questions, jazzquiz {{/ str }}

@@ -13,10 +13,8 @@ {{{ icon }}}
- - - {{{ name }}} - + + {{{ name }}}
{{# first }}{{# pix }} spacer, core {{/ pix }}{{/ first }} diff --git a/templates/quiz.mustache b/templates/quiz.mustache index 1759b58..177d534 100755 --- a/templates/quiz.mustache +++ b/templates/quiz.mustache @@ -22,7 +22,7 @@
- +
@@ -46,6 +46,6 @@
- + {{/ instructor }}
\ No newline at end of file diff --git a/templates/report.mustache b/templates/report.mustache index daffc4a..9afd562 100755 --- a/templates/report.mustache +++ b/templates/report.mustache @@ -20,20 +20,16 @@ {{# str }} download_report, jazzquiz {{/str}}
-