Gitlab CSE Unil

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

correction bug ajout annotation

parent fa0b9365
define(["jquery","mod_audioannotation/annotation","core/notification","core/templates","core/fragment","core/ajax","core/str"],function(a,b,c,d,e,f,g){function h(c){this.controler="controler"in c?c.controler:null,this.contextid="contextid"in c?c.contextid:null,this.courseid="courseid"in c?c.courseid:null,this.assignpartid="assignpartid"in c?c.assignpartid:null,this.audioannotation="audioannotation"in c?c.audioannotation:null;var d="annotations"in c?c.annotations:[],e="tags"in c?c.tags:[];this.tags=[];for(var f=0;f<e.length;f++)f in this.TAGSCOLOR?e[f].color=this.TAGSCOLOR[f]:e[f].color=this.TAGDEFAULTCOLOR,this.tags[e[f].id]=e[f],a("button[data-tag='"+e[f].id+"']").css("color",e[f].color);var g=new Object;g.editor=this;for(var j=0;j<d.length;j++){var k=new b(g);k.init(d[j]),h.annotations[h.annotations.length]=k}i()}h.annotations=[],h.controler=null,h.contextid=null,h.courseid=null,h.assignpartid=null,h.audioannotation=null,h.tags=null,h.isaddopen=!1,h.iseditopen=!1,h.isviewopen=!1,h.currentAnnotation=null,h.filtretag=null,h.filtrequestion=null,h.filtrestatut=null,h.prototype.TAGSCOLOR={0:"#004586",1:"#ff420e",2:"#ffd320",3:"#579d1c",4:"#7e0021",5:"#83caf",6:"#314004",7:"#aecf00",8:"#4b1f6f",9:"#ff950e",10:"#c5000b",11:"#0084d1"},h.prototype.TAGDEFAULTCOLOR="blue",h.messageErrorSave="error",h.messageErrorDelete="error";var i=function(){g.get_string("ajaxsave_messageko","audioannotation").done(function(a){h.messageErrorSave=a}).fail(c.exception),g.get_string("ajaxdel_messageko","audioannotation").done(function(a){h.messageErrorDelete=a}).fail(c.exception)};h.prototype.initAnnotationsDisplay=function(){for(var a=0;a<h.annotations.length;a++)this.controler.notify("drawannotation","editor",h.annotations[a]),h.annotations[a].initListener()},h.prototype.setEditorStatus=function(a){switch(a){case"add":h.isaddopen=!0,h.iseditopen&&k(this.currentAnnotation);break;case"edit":h.iseditopen=!0,h.isaddopen&&j();break;case"view":h.isviewopen=!0;break;case"delete":h.iseditopen&&k(this.currentAnnotation),h.isaddopen&&j()}};var j=function(b){a("#annotation_add").hide(),a("#annotation_add").html(""),b?b.delDisplay():a("div").find("[data-annotation='draft']").remove(),h.isaddopen=!1},k=function(b){a("#annotation_edit").hide(),a("#annotation_edit").html(""),b&&b.refreshDiv(),h.iseditopen=!1},l=function(b){a("#annotation_view").hide(),a("#annotation_view").html(""),a("#annotation_view").css("border","none"),b&&b.refreshDiv(),h.isviewopen=!1};h.prototype.viewAnnotation=function(b){(this.currentAnnotation||this.isviewopen)&&l(this.currentAnnotation),this.currentAnnotation=b;var g=this.getTagColor(b.tag),h=this.controler,i=b.serialize(this.courseid,"view",this.audioannotation);e.loadFragment("mod_audioannotation","annotation",this.contextid,i).done(function(e,i){a("#annotation_view").show(),d.replaceNodeContents("#annotation_view",e,i),b.refreshDiv(!0),a("#annotation_view").css("border","solid 4px "+g),a("input[name=statutradio][value='"+b.statut+"']").attr("checked",!0),h.notify("viewannotation","editor",null),a("#annot_form_btn_cancel").on("click",function(){l(b)}),a("#annot_form_btn_valid").on("click",function(){var d=a("#mod_audioanntation_annotation"),e=d.serialize();f.call([{methodname:"mod_audioannotation_submit_annotation_reply_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(c){"error"!==c.message&&(b.statut=a("input[name=statutradio]:checked").val(),l(b))}).fail(c.exception)})}.bind(this)).fail(c.exception)},h.prototype.addAnnotation=function(g){h.isaddopen&&j();var i=this.controler,k=new Object;k.editor=this;var l=new b(k),m=new Object;m.timeposition=g.currentTime,m.assignementpart=this.assignpartid,l.init(m),this.controler.notify("drawannotation_draft","editor",l),a("#annotation_add").html("");var n=l.serialize(this.courseid,"add",this.audioannotation);e.loadFragment("mod_audioannotation","annotation",this.contextid,n).done(function(b,e){a("#annotation_add").show(),d.replaceNodeContents("#annotation_add",b,e),i.notify("addannotation","editor",null),p(),o(),a("#annot_form_btn_cancel").on("click",function(){j()}),a("#annot_form_btn_valid").on("click",function(){var b=a("#mod_audioanntation_annotation"),d=b.serialize();f.call([{methodname:"mod_audioannotation_submit_annotation_add_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){"error"!==b.message&&(l.divDisplay.attr("data-annotation",b.annotationid),l.id=b.annotationid,l.tag=a("#id_tag").val(),l.initListener(),h.annotations[h.annotations.length]=l,j(l))}).fail(c.exception)})}.bind(this)).fail(c.exception)},h.prototype.editAnnotation=function(b){(this.currentAnnotation||this.iseditopen)&&k(this.currentAnnotation),this.currentAnnotation=b;var g=this.controler,i=b.serialize(this.courseid,"edit",this.audioannotation);e.loadFragment("mod_audioannotation","annotation",this.contextid,i).done(function(e,i){a("#annotation_edit").show(),d.replaceNodeContents("#annotation_edit",e,i),g.notify("editannotation","editor",null),b.refreshDiv(!0),p(),n(),o(),a("#annot_form_btn_cancel").on("click",function(){k(b)}),a("#annot_form_btn_valid").on("click",function(){var d=a("#mod_audioanntation_annotation"),e=d.serialize();f.call([{methodname:"mod_audioannotation_submit_annotation_edit_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(c){return"error"===c.message?(a("#annotationError").text(h.messageErrorSave),void a("#annotationError").addClass("alert-danger")):(b.tag=a("#id_tag").val(),b.refreshDiv(),void k(b))}).fail(c.exception)}),a("#annot_form_btn_delete").on("click",m),a("#message_pj_btn_delete").on("click",function(){var b=a("#mod_audioanntation_annotation"),d=b.serialize();f.call([{methodname:"mod_audioannotation_submit_message_pj_del_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){return"error"===b.message?(a("#annotationError").text(h.messageErrorDelete),void a("#annotationError").addClass("alert-danger")):(a("#fileuploadA").hide(),void a("#fileuploadA").html(""))}).fail(c.exception)})}.bind(this)).fail(c.exception)},h.prototype.deleteAnnotation=function(b){var f=this.getAnnotation(b);if(null!==f){a("#annotation_delete").html(""),(this.currentAnnotation||this.iseditopen)&&k(this.currentAnnotation);var g=this.controler,h=f.serialize(this.courseid,"edit",this.audioannotation);e.loadFragment("mod_audioannotation","annotation",this.contextid,h).done(function(a,b){d.replaceNodeContents("#annotation_delete",a,b),g.notify("deleteannotation","editor",null),m(f)}.bind(this)).fail(c.exception)}};var m=function(b){var d=a("#mod_audioanntation_annotation"),e=d.serialize();f.call([{methodname:"mod_audioannotation_submit_annotation_del_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(c){if("error"===c.message)return a("#annotationError").text(h.messageErrorDelete),void a("#annotationError").addClass("alert-danger");b.delDisplay();var d=h.annotations.indexOf(b);h.annotations.splice(d,1),k(),a("#annotation_delete").html("")}).fail(c.exception)};h.prototype.getAnnotation=function(a){for(var b=0;b<h.annotations.length;b++)if(h.annotations[b].id==a)return h.annotations[b];return null},h.prototype.notify=function(a,b){if("edit"===a)this.editAnnotation(b);else if("add"===a)this.addAnnotation(b);else if("view"===a){var c=b;!b.hasOwnProperty("id")&&b.hasOwnProperty("annotation")&&(c=this.getAnnotation(b.annotation)),c&&this.viewAnnotation(c)}else"displaytqs"===a?this.displayAnnotationByTagQuestionStatut(b):"delete"===a&&this.deleteAnnotation(b)},h.prototype.displayAnnotationByTagQuestionStatut=function(a){var b=a.tag,c=a.question,d=a.statut;if(b==-2&&c==-1&&d==-1)for(var e=0;e<h.annotations.length;e++)h.annotations[e].show();else for(var f=0;f<h.annotations.length;f++){var g=h.annotations[f].isquestion,i=h.annotations[f].statut,j=h.annotations[f].tag;b==-2&&c==-1&&i==d||b==-2&&g==c&&d==-1||j==b&&c==-1&&d==-1||b==-2&&g==c&&i==d||j==b&&c==-1&&i==d||j==b&&g==c&&d==-1||j==b&&g==c&&i==d?h.annotations[f].show():h.annotations[f].hide()}l(this.currentAnnotation)};var n=function(){var b=parseInt(a("[name='isquestion']").val());0===b?a("#annot_form_btn_question .fa-ban").show():a("#annot_form_btn_question .fa-ban").hide()},o=function(){a("#annot_form_btn_question").on("click",function(){var b=parseInt(a("[name='isquestion']").val());0===b?(a("[name='isquestion']").val(1),a("#annot_form_btn_question .fa-ban").hide()):(a("[name='isquestion']").val(0),a("#annot_form_btn_question .fa-ban").show())})},p=function(){a("#fileinput").append(a('[data-fieldtype="filepicker"]')),a('[data-fieldtype="filepicker"]').removeClass("col-md-9"),a(".form-filetypes-descriptions").hide(),a("#fileinput").append(a("input[name*='_qf__mod_audioannotation']")),a("#fileinput").find("p").remove(),a("#fileinput").find(".femptylabel").css("margin-bottom","0"),a("#mform1").remove()};return h.prototype.getTagColor=function(a){return a>-1?this.tags[a].color:this.TAGDEFAULTCOLOR},h.prototype.getEval=function(){return this.controler.getEval()},h});
\ No newline at end of file
define(["jquery","mod_audioannotation/annotation","core/notification","core/templates","core/fragment","core/ajax","core/str"],function(a,b,c,d,e,f,g){function h(c){this.controler="controler"in c?c.controler:null,this.contextid="contextid"in c?c.contextid:null,this.courseid="courseid"in c?c.courseid:null,this.assignpartid="assignpartid"in c?c.assignpartid:null,this.audioannotation="audioannotation"in c?c.audioannotation:null;var d="annotations"in c?c.annotations:[],e="tags"in c?c.tags:[];this.tags=[];for(var f=0;f<e.length;f++)f in this.TAGSCOLOR?e[f].color=this.TAGSCOLOR[f]:e[f].color=this.TAGDEFAULTCOLOR,this.tags[e[f].id]=e[f],a("button[data-tag='"+e[f].id+"']").css("color",e[f].color);var g=new Object;g.editor=this;for(var j=0;j<d.length;j++){var k=new b(g);k.init(d[j]),h.annotations[h.annotations.length]=k}i()}h.annotations=[],h.controler=null,h.contextid=null,h.courseid=null,h.assignpartid=null,h.audioannotation=null,h.tags=null,h.isaddopen=!1,h.iseditopen=!1,h.isviewopen=!1,h.currentAnnotation=null,h.filtretag=null,h.filtrequestion=null,h.filtrestatut=null,h.prototype.TAGSCOLOR={0:"#004586",1:"#ff420e",2:"#ffd320",3:"#579d1c",4:"#7e0021",5:"#83caf",6:"#314004",7:"#aecf00",8:"#4b1f6f",9:"#ff950e",10:"#c5000b",11:"#0084d1"},h.prototype.TAGDEFAULTCOLOR="blue",h.messageErrorSave="error",h.messageErrorDelete="error";var i=function(){g.get_string("ajaxsave_messageko","audioannotation").done(function(a){h.messageErrorSave=a}).fail(c.exception),g.get_string("ajaxdel_messageko","audioannotation").done(function(a){h.messageErrorDelete=a}).fail(c.exception)};h.prototype.initAnnotationsDisplay=function(){for(var a=0;a<h.annotations.length;a++)this.controler.notify("drawannotation","editor",h.annotations[a]),h.annotations[a].initListener()},h.prototype.setEditorStatus=function(a){switch(a){case"add":h.isaddopen=!0,h.iseditopen&&k(this.currentAnnotation);break;case"edit":h.iseditopen=!0,h.isaddopen&&j();break;case"view":h.isviewopen=!0;break;case"delete":h.iseditopen&&k(this.currentAnnotation),h.isaddopen&&j()}};var j=function(b){a("#annotation_add").hide(),a("#annotation_add").html(""),b&&b.id?b.refreshDiv():a("div").find("[data-annotation='draft']").remove(),h.isaddopen=!1},k=function(b){a("#annotation_edit").hide(),a("#annotation_edit").html(""),b&&b.refreshDiv(),h.iseditopen=!1},l=function(b){a("#annotation_view").hide(),a("#annotation_view").html(""),a("#annotation_view").css("border","none"),b&&b.refreshDiv(),h.isviewopen=!1};h.prototype.viewAnnotation=function(b){(this.currentAnnotation||this.isviewopen)&&l(this.currentAnnotation),this.currentAnnotation=b;var g=this.getTagColor(b.tag),h=this.controler,i=b.serialize(this.courseid,"view",this.audioannotation);e.loadFragment("mod_audioannotation","annotation",this.contextid,i).done(function(e,i){a("#annotation_view").show(),d.replaceNodeContents("#annotation_view",e,i),b.refreshDiv(!0),a("#annotation_view").css("border","solid 4px "+g),a("input[name=statutradio][value='"+b.statut+"']").attr("checked",!0),h.notify("viewannotation","editor",null),a("#annot_form_btn_cancel").on("click",function(){l(b)}),a("#annot_form_btn_valid").on("click",function(){var d=a("#mod_audioanntation_annotation"),e=d.serialize();f.call([{methodname:"mod_audioannotation_submit_annotation_reply_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(c){"error"!==c.message&&(b.statut=a("input[name=statutradio]:checked").val(),l(b))}).fail(c.exception)})}.bind(this)).fail(c.exception)},h.prototype.addAnnotation=function(g){h.isaddopen&&j();var i=this.controler,k=new Object;k.editor=this;var l=new b(k),m=new Object;m.timeposition=g.currentTime,m.assignementpart=this.assignpartid,l.init(m),this.controler.notify("drawannotation_draft","editor",l),a("#annotation_add").html("");var n=l.serialize(this.courseid,"add",this.audioannotation);e.loadFragment("mod_audioannotation","annotation",this.contextid,n).done(function(b,e){a("#annotation_add").show(),d.replaceNodeContents("#annotation_add",b,e),i.notify("addannotation","editor",null),p(),o(),a("#annot_form_btn_cancel").on("click",function(){j()}),a("#annot_form_btn_valid").on("click",function(){var b=a("#mod_audioanntation_annotation"),d=b.serialize();f.call([{methodname:"mod_audioannotation_submit_annotation_add_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){"error"!==b.message&&(l.divDisplay.attr("data-annotation",b.annotationid),l.id=b.annotationid,l.tag=a("#id_tag").val(),l.initListener(),h.annotations[h.annotations.length]=l,j(l))}).fail(c.exception)})}.bind(this)).fail(c.exception)},h.prototype.editAnnotation=function(b){(this.currentAnnotation||this.iseditopen)&&k(this.currentAnnotation),this.currentAnnotation=b;var g=this.controler,i=b.serialize(this.courseid,"edit",this.audioannotation);e.loadFragment("mod_audioannotation","annotation",this.contextid,i).done(function(e,i){a("#annotation_edit").show(),d.replaceNodeContents("#annotation_edit",e,i),g.notify("editannotation","editor",null),b.refreshDiv(!0),p(),n(),o(),a("#annot_form_btn_cancel").on("click",function(){k(b)}),a("#annot_form_btn_valid").on("click",function(){var d=a("#mod_audioanntation_annotation"),e=d.serialize();f.call([{methodname:"mod_audioannotation_submit_annotation_edit_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(c){return"error"===c.message?(a("#annotationError").text(h.messageErrorSave),void a("#annotationError").addClass("alert-danger")):(b.tag=a("#id_tag").val(),b.refreshDiv(),void k(b))}).fail(c.exception)}),a("#annot_form_btn_delete").on("click",m),a("#message_pj_btn_delete").on("click",function(){var b=a("#mod_audioanntation_annotation"),d=b.serialize();f.call([{methodname:"mod_audioannotation_submit_message_pj_del_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){return"error"===b.message?(a("#annotationError").text(h.messageErrorDelete),void a("#annotationError").addClass("alert-danger")):(a("#fileuploadA").hide(),void a("#fileuploadA").html(""))}).fail(c.exception)})}.bind(this)).fail(c.exception)},h.prototype.deleteAnnotation=function(b){var f=this.getAnnotation(b);if(null!==f){a("#annotation_delete").html(""),(this.currentAnnotation||this.iseditopen)&&k(this.currentAnnotation);var g=this.controler,h=f.serialize(this.courseid,"edit",this.audioannotation);e.loadFragment("mod_audioannotation","annotation",this.contextid,h).done(function(a,b){d.replaceNodeContents("#annotation_delete",a,b),g.notify("deleteannotation","editor",null),m(f)}.bind(this)).fail(c.exception)}};var m=function(b){var d=a("#mod_audioanntation_annotation"),e=d.serialize();f.call([{methodname:"mod_audioannotation_submit_annotation_del_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(c){if("error"===c.message)return a("#annotationError").text(h.messageErrorDelete),void a("#annotationError").addClass("alert-danger");b.delDisplay();var d=h.annotations.indexOf(b);h.annotations.splice(d,1),k(),a("#annotation_delete").html("")}).fail(c.exception)};h.prototype.getAnnotation=function(a){for(var b=0;b<h.annotations.length;b++)if(h.annotations[b].id==a)return h.annotations[b];return null},h.prototype.notify=function(a,b){if("edit"===a)this.editAnnotation(b);else if("add"===a)this.addAnnotation(b);else if("view"===a){var c=b;!b.hasOwnProperty("id")&&b.hasOwnProperty("annotation")&&(c=this.getAnnotation(b.annotation)),c&&this.viewAnnotation(c)}else"displaytqs"===a?this.displayAnnotationByTagQuestionStatut(b):"delete"===a&&this.deleteAnnotation(b)},h.prototype.displayAnnotationByTagQuestionStatut=function(a){var b=a.tag,c=a.question,d=a.statut;if(b==-2&&c==-1&&d==-1)for(var e=0;e<h.annotations.length;e++)h.annotations[e].show();else for(var f=0;f<h.annotations.length;f++){var g=h.annotations[f].isquestion,i=h.annotations[f].statut,j=h.annotations[f].tag;b==-2&&c==-1&&i==d||b==-2&&g==c&&d==-1||j==b&&c==-1&&d==-1||b==-2&&g==c&&i==d||j==b&&c==-1&&i==d||j==b&&g==c&&d==-1||j==b&&g==c&&i==d?h.annotations[f].show():h.annotations[f].hide()}l(this.currentAnnotation)};var n=function(){var b=parseInt(a("[name='isquestion']").val());0===b?a("#annot_form_btn_question .fa-ban").show():a("#annot_form_btn_question .fa-ban").hide()},o=function(){a("#annot_form_btn_question").on("click",function(){var b=parseInt(a("[name='isquestion']").val());0===b?(a("[name='isquestion']").val(1),a("#annot_form_btn_question .fa-ban").hide()):(a("[name='isquestion']").val(0),a("#annot_form_btn_question .fa-ban").show())})},p=function(){a("#fileinput").append(a('[data-fieldtype="filepicker"]')),a('[data-fieldtype="filepicker"]').removeClass("col-md-9"),a(".form-filetypes-descriptions").hide(),a("#fileinput").append(a("input[name*='_qf__mod_audioannotation']")),a("#fileinput").find("p").remove(),a("#fileinput").find(".femptylabel").css("margin-bottom","0"),a("#mform1").remove()};return h.prototype.getTagColor=function(a){return a>-1?this.tags[a].color:this.TAGDEFAULTCOLOR},h.prototype.getEval=function(){return this.controler.getEval()},h});
\ No newline at end of file
......@@ -218,9 +218,9 @@ define(['jquery', 'mod_audioannotation/annotation', 'core/notification', 'core/t
//$("#btn_add_annotation").prop("disabled", false);
$("#annotation_add").hide();
$("#annotation_add").html("");
if (annotation) {
//delete annotation display on audio graph
annotation.delDisplay();
if (annotation && annotation.id) {
//refresh annotation display on audio graph
annotation.refreshDiv();
} else {
$("div").find("[data-annotation='draft']").remove();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment