You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
1.9 KiB
1 lines
1.9 KiB
define(["jquery","core/ajax","core/str","core/modal_factory","core/modal_events","core/notification","core/custom_interaction_events","core/templates"],function(a,b,c,d,e,f,g,h){var i,j,k=function(a,b){return a>0?"i/completion-"+b+"-y-override":"i/completion-"+b+"-n-override"},l=function(a){h.render("core/loading",{}).then(function(c){return j.append(c),b.call([{methodname:"core_completion_override_activity_completion_status",args:a}])[0]}).then(function(b){var d=b.state>0?1:0,e=d?"completion-y-override":"completion-n-override";c.get_string(e,"completion",i).then(function(a){var b={state:a,date:"",user:j.attr("data-userfullname"),activity:j.attr("data-activityname")};return c.get_string("progress-title","completion",b)}).then(function(a){var b=j.attr("data-completiontracking");return h.renderPix(k(d,b),"core",a)}).then(function(b){var c=d>0?0:1;j.find(".loading-icon").remove(),j.data("changecompl",a.userid+"-"+a.cmid+"-"+c),j.attr("data-changecompl",a.userid+"-"+a.cmid+"-"+c),j.children("img").replaceWith(b)})["catch"](f.exception)})["catch"](f.exception)},m=function(b,g){g.originalEvent.preventDefault(),g.originalEvent.stopPropagation(),b.preventDefault(),b.stopPropagation(),j=a(b.currentTarget);var h=j.data("changecompl").split("-"),i={userid:h[0],cmid:h[1],newstate:h[2]},k=1==i.newstate?"completion-y":"completion-n";c.get_strings([{key:k,component:"completion"}]).then(function(a){return c.get_strings([{key:"confirm",component:"moodle"},{key:"areyousureoverridecompletion",component:"completion",param:a[0]}])}).then(function(a){return d.create({type:d.types.CONFIRM,title:a[0],body:a[1]})}).then(function(a){a.getRoot().on(e.yes,function(){l(i)}),a.getRoot().on(e.hidden,function(){j.focus(),a.destroy()}),a.show()})["catch"](f.exception)},n=function(b){i=b,a("#completion-progress a.changecompl").each(function(a,b){g.define(b,[g.events.activate])}),a("#completion-progress").on(g.events.activate,"a.changecompl",function(a,b){m(a,b)})};return{init:n}});
|