Gitlab CSE Unil

Commit 8c1fa150 authored by M. Chardon's avatar M. Chardon
Browse files

migration des cours vers les contextes pour contrôle des formulaires ajax

parent 3ca80b06
define(["jquery","jqueryui","core/notification","core/templates","core/fragment","core/ajax","core/str","assignfeedback_editpdfplus/tool","assignfeedback_editpdfplus/tooltype","assignfeedback_editpdfplus/annotationhighlightplus","assignfeedback_editpdfplus/annotationstampplus","assignfeedback_editpdfplus/annotationframe","assignfeedback_editpdfplus/annotationcommentplus","assignfeedback_editpdfplus/annotationverticalline","assignfeedback_editpdfplus/annotationstampcomment"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p=null,q=null,r=null,s=null,t=null,u=function(a,b){p=a,this.initTypeTool(b),this.init()};u.messageDelOk="",u.messageDelKo="",u.messageko="",u.messageaddok="",u.messageaddlibelleko="",u.messageEditOk="",u.prototype.selectTool=null;var v=function(){g.get_string("admindeltool_messageok","assignfeedback_editpdfplus").done(function(a){u.messageDelOk=a}).fail(c.exception),g.get_string("admindeltool_messageko","assignfeedback_editpdfplus").done(function(a){u.messageDelKo=a}).fail(c.exception),g.get_string("adminaddtool_messageok","assignfeedback_editpdfplus").done(function(a){u.messageaddok=a}).fail(c.exception),g.get_string("admin_messageko","assignfeedback_editpdfplus").done(function(a){u.messageko=a}).fail(c.exception),g.get_string("adminedittool_messageok","assignfeedback_editpdfplus").done(function(a){u.messageEditOk=a}).fail(c.exception),g.get_string("adminaddtool_messagelibelleko","assignfeedback_editpdfplus").done(function(a){u.messageaddlibelleko=a}).fail(c.exception)};u.prototype.initTypeTool=function(a){var b=JSON.parse(a);s=[];for(var c=0;c<b.length;c++){var d=new i;d.initAdmin(b[c]),s[c]=d}},u.prototype.init=function(){a("#editpdlplus_axes").on("change",function(){a(".toolbar").hide();var b=a("#editpdlplus_axes").val();if(b&&""!==b){a("#editpdlplus_toolbar_"+b).show();var c=a("#editpdlplus_axes option:selected").data("delete");c?parseInt(c)>0?a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").prop("disabled",!0):a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeAttr("disabled"):(a("#editpdlplus_axes option[value='"+b+"']").data("delete",0),a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeAttr("disabled"))}else a("#assignfeedback_editpdfplus_widget_admin_workspace").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide();a("#toolworkspace").html("")}),a("#editpdlplus_axes").change(),a(".editpdlplus_tool").on("click",B),this.selectTool=a(".editpdlplus_tool").first(),this.initToolUI(),a("#assignfeedback_editpdfplus_widget_admin_button_addaxis").on("click",this.openDivAddAxis),a("#assignfeedback_editpdfplus_widget_admin_button_editaxis").on("click",this.openDivEditAxis),a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").on("click",this.openDivDelAxis),a("#assignfeedback_editpdfplus_widget_admin_button_addtool").on("click",this.openDivAddTool),a(".btn-primary").click(),a(".btnimport").on("click",this.importAxis),v()},u.prototype.initToolUI=function(){a(this.selectTool).addClass("btn-primary"),w()};var w=function(){a(".sortable").sortable({placeholder:"alert-warning",handle:"button",cancel:"",stop:function(b,d){var e=a(d.item).prev().find("button").val(),g=a(d.item).next().find("button").val(),h=a(d.item).find("button").val();a("input[name^='previoustoolid']").val(e),a("input[name^='toolid']").val(h),a("input[name^='nexttoolid']").val(g);var i=a("#assignfeedback_editpdfplus_order_tool"),j=i.serialize()+"&courseid="+a("#courseid").val();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_order_form",args:{jsonformdata:JSON.stringify(j)}}])[0].done(function(b){"ok"===b.message?(a("#message_order_tool").show(),a("#message_order_tool").html(u.messageEditOk),a("#message_order_tool").addClass("alert-success"),a("#message_order_tool").removeClass("alert-danger"),a("#message_order_tool").removeClass("alert-warning"),a("#message_order_tool").fadeOut(5e3)):(a("#message_order_tool").show(),a("#message_order_tool").html(u.messageko),a("#message_order_tool").addClass("alert-danger"),a("#message_order_tool").removeClass("alert-success"),a("#message_order_tool").fadeOut(5e3))}).fail(c.exception)}}),a(".sortable").disableSelection()};u.prototype.refreshPrevisu=function(){q.axis=a("#toolaxis").val(),q.typetool=a("#typetool").val(),q.colors=a("#color").val(),q.cartridge=a("#libelle").val(),q.cartridgeColor=a("#cartridgecolor").val();var b="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(b+='"'+a(this).val().replace(/"/g,"")+'",')}),b.length>0&&a("#texts").val(b.substring(0,b.length-1)),q.texts=a("#texts").val(),q.label=a("#button").val(),q.enabled=a("#enabled").val(),q.reply=0,a("#reply").is(":checked")&&(q.reply=1),q.orderTool=a("#order").val(),z(),y()};var x=function(a){for(var b=0;b<s.length;b++)if(s[b].id==a)return s[b]},y=function(){var b=parseInt(a("#typetool").val()),c=x(b),d=!1,e=!1;c.configurableCartridge&&0===parseInt(c.configurableCartridge)?(a("#libelle").hide(),a("label[for='libelle']").hide(),d=!0):(a("#libelle").show(),a("label[for='libelle']").show()),c.configurableCartridgeColor&&0===parseInt(c.configurableCartridgeColor)?(a("#cartridgecolor").hide(),a("label[for='cartridgecolor']").hide(),e=!0):(a("#cartridgecolor").show(),a("label[for='cartridgecolor']").show()),d&&e?a("#collapse3").parent().hide():a("#collapse3").parent().show();var f=!1,g=!1,h=!1;c.configurableColor&&0===parseInt(c.configurableColor)?(a("#color").hide(),a("label[for='color']").hide(),f=!0):(a("#color").show(),a("label[for='color']").show()),c.configurableTexts&&0===parseInt(c.configurableTexts)?(a(".textform").hide(),a("label[for='texts']").hide(),g=!0):(a(".textform").show(),a("label[for='texts']").show()),c.configurableQuestion&&0===parseInt(c.configurableQuestion)?(a("#reply").hide(),a("label[for='reply']").hide(),h=!0):(a("#reply").show(),a("label[for='reply']").show()),f&&h&&g?a("#collapse4").parent().hide():a("#collapse4").parent().show()},z=function(){a("#canevas").html(""),t=null;var b=parseInt(a("#typetool").val());if(3===b||4===b||7===b?a("#canevas").css("background-image","url("+a("#map01").val()+")"):1===b||6===b?a("#canevas").css("background-image","url("+a("#map02").val()+")"):5===b&&a("#canevas").css("background-image","url("+a("#map03").val()+")"),1===b)t=new j;else if(3===b)t=new k;else if(4===b){t=new l;var c=new l}else 5===b?t=new n:6===b?t=new o:7===b&&(t=new m);if(t){var d=x(b);q.type=d,q.reply=0,a("#reply").is(":checked")&&(q.reply=1),t.initAdminDemo(q),t.draw(a("#canevas")),c&&(c.initChildAdminDemo(t),c.draw(a("#canevas")))}};u.prototype.openDivAddAxis=function(){var b=a("#editpdlplus_axes").val();b&&""!==b?(a("#message_edit_tool").hide(),a("#axistool").hide()):(a("#assignfeedback_editpdfplus_widget_admin_workspace").show(),a("#editpdlplus_axes_worspace").hide()),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled",!0);var f={};e.loadFragment("assignfeedback_editpdfplus","axisadd",p,f).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_addaxis",a,b)}.bind(this)).fail(c.exception)},u.prototype.openDivEditAxis=function(){a("#message_edit_tool").hide(),a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled",!0);var b=a("#editpdlplus_axes option:selected").val(),f={axeid:b};e.loadFragment("assignfeedback_editpdfplus","axisedit",p,f).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_editaxis",a,b)}.bind(this)).fail(c.exception)},u.prototype.openDivDelAxis=function(){var b=a("#editpdlplus_axes option:selected").data("delete");if(null!==b&&0===parseInt(b)){a("#message_edit_tool").hide(),a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled",!0);var f=a("#editpdlplus_axes option:selected").val(),g={axeid:f};e.loadFragment("assignfeedback_editpdfplus","axisdel",p,g).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_delaxis",a,b)}.bind(this)).fail(c.exception)}};var A=function(b,c,e){var f=a.Deferred();return b.fadeOut("fast",function(){d.replaceNodeContents(b,c,e),b.fadeIn("fast",function(){f.resolve()})}),f.promise()};u.prototype.importAxis=function(){var b=a(this).data("axis");if(b&&parseInt(b)>0){a("#assignfeedback_editpdfplus_import_axis > div > input[name^='axeid']").val(b);var d=a("#assignfeedback_editpdfplus_import_axis"),e=d.serialize()+"&courseid="+a("#courseid").val();f.call([{methodname:"assignfeedback_editpdfplus_submit_axis_import_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(b){if(""===b[0].message){a("#message_import_axis").show(),a("#message_import_axis").html(u.messageaddok),a("#message_import_axis").addClass("alert-success"),a("#message_import_axis").removeClass("alert-danger"),a("#message_import_axis").removeClass("alert-warning"),a("#message_import_axis").fadeOut(5e3);var c="<div id='editpdlplus_toolbar_"+b[0].axeid+"' class='btn-group toolbar' style='display: none;'><ul class='sortable' style='list-style-type: none;margin: 0;padding: 0;width: 100%;'></ul></div>";a("#editpdlplus_toolbars").append(c),w();var d=new Option(b[0].axelabel,b[0].axeid,(!0),(!0));a("#editpdlplus_axes").append(d);var e=a("#editpdlplus_axes option[value='"+b[0].axeid+"']");e.data("delete",1);var f=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");if(f.prop("disabled",!0),a("#editpdlplus_tool_item").html(""),b[0].toolid&&b[0].toolid>0)for(var g=0;g<b.length;g++){var i=new h;i.initAdmin(b[g]);var j=i.getButtonSortable(b[g].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(j)}else{var k=b[0].axeid,e=a("#editpdlplus_axes option[value='"+k+"']");e.data("delete",0);var f=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");f.removeAttr("disabled")}a(".editpdlplus_tool").on("click",B),a("#editpdlplus_axes").change(),a("a[href^='#collapseadmin1'").click(),a("#axistool").show(),a("#assignfeedback_editpdfplus_widget_admin_toolheader").show(),a("#assignfeedback_editpdfplus_widget_admin_workspace").show(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").show()}else a("#message_import_axis").show(),a("#message_import_axis").html(b[0].message),a("#message_import_axis").addClass("alert-danger"),a("#message_import_axis").removeClass("alert-success"),a("#message_import_axis").fadeOut(5e3)}).fail(c.exception)}};var B=function(){var b=a(this).val();a(".editpdlplus_tool").each(function(){a(this).removeClass("btn-primary"),a(this).css("background-image",""),a(this).css("background-color","");var c=a(this).data("enable");1!==c&&a(this).val()!==b&&(a(this).css("background-image","none"),a(this).css("background-color","#CCCCCC"))}),a(this).addClass("btn-primary"),q&&q.id===b||a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html("");var d={toolid:b};e.loadFragment("assignfeedback_editpdfplus","tooledit",p,d).done(function(d,e){A(a("#editpdlplus_tool_item"),d,e).done(function(){q=new h,q.id=b,q.axis=a("#toolaxis").val(),q.typetool=a("#typetool").val();var d=x(q.typetool);q.type=d;var e=a("#realcolor").val();e.length>0?q.colors=a("#color").val():(a("#color").val(d.color),q.colors=null),q.cartridge=a("#libelle").val(),a("#realcartridgecolor").val()&&a("#realcartridgecolor").val().length>0?q.cartridgeColor=a("#cartridgecolor").val():(a("#cartridgecolor").val(d.get_color_cartridge()),q.cartridgeColor=null),q.texts=a("#texts").val(),q.label=a("#button").val(),q.enabled=a("#enabled").val(),q.reply=a("#reply").val(),q.orderTool=a("#order").val(),a("#typetool").on("change",function(){q.typetool=a("#typetool").val();var b=x(q.typetool);q.type=b,q.colors=b.get_color(),q.cartridgeColor=b.get_color_cartridge(),a("#color").val(q.colors),a("#cartridgecolor").val(q.cartridgeColor),y(),z()}),a("#toolFormSubmit").on("click",function(){var b="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(b+='"'+a(this).val().replace(/"/g,"")+'",')}),b.length>0&&a("#texts").val(b.substring(0,b.length-1));var d=a("#assignfeedback_editpdfplus_edit_tool"),e=d.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_edit_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").show(),a("#message_edit_tool").html(u.messageEditOk),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-warning"),a("#editpdlplus_tool_"+b[0].selecttool).remove(),a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").html("");for(var c=0;c<b.length;c++){var d=new h;d.initAdmin(b[c]);var e=d.getButtonSortable(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(e)}a(".editpdlplus_tool").on("click",B);var f=a("#axisid").val();f!==b[0].axeid&&(a("#editpdlplus_axes").val(b[0].axeid),a("#editpdlplus_axes").change()),a("#editpdlplus_tool_"+b[0].selecttool).click()}else a("#message_edit_tool").show(),a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(c.exception)}),a("#toolEnabled").on("click",function(){var b=a("#toolenabled").val();1==b?(a("#toolEnabled > i").addClass("fa-eye-slash"),a("#toolEnabled > i").removeClass("fa-eye"),a("#toolenabled").val(0)):(a("#toolEnabled > i").addClass("fa-eye"),a("#toolEnabled > i").removeClass("fa-eye-slash"),a("#toolenabled").val(1)),a("#toolFormSubmit").click()}),a("#toolClone").on("click",function(){r="clone",a("#assignfeedback_editpdfplus_widget_admin_button_addtool").click()}),a("#toolRemove").on("click",function(){if(!a(this).prop("disabled")){var b=a("#assignfeedback_editpdfplus_edit_tool"),d=b.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_del_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message||"1"===b[0].message){if(a("#message_edit_tool").show(),a("#message_edit_tool").html(u.messageDelOk),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-warning"),a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").html(""),parseInt(b[0].toolid)>0){for(var c=0;c<b.length;c++){var d=new h;d.initAdmin(b[c]);var e=d.getButtonSortable(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(e)}a(".editpdlplus_tool").on("click",B)}else{var f=b[0].axeid,g=a("#editpdlplus_axes option[value='"+f+"']");g.data("delete",0);var i=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");i.removeAttr("disabled")}a("#toolworkspace").html("")}else a("#message_edit_tool").show(),a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(c.exception)}}),a("#toolRefesh").on("click",function(){u.prototype.refreshPrevisu()}),z(),y()}.bind(this)).fail(c.exception)}.bind(this)).fail(c.exception)};return u.prototype.openDivAddTool=function(){a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html(""),a(".editpdlplus_tool").removeClass("btn-primary");var b=a("#editpdlplus_axes option:selected").val(),d={axisid:b};e.loadFragment("assignfeedback_editpdfplus","tooladd",p,d).done(function(d,e){A(a("#editpdlplus_tool_item"),d,e).done(function(){a("#canevas").hide(),a("#toolaxis").val(b),"clone"===r?(a("#toolaxis").val(q.axis),a("#typetool").val(q.typetool),a("#color").val(q.colors),a("#libelle").val(q.cartridge),a("#cartridgecolor").val(q.cartridgeColor),a("#texts").val(q.texts),a("#button").val(q.label),a("#enabled").val(q.enabled),a("#reply").val(q.reply),a("#order").val(q.orderTool),q=new h,r=null):(q=new h,a("#typetool").on("change",function(){q=new h,q.axis=a("#toolaxis").val(),q.typetool=a("#typetool").val();var b=x(q.typetool);q.type=b,q.colors=b.get_color(),q.cartridgeColor=b.get_color_cartridge(),a("#color").val(q.colors),a("#cartridgecolor").val(q.cartridgeColor),y()}),a("#typetool").change()),a("#toolFormSubmit").on("click",function(){if(""===a("#button").val())a("#message_edit_tool").show(),a("#message_edit_tool").html(u.messageaddlibelleko),a("#message_edit_tool").addClass("alert-warning"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success");else{var b="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(b+='"'+a(this).val().replace(/"/g,"")+'",')}),b.length>0&&a("#texts").val(b.substring(0,b.length-1));var d=a("#assignfeedback_editpdfplus_edit_tool"),e=d.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_add_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").show(),a("#message_edit_tool").html(u.messageaddok),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-warning"),a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").html("");for(var c=0;c<b.length;c++){var d=new h;d.initAdmin(b[c]);var e=d.getButtonSortable(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(e)}a(".editpdlplus_tool").on("click",B),a("#toolworkspace").html("");var f=b[0].axeid,g=a("#editpdlplus_axes option[value='"+f+"']");g.data("delete",1);var i=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");i.prop("disabled",!0)}else a("#message_edit_tool").show(),a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(c.exception)}})}.bind(this)).fail(c.exception)}.bind(this)).fail(c.exception)},u});
\ No newline at end of file
define(["jquery","jqueryui","core/notification","core/templates","core/fragment","core/ajax","core/str","assignfeedback_editpdfplus/tool","assignfeedback_editpdfplus/tooltype","assignfeedback_editpdfplus/annotationhighlightplus","assignfeedback_editpdfplus/annotationstampplus","assignfeedback_editpdfplus/annotationframe","assignfeedback_editpdfplus/annotationcommentplus","assignfeedback_editpdfplus/annotationverticalline","assignfeedback_editpdfplus/annotationstampcomment"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p=null,q=null,r=null,s=null,t=null,u=function(a,b){p=a,this.initTypeTool(b),this.init()};u.messageDelOk="",u.messageDelKo="",u.messageko="",u.messageaddok="",u.messageaddlibelleko="",u.messageEditOk="",u.prototype.selectTool=null;var v=function(){g.get_string("admindeltool_messageok","assignfeedback_editpdfplus").done(function(a){u.messageDelOk=a}).fail(c.exception),g.get_string("admindeltool_messageko","assignfeedback_editpdfplus").done(function(a){u.messageDelKo=a}).fail(c.exception),g.get_string("adminaddtool_messageok","assignfeedback_editpdfplus").done(function(a){u.messageaddok=a}).fail(c.exception),g.get_string("admin_messageko","assignfeedback_editpdfplus").done(function(a){u.messageko=a}).fail(c.exception),g.get_string("adminedittool_messageok","assignfeedback_editpdfplus").done(function(a){u.messageEditOk=a}).fail(c.exception),g.get_string("adminaddtool_messagelibelleko","assignfeedback_editpdfplus").done(function(a){u.messageaddlibelleko=a}).fail(c.exception)};u.prototype.initTypeTool=function(a){var b=JSON.parse(a);s=[];for(var c=0;c<b.length;c++){var d=new i;d.initAdmin(b[c]),s[c]=d}},u.prototype.init=function(){a("#editpdlplus_axes").on("change",function(){a(".toolbar").hide();var b=a("#editpdlplus_axes").val();if(b&&""!==b){a("#editpdlplus_toolbar_"+b).show();var c=a("#editpdlplus_axes option:selected").data("delete");c?parseInt(c)>0?a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").prop("disabled",!0):a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeAttr("disabled"):(a("#editpdlplus_axes option[value='"+b+"']").data("delete",0),a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeAttr("disabled"))}else a("#assignfeedback_editpdfplus_widget_admin_workspace").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide();a("#toolworkspace").html("")}),a("#editpdlplus_axes").change(),a(".editpdlplus_tool").on("click",B),this.selectTool=a(".editpdlplus_tool").first(),this.initToolUI(),a("#assignfeedback_editpdfplus_widget_admin_button_addaxis").on("click",this.openDivAddAxis),a("#assignfeedback_editpdfplus_widget_admin_button_editaxis").on("click",this.openDivEditAxis),a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").on("click",this.openDivDelAxis),a("#assignfeedback_editpdfplus_widget_admin_button_addtool").on("click",this.openDivAddTool),a(".btn-primary").click(),a(".btnimport").on("click",this.importAxis),v()},u.prototype.initToolUI=function(){a(this.selectTool).addClass("btn-primary"),w()};var w=function(){a(".sortable").sortable({placeholder:"alert-warning",handle:"button",cancel:"",stop:function(b,d){var e=a(d.item).prev().find("button").val(),g=a(d.item).next().find("button").val(),h=a(d.item).find("button").val();a("input[name^='previoustoolid']").val(e),a("input[name^='toolid']").val(h),a("input[name^='nexttoolid']").val(g);var i=a("#assignfeedback_editpdfplus_order_tool"),j=i.serialize()+"&contextid="+p;f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_order_form",args:{jsonformdata:JSON.stringify(j)}}])[0].done(function(b){"ok"===b.message?(a("#message_order_tool").show(),a("#message_order_tool").html(u.messageEditOk),a("#message_order_tool").addClass("alert-success"),a("#message_order_tool").removeClass("alert-danger"),a("#message_order_tool").removeClass("alert-warning"),a("#message_order_tool").fadeOut(5e3)):(a("#message_order_tool").show(),a("#message_order_tool").html(u.messageko),a("#message_order_tool").addClass("alert-danger"),a("#message_order_tool").removeClass("alert-success"),a("#message_order_tool").fadeOut(5e3))}).fail(c.exception)}}),a(".sortable").disableSelection()};u.prototype.refreshPrevisu=function(){q.axis=a("#toolaxis").val(),q.typetool=a("#typetool").val(),q.colors=a("#color").val(),q.cartridge=a("#libelle").val(),q.cartridgeColor=a("#cartridgecolor").val();var b="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(b+='"'+a(this).val().replace(/"/g,"")+'",')}),b.length>0&&a("#texts").val(b.substring(0,b.length-1)),q.texts=a("#texts").val(),q.label=a("#button").val(),q.enabled=a("#enabled").val(),q.reply=0,a("#reply").is(":checked")&&(q.reply=1),q.orderTool=a("#order").val(),z(),y()};var x=function(a){for(var b=0;b<s.length;b++)if(s[b].id==a)return s[b]},y=function(){var b=parseInt(a("#typetool").val()),c=x(b),d=!1,e=!1;c.configurableCartridge&&0===parseInt(c.configurableCartridge)?(a("#libelle").hide(),a("label[for='libelle']").hide(),d=!0):(a("#libelle").show(),a("label[for='libelle']").show()),c.configurableCartridgeColor&&0===parseInt(c.configurableCartridgeColor)?(a("#cartridgecolor").hide(),a("label[for='cartridgecolor']").hide(),e=!0):(a("#cartridgecolor").show(),a("label[for='cartridgecolor']").show()),d&&e?a("#collapse3").parent().hide():a("#collapse3").parent().show();var f=!1,g=!1,h=!1;c.configurableColor&&0===parseInt(c.configurableColor)?(a("#color").hide(),a("label[for='color']").hide(),f=!0):(a("#color").show(),a("label[for='color']").show()),c.configurableTexts&&0===parseInt(c.configurableTexts)?(a(".textform").hide(),a("label[for='texts']").hide(),g=!0):(a(".textform").show(),a("label[for='texts']").show()),c.configurableQuestion&&0===parseInt(c.configurableQuestion)?(a("#reply").hide(),a("label[for='reply']").hide(),h=!0):(a("#reply").show(),a("label[for='reply']").show()),f&&h&&g?a("#collapse4").parent().hide():a("#collapse4").parent().show()},z=function(){a("#canevas").html(""),t=null;var b=parseInt(a("#typetool").val());if(3===b||4===b||7===b?a("#canevas").css("background-image","url("+a("#map01").val()+")"):1===b||6===b?a("#canevas").css("background-image","url("+a("#map02").val()+")"):5===b&&a("#canevas").css("background-image","url("+a("#map03").val()+")"),1===b)t=new j;else if(3===b)t=new k;else if(4===b){t=new l;var c=new l}else 5===b?t=new n:6===b?t=new o:7===b&&(t=new m);if(t){var d=x(b);q.type=d,q.reply=0,a("#reply").is(":checked")&&(q.reply=1),t.initAdminDemo(q),t.draw(a("#canevas")),c&&(c.initChildAdminDemo(t),c.draw(a("#canevas")))}};u.prototype.openDivAddAxis=function(){var b=a("#editpdlplus_axes").val();b&&""!==b?(a("#message_edit_tool").hide(),a("#axistool").hide()):(a("#assignfeedback_editpdfplus_widget_admin_workspace").show(),a("#editpdlplus_axes_worspace").hide()),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled",!0);var f={};e.loadFragment("assignfeedback_editpdfplus","axisadd",p,f).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_addaxis",a,b)}.bind(this)).fail(c.exception)},u.prototype.openDivEditAxis=function(){a("#message_edit_tool").hide(),a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled",!0);var b=a("#editpdlplus_axes option:selected").val(),f={axeid:b};e.loadFragment("assignfeedback_editpdfplus","axisedit",p,f).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_editaxis",a,b)}.bind(this)).fail(c.exception)},u.prototype.openDivDelAxis=function(){var b=a("#editpdlplus_axes option:selected").data("delete");if(null!==b&&0===parseInt(b)){a("#message_edit_tool").hide(),a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled",!0);var f=a("#editpdlplus_axes option:selected").val(),g={axeid:f};e.loadFragment("assignfeedback_editpdfplus","axisdel",p,g).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_delaxis",a,b)}.bind(this)).fail(c.exception)}};var A=function(b,c,e){var f=a.Deferred();return b.fadeOut("fast",function(){d.replaceNodeContents(b,c,e),b.fadeIn("fast",function(){f.resolve()})}),f.promise()};u.prototype.importAxis=function(){var b=a(this).data("axis");if(b&&parseInt(b)>0){a("#assignfeedback_editpdfplus_import_axis > div > input[name^='axeid']").val(b);var d=a("#assignfeedback_editpdfplus_import_axis"),e=d.serialize()+"&contextid="+p;f.call([{methodname:"assignfeedback_editpdfplus_submit_axis_import_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(b){if(""===b[0].message){a("#message_import_axis").show(),a("#message_import_axis").html(u.messageaddok),a("#message_import_axis").addClass("alert-success"),a("#message_import_axis").removeClass("alert-danger"),a("#message_import_axis").removeClass("alert-warning"),a("#message_import_axis").fadeOut(5e3);var c="<div id='editpdlplus_toolbar_"+b[0].axeid+"' class='btn-group toolbar' style='display: none;'><ul class='sortable' style='list-style-type: none;margin: 0;padding: 0;width: 100%;'></ul></div>";a("#editpdlplus_toolbars").append(c),w();var d=new Option(b[0].axelabel,b[0].axeid,(!0),(!0));a("#editpdlplus_axes").append(d);var e=a("#editpdlplus_axes option[value='"+b[0].axeid+"']");e.data("delete",1);var f=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");if(f.prop("disabled",!0),a("#editpdlplus_tool_item").html(""),b[0].toolid&&b[0].toolid>0)for(var g=0;g<b.length;g++){var i=new h;i.initAdmin(b[g]);var j=i.getButtonSortable(b[g].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(j)}else{var k=b[0].axeid,e=a("#editpdlplus_axes option[value='"+k+"']");e.data("delete",0);var f=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");f.removeAttr("disabled")}a(".editpdlplus_tool").on("click",B),a("#editpdlplus_axes").change(),a("a[href^='#collapseadmin1'").click(),a("#axistool").show(),a("#assignfeedback_editpdfplus_widget_admin_toolheader").show(),a("#assignfeedback_editpdfplus_widget_admin_workspace").show(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").show()}else a("#message_import_axis").show(),a("#message_import_axis").html(b[0].message),a("#message_import_axis").addClass("alert-danger"),a("#message_import_axis").removeClass("alert-success"),a("#message_import_axis").fadeOut(5e3)}).fail(c.exception)}};var B=function(){var b=a(this).val();a(".editpdlplus_tool").each(function(){a(this).removeClass("btn-primary"),a(this).css("background-image",""),a(this).css("background-color","");var c=a(this).data("enable");1!==c&&a(this).val()!==b&&(a(this).css("background-image","none"),a(this).css("background-color","#CCCCCC"))}),a(this).addClass("btn-primary"),q&&q.id===b||a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html("");var d={toolid:b};e.loadFragment("assignfeedback_editpdfplus","tooledit",p,d).done(function(d,e){A(a("#editpdlplus_tool_item"),d,e).done(function(){q=new h,q.id=b,q.axis=a("#toolaxis").val(),q.typetool=a("#typetool").val();var d=x(q.typetool);q.type=d;var e=a("#realcolor").val();e.length>0?q.colors=a("#color").val():(a("#color").val(d.color),q.colors=null),q.cartridge=a("#libelle").val(),a("#realcartridgecolor").val()&&a("#realcartridgecolor").val().length>0?q.cartridgeColor=a("#cartridgecolor").val():(a("#cartridgecolor").val(d.get_color_cartridge()),q.cartridgeColor=null),q.texts=a("#texts").val(),q.label=a("#button").val(),q.enabled=a("#enabled").val(),q.reply=a("#reply").val(),q.orderTool=a("#order").val(),a("#typetool").on("change",function(){q.typetool=a("#typetool").val();var b=x(q.typetool);q.type=b,q.colors=b.get_color(),q.cartridgeColor=b.get_color_cartridge(),a("#color").val(q.colors),a("#cartridgecolor").val(q.cartridgeColor),y(),z()}),a("#toolFormSubmit").on("click",function(){var b="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(b+='"'+a(this).val().replace(/"/g,"")+'",')}),b.length>0&&a("#texts").val(b.substring(0,b.length-1));var d=a("#assignfeedback_editpdfplus_edit_tool"),e=d.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_edit_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").show(),a("#message_edit_tool").html(u.messageEditOk),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-warning"),a("#editpdlplus_tool_"+b[0].selecttool).remove(),a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").html("");for(var c=0;c<b.length;c++){var d=new h;d.initAdmin(b[c]);var e=d.getButtonSortable(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(e)}a(".editpdlplus_tool").on("click",B);var f=a("#axisid").val();f!==b[0].axeid&&(a("#editpdlplus_axes").val(b[0].axeid),a("#editpdlplus_axes").change()),a("#editpdlplus_tool_"+b[0].selecttool).click()}else a("#message_edit_tool").show(),a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(c.exception)}),a("#toolEnabled").on("click",function(){var b=a("#toolenabled").val();1==b?(a("#toolEnabled > i").addClass("fa-eye-slash"),a("#toolEnabled > i").removeClass("fa-eye"),a("#toolenabled").val(0)):(a("#toolEnabled > i").addClass("fa-eye"),a("#toolEnabled > i").removeClass("fa-eye-slash"),a("#toolenabled").val(1)),a("#toolFormSubmit").click()}),a("#toolClone").on("click",function(){r="clone",a("#assignfeedback_editpdfplus_widget_admin_button_addtool").click()}),a("#toolRemove").on("click",function(){if(!a(this).prop("disabled")){var b=a("#assignfeedback_editpdfplus_edit_tool"),d=b.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_del_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message||"1"===b[0].message){if(a("#message_edit_tool").show(),a("#message_edit_tool").html(u.messageDelOk),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-warning"),a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").html(""),parseInt(b[0].toolid)>0){for(var c=0;c<b.length;c++){var d=new h;d.initAdmin(b[c]);var e=d.getButtonSortable(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(e)}a(".editpdlplus_tool").on("click",B)}else{var f=b[0].axeid,g=a("#editpdlplus_axes option[value='"+f+"']");g.data("delete",0);var i=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");i.removeAttr("disabled")}a("#toolworkspace").html("")}else a("#message_edit_tool").show(),a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(c.exception)}}),a("#toolRefesh").on("click",function(){u.prototype.refreshPrevisu()}),z(),y()}.bind(this)).fail(c.exception)}.bind(this)).fail(c.exception)};return u.prototype.openDivAddTool=function(){a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html(""),a(".editpdlplus_tool").removeClass("btn-primary");var b=a("#editpdlplus_axes option:selected").val(),d={axisid:b};e.loadFragment("assignfeedback_editpdfplus","tooladd",p,d).done(function(d,e){A(a("#editpdlplus_tool_item"),d,e).done(function(){a("#canevas").hide(),a("#toolaxis").val(b),"clone"===r?(a("#toolaxis").val(q.axis),a("#typetool").val(q.typetool),a("#color").val(q.colors),a("#libelle").val(q.cartridge),a("#cartridgecolor").val(q.cartridgeColor),a("#texts").val(q.texts),a("#button").val(q.label),a("#enabled").val(q.enabled),a("#reply").val(q.reply),a("#order").val(q.orderTool),q=new h,r=null):(q=new h,a("#typetool").on("change",function(){q=new h,q.axis=a("#toolaxis").val(),q.typetool=a("#typetool").val();var b=x(q.typetool);q.type=b,q.colors=b.get_color(),q.cartridgeColor=b.get_color_cartridge(),a("#color").val(q.colors),a("#cartridgecolor").val(q.cartridgeColor),y()}),a("#typetool").change()),a("#toolFormSubmit").on("click",function(){if(""===a("#button").val())a("#message_edit_tool").show(),a("#message_edit_tool").html(u.messageaddlibelleko),a("#message_edit_tool").addClass("alert-warning"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success");else{var b="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(b+='"'+a(this).val().replace(/"/g,"")+'",')}),b.length>0&&a("#texts").val(b.substring(0,b.length-1));var d=a("#assignfeedback_editpdfplus_edit_tool"),e=d.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_add_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").show(),a("#message_edit_tool").html(u.messageaddok),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-warning"),a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").html("");for(var c=0;c<b.length;c++){var d=new h;d.initAdmin(b[c]);var e=d.getButtonSortable(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(e)}a(".editpdlplus_tool").on("click",B),a("#toolworkspace").html("");var f=b[0].axeid,g=a("#editpdlplus_axes option[value='"+f+"']");g.data("delete",1);var i=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");i.prop("disabled",!0)}else a("#message_edit_tool").show(),a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(c.exception)}})}.bind(this)).fail(c.exception)}.bind(this)).fail(c.exception)},u});
\ No newline at end of file
......@@ -242,7 +242,7 @@ define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragm
$("input[name^='toolid']").val(currentButtonId);
$("input[name^='nexttoolid']").val(nextButtonId);
var form = $('#assignfeedback_editpdfplus_order_tool');
var data = form.serialize() + "&courseid=" + $("#courseid").val();
var data = form.serialize() + "&contextid=" + contextid;
ajax.call([
{
methodname: 'assignfeedback_editpdfplus_submit_tool_order_form',
......@@ -517,7 +517,7 @@ define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragm
if (axisimportid && parseInt(axisimportid) > 0) {
$("#assignfeedback_editpdfplus_import_axis > div > input[name^='axeid']").val(axisimportid);
var form = $('#assignfeedback_editpdfplus_import_axis');
var data = form.serialize() + "&courseid=" + $("#courseid").val();
var data = form.serialize() + "&contextid=" + contextid;
ajax.call([
{
methodname: 'assignfeedback_editpdfplus_submit_axis_import_form',
......
......@@ -187,11 +187,13 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
$toolbarAxis = $statuschoice;
// Toolbar pour lien creation palette et aide
$courseid = $this->page->course->id;
$lienAdmin = new moodle_url('/mod/assign/feedback/editpdfplus/view_admin.php', array('id' => $courseid));
$parentContext = $this->page->context->get_parent_context();
if ($parentContext->contextlevel == CONTEXT_COURSE) {
$lienAdmin = new moodle_url('/mod/assign/feedback/editpdfplus/view_admin.php', array('id' => $parentContext->id));
$toolbarAdmin = $this->render_toolbar_button_html($this->render_toolbar_button_icon("fa-wrench"), array(
self::HTMLCLASS => 'btn btn-outline-info',
'onclick' => "document.location='" . $lienAdmin->out() . "';"));
}
$toolbarAdmin .= $this->render_toolbar_button_html($this->render_toolbar_button_icon("fa-question-circle"), array(self::HTMLCLASS => 'btn btn-outline-info helpmessage'));
$toolbarAdminBlock = $this->render_toolbar($toolbarAdmin, "mr-3");
} else {
......@@ -245,7 +247,7 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
//help message
$helpmessageTitle = html_writer::div(get_string('help_title', self::PLUGIN_NAME), null, array('id' => 'afppHelpmessageTitle'));
$helpmessagecontent=$this->render_from_template('assignfeedback_editpdfplus/help_workspace', array());
$helpmessagecontent = $this->render_from_template('assignfeedback_editpdfplus/help_workspace', array());
$helpmessageBody = html_writer::div($helpmessagecontent, null, array('id' => 'afppHelpmessageBody'));
$helpmessageDiv = html_writer::div($helpmessageTitle . $helpmessageBody, 'helpmessage');
$canvas .= $helpmessageDiv;
......
......@@ -49,16 +49,14 @@ class widget_admin implements renderable, templatable {
/**
* Constructor
* @param type $context
* @param type $course
* @param type $userid - The user id we are grading
* @param type $toolbars
* @param type $axis - the different axis to display
* @param type $typetools
* @param type $toolbarsDispo
*/
public function __construct($context, $course, $userid, $toolbars, $axis, $typetools, $toolbarsDispo) {
public function __construct($context, $userid, $toolbars, $axis, $typetools, $toolbarsDispo) {
$this->context = $context;
$this->course = $course;
$this->userid = $userid;
$this->toolbars = $toolbars;
$this->axis = $axis;
......
......@@ -41,7 +41,7 @@ class assignfeedback_editpdfplus_external extends external_api {
const DATAJSON = 'jsonformdata';
const MESSAGELIB = 'message';
const COURSELIB = "course";
const COURSEID = "courseid";
const CONTEXTID = "contextid";
const AXEID = "axeid";
const AXEIDDESC = "Axe ID";
const AXELIB = "axelabel";
......@@ -122,13 +122,12 @@ class assignfeedback_editpdfplus_external extends external_api {
* Set Page context from the course id given. It returns the context found.
* @global $DB
* @global $PAGE
* @param int $courseid Current course id
* @param int $contextid Current context id
* @return context course's context
*/
public static function setPageContext($courseid) {
global $DB, $PAGE;
$course = $DB->get_record(self::COURSELIB, array('id' => $courseid), '*', MUST_EXIST);
$context = context_course::instance($course->id, MUST_EXIST);
public static function setPageContext($contextid) {
global $PAGE;
$context = context::instance_by_id($contextid, MUST_EXIST);
$PAGE->set_context($context);
return $context;
}
......@@ -153,7 +152,7 @@ class assignfeedback_editpdfplus_external extends external_api {
public static function submit_axis_form($jsonformdata) {
$data = self::getParseData(self::submit_axis_form_parameters(), $jsonformdata);
$context = self::setPageContext($data[self::COURSEID]);
$context = self::setPageContext($data[self::CONTEXTID]);
$customdata = (object) $data;
$formparams = array($customdata);
......@@ -206,7 +205,7 @@ class assignfeedback_editpdfplus_external extends external_api {
public static function submit_axis_del_form($jsonformdata) {
$data = self::getParseData(self::submit_axis_form_parameters(), $jsonformdata);
self::setPageContext($data[self::COURSEID]);
self::setPageContext($data[self::CONTEXTID]);
$customdata = (object) $data;
$formparams = array($customdata);
......@@ -244,7 +243,7 @@ class assignfeedback_editpdfplus_external extends external_api {
public static function submit_tool_form($jsonformdata, $mode) {
$data = self::getParseData(self::submit_axis_form_parameters(), $jsonformdata);
$context = self::setPageContext($data[self::COURSEID]);
$context = self::setPageContext($data[self::CONTEXTID]);
$customdata = (object) $data;
......@@ -334,7 +333,7 @@ class assignfeedback_editpdfplus_external extends external_api {
public static function submit_tool_del_form($jsonformdata) {
$data = self::getParseData(self::submit_axis_form_parameters(), $jsonformdata);
$context = self::setPageContext($data[self::COURSEID]);
$context = self::setPageContext($data[self::CONTEXTID]);
$customdata = (object) $data;
......@@ -382,7 +381,7 @@ class assignfeedback_editpdfplus_external extends external_api {
$data = self::getParseData(self::submit_axis_import_form_parameters(), $jsonformdata);
$context = self::setPageContext($data[self::COURSEID]);
$context = self::setPageContext($data[self::CONTEXTID]);
$customdata = (object) $data;
$formparams = array($customdata);
......@@ -451,7 +450,7 @@ class assignfeedback_editpdfplus_external extends external_api {
public static function submit_tool_order_form($jsonformdata) {
$data = self::getParseData(self::submit_tool_order_form_parameters(), $jsonformdata);
self::setPageContext($data[self::COURSEID]);
self::setPageContext($data[self::CONTEXTID]);
$customdata = (object) $data;
......
......@@ -185,6 +185,8 @@ $string['help_highlight'] = 'Highlight an item in the document';
$string['help_verticalline'] = 'Click drag a vertical line in the document';
$string['help_stamp'] = 'Click where to place the stamp';
$string['admin_access_error'] = 'You are not allow to access this page, please contact your teacher or your manager';
$string['basepalette'] = 'Base annotation tools';
$string['basepalette_desc'] = 'The base annotation tool palette is defined <a href="{$a}">here</a> for the whole Moodle site. Teachers can then define their own tool palettes in their courses via the course administration menu.';
$string['assignmentgradedsubject'] = '[Moodle] Assignment updated';
$string['assignmentgradedbody'] = '{$a->coursename} → {$a->modulename} → {$a->assignmentname}
......
......@@ -184,3 +184,11 @@ $string['help_highlight'] = 'Surligner un élément dans le document';
$string['help_verticalline'] = 'Cliquer glisser une ligne verticale dans le document';
$string['help_stamp'] = 'Cliquer à l\'endroit où placer le tampon';
$string['admin_access_error'] = 'Vous n\'avez pas les droits suffisants pour accéder à cette page, contactez votre enseignant ou un responsable de Moodle.';
$string['basepalette'] = 'Base annotation tools';
$string['basepalette_desc'] = 'The base annotation tool palette is defined <a href="{$a}">here</a> for the whole Moodle site. Teachers can then define their own tool palettes in their courses via the course administration menu.';
$string['assignmentgradedsubject'] = '[Moodle] Assignment updated';
$string['assignmentgradedbody'] = '{$a->coursename} → {$a->modulename} → {$a->assignmentname}
The assignment correction has been updated.
You can access the document following this link: {$a->url}';
\ No newline at end of file
......@@ -23,7 +23,6 @@
* The code is based on mod/assign/feedback/editpdf/lib.php by Davo Smith.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
......@@ -39,7 +38,7 @@ defined('MOODLE_INTERNAL') || die();
* @return bool false if file not found, does not return if found - just send the file
*/
function assignfeedback_editpdfplus_pluginfile($course, $cm, context $context, $filearea, $args, $forcedownload, array $options = array()) {
global $USER, $DB, $CFG;
global $DB, $CFG;
require_once($CFG->dirroot . '/mod/assign/locallib.php');
......@@ -82,7 +81,7 @@ function assignfeedback_editpdfplus_pluginfile($course, $cm, context $context, $
*/
function assignfeedback_editpdfplus_extend_navigation_course(navigation_node $navigation, stdClass $course, context_course $context) {
if (has_capability('assignfeedback/editpdfplus:use', $context, null, false) && has_capability('assignfeedback/editpdfplus:managetools', $context, null, false)) {
$url = new moodle_url('/mod/assign/feedback/editpdfplus/view_admin.php', array('id' => $course->id));
$url = new moodle_url('/mod/assign/feedback/editpdfplus/view_admin.php', array('id' => $context->id));
$feedbackadminnode = navigation_node::create('Feedback : configuration', $url, navigation_node::TYPE_CUSTOM, 'Bars d\'outils', 'editpdfplusadmin', new pix_icon('i/grades', ""));
$navigation->add_node($feedbackadminnode);
}
......@@ -90,124 +89,79 @@ function assignfeedback_editpdfplus_extend_navigation_course(navigation_node $na
/**
* Get axis form (add)
* @global $DB
* @param type $args
*/
function assignfeedback_editpdfplus_output_fragment_axisadd($args) {
global $DB;
$context = $args['context'];
if ($context->contextlevel != CONTEXT_COURSE) {
return null;
}
require_once('locallib_admin.php');
if (has_capability('assignfeedback/editpdfplus:managetools', $context, null, false)) {
$course = $DB->get_record('course', array('id' => $context->instanceid), '*', MUST_EXIST);
$editpdfplus = new assign_feedback_editpdfplus_admin($context, $course);
return $editpdfplus->getAxisForm();
}
require_capability('assignfeedback/editpdfplus:managetools', $context, null, true, get_string('admin_access_error', 'assignfeedback_editpdfplus'));
return null;
$editpdfplus = new assign_feedback_editpdfplus_admin($context);
return $editpdfplus->getAxisForm();
}
/**
* Get axis form (edit)
* @global $DB
* @param type $args
*/
function assignfeedback_editpdfplus_output_fragment_axisedit($args) {
global $DB;
$context = $args['context'];
$axisid = $args['axeid'];
if ($context->contextlevel != CONTEXT_COURSE) {
return null;
}
require_once('locallib_admin.php');
if (has_capability('assignfeedback/editpdfplus:managetools', $context, null, false)) {
$course = $DB->get_record('course', array('id' => $context->instanceid), '*', MUST_EXIST);
$editpdfplus = new assign_feedback_editpdfplus_admin($context, $course);
return $editpdfplus->getAxisForm($axisid);
}
require_capability('assignfeedback/editpdfplus:managetools', $context, null, true, get_string('admin_access_error', 'assignfeedback_editpdfplus'));
return null;
$editpdfplus = new assign_feedback_editpdfplus_admin($context);
return $editpdfplus->getAxisForm($axisid);
}
/**
* Get axis form (delete)
* @global $DB
* @param type $args
*/
function assignfeedback_editpdfplus_output_fragment_axisdel($args) {
global $DB;
$context = $args['context'];
$axisid = $args['axeid'];
if ($context->contextlevel != CONTEXT_COURSE) {
return null;
}
require_once('locallib_admin.php');
if (has_capability('assignfeedback/editpdfplus:managetools', $context, null, false)) {
$course = $DB->get_record('course', array('id' => $context->instanceid), '*', MUST_EXIST);
$editpdfplus = new assign_feedback_editpdfplus_admin($context, $course);
return $editpdfplus->getAxisDelForm($axisid);
}
require_capability('assignfeedback/editpdfplus:managetools', $context, null, true, get_string('admin_access_error', 'assignfeedback_editpdfplus'));
return null;
$editpdfplus = new assign_feedback_editpdfplus_admin($context);
return $editpdfplus->getAxisDelForm($axisid);
}
/**
* Get tool form (edit)
* @global $DB
* @param type $args
*/
function assignfeedback_editpdfplus_output_fragment_tooledit($args) {
global $DB;
$context = $args['context'];
$toolid = $args['toolid'];
if ($context->contextlevel != CONTEXT_COURSE) {
return null;
}
require_once('locallib_admin.php');
if (has_capability('assignfeedback/editpdfplus:managetools', $context, null, false)) {
$course = $DB->get_record('course', array('id' => $context->instanceid), '*', MUST_EXIST);
$editpdfplus = new assign_feedback_editpdfplus_admin($context, $course);
return $editpdfplus->getToolForm($toolid);
}
require_capability('assignfeedback/editpdfplus:managetools', $context, null, true, get_string('admin_access_error', 'assignfeedback_editpdfplus'));
return null;
$editpdfplus = new assign_feedback_editpdfplus_admin($context);
return $editpdfplus->getToolForm($toolid);
}
/**
* Get tool form (add)
* @global $DB
* @param type $args
*/
function assignfeedback_editpdfplus_output_fragment_tooladd($args) {
global $DB;
$context = $args['context'];
$axisid = $args['axisid'];
if ($context->contextlevel != CONTEXT_COURSE) {
return null;
}
require_once('locallib_admin.php');
if (has_capability('assignfeedback/editpdfplus:managetools', $context, null, false)) {
$course = $DB->get_record('course', array('id' => $context->instanceid), '*', MUST_EXIST);
$editpdfplus = new assign_feedback_editpdfplus_admin($context, $course);
return $editpdfplus->getToolForm(null, $axisid);
}
require_capability('assignfeedback/editpdfplus:managetools', $context, null, true, get_string('admin_access_error', 'assignfeedback_editpdfplus'));
return null;
$editpdfplus = new assign_feedback_editpdfplus_admin($context);
return $editpdfplus->getToolForm(null, $axisid);
}
......@@ -37,15 +37,11 @@ class assign_feedback_editpdfplus_admin {
const PLUGIN_NAME = "assignfeedback_editpdfplus";
/** @var stdClass $course current course */
private $course = null;
/** @var stdClass $context current context */
private $context = null;
function __construct(stdClass $context, stdClass $course) {
function __construct(stdClass $context) {
$this->context = $context;
$this->course = $course;
}
/**
......@@ -59,18 +55,17 @@ class assign_feedback_editpdfplus_admin {
$html = '';
$renderer = $PAGE->get_renderer(self::PLUGIN_NAME);
$axisimportform = new axis_import_form(null, array('id' => $this->course->id), null, null, array('id' => "assignfeedback_editpdfplus_import_axis"));
$axisimportform = new axis_import_form(null, array('id' => $this->context->id), null, null, array('id' => "assignfeedback_editpdfplus_import_axis"));
$axisimportform->id = "assignfeedback_editpdfplus_import_axis";
$axisimportform->title = "";
$axisimportform->action = "import";
$toolorderform = new tool_order_form(null, array('id' => $this->course->id), null, null, array('id' => "assignfeedback_editpdfplus_order_tool"));
$toolorderform = new tool_order_form(null, array('id' => $this->context->id), null, null, array('id' => "assignfeedback_editpdfplus_order_tool"));
$toolorderform->id = "assignfeedback_editpdfplus_order_tool";
$toolorderform->title = "";
$toolorderform->action = "order";
$widget = $this->get_widget();
$widget->axisimportform = $axisimportform;
$widget->toolorderform = $toolorderform;
$widget->courseid = $this->course->id;
$html .= $renderer->render_assignfeedback_editpdfplus_widget_admin($widget);
return $html;
}
......@@ -93,20 +88,20 @@ class assign_feedback_editpdfplus_admin {
$axis = $DB->get_record('assignfeedback_editpp_axis', array('id' => $axeid), '*', MUST_EXIST);
}
if ($axis != null) {
$formAxis = new axis_form(null, array('id' => $this->course->id), null, null, array('id' => "assignfeedback_editpdfplus_edit_axis")); //Form processing and displaying is done here
$formAxis = new axis_form(null, array('id' => $this->context->id), null, null, array('id' => "assignfeedback_editpdfplus_edit_axis")); //Form processing and displaying is done here
$formAxis->set_data(array('axeid' => $axeid, 'label' => $axis->label));
$formAxis->id = "assignfeedback_editpdfplus_edit_axis";
$formAxis->title = "Renommer l'axe";
$formAxis->action = "edit";
} else {
$formAxis = new axis_form(null, array('id' => $this->course->id), null, null, array('id' => "assignfeedback_editpdfplus_add_axis")); //Form processing and displaying is done here
$formAxis = new axis_form(null, array('id' => $this->context->id), null, null, array('id' => "assignfeedback_editpdfplus_add_axis")); //Form processing and displaying is done here
$formAxis->set_data($toform);
$formAxis->id = "assignfeedback_editpdfplus_add_axis";
$formAxis->title = "Ajouter un nouvel axe";
$formAxis->action = "add";
}
$renderer = $PAGE->get_renderer(self::PLUGIN_NAME);
$formAxis->courseid = $this->course->id;
$formAxis->contextid = $this->context->id;
$html .= $renderer->render_assignfeedback_editpdfplus_widget_admin_axisform($formAxis);
return $html;
}
......@@ -128,14 +123,14 @@ class assign_feedback_editpdfplus_admin {
$axis = $DB->get_record('assignfeedback_editpp_axis', array('id' => $axeid), '*', MUST_EXIST);
}
if ($axis != null) {
$formAxis = new axis_del_form(null, array('id' => $this->course->id), null, null, array('id' => "assignfeedback_editpdfplus_del_axis")); //Form processing and displaying is done here
$formAxis = new axis_del_form(null, array('id' => $this->context->id), null, null, array('id' => "assignfeedback_editpdfplus_del_axis")); //Form processing and displaying is done here
$formAxis->set_data(array('axeid' => $axeid, 'label' => $axis->label));
}
$formAxis->id = "assignfeedback_editpdfplus_del_axis";
$formAxis->title = "Supprimer l'axe";
$formAxis->action = "del";
$renderer = $PAGE->get_renderer(self::PLUGIN_NAME);
$formAxis->courseid = $this->course->id;
$formAxis->contextid = $this->context->id;
$html .= $renderer->render_assignfeedback_editpdfplus_widget_admin_axisdelform($formAxis);
return $html;
}
......@@ -153,7 +148,7 @@ class assign_feedback_editpdfplus_admin {
$html = '';
$data = new stdClass;
$data->courseid = $this->course->id;
$data->contextid = $this->context->id;
$data->sesskey = sesskey();
$data->actionurl = "/moodle/lib/ajax/service.php";
$data->formid = "assignfeedback_editpdfplus_edit_tool";
......@@ -188,35 +183,24 @@ class assign_feedback_editpdfplus_admin {
global $USER;