Gitlab CSE Unil

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

Merge branch 'V3' into 'master'

V3

See merge request !3
parents 30be535f d4d4daf9
define(["jquery"],function(a){function b(a){this.editor=a.editor,this.id=null,this.timeposition=null,this.isquestion=0,this.assignementpart=null,this.validation=0,this.statut=0,this.mainmessage=null,this.tag=-1}return b.id=null,b.timeposition=null,b.isquestion=0,b.assignementpart=null,b.validation=0,b.statut=0,b.mainmessage=null,b.tag=-1,b.editor=null,b.divDisplay=null,b.DEFAULTCOLOR="yellow",b.prototype.init=function(a){a.timeposition&&(this.timeposition=a.timeposition),a.id&&(this.id=a.id),a.isquestion&&(this.isquestion=a.isquestion),a.assignementpart&&(this.assignementpart=a.assignementpart),a.validation&&(this.validation=a.validation),a.statut&&(this.statut=a.statut),a.mainmessage&&(this.mainmessage=a.mainmessage),a.tag&&(this.tag=a.tag)},b.prototype.initListener=function(){if(this.divDisplay){var a=this;this.divDisplay.on("click",function(){1==a.editor.getEval()?a.editor.notify("edit",a):a.editor.notify("view",a)})}},b.prototype.serialize=function(a,b,c){return{courseid:a,action:b,audioannotation:c,timeposition:this.timeposition,id:this.id,isquestion:this.isquestion,assignementpart:this.assignementpart,validation:this.validation,statut:this.statut,mainmessage:this.mainmessage,tag:this.tag}},b.prototype.displayDiv=function(a,b,c){return this.divDisplay&&!c||this.buildDiv(a,b),this.divDisplay},b.prototype.buildDiv=function(c,d){var e=this.editor.getTagColor();d&&(e=b.DEFAULTCOLOR),this.tag>-1&&(e=this.editor.getTagColor(this.tag));var f="<div style='background-color:"+e+";";f+="margin-left:"+c+"%;' ",f+="class='audio_annotation' ",f+=d?"data-annotation='draft' ":"data-annotation='"+this.id+"' ",f+="></div>",this.divDisplay=a(f)},b.prototype.hide=function(){this.divDisplay.hide()},b.prototype.show=function(){this.divDisplay.show()},b.prototype.refreshDiv=function(a){a?this.divDisplay.css("background-color",b.DEFAULTCOLOR):this.divDisplay.css("background-color",this.editor.getTagColor(this.tag)),this.divDisplay.data("annotation",this.id)},b.prototype.delDisplay=function(){this.divDisplay&&this.divDisplay.remove()},b});
\ No newline at end of file
define(["jquery"],function(a){function b(a){this.editor=a.editor,this.id=null,this.timeposition=null,this.isquestion=0,this.assignementpart=null,this.validation=0,this.statut=0,this.mainmessage=null,this.tag=-1,this.user=-1,this.typeuser=-1}return b.id=null,b.user=null,b.timeposition=null,b.isquestion=0,b.assignementpart=null,b.validation=0,b.statut=0,b.mainmessage=null,b.tag=-1,b.typeuser=-1,b.editor=null,b.divDisplay=null,b.DEFAULTCOLOR="yellow",b.prototype.init=function(a){a.timeposition&&(this.timeposition=a.timeposition),a.id&&(this.id=a.id),a.user&&(this.user=a.user),a.isquestion&&(this.isquestion=a.isquestion),a.assignementpart&&(this.assignementpart=a.assignementpart),a.validation&&(this.validation=a.validation),a.statut&&(this.statut=a.statut),a.mainmessage&&(this.mainmessage=a.mainmessage),a.tag&&(this.tag=a.tag),a.typeuser&&(this.typeuser=a.typeuser)},b.prototype.initListener=function(){if(this.divDisplay){var a=this,b=this.editor.getCurrentUser()==this.user,c=(this.editor.isWriting()>0||this.editor.getPairing()>0)&&b;this.divDisplay.on("click",function(){c?a.editor.notify("edit",a):a.editor.notify("view",a)})}},b.prototype.serialize=function(a,b,c){return{courseid:a,action:b,audioannotation:c,timeposition:this.timeposition,id:this.id,isquestion:this.isquestion,assignementpart:this.assignementpart,validation:this.validation,statut:this.statut,mainmessage:this.mainmessage,tag:this.tag}},b.prototype.displayDiv=function(a,b,c){return this.divDisplay&&!c||this.buildDiv(a,b),this.divDisplay},b.prototype.buildDiv=function(c,d){var e=this.editor.getTagColor();d&&(e=b.DEFAULTCOLOR),this.tag>-1&&(e=this.editor.getTagColor(this.tag));var f="<div style='background-color:"+e+";";f+="margin-left:"+c+"%; ",this.editor.getCurrentUser()!=this.user&&(f+="padding-top:10px; padding-left:2px;"),f+="' ",f+="class='audio_annotation' ",f+=d?"data-annotation='draft' ":"data-annotation='"+this.id+"' ",f+=">",this.editor.getCurrentUser()!=this.user&&(f+="<div style='background-color:white;height: 145px;width: 2px;cursor: pointer;'></div>"),f+="</div>",this.divDisplay=a(f)},b.prototype.hide=function(){this.divDisplay.hide()},b.prototype.show=function(){this.divDisplay.show()},b.prototype.refreshDiv=function(a){a?this.divDisplay.css("background-color",b.DEFAULTCOLOR):this.divDisplay.css("background-color",this.editor.getTagColor(this.tag)),this.divDisplay.data("annotation",this.id)},b.prototype.delDisplay=function(){this.divDisplay&&this.divDisplay.remove()},b});
\ No newline at end of file
define(["jquery","mod_audioannotation/justWave","mod_audioannotation/editor","mod_audioannotation/rightMenu"],function(a,b,c,d){function e(a){e.courseid="course"in a?a.course:null,e.audioannotation="audioannotation"in a?a.audioannotation:null,e.eval="eval"in a?a.eval:0;var f="repo"in a?a.repo:null,g="assignparts"in a?a.assignparts:null,h=null;g&&(h=JSON.parse(g));var i="tags"in a?a.tags:null,j=null;if(i&&(j=JSON.parse(i)),e.wavePlayer=new b(this),e.editors=[],h)for(var k=0;k<h.length;k++){e.editors[h[k].id]=new c({controler:this,courseid:e.courseid,assignpart:h[k],audioannotation:e.audioannotation,tags:j,repo:f});var l=new b(this,e.editors[h[k].id]);e.editors[h[k].id].setWavePlayer(l),this.initWave(l,"justwave",h[k].id)}this.initTrigger(),e.rightMenu=new d({controler:this})}return e.courseid=-1,e.audioannotation=-1,e.wavePlayer=null,e.prototype.editors=null,e.rightMenu=null,e.lastP=null,e.eval=0,e.prototype.initTrigger=function(){1==e.eval&&a(".btn_add_annotation").on("click",function(){e.editors[a(this).data("assignpart")].notify("add")}),a(".select_tqs").on("change",function(){var b=a(this).data("assignpart");e.editors[b].notify("displaytqs",{tag:a("#select_tag"+b).val(),question:a("#select_question"+b).val(),statut:a("#select_statut"+b).val()})}),a("li[data-annotation]").on("click",function(){var b=a(this).data("annotation"),c=a(this).parents(".annotationGroupAccordion").data("assignpart");b&&e.editors[c].notify("view",{annotation:b})})},e.prototype.initWave=function(b,c,d){b.init(c),a(".justwave"+d+" .justwave_playpause").click(),a(".justwave"+d+" .justwave_playpause").click()},e.prototype.initAnnotations=function(){for(var a=0;a<e.editors.length;a++)e.editors[a]&&e.editors[a].initAnnotationsDisplay()},e.prototype.notify=function(a,b,c){switch(a){case"loadedmetadata":this.initAnnotations();break;case"addannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("add");break;case"editannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("edit");break;case"viewannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("view");break;case"deleteannotation":if("rightMenu"===b)for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].notify("delete",c);else for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("delete")}},e.prototype.getEval=function(){return e.eval},e});
\ No newline at end of file
define(["jquery","mod_audioannotation/justWave","mod_audioannotation/editor","mod_audioannotation/rightMenu"],function(a,b,c,d){function e(a){e.currentUser="userid"in a?a.userid:null,e.courseid="course"in a?a.course:null,e.audioannotation="audioannotation"in a?a.audioannotation:null,e.eval="eval"in a?a.eval:0,e.iswriting="iswriting"in a?a.iswriting:0,e.pairing="pairing"in a?a.pairing:0;var f="repo"in a?a.repo:null,g="assignparts"in a?a.assignparts:null,h=null;g&&(h=JSON.parse(g));var i="tags"in a?a.tags:null,j=null;if(i&&(j=JSON.parse(i)),e.wavePlayer=new b(this),e.editors=[],h)for(var k=0;k<h.length;k++){e.editors[h[k].id]=new c({controler:this,courseid:e.courseid,assignpart:h[k],audioannotation:e.audioannotation,tags:j,repo:f});var l=new b(this,e.editors[h[k].id]);e.editors[h[k].id].setWavePlayer(l),this.initWave(l,"justwave",h[k].id)}this.initTrigger(),e.rightMenu=new d({controler:this})}return e.courseid=-1,e.audioannotation=-1,e.wavePlayer=null,e.prototype.editors=null,e.rightMenu=null,e.lastP=null,e.eval=0,e.iswriting=0,e.pairing=0,e.currentUser=null,e.prototype.initTrigger=function(){1!=e.eval&&1!=e.iswriting||a(".btn_add_annotation").on("click",function(){e.editors[a(this).data("assignpart")].notify("add")}),a(".select_tqs").on("change",function(){var b=a(this).data("assignpart");e.editors[b].notify("displaytqs",{tag:a("#select_tag"+b).val(),question:a("#select_question"+b).val(),statut:a("#select_statut"+b).val(),author:a("#select_author"+b).val()})}),a("li[data-annotation]").on("click",function(){var b=a(this).data("annotation"),c=a(this).parents(".annotationGroupAccordion").data("assignpart");b&&e.editors[c].notify("view",{annotation:b})})},e.prototype.initWave=function(b,c,d){b.init(c),a(".justwave"+d+" .justwave_playpause").click(),a(".justwave"+d+" .justwave_playpause").click()},e.prototype.initAnnotations=function(){for(var a=0;a<e.editors.length;a++)e.editors[a]&&e.editors[a].initAnnotationsDisplay()},e.prototype.notify=function(a,b,c){switch(a){case"loadedmetadata":this.initAnnotations();break;case"addannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("add");break;case"editannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("edit");break;case"viewannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("view");break;case"deleteannotation":if("rightMenu"===b)for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].notify("delete",c);else for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("delete")}},e.prototype.getEval=function(){return e.eval},e.prototype.isWriting=function(){return e.iswriting},e.prototype.getPairing=function(){return e.pairing},e.prototype.getCurrentUser=function(){return e.currentUser},e});
\ No newline at end of file
This diff is collapsed.
define(["jquery"],function(a){function b(a){this.repo="repo"in a?a.repo:null,this.limit="limit"in a&&a.limit>0?1e3*a.limit:null,this.indice="indice"in a?a.indice:"",this.manager="manager"in a?a.manager:null,this.init(),this.initTrigger()}return b.mediaRecorder=null,b.recordedBlobs=null,b.errorMsgElement="#errorMsg",b.recordButton="#record",b.pauseRecordButton="#pauseRecord",b.playButton="#play",b.removeButton="#remove",b.recordedVideo="#recorded",b.repo=-1,b.initTimestamp=-1,b.timestampStop=0,b.limit=null,b.indice="",b.manager=null,b.prototype.init=function(){if(this.errorMsgElement="#errorMsg",this.recordButton="#record",this.pauseRecordButton="#pauseRecord",this.playButton="#play",this.removeButton="#remove",this.recordedVideo="#recorded",this.indice>=0){var b=this.indice,c=a("#audioworkspace").clone();c.find("[id]").each(function(){this.id+=b}),c.children().each(function(){a("#audio"+b).append(this)}),this.errorMsgElement+=this.indice,this.recordButton+=this.indice,this.pauseRecordButton+=this.indice,this.playButton+=this.indice,this.removeButton+=this.indice,this.recordedVideo+=this.indice}else a("#audio").html(a("#audioworkspace").html()),a("#audioworkspace").remove();var d=a("input[name='audio"+this.indice+"']").val();d&&(a(this.recordedVideo).attr("src",d),a(this.playButton).attr("disabled",!1),a(this.removeButton).attr("disabled",!1),a("input[name='file"+b+"']").parent().parent().addClass("disabled")),a(this.recordButton).data("statut","stop")},b.prototype.reset=function(){a(this.recordButton).attr("disabled",!1),a(this.recordedVideo).attr("src")&&(a(this.playButton).attr("disabled",!1),a(this.removeButton).attr("disabled",!1)),this.initTrigger()},b.prototype.initTrigger=function(){var c=this.pauseRecordButton,d=this.recordedVideo,e=this.playButton,f=this.removeButton,g=this.manager,h=this.indice,i=this.errorMsgElement;a(this.recordButton).on("click",function(){if("stop"===a(this).data("statut")){var b=g.startRecording(h);b?(a(d).attr("src",null),a(this).data("statut","start"),a(c).attr("disabled",!1),a(c).data("statut","off"),a(c).find(".fa-ban").hide(),a(e).attr("disabled",!0),a(f).attr("disabled",!0),a(this).find("i").removeClass("fa-microphone"),a(this).find("i").addClass("fa-microphone-slash"),a(this).removeClass("btn-primary"),a(this).addClass("btn-danger")):a(i).text("Un enregistrement est déjà en cours :un seul enregistrement à la fois est possible!")}else g.stopRecording(h),a(this).data("statut","stop"),a(this).find("i").addClass("fa-microphone"),a(this).find("i").removeClass("fa-microphone-slash"),a(this).addClass("btn-primary"),a(this).removeClass("btn-danger"),a(e).attr("disabled",!1),a(f).attr("disabled",!1),a(c).attr("disabled",!0)}),a(this.pauseRecordButton).on("click",function(){"off"===a(this).data("statut")?(g.pauseRecording(),a(this).data("statut","on"),a(this).find(".fa-ban").show()):(g.resumeRecording(),a(this).data("statut","off"),a(this).find(".fa-ban").hide())}),a(this.playButton).on("click",function(){if(!a(d).attr("src")){var c=new Blob(b.recordedBlobs);a(d).show(),a(d).attr("src",null),a(d).attr("srcObject",null),a(d).attr("src",window.URL.createObjectURL(c))}a(d).attr("controls",!0),a(d).attr("autoplay",!0)}),a(this.removeButton).on("click",function(){a("input[name='filerecord"+h+"']").val(-1),a("input[name='file"+h+"']").parent().parent().removeClass("disabled"),a(e).attr("disabled",!0),a(this).attr("disabled",!0),a(d).hide(),a(d).attr("src",null),a(d).attr("srcObject",null)})},b.prototype.sendBlob=function(a){b.recordedBlobs=a},b.prototype.stopRecord=function(){a(this.recordButton).click()},b});
\ No newline at end of file
define(["jquery","core/modal_factory","core/modal_events"],function(a,b,c){function d(a){this.repo="repo"in a?a.repo:null,this.limit="limit"in a&&a.limit>0?1e3*a.limit:null,this.indice="indice"in a?a.indice:"",this.manager="manager"in a?a.manager:null,this.init(),this.initTrigger()}return d.mediaRecorder=null,d.recordedBlobs=null,d.errorMsgElement="#errorMsg",d.recordButton="#record",d.pauseRecordButton="#pauseRecord",d.removeButton="#remove",d.recordedVideo="#recorded",d.sending="#sending",d.repo=-1,d.initTimestamp=-1,d.timestampStop=0,d.limit=null,d.indice="",d.manager=null,d.prototype.init=function(){if(this.errorMsgElement="#errorMsg",this.recordButton="#record",this.pauseRecordButton="#pauseRecord",this.removeButton="#remove",this.recordedVideo="#recorded",this.sending="#sending",this.indice>=0){var b=this.indice,c=a("#audioworkspace").clone();c.find("[id]").each(function(){this.id+=b}),c.children().each(function(){a("#audio"+b).append(this)}),this.errorMsgElement+=this.indice,this.recordButton+=this.indice,a(this.recordButton).prop("indice",this.indice),this.pauseRecordButton+=this.indice,this.removeButton+=this.indice,this.recordedVideo+=this.indice,this.sending+=this.indice}else a("#audio").html(a("#audioworkspace").html()),a("#audioworkspace").remove();var d=a("input[name='audio"+this.indice+"']").val();d&&(a(this.recordedVideo).attr("src",d),a("input[name='file"+b+"']").parent().parent().addClass("disabled")),a(this.recordedVideo).attr("src")&&(a(this.removeButton).attr("disabled",!1),this.displayAudio()),a(this.recordButton).data("statut","stop")},d.prototype.initDisplayRecordButton=function(){"undefined"==typeof a(this.recordedVideo).attr("src")&&a(this.recordButton).attr("disabled",!1)},d.prototype.reset=function(){a(this.recordButton).attr("disabled",!1),a(this.recordedVideo).attr("src")&&a(this.removeButton).attr("disabled",!1),this.initTrigger()},d.prototype.initTrigger=function(){var d=this.pauseRecordButton,e=this.recordedVideo,f=this.removeButton,g=this.recordButton,h=this.manager,i=this.indice,j=this.errorMsgElement,k=this;a(this.recordButton).on("click",function(){if("stop"===a(this).data("statut")){var b=h.startRecording(i);b?(a(e).attr("src",null),a(this).data("statut","start"),a(d).attr("disabled",!1),a(d).data("statut","off"),a(d).find(".fa-ban").hide(),a(f).attr("disabled",!0),a(this).find("i.fa-square").show(),a(this).find("i.fa-square").parent().parent().attr("title","Stop")):a(j).text("Un enregistrement est déjà en cours :un seul enregistrement à la fois est possible!")}else h.stopRecording(i),a(this).data("statut","stop"),a(this).find("i.fa-square").hide(),a(this).find("i.fa-square").parent().parent().attr("title","Enregistrement"),a(this).attr("disabled",!0),k.displayAudio(),a(f).attr("disabled",!1),a(d).attr("disabled",!0)}),a(this.pauseRecordButton).on("click",function(b){"off"===a(this).data("statut")?(h.pauseRecording(b),a(this).data("statut","on"),a(this).find(".fa-ban").show()):(h.resumeRecording(b),a(this).data("statut","off"),a(this).find(".fa-ban").hide())}),a(this.removeButton).on("click",function(){}),b.create({type:b.types.CONFIRM,title:"Confirmation",body:"Êtes-vous sûr de vouloir supprimer cet enregistrement ?"},a(this.removeButton)).done(function(b){b.getRoot().on(c.save,function(){a("input[name='filerecord"+i+"']").val(-1),a("input[name='file"+i+"']").parent().parent().removeClass("disabled"),a(f).attr("disabled",!0),a(e).hide(),a(e).attr("src",null),a(e).attr("srcObject",null),a(g).attr("disabled",!1)})})},d.prototype.displayAudio=function(){var b=this.recordedVideo;if(!a(b).attr("src")){var c=new Blob(d.recordedBlobs);a(b).show(),a(b).attr("src",null),a(b).attr("srcObject",null),a(b).attr("src",window.URL.createObjectURL(c))}a(b).attr("controls",!0),a(b).attr("autoplay",!1)},d.prototype.sendBlob=function(a){d.recordedBlobs=a},d.prototype.stopRecord=function(){a(this.recordButton).click()},d});
\ No newline at end of file
define(["jquery","mod_audioannotation/record"],function(a,b){function c(a){c.repo="repo"in a?a.repo:null,c.limit="limit"in a&&a.limit>0?1e3*a.limit:null,c.nbRendu="nbRendu"in a&&a.nbRendu>0?a.nbRendu:1,this.init()}c.constraints={audio:!0},c.sourceBuffer=null,c.mediaRecorder=null,c.recordedBlobs=null,c.repo=-1,c.limit=null,c.nbRendu=1,c.records=null,c.statut="off",c.prototype.mediaSource=null,c.prototype.init=function(){c.records=[];for(var f=0;f<c.nbRendu;f++){var g=[];g.manager=this,g.limit=c.limit,g.repo=c.repo,g.indice=f,c.records[f]=new b(g)}a("#audioworkspace").remove(),c.mediaSource=new MediaSource,c.mediaSource.addEventListener("sourceopen",e,!1);try{navigator.mediaDevices.getUserMedia(c.constraints).then(function(a){d(a)})}catch(h){window.console.error("navigator.getUserMedia error:",h),a(c.errorMsgElement).html("navigator.getUserMedia error:"+h.toString())}};var d=function(b){a(".btn-record").attr("disabled",!1),window.console.log("getUserMedia() got stream:",b),window.stream=b},e=function(){window.console.log("MediaSource opened"),c.sourceBuffer=c.mediaSource.addSourceBuffer("audio/ogg"),window.console.log("Source buffer: ",c.sourceBuffer)};c.prototype.startRecording=function(b){if(window.console.log(c.statut),"off"!==c.statut)return!1;c.statut="on",c.recordedBlobs=[],c.initTimestamp=-1;var d=null;try{c.mediaRecorder=new MediaRecorder(window.stream,d)}catch(e){return window.console.error("Exception while creating MediaRecorder:",e),void a(this.errorMsgElement).html("Exception while creating MediaRecorder: "+JSON.stringify(e))}return window.console.log("Created MediaRecorder",c.mediaRecorder,"with options",d),c.mediaRecorder.addEventListener("stop",function(c){a("#audiotime"+b).text(""),this.timestampStop=0,window.console.log("Recorder stopped: ",c)},!1),c.mediaRecorder.addEventListener("dataavailable",function(a){f(a,b)},!1),c.mediaRecorder.start(10),window.console.log("MediaRecorder started",c.mediaRecorder),!0};var f=function(b,d){if(b.data&&b.data.size>0){c.initTimestamp<0&&(c.initTimestamp=b.timeStamp);var e=b.timeStamp-c.initTimestamp,f=new Date(e);f.setHours(f.getHours()-1);var g=f.getHours()<10?"0"+f.getHours():f.getHours(),h=f.getMinutes()<10?"0"+f.getMinutes():f.getMinutes(),i=f.getSeconds()<10?"0"+f.getSeconds():f.getSeconds(),j=g+":"+h+":"+i;a("#audiotime"+d).text(j),c.limit&&e>c.limit&&0===c.timestampStop&&(c.timestampStop=1,c.records[d].stopRecord()),c.recordedBlobs.push(b.data)}};return c.prototype.stopRecording=function(a){c.statut="off",c.mediaRecorder.stop(),window.console.log("Recorded Blobs: ",c.recordedBlobs);var b=c.recordedBlobs;c.records[a].sendBlob(b),this.sendFile(b,a)},c.prototype.sendFile=function(b,d){var e=new Blob(b),f=new window.FormData,g=(1e3*Math.random()).toString().replace(".","");f.append("repo_upload_file",e,g),f.append("itemid",g),f.append("title",g),f.append("repo_id",c.repo),f.append("env","editor"),f.append("sesskey",M.cfg.sesskey),f.append("savepath","/"),f.append("ctx_id",M.cfg.contextid);var h=M.cfg.wwwroot+"/repository/repository_ajax.php?action=upload",i=new XMLHttpRequest;i.addEventListener("readystatechange",function(){if(4===this.readyState&&200===this.status){var b=i.response,c=JSON.parse(b);a("input[name='filerecord"+d+"']").val(c.file),a("input[name='file"+d+"']").parent().parent().addClass("disabled"),a("#sendok"+d).show().fadeOut(3e3)}else this.readyState>200&&a("#sendko"+d).show()},!1),i.open("POST",h,!0),i.send(f)},c.prototype.pauseRecording=function(){c.mediaRecorder&&(c.mediaRecorder.pause(),window.console.log("MediaRecorder paused",c.mediaRecorder))},c.prototype.resumeRecording=function(){c.mediaRecorder&&(c.mediaRecorder.resume(),window.console.log("MediaRecorder resumed",c.mediaRecorder))},c.prototype.reset=function(){for(var a=0;a<c.records.length;a++)c.records[a].reset()},c});
\ No newline at end of file
define(["jquery","mod_audioannotation/record"],function(a,b){function c(a){c.repo="repo"in a?a.repo:null,c.limit="limit"in a&&a.limit>0?1e3*a.limit:null,c.nbRendu="nbRendu"in a&&a.nbRendu>0?a.nbRendu:1,this.init()}c.constraints={audio:!0},c.sourceBuffer=null,c.mediaRecorder=null,c.recordedBlobs=null,c.repo=-1,c.limit=null,c.nbRendu=1,c.records=null,c.statut="off",c.prototype.mediaSource=null,c.pauseTimestamp=0,c.prototype.init=function(){c.records=[];for(var f=0;f<c.nbRendu;f++){var g=[];g.manager=this,g.limit=c.limit,g.repo=c.repo,g.indice=f,c.records[f]=new b(g)}a("#audioworkspace").remove(),c.mediaSource=new MediaSource,c.mediaSource.addEventListener("sourceopen",e,!1);try{navigator.mediaDevices.getUserMedia(c.constraints).then(function(a){d(a)})}catch(h){window.console.error("navigator.getUserMedia error:",h),a(c.errorMsgElement).html("navigator.getUserMedia error:"+h.toString())}};var d=function(b){a(".btn-record").each(function(){a(this).prop("indice")>=0&&c.records[a(this).prop("indice")].initDisplayRecordButton()}),window.console.log("getUserMedia() got stream:",b),window.stream=b},e=function(){window.console.log("MediaSource opened"),c.sourceBuffer=c.mediaSource.addSourceBuffer("audio/ogg"),window.console.log("Source buffer: ",c.sourceBuffer)};c.prototype.startRecording=function(b){if(window.console.log(c.statut),"off"!==c.statut)return!1;c.statut="on",c.recordedBlobs=[],c.initTimestamp=-1,c.pauseTimestamp=0;var d=null;try{c.mediaRecorder=new MediaRecorder(window.stream,d)}catch(e){return window.console.error("Exception while creating MediaRecorder:",e),void a(this.errorMsgElement).html("Exception while creating MediaRecorder: "+JSON.stringify(e))}return window.console.log("Created MediaRecorder",c.mediaRecorder,"with options",d),c.mediaRecorder.addEventListener("stop",function(c){a("#audiotime"+b).text(""),this.timestampStop=0,window.console.log("Recorder stopped: ",c)},!1),c.mediaRecorder.addEventListener("dataavailable",function(a){f(a,b)},!1),c.mediaRecorder.start(10),window.console.log("MediaRecorder started",c.mediaRecorder),!0};var f=function(b,d){if(b.data&&b.data.size>0){c.initTimestamp<0&&(c.initTimestamp=b.timeStamp);var e=b.timeStamp-c.initTimestamp-c.pauseTimestamp,f=new Date(e);f.setHours(f.getHours()-1);var g=f.getHours()<10?"0"+f.getHours():f.getHours(),h=f.getMinutes()<10?"0"+f.getMinutes():f.getMinutes(),i=f.getSeconds()<10?"0"+f.getSeconds():f.getSeconds(),j=g+":"+h+":"+i;a("#audiotime"+d).text(j),c.limit&&e>c.limit&&0===c.timestampStop&&(c.timestampStop=1,c.records[d].stopRecord()),c.recordedBlobs.push(b.data)}};return c.prototype.stopRecording=function(a){c.statut="off",c.mediaRecorder.stop(),window.console.log("Recorded Blobs: ",c.recordedBlobs);var b=c.recordedBlobs;c.records[a].sendBlob(b),this.sendFile(b,a)},c.prototype.sendFile=function(b,d){a("#sending"+d).show();var e=new Blob(b),f=new window.FormData,g=(1e3*Math.random()).toString().replace(".","");f.append("repo_upload_file",e,g),f.append("itemid",g),f.append("title",g),f.append("repo_id",c.repo),f.append("env","editor"),f.append("sesskey",M.cfg.sesskey),f.append("savepath","/"),f.append("ctx_id",M.cfg.contextid);var h=M.cfg.wwwroot+"/repository/repository_ajax.php?action=upload",i=new XMLHttpRequest;i.addEventListener("readystatechange",function(){if(a("#sending"+d).hide(),4===this.readyState&&200===this.status){var b=i.response,c=JSON.parse(b);a("input[name='filerecord"+d+"']").val(c.file),a("input[name='file"+d+"']").parent().parent().addClass("disabled"),a("#sendok"+d).show().fadeOut(3e3)}else this.readyState>200&&a("#sendko"+d).show()},!1),i.open("POST",h,!0),i.send(f)},c.prototype.pauseRecording=function(a){c.mediaRecorder&&(c.pauseBeginTimestamp=a.timeStamp,c.mediaRecorder.pause(),window.console.log("MediaRecorder paused",c.mediaRecorder))},c.prototype.resumeRecording=function(a){c.mediaRecorder&&(c.pauseTimestamp+=a.timeStamp-c.pauseBeginTimestamp,c.mediaRecorder.resume(),window.console.log("MediaRecorder resumed",c.mediaRecorder))},c.prototype.reset=function(){for(var a=0;a<c.records.length;a++)c.records[a].reset()},c});
\ No newline at end of file
define(["jquery"],function(a){function b(){this.init(),this.initTriggers()}return b.prototype.init=function(){a('input[name^="color"]').attr("type","color"),a('input[name^="color"]').removeClass("form-control")},b.prototype.initTriggers=function(){a('input[name^="color"]').on("change",function(){var b=a(this).parents("tr").data("tag");b?a('input[name="isColorEdit'+b+'"]').val(1):a('input[name="isColorEdit"]').val(1)}),a("#btnadd").on("click",function(){a('form[name="addTag"]').submit()}),a("#btnexport").on("click",function(){a('form[name="exportTags"]').submit()}),a(".btnimport").on("click",function(){var b=a(this).data("model");a('form[name="importTags"] input[name="model"]').val(b),a('form[name="importTags"]').submit()}),a(".btnsuppr").on("click",function(){var b=a(this).data("model");a('form[name="deleteModel"] input[name="model"]').val(b),a('form[name="deleteModel"]').submit()}),a(".btntagsuppr").on("click",function(){var b=a(this).data("status");b&&"active"!==b?(a(this).removeClass("disabled"),a(this).addClass("btn-danger"),a(this).removeClass("btn-info"),a(this).find("i").addClass("fa-times"),a(this).find("i").removeClass("fa-undo"),a('tr[data-tag="'+a(this).data("tag")+'"]').prop("style",""),a('tr[data-tag="'+a(this).data("tag")+'"]').find("div").each(function(){a(this).show()}),a('input[name="del'+a(this).data("tag")+'"]').val(0),a(this).data("status","active")):(a(this).addClass("disabled"),a(this).addClass("btn-info"),a(this).removeClass("btn-danger"),a(this).find("i").addClass("fa-undo"),a(this).find("i").removeClass("fa-times"),a('tr[data-tag="'+a(this).data("tag")+'"]').css("background-color","grey"),a('tr[data-tag="'+a(this).data("tag")+'"]').find("div").each(function(){a(this).hide()}),a('input[name="del'+a(this).data("tag")+'"]').val(1),a(this).data("status","deactive"))})},b});
\ No newline at end of file
......@@ -36,6 +36,7 @@ define(['jquery'],
* Annotation's proprietes
*/
Annotation.id = null;
Annotation.user = null;
Annotation.timeposition = null;
Annotation.isquestion = 0;
Annotation.assignementpart = null;
......@@ -43,6 +44,7 @@ define(['jquery'],
Annotation.statut = 0;
Annotation.mainmessage = null;
Annotation.tag = -1;
Annotation.typeuser = -1;
/**
* Editor parent which contains all annoations
......@@ -81,6 +83,8 @@ define(['jquery'],
this.statut = 0;
this.mainmessage = null;
this.tag = -1;
this.user = -1;
this.typeuser = -1;
}
/*************
......@@ -98,6 +102,9 @@ define(['jquery'],
if (opt.id) {
this.id = opt.id;
}
if (opt.user) {
this.user = opt.user;
}
if (opt.isquestion) {
this.isquestion = opt.isquestion;
}
......@@ -116,6 +123,9 @@ define(['jquery'],
if (opt.tag) {
this.tag = opt.tag;
}
if (opt.typeuser) {
this.typeuser = opt.typeuser;
}
};
/**
......@@ -126,8 +136,11 @@ define(['jquery'],
return;
}
var annotation = this;
var userIsCurrentUser = this.editor.getCurrentUser() == this.user;
var usercanedit = (this.editor.isWriting() > 0 || this.editor.getPairing() > 0)
&& userIsCurrentUser;
this.divDisplay.on('click', function () {
if (annotation.editor.getEval() == 1) {
if (usercanedit) {
annotation.editor.notify('edit', annotation);
} else {
annotation.editor.notify('view', annotation);
......@@ -178,14 +191,22 @@ define(['jquery'],
color = this.editor.getTagColor(this.tag);
}
var html = "<div style='background-color:" + color + ";";
html += "margin-left:" + annotWidth + "%;' ";
html += "margin-left:" + annotWidth + "%; ";
if (this.editor.getCurrentUser() != this.user) {
html += "padding-top:10px; padding-left:2px;";
}
html += "' ";
html += "class='audio_annotation' ";
if (!draft) {
html += "data-annotation='" + this.id + "' ";
} else {
html += "data-annotation='draft' ";
}
html += "></div>";
html += ">";
if (this.editor.getCurrentUser() != this.user) {
html += "<div style='background-color:white;height: 145px;width: 2px;cursor: pointer;'></div>";
}
html += "</div>";
this.divDisplay = $(html);
};
......
......@@ -42,6 +42,9 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
Controler.rightMenu = null;
Controler.lastP = null;
Controler.eval = 0;
Controler.iswriting = 0;
Controler.pairing = 0;
Controler.currentUser = null;
/********************************
* CONSTRUCTOR *
......@@ -55,9 +58,12 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
*/
function Controler(data) {
//get data
Controler.currentUser = 'userid' in data ? data['userid'] : null;
Controler.courseid = 'course' in data ? data['course'] : null;
Controler.audioannotation = 'audioannotation' in data ? data['audioannotation'] : null;
Controler.eval = 'eval' in data ? data['eval'] : 0;
Controler.iswriting = 'iswriting' in data ? data['iswriting'] : 0;
Controler.pairing = 'pairing' in data ? data['pairing'] : 0;
var repoid = 'repo' in data ? data['repo'] : null;
//parse elements
var assignPartsRaw = 'assignparts' in data ? data['assignparts'] : null;
......@@ -99,9 +105,8 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
* @returns {undefined}
*/
Controler.prototype.initTrigger = function () {
if (Controler.eval == 1) {
if (Controler.eval == 1 || Controler.iswriting == 1) {
$(".btn_add_annotation").on('click', function () {
//alert($(this).data('assignpart'));
Controler.editors[$(this).data('assignpart')].notify("add");
});
}
......@@ -110,7 +115,8 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
Controler.editors[assignpartid].notify("displaytqs",
{'tag': $("#select_tag" + assignpartid).val(),
'question': $("#select_question" + assignpartid).val(),
'statut': $("#select_statut" + assignpartid).val()}
'statut': $("#select_statut" + assignpartid).val(),
'author': $("#select_author" + assignpartid).val()}
);
});
$("li[data-annotation]").on('click', function () {
......@@ -154,11 +160,6 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
* @param {object} object Element to proceed
*/
Controler.prototype.notify = function (event, agent, object) {
/*if (agent === "player") {
console.log(Controler.editors);
Controler.editors[object.assignpartid].setWavePlayer(object);
//Controler.lastP = object;
}*/
switch (event) {
case "loadedmetadata" :
this.initAnnotations();
......@@ -217,11 +218,35 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
/**
* Get the evaluation statut of the workspace
* @returns {bool} is the workspace on evaludation or on readonly
* @returns {bool} is the workspace on evaluation or on readonly
*/
Controler.prototype.getEval = function () {
return Controler.eval;
};
/**
* Get the edition statut of the workspace
* @returns {bool} is not the workspace on evaluation but user can edit
*/
Controler.prototype.isWriting = function () {
return Controler.iswriting;
};
/**
* Get if the worskpace is in pairing mode
* @returns {bool}
*/
Controler.prototype.getPairing = function () {
return Controler.pairing;
};
/**
* Get the current user id
* @returns {int} moodle id
*/
Controler.prototype.getCurrentUser = function () {
return Controler.currentUser;
};
return Controler;
});
\ No newline at end of file
......@@ -138,14 +138,16 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
var compteur = 0;
for (var tagId in tagsTmp) {
var tag = tagsTmp[tagId];
if (compteur in this.TAGSCOLOR) {
tag.color = this.TAGSCOLOR[compteur];
} else {
tag.color = this.TAGDEFAULTCOLOR;
if (!tag.color) {
if (compteur in this.TAGSCOLOR) {
tag.color = this.TAGSCOLOR[compteur];
compteur++;
} else {
tag.color = this.TAGDEFAULTCOLOR;
}
}
this.tags[tagId] = tag;
$("button[data-tag='" + tagId + "']").css('color', tag.color);
compteur++;
}
//create annotations
var editorData = new Object();
......@@ -199,12 +201,18 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
Editor.prototype.setEditorStatus = function (status) {
switch (status) {
case "add":
if (this.isviewopen && this.currentAnnotation) {
closeViewForm(this.currentAnnotation);
}
this.isaddopen = true;
if (this.iseditopen) {
closeEditForm(this.currentAnnotation);
}
break;
case "edit":
if (this.isviewopen && this.currentAnnotation) {
closeViewForm(this.currentAnnotation);
}
if (this.iseditopen && this.currentAnnotation) {
this.currentAnnotation.refreshDiv();
}
......@@ -214,12 +222,20 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
}
break;
case "view":
if (this.iseditopen) {
closeEditForm();
}
if (this.isaddopen) {
closeAddForm();
}
if (this.isviewopen && this.currentAnnotation) {
this.currentAnnotation.refreshDiv();
}
this.isviewopen = true;
break;
case "delete":
if (this.isviewopen && this.currentAnnotation) {
closeViewForm(this.currentAnnotation);
}
if (this.iseditopen) {
closeEditForm(this.currentAnnotation);
}
......@@ -297,7 +313,9 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
templates.replaceNodeContents('#annotation_view' + this.assignpartid, html, js);
annotation.refreshDiv(true);
$("#annotation_view" + this.assignpartid).css('border', "solid 4px " + tagcolor);
$("input[name=statutradio][value='" + annotation.statut + "']").attr('checked', true);
if ($("input[name=statutradio]").length > 0) {
$("input[name=statutradio][value='" + annotation.statut + "']").attr('checked', true);
}
//notify controler
control.notify('viewannotation', "editor", null);
//cancel action
......@@ -317,7 +335,9 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
if (reponse["message"] === "error") {
return;
}
annotation.statut = $("input[name=statutradio]:checked").val();
if ($("input[name=statutradio]:checked").val()) {
annotation.statut = $("input[name=statutradio]:checked").val();
}
closeViewForm(annotation);
}).fail(notification.exception);
});
......@@ -340,6 +360,7 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
var opt = new Object();
opt.timeposition = this.lastP.currentTime;
opt.assignementpart = this.assignpartid;
opt.user = this.getCurrentUser();
annotation.init(opt);
this.waveplayer.drawAnnotation(this.lastP, annotation, 1);
$(".annotation_add").html("");
......@@ -476,7 +497,9 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
});
//message part
$("input[name=validationradio][value='" + annotation.validation + "']").attr('checked', true);
if ($("input[name=validationradio]").length > 0) {
$("input[name=validationradio][value='" + annotation.validation + "']").attr('checked', true);
}
$("#message_form_btn_valid").on("click", function () {
var form = $('form[name=mod_audioannotation_form_message_form]');
......@@ -492,7 +515,9 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
$("#annotationError").addClass("alert-danger");
return;
}
annotation.validation = $("input[name=validationradio]:checked").val();
if ($("input[name=validationradio]:checked").val()) {
annotation.validation = $("input[name=validationradio]:checked").val();
}
closeEditForm(annotation);
}).fail(notification.exception);
......@@ -510,7 +535,6 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
*/
Editor.prototype.deleteAnnotation = function (annotationid) {
var annotation = this.getAnnotation(annotationid);
window.console.log(annotation);
if (annotation === null) {
return;
}
......@@ -549,7 +573,6 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
return;
}
annotation.delDisplay();
window.console.log(listAnnotations);
var index = listAnnotations.indexOf(annotation);
listAnnotations.splice(index, 1);
closeEditForm();
......@@ -581,7 +604,6 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
this.lastP = object;
this.initAnnotationsDisplay();
} else if (event === "edit") {
//alert(this.assignpartid);
this.editAnnotation(object);
} else if (event === "add") {
this.addAnnotation(object);
......@@ -608,9 +630,10 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
var tagid = data['tag'];
var question = data['question'];
var statut = data['statut'];
var author = data['author'];
var elemlist = null;
if (tagid == -2 && question == -1 && statut == -1) {
if (tagid == -2 && question == -1 && statut == -1 && author == -1) {
for (var i = 0; i < this.annotations.length; i++) {
this.annotations[i].show();
elemlist = $('li[data-annotation=' + this.annotations[i].id + ']');
......@@ -622,14 +645,14 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
var annotQ = this.annotations[j].isquestion;
var annotS = this.annotations[j].statut;
var annotT = this.annotations[j].tag;
var annotA = this.annotations[j].typeuser;
elemlist = $('li[data-annotation=' + this.annotations[j].id + ']');
if ((tagid == -2 && question == -1 && annotS == statut)
|| (tagid == -2 && annotQ == question && statut == -1)
|| (annotT == tagid && question == -1 && statut == -1)
|| (tagid == -2 && annotQ == question && annotS == statut)
|| (annotT == tagid && question == -1 && annotS == statut)
|| (annotT == tagid && annotQ == question && statut == -1)
|| (annotT == tagid && annotQ == question && annotS == statut)) {
if ((tagid == -2 || tagid == annotT)
&& (question == -1 || annotQ == question)
&& (statut == -1 || annotS == statut)
&& (author == -1 ||
(author == 0 && this.annotations[j].user == this.getCurrentUser())
|| annotA == author)) {
this.annotations[j].show();
elemlist.show();
elemlist.data('display', '1');
......@@ -767,5 +790,29 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
return this.controler.getEval();
};
/**
* Get the edition statut of the workspace
* @returns {bool} is not the workspace on evaluation but user can edit
*/
Editor.prototype.isWriting = function () {
return this.controler.isWriting();
};
/**
* Get if the worskpace is in pairing mode
* @returns {bool}
*/
Editor.prototype.getPairing = function () {
return this.controler.getPairing();
};
/**
* Get the current user id
* @returns {int} moodle id
*/
Editor.prototype.getCurrentUser = function () {
return this.controler.getCurrentUser();
};
return Editor;
});
\ No newline at end of file
......@@ -27,8 +27,8 @@
* @param {Jquery} $
* inspired by https://github.com/webrtc/samples/blob/gh-pages/src/content/getusermedia/record/js/main.js
*/
define(['jquery'],
function ($) {
define(['jquery', 'core/modal_factory', 'core/modal_events'],
function ($, ModalFactory, ModalEvents) {
/*************
* CONSTANTES *
......@@ -39,9 +39,9 @@ define(['jquery'],
Record.errorMsgElement = '#errorMsg';
Record.recordButton = '#record';
Record.pauseRecordButton = '#pauseRecord';
Record.playButton = '#play';
Record.removeButton = '#remove';
Record.recordedVideo = '#recorded';
Record.sending = '#sending';
Record.repo = -1;
......@@ -77,26 +77,6 @@ define(['jquery'],
* FUNCTIONS *
*************/
/**
* Open MediaSource
* @returns {undefined}
*/
/*var handleSourceOpen = function () {
window.console.log('MediaSource opened');
this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/ogg');
window.console.log('Source buffer: ', this.sourceBuffer);
};*/
/**
* Close MediaSource
* @param {UserMedia} stream
*/
/*var handleSuccess = function (stream) {
$(Record.recordButton).attr('disabled', false);
window.console.log('getUserMedia() got stream:', stream);
window.stream = stream;
};*/
/**
* Check if the user can record, and accept to record form its device
*/
......@@ -104,9 +84,9 @@ define(['jquery'],
this.errorMsgElement = '#errorMsg';
this.recordButton = '#record';
this.pauseRecordButton = '#pauseRecord';