define(["local_fliplearning/vue","local_fliplearning/vuetify","local_fliplearning/axios","local_fliplearning/moment","local_fliplearning/pagination","local_fliplearning/chartdynamic","local_fliplearning/pageheader","local_fliplearning/emailform","local_fliplearning/helpdialog"],function(s,e,t,i,n,o,a,r,c){"use strict";return{init:function(i){s.use(e),s.component("pagination",n),s.component("chart",o),s.component("pageheader",a),s.component("emailform",r),s.component("helpdialog",c);letl=news({delimiters:["[[","]]"],el:"#submissions",vuetify:newe,data:()=>({dialog:!1,selected_users:[],modulename:"",moduleid:!1,strings:i.strings,groups:i.groups,userid:i.userid,courseid:i.courseid,timezone:i.timezone,render_has:i.profile_render,scriptname:i.scriptname,loading:!1,errors:[],pages:i.pages,submissions:i.submissions,email_strings:i.strings.email_strings,access:i.access,assigns_submissions_colors:i.assigns_submissions_colors,access_content_colors:i.access_content_colors,access_chart_categories:[],access_chart_series:[],access_chart_users:[],help_dialog:!1,help_contents:[],email_object_name:""}),beforeMount(){this.generate_access_content_data()},mounted(){document.querySelector("#sessions-loader").style.display="none",document.querySelector("#submissions").style.display="block",setTimeout(function(){l.setGraphicsEventListeners()},1e3)},methods:{get_help_content(){lets=[];returns.push({title:this.strings.section_help_title,description:this.strings.section_help_description}),s},update_interactions(s){this.loading=!0,this.errors=[];lete={action:"assignments",userid:this.userid,courseid:this.courseid,weekcode:s.weekcode,profile:this.render_has};returnt({method:"get",url:M.cfg.wwwroot+"/local/fliplearning/ajax.php",params:e}).then(s=>{200==s.status&&s.data.ok?(this.submissions=s.data.data.submissions,this.access=s.data.data.access,this.generate_access_content_data()):this.error_messages.push(this.strings.error_network)}).catch(s=>{this.errors.push(this.strings.api_error_network)}).finally(()=>{this.loading=!1,l.addLogsIntoDB("viewed","week_"+s.weekcode,"week_section","Week section that allows you to obtain information on a specific week"),l.setGraphicsEventListeners()}),this.data},build_assigns_submissions_chart(){lets=newObject;returns.chart={type:"column",backgroundColor:null,style:{fontFamily:"poppins"}},s.title={text:null},s.colors=this.assigns_submissions_colors,s.xAxis={categories:this.submissions.categories,crosshair:!0},s.yAxis={min:0,title:{text:this.strings.assignsubs_chart_yaxis},allowDecimals:!1},s.tooltip={formatter:function(){lets=this.x.split("</b>");s=(s=(s=s[0]||"").split("<b>"))[1]||"";lete=this.series.name,t=this.y,i=l.strings.students_text,n=l.strings.send_mail;return1==t&&(i=l.strings.student_text),"<b>"+s+"</b><br/><b>"+e+": </b>"+t+""+i+"<br/>"+n}},s.plotOptions={series:{cursor:"pointer",point:{events:{click:function(){l.email_object_name="assigns_submissions";lets=this.category.split("</b>");s=(s=(s=s[0]||"").split("<b>"))[1]||"",l.email_strings.subject=l.email_strings.subject_prefix+" - "+s;lete=this.x,t=this.series.colorIndex;l.dialog=!0,l.selected_users=l.submissions.users[e][t],l.moduleid=l.submissions.modules[e],l.modulename="assign",l.scriptname="test"}}}}},s.series=this.submissions.data,s},build_access_content_chart(){lets=newObject;returns.chart={type:"bar",backgroundColor:null,style:{fontFamily:"poppins"}},s.title={text:null},s.colors=this.access_content_colors,s.xAxis={categories:this.access_chart_categories,title:{text:null},crosshair:!0},s.yAxis={min:0,title:{text:this.strings.access_chart_yaxis_label},labels:{overflow:"justify"},allowDecimals:!1},s.tooltip={formatter:function(){lets=this.x,e=this.series.name,t=this.y,i=l.strings.students_text,n=l.strings.send_mail;return1==t&&(i=l.strings.student_text),"<b>"+s+"</b><br/><b>"+e+": </b>"+t+""+i+"<br/>"+n}},s.plotOptions={bar:{dataLabels:{enabled:!1}},series:{cursor:"pointer",point:{events:{click:function(){l.email_object_name="access_content";lets=this.category;l.email_strings.subject=l.email_strings.subject_prefix+" - "+s;lete=this.x,t=this.series.colorIndex,i=l.get_users(l.access_chart_users[e][t]);l.selected_users=i;letn=l.get_moduletype(this.category);l.modulename=n.type,l.moduleid=n.id,l.dialog=!0,l.scriptname="test"}}}}},s.series=this.access_chart_series,s},update_dialog(s){this.dialog=s},generate_access_content_data(){lets=[];this.access.users.forEach(e=>{s.push(Number(e.id))});lete=[];this.access.types.forEach(s=>{s.show&&e.push(s.type)});lett=[];this.access.modules.forEach(s=>{e.includes(s.type)&&t.push(s)});leti=[],n=[],o=[],a=[];t.forEach(e=>{i.push(e.name);lett=e.users,r=s.filter(s=>!t.includes(s));o.push(t.length),a.push(r.length),n.push([t,r])});letr=[{name:this.strings.access,data:o},{name:this.strings.no_access,data:a}];this.access_chart_categories=i,this.access_chart_series=r,this.access_chart_users=n},get_users(s){lete=[];returnthis.access.users.forEach(t=>{leti=Number(t.id);s.includes(i)&&e.push(t)}),e},get_moduletype(s){lete;returnthis.access.modules.forEach(t=>{t.name===s&&(e=t)}),e},open_chart_help(s){lete=[];vart="",i="",n="",o="";"assigns_submissions"==s?(e.push({title:this.strings.assigns_submissions_help_title,description:this.strings.assigns_submissions_help_description_p1}),e.push({description:this.strings.assigns_submissions_help_description_p2}),t="viewed",n="help",i="assigns_submissions",o="Help section that provides information about the invested time chart",l.addLogsIntoDB(t,i,n,o)):"access_content"==s&&(e.push({title:this.strings.access_content_help_title,description:this.strings.access_content_help_description_p1}),e.push({description:this.strings.access_content_help_description_p2}),t="viewed",n="help",i="access_content",o="Help section that provides information about the sessions per hour chart",l.addLogsIntoDB(t,i,n,o)),this.help_contents=e,this.help_contents.length&&(this.help_dialog=!0)},update_help_dialog(s){this.help_dialog=s},get_timezone(){return`${this.strings.ss_change_timezone}${this.timezone}`},setGraphicsEventListeners(){lets=document.querySelectorAll(".highcharts-container");s.length<1?setTimeout(l.setGraphicsEventListeners,500):(s[0].id="submissions",s[1].id="accessContent",s.forEach(s=>{s.addEventListener("mouseenter",l.addLogsViewGraphic)}))},addLogsViewGraphic(s){event.stopPropagation();vare="",t="",i="",n="";switch(s.target.id){case"submissions":e="viewed",t="assigns_submissions",i="chart",n="Chart showing the work submited by the students";break;case"accessContent":e="viewed",t="access_content",i="chart",n="Chart showing the course content accessed by the students";break;default:e="viewed",t="",i="chart",n="A chart"}l.addLogsIntoDB(e,t,i,n)},addLogsIntoDB(s,e,n,o){leta={courseid:i.courseid,userid:i.userid,action:"addLogs",sectionname:"TASKS_MONITORING",actiontype:s,objectType:n,objectName:e,currentUrl:document.location.href,objectDescription:o};t({method:"get",url:M.cfg.wwwroot+"/local/fliplearning/ajax.php",params:a}).then(s=>{200==s.status&&s.data.ok}).catch(s=>{})}}})}}});