Gitlab CSE Unil

Commit c8931d2c authored by M. Chardon's avatar M. Chardon
Browse files

tool suppression

parent 96ee90f2
define(["jquery","core/notification","core/templates","core/fragment","core/ajax"],function(a,b,c,d,e){var f=null,g=null,h=null,i=function(a){this.init(),f=a};i.prototype.selectTool=null,i.prototype.init=function(){a("#editpdlplus_axes").on("change",function(){a(".toolbar").hide();var b=a("#editpdlplus_axes").val();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").addClass("disabled"):a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeClass("disabled")}),a("#editpdlplus_axes").change(),a(".editpdlplus_tool").on("click",k),this.selectTool=a(".editpdlplus_tool").first(),this.initTool(),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)},i.prototype.test=function(){alert("test"),k()},i.prototype.initTool=function(){a(this.selectTool).removeClass("btn-default"),a(this.selectTool).addClass("btn-primary")},i.prototype.openDivAddAxis=function(){a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body").html("");var e={};d.loadFragment("assignfeedback_editpdfplus","axisadd",f,e).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},i.prototype.openDivEditAxis=function(){a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body").html("");var e=a("#editpdlplus_axes option:selected").val(),g={axeid:e};d.loadFragment("assignfeedback_editpdfplus","axisedit",f,g).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},i.prototype.openDivDelAxis=function(){a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body").html("");var e=a("#editpdlplus_axes option:selected").val(),g={axeid:e};d.loadFragment("assignfeedback_editpdfplus","axisdel",f,g).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)};var j=function(b,d,e){var f=a.Deferred();return b.fadeOut("fast",function(){c.replaceNodeContents(b,d,e),b.fadeIn("fast",function(){f.resolve()})}),f.promise()},k=function(){var c=a(this).val();a(".editpdlplus_tool").each(function(){a(this).removeClass("btn-primary"),a(this).removeClass("btn-default");var b=a(this).data("enable");1===b&&a(this).val()!==c&&a(this).addClass("btn-default")}),a(this).addClass("btn-primary"),a("#editpdlplus_tool_item").html("");var i={toolid:c};d.loadFragment("assignfeedback_editpdfplus","tooledit",f,i).done(function(c,d){j(a("#editpdlplus_tool_item"),c,d).done(function(){a("#toolFormSubmit").on("click",function(){var c=a("#assignfeedback_editpdfplus_edit_tool"),d=c.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_edit_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").html("Modifications enregistrées"),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#editpdlplus_toolbar_"+b[0].axeid).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",k)}else a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(b.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(){h="clone",g=new Object,g.typetool=a("#typetool").val(),g.color=a("#color").val(),g.libelle=a("#libelle").val(),g.catridgecolor=a("#catridgecolor").val(),g.texts=a("#texts").val(),g.button=a("#button").val(),g.enabled=a("#enabled").val(),g.reply=a("#reply").val(),g.order=a("#order").val(),a("#assignfeedback_editpdfplus_widget_admin_button_addtool").click()})}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)};return i.prototype.openDivAddTool=function(){a("#editpdlplus_tool_item").html(""),a(".btn-primary").addClass("btn-default"),a(".editpdlplus_tool").removeClass("btn-primary");var c=a("#editpdlplus_axes option:selected").val(),i={axisid:c};d.loadFragment("assignfeedback_editpdfplus","tooladd",f,i).done(function(c,d){j(a("#editpdlplus_tool_item"),c,d).done(function(){"clone"===h&&(alert(g),a("#typetool").val(g.typetool),a("#color").val(g.color),a("#libelle").val(g.libelle),a("#catridgecolor").val(g.catridgecolor),a("#texts").val(g.texts),a("#button").val(g.button),a("#enabled").val(g.enabled),a("#reply").val(g.reply),a("#order").val(g.order),g=null,h=null),a("#toolFormSubmit").on("click",function(){var c=a("#assignfeedback_editpdfplus_edit_tool"),d=c.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_add_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").html("Ajout enregistré"),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#editpdlplus_toolbar_"+b[0].axeid).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",k),a("#editpdlplus_tool_item").html("")}else a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(b.exception)})}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)},i});
\ No newline at end of file
define(["jquery","core/notification","core/templates","core/fragment","core/ajax"],function(a,b,c,d,e){var f=null,g=null,h=null,i=function(a){this.init(),f=a};i.prototype.selectTool=null,i.prototype.init=function(){a("#editpdlplus_axes").on("change",function(){a(".toolbar").hide();var b=a("#editpdlplus_axes").val();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").addClass("disabled"):a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeClass("disabled")}),a("#editpdlplus_axes").change(),a(".editpdlplus_tool").on("click",k),this.selectTool=a(".editpdlplus_tool").first(),this.initTool(),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)},i.prototype.test=function(){alert("test"),k()},i.prototype.initTool=function(){a(this.selectTool).removeClass("btn-default"),a(this.selectTool).addClass("btn-primary")},i.prototype.openDivAddAxis=function(){a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body").html("");var e={};d.loadFragment("assignfeedback_editpdfplus","axisadd",f,e).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},i.prototype.openDivEditAxis=function(){a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body").html("");var e=a("#editpdlplus_axes option:selected").val(),g={axeid:e};d.loadFragment("assignfeedback_editpdfplus","axisedit",f,g).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},i.prototype.openDivDelAxis=function(){a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body").html("");var e=a("#editpdlplus_axes option:selected").val(),g={axeid:e};d.loadFragment("assignfeedback_editpdfplus","axisdel",f,g).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)};var j=function(b,d,e){var f=a.Deferred();return b.fadeOut("fast",function(){c.replaceNodeContents(b,d,e),b.fadeIn("fast",function(){f.resolve()})}),f.promise()},k=function(){var c=a(this).val();a(".editpdlplus_tool").each(function(){a(this).removeClass("btn-primary"),a(this).removeClass("btn-default");var b=a(this).data("enable");1===b&&a(this).val()!==c&&a(this).addClass("btn-default")}),a(this).addClass("btn-primary"),a("#editpdlplus_tool_item").html("");var i={toolid:c};d.loadFragment("assignfeedback_editpdfplus","tooledit",f,i).done(function(c,d){j(a("#editpdlplus_tool_item"),c,d).done(function(){a("#toolFormSubmit").on("click",function(){var c=a("#assignfeedback_editpdfplus_edit_tool"),d=c.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_edit_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").html("Modifications enregistrées"),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#editpdlplus_toolbar_"+b[0].axeid).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",k)}else a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(b.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(){h="clone",g=new Object,g.typetool=a("#typetool").val(),g.color=a("#color").val(),g.libelle=a("#libelle").val(),g.catridgecolor=a("#catridgecolor").val(),g.texts=a("#texts").val(),g.button=a("#button").val(),g.enabled=a("#enabled").val(),g.reply=a("#reply").val(),g.order=a("#order").val(),a("#assignfeedback_editpdfplus_widget_admin_button_addtool").click()}),a("#toolRemove").on("click",function(){if(!a(this).hasClass("disabled")){var c=a("#assignfeedback_editpdfplus_edit_tool"),d=c.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_del_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").html("Outil supprimé"),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#editpdlplus_toolbar_"+b[0].axeid).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",k),a("#toolworkspace").html("")}else a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(b.exception)}})}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)};return i.prototype.openDivAddTool=function(){a("#editpdlplus_tool_item").html(""),a(".btn-primary").addClass("btn-default"),a(".editpdlplus_tool").removeClass("btn-primary");var c=a("#editpdlplus_axes option:selected").val(),i={axisid:c};d.loadFragment("assignfeedback_editpdfplus","tooladd",f,i).done(function(c,d){j(a("#editpdlplus_tool_item"),c,d).done(function(){"clone"===h&&(a("#typetool").val(g.typetool),a("#color").val(g.color),a("#libelle").val(g.libelle),a("#catridgecolor").val(g.catridgecolor),a("#texts").val(g.texts),a("#button").val(g.button),a("#enabled").val(g.enabled),a("#reply").val(g.reply),a("#order").val(g.order),g=null,h=null),a("#toolFormSubmit").on("click",function(){var c=a("#assignfeedback_editpdfplus_edit_tool"),d=c.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_add_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").html("Ajout enregistré"),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#editpdlplus_toolbar_"+b[0].axeid).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",k),a("#editpdlplus_tool_item").html("")}else a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(b.exception)})}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)},i});
\ No newline at end of file
......@@ -248,6 +248,65 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
currentTool.order = $("#order").val();
$("#assignfeedback_editpdfplus_widget_admin_button_addtool").click();
});
$("#toolRemove").on("click", function () {
if (!$(this).hasClass("disabled")) {
var form = $('#assignfeedback_editpdfplus_edit_tool');
var data = form.serialize();
ajax.call([
{
methodname: 'assignfeedback_editpdfplus_submit_tool_del_form',
args: {jsonformdata: JSON.stringify(data)}
}
])[0].done(function (toolbar) {
if (toolbar[0].message === "") {
//mise à jour du message
$("#message_edit_tool").html("Outil supprimé");
$("#message_edit_tool").addClass("alert-success");
$("#message_edit_tool").removeClass("alert-danger");
//mise à jour bar d'outils
$("#editpdlplus_toolbar_" + toolbar[0].axeid).html("");
for (var i = 0; i < toolbar.length; i++) {
var classButton = "btn-default";
if (toolbar[i].enable !== 1) {
classButton = "";
}
if (toolbar[i].toolid === toolbar[i].selecttool) {
classButton = "btn-primary";
}
var style = "";
if (toolbar[i].typetool === 4 || toolbar[i].typetool === 1) {
style = "text-decoration: underline;";
}
var label = toolbar[i].button;
if (toolbar[i].typetool === 4 || toolbar[i].typetool === 5) {
label = "| " + label;
if (toolbar[i].typetool === 4) {
label += " |";
}
}
var buttonTmp = "<button class='btn "
+ classButton
+ " editpdlplus_tool' id='editpdlplus_tool_"
+ toolbar[i].toolid + "' style='"
+ style
+ "' value='"
+ toolbar[i].toolid
+ "' data-enable='"
+ toolbar[i].enable + "'>"
+ label
+ "</button>";
$("#editpdlplus_toolbar_" + toolbar[0].axeid).append(buttonTmp);
}
$(".editpdlplus_tool").on("click", refreshToolView);
$('#toolworkspace').html("");
} else {
$("#message_edit_tool").html(toolbar[0].message);
$("#message_edit_tool").addClass("alert-danger");
$("#message_edit_tool").removeClass("alert-success");
}
}).fail(notification.exception);
}
});
}.bind(this)).fail(notification.exception);
//templates.appendNodeContents('#editpdlplus_tool_item', html, js).done(function () {
//alert("jdikdi");
......@@ -267,7 +326,6 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
fillResultAjax($('#editpdlplus_tool_item'), html, js)
.done(function () {
if (action === "clone") {
alert(currentTool);
$("#typetool").val(currentTool.typetool);
$("#color").val(currentTool.color);
$("#libelle").val(currentTool.libelle);
......
......@@ -176,10 +176,15 @@ class admin_editor {
return $DB->delete_records('assignfeedback_editpp_axis', array('id' => $axeid));
}
public static function get_tools_by_axis($tool) {
public static function del_tool($tool) {
global $DB;
return $DB->delete_records('assignfeedback_editpp_tool', array('id' => $tool->toolid));
}
public static function get_tools_by_axis($axisid) {
global $DB;
$tools = array();
$records = $DB->get_records('assignfeedback_editpp_tool', array('axis' => $tool->axis));
$records = $DB->get_records('assignfeedback_editpp_tool', array('axis' => $axisid));
foreach ($records as $record) {
if ($record->id == $tool->id) {
array_push($tools, $tool);
......
......@@ -31,7 +31,7 @@ $functions = array(
'type' => 'write',
'ajax' => true,
'requiredcapability' => 'mod/assignfeedback_editpdfplus:use',
'enabled'=>1,
'enabled' => 1,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
),
'assignfeedback_editpdfplus_submit_axis_edit_form' => array(
......@@ -42,7 +42,7 @@ $functions = array(
'type' => 'write',
'ajax' => true,
'requiredcapability' => 'mod/assignfeedback_editpdfplus:use',
'enabled'=>1,
'enabled' => 1,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
),
'assignfeedback_editpdfplus_submit_axis_del_form' => array(
......@@ -53,7 +53,7 @@ $functions = array(
'type' => 'write',
'ajax' => true,
'requiredcapability' => 'mod/assignfeedback_editpdfplus:use',
'enabled'=>1,
'enabled' => 1,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
),
'assignfeedback_editpdfplus_submit_tool_edit_form' => array(
......@@ -64,7 +64,7 @@ $functions = array(
'type' => 'write',
'ajax' => true,
'requiredcapability' => 'mod/assignfeedback_editpdfplus:use',
'enabled'=>1,
'enabled' => 1,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
),
'assignfeedback_editpdfplus_submit_tool_add_form' => array(
......@@ -75,7 +75,18 @@ $functions = array(
'type' => 'write',
'ajax' => true,
'requiredcapability' => 'mod/assignfeedback_editpdfplus:use',
'enabled'=>1,
'enabled' => 1,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
),
'assignfeedback_editpdfplus_submit_tool_del_form' => array(
'classname' => 'assignfeedback_editpdfplus_external',
'methodname' => 'submit_tool_del_form',
'classpath' => 'mod/assign/feedback/editpdfplus/externallib.php',
'description' => 'Remove a tool',
'type' => 'write',
'ajax' => true,
'requiredcapability' => 'mod/assignfeedback_editpdfplus:use',
'enabled' => 1,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
),
);
......@@ -223,7 +223,7 @@ class assignfeedback_editpdfplus_external extends external_api {
if ($sessionkey == $customdata->sesskey && $customdata->toolid) {
$tool = admin_editor::edit_tool($customdata);
if ($tool) {
$tools = admin_editor::get_tools_by_axis($tool);
$tools = admin_editor::get_tools_by_axis($tool->axis);
$res = array();
foreach ($tools as $toolTmp) {
$res[] = array('axeid' => $tool->axis, 'selecttool' => $tool->id, 'enable' => $toolTmp->enabled, 'toolid' => $toolTmp->id, 'typetool' => $toolTmp->type, 'button' => $toolTmp->label, 'message' => '');
......@@ -309,7 +309,7 @@ class assignfeedback_editpdfplus_external extends external_api {
if ($sessionkey == $customdata->sesskey) {
$tool = admin_editor::add_tool($customdata, $context->id);
if ($tool) {
$tools = admin_editor::get_tools_by_axis($tool);
$tools = admin_editor::get_tools_by_axis($tool->axis);
$res = array();
foreach ($tools as $toolTmp) {
$res[] = array('axeid' => $tool->axis, 'selecttool' => $tool->id, 'enable' => $toolTmp->enabled, 'toolid' => $toolTmp->id, 'typetool' => $toolTmp->type, 'button' => $toolTmp->label, 'message' => '');
......@@ -353,4 +353,78 @@ class assignfeedback_editpdfplus_external extends external_api {
);
}
/**
* Returns description of method parameters
* @return external_function_parameters
*/
public static function submit_tool_del_form_parameters() {
return new external_function_parameters(
array(
'jsonformdata' => new external_value(PARAM_RAW, 'The data from the grading form, encoded as a json array')
)
);
}
public static function submit_tool_del_form($jsonformdata) {
global $USER, $PAGE, $DB;
$params = self::validate_parameters(self::submit_axis_form_parameters(), array(
'jsonformdata' => $jsonformdata
));
$serialiseddata = json_decode($params['jsonformdata']);
$data = array();
parse_str($serialiseddata, $data);
$warnings = array();
if (WS_SERVER) {
// Assume form submission if coming from WS.
$USER->ignoresesskey = true;
//$data['_qf__mod_assign_grade_form_' . $params['userid']] = 1;
}
$course = $DB->get_record('course', array('id' => $data['courseid']), '*', MUST_EXIST);
$context = context_course::instance($course->id, MUST_EXIST);
$PAGE->set_context($context);
$customdata = (object) $data;
$sessionkey = sesskey();
if ($sessionkey == $customdata->sesskey) {
$axisid = $customdata->axisid;
if (admin_editor::del_tool($customdata, $context->id)) {
$res = array();
$tools = admin_editor::get_tools_by_axis($axisid);
foreach ($tools as $toolTmp) {
$res[] = array('axeid' => $axisid, 'selecttool' => $tool->id, 'enable' => $toolTmp->enabled, 'toolid' => $toolTmp->id, 'typetool' => $toolTmp->type, 'button' => $toolTmp->label, 'message' => '');
}
return $res;
} else {
$warnings[] = array('message' => 'erreur à l enregistrement');
}
} else {
$warnings[] = array('message' => 'erreur à l enregistrement');
}
return $warnings;
}
public static function submit_tool_del_form_returns() {
return new external_multiple_structure(
new external_single_structure(
array(
'axeid' => new external_value(PARAM_INT, 'axe id'),
'selecttool' => new external_value(PARAM_INT, 'tool id'),
'enable' => new external_value(PARAM_INT, 'tool enable'),
'toolid' => new external_value(PARAM_INT, 'tool id'),
'typetool' => new external_value(PARAM_INT, 'tool type'),
'button' => new external_value(PARAM_TEXT, 'tool label'),
'message' => new external_value(PARAM_TEXT, 'message', VALUE_OPTIONAL)
)
)
);
}
}
......@@ -137,11 +137,17 @@ class assign_feedback_editpdfplus_admin {
$data->formid = "assignfeedback_editpdfplus_edit_tool";
if ($toolid != null) {
$data->tool = $DB->get_record('assignfeedback_editpp_tool', array('id' => $toolid), '*', MUST_EXIST);
$data->tool->removable = true;
$nbEnregistrements = $DB->get_record_sql('SELECT count(*) as val FROM {assignfeedback_editpp_annot} WHERE toolid = ?', array('toolid' => $toolid));
if ($nbEnregistrements->val > 0) {
$data->tool->removable = false;
}
} else {
$tool = new \assignfeedback_editpdfplus\tool();
$tool->contextid = $this->context->id;
$tool->enabled = true;
$tool->axis = $axisid;
$tool->removable = true;
$data->tool = $tool;
}
$data->tools = page_editor::get_typetools(null);
......
......@@ -58,7 +58,9 @@
{{# toolbars }}
<div id="editpdlplus_toolbar_{{axis.id}}" class="btn-group toolbar" style="display: none;">
{{# tools }}
<button class="btn {{button}} editpdlplus_tool" id="editpdlplus_tool_{{id}}" value="{{id}}" style="{{style}}" data-enable="{{enabled}}">{{label}}</button>
<button class="btn {{button}} editpdlplus_tool" id="editpdlplus_tool_{{id}}" value="{{id}}" style="{{style}}" data-enable="{{enabled}}">
{{label}}
</button>
{{/ tools }}
</div>
{{/ toolbars }}
......
......@@ -6,131 +6,133 @@
</div>
<div class='row' style="margin-bottom: 10px;">
{{^tool.id}}<h4>Ajout d'un nouvel outil</h4>{{/tool.id}}
<div class='col-sm-1'>
<div id="editpdlplus_tool_label">{{#tool.id}}{{tool.label}}{{/tool.id}}</div>
<div id="toolworkspace">
<div class='row' style="margin-bottom: 10px;">
{{^tool.id}}<h4>Ajout d'un nouvel outil</h4>{{/tool.id}}
<div class='col-sm-1'>
<div id="editpdlplus_tool_label">{{#tool.id}}{{tool.label}}{{/tool.id}}</div>
</div>
<div class='col-sm-offset-2 col-sm-5'>
Action{{#tool.id}}s{{/tool.id}} :
<button type="button" class="btn btn-default" id="toolFormSubmit"><i class="fa fa-{{#tool.id}}pencil{{/tool.id}}{{^tool.id}}save{{/tool.id}}" aria-hidden="true"></i></button>
{{#tool.id}}
<button type="button" class="btn btn-default" id="toolClone"><i class="fa fa-clone" aria-hidden="true"></i></button>
<button type="button" class="btn btn-default" id="toolEnabled"><i class="fa fa-eye{{^tool.enabled}}-slash{{/tool.enabled}}" aria-hidden="true"></i></button>
<button type="button" class="btn btn-default {{^tool.removable}}disabled{{/tool.removable}}" id="toolRemove"><i class="fa fa-remove" aria-hidden="true"></i></button>
{{/tool.id}}
</div>
</div>
<div class='col-sm-offset-2 col-sm-5'>
Action{{#tool.id}}s{{/tool.id}} :
<button type="button" class="btn btn-default" id="toolFormSubmit"><i class="fa fa-{{#tool.id}}pencil{{/tool.id}}{{^tool.id}}save{{/tool.id}}" aria-hidden="true"></i></button>
{{#tool.id}}
<button type="button" class="btn btn-default" id="toolClone"><i class="fa fa-clone" aria-hidden="true"></i></button>
<button type="button" class="btn btn-default" id="toolEnabled"><i class="fa fa-eye{{^tool.enabled}}-slash{{/tool.enabled}}" aria-hidden="true"></i></button>
<button type="button" class="btn btn-default"><i class="fa fa-remove" aria-hidden="true"></i></button>
{{/tool.id}}
</div>
</div>
<div class='row'>
<div class='col-sm-6'>
<form id="{{formid}}" method="post" action="{{actionurl}}" class="form-horizontal">
<div class='row'>
<div class='col-sm-6'>
<form id="{{formid}}" method="post" action="{{actionurl}}" class="form-horizontal">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-wrench" aria-hidden="true"></i>&nbsp;&nbsp;<a data-toggle="collapse" href="#collapse1">Type d'outil</a>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body" style="margin-bottom: 20px;">
<div class="form-group">
<label class="control-label col-sm-3" for="typetool">Type</label>
<div class="col-sm-9">
<select class="form-control" id="typetool" name="typetool">
{{# tools }}
<option value='{{id}}'>{{label}}</option>
{{/ tools }}
</select>
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-wrench" aria-hidden="true"></i>&nbsp;&nbsp;<a data-toggle="collapse" href="#collapse1">Type d'outil</a>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body" style="margin-bottom: 20px;">
<div class="form-group">
<label class="control-label col-sm-3" for="typetool">Type</label>
<div class="col-sm-9">
<select class="form-control" id="typetool" name="typetool">
{{# tools }}
<option value='{{id}}'>{{label}}</option>
{{/ tools }}
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bars" aria-hidden="true"></i>&nbsp;&nbsp;<a data-toggle="collapse" href="#collapse2">Affichage barre d'outil</a>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body" style="margin-bottom: 50px;">
<div class="form-group">
<label class="control-label col-sm-3" for="button">Bouton</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="button" value="{{tool.label}}" name="button" />
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bars" aria-hidden="true"></i>&nbsp;&nbsp;<a data-toggle="collapse" href="#collapse2">Affichage barre d'outil</a>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body" style="margin-bottom: 50px;">
<div class="form-group">
<label class="control-label col-sm-3" for="button">Bouton</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="button" value="{{tool.label}}" name="button" />
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="order">Ordre</label>
<div class="col-sm-9">
<input type="number" class="form-control" id="order" value="{{tool.order_tool}}" name="order" />
<div class="form-group">
<label class="control-label col-sm-3" for="order">Ordre</label>
<div class="col-sm-9">
<input type="number" class="form-control" id="order" value="{{tool.order_tool}}" name="order" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-address-card-o" aria-hidden="true"></i>&nbsp;&nbsp;<a data-toggle="collapse" href="#collapse3">Cartouche</a>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div class="panel-body" style="margin-bottom: 50px;">
<div class="form-group">
<label class="control-label col-sm-3" for="libelle">Libellé</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="libelle" value="{{tool.cartridge}}" name="libelle" />
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-address-card-o" aria-hidden="true"></i>&nbsp;&nbsp;<a data-toggle="collapse" href="#collapse3">Cartouche</a>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div class="panel-body" style="margin-bottom: 50px;">
<div class="form-group">
<label class="control-label col-sm-3" for="libelle">Libellé</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="libelle" value="{{tool.cartridge}}" name="libelle" />
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="cartridgecolor">Couleur</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="cartridgecolor" placeholder="{{^tool.cartridge_color}}-{{/tool.cartridge_color}}"
value="{{#tool.cartridge_color}}{{tool.cartridge_color}}{{/tool.cartridge_color}}" name="catridgecolor" />
<div class="form-group">
<label class="control-label col-sm-3" for="cartridgecolor">Couleur</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="cartridgecolor" placeholder="{{^tool.cartridge_color}}-{{/tool.cartridge_color}}"
value="{{#tool.cartridge_color}}{{tool.cartridge_color}}{{/tool.cartridge_color}}" name="catridgecolor" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-pencil-square-o" aria-hidden="true"></i>&nbsp;&nbsp;<a data-toggle="collapse" href="#collapse4">Annotation</a>
</div>
<div id="collapse4" class="panel-collapse collapse">
<div class="panel-body" style="margin-bottom: 80px;">
<div class="form-group">
<label class="control-label col-sm-3" for="color">Couleur</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="color" placeholder="{{^tool.colors}}-{{/tool.colors}}"
value="{{#tool.colors}}{{tool.colors}}{{/tool.colors}}" name="color" />
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-pencil-square-o" aria-hidden="true"></i>&nbsp;&nbsp;<a data-toggle="collapse" href="#collapse4">Annotation</a>
</div>
<div id="collapse4" class="panel-collapse collapse">
<div class="panel-body" style="margin-bottom: 80px;">
<div class="form-group">
<label class="control-label col-sm-3" for="color">Couleur</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="color" placeholder="{{^tool.colors}}-{{/tool.colors}}"
value="{{#tool.colors}}{{tool.colors}}{{/tool.colors}}" name="color" />
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="texts">Texte prédéfinis</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="texts" value="{{tool.texts}}" name="texts" />
<div class="form-group">
<label class="control-label col-sm-3" for="texts">Texte prédéfinis</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="texts" value="{{tool.texts}}" name="texts" />
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="reply">Question/réponse</label>
<div class="col-sm-9">
<input type="checkbox" class="form-control" id="reply" {{#tool.reply}}checked {{/tool.reply}}name="reply" />
<div class="form-group">
<label class="control-label col-sm-3" for="reply">Question/réponse</label>
<div class="col-sm-9">
<input type="checkbox" class="form-control" id="reply" {{#tool.reply}}checked {{/tool.reply}}name="reply" />
</div>
</div>
</div>
</div>
</div>
</div>
<div style='display:none;'>
<input type="hidden" name="toolid" value="{{tool.id}}" />
<input type="hidden" name="axisid" value="{{tool.axis}}" />
<input type="hidden" name="courseid" value="{{courseid}}" />
<input type="hidden" name="sesskey" value="{{sesskey}}" />
<input type="hidden" name="enabled" id="toolenabled" value="{{tool.enabled}}" />
</div>
<div style='display:none;'>
<input type="hidden" name="toolid" value="{{tool.id}}" />
<input type="hidden" name="axisid" value="{{tool.axis}}" />
<input type="hidden" name="courseid" value="{{courseid}}" />
<input type="hidden" name="sesskey" value="{{sesskey}}" />
<input type="hidden" name="enabled" id="toolenabled" value="{{tool.enabled}}" />
</div>
</form>
</div>
<div class='col-sm-6'>
</form>