MDL-66958 core_grade: Add comparison js for grade saves
[moodle.git] / mod / forum / amd / build / local / grades / grader.min.js
1 define ("mod_forum/local/grades/grader",["exports","core/templates","./local/grader/selectors","./local/grader/user_picker","mod_forum/local/layout/fullscreen","./local/grader/gradingpanel","core/toast","core/str","core_grades/grades/grader/gradingpanel/normalise","core/loadingicon","core/utils","core_grades/grades/grader/gradingpanel/comparison"],function(a,b,c,d,e,f,g,h,i,j,k,l){"use strict";Object.defineProperty(a,"__esModule",{value:!0});Object.defineProperty(a,"getGradingPanelFunctions",{enumerable:!0,get:function get(){return f.default}});a.launch=void 0;b=m(b);c=m(c);d=m(d);f=m(f);function m(a){return a&&a.__esModule?a:{default:a}}function n(a){for(var b=1;b<arguments.length;b++){var c=null!=arguments[b]?arguments[b]:{},d=Object.keys(c);if("function"==typeof Object.getOwnPropertySymbols){d=d.concat(Object.getOwnPropertySymbols(c).filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable}))}d.forEach(function(b){o(a,b,c[b])})}return a}function o(a,b,c){if(b in a){Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0})}else{a[b]=c}return a}function p(a,b){return s(a)||r(a,b)||q()}function q(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function r(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function s(a){if(Array.isArray(a))return a}function t(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function u(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){t(h,d,e,f,g,"next",a)}function g(a){t(h,d,e,f,g,"throw",a)}f(void 0)})}}var v={grader:{app:"mod_forum/local/grades/grader",gradingPanel:{error:"mod_forum/local/grades/local/grader/gradingpanel/error"},searchResults:"mod_forum/local/grades/local/grader/user_picker/user_search",status:"mod_forum/local/grades/local/grader/status"}},w=function(a,d){var e=a.querySelector(c.default.regions.pickerRegion);b.default.replaceNodeContents(e,d,"")},x=function(a,b){return[a,b]},y=function(a,d,e){var f=!0;return function(){var g=u(regeneratorRuntime.mark(function g(h){var i,k,m,n,o,q,r,s,t,u,v,w,y;return regeneratorRuntime.wrap(function(g){while(1){switch(g.prev=g.next){case 0:i=f?null:(0,j.addIconToContainerWithPromise)(a);g.next=3;return Promise.all([d(h.id).then(x),e(h.id)]);case 3:k=g.sent;m=p(k,2);n=p(m[0],2);o=n[0];q=n[1];r=m[1];b.default.replaceNodeContents(a.querySelector(c.default.regions.moduleReplace),o,q);g.next=12;return b.default.render(r.templatename,r.grade).then(x);case 12:s=g.sent;t=p(s,2);u=t[0];v=t[1];w=a.querySelector(c.default.regions.gradingPanelContainer);y=w.querySelector(c.default.regions.gradingPanel);b.default.replaceNodeContents(y,u,v);(0,l.fillInitialValues)(y.querySelector("form"));w.scrollTop=0;f=!1;if(i){i.resolve()}case 23:case"end":return g.stop();}}},g)}));return function(){return g.apply(this,arguments)}}()},z=function(a,b,c){a.classList.add("hidden");b.classList.add("hidden");c.classList.remove("hidden")},A=function(a,b,c){a.classList.remove("hidden");b.classList.remove("hidden");c.classList.add("hidden")},B=function(a,b,c){b.classList.remove("collapsed");a.setAttribute("aria-expanded","true");a.classList.add("expand");a.classList.remove("collapse");c.focus()},C=function(a,b,c){b.classList.add("collapsed");a.setAttribute("aria-expanded","false");a.classList.add("collapse");a.classList.remove("expand");a.focus();c.value=""},D=function(a,b){if(""===b){return a}b=b.toLowerCase();return a.filter(function(a){return a.fullname.toLowerCase().includes(b)})},E=function(){var a=u(regeneratorRuntime.mark(function a(c,d){var e,f,g;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.next=2;return b.default.renderForPromise(v.grader.searchResults,{users:d});case 2:e=a.sent;f=e.html;g=e.js;b.default.replaceNodeContents(c,f,g);case 6:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),F=function(a,b,d,e){var f=a.getContainer(),g=f.querySelector(c.default.buttons.toggleSearch),h=f.querySelector(c.default.regions.userSearchContainer),i=h.querySelector(c.default.regions.userSearchInput),j=f.querySelector(c.default.regions.bodyContainer),l=f.querySelector(c.default.regions.pickerRegion),m=f.querySelector(c.default.regions.searchResultsContainer);f.addEventListener("click",function(f){if(f.target.closest(c.default.buttons.toggleFullscreen)){f.stopImmediatePropagation();f.preventDefault();a.toggleFullscreen();return}if(f.target.closest(c.default.buttons.closeGrader)){f.stopImmediatePropagation();f.preventDefault();a.close();return}if(f.target.closest(c.default.buttons.saveGrade)){d(b.currentUser)}if(f.target.closest(c.default.buttons.toggleSearch)){if("true"===g.getAttribute("aria-expanded")){C(g,h,i);A(j,l,m);m.innerHTML=""}else{B(g,h,i);z(j,l,m);E(m,e)}return}var k=f.target.closest(c.default.buttons.selectUser);if(k){var n=k.getAttribute("data-userid"),o=e.find(function(a){return a.id==n});b.setUserId(n);b.showUser(o);C(g,h,i);A(j,l,m);m.innerHTML=""}});i.addEventListener("input",(0,k.debounce)(function(){var a=D(e,i.value);E(m,a)},300))},G=function(a,b){return function(){var d=u(regeneratorRuntime.mark(function d(e){var f;return regeneratorRuntime.wrap(function(d){while(1){switch(d.prev=d.next){case 0:d.prev=0;a.querySelector(c.default.regions.gradingPanelErrors).innerHTML="";d.next=4;return b(e.id,a.querySelector(c.default.regions.gradingPanel));case 4:f=d.sent;if(!f.success){d.next=11;break}d.t0=g.add;d.next=9;return(0,h.get_string)("grades:gradesavedfor","mod_forum",e);case 9:d.t1=d.sent;(0,d.t0)(d.t1);case 11:if(f.failed){H(a,e,f.error)}return d.abrupt("return",f);case 15:d.prev=15;d.t2=d["catch"](0);H(a,e,d.t2);return d.abrupt("return",(0,i.failedUpdate)(d.t2));case 19:case"end":return d.stop();}}},d,null,[[0,15]])}));return function(){return d.apply(this,arguments)}}()},H=function(){var a=u(regeneratorRuntime.mark(function a(d,e,f){var i,j,k,l,m,o;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.t0=Promise;a.t1=b.default.renderForPromise(v.grader.gradingPanel.error,{error:f});a.next=4;return(0,h.get_string)("grades:gradesavefailed","mod_forum",n({error:f.message},e));case 4:a.t2=a.sent;a.t3=[a.t1,a.t2];a.next=8;return a.t0.all.call(a.t0,a.t3);case 8:i=a.sent;j=p(i,2);k=j[0];l=k.html;m=k.js;o=j[1];b.default.replaceNodeContents(d.querySelector(c.default.regions.gradingPanelErrors),l,m);(0,g.add)(o);case 16:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),I=function(){var a=u(regeneratorRuntime.mark(function a(f,g,h,i){var j,k,l,m,n,o,q,r,s,t,u,x,z,A,B,C,D,E,H,I=arguments;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:j=4<I.length&&I[4]!==void 0?I[4]:{},k=j.initialUserId,l=void 0===k?null:k,m=j.moduleName,n=j.courseName,o=j.courseUrl;a.next=3;return Promise.all([(0,e.createLayout)({fullscreen:!1,showLoader:!1}),b.default.renderForPromise(v.grader.app,{moduleName:m,courseName:n,courseUrl:o,drawer:{show:!0}}),f()]);case 3:q=a.sent;r=p(q,3);s=r[0];t=r[1];u=t.html;x=t.js;z=r[2];A=s.getContainer();B=G(A,i);b.default.replaceNodeContents(A,u,x);C=y(A,g,h);D=z.map(function(a){return a.id});E=A.querySelector(c.default.regions.statusContainer);a.next=18;return(0,d.default)(z,function(a){var c={status:null,index:D.indexOf(a.id)+1,total:z.length};b.default.render(v.grader.status,c).then(function(a){E.innerHTML=a;return a}).catch();C(a)},B,{initialUserId:l});case 18:H=a.sent;F(s,H,B,z);w(A,H.rootNode);case 21:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.launch=I});
2 //# sourceMappingURL=grader.min.js.map