From 92fd4793bccaa17bebc4be1a9a3261f504c76253 Mon Sep 17 00:00:00 2001 From: Matthias Opitz Date: Thu, 19 Dec 2024 14:23:14 +0000 Subject: [PATCH] CTP-4183 : fixing JS for Moodle 4.5 (#43) - refactored coursework.js and coursework_edit.js as AMD using jQuery - replaced M.core.alert with modal - cleanup, dealing with space issues in JS - using postgres 14 for GHA cleanup, dealing with space issues in JS Co-authored-by: Matthias Opitz --- .github/workflows/moodle-ci.yml | 2 +- amd/build/coursework.min.js | 3 + amd/build/coursework.min.js.map | 1 + amd/build/coursework_edit.min.js | 3 + amd/build/coursework_edit.min.js.map | 1 + amd/src/coursework.js | 328 ++++++ amd/src/coursework_edit.js | 991 ++++++++++++++++++ coursework.js | 296 ------ coursework_edit.js | 915 ---------------- module.js | 1 - .../submissions_early_finalisation.feature | 2 +- .../submissions_file_upload_types.feature | 2 +- view.php | 9 +- 13 files changed, 1332 insertions(+), 1222 deletions(-) create mode 100644 amd/build/coursework.min.js create mode 100644 amd/build/coursework.min.js.map create mode 100644 amd/build/coursework_edit.min.js create mode 100644 amd/build/coursework_edit.min.js.map create mode 100644 amd/src/coursework.js create mode 100644 amd/src/coursework_edit.js delete mode 100644 coursework.js delete mode 100644 coursework_edit.js diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index 51ff875c..eda1dc34 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -8,7 +8,7 @@ jobs: services: postgres: - image: postgres:13 + image: postgres:14 env: POSTGRES_USER: 'postgres' POSTGRES_HOST_AUTH_METHOD: 'trust' diff --git a/amd/build/coursework.min.js b/amd/build/coursework.min.js new file mode 100644 index 00000000..6cd310a5 --- /dev/null +++ b/amd/build/coursework.min.js @@ -0,0 +1,3 @@ +define("mod_coursework/coursework",["jquery","core/log"],(function($){return{init:function(){var table_obj_list=[],tableobject=0;function isMobileDevice(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}$(document).ready((function(){var langmessage=JSON.parse($("#element_lang_messages").attr("data-lang")),base_url=window.location.origin+"/mod/coursework/datatables/js/";function initDatatable(){$(".datatabletest").each((function(){var fullloaded=$(this).hasClass("full-loaded");table_obj_list[$(this).attr("id")]=$(this).DataTable({order:[],stateSave:!0,language:{searchPanes:{collapse:{0:$("#search_pane_button").val()||"Filter",_:($("#search_pane_button").val()||"Filter")+" (%d)"}}},buttons:[],dom:"Blfrtip",columnDefs:[{searchPanes:{show:!1},targets:["studentname","addition-multiple-button"],bSortable:!1},{searchPanes:{show:!1},targets:["lastname_cell","firstname_cell","tableheadpersonaldeadline","tableheaddate","tableheadfilename","tableheadplagiarismalert","plagiarism","agreedgrade","feedbackandgrading","provisionalgrade","tableheadmoderationagreement"]},{searchPanes:{show:!0,header:$("#search_pane_group").val()||"Group"},targets:"tableheadgroups"},{searchPanes:{show:!0,header:$("#search_pane_status").val()||"Status",getFullText:!0},targets:"tableheadstatus"},{searchPanes:{show:!0,header:$("#search_pane_firstname").val()||"First Name Initial"},targets:"firstname_letter_cell"},{searchPanes:{show:!0,header:$("#search_pane_lastname").val()||"Last Name Initial"},targets:"lastname_letter_cell"},{visible:!1,targets:["lastname_letter_cell","firstname_letter_cell","lastname_cell","firstname_cell"]}],select:{style:"multi",selector:".select-checkbox"},stateSaveParams:function(settings,data){data.columns=[]}}),fullloaded||function(tableid){var tableelement=$("#"+tableid),wrapperelement=tableelement.parent(".dataTables_wrapper"),paginationelement=wrapperelement.find(".dataTables_paginate");tableobject=table_obj_list[tableid];var submissionswrapper=tableelement.parent(".dataTables_wrapper");wrapperelement.find(".dataTables_paginate, .dataTables_info, .dataTables_length, .dataTables_filter").css("visibility","hidden"),wrapperelement.find("thead, .dt-button").each((function(){var me=$(this);me.css("pointer-events","none"),me.hasClass("dt-button")&&me.find("span").html(" "+me.find("span").html())})),$('
'+langmessage.loadingpagination+"
").insertBefore(submissionswrapper),$('
'+langmessage.loadingpagination+"
").insertAfter(paginationelement),$('').insertBefore(wrapperelement.find(".dt-button > span"));var params={group:tableelement.attr("group"),perpage:tableelement.attr("perpage"),sortby:tableelement.attr("sortby"),sorthow:tableelement.attr("sorthow"),firstnamealpha:tableelement.attr("firstnamealpha"),lastnamealpha:tableelement.attr("lastnamealpha"),groupnamealpha:tableelement.attr("groupnamealpha"),substatus:tableelement.attr("substatus"),unallocated:tableelement.attr("unallocated"),courseworkid:tableelement.attr("courseworkid")};$.ajax({url:"/mod/coursework/actions/ajax/datatable/grading.php",type:"POST",data:params}).done((function(response){$("#datatable_top_loading_message").remove(),tableobject.rows.add($(response)).draw(!1),wrapperelement.find(".submission-loading").remove()})).fail((function(){})).always((function(){wrapperelement.find(".pagination-loading").remove(),wrapperelement.find(".submission-loading").remove(),wrapperelement.find("thead, .dt-button").css("pointer-events","auto"),wrapperelement.find(".dataTables_paginate, .dataTables_info, .dataTables_length, .dataTables_filter").css("visibility","visible")}))}($(this).attr("id"))}))}if(require.config({paths:{"datatables.net":base_url+"jquery.datatables","datatables.searchpanes":base_url+"datatables.searchpanes","datatables.buttons":base_url+"datatables.buttons","datatables.select":base_url+"datatables.select","datatables.responsive":base_url+"datatables.responsive.min"}}),require(["datatables.net"],(function(DataTable){$.fn.dataTable||($.fn.dataTable=DataTable),$.fn.DataTable=DataTable,$.fn.DataTableSettings=DataTable.settings,$.fn.dataTableExt=DataTable.ext,DataTable.$=$,$.fn.DataTable=function(opts){return $(this).dataTable(opts).api()},$.fn.dataTable.Api.register("row().show()",(function(){var page_info=this.table().page.info(),new_row_index=this.index(),row_position=this.table().rows({search:"applied"})[0].indexOf(new_row_index);if(row_position>=page_info.start&&row_position0)$(tr).next("tr.row_assessors").remove();else{const oldTable=$("#"+table_id),newRow=$('');oldTable.addClass("assessors_expanded").css("width","95%").appendTo(newRow.find("td"))}$(tr).toggleClass("shown")}));else $(".datatabletest tbody").on("click","td.details-control",(function(){var tr=$(this).closest("tr"),table_key=$(this).closest(".datatabletest").attr("id"),table=table_obj_list[table_key];if(table){var row=table.row(tr),row_id=tr.attr("id").replace("allocatable_","");const oldTable=$("#"+("assessorfeedbacktable_"+row_id)),subRow=$("#sub-row-"+tr.data("allocatable"));if(oldTable.length)if(0===subRow.length){const newRow=$('');oldTable.addClass("assessors_expanded").css("width","95%").appendTo(newRow.find("td")),oldTable.show(),row.child(newRow).show(),tr.addClass("shown")}else"none"===subRow.css("display")?(subRow.show(),tr.addClass("shown")):(tr.removeClass("shown"),subRow.hide());else"none"===subRow.css("display")?(subRow.show(),tr.addClass("shown")):(subRow.hide(),tr.removeClass("shown"))}}));$(".datatabletest").on("click",".splitter-firstname, .splitter-lastname, .splitter-email",(function(event){event.preventDefault();var node=$(event.target),currentsort="asc",sortby="desc";node.hasClass("sorting_asc")||(currentsort="desc",sortby="asc");var table_id=$(this).closest(".datatabletest").attr("id");table=table_obj_list[table_id];var headerclass=$(this).hasClass("splitter-firstname")?"firstname_cell":"lastname_cell";headerclass=$(this).hasClass("splitter-email")?"email_cell":headerclass;var sortColumn=table.column("."+headerclass).index();table.order([sortColumn,sortby]).draw(),node.addClass("sorting_"+sortby).removeClass("sorting sorting_"+currentsort),node.parent().removeClass("sorting sorting_asc sorting_desc"),node.siblings().removeClass("sorting_asc sorting_desc").addClass("sorting")}))}))}}})); + +//# sourceMappingURL=coursework.min.js.map \ No newline at end of file diff --git a/amd/build/coursework.min.js.map b/amd/build/coursework.min.js.map new file mode 100644 index 00000000..df58bec8 --- /dev/null +++ b/amd/build/coursework.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"coursework.min.js","sources":["../src/coursework.js"],"sourcesContent":["define('mod_coursework/coursework', ['jquery', 'core/log'], function($) {\n return {\n init: function() {\n var table_obj_list = [];\n// var is_responsive = false;\n var tableobject = 0;\n\n $(document).ready(function() {\n var langmessage = JSON.parse($('#element_lang_messages').attr('data-lang'));\n var base_url = window.location.origin + '/mod/coursework/datatables/js/';\n\n require.config({\n paths: {\n 'datatables.net': base_url + 'jquery.datatables',\n 'datatables.searchpanes': base_url + 'datatables.searchpanes',\n 'datatables.buttons': base_url + 'datatables.buttons',\n 'datatables.select': base_url + 'datatables.select',\n 'datatables.responsive': base_url + 'datatables.responsive.min',\n }\n });\n\n require(['datatables.net'], function(DataTable) {\n\n // Ensure jQuery access.\n if (!$.fn.dataTable) {\n $.fn.dataTable = DataTable;\n }\n\n $.fn.DataTable = DataTable;\n $.fn.DataTableSettings = DataTable.settings;\n $.fn.dataTableExt = DataTable.ext;\n DataTable.$ = $;\n $.fn.DataTable = function(opts) {\n return $(this).dataTable(opts).api();\n };\n\n $.fn.dataTable.Api.register('row().show()', function() {\n var page_info = this.table().page.info();\n // Get row index.\n var new_row_index = this.index();\n // Row position.\n var row_position = this.table()\n .rows({search: 'applied'})[0]\n .indexOf(new_row_index);\n // Already on right page ?\n if ((row_position >= page_info.start && row_position < page_info.end) || row_position < 0) {\n // Return row object.\n return this;\n }\n // Find page number.\n var page_to_display = Math.floor(row_position / this.table().page.len());\n // Go to that page.\n this.table().page(page_to_display);\n // Return row object.\n return this;\n });\n require(['datatables.searchpanes',\n 'datatables.select',\n 'datatables.buttons',\n 'datatables.responsive'],\n function() {\n if (isMobileDevice() && $(window).width() < 768) {\n// is_responsive = true;\n initDatatable();\n\n $('.datatabletest').on('order.dt', function() {\n $('.submissionrowmulti').removeClass(\"shown\");\n });\n } else {\n initDatatable();\n }\n });\n });\n\n /**\n *\n * @param {string} tableid\n */\n function background_load_table(tableid) {\n var tableelement = $('#' + tableid);\n var wrapperelement = tableelement.parent('.dataTables_wrapper');\n var paginationelement = wrapperelement.find('.dataTables_paginate');\n tableobject = table_obj_list[tableid];\n var submissionswrapper = tableelement.parent('.dataTables_wrapper');\n\n // Hide buttons.\n wrapperelement.find('.dataTables_paginate, .dataTables_info, .dataTables_length,' +\n ' .dataTables_filter').css('visibility', 'hidden');\n wrapperelement.find('thead, .dt-button').each(function() {\n var me = $(this);\n me.css('pointer-events', 'none');\n if (me.hasClass('dt-button')) {\n me.find('span').html(' ' + me.find('span').html());\n }\n });\n// console.log(submissionswrapper);\n\n $('
' +\n ' ' + langmessage.loadingpagination + '
').\n insertBefore(submissionswrapper);\n $('
' +\n langmessage.loadingpagination + '
').insertAfter(paginationelement);\n $('').insertBefore(wrapperelement.\n find('.dt-button > span'));\n\n // Prepare params for ajax request.\n var params = {\n group: tableelement.attr('group'),\n perpage: tableelement.attr('perpage'),\n sortby: tableelement.attr('sortby'),\n sorthow: tableelement.attr('sorthow'),\n firstnamealpha: tableelement.attr('firstnamealpha'),\n lastnamealpha: tableelement.attr('lastnamealpha'),\n groupnamealpha: tableelement.attr('groupnamealpha'),\n substatus: tableelement.attr('substatus'),\n unallocated: tableelement.attr('unallocated'),\n courseworkid: tableelement.attr('courseworkid')\n };\n\n $.ajax({\n url: '/mod/coursework/actions/ajax/datatable/grading.php',\n type: 'POST',\n data: params\n }).done(function(response) {\n// console.log('test remove 1');\n $(\"#datatable_top_loading_message\").remove();\n tableobject.rows.add($(response)).draw(false);\n wrapperelement.find('.submission-loading').remove();\n }).fail(function() {}).always(function() {\n // Show buttons.\n wrapperelement.find('.pagination-loading').remove();\n wrapperelement.find('.submission-loading').remove();\n wrapperelement.find('thead, .dt-button').css('pointer-events', 'auto');\n wrapperelement.find('.dataTables_paginate, .dataTables_info, .dataTables_length,' +\n ' .dataTables_filter').css('visibility', 'visible');\n });\n }\n\n /**\n *\n */\n function initDatatable() {\n $(\".datatabletest\").each(function() {\n // Class that determines whether all data for the databale has been full loaded.\n var fullloaded = $(this).hasClass('full-loaded');\n\n table_obj_list[$(this).attr('id')] = $(this).DataTable({\n 'order': [],\n stateSave: true,\n language: {\n searchPanes: {\n collapse: {\"0\": $('#search_pane_button').val() || 'Filter',\n _: ($('#search_pane_button').val() || 'Filter') + ' (%d)'}\n }\n },\n buttons: [\n\n ],\n dom: 'Blfrtip',\n columnDefs: [\n {\n searchPanes: {show: false},\n targets: ['studentname', 'addition-multiple-button'],\n bSortable: false\n },\n {\n searchPanes: {show: false},\n targets: ['lastname_cell', 'firstname_cell', 'tableheadpersonaldeadline',\n 'tableheaddate', 'tableheadfilename', 'tableheadplagiarismalert',\n 'plagiarism', 'agreedgrade', 'feedbackandgrading', 'provisionalgrade',\n 'tableheadmoderationagreement']\n },\n {\n searchPanes: {\n show: true,\n header: $('#search_pane_group').val() || 'Group',\n },\n targets: 'tableheadgroups',\n },\n {\n searchPanes: {\n show: true,\n header: $('#search_pane_status').val() || 'Status',\n getFullText: true,\n },\n targets: 'tableheadstatus',\n },\n {\n searchPanes: {\n show: true,\n header: $('#search_pane_firstname').val() || 'First Name Initial',\n },\n targets: 'firstname_letter_cell',\n },\n {\n searchPanes: {\n show: true,\n header: $('#search_pane_lastname').val() || 'Last Name Initial',\n },\n targets: 'lastname_letter_cell',\n },\n {\"visible\": false, \"targets\": ['lastname_letter_cell', 'firstname_letter_cell',\n 'lastname_cell', 'firstname_cell']}\n ],\n select: {\n style: 'multi',\n selector: '.select-checkbox'\n },\n stateSaveParams: function(settings, data) {\n data.columns = [];\n }\n\n });\n\n if (!fullloaded) {\n background_load_table($(this).attr('id'));\n }\n });\n }\n\n if (isMobileDevice() && $(window).width() < 768) {\n // For small screens.\n var table = $('.datatabletest tbody').on('click', 'td.details-control', function() {\n var tr = $(this).closest(\"tr\");\n var row_id = tr.attr('id').replace('allocatable_', '');\n var table_id = 'assessorfeedbacktable_' + row_id;\n\n if ($(tr).next('tr.row_assessors').length > 0) {\n $(tr).next('tr.row_assessors').remove();\n } else {\n // As originally written this code created a new table with duplicate IDs.\n // See comment on CTP-3783 below for more info.\n const oldTable = $('#' + table_id);\n const newRow = $(\n ''\n );\n oldTable.addClass('assessors_expanded').css('width', '95%').appendTo(newRow.find('td'));\n }\n $(tr).toggleClass('shown');\n });\n } else {\n // Add event listener for opening and closing details.\n $('.datatabletest tbody').on('click', 'td.details-control', function() {\n var tr = $(this).closest(\"tr\");\n var table_key = $(this).closest('.datatabletest').attr('id');\n var table = table_obj_list[table_key];\n if (table) {\n var row = table.row(tr);\n\n var row_id = tr.attr('id').replace('allocatable_', '');\n var table_id = 'assessorfeedbacktable_' + row_id;\n const oldTable = $('#' + table_id);\n const subRow = $('#sub-row-' + tr.data('allocatable'));\n if (oldTable.length) {\n if (subRow.length === 0) {\n // Open this row - create as sub-row.\n // CTP-3783 As originally written this code cloned the old table and\n // added its HTML again to the new row.\n // This meant that we had 2 x tables do duplicate IDs, with the old table hidden and\n // new one visible.\n // Then multiple behat tests failed when trying to click the hidden feedback button\n // not visible one.\n const newRow = $(\n ''\n );\n oldTable.addClass('assessors_expanded').css('width', '95%').appendTo(newRow.find('td'));\n oldTable.show();\n row.child(newRow).show();\n tr.addClass('shown');\n } else {\n // Sub-row already exists.\n if (subRow.css('display') === 'none') {\n subRow.show();\n tr.addClass('shown');\n } else {\n // This row is already open - close it.\n tr.removeClass('shown');\n subRow.hide();\n }\n }\n } else {\n // No need to move table - just open/close.\n if (subRow.css('display') === 'none') {\n subRow.show();\n tr.addClass('shown');\n } else {\n // This row is already open - close it.\n subRow.hide();\n tr.removeClass('shown');\n }\n }\n }\n });\n }\n\n $('.datatabletest').on('click', '.splitter-firstname, .splitter-lastname, .splitter-email', function(event) {\n event.preventDefault();\n var node = $(event.target),\n isAscending = node.hasClass('sorting_asc'),\n currentsort = 'asc',\n sortby = 'desc';\n if (!isAscending) {\n currentsort = 'desc';\n sortby = 'asc';\n }\n var table_id = $(this).closest('.datatabletest').attr('id');\n table = table_obj_list[table_id];\n var headerclass = $(this).hasClass('splitter-firstname') ? 'firstname_cell' : 'lastname_cell';\n headerclass = $(this).hasClass('splitter-email') ? 'email_cell' : headerclass;\n// console.log(headerclass);\n var sortColumn = table.column('.' + headerclass).index();\n table.order([sortColumn, sortby]).draw();\n\n node.addClass('sorting_' + sortby).removeClass('sorting sorting_' + currentsort);\n node.parent().removeClass('sorting sorting_asc sorting_desc');\n node.siblings().removeClass('sorting_asc sorting_desc').addClass('sorting');\n });\n });\n\n /**\n *\n */\n function isMobileDevice() {\n return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));\n }\n }\n };\n});\n\n"],"names":["define","$","init","table_obj_list","tableobject","isMobileDevice","test","navigator","userAgent","document","ready","langmessage","JSON","parse","attr","base_url","window","location","origin","initDatatable","each","fullloaded","this","hasClass","DataTable","stateSave","language","searchPanes","collapse","val","_","buttons","dom","columnDefs","show","targets","bSortable","header","getFullText","select","style","selector","stateSaveParams","settings","data","columns","tableid","tableelement","wrapperelement","parent","paginationelement","find","submissionswrapper","css","me","html","loadingpagination","insertBefore","insertAfter","params","group","perpage","sortby","sorthow","firstnamealpha","lastnamealpha","groupnamealpha","substatus","unallocated","courseworkid","ajax","url","type","done","response","remove","rows","add","draw","fail","always","background_load_table","require","config","paths","fn","dataTable","DataTableSettings","dataTableExt","ext","opts","api","Api","register","page_info","table","page","info","new_row_index","index","row_position","search","indexOf","start","end","page_to_display","Math","floor","len","width","on","removeClass","tr","closest","table_id","replace","next","length","oldTable","newRow","addClass","appendTo","toggleClass","table_key","row","row_id","subRow","child","hide","event","preventDefault","node","target","currentsort","headerclass","sortColumn","column","order","siblings"],"mappings":"AAAAA,mCAAoC,CAAC,SAAU,aAAa,SAASC,SAC1D,CACHC,KAAM,eACEC,eAAiB,GAEjBC,YAAc,WA8TTC,uBACG,iEAAiEC,KAAKC,UAAUC,WA7T5FP,EAAEQ,UAAUC,OAAM,eACVC,YAAcC,KAAKC,MAAMZ,EAAE,0BAA0Ba,KAAK,cAC1DC,SAAWC,OAAOC,SAASC,OAAS,0CAoI/BC,gBACLlB,EAAE,kBAAkBmB,MAAK,eAEjBC,WAAapB,EAAEqB,MAAMC,SAAS,eAElCpB,eAAeF,EAAEqB,MAAMR,KAAK,OAASb,EAAEqB,MAAME,UAAU,OAC1C,GACTC,WAAW,EACXC,SAAU,CACNC,YAAa,CACTC,SAAU,GAAM3B,EAAE,uBAAuB4B,OAAS,SAC9CC,GAAI7B,EAAE,uBAAuB4B,OAAS,U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KADJ,yBAA2B4H,SAEpCC,OAAS7H,EAAE,YAAc+G,GAAGpE,KAAK,mBACnC0E,SAASD,UACa,IAAlBS,OAAOT,OAAc,OAQfE,OAAStH,EACX,mDAAqD+G,GAAGpE,KAAK,eAC3D,qDAEN0E,SAASE,SAAS,sBAAsBnE,IAAI,QAAS,OAAOoE,SAASF,OAAOpE,KAAK,OACjFmE,SAASpF,OACT0F,IAAIG,MAAMR,QAAQrF,OAClB8E,GAAGQ,SAAS,aAGkB,SAA1BM,OAAOzE,IAAI,YACXyE,OAAO5F,OACP8E,GAAGQ,SAAS,WAGZR,GAAGD,YAAY,SACfe,OAAOE,YAKe,SAA1BF,OAAOzE,IAAI,YACXyE,OAAO5F,OACP8E,GAAGQ,SAAS,WAGZM,OAAOE,OACPhB,GAAGD,YAAY,cAOnC9G,EAAE,kBAAkB6G,GAAG,QAAS,4DAA4D,SAASmB,OACjGA,MAAMC,qBACFC,KAAOlI,EAAEgI,MAAMG,QAEfC,YAAc,MACdvE,OAAS,OAFKqE,KAAK5G,SAAS,iBAI5B8G,YAAc,OACdvE,OAAS,WAEToD,SAAWjH,EAAEqB,MAAM2F,QAAQ,kBAAkBnG,KAAK,MACtDiF,MAAQ5F,eAAe+G,cACnBoB,YAAcrI,EAAEqB,MAAMC,SAAS,sBAAwB,iBAAmB,gBAC9E+G,YAAcrI,EAAEqB,MAAMC,SAAS,kBAAoB,aAAe+G,gBAE9DC,WAAaxC,MAAMyC,OAAO,IAAMF,aAAanC,QACjDJ,MAAM0C,MAAM,CAACF,WAAYzE,SAASgB,OAElCqD,KAAKX,SAAS,WAAa1D,QAAQiD,YAAY,mBAAqBsB,aACpEF,KAAKlF,SAAS8D,YAAY,oCAC1BoB,KAAKO,WAAW3B,YAAY,4BAA4BS,SAAS"} \ No newline at end of file diff --git a/amd/build/coursework_edit.min.js b/amd/build/coursework_edit.min.js new file mode 100644 index 00000000..11b65b1f --- /dev/null +++ b/amd/build/coursework_edit.min.js @@ -0,0 +1,3 @@ +define("mod_coursework/coursework_edit",["jquery","core/notification","core/modal"],(function($,Notification,Modal){return{init:function(){function compare_row(row){return this==row.DT_RowId}var now=new Date,extension_form_change=!1;window.addEventListener("beforeunload",(table_obj_list=>{if(table_obj_list)for(var table_id in table_obj_list)table_obj_list[table_id].state.save()})),$(document).ready((function(){function log_datatable_navigate(tr){var row_id=tr.attr("id"),tableid=tr.closest("table").attr("id"),key="datatable_navigate_"+window.location.href+tableid;localStorage.setItem(key,row_id)}$(".datatabletest").on("click",".new_plagiarism_flag",(function(){log_datatable_navigate($(this).closest("tr"))})),$(".datatabletest").on("click",".edit_plagiarism_flag",(function(){log_datatable_navigate($(this).closest("tr"))})),$(".datatabletest").on("click",".new_final_feedback",(function(){log_datatable_navigate($(this).closest("tr"))})),$(".datatabletest").on("click",".edit_final_feedback",(function(){log_datatable_navigate($(this).closest("tr"))})),$(".datatabletest").on("click",".show_feedback",(function(){log_datatable_navigate($(this).closest("tr"))})),$(".datatabletest").on("click",".assessor_feedback_grade .new_feedback",(function(){log_datatable_navigate($(this).closest("td.assessors").closest("table.assessors").closest("tr").prev())})),$(".datatabletest").on("click",".assessor_feedback_grade .show_feedback",(function(){log_datatable_navigate($(this).closest("td.assessors").closest("table.assessors").closest("tr").prev())})),$(".datatabletest").on("click",".assessor_feedback_grade .edit_feedback",(function(){log_datatable_navigate($(this).closest("td.assessors").closest("table.assessors").closest("tr").prev())})),$(".datatabletest").on("click",".new_deadline_extension",(function(){log_datatable_navigate($(this).closest("tr"))})),$(".datatabletest").on("click",".edit_deadline_extension",(function(){log_datatable_navigate($(this).closest("tr"))})),$(".datatabletest").on("click",".new_submission",(function(){log_datatable_navigate($(this).closest("tr"))}));var datatables_lang_messages=JSON.parse($("#datatables_lang_messages").attr("data-lang"));function extension_edit_change_data_form(data_name,data_params,data_time,current_rowid){var title="Editing the extension for "+data_name,time_content="Default deadline: "+data_time.time_content;$("#extension-modal-title").html(title),$("#form-extension").find("input[type=hidden]").val(""),$("#form-extension").find("textarea").val(""),$("#button-id").val(current_rowid),$("#extension-submissionid").val(data_params.submissionid),$("#extension-name").val(data_name),data_params.requesttype="edit";var url=datatables_lang_messages.url_root;$.ajax({type:"GET",url:url+"/mod/coursework/actions/ajax/deadline_extension/edit.php",data:data_params,beforeSend:function(){change__status_extension_submit_button(!0),$("html, body").css("cursor","wait"),$(".modal-footer").children("img").css("visibility","visible")},success:function(response){var data_response=JSON.parse(response);if($("html, body").css("cursor","auto"),$(".modal-footer").children("img").css("visibility","hidden"),1==data_response.error)Modal.create({title:datatables_lang_messages.notification_info,body:data_response.message+" .Please reload the page!",show:!0,removeOnClose:!0});else{var extension=data_response.data;extension.time_content?$("#extension-time-content").html(extension.time_content):$("#extension-time-content").html(time_content),document.getElementById("extension-extend-deadline").value=data_response.data.time_iso_8601.slice(0,16),$("#extension-reason-select").val(extension.pre_defined_reason),$("#extension-allocatabletype").val(extension.allocatabletype),$("#extension-allocatableid").val(extension.allocatableid),$("#extension-courseworkid").val(extension.courseworkid),$("#extension-id").val(extension.id),$("#id_extra_information").val(extension.text),$("#id_extra_information").prop("disabled",!1),$("#extension-extend-deadline").prop("disabled",!1),$("#extension-reason-select").prop("disabled",!1),save_extension_form_data()}},error:function(){$("html, body").css("cursor","auto"),change__status_extension_submit_button(!1)},complete:function(){$("html, body").css("cursor","auto"),change__status_extension_submit_button(!1)}})}function extension_new_change_data_form(data_name,data_params,data_time,current_rowid){var title="New extension for "+data_name;if($("#extension-modal-title").html(title),$("#form-extension").find("input[type=hidden]").val(""),$("#form-extension").find("textarea").val(""),"1"==data_time.is_have_deadline){var url=datatables_lang_messages.url_root;$.ajax({type:"GET",url:url+"/mod/coursework/actions/ajax/deadline_extension/new.php",data:data_params,beforeSend:function(){change__status_extension_submit_button(!0),$("html, body").css("cursor","wait"),$(".modal-footer").children("img").css("visibility","visible")},success:function(response){$("html, body").css("cursor","auto"),$(".modal-footer").children("img").css("visibility","hidden");var data_response=JSON.parse(response);$("#extension-time-content").html(data_response.data.time_content),document.getElementById("extension-extend-deadline").value=data_response.data.time_iso_8601.slice(0,16),save_extension_form_data()},error:function(){$("html, body").css("cursor","auto")},complete:function(){$("html, body").css("cursor","auto")}})}else save_extension_form_data();$("#extension-reason-select").val(""),$("#extension-allocatabletype").val(data_params.allocatabletype),$("#extension-allocatableid").val(data_params.allocatableid),$("#extension-courseworkid").val(data_params.courseworkid),$("#extension-submissionid").val(data_params.submissionid),$("#extension-name").val(data_name),$("#button-id").val(current_rowid),$("#id_extra_information").prop("disabled",!1),$("#extension-extend-deadline").prop("disabled",!1),$("#extension-reason-select").prop("disabled",!1)}function change__status_extension_submit_button(status){$("#extension-submit").prop("disabled",status)}function save_extension_form_data(){extension_form_change=!1}function is_data_extension_form_change(){return extension_form_change}function update_feedback(form_data,url,celltype,submitbutton,removefeedbackbutton,submitfeedbackbutton,confirm,button){form_data=form_data.concat({name:"ajax",value:1},{name:"cell_type",value:celltype},{name:"submitbutton",value:submitbutton},{name:"submitfeedbackbutton",value:submitfeedbackbutton},{name:"removefeedbackbutton",value:removefeedbackbutton},{name:"confirm",value:confirm}),$.ajax({type:"POST",data:form_data,url:url,dataType:"json"}).done((function(response){var _response$success2,_response$message2;if(!1===(null===(_response$success2=response.success)||void 0===_response$success2||_response$success2)&&null!==(_response$message2=response.message)&&void 0!==_response$message2&&_response$message2)$("#modal-grading").find(".modal-body").html('
'+response.message+"
");else if(response.success){var cell_selector=$("#modal-grading").find("#cell_selector").val();if($(cell_selector).html(response.html),void 0!==response.extrahtml&&""!=response.extrahtml&&$(cell_selector).next("td").html(response.extrahtml),void 0!==response.assessdate&&""!=response.assessdate&&$(cell_selector).next("td").html(response.assessdate),void 0!==response.assessorname&&""!=response.assessorname&&$(cell_selector).prev("td").html(response.assessorname),void 0!==response.assessortwo&&""!=response.assessortwo){var tdcell=$(cell_selector).closest("tr").next().find("td")[1];$(tdcell).html(response.assessortwo)}if(void 0!==response.finalhtml&&""!=response.assessortwo){var tablerowid="allocatable_"+response.allocatableid,tdcell2=$("#"+tablerowid).find(".multiple_agreed_grade_cell")[0];$(tdcell2).html(response.finalhtml)}var datatables_lang_messages_two=JSON.parse($("#datatables_lang_messages").attr("data-lang"));$("#modal-grading").modal("hide"),1===submitbutton?Modal.create({title:datatables_lang_messages_two.notification_info,body:datatables_lang_messages_two.alert_feedback_save_successful.replace(/\_/g," "),show:!0,removeOnClose:!0}):1===submitfeedbackbutton?Modal.create({title:datatables_lang_messages_two.notification_info,body:datatables_lang_messages_two.alert_feedback_draft_save_successful.replace(/\_/g," "),show:!0,removeOnClose:!0}):Modal.create({title:datatables_lang_messages_two.notification_info,body:datatables_lang_messages_two.alert_feedback_remove_successful.replace(/\_/g," "),show:!0,removeOnClose:!0})}else Modal.create({title:datatables_lang_messages_two.notification_info,body:response.message,show:!0,removeOnClose:!0})})).always((function(){button.prop("disabled",!1)}))}$(".datatabletest").on("click",".edit_personal_deadline",(function(e){e.preventDefault();var parent=$(this).closest(".personal_deadline_cell");parent.children(".show_personal_dealine").addClass("display-none");var change_form=parent.children(".show_edit_personal_dealine"),data_get=$(this).attr("data-get"),data_time=$(this).attr("data-time-iso-8601");if(1===change_form.html().length){var form='';form+='
',form+='
',$(change_form).html(form)}$(change_form).removeClass("display-none")})),$(".datatabletest").on("click",".cancel-personal-deadline",(function(e){e.preventDefault(),$(this).closest(".show_edit_personal_dealine").addClass("display-none"),$(this).closest(".personal_deadline_cell").children(".show_personal_dealine").removeClass("display-none")})),$(".datatabletest").on("click",".approve-personal-deadline",(function(e){e.preventDefault();var deadline=$(this),data_get=$(deadline).attr("data-get"),value=$(deadline).closest(".show_edit_personal_dealine").children(".input-personal-deadline").val();new Date(value)<=Date.parse(now)&&Modal.create({title:datatables_lang_messages.notification_info,body:datatables_lang_messages.alert_validate_deadline.replace(/\_/g," "),show:!0,removeOnClose:!0});var url=datatables_lang_messages.url_root+"/mod/coursework/actions/personal_deadline.php",param=JSON.parse(data_get);param.personal_deadline_time=value,$.ajax({type:"POST",url:url,data:param,beforeSend:function(){$("html, body").css("cursor","wait"),$(self).prev("img").css("visibility","visible")},success:function(response,table_obj_list){$("html, body").css("cursor","auto");var data_response=JSON.parse(response);if(1==data_response.error)Modal.create({title:datatables_lang_messages.notification_info,body:data_response.message,show:!0,removeOnClose:!0});else{var parent=$(deadline).closest(".personal_deadline_cell");$(parent).attr("data-order",data_response.timestamp),table_obj_list[Object.keys(table_obj_list)[0]].row("#"+$(parent).closest("tr").attr("id")).invalidate(),$(parent).children(".show_personal_dealine").children(".content_personal_deadline").html(data_response.time),$(parent).children(".show_edit_personal_dealine").addClass("display-none"),$(parent).children(".show_personal_dealine").removeClass("display-none"),Modal.create({title:datatables_lang_messages.notification_info,body:datatables_lang_messages.alert_personaldeadline_save_successful.replace(/\_/g," "),show:!0,removeOnClose:!0})}},error:function(){$("html, body").css("cursor","auto")},complete:function(){$("html, body").css("cursor","auto")}})})),$(".datatabletest").on("click",".new_deadline_extension",(function(e){e.preventDefault(),extension_new_change_data_form($(this).attr("data-name"),JSON.parse($(this).attr("data-params")),JSON.parse($(this).attr("data-time")),$(this).closest("tr").attr("id")),$("#modal-ajax").modal("show")})),$(".datatabletest").on("click",".edit_deadline_extension",(function(e){e.preventDefault(),extension_edit_change_data_form($(this).attr("data-name"),JSON.parse($(this).attr("data-params")),JSON.parse($(this).attr("data-time")),$(this).closest("tr").attr("id")),$("#modal-ajax").modal("show")})),$(".modal-footer").on("click","#extension-submit",(function(e){e.preventDefault();var params={};params.allocatabletype=$("#extension-allocatabletype").val(),params.allocatableid=$("#extension-allocatableid").val(),params.courseworkid=$("#extension-courseworkid").val(),params.id=$("#extension-id").val(),params.extended_deadline=$("#extension-extend-deadline").val(),params.editor=$("#extension-time-content").html(),params.text=$("#id_extra_information").val(),params.submissionid=$("#extension-submissionid").val(),params.pre_defined_reason=$("#extension-reason-select").val(),params.requesttype="submit";var current_rowid=$("#button-id").val(),url=datatables_lang_messages.url_root;$.ajax({type:"POST",url:url+"/mod/coursework/actions/ajax/deadline_extension/submit.php",data:params,beforeSend:function(){$("html, body").css("cursor","wait"),$(".modal-footer").children("img").css("visibility","visible")},success:function(response,table_obj_list){var data_response=JSON.parse(response);if($("html, body").css("cursor","auto"),$(".modal-footer").children("img").css("visibility","hidden"),1==data_response.error)Modal.create({title:datatables_lang_messages.notification_info,body:data_response.messages,show:!0,removeOnClose:!0});else{if(Object.keys(table_obj_list).length>0){var table=table_obj_list[Object.keys(table_obj_list)[0]];if(table.row){var current_row_data=table.row("#"+current_rowid).data(),submissiondateindex=table.column(".tableheaddate").index(),current_moderation_cell_data=data_response.content;current_row_data[submissiondateindex]=current_moderation_cell_data;var table_row=table.row("#"+current_rowid);table_row.data(current_row_data);var dom_row=$("#"+current_rowid);dom_row.find(".time_submitted_cell").attr("data-order",current_moderation_cell_data["@data-order"]),dom_row.find(".edit_personal_deadline").remove(),table_row.invalidate(),$("#extension-id").val(data_response.data.id)}}change__status_extension_submit_button(!0),save_extension_form_data(),Modal.create({title:datatables_lang_messages.notification_info,body:datatables_lang_messages.alert_extension_save_successful.replace(/\_/g," "),show:!0,removeOnClose:!0})}},error:function(){$("html, body").css("cursor","auto")},complete:function(){$("html, body").css("cursor","auto")}})})),$("#modal-ajax").on("hide.bs.modal",(function(){var self=this;if(is_data_extension_form_change()){var confirm=new M.core.confirm({title:datatables_lang_messages.notification_leave_form_title.replace(/\_/g," "),question:datatables_lang_messages.notification_leave_form_message.replace(/\_/g," "),yesLabel:datatables_lang_messages.notification_yes_label,noLabel:datatables_lang_messages.notification_no_label});return confirm.on("complete-yes",(function(){save_extension_form_data(),confirm.hide(),confirm.destroy(),$(self).modal("hide")})),confirm.on("complete-no",(function(){return confirm.hide(),confirm.destroy(),!1})),confirm.show(),!1}return!0})),$(".modal-footer").on("click","#extension-next",(function(e,table_obj_list){if(e.preventDefault(),is_data_extension_form_change()){var confirm=new M.core.confirm({title:datatables_lang_messages.notification_leave_form_title.replace(/\_/g," "),question:datatables_lang_messages.notification_leave_form_message.replace(/\_/g," "),yesLabel:datatables_lang_messages.notification_yes_label,noLabel:datatables_lang_messages.notification_no_label});confirm.on("complete-yes",(function(table_obj_list){if(confirm.hide(),confirm.destroy(),Object.keys(table_obj_list).length>0){var prev_rowid=$("#button-id").val(),table=table_obj_list[Object.keys(table_obj_list)[0]],current_row_index=table.row("#"+prev_rowid).index()+1;if(table.row(current_row_index)){var current_row_data=table.row(current_row_index).data();if(current_row_data){var current_rowid=table.row(current_row_index).id(),current_cell_data=current_row_data[table.column(".tableheaddate").index()];if(current_cell_data){var tmp_node=$("
").html(current_cell_data.display),submisiondate=$(tmp_node).find(".new_deadline_extension");if(submisiondate.length>0){var data_params=JSON.parse(submisiondate.attr("data-params"));extension_new_change_data_form(submisiondate.attr("data-name"),data_params,JSON.parse(submisiondate.attr("data-time")),current_rowid)}else{submisiondate=$(tmp_node).find(".edit_deadline_extension");data_params=JSON.parse(submisiondate.attr("data-params"));extension_edit_change_data_form(submisiondate.attr("data-name"),data_params,JSON.parse(submisiondate.attr("data-time")),current_rowid)}}}else $("#extension-next").prop("disabled",!0),Modal.create({title:datatables_lang_messages.notification_info,body:datatables_lang_messages.alert_no_extension.replace(/\_/g," "),show:!0,removeOnClose:!0})}}})),confirm.on("complete-no",(function(){confirm.hide(),confirm.destroy()})),confirm.show()}else if(Object.keys(table_obj_list).length>0){var prev_rowid=$("#button-id").val(),table=table_obj_list[Object.keys(table_obj_list)[0]],ordereddata=table.rows({order:"applied",search:"applied"}).data().toArray(),current_row_index=ordereddata.findIndex(compare_row,prev_rowid)+1;if(table.row(current_row_index)){var current_row_data=ordereddata[current_row_index];if(void 0!==current_row_data){var current_rowid=current_row_data.DT_RowId,current_cell_data=current_row_data[table.column(".tableheaddate").index()];if(current_cell_data){var tmp_node=$("
").html(current_cell_data.display),submisiondate=$(tmp_node).find(".new_deadline_extension");if(submisiondate.length>0){var data_params=JSON.parse(submisiondate.attr("data-params"));extension_new_change_data_form(submisiondate.attr("data-name"),data_params,JSON.parse(submisiondate.attr("data-time")),current_rowid)}else{submisiondate=$(tmp_node).find(".edit_deadline_extension");data_params=JSON.parse(submisiondate.attr("data-params"));extension_edit_change_data_form(submisiondate.attr("data-name"),data_params,JSON.parse(submisiondate.attr("data-time")),current_rowid)}}}else $("#extension-next").prop("disabled",!0),Modal.create({title:datatables_lang_messages.notification_info,body:datatables_lang_messages.alert_no_mitigation.replace(/\_/g," "),show:!0,removeOnClose:!0})}}})),$(".modal-footer").on("click","#extension-back",(function(e,table_obj_list){if(e.preventDefault(),is_data_extension_form_change()){var confirm=new M.core.confirm({title:datatables_lang_messages.notification_leave_form_title.replace(/\_/g," "),question:datatables_lang_messages.notification_leave_form_message.replace(/\_/g," "),yesLabel:datatables_lang_messages.notification_yes_label,noLabel:datatables_lang_messages.notification_no_label});confirm.on("complete-yes",(function(table_obj_list){if(confirm.hide(),confirm.destroy(),Object.keys(table_obj_list).length>0){var prev_rowid=$("#button-id").val(),table=table_obj_list[Object.keys(table_obj_list)[0]],current_row_index=table.row("#"+prev_rowid).index()-1;if(table.row(current_row_index)){var current_row_data=table.row(current_row_index).data();if(current_row_data){var current_rowid=table.row(current_row_index).id(),current_cell_data=current_row_data[table.column(".tableheaddate").index()];if(current_cell_data){var tmp_node=$("
").html(current_cell_data.display),submisiondate=$(tmp_node).find(".new_deadline_extension");if(submisiondate.length>0){var data_params=JSON.parse(submisiondate.attr("data-params"));extension_new_change_data_form(submisiondate.attr("data-name"),data_params,JSON.parse(submisiondate.attr("data-time")),current_rowid)}else{submisiondate=$(tmp_node).find(".edit_deadline_extension");data_params=JSON.parse(submisiondate.attr("data-params"));extension_edit_change_data_form(submisiondate.attr("data-name"),data_params,JSON.parse(submisiondate.attr("data-time")),current_rowid)}}}else $("#extension-back").prop("disabled",!0),Modal.create({title:datatables_lang_messages.notification_info,body:datatables_lang_messages.alert_no_mitigation.replace(/\_/g," "),show:!0,removeOnClose:!0})}}})),confirm.on("complete-no",(function(){confirm.hide(),confirm.destroy()})),confirm.show()}else if(Object.keys(table_obj_list).length>0){var prev_rowid=$("#button-id").val(),table=table_obj_list[Object.keys(table_obj_list)[0]],ordereddata=table.rows({order:"applied",search:"applied"}).data().toArray(),current_row_index=ordereddata.findIndex(compare_row,prev_rowid)-1;if(table.row(current_row_index)){var current_row_data=ordereddata[current_row_index];if(void 0!==current_row_data){var current_rowid=current_row_data.DT_RowId,current_cell_data=current_row_data[table.column(".tableheaddate").index()];if(current_cell_data){var tmp_node=$("
").html(current_cell_data.display),submisiondate=$(tmp_node).find(".new_deadline_extension");if(submisiondate.length>0){var data_params=JSON.parse(submisiondate.attr("data-params"));extension_new_change_data_form(submisiondate.attr("data-name"),data_params,JSON.parse(submisiondate.attr("data-time")),current_rowid)}else{submisiondate=$(tmp_node).find(".edit_deadline_extension");data_params=JSON.parse(submisiondate.attr("data-params"));extension_edit_change_data_form(submisiondate.attr("data-name"),data_params,JSON.parse(submisiondate.attr("data-time")),current_rowid)}}}else $("#extension-back").prop("disabled",!0),Modal.create({title:datatables_lang_messages.notification_info,body:datatables_lang_messages.alert_no_mitigation.replace(/\_/g," "),show:!0,removeOnClose:!0})}}})),$("#form-extension :input").change((function(){extension_form_change=!0,change__status_extension_submit_button(!1)})),$(".datatabletest").on("click",".new_final_feedback, .new_feedback, .edit_final_feedback, .edit_feedback, .show_feedback",(function(e){e.preventDefault();var url=$(this).attr("href");$.ajax({type:"GET",url:url+"&ajax=1"}).done((function(response){var _response$success,_response$message;response=$.parseJSON(response);var modalbody=$("#modal-grading").find(".modal-body");if(!1===(null===(_response$success=response.success)||void 0===_response$success||_response$success)&&null!==(_response$message=response.message)&&void 0!==_response$message&&_response$message)modalbody.html(response.message);else{modalbody.html(response.formhtml);var filemanager=modalbody.find(".filemanager");if(response.filemanageroptions&&filemanager.length){var clientid=filemanager.attr("id").substr(12);clientid&&(response.filemanageroptions.client_id=clientid,M.form_filemanager.init(Y,response.filemanageroptions))}response.editoroptions&&require(["editor_tiny/editor"],(Tiny=>{Tiny.setupForElementId({elementId:"id_feedbackcomment",options:JSON.parse(response.editoroptions)})})),response.commentoptions&&(M.util.js_pending("gradingform_guide/comment_chooser"),require(["gradingform_guide/comment_chooser"],(function(amd){$(".remark").each((function(i,ele){var buttonele=$(ele).find(".commentchooser"),textele=$(ele).find(".markingguideremark"),buttonid=$(buttonele).attr("id"),textid=$(textele).attr("id");amd.initialise(1,buttonid,textid,response.commentoptions),M.util.js_complete("gradingform_guide/comment_chooser")}))})))}}));var cell_td=$(this).closest("td");!function(cell_selector,cell_type){var modal=$("#modal-grading");modal.find("#cell_selector").val(cell_selector),modal.find("#cell_type").val(cell_type),modal.find(".modal-body").html(' loading'),$("#modal-grading").modal("show")}(function(td_cell){var result="."+td_cell.attr("class").replaceAll(" ","."),tr_cell=td_cell.closest("tr");result=tr_cell.attr("id")?"#"+tr_cell.attr("id")+" "+result:"."+tr_cell.attr("class").replaceAll(" ",".")+" "+result;return result}(cell_td),cell_td.attr("data-class-name"))})),$("#modal-grading").on("click","#id_submitfeedbackbutton, #id_submitbutton",(function(e){e.preventDefault();var button=$(this);button.prop("disabled",!0);for(var submitbutton="id_submitbutton"==button.attr("id")?1:0,removefeedbackbutton="id_removefeedbackbutton"==button.attr("id")?1:0,submitfeedbackbutton="id_submitfeedbackbutton"==button.attr("id")?1:0,modal=$("#modal-grading"),url="/mod/coursework/actions/feedbacks/create.php",form_data=modal.find("form").serializeArray(),i=0,length=form_data.length;i {\n if (table_obj_list) {\n for (var table_id in table_obj_list) {\n table_obj_list[table_id].state.save();\n }\n }\n });\n $(document).ready(function () {\n /**\n *\n * @param {object} tr\n */\n function log_datatable_navigate(tr) {\n var row_id = tr.attr('id');\n var tableid = tr.closest('table').attr('id');\n var key = 'datatable_navigate_' + window.location.href + tableid;\n localStorage.setItem(key, row_id);\n }\n\n /* plagiarism flag */\n $('.datatabletest').on('click', '.new_plagiarism_flag', function() {\n log_datatable_navigate($(this).closest('tr'));\n });\n\n $('.datatabletest').on('click', '.edit_plagiarism_flag', function() {\n log_datatable_navigate($(this).closest('tr'));\n });\n\n /* feedback */\n $('.datatabletest').on('click', '.new_final_feedback', function() {\n log_datatable_navigate($(this).closest('tr'));\n });\n\n $('.datatabletest').on('click', '.edit_final_feedback', function() {\n log_datatable_navigate($(this).closest('tr'));\n });\n\n $('.datatabletest').on('click', '.show_feedback', function() {\n log_datatable_navigate($(this).closest('tr'));\n });\n\n /* assessor feedback */\n $('.datatabletest').on('click', '.assessor_feedback_grade .new_feedback', function() {\n log_datatable_navigate($(this).closest('td.assessors').closest('table.assessors').closest('tr').prev());\n });\n\n $('.datatabletest').on('click', '.assessor_feedback_grade .show_feedback', function() {\n log_datatable_navigate($(this).closest('td.assessors').closest('table.assessors').closest('tr').prev());\n });\n\n $('.datatabletest').on('click', '.assessor_feedback_grade .edit_feedback', function() {\n log_datatable_navigate($(this).closest('td.assessors').closest('table.assessors').closest('tr').prev());\n });\n\n /* deadline extension */\n $('.datatabletest').on('click', '.new_deadline_extension', function() {\n log_datatable_navigate($(this).closest('tr'));\n });\n\n $('.datatabletest').on('click', '.edit_deadline_extension', function() {\n log_datatable_navigate($(this).closest('tr'));\n });\n\n /* submission */\n $('.datatabletest').on('click', '.new_submission', function() {\n log_datatable_navigate($(this).closest('tr'));\n });\n\n // Prepare Message\n var datatables_lang_messages = JSON.parse($('#datatables_lang_messages').attr('data-lang'));\n\n /**\n * Personal Deadline\n */\n $('.datatabletest').on('click', '.edit_personal_deadline',function (e) {\n e.preventDefault();\n var parent = $(this).closest('.personal_deadline_cell');\n parent.children('.show_personal_dealine').addClass('display-none');\n var change_form = parent.children('.show_edit_personal_dealine');\n var data_get = $(this).attr('data-get');\n var data_time = $(this).attr('data-time-iso-8601');\n if (change_form.html().length === 1) {\n var form = '';\n form += '
';\n form += '' +\n '
';\n $(change_form).html(form);\n }\n $(change_form).removeClass('display-none');\n });\n\n $('.datatabletest').on('click', '.cancel-personal-deadline', function (e) {\n e.preventDefault();\n $(this).closest('.show_edit_personal_dealine').addClass('display-none');\n $(this).closest('.personal_deadline_cell').children('.show_personal_dealine').removeClass('display-none');\n });\n\n $('.datatabletest').on('click', '.approve-personal-deadline', function (e) {\n e.preventDefault();\n var deadline = $(this);\n var data_get = $(deadline).attr('data-get');\n var value = $(deadline).closest('.show_edit_personal_dealine').children('.input-personal-deadline').val();\n var input_date = new Date(value);\n if (input_date <= Date.parse(now)) {\n Modal.create({\n title: datatables_lang_messages.notification_info,\n body: datatables_lang_messages.alert_validate_deadline.replace(/\\_/g, ' '),\n show: true,\n removeOnClose: true,\n });\n }\n\n var url = datatables_lang_messages.url_root + \"/mod/coursework/actions/personal_deadline.php\";\n var param = JSON.parse(data_get);\n param.personal_deadline_time = value;\n\n $.ajax({\n type: \"POST\",\n url: url,\n data: param,\n beforeSend: function () {\n $('html, body').css(\"cursor\", \"wait\");\n $(self).prev('img').css('visibility', 'visible');\n },\n success: function (response, table_obj_list) {\n $('html, body').css(\"cursor\", \"auto\");\n var data_response = JSON.parse(response);\n if (data_response.error == 1) {\n Modal.create({\n title: datatables_lang_messages.notification_info,\n body: data_response.message,\n show: true,\n removeOnClose: true,\n });\n } else {\n var parent = $(deadline).closest('.personal_deadline_cell');\n $(parent).attr('data-order', data_response.timestamp);\n var table = table_obj_list[Object.keys(table_obj_list)[0]];\n table.row('#' + $(parent).closest('tr').attr('id')).invalidate();\n\n $(parent).children('.show_personal_dealine').children('.content_personal_deadline').\n html(data_response.time);\n $(parent).children('.show_edit_personal_dealine').addClass('display-none');\n $(parent).children('.show_personal_dealine').removeClass('display-none');\n Modal.create({\n title: datatables_lang_messages.notification_info,\n body: datatables_lang_messages.alert_personaldeadline_save_successful.replace(/\\_/g, ' '),\n show: true,\n removeOnClose: true,\n });\n }\n },\n error: function () {\n $('html, body').css(\"cursor\", \"auto\");\n },\n complete: function () {\n $('html, body').css(\"cursor\", \"auto\");\n }\n });\n\n });\n\n /***************************\n * Extensions\n */\n\n /**\n * Add new extension\n */\n $('.datatabletest').on('click', '.new_deadline_extension', function (e) {\n e.preventDefault();\n var data_name = $(this).attr('data-name');\n var data_params = JSON.parse($(this).attr('data-params'));\n var data_time = JSON.parse($(this).attr('data-time'));\n var current_rowid = $(this).closest('tr').attr('id');\n extension_new_change_data_form(data_name, data_params, data_time, current_rowid);\n $('#modal-ajax').modal('show');\n });\n\n /**\n * Edit extensions\n */\n $('.datatabletest').on('click', '.edit_deadline_extension', function (e) {\n\n e.preventDefault();\n var data_name = $(this).attr('data-name');\n var data_params = JSON.parse($(this).attr('data-params'));\n var data_time = JSON.parse($(this).attr('data-time'));\n var current_rowid = $(this).closest('tr').attr('id');\n extension_edit_change_data_form(data_name, data_params, data_time, current_rowid);\n $('#modal-ajax').modal('show');\n });\n\n /**\n * Submit save extension\n */\n $('.modal-footer').on('click', '#extension-submit', function (e) {\n e.preventDefault();\n var params = {};\n params.allocatabletype = $('#extension-allocatabletype').val();\n params.allocatableid = $('#extension-allocatableid').val();\n params.courseworkid = $('#extension-courseworkid').val();\n params.id = $('#extension-id').val();\n params.extended_deadline = $('#extension-extend-deadline').val();\n params.editor = $('#extension-time-content').html();\n params.text = $('#id_extra_information').val();\n params.submissionid = $('#extension-submissionid').val();\n params.pre_defined_reason = $('#extension-reason-select').val();\n params.requesttype = 'submit';\n var current_rowid = $('#button-id').val();\n var url = datatables_lang_messages.url_root;\n $.ajax({\n type: \"POST\",\n url: url + \"/mod/coursework/actions/ajax/deadline_extension/submit.php\",\n data: params,\n beforeSend: function () {\n $('html, body').css(\"cursor\", \"wait\");\n $('.modal-footer').children('img').css('visibility', 'visible');\n },\n success: function (response, table_obj_list) {\n var data_response = JSON.parse(response);\n $('html, body').css(\"cursor\", \"auto\");\n $('.modal-footer').children('img').css('visibility', 'hidden');\n if (data_response.error == 1) {\n Modal.create({\n title: datatables_lang_messages.notification_info,\n body: data_response.messages,\n show: true,\n removeOnClose: true,\n });\n } else {\n if (Object.keys(table_obj_list).length > 0) {\n // Get the first datatable object.\n var table = table_obj_list[Object.keys(table_obj_list)[0]];\n if (table.row) {\n var current_row_data = table.row('#' + current_rowid).data();\n var submissiondateindex = table.column('.tableheaddate').index();\n var current_moderation_cell_data = data_response.content;\n current_row_data[submissiondateindex] = current_moderation_cell_data;\n var table_row = table.row('#' + current_rowid);\n table_row.data(current_row_data);\n var dom_row = $('#' + current_rowid);\n dom_row.find('.time_submitted_cell').attr('data-order',\n current_moderation_cell_data['@data-order']);\n dom_row.find('.edit_personal_deadline').remove();\n table_row.invalidate();\n $('#extension-id').val(data_response.data.id);\n }\n }\n\n change__status_extension_submit_button(true);\n save_extension_form_data();\n\n Modal.create({\n title: datatables_lang_messages.notification_info,\n body: datatables_lang_messages.alert_extension_save_successful.replace(/\\_/g, ' '),\n show: true,\n removeOnClose: true,\n });\n\n }\n },\n error: function () {\n $('html, body').css(\"cursor\", \"auto\");\n },\n complete: function () {\n $('html, body').css(\"cursor\", \"auto\");\n }\n });\n });\n\n\n /**\n * Function close button\n */\n $('#modal-ajax').on('hide.bs.modal', function() {\n var self = this;\n if(is_data_extension_form_change()) {\n var confirm = new M.core.confirm({\n title: datatables_lang_messages.notification_leave_form_title.replace(/\\_/g, ' '),\n question: datatables_lang_messages.notification_leave_form_message.replace(/\\_/g, ' '),\n yesLabel: datatables_lang_messages.notification_yes_label,\n noLabel: datatables_lang_messages.notification_no_label,\n });\n\n confirm.on('complete-yes',function() {\n save_extension_form_data();\n confirm.hide();\n confirm.destroy();\n $(self).modal('hide');\n });\n\n confirm.on('complete-no',function() {\n confirm.hide();\n confirm.destroy();\n return false;\n });\n\n confirm.show();\n return false;\n }\n return true;\n });\n\n /**\n * Function next button\n */\n $('.modal-footer').on('click', '#extension-next', function (e, table_obj_list) {\n e.preventDefault();\n\n if (is_data_extension_form_change()) {\n var confirm = new M.core.confirm({\n title: datatables_lang_messages.notification_leave_form_title.replace(/\\_/g, ' '),\n question: datatables_lang_messages.notification_leave_form_message.replace(/\\_/g, ' '),\n yesLabel: datatables_lang_messages.notification_yes_label,\n noLabel: datatables_lang_messages.notification_no_label,\n });\n\n confirm.on('complete-yes', function(table_obj_list) {\n confirm.hide();\n confirm.destroy();\n if (Object.keys(table_obj_list).length > 0) {\n\n var prev_rowid = $('#button-id').val();\n\n // Get the first datatable object.\n var table = table_obj_list[Object.keys(table_obj_list)[0]];\n\n var prev_row_index = table.row('#' + prev_rowid).index();\n\n\n var current_row_index = prev_row_index + 1;\n\n if (table.row(current_row_index)) {\n var current_row_data = table.row(current_row_index).data();\n if (current_row_data) {\n var current_rowid = table.row(current_row_index).id();\n\n var submissiondateindex = table.column('.tableheaddate').index();\n var current_cell_data = current_row_data[submissiondateindex];\n if (current_cell_data) {\n var tmp_node = $('
').html(current_cell_data.display);\n var submisiondate = $(tmp_node).find('.new_deadline_extension');\n if (submisiondate.length > 0) {\n var data_params = JSON.parse(submisiondate.attr('data-params'));\n var data_name = submisiondate.attr('data-name');\n var data_time = JSON.parse(submisiondate.attr('data-time'));\n extension_new_change_data_form(data_name, data_params, data_time, current_rowid);\n } else {\n submisiondate = $(tmp_node).find('.edit_deadline_extension');\n var data_params = JSON.parse(submisiondate.attr('data-params'));\n var data_name = submisiondate.attr('data-name');\n var data_time = JSON.parse(submisiondate.attr('data-time'));\n extension_edit_change_data_form(data_name, data_params, data_time, current_rowid);\n }\n }\n }\n else {\n $('#extension-next').prop('disabled', true);\n Modal.create({\n title: datatables_lang_messages.notification_info,\n body: datatables_lang_messages.alert_no_extension.replace(/\\_/g, ' '),\n show: true,\n removeOnClose: true,\n });\n }\n }\n }\n });\n\n confirm.on('complete-no', function () {\n confirm.hide();\n confirm.destroy();\n\n });\n\n confirm.show();\n } else {\n if (Object.keys(table_obj_list).length > 0) {\n\n var prev_rowid = $('#button-id').val();\n\n // Get the first datatable object.\n var table = table_obj_list[Object.keys(table_obj_list)[0]];\n\n var ordereddata = table.rows( { order: 'applied', search: 'applied' } ).data().toArray();\n var prev_row_index = ordereddata.findIndex(compare_row, prev_rowid);\n\n\n var current_row_index = prev_row_index + 1;\n\n if (table.row(current_row_index)) {\n var current_row_data = ordereddata[current_row_index];\n if (typeof current_row_data != 'undefined') {\n var current_rowid = current_row_data.DT_RowId;\n\n var submissiondateindex = table.column('.tableheaddate').index();\n var current_cell_data = current_row_data[submissiondateindex];\n if (current_cell_data) {\n var tmp_node = $('
').html(current_cell_data.display);\n var submisiondate = $(tmp_node).find('.new_deadline_extension');\n if (submisiondate.length > 0) {\n var data_params = JSON.parse(submisiondate.attr('data-params'));\n var data_name = submisiondate.attr('data-name');\n var data_time = JSON.parse(submisiondate.attr('data-time'));\n extension_new_change_data_form(data_name, data_params, data_time, current_rowid);\n } else {\n submisiondate = $(tmp_node).find('.edit_deadline_extension');\n var data_params = JSON.parse(submisiondate.attr('data-params'));\n var data_name = submisiondate.attr('data-name');\n var data_time = JSON.parse(submisiondate.attr('data-time'));\n extension_edit_change_data_form(data_name, data_params, data_time, current_rowid);\n }\n }\n }\n else {\n $('#extension-next').prop('disabled', true);\n Modal.create({\n title: datatables_lang_messages.notification_info,\n body: datatables_lang_messages.alert_no_mitigation.replace(/\\_/g, ' '),\n show: true,\n removeOnClose: true,\n });\n }\n }\n }\n }\n\n\n });\n\n /**\n * Function back button\n */\n $('.modal-footer').on('click', '#extension-back', function (e, table_obj_list) {\n e.preventDefault();\n if (is_data_extension_form_change()) {\n var confirm = new M.core.confirm({\n title: datatables_lang_messages.notification_leave_form_title.replace(/\\_/g, ' '),\n question: datatables_lang_messages.notification_leave_form_message.replace(/\\_/g, ' '),\n yesLabel: datatables_lang_messages.notification_yes_label,\n noLabel: datatables_lang_messages.notification_no_label,\n });\n\n confirm.on('complete-yes', function (table_obj_list) {\n confirm.hide();\n confirm.destroy();\n if (Object.keys(table_obj_list).length > 0) {\n\n var prev_rowid = $('#button-id').val();\n\n // Get the first datatable object.\n var table = table_obj_list[Object.keys(table_obj_list)[0]];\n\n var prev_row_index = table.row('#' + prev_rowid).index();\n\n\n var current_row_index = prev_row_index - 1;\n\n if (table.row(current_row_index)) {\n var current_row_data = table.row(current_row_index).data();\n if (current_row_data) {\n var current_rowid = table.row(current_row_index).id();\n\n var submissiondateindex = table.column('.tableheaddate').index();\n var current_cell_data = current_row_data[submissiondateindex];\n if (current_cell_data) {\n var tmp_node = $('
').html(current_cell_data.display);\n var submisiondate = $(tmp_node).find('.new_deadline_extension');\n if (submisiondate.length > 0) {\n var data_params = JSON.parse(submisiondate.attr('data-params'));\n var data_name = submisiondate.attr('data-name');\n var data_time = JSON.parse(submisiondate.attr('data-time'));\n extension_new_change_data_form(data_name, data_params, data_time, current_rowid);\n } else {\n submisiondate = $(tmp_node).find('.edit_deadline_extension');\n var data_params = JSON.parse(submisiondate.attr('data-params'));\n var data_name = submisiondate.attr('data-name');\n var data_time = JSON.parse(submisiondate.attr('data-time'));\n extension_edit_change_data_form(data_name, data_params, data_time, current_rowid);\n }\n }\n }\n else {\n $('#extension-back').prop('disabled', true);\n Modal.create({\n title: datatables_lang_messages.notification_info,\n body: datatables_lang_messages.alert_no_mitigation.replace(/\\_/g, ' '),\n show: true,\n removeOnClose: true,\n });\n }\n }\n }\n });\n\n confirm.on('complete-no', function () {\n confirm.hide();\n confirm.destroy();\n });\n\n confirm.show();\n } else {\n if (Object.keys(table_obj_list).length > 0) {\n\n var prev_rowid = $('#button-id').val();\n\n // Get the first datatable object.\n var table = table_obj_list[Object.keys(table_obj_list)[0]];\n\n var ordereddata = table.rows( { order: 'applied', search: 'applied' } ).data().toArray();\n var prev_row_index = ordereddata.findIndex(compare_row, prev_rowid);\n\n\n var current_row_index = prev_row_index - 1;\n\n if (table.row(current_row_index)) {\n var current_row_data = ordereddata[current_row_index];\n if (typeof current_row_data != 'undefined') {\n var current_rowid = current_row_data.DT_RowId;\n\n var submissiondateindex = table.column('.tableheaddate').index();\n var current_cell_data = current_row_data[submissiondateindex];\n if (current_cell_data) {\n var tmp_node = $('
').html(current_cell_data.display);\n var submisiondate = $(tmp_node).find('.new_deadline_extension');\n if (submisiondate.length > 0) {\n var data_params = JSON.parse(submisiondate.attr('data-params'));\n var data_name = submisiondate.attr('data-name');\n var data_time = JSON.parse(submisiondate.attr('data-time'));\n extension_new_change_data_form(data_name, data_params, data_time, current_rowid);\n } else {\n submisiondate = $(tmp_node).find('.edit_deadline_extension');\n var data_params = JSON.parse(submisiondate.attr('data-params'));\n var data_name = submisiondate.attr('data-name');\n var data_time = JSON.parse(submisiondate.attr('data-time'));\n extension_edit_change_data_form(data_name, data_params, data_time, current_rowid);\n }\n }\n }\n else {\n $('#extension-back').prop('disabled', true);\n Modal.create({\n title: datatables_lang_messages.notification_info,\n body: datatables_lang_messages.alert_no_mitigation.replace(/\\_/g, ' '),\n show: true,\n removeOnClose: true,\n });\n }\n }\n }\n }\n\n\n });\n\n /**\n *\n * @param {string} data_name\n * @param {object} data_params\n * @param {string} data_time\n * @param {string} current_rowid\n */\n function extension_edit_change_data_form(data_name, data_params, data_time, current_rowid) {\n var title = 'Editing the extension for ' + data_name;\n var time_content = 'Default deadline: ' + data_time.time_content;\n $('#extension-modal-title').html(title);\n $('#form-extension').find('input[type=hidden]').val(\"\");\n $('#form-extension').find('textarea').val(\"\");\n $('#button-id').val(current_rowid);\n $('#extension-submissionid').val(data_params.submissionid);\n $('#extension-name').val(data_name);\n data_params.requesttype = 'edit';\n var url = datatables_lang_messages.url_root;\n $.ajax({\n type: \"GET\",\n url: url + \"/mod/coursework/actions/ajax/deadline_extension/edit.php\",\n data: data_params,\n beforeSend: function () {\n change__status_extension_submit_button(true);\n $('html, body').css(\"cursor\", \"wait\");\n $('.modal-footer').children('img').css('visibility', 'visible');\n },\n success: function (response) {\n var data_response = JSON.parse(response);\n $('html, body').css(\"cursor\", \"auto\");\n $('.modal-footer').children('img').css('visibility', 'hidden');\n if (data_response.error == 1) {\n Modal.create({\n title: datatables_lang_messages.notification_info,\n body: data_response.message + ' .Please reload the page!',\n show: true,\n removeOnClose: true,\n });\n } else {\n var extension = data_response.data;\n if (extension.time_content) {\n $('#extension-time-content').html(extension.time_content);\n } else {\n $('#extension-time-content').html(time_content);\n }\n document.getElementById('extension-extend-deadline').\n value = data_response.data.time_iso_8601.slice(0,16);\n $('#extension-reason-select').val(extension.pre_defined_reason);\n $('#extension-allocatabletype').val(extension.allocatabletype);\n $('#extension-allocatableid').val(extension.allocatableid);\n $('#extension-courseworkid').val(extension.courseworkid);\n $('#extension-id').val(extension.id);\n\n $('#id_extra_information').val(extension.text);\n\n $('#id_extra_information').prop('disabled', false);\n $('#extension-extend-deadline').prop('disabled', false);\n $('#extension-reason-select').prop('disabled', false);\n save_extension_form_data();\n }\n },\n error: function () {\n $('html, body').css(\"cursor\", \"auto\");\n change__status_extension_submit_button(false);\n },\n complete: function () {\n $('html, body').css(\"cursor\", \"auto\");\n change__status_extension_submit_button(false);\n }\n });\n }\n\n /**\n *\n * @param {string} data_name\n * @param {object} data_params\n * @param {string} data_time\n * @param {string} current_rowid\n */\n function extension_new_change_data_form(data_name, data_params, data_time, current_rowid) {\n var title = 'New extension for ' + data_name;\n $('#extension-modal-title').html(title);\n $('#form-extension').find('input[type=hidden]').val('');\n $('#form-extension').find('textarea').val('');\n\n if(data_time.is_have_deadline == '1') {\n var url = datatables_lang_messages.url_root;\n $.ajax({\n type: \"GET\",\n url: url + \"/mod/coursework/actions/ajax/deadline_extension/new.php\",\n data: data_params,\n beforeSend: function () {\n change__status_extension_submit_button(true);\n $('html, body').css(\"cursor\", \"wait\");\n $('.modal-footer').children('img').css('visibility', 'visible');\n },\n success: function (response) {\n $('html, body').css(\"cursor\", \"auto\");\n $('.modal-footer').children('img').css('visibility', 'hidden');\n var data_response = JSON.parse(response);\n $('#extension-time-content').html(data_response.data.time_content);\n document.getElementById('extension-extend-deadline').\n value = data_response.data.time_iso_8601.slice(0,16);\n save_extension_form_data();\n },\n error: function () {\n $('html, body').css(\"cursor\", \"auto\");\n },\n complete: function () {\n $('html, body').css(\"cursor\", \"auto\");\n }\n });\n } else {\n save_extension_form_data();\n }\n $('#extension-reason-select').val('');\n $('#extension-allocatabletype').val(data_params.allocatabletype);\n $('#extension-allocatableid').val(data_params.allocatableid);\n $('#extension-courseworkid').val(data_params.courseworkid);\n $('#extension-submissionid').val(data_params.submissionid);\n $('#extension-name').val(data_name);\n $('#button-id').val(current_rowid);\n\n $('#id_extra_information').prop('disabled', false);\n $('#extension-extend-deadline').prop('disabled', false);\n $('#extension-reason-select').prop('disabled', false);\n }\n\n\n $(\"#form-extension :input\").change(function () {\n extension_form_change = true;\n change__status_extension_submit_button(false);\n });\n\n /**\n *\n * @param {string} status\n */\n function change__status_extension_submit_button(status) {\n $('#extension-submit').prop('disabled', status);\n }\n\n /**\n *\n */\n function save_extension_form_data() {\n extension_form_change = false;\n }\n\n /**\n *\n */\n function is_data_extension_form_change() {\n return extension_form_change;\n }\n\n /**\n * Feedback\n */\n $('.datatabletest').on('click', '.new_final_feedback, .new_feedback,' +\n ' .edit_final_feedback, .edit_feedback, .show_feedback', function (e) {\n e.preventDefault();\n var url = $(this).attr('href');\n $.ajax({\n type: \"GET\",\n url: url+'&ajax=1'\n }).done(function(response) {\n response = $.parseJSON(response);\n var modalbody = $('#modal-grading').find('.modal-body');\n // Careful as not all requests return a response.success value. Only if it's false, show error.\n if ((response.success ?? true) === false && (response.message ?? null)) {\n modalbody.html(response.message);\n } else {\n modalbody.html(response.formhtml);\n var filemanager = modalbody.find('.filemanager');\n if (response.filemanageroptions && filemanager.length) {\n var elementid = filemanager.attr('id');\n var clientid = elementid.substr(12);\n if (clientid) {\n response.filemanageroptions.client_id = clientid;\n M.form_filemanager.init(Y, response.filemanageroptions);\n }\n }\n if (response.editoroptions) {\n require(['editor_tiny/editor'], (Tiny) => {\n Tiny.setupForElementId({\n elementId: 'id_feedbackcomment',\n options: JSON.parse(response.editoroptions),\n });\n });\n }\n\n if (response.commentoptions) {\n M.util.js_pending('gradingform_guide/comment_chooser');\n require(['gradingform_guide/comment_chooser'], function(amd) {\n $(\".remark\").each( function (i,ele) {\n var buttonele = $(ele).find(\".commentchooser\");\n var textele = $(ele).find(\".markingguideremark\");\n var buttonid = $(buttonele).attr(\"id\");\n var textid = $(textele).attr(\"id\");\n amd.initialise(1, buttonid, textid, response.commentoptions);\n M.util.js_complete('gradingform_guide/comment_chooser');\n\n });\n\n });\n }\n }\n });\n var cell_td = $(this).closest('td');\n var cell_selector = get_td_cell_selector(cell_td);\n var cell_type = cell_td.attr('data-class-name');\n show_loading_modal_grading(cell_selector, cell_type);\n });\n\n /**\n *\n * @param {object} td_cell\n * @returns {string}\n */\n function get_td_cell_selector(td_cell) {\n var result = '.' + td_cell.attr('class').replaceAll(' ', '.');\n var tr_cell = td_cell.closest('tr');\n if (tr_cell.attr('id')) {\n result = '#' + tr_cell.attr('id') + ' ' + result;\n } else {\n result = '.' + tr_cell.attr('class').replaceAll(' ', '.') + ' ' + result;\n }\n return result;\n }\n\n /**\n *\n * @param {object} cell_selector\n * @param {object} cell_type\n */\n function show_loading_modal_grading(cell_selector, cell_type) {\n // Set row id.\n var modal = $('#modal-grading');\n modal.find('#cell_selector').val(cell_selector);\n modal.find('#cell_type').val(cell_type);\n modal.find('.modal-body').html(' loading');\n $('#modal-grading').modal('show');\n }\n\n $('#modal-grading').on('click', '#id_submitfeedbackbutton, #id_submitbutton', function (e) {\n e.preventDefault();\n var button = $(this);\n button.prop('disabled', true);\n var submitbutton = (button.attr('id') == 'id_submitbutton') ? 1 : 0;\n var removefeedbackbutton = (button.attr('id') == 'id_removefeedbackbutton') ? 1 : 0;\n var submitfeedbackbutton = (button.attr('id') == 'id_submitfeedbackbutton') ? 1 : 0;\n var modal = $('#modal-grading');\n var url = '/mod/coursework/actions/feedbacks/create.php';\n var form_data = modal.find('form').serializeArray();\n for (var i = 0, length = form_data.length; i < length; i++) {\n if (form_data[i].name == 'feedbackid' && !isNaN(parseInt(form_data[i].value)) &&\n form_data[i].value != '0') {\n url = '/mod/coursework/actions/feedbacks/update.php';\n break;\n }\n }\n var cell_type = modal.find('#cell_type').val();\n update_feedback(form_data,url,cell_type,submitbutton,removefeedbackbutton,submitfeedbackbutton,0,button);\n /*\n form_data = form_data.concat({name: 'ajax', value: 1},\n {name: 'cell_type', value: cell_type},\n {name: 'submitbutton', value: submitbutton},\n {name: 'removefeedbackbutton', value: removefeedbackbutton});\n $.ajax({\n type: 'POST',\n data: form_data,\n url: url,\n dataType: 'json'\n }).done(function(response) {\n console.log(response);\n if (response.success) {\n var cell_selector = modal.find('#cell_selector').val();\n $(cell_selector).html(response.html);\n $('#modal-grading').modal('hide');\n if (submitbutton == 1) {\n alert('Your data has been saved.');\n } else {\n alert('The feedback has been removed.');\n }\n } else {\n alert('Sorry! There was an error with your request.');\n }\n }).always(function() {\n me.prop('disabled', false);\n });*/\n });\n\n $('#modal-grading').on('click', '#id_cancel', function (e) {\n e.preventDefault();\n $('#modal-grading').modal('hide');\n });\n\n $('#modal-grading').on('click', '#id_removefeedbackbutton', function (e) {\n e.preventDefault();\n var button = $(this);\n button.prop('disabled', true);\n if (confirm('do you want to remove feedback')) {\n var submitbutton = (button.attr('id') == 'id_submitbutton') ? 1 : 0;\n var removefeedbackbutton = (button.attr('id') == 'id_removefeedbackbutton') ? 1 : 0;\n var submitfeedbackbutton = (button.attr('id') == 'id_submitfeedbackbutton') ? 1 : 0;\n var modal = $('#modal-grading');\n var url = '/mod/coursework/actions/feedbacks/update.php';\n var form_data = modal.find('form').serializeArray();\n var cell_type = modal.find('#cell_type').val();\n update_feedback(form_data, url, cell_type, submitbutton, removefeedbackbutton,\n submitfeedbackbutton,1, button);\n }\n });\n\n /**\n *\n * @param {object} form_data\n * @param {string} url\n * @param {string} celltype\n * @param {object} submitbutton\n * @param {object} removefeedbackbutton\n * @param {object} submitfeedbackbutton\n * @param {object} confirm\n * @param {object} button\n */\n function update_feedback(form_data, url, celltype, submitbutton, removefeedbackbutton,\n submitfeedbackbutton, confirm,button) {\n\n form_data = form_data.concat({name: 'ajax', value: 1},\n {name: 'cell_type', value: celltype},\n {name: 'submitbutton', value: submitbutton},\n {name: 'submitfeedbackbutton', value: submitfeedbackbutton},\n {name: 'removefeedbackbutton', value: removefeedbackbutton},\n {name: 'confirm', value: confirm});\n\n $.ajax({\n type: 'POST',\n data: form_data,\n url: url,\n dataType: 'json'\n }).done(function(response) {\n if ((response.success ?? true) === false && (response.message ?? null)) {\n // Could be an error like \"Please provide a valid grade for each criterion\".\n $('#modal-grading').find('.modal-body').html(\n '
' + response.message + '
'\n );\n } else if (response.success) {\n var cell_selector = $('#modal-grading').find('#cell_selector').val();\n $(cell_selector).html(response.html);\n\n if (typeof response.extrahtml !== 'undefined' && response.extrahtml != '') {\n $(cell_selector).next('td').html(response.extrahtml);\n }\n if (typeof response.assessdate !== 'undefined' && response.assessdate != '') {\n $(cell_selector).next('td').html(response.assessdate);\n }\n\n if (typeof response.assessorname !== 'undefined' && response.assessorname != '') {\n $(cell_selector).prev('td').html(response.assessorname);\n }\n\n if (typeof response.assessortwo !== 'undefined' && response.assessortwo != '') {\n var tdcell = $(cell_selector).closest('tr').next().find('td')[1];\n $(tdcell).html(response.assessortwo);\n }\n\n if (typeof response.finalhtml !== 'undefined' && response.assessortwo != '') {\n var tablerowid = 'allocatable_' + response.allocatableid;\n var tdcell2 = $('#' + tablerowid).find('.multiple_agreed_grade_cell')[0];\n $(tdcell2).html(response.finalhtml);\n }\n var datatables_lang_messages_two = JSON.parse($('#datatables_lang_messages').attr('data-lang'));\n $('#modal-grading').modal('hide');\n if (submitbutton === 1) {\n Modal.create({\n title: datatables_lang_messages_two.notification_info,\n body: datatables_lang_messages_two.alert_feedback_save_successful.replace(/\\_/g, ' '),\n show: true,\n removeOnClose: true,\n });\n\n } else if (submitfeedbackbutton === 1) {\n Modal.create({\n title: datatables_lang_messages_two.notification_info,\n body: datatables_lang_messages_two.alert_feedback_draft_save_successful.replace(/\\_/g, ' '),\n show: true,\n removeOnClose: true,\n });\n\n } else {\n Modal.create({\n title: datatables_lang_messages_two.notification_info,\n body: datatables_lang_messages_two.alert_feedback_remove_successful.replace(/\\_/g, ' '),\n show: true,\n removeOnClose: true,\n });\n }\n } else {\n Modal.create({\n title: datatables_lang_messages_two.notification_info,\n body: response.message,\n show: true,\n removeOnClose: true,\n });\n\n// error_wrapper_element.prepend('
' + response.message + '
');\n\n }\n }).always(function(){\n button.prop('disabled', false);\n });\n }\n });\n }\n };\n});\n\n"],"names":["define","$","Notification","Modal","init","compare_row","row","this","DT_RowId","now","Date","extension_form_change","window","addEventListener","table_obj_list","table_id","state","save","document","ready","log_datatable_navigate","tr","row_id","attr","tableid","closest","key","location","href","localStorage","setItem","on","prev","datatables_lang_messages","JSON","parse","extension_edit_change_data_form","data_name","data_params","data_time","current_rowid","title","time_content","html","find","val","submissionid","requesttype","url","url_root","ajax","type","data","beforeSend","change__status_extension_submit_button","css","children","success","response","data_response","error","create","notification_info","body","message","show","removeOnClose","extension","getElementById","value","time_iso_8601","slice","pre_defined_reason","allocatabletype","allocatableid","courseworkid","id","text","prop","save_extension_form_data","complete","extension_new_change_data_form","is_have_deadline","status","is_data_extension_form_change","update_feedback","form_data","celltype","submitbutton","removefeedbackbutton","submitfeedbackbutton","confirm","button","concat","name","dataType","done","cell_selector","extrahtml","next","assessdate","assessorname","assessortwo","tdcell","finalhtml","tablerowid","tdcell2","datatables_lang_messages_two","modal","alert_feedback_save_successful","replace","alert_feedback_draft_save_successful","alert_feedback_remove_successful","always","e","preventDefault","parent","addClass","change_form","data_get","length","form","removeClass","deadline","alert_validate_deadline","param","personal_deadline_time","self","timestamp","Object","keys","invalidate","time","alert_personaldeadline_save_successful","params","extended_deadline","editor","messages","table","current_row_data","submissiondateindex","column","index","current_moderation_cell_data","content","table_row","dom_row","remove","alert_extension_save_successful","M","core","notification_leave_form_title","question","notification_leave_form_message","yesLabel","notification_yes_label","noLabel","notification_no_label","hide","destroy","prev_rowid","current_row_index","current_cell_data","tmp_node","display","submisiondate","alert_no_extension","ordereddata","rows","order","search","toArray","findIndex","alert_no_mitigation","change","parseJSON","modalbody","formhtml","filemanager","filemanageroptions","clientid","substr","client_id","form_filemanager","Y","editoroptions","require","Tiny","setupForElementId","elementId","options","commentoptions","util","js_pending","amd","each","i","ele","buttonele","textele","buttonid","textid","initialise","js_complete","cell_td","cell_type","show_loading_modal_grading","td_cell","result","replaceAll","tr_cell","get_td_cell_selector","serializeArray","isNaN","parseInt"],"mappings":"AAAAA,wCACI,CAAC,SAAU,oBAAqB,eAAe,SAASC,EAAGC,aAAcC,aAClE,CACHC,KAAM,oBAOOC,YAAYC,YACTC,MAAQD,IAAIE,aAIpBC,IAAM,IAAIC,KACVC,uBAAwB,EAC5BC,OAAOC,iBAAiB,gBAAiBC,oBACjCA,mBACK,IAAIC,YAAYD,eACjBA,eAAeC,UAAUC,MAAMC,UAI3ChB,EAAEiB,UAAUC,OAAM,oBAKLC,uBAAuBC,QACxBC,OAASD,GAAGE,KAAK,MACjBC,QAAUH,GAAGI,QAAQ,SAASF,KAAK,MACnCG,IAAM,sBAAwBd,OAAOe,SAASC,KAAOJ,QACzDK,aAAaC,QAAQJ,IAAKJ,QAI9BrB,EAAE,kBAAkB8B,GAAG,QAAS,wBAAwB,WACpDX,uBAAuBnB,EAAEM,MAAMkB,QAAQ,UAG3CxB,EAAE,kBAAkB8B,GAAG,QAAS,yBAAyB,WACrDX,uBAAuBnB,EAAEM,MAAMkB,QAAQ,UAI3CxB,EAAE,kBAAkB8B,GAAG,QAAS,uBAAuB,WACnDX,uBAAuBnB,EAAEM,MAAMkB,QAAQ,UAG3CxB,EAAE,kBAAkB8B,GAAG,QAAS,wBAAwB,WACpDX,uBAAuBnB,EAAEM,MAAMkB,QAAQ,UAG3CxB,EAAE,kBAAkB8B,GAAG,QAAS,kBAAkB,WAC9CX,uBAAuBnB,EAAEM,MAAMkB,QAAQ,UAI3CxB,EAAE,kBAAkB8B,GAAG,QAAS,0CAA0C,WACtEX,uBAAuBnB,EAAEM,MAAMkB,QAAQ,gBAAgBA,QAAQ,mBAAmBA,QAAQ,MAAMO,WAGpG/B,EAAE,kBAAkB8B,GAAG,QAAS,2CAA2C,WACvEX,uBAAuBnB,EAAEM,MAAMkB,QAAQ,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,GAAGtG,OAAyBuH,MAAMC,SAAShI,UAAU8G,GAAG/H,SACxC,KAAtBiB,UAAU8G,GAAG/H,MAAc,CAC/BrB,IAAM,qDAKdqC,gBAAgBC,UAAUtC,IADV4D,MAAMhE,KAAK,cAAcC,MACD2C,aAAaC,qBAAqBC,qBAAqB,EAAEE,WA8BrG3F,EAAE,kBAAkB8B,GAAG,QAAS,cAAc,SAAUmF,GACpDA,EAAEC,iBACFlH,EAAE,kBAAkB2G,MAAM,WAG9B3G,EAAE,kBAAkB8B,GAAG,QAAS,4BAA4B,SAAUmF,GAClEA,EAAEC,qBACEvB,OAAS3F,EAAEM,SACfqF,OAAOd,KAAK,YAAY,GACpBa,QAAQ,kCAAmC,KACvCH,aAAqC,mBAArBI,OAAOrE,KAAK,MAA8B,EAAI,EAC9DkE,qBAA6C,2BAArBG,OAAOrE,KAAK,MAAsC,EAAI,EAC9EmE,qBAA6C,2BAArBE,OAAOrE,KAAK,MAAsC,EAAI,EAC9EqF,MAAQ3G,EAAE,kBAIdoF,gBAFgBuB,MAAMhE,KAAK,QAAQwK,iBADzB,+CAEMxG,MAAMhE,KAAK,cAAcC,MACE2C,aAAcC,qBACrDC,qBAAqB,EAAGE"} \ No newline at end of file diff --git a/amd/src/coursework.js b/amd/src/coursework.js new file mode 100644 index 00000000..355902b0 --- /dev/null +++ b/amd/src/coursework.js @@ -0,0 +1,328 @@ +define('mod_coursework/coursework', ['jquery', 'core/log'], function($) { + return { + init: function() { + var table_obj_list = []; + var tableobject = 0; + + $(document).ready(function() { + var langmessage = JSON.parse($('#element_lang_messages').attr('data-lang')); + var base_url = window.location.origin + '/mod/coursework/datatables/js/'; + + require.config({ + paths: { + 'datatables.net': base_url + 'jquery.datatables', + 'datatables.searchpanes': base_url + 'datatables.searchpanes', + 'datatables.buttons': base_url + 'datatables.buttons', + 'datatables.select': base_url + 'datatables.select', + 'datatables.responsive': base_url + 'datatables.responsive.min', + } + }); + + require(['datatables.net'], function(DataTable) { + + // Ensure jQuery access. + if (!$.fn.dataTable) { + $.fn.dataTable = DataTable; + } + + $.fn.DataTable = DataTable; + $.fn.DataTableSettings = DataTable.settings; + $.fn.dataTableExt = DataTable.ext; + DataTable.$ = $; + $.fn.DataTable = function(opts) { + return $(this).dataTable(opts).api(); + }; + + $.fn.dataTable.Api.register('row().show()', function() { + var page_info = this.table().page.info(); + // Get row index. + var new_row_index = this.index(); + // Row position. + var row_position = this.table() + .rows({search: 'applied'})[0] + .indexOf(new_row_index); + // Already on right page ? + if ((row_position >= page_info.start && row_position < page_info.end) || row_position < 0) { + // Return row object. + return this; + } + // Find page number. + var page_to_display = Math.floor(row_position / this.table().page.len()); + // Go to that page. + this.table().page(page_to_display); + // Return row object. + return this; + }); + require(['datatables.searchpanes', + 'datatables.select', + 'datatables.buttons', + 'datatables.responsive'], + function() { + if (isMobileDevice() && $(window).width() < 768) { + initDatatable(); + + $('.datatabletest').on('order.dt', function() { + $('.submissionrowmulti').removeClass("shown"); + }); + } else { + initDatatable(); + } + }); + }); + + /** + * + * @param {string} tableid + */ + function background_load_table(tableid) { + var tableelement = $('#' + tableid); + var wrapperelement = tableelement.parent('.dataTables_wrapper'); + var paginationelement = wrapperelement.find('.dataTables_paginate'); + tableobject = table_obj_list[tableid]; + var submissionswrapper = tableelement.parent('.dataTables_wrapper'); + + // Hide buttons. + wrapperelement.find('.dataTables_paginate, .dataTables_info, .dataTables_length,' + + ' .dataTables_filter').css('visibility', 'hidden'); + wrapperelement.find('thead, .dt-button').each(function() { + var me = $(this); + me.css('pointer-events', 'none'); + if (me.hasClass('dt-button')) { + me.find('span').html(' ' + me.find('span').html()); + } + }); + window.console.log(submissionswrapper); + + $('
' + + ' ' + langmessage.loadingpagination + '
'). + insertBefore(submissionswrapper); + $('
' + + langmessage.loadingpagination + '
').insertAfter(paginationelement); + $('').insertBefore(wrapperelement. + find('.dt-button > span')); + + // Prepare params for ajax request. + var params = { + group: tableelement.attr('group'), + perpage: tableelement.attr('perpage'), + sortby: tableelement.attr('sortby'), + sorthow: tableelement.attr('sorthow'), + firstnamealpha: tableelement.attr('firstnamealpha'), + lastnamealpha: tableelement.attr('lastnamealpha'), + groupnamealpha: tableelement.attr('groupnamealpha'), + substatus: tableelement.attr('substatus'), + unallocated: tableelement.attr('unallocated'), + courseworkid: tableelement.attr('courseworkid') + }; + + $.ajax({ + url: '/mod/coursework/actions/ajax/datatable/grading.php', + type: 'POST', + data: params + }).done(function(response) { +// console.log('test remove 1'); + $("#datatable_top_loading_message").remove(); + tableobject.rows.add($(response)).draw(false); + wrapperelement.find('.submission-loading').remove(); + }).fail(function() {}).always(function() { + // Show buttons. + wrapperelement.find('.pagination-loading').remove(); + wrapperelement.find('.submission-loading').remove(); + wrapperelement.find('thead, .dt-button').css('pointer-events', 'auto'); + wrapperelement.find('.dataTables_paginate, .dataTables_info, .dataTables_length,' + + ' .dataTables_filter').css('visibility', 'visible'); + }); + } + + /** + * + */ + function initDatatable() { + $(".datatabletest").each(function() { + // Class that determines whether all data for the databale has been full loaded. + var fullloaded = $(this).hasClass('full-loaded'); + + table_obj_list[$(this).attr('id')] = $(this).DataTable({ + 'order': [], + stateSave: true, + language: { + searchPanes: { + collapse: {"0": $('#search_pane_button').val() || 'Filter', + _: ($('#search_pane_button').val() || 'Filter') + ' (%d)'} + } + }, + buttons: [ + + ], + dom: 'Blfrtip', + columnDefs: [ + { + searchPanes: {show: false}, + targets: ['studentname', 'addition-multiple-button'], + bSortable: false + }, + { + searchPanes: {show: false}, + targets: ['lastname_cell', 'firstname_cell', 'tableheadpersonaldeadline', + 'tableheaddate', 'tableheadfilename', 'tableheadplagiarismalert', + 'plagiarism', 'agreedgrade', 'feedbackandgrading', 'provisionalgrade', + 'tableheadmoderationagreement'] + }, + { + searchPanes: { + show: true, + header: $('#search_pane_group').val() || 'Group', + }, + targets: 'tableheadgroups', + }, + { + searchPanes: { + show: true, + header: $('#search_pane_status').val() || 'Status', + getFullText: true, + }, + targets: 'tableheadstatus', + }, + { + searchPanes: { + show: true, + header: $('#search_pane_firstname').val() || 'First Name Initial', + }, + targets: 'firstname_letter_cell', + }, + { + searchPanes: { + show: true, + header: $('#search_pane_lastname').val() || 'Last Name Initial', + }, + targets: 'lastname_letter_cell', + }, + {"visible": false, "targets": ['lastname_letter_cell', 'firstname_letter_cell', + 'lastname_cell', 'firstname_cell']} + ], + select: { + style: 'multi', + selector: '.select-checkbox' + }, + stateSaveParams: function(settings, data) { + data.columns = []; + } + + }); + + if (!fullloaded) { + background_load_table($(this).attr('id')); + } + }); + } + + if (isMobileDevice() && $(window).width() < 768) { + // For small screens. + var table = $('.datatabletest tbody').on('click', 'td.details-control', function() { + var tr = $(this).closest("tr"); + var row_id = tr.attr('id').replace('allocatable_', ''); + var table_id = 'assessorfeedbacktable_' + row_id; + + if ($(tr).next('tr.row_assessors').length > 0) { + $(tr).next('tr.row_assessors').remove(); + } else { + // As originally written this code created a new table with duplicate IDs. + // See comment on CTP-3783 below for more info. + const oldTable = $('#' + table_id); + const newRow = $( + '' + ); + oldTable.addClass('assessors_expanded').css('width', '95%').appendTo(newRow.find('td')); + } + $(tr).toggleClass('shown'); + }); + } else { + // Add event listener for opening and closing details. + $('.datatabletest tbody').on('click', 'td.details-control', function() { + var tr = $(this).closest("tr"); + var table_key = $(this).closest('.datatabletest').attr('id'); + var table = table_obj_list[table_key]; + if (table) { + var row = table.row(tr); + + var row_id = tr.attr('id').replace('allocatable_', ''); + var table_id = 'assessorfeedbacktable_' + row_id; + const oldTable = $('#' + table_id); + const subRow = $('#sub-row-' + tr.data('allocatable')); + if (oldTable.length) { + if (subRow.length === 0) { + // Open this row - create as sub-row. + // CTP-3783 As originally written this code cloned the old table and + // added its HTML again to the new row. + // This meant that we had 2 x tables do duplicate IDs, with the old table hidden and + // new one visible. + // Then multiple behat tests failed when trying to click the hidden feedback button + // not visible one. + const newRow = $( + '' + ); + oldTable.addClass('assessors_expanded').css('width', '95%').appendTo(newRow.find('td')); + oldTable.show(); + row.child(newRow).show(); + tr.addClass('shown'); + } else { + // Sub-row already exists. + if (subRow.css('display') === 'none') { + subRow.show(); + tr.addClass('shown'); + } else { + // This row is already open - close it. + tr.removeClass('shown'); + subRow.hide(); + } + } + } else { + // No need to move table - just open/close. + if (subRow.css('display') === 'none') { + subRow.show(); + tr.addClass('shown'); + } else { + // This row is already open - close it. + subRow.hide(); + tr.removeClass('shown'); + } + } + } + }); + } + + $('.datatabletest').on('click', '.splitter-firstname, .splitter-lastname, .splitter-email', function(event) { + event.preventDefault(); + var node = $(event.target), + isAscending = node.hasClass('sorting_asc'), + currentsort = 'asc', + sortby = 'desc'; + if (!isAscending) { + currentsort = 'desc'; + sortby = 'asc'; + } + var table_id = $(this).closest('.datatabletest').attr('id'); + table = table_obj_list[table_id]; + var headerclass = $(this).hasClass('splitter-firstname') ? 'firstname_cell' : 'lastname_cell'; + headerclass = $(this).hasClass('splitter-email') ? 'email_cell' : headerclass; + window.console.log(headerclass); + var sortColumn = table.column('.' + headerclass).index(); + table.order([sortColumn, sortby]).draw(); + + node.addClass('sorting_' + sortby).removeClass('sorting sorting_' + currentsort); + node.parent().removeClass('sorting sorting_asc sorting_desc'); + node.siblings().removeClass('sorting_asc sorting_desc').addClass('sorting'); + }); + }); + + /** + * + */ + function isMobileDevice() { + return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)); + } + } + }; +}); + diff --git a/amd/src/coursework_edit.js b/amd/src/coursework_edit.js new file mode 100644 index 00000000..267fa52e --- /dev/null +++ b/amd/src/coursework_edit.js @@ -0,0 +1,991 @@ +define('mod_coursework/coursework_edit', + ['jquery', 'core/notification', 'core/modal'], function($, Notification, Modal) { + return { + init: function() { +// Add the init function: + /** + * + * @param {object} row + * @returns {boolean} + */ + function compare_row(row) { + return (this == row.DT_RowId); + } + + + var now = new Date(); + var extension_form_change = false; + window.addEventListener('beforeunload', (table_obj_list) => { + if (table_obj_list) { + for (var table_id in table_obj_list) { + table_obj_list[table_id].state.save(); + } + } + }); + $(document).ready(function() { + /** + * + * @param {object} tr + */ + function log_datatable_navigate(tr) { + var row_id = tr.attr('id'); + var tableid = tr.closest('table').attr('id'); + var key = 'datatable_navigate_' + window.location.href + tableid; + localStorage.setItem(key, row_id); + } + + /* plagiarism flag */ + $('.datatabletest').on('click', '.new_plagiarism_flag', function() { + log_datatable_navigate($(this).closest('tr')); + }); + + $('.datatabletest').on('click', '.edit_plagiarism_flag', function() { + log_datatable_navigate($(this).closest('tr')); + }); + + /* feedback */ + $('.datatabletest').on('click', '.new_final_feedback', function() { + log_datatable_navigate($(this).closest('tr')); + }); + + $('.datatabletest').on('click', '.edit_final_feedback', function() { + log_datatable_navigate($(this).closest('tr')); + }); + + $('.datatabletest').on('click', '.show_feedback', function() { + log_datatable_navigate($(this).closest('tr')); + }); + + /* assessor feedback */ + $('.datatabletest').on('click', '.assessor_feedback_grade .new_feedback', function() { + log_datatable_navigate($(this).closest('td.assessors').closest('table.assessors').closest('tr').prev()); + }); + + $('.datatabletest').on('click', '.assessor_feedback_grade .show_feedback', function() { + log_datatable_navigate($(this).closest('td.assessors').closest('table.assessors').closest('tr').prev()); + }); + + $('.datatabletest').on('click', '.assessor_feedback_grade .edit_feedback', function() { + log_datatable_navigate($(this).closest('td.assessors').closest('table.assessors').closest('tr').prev()); + }); + + /* deadline extension */ + $('.datatabletest').on('click', '.new_deadline_extension', function() { + log_datatable_navigate($(this).closest('tr')); + }); + + $('.datatabletest').on('click', '.edit_deadline_extension', function() { + log_datatable_navigate($(this).closest('tr')); + }); + + /* submission */ + $('.datatabletest').on('click', '.new_submission', function() { + log_datatable_navigate($(this).closest('tr')); + }); + + // Prepare Message + var datatables_lang_messages = JSON.parse($('#datatables_lang_messages').attr('data-lang')); + + /** + * Personal Deadline + */ + $('.datatabletest').on('click', '.edit_personal_deadline',function(e) { + e.preventDefault(); + var parent = $(this).closest('.personal_deadline_cell'); + parent.children('.show_personal_dealine').addClass('display-none'); + var change_form = parent.children('.show_edit_personal_dealine'); + var data_get = $(this).attr('data-get'); + var data_time = $(this).attr('data-time-iso-8601'); + if (change_form.html().length === 1) { + var form = ''; + form += '
'; + form += '
'; + $(change_form).html(form); + } + $(change_form).removeClass('display-none'); + }); + + $('.datatabletest').on('click', '.cancel-personal-deadline', function(e) { + e.preventDefault(); + $(this).closest('.show_edit_personal_dealine').addClass('display-none'); + $(this).closest('.personal_deadline_cell').children('.show_personal_dealine').removeClass('display-none'); + }); + + $('.datatabletest').on('click', '.approve-personal-deadline', function(e) { + e.preventDefault(); + var deadline = $(this); + var data_get = $(deadline).attr('data-get'); + var value = $(deadline).closest('.show_edit_personal_dealine').children('.input-personal-deadline').val(); + var input_date = new Date(value); + if (input_date <= Date.parse(now)) { + Modal.create({ + title: datatables_lang_messages.notification_info, + body: datatables_lang_messages.alert_validate_deadline.replace(/\_/g, ' '), + show: true, + removeOnClose: true, + }); + } + + var url = datatables_lang_messages.url_root + "/mod/coursework/actions/personal_deadline.php"; + var param = JSON.parse(data_get); + param.personal_deadline_time = value; + + $.ajax({ + type: "POST", + url: url, + data: param, + beforeSend: function() { + $('html, body').css("cursor", "wait"); + $(self).prev('img').css('visibility', 'visible'); + }, + success: function(response, table_obj_list) { + $('html, body').css("cursor", "auto"); + var data_response = JSON.parse(response); + if (data_response.error === 1) { + Modal.create({ + title: datatables_lang_messages.notification_info, + body: data_response.message, + show: true, + removeOnClose: true, + }); + } else { + var parent = $(deadline).closest('.personal_deadline_cell'); + $(parent).attr('data-order', data_response.timestamp); + var table = table_obj_list[Object.keys(table_obj_list)[0]]; + table.row('#' + $(parent).closest('tr').attr('id')).invalidate(); + + $(parent).children('.show_personal_dealine').children('.content_personal_deadline'). + html(data_response.time); + $(parent).children('.show_edit_personal_dealine').addClass('display-none'); + $(parent).children('.show_personal_dealine').removeClass('display-none'); + Modal.create({ + title: datatables_lang_messages.notification_info, + body: datatables_lang_messages.alert_personaldeadline_save_successful.replace(/\_/g, ' '), + show: true, + removeOnClose: true, + }); + } + }, + error: function() { + $('html, body').css("cursor", "auto"); + }, + complete: function() { + $('html, body').css("cursor", "auto"); + } + }); + + }); + + /*************************** + * Extensions + */ + + /** + * Add new extension + */ + $('.datatabletest').on('click', '.new_deadline_extension', function(e) { + e.preventDefault(); + var data_name = $(this).attr('data-name'); + var data_params = JSON.parse($(this).attr('data-params')); + var data_time = JSON.parse($(this).attr('data-time')); + var current_rowid = $(this).closest('tr').attr('id'); + extension_new_change_data_form(data_name, data_params, data_time, current_rowid); + $('#modal-ajax').modal('show'); + }); + + /** + * Edit extensions + */ + $('.datatabletest').on('click', '.edit_deadline_extension', function(e) { + + e.preventDefault(); + var data_name = $(this).attr('data-name'); + var data_params = JSON.parse($(this).attr('data-params')); + var data_time = JSON.parse($(this).attr('data-time')); + var current_rowid = $(this).closest('tr').attr('id'); + extension_edit_change_data_form(data_name, data_params, data_time, current_rowid); + $('#modal-ajax').modal('show'); + }); + + /** + * Submit save extension + */ + $('.modal-footer').on('click', '#extension-submit', function(e) { + e.preventDefault(); + var params = {}; + params.allocatabletype = $('#extension-allocatabletype').val(); + params.allocatableid = $('#extension-allocatableid').val(); + params.courseworkid = $('#extension-courseworkid').val(); + params.id = $('#extension-id').val(); + params.extended_deadline = $('#extension-extend-deadline').val(); + params.editor = $('#extension-time-content').html(); + params.text = $('#id_extra_information').val(); + params.submissionid = $('#extension-submissionid').val(); + params.pre_defined_reason = $('#extension-reason-select').val(); + params.requesttype = 'submit'; + var current_rowid = $('#button-id').val(); + var url = datatables_lang_messages.url_root; + $.ajax({ + type: "POST", + url: url + "/mod/coursework/actions/ajax/deadline_extension/submit.php", + data: params, + beforeSend: function() { + $('html, body').css("cursor", "wait"); + $('.modal-footer').children('img').css('visibility', 'visible'); + }, + success: function(response, table_obj_list) { + var data_response = JSON.parse(response); + $('html, body').css("cursor", "auto"); + $('.modal-footer').children('img').css('visibility', 'hidden'); + if (data_response.error == 1) { + Modal.create({ + title: datatables_lang_messages.notification_info, + body: data_response.messages, + show: true, + removeOnClose: true, + }); + } else { + if (Object.keys(table_obj_list).length > 0) { + // Get the first datatable object. + var table = table_obj_list[Object.keys(table_obj_list)[0]]; + if (table.row) { + var current_row_data = table.row('#' + current_rowid).data(); + var submissiondateindex = table.column('.tableheaddate').index(); + var current_moderation_cell_data = data_response.content; + current_row_data[submissiondateindex] = current_moderation_cell_data; + var table_row = table.row('#' + current_rowid); + table_row.data(current_row_data); + var dom_row = $('#' + current_rowid); + dom_row.find('.time_submitted_cell').attr('data-order', + current_moderation_cell_data['@data-order']); + dom_row.find('.edit_personal_deadline').remove(); + table_row.invalidate(); + $('#extension-id').val(data_response.data.id); + } + } + + change__status_extension_submit_button(true); + save_extension_form_data(); + + Modal.create({ + title: datatables_lang_messages.notification_info, + body: datatables_lang_messages.alert_extension_save_successful.replace(/\_/g, ' '), + show: true, + removeOnClose: true, + }); + + } + }, + error: function() { + $('html, body').css("cursor", "auto"); + }, + complete: function() { + $('html, body').css("cursor", "auto"); + } + }); + }); + + + /** + * Function close button + */ + $('#modal-ajax').on('hide.bs.modal', function() { + var self = this; + if (is_data_extension_form_change()) { + var confirm = new M.core.confirm({ + title: datatables_lang_messages.notification_leave_form_title.replace(/\_/g, ' '), + question: datatables_lang_messages.notification_leave_form_message.replace(/\_/g, ' '), + yesLabel: datatables_lang_messages.notification_yes_label, + noLabel: datatables_lang_messages.notification_no_label, + }); + + confirm.on('complete-yes',function() { + save_extension_form_data(); + confirm.hide(); + confirm.destroy(); + $(self).modal('hide'); + }); + + confirm.on('complete-no',function() { + confirm.hide(); + confirm.destroy(); + return false; + }); + + confirm.show(); + return false; + } + return true; + }); + + /** + * Function next button + */ + $('.modal-footer').on('click', '#extension-next', function(e, table_obj_list) { + e.preventDefault(); + + if (is_data_extension_form_change()) { + var confirm = new M.core.confirm({ + title: datatables_lang_messages.notification_leave_form_title.replace(/\_/g, ' '), + question: datatables_lang_messages.notification_leave_form_message.replace(/\_/g, ' '), + yesLabel: datatables_lang_messages.notification_yes_label, + noLabel: datatables_lang_messages.notification_no_label, + }); + + confirm.on('complete-yes', function(table_obj_list) { + confirm.hide(); + confirm.destroy(); + if (Object.keys(table_obj_list).length > 0) { + + var prev_rowid = $('#button-id').val(); + + // Get the first datatable object. + var table = table_obj_list[Object.keys(table_obj_list)[0]]; + + var prev_row_index = table.row('#' + prev_rowid).index(); + + + var current_row_index = prev_row_index + 1; + + if (table.row(current_row_index)) { + var current_row_data = table.row(current_row_index).data(); + if (current_row_data) { + var current_rowid = table.row(current_row_index).id(); + + var submissiondateindex = table.column('.tableheaddate').index(); + var current_cell_data = current_row_data[submissiondateindex]; + if (current_cell_data) { + var tmp_node = $('
').html(current_cell_data.display); + var submisiondate = $(tmp_node).find('.new_deadline_extension'); + if (submisiondate.length > 0) { + var data_params = JSON.parse(submisiondate.attr('data-params')); + var data_name = submisiondate.attr('data-name'); + var data_time = JSON.parse(submisiondate.attr('data-time')); + extension_new_change_data_form(data_name, data_params, data_time, current_rowid); + } else { + submisiondate = $(tmp_node).find('.edit_deadline_extension'); + var data_params = JSON.parse(submisiondate.attr('data-params')); + var data_name = submisiondate.attr('data-name'); + var data_time = JSON.parse(submisiondate.attr('data-time')); + extension_edit_change_data_form(data_name, data_params, data_time, current_rowid); + } + } + } + else { + $('#extension-next').prop('disabled', true); + Modal.create({ + title: datatables_lang_messages.notification_info, + body: datatables_lang_messages.alert_no_extension.replace(/\_/g, ' '), + show: true, + removeOnClose: true, + }); + } + } + } + }); + + confirm.on('complete-no', function() { + confirm.hide(); + confirm.destroy(); + + }); + + confirm.show(); + } else { + if (Object.keys(table_obj_list).length > 0) { + + var prev_rowid = $('#button-id').val(); + + // Get the first datatable object. + var table = table_obj_list[Object.keys(table_obj_list)[0]]; + + var ordereddata = table.rows({order: 'applied', search: 'applied'}).data().toArray(); + var prev_row_index = ordereddata.findIndex(compare_row, prev_rowid); + + + var current_row_index = prev_row_index + 1; + + if (table.row(current_row_index)) { + var current_row_data = ordereddata[current_row_index]; + if (typeof current_row_data != 'undefined') { + var current_rowid = current_row_data.DT_RowId; + + var submissiondateindex = table.column('.tableheaddate').index(); + var current_cell_data = current_row_data[submissiondateindex]; + if (current_cell_data) { + var tmp_node = $('
').html(current_cell_data.display); + var submisiondate = $(tmp_node).find('.new_deadline_extension'); + if (submisiondate.length > 0) { + var data_params = JSON.parse(submisiondate.attr('data-params')); + var data_name = submisiondate.attr('data-name'); + var data_time = JSON.parse(submisiondate.attr('data-time')); + extension_new_change_data_form(data_name, data_params, data_time, current_rowid); + } else { + submisiondate = $(tmp_node).find('.edit_deadline_extension'); + var data_params = JSON.parse(submisiondate.attr('data-params')); + var data_name = submisiondate.attr('data-name'); + var data_time = JSON.parse(submisiondate.attr('data-time')); + extension_edit_change_data_form(data_name, data_params, data_time, current_rowid); + } + } + } + else { + $('#extension-next').prop('disabled', true); + Modal.create({ + title: datatables_lang_messages.notification_info, + body: datatables_lang_messages.alert_no_mitigation.replace(/\_/g, ' '), + show: true, + removeOnClose: true, + }); + } + } + } + } + + + }); + + /** + * Function back button + */ + $('.modal-footer').on('click', '#extension-back', function(e, table_obj_list) { + e.preventDefault(); + if (is_data_extension_form_change()) { + var confirm = new M.core.confirm({ + title: datatables_lang_messages.notification_leave_form_title.replace(/\_/g, ' '), + question: datatables_lang_messages.notification_leave_form_message.replace(/\_/g, ' '), + yesLabel: datatables_lang_messages.notification_yes_label, + noLabel: datatables_lang_messages.notification_no_label, + }); + + confirm.on('complete-yes', function(table_obj_list) { + confirm.hide(); + confirm.destroy(); + if (Object.keys(table_obj_list).length > 0) { + + var prev_rowid = $('#button-id').val(); + + // Get the first datatable object. + var table = table_obj_list[Object.keys(table_obj_list)[0]]; + + var prev_row_index = table.row('#' + prev_rowid).index(); + + + var current_row_index = prev_row_index - 1; + + if (table.row(current_row_index)) { + var current_row_data = table.row(current_row_index).data(); + if (current_row_data) { + var current_rowid = table.row(current_row_index).id(); + + var submissiondateindex = table.column('.tableheaddate').index(); + var current_cell_data = current_row_data[submissiondateindex]; + if (current_cell_data) { + var tmp_node = $('
').html(current_cell_data.display); + var submisiondate = $(tmp_node).find('.new_deadline_extension'); + if (submisiondate.length > 0) { + var data_params = JSON.parse(submisiondate.attr('data-params')); + var data_name = submisiondate.attr('data-name'); + var data_time = JSON.parse(submisiondate.attr('data-time')); + extension_new_change_data_form(data_name, data_params, data_time, current_rowid); + } else { + submisiondate = $(tmp_node).find('.edit_deadline_extension'); + var data_params = JSON.parse(submisiondate.attr('data-params')); + var data_name = submisiondate.attr('data-name'); + var data_time = JSON.parse(submisiondate.attr('data-time')); + extension_edit_change_data_form(data_name, data_params, data_time, current_rowid); + } + } + } + else { + $('#extension-back').prop('disabled', true); + Modal.create({ + title: datatables_lang_messages.notification_info, + body: datatables_lang_messages.alert_no_mitigation.replace(/\_/g, ' '), + show: true, + removeOnClose: true, + }); + } + } + } + }); + + confirm.on('complete-no', function() { + confirm.hide(); + confirm.destroy(); + }); + + confirm.show(); + } else { + if (Object.keys(table_obj_list).length > 0) { + + var prev_rowid = $('#button-id').val(); + + // Get the first datatable object. + var table = table_obj_list[Object.keys(table_obj_list)[0]]; + + var ordereddata = table.rows( { order: 'applied', search: 'applied' } ).data().toArray(); + var prev_row_index = ordereddata.findIndex(compare_row, prev_rowid); + + + var current_row_index = prev_row_index - 1; + + if (table.row(current_row_index)) { + var current_row_data = ordereddata[current_row_index]; + if (typeof current_row_data != 'undefined') { + var current_rowid = current_row_data.DT_RowId; + + var submissiondateindex = table.column('.tableheaddate').index(); + var current_cell_data = current_row_data[submissiondateindex]; + if (current_cell_data) { + var tmp_node = $('
').html(current_cell_data.display); + var submisiondate = $(tmp_node).find('.new_deadline_extension'); + if (submisiondate.length > 0) { + var data_params = JSON.parse(submisiondate.attr('data-params')); + var data_name = submisiondate.attr('data-name'); + var data_time = JSON.parse(submisiondate.attr('data-time')); + extension_new_change_data_form(data_name, data_params, data_time, current_rowid); + } else { + submisiondate = $(tmp_node).find('.edit_deadline_extension'); + var data_params = JSON.parse(submisiondate.attr('data-params')); + var data_name = submisiondate.attr('data-name'); + var data_time = JSON.parse(submisiondate.attr('data-time')); + extension_edit_change_data_form(data_name, data_params, data_time, current_rowid); + } + } + } + else { + $('#extension-back').prop('disabled', true); + Modal.create({ + title: datatables_lang_messages.notification_info, + body: datatables_lang_messages.alert_no_mitigation.replace(/\_/g, ' '), + show: true, + removeOnClose: true, + }); + } + } + } + } + + + }); + + /** + * + * @param {string} data_name + * @param {object} data_params + * @param {string} data_time + * @param {string} current_rowid + */ + function extension_edit_change_data_form(data_name, data_params, data_time, current_rowid) { + var title = 'Editing the extension for ' + data_name; + var time_content = 'Default deadline: ' + data_time.time_content; + $('#extension-modal-title').html(title); + $('#form-extension').find('input[type=hidden]').val(""); + $('#form-extension').find('textarea').val(""); + $('#button-id').val(current_rowid); + $('#extension-submissionid').val(data_params.submissionid); + $('#extension-name').val(data_name); + data_params.requesttype = 'edit'; + var url = datatables_lang_messages.url_root; + $.ajax({ + type: "GET", + url: url + "/mod/coursework/actions/ajax/deadline_extension/edit.php", + data: data_params, + beforeSend: function() { + change__status_extension_submit_button(true); + $('html, body').css("cursor", "wait"); + $('.modal-footer').children('img').css('visibility', 'visible'); + }, + success: function(response) { + var data_response = JSON.parse(response); + $('html, body').css("cursor", "auto"); + $('.modal-footer').children('img').css('visibility', 'hidden'); + if (data_response.error == 1) { + Modal.create({ + title: datatables_lang_messages.notification_info, + body: data_response.message + ' .Please reload the page!', + show: true, + removeOnClose: true, + }); + } else { + var extension = data_response.data; + if (extension.time_content) { + $('#extension-time-content').html(extension.time_content); + } else { + $('#extension-time-content').html(time_content); + } + document.getElementById('extension-extend-deadline'). + value = data_response.data.time_iso_8601.slice(0, 16); + $('#extension-reason-select').val(extension.pre_defined_reason); + $('#extension-allocatabletype').val(extension.allocatabletype); + $('#extension-allocatableid').val(extension.allocatableid); + $('#extension-courseworkid').val(extension.courseworkid); + $('#extension-id').val(extension.id); + + $('#id_extra_information').val(extension.text); + + $('#id_extra_information').prop('disabled', false); + $('#extension-extend-deadline').prop('disabled', false); + $('#extension-reason-select').prop('disabled', false); + save_extension_form_data(); + } + }, + error: function() { + $('html, body').css("cursor", "auto"); + change__status_extension_submit_button(false); + }, + complete: function() { + $('html, body').css("cursor", "auto"); + change__status_extension_submit_button(false); + } + }); + } + + /** + * + * @param {string} data_name + * @param {object} data_params + * @param {string} data_time + * @param {string} current_rowid + */ + function extension_new_change_data_form(data_name, data_params, data_time, current_rowid) { + var title = 'New extension for ' + data_name; + $('#extension-modal-title').html(title); + $('#form-extension').find('input[type=hidden]').val(''); + $('#form-extension').find('textarea').val(''); + + if (data_time.is_have_deadline == '1') { + var url = datatables_lang_messages.url_root; + $.ajax({ + type: "GET", + url: url + "/mod/coursework/actions/ajax/deadline_extension/new.php", + data: data_params, + beforeSend: function() { + change__status_extension_submit_button(true); + $('html, body').css("cursor", "wait"); + $('.modal-footer').children('img').css('visibility', 'visible'); + }, + success: function(response) { + $('html, body').css("cursor", "auto"); + $('.modal-footer').children('img').css('visibility', 'hidden'); + var data_response = JSON.parse(response); + $('#extension-time-content').html(data_response.data.time_content); + document.getElementById('extension-extend-deadline'). + value = data_response.data.time_iso_8601.slice(0,16); + save_extension_form_data(); + }, + error: function() { + $('html, body').css("cursor", "auto"); + }, + complete: function() { + $('html, body').css("cursor", "auto"); + } + }); + } else { + save_extension_form_data(); + } + $('#extension-reason-select').val(''); + $('#extension-allocatabletype').val(data_params.allocatabletype); + $('#extension-allocatableid').val(data_params.allocatableid); + $('#extension-courseworkid').val(data_params.courseworkid); + $('#extension-submissionid').val(data_params.submissionid); + $('#extension-name').val(data_name); + $('#button-id').val(current_rowid); + + $('#id_extra_information').prop('disabled', false); + $('#extension-extend-deadline').prop('disabled', false); + $('#extension-reason-select').prop('disabled', false); + } + + + $("#form-extension :input").change(function() { + extension_form_change = true; + change__status_extension_submit_button(false); + }); + + /** + * + * @param {string} status + */ + function change__status_extension_submit_button(status) { + $('#extension-submit').prop('disabled', status); + } + + /** + * + */ + function save_extension_form_data() { + extension_form_change = false; + } + + /** + * + */ + function is_data_extension_form_change() { + return extension_form_change; + } + + /** + * Feedback + */ + $('.datatabletest').on('click', '.new_final_feedback, .new_feedback,' + + ' .edit_final_feedback, .edit_feedback, .show_feedback', function(e) { + e.preventDefault(); + var url = $(this).attr('href'); + $.ajax({ + type: "GET", + url: url + '&ajax=1' + }).done(function(response) { + response = $.parseJSON(response); + var modalbody = $('#modal-grading').find('.modal-body'); + // Careful as not all requests return a response.success value. Only if it's false, show error. + if ((response.success ?? true) === false && (response.message ?? null)) { + modalbody.html(response.message); + } else { + modalbody.html(response.formhtml); + var filemanager = modalbody.find('.filemanager'); + if (response.filemanageroptions && filemanager.length) { + var elementid = filemanager.attr('id'); + var clientid = elementid.substr(12); + if (clientid) { + response.filemanageroptions.client_id = clientid; + M.form_filemanager.init(Y, response.filemanageroptions); + } + } + if (response.editoroptions) { + require(['editor_tiny/editor'], (Tiny) => { + Tiny.setupForElementId({ + elementId: 'id_feedbackcomment', + options: JSON.parse(response.editoroptions), + }); + }); + } + + if (response.commentoptions) { + M.util.js_pending('gradingform_guide/comment_chooser'); + require(['gradingform_guide/comment_chooser'], function(amd) { + $(".remark").each(function(i, ele) { + var buttonele = $(ele).find(".commentchooser"); + var textele = $(ele).find(".markingguideremark"); + var buttonid = $(buttonele).attr("id"); + var textid = $(textele).attr("id"); + amd.initialise(1, buttonid, textid, response.commentoptions); + M.util.js_complete('gradingform_guide/comment_chooser'); + + }); + + }); + } + } + }); + var cell_td = $(this).closest('td'); + var cell_selector = get_td_cell_selector(cell_td); + var cell_type = cell_td.attr('data-class-name'); + show_loading_modal_grading(cell_selector, cell_type); + }); + + /** + * + * @param {object} td_cell + * @returns {string} + */ + function get_td_cell_selector(td_cell) { + var result = '.' + td_cell.attr('class').replaceAll(' ', '.'); + var tr_cell = td_cell.closest('tr'); + if (tr_cell.attr('id')) { + result = '#' + tr_cell.attr('id') + ' ' + result; + } else { + result = '.' + tr_cell.attr('class').replaceAll(' ', '.') + ' ' + result; + } + return result; + } + + /** + * + * @param {object} cell_selector + * @param {object} cell_type + */ + function show_loading_modal_grading(cell_selector, cell_type) { + // Set row id. + var modal = $('#modal-grading'); + modal.find('#cell_selector').val(cell_selector); + modal.find('#cell_type').val(cell_type); + modal.find('.modal-body').html(' loading'); + $('#modal-grading').modal('show'); + } + + $('#modal-grading').on('click', '#id_submitfeedbackbutton, #id_submitbutton', function(e) { + e.preventDefault(); + var button = $(this); + button.prop('disabled', true); + var submitbutton = (button.attr('id') == 'id_submitbutton') ? 1 : 0; + var removefeedbackbutton = (button.attr('id') == 'id_removefeedbackbutton') ? 1 : 0; + var submitfeedbackbutton = (button.attr('id') == 'id_submitfeedbackbutton') ? 1 : 0; + var modal = $('#modal-grading'); + var url = '/mod/coursework/actions/feedbacks/create.php'; + var form_data = modal.find('form').serializeArray(); + for (var i = 0, length = form_data.length; i < length; i++) { + if (form_data[i].name == 'feedbackid' && !isNaN(parseInt(form_data[i].value)) && + form_data[i].value != '0') { + url = '/mod/coursework/actions/feedbacks/update.php'; + break; + } + } + var cell_type = modal.find('#cell_type').val(); + update_feedback(form_data, url, cell_type, submitbutton, removefeedbackbutton, submitfeedbackbutton, 0, button); + /* + form_data = form_data.concat({name: 'ajax', value: 1}, + {name: 'cell_type', value: cell_type}, + {name: 'submitbutton', value: submitbutton}, + {name: 'removefeedbackbutton', value: removefeedbackbutton}); + $.ajax({ + type: 'POST', + data: form_data, + url: url, + dataType: 'json' + }).done(function(response) { + console.log(response); + if (response.success) { + var cell_selector = modal.find('#cell_selector').val(); + $(cell_selector).html(response.html); + $('#modal-grading').modal('hide'); + if (submitbutton == 1) { + alert('Your data has been saved.'); + } else { + alert('The feedback has been removed.'); + } + } else { + alert('Sorry! There was an error with your request.'); + } + }).always(function() { + me.prop('disabled', false); + });*/ + }); + + $('#modal-grading').on('click', '#id_cancel', function(e) { + e.preventDefault(); + $('#modal-grading').modal('hide'); + }); + + $('#modal-grading').on('click', '#id_removefeedbackbutton', function(e) { + e.preventDefault(); + var button = $(this); + button.prop('disabled', true); + if (confirm('do you want to remove feedback')) { + var submitbutton = (button.attr('id') == 'id_submitbutton') ? 1 : 0; + var removefeedbackbutton = (button.attr('id') == 'id_removefeedbackbutton') ? 1 : 0; + var submitfeedbackbutton = (button.attr('id') == 'id_submitfeedbackbutton') ? 1 : 0; + var modal = $('#modal-grading'); + var url = '/mod/coursework/actions/feedbacks/update.php'; + var form_data = modal.find('form').serializeArray(); + var cell_type = modal.find('#cell_type').val(); + update_feedback(form_data, url, cell_type, submitbutton, removefeedbackbutton, + submitfeedbackbutton, 1, button); + } + }); + + /** + * + * @param {object} form_data + * @param {string} url + * @param {string} celltype + * @param {object} submitbutton + * @param {object} removefeedbackbutton + * @param {object} submitfeedbackbutton + * @param {object} confirm + * @param {object} button + */ + function update_feedback(form_data, url, celltype, submitbutton, removefeedbackbutton, + submitfeedbackbutton, confirm, button) { + + form_data = form_data.concat({name: 'ajax', value: 1}, + {name: 'cell_type', value: celltype}, + {name: 'submitbutton', value: submitbutton}, + {name: 'submitfeedbackbutton', value: submitfeedbackbutton}, + {name: 'removefeedbackbutton', value: removefeedbackbutton}, + {name: 'confirm', value: confirm}); + + $.ajax({ + type: 'POST', + data: form_data, + url: url, + dataType: 'json' + }).done(function(response) { + if ((response.success ?? true) === false && (response.message ?? null)) { + // Could be an error like "Please provide a valid grade for each criterion". + $('#modal-grading').find('.modal-body').html( + '
' + response.message + '
' + ); + } else if (response.success) { + var cell_selector = $('#modal-grading').find('#cell_selector').val(); + $(cell_selector).html(response.html); + + if (typeof response.extrahtml !== 'undefined' && response.extrahtml != '') { + $(cell_selector).next('td').html(response.extrahtml); + } + if (typeof response.assessdate !== 'undefined' && response.assessdate != '') { + $(cell_selector).next('td').html(response.assessdate); + } + + if (typeof response.assessorname !== 'undefined' && response.assessorname != '') { + $(cell_selector).prev('td').html(response.assessorname); + } + + if (typeof response.assessortwo !== 'undefined' && response.assessortwo != '') { + var tdcell = $(cell_selector).closest('tr').next().find('td')[1]; + $(tdcell).html(response.assessortwo); + } + + if (typeof response.finalhtml !== 'undefined' && response.assessortwo != '') { + var tablerowid = 'allocatable_' + response.allocatableid; + var tdcell2 = $('#' + tablerowid).find('.multiple_agreed_grade_cell')[0]; + $(tdcell2).html(response.finalhtml); + } + var datatables_lang_messages_two = JSON.parse($('#datatables_lang_messages').attr('data-lang')); + $('#modal-grading').modal('hide'); + if (submitbutton === 1) { + Modal.create({ + title: datatables_lang_messages_two.notification_info, + body: datatables_lang_messages_two.alert_feedback_save_successful.replace(/\_/g, ' '), + show: true, + removeOnClose: true, + }); + + } else if (submitfeedbackbutton === 1) { + Modal.create({ + title: datatables_lang_messages_two.notification_info, + body: datatables_lang_messages_two.alert_feedback_draft_save_successful.replace(/\_/g, ' '), + show: true, + removeOnClose: true, + }); + + } else { + Modal.create({ + title: datatables_lang_messages_two.notification_info, + body: datatables_lang_messages_two.alert_feedback_remove_successful.replace(/\_/g, ' '), + show: true, + removeOnClose: true, + }); + } + } else { + Modal.create({ + title: datatables_lang_messages_two.notification_info, + body: response.message, + show: true, + removeOnClose: true, + }); + } + }).always(function() { + button.prop('disabled', false); + }); + } + }); + } + }; +}); + diff --git a/coursework.js b/coursework.js deleted file mode 100644 index fc543ebd..00000000 --- a/coursework.js +++ /dev/null @@ -1,296 +0,0 @@ -var table_obj_list = []; -var id = 0; -var is_responsive = false; -var tableobject = 0; - -$( document ).ready(function() { - var langmessage = JSON.parse($('#element_lang_messages').attr('data-lang')); - var base_url = window.location.origin + '/mod/coursework/datatables/js/'; - - require.config({ - paths: { - 'datatables.net': base_url + 'jquery.datatables', - 'datatables.searchpanes': base_url + 'datatables.searchpanes', - 'datatables.buttons': base_url + 'datatables.buttons', - 'datatables.select': base_url + 'datatables.select', - 'datatables.responsive': base_url + 'datatables.responsive.min', - } - }); - - require(['datatables.net'], function (DataTable) { - - $.fn.DataTable = DataTable; - $.fn.DataTableSettings = DataTable.settings; - $.fn.dataTableExt = DataTable.ext; - DataTable.$ = $; - $.fn.DataTable = function ( opts ) { - return $(this).dataTable( opts ).api(); - }; - $.fn.dataTable.Api.register('row().show()', function() { - var page_info = this.table().page.info(); - // Get row index. - var new_row_index = this.index(); - // Row position. - var row_position = this.table() - .rows({ search: 'applied' })[0] - .indexOf(new_row_index); - // Already on right page ? - if ((row_position >= page_info.start && row_position < page_info.end) || row_position < 0) { - // Return row object. - return this; - } - // Find page number. - var page_to_display = Math.floor(row_position / this.table().page.len()); - // Go to that page. - this.table().page(page_to_display); - // Return row object. - return this; - }); - require(['datatables.searchpanes', 'datatables.select', 'datatables.buttons', 'datatables.responsive'], function() { - if(isMobileDevice() && $(window).width() < 768) { - is_responsive = true; - initDatatable(is_responsive); - - $('.datatabletest').on('order.dt', function(e) { - $('.submissionrowmulti').removeClass("shown"); - }); - } - else { - initDatatable(is_responsive); - } - }); - }); - - /** - * - * @param tableid - */ - function background_load_table(tableid) { - var tableelement = $('#' + tableid); - var wrapperelement = tableelement.parent('.dataTables_wrapper'); - var paginationelement = wrapperelement.find('.dataTables_paginate'); - tableobject = table_obj_list[tableid]; - var submissionswrapper = tableelement.parent('.dataTables_wrapper'); - - // Hide buttons. - wrapperelement.find('.dataTables_paginate, .dataTables_info, .dataTables_length, .dataTables_filter').css('visibility', 'hidden'); - wrapperelement.find('thead, .dt-button').each(function() { - var me = $(this); - me.css('pointer-events', 'none'); - if (me.hasClass('dt-button')) { - me.find('span').html(' ' + me.find('span').html()); - } - }); - console.log(submissionswrapper); - - $('
' + langmessage.loadingpagination + '
').insertBefore(submissionswrapper); - $('
' + langmessage.loadingpagination + '
').insertAfter(paginationelement); - $('').insertBefore(wrapperelement.find('.dt-button > span')); - - // Prepare params for ajax request. - var params = { - group: tableelement.attr('group'), - perpage: tableelement.attr('perpage'), - sortby: tableelement.attr('sortby'), - sorthow: tableelement.attr('sorthow'), - firstnamealpha: tableelement.attr('firstnamealpha'), - lastnamealpha: tableelement.attr('lastnamealpha'), - groupnamealpha: tableelement.attr('groupnamealpha'), - substatus: tableelement.attr('substatus'), - unallocated: tableelement.attr('unallocated'), - courseworkid: tableelement.attr('courseworkid') - }; - - $.ajax({ - url: '/mod/coursework/actions/ajax/datatable/grading.php', - type: 'POST', - data: params - }).done(function(response) { - console.log('test remove 1'); - $("#datatable_top_loading_message").remove(); - tableobject.rows.add($(response)).draw(false); - wrapperelement.find('.submission-loading').remove(); - }).fail(function() {}).always(function() { - // Show buttons. - wrapperelement.find('.pagination-loading').remove(); - wrapperelement.find('.submission-loading').remove(); - wrapperelement.find('thead, .dt-button').css('pointer-events', 'auto'); - wrapperelement.find('.dataTables_paginate, .dataTables_info, .dataTables_length, .dataTables_filter').css('visibility', 'visible'); - }); - } - - function initDatatable(is_responsive) { - $(".datatabletest").each(function () { - // Class that determines whether all data for the databale has been full loaded. - var fullloaded = $(this).hasClass('full-loaded'); - - table_obj_list[$(this).attr('id')] = $(this).DataTable( { - 'order': [], - stateSave: true, - language: { - searchPanes: { - collapse: {0: $('#search_pane_button').val() || 'Filter', _:($('#search_pane_button').val() || 'Filter') + ' (%d)'} - } - }, - buttons:[ - - ], - dom: 'Blfrtip', - columnDefs:[ - { - searchPanes:{show: false}, - targets: ['studentname','addition-multiple-button'], - bSortable: false - }, - { - searchPanes: {show: false}, - targets: ['lastname_cell','firstname_cell','tableheadpersonaldeadline', 'tableheaddate', 'tableheadfilename', 'tableheadplagiarismalert', 'plagiarism', 'agreedgrade', 'feedbackandgrading', 'provisionalgrade', 'tableheadmoderationagreement'] - }, - { - searchPanes:{ - show: true, - header: $('#search_pane_group').val() || 'Group', - }, - targets: 'tableheadgroups', - }, - { - searchPanes:{ - show: true, - header: $('#search_pane_status').val() || 'Status', - getFullText: true, - }, - targets: 'tableheadstatus', - }, - { - searchPanes:{ - show: true, - header: $('#search_pane_firstname').val() || 'First Name Initial', - }, - targets: 'firstname_letter_cell', - }, - { - searchPanes:{ - show: true, - header: $('#search_pane_lastname').val() || 'Last Name Initial', - }, - targets: 'lastname_letter_cell', - }, - { "visible": false, "targets": [ 'lastname_letter_cell','firstname_letter_cell', 'lastname_cell','firstname_cell'] } - ], - select: { - style: 'multi', - selector: '.select-checkbox' - }, - stateSaveParams: function (settings, data) { - data.columns = []; - } - - }); - - if (!fullloaded) { - background_load_table($(this).attr('id')); - } - }); - } - - if(isMobileDevice() && $(window).width() < 768) { - // For small screens. - var table = $('.datatabletest tbody').on('click', 'td.details-control', function () { - var tr = $(this).closest("tr"); - var row_id = tr.attr('id').replace('allocatable_', ''); - var table_id = 'assessorfeedbacktable_' + row_id; - - if ($(tr).next('tr.row_assessors').length > 0) { - $(tr).next('tr.row_assessors').remove(); - } - else { - // As originally written this code created a new table with duplicate IDs. - // See comment on CTP-3783 below for more info. - const oldTable = $('#' + table_id); - const newRow = $( - '' - ); - oldTable.addClass('assessors_expanded').css('width', '95%').appendTo(newRow.find('td')); - } - $(tr).toggleClass('shown'); - }); - } - else { - // Add event listener for opening and closing details. - $('.datatabletest tbody').on('click', 'td.details-control', function () { - var tr = $(this).closest("tr"); - var table_key = $(this).closest('.datatabletest').attr('id'); - var table = table_obj_list[table_key]; - if (table) { - var row = table.row( tr ); - - var row_id = tr.attr('id').replace('allocatable_', ''); - var table_id = 'assessorfeedbacktable_' + row_id; - const oldTable = $('#' + table_id); - if (oldTable.length) { - const subRow = $('#sub-row-' + tr.data('allocatable')); - if (subRow.length === 0) { - // Open this row - create as sub-row. - // CTP-3783 As originally written this code cloned the old table and added its HTML again to the new row. - // This meant that we had 2 x tables do duplicate IDs, with the old table hidden and new one visible. - // Then multiple behat tests failed when trying to click the hidden feedback button not visible one. - const newRow = $( - '' - ); - oldTable.addClass('assessors_expanded').css('width', '95%').appendTo(newRow.find('td')); - oldTable.show(); - row.child(newRow).show(); - tr.addClass('shown'); - } else { - // Sub-row already exists. - if (subRow.css('display') === 'none') { - subRow.show(); - tr.addClass('shown'); - } else { - // This row is already open - close it. - tr.removeClass('shown'); - subRow.hide(); - } - } - } else { - // No need to move table - just open/close. - if (subRow.css('display') === 'none') { - subRow.show(); - tr.addClass('shown'); - } else { - // This row is already open - close it. - subRow.hide(); - tr.removeClass('shown'); - } - } - } - }); - } - - $('.datatabletest').on('click', '.splitter-firstname, .splitter-lastname, .splitter-email', function (event) { - event.preventDefault(); - var node = $(event.target), - isAscending = node.hasClass('sorting_asc'), - currentsort = 'asc', sortby = 'desc'; - if (!isAscending) { - currentsort = 'desc'; - sortby = 'asc'; - } - var table_id = $(this).closest('.datatabletest').attr('id'); - table = table_obj_list[table_id]; - var headerclass = $(this).hasClass('splitter-firstname') ? 'firstname_cell' : 'lastname_cell'; - headerclass = $(this).hasClass('splitter-email') ? 'email_cell' : headerclass; - console.log(headerclass); - var sortColumn = table.column('.' + headerclass).index(); - table.order([sortColumn, sortby]).draw(); - - node.addClass('sorting_' + sortby).removeClass('sorting sorting_' + currentsort); - node.parent().removeClass('sorting sorting_asc sorting_desc'); - node.siblings().removeClass('sorting_asc sorting_desc').addClass('sorting'); - }); -}); - -function isMobileDevice() { - return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)); -} diff --git a/coursework_edit.js b/coursework_edit.js deleted file mode 100644 index a43000e3..00000000 --- a/coursework_edit.js +++ /dev/null @@ -1,915 +0,0 @@ -// Add the init function: -function notification_init() { - // Init stuff ... -} - -/** - * - * @param row - * @returns {boolean} - */ -function compare_row(row) { - return (this == row.DT_RowId); -} - - -var now = new Date(); -var extension_form_change = false; -window.addEventListener('beforeunload', (event) => { - if (table_obj_list) { - for (var table_id in table_obj_list) { - table_obj_list[table_id].state.save(); - } - } -}); -$(document).ready(function () { - function log_datatable_navigate(tr) { - var row_id = tr.attr('id'); - var tableid = tr.closest('table').attr('id'); - var key = 'datatable_navigate_' + window.location.href + tableid; - localStorage.setItem(key, row_id); - } - - /* plagiarism flag */ - $('.datatabletest').on('click', '.new_plagiarism_flag', function (e) { - log_datatable_navigate($(this).closest('tr')); - }); - - $('.datatabletest').on('click', '.edit_plagiarism_flag', function (e) { - log_datatable_navigate($(this).closest('tr')); - }); - - /* feedback */ - $('.datatabletest').on('click', '.new_final_feedback', function (e) { - log_datatable_navigate($(this).closest('tr')); - }); - - $('.datatabletest').on('click', '.edit_final_feedback', function (e) { - log_datatable_navigate($(this).closest('tr')); - }); - - $('.datatabletest').on('click', '.show_feedback', function (e) { - log_datatable_navigate($(this).closest('tr')); - }); - - /* assessor feedback */ - $('.datatabletest').on('click', '.assessor_feedback_grade .new_feedback', function (e) { - log_datatable_navigate($(this).closest('td.assessors').closest('table.assessors').closest('tr').prev()); - }); - - $('.datatabletest').on('click', '.assessor_feedback_grade .show_feedback', function (e) { - log_datatable_navigate($(this).closest('td.assessors').closest('table.assessors').closest('tr').prev()); - }); - - $('.datatabletest').on('click', '.assessor_feedback_grade .edit_feedback', function (e) { - log_datatable_navigate($(this).closest('td.assessors').closest('table.assessors').closest('tr').prev()); - }); - - /* deadline extension */ - $('.datatabletest').on('click', '.new_deadline_extension', function (e) { - log_datatable_navigate($(this).closest('tr')); - }); - - $('.datatabletest').on('click', '.edit_deadline_extension', function (e) { - log_datatable_navigate($(this).closest('tr')); - }); - - /* submission */ - $('.datatabletest').on('click', '.new_submission', function (e) { - log_datatable_navigate($(this).closest('tr')); - }); - - // Prepare Message - var datatables_lang_messages = JSON.parse($('#datatables_lang_messages').attr('data-lang')); - -/** - * Personal Deadline - */ - $('.datatabletest').on('click', '.edit_personal_deadline',function (e) { - e.preventDefault(); - var parent = $(this).closest('.personal_deadline_cell'); - parent.children('.show_personal_dealine').addClass('display-none'); - var change_form = parent.children('.show_edit_personal_dealine'); - var data_get = $(this).attr('data-get'); - var data_time = $(this).attr('data-time-iso-8601'); - if (change_form.html().length === 1) { - var form = ''; - form += '
'; - form += '
'; - $(change_form).html(form); - } - $(change_form).removeClass('display-none'); - }); - - $('.datatabletest').on('click', '.cancel-personal-deadline', function (e) { - e.preventDefault(); - $(this).closest('.show_edit_personal_dealine').addClass('display-none'); - $(this).closest('.personal_deadline_cell').children('.show_personal_dealine').removeClass('display-none'); - }); - - $('.datatabletest').on('click', '.approve-personal-deadline', function (e) { - e.preventDefault(); - var deadline = $(this); - var data_get = $(deadline).attr('data-get'); - var value = $(deadline).closest('.show_edit_personal_dealine').children('.input-personal-deadline').val(); - var input_date = new Date(value); - if (input_date <= Date.parse(now)) { - (new M.core.alert({ - message: datatables_lang_messages.alert_validate_deadline.replace(/\_/g, ' '), - title: datatables_lang_messages.notification_info, - })).show(); - return 0; - } - - var url = datatables_lang_messages.url_root + "/mod/coursework/actions/personal_deadline.php"; - var param = JSON.parse(data_get); - param.personal_deadline_time = value; - - $.ajax({ - type: "POST", - url: url, - data: param, - beforeSend: function () { - $('html, body').css("cursor", "wait"); - $(self).prev('img').css('visibility', 'visible'); - }, - success: function (response) { - $('html, body').css("cursor", "auto"); - data_response = JSON.parse(response); - if (data_response.error == 1) { - (new M.core.alert({ - message: data_response.message, - title: datatables_lang_messages.notification_info, - })).show(); - } else { - var parent = $(deadline).closest('.personal_deadline_cell'); - $(parent).attr('data-order', data_response.timestamp); - var table = table_obj_list[Object.keys(table_obj_list)[0]]; - table.row('#' + $(parent).closest('tr').attr('id')).invalidate(); - - $(parent).children('.show_personal_dealine').children('.content_personal_deadline').html(data_response.time); - $(parent).children('.show_edit_personal_dealine').addClass('display-none'); - $(parent).children('.show_personal_dealine').removeClass('display-none'); - (new M.core.alert({ - message: datatables_lang_messages.alert_personaldeadline_save_successful.replace(/\_/g, ' '), - title: datatables_lang_messages.notification_info, - })).show(); - } - }, - error: function () { - $('html, body').css("cursor", "auto"); - }, - complete: function () { - $('html, body').css("cursor", "auto"); - } - }); - - }); - - /*************************** - * Extensions - */ - - /** - * Add new extension - */ - $('.datatabletest').on('click', '.new_deadline_extension', function (e) { - e.preventDefault(); - var data_name = $(this).attr('data-name'); - var data_params = JSON.parse($(this).attr('data-params')); - var data_time = JSON.parse($(this).attr('data-time')); - var current_rowid = $(this).closest('tr').attr('id'); - extension_new_change_data_form(data_name, data_params, data_time, current_rowid); - $('#modal-ajax').modal('show'); - }); - - /** - * Edit extensions - */ - $('.datatabletest').on('click', '.edit_deadline_extension', function (e) { - - e.preventDefault(); - var data_name = $(this).attr('data-name'); - var data_params = JSON.parse($(this).attr('data-params')); - var data_time = JSON.parse($(this).attr('data-time')); - var current_rowid = $(this).closest('tr').attr('id'); - extension_edit_change_data_form(data_name, data_params, data_time, current_rowid); - $('#modal-ajax').modal('show'); - }); - - /** - * Submit save extension - */ - $('.modal-footer').on('click', '#extension-submit', function (e) { - e.preventDefault(); - var params = {}; - params.allocatabletype = $('#extension-allocatabletype').val(); - params.allocatableid = $('#extension-allocatableid').val(); - params.courseworkid = $('#extension-courseworkid').val(); - params.id = $('#extension-id').val(); - params.extended_deadline = $('#extension-extend-deadline').val(); - params.editor = $('#extension-time-content').html(); - params.text = $('#id_extra_information').val(); - params.submissionid = $('#extension-submissionid').val(); - params.pre_defined_reason = $('#extension-reason-select').val(); - params.requesttype = 'submit'; - current_rowid = $('#button-id').val(); - var url = datatables_lang_messages.url_root; - $.ajax({ - type: "POST", - url: url + "/mod/coursework/actions/ajax/deadline_extension/submit.php", - data: params, - beforeSend: function () { - $('html, body').css("cursor", "wait"); - $('.modal-footer').children('img').css('visibility', 'visible'); - }, - success: function (response) { - var data_response = JSON.parse(response); - $('html, body').css("cursor", "auto"); - $('.modal-footer').children('img').css('visibility', 'hidden'); - if (data_response.error == 1) { - (new M.core.alert({ - message: data_response.messages, - title: datatables_lang_messages.notification_info, - })).show(); - } else { - if (Object.keys(table_obj_list).length > 0) { - // Get the first datatable object. - var table = table_obj_list[Object.keys(table_obj_list)[0]]; - var current_row_data = table.row('#' + current_rowid).data(); - var submissiondateindex = table.column('.tableheaddate').index(); - var current_moderation_cell_data = data_response.content; - current_row_data[submissiondateindex] = current_moderation_cell_data; - var table_row = table.row('#' + current_rowid); - table_row.data(current_row_data); - var dom_row = $('#' + current_rowid); - dom_row.find('.time_submitted_cell').attr('data-order', current_moderation_cell_data['@data-order']); - dom_row.find('.edit_personal_deadline').remove(); - table_row.invalidate(); - $('#extension-id').val(data_response.data.id); - } - - change__status_extension_submit_button(true); - save_extension_form_data(); - - (new M.core.alert({ - message: datatables_lang_messages.alert_extension_save_successful.replace(/\_/g, ' '), - title: datatables_lang_messages.notification_info, - })).show(); - } - }, - error: function () { - $('html, body').css("cursor", "auto"); - }, - complete: function () { - $('html, body').css("cursor", "auto"); - } - }); - }); - - - /** - * Function close button - */ - $('#modal-ajax').on('hide.bs.modal', function (e) { - var self = this; - if(is_data_extension_form_change()) { - var confirm = new M.core.confirm({ - title: datatables_lang_messages.notification_leave_form_title.replace(/\_/g, ' '), - question: datatables_lang_messages.notification_leave_form_message.replace(/\_/g, ' '), - yesLabel: datatables_lang_messages.notification_yes_label, - noLabel: datatables_lang_messages.notification_no_label, - }); - - confirm.on('complete-yes',function() { - save_extension_form_data(); - confirm.hide(); - confirm.destroy(); - $(self).modal('hide'); - }); - - confirm.on('complete-no',function() { - confirm.hide(); - confirm.destroy(); - return false; - }); - - confirm.show(); - return false; - } - return true; - }); - - /** - * Function next button - */ - $('.modal-footer').on('click', '#extension-next', function (e) { - e.preventDefault(); - - if (is_data_extension_form_change()) { - var confirm = new M.core.confirm({ - title: datatables_lang_messages.notification_leave_form_title.replace(/\_/g, ' '), - question: datatables_lang_messages.notification_leave_form_message.replace(/\_/g, ' '), - yesLabel: datatables_lang_messages.notification_yes_label, - noLabel: datatables_lang_messages.notification_no_label, - }); - - confirm.on('complete-yes', function () { - confirm.hide(); - confirm.destroy(); - if (Object.keys(table_obj_list).length > 0) { - - var self = $(this); - var prev_rowid = $('#button-id').val(); - - // Get the first datatable object. - var table = table_obj_list[Object.keys(table_obj_list)[0]]; - - var prev_row_index = table.row('#' + prev_rowid).index(); - - - var current_row_index = prev_row_index + 1; - - if (table.row(current_row_index)) { - var current_row_data = table.row(current_row_index).data(); - if (current_row_data) { - var current_rowid = table.row(current_row_index).id(); - - var submissiondateindex = table.column('.tableheaddate').index(); - var current_cell_data = current_row_data[submissiondateindex]; - if (current_cell_data) { - var tmp_node = $('
').html(current_cell_data.display); - var submisiondate = $(tmp_node).find('.new_deadline_extension'); - if (submisiondate.length > 0) { - var data_params = JSON.parse(submisiondate.attr('data-params')); - var data_name = submisiondate.attr('data-name'); - var data_time = JSON.parse(submisiondate.attr('data-time')); - extension_new_change_data_form(data_name, data_params, data_time, current_rowid); - } else { - submisiondate = $(tmp_node).find('.edit_deadline_extension'); - var data_params = JSON.parse(submisiondate.attr('data-params')); - var data_name = submisiondate.attr('data-name'); - var data_time = JSON.parse(submisiondate.attr('data-time')); - extension_edit_change_data_form(data_name, data_params, data_time, current_rowid); - } - } - } - else { - $('#extension-next').prop('disabled', true); - (new M.core.alert({ - message: datatables_lang_messages.alert_no_extension.replace(/\_/g, ' '), - title: datatables_lang_messages.notification_info, - })).show(); - } - } - } - }); - - confirm.on('complete-no', function () { - confirm.hide(); - confirm.destroy(); - - }); - - confirm.show(); - } else { - if (Object.keys(table_obj_list).length > 0) { - - var self = $(this); - var prev_rowid = $('#button-id').val(); - - // Get the first datatable object. - var table = table_obj_list[Object.keys(table_obj_list)[0]]; - - var ordereddata = table.rows( { order: 'applied', search: 'applied' } ).data().toArray(); - var prev_row_index = ordereddata.findIndex(compare_row, prev_rowid); - - - var current_row_index = prev_row_index + 1; - - if (table.row(current_row_index)) { - var current_row_data = ordereddata[current_row_index]; - if (typeof current_row_data != 'undefined') { - var current_rowid = current_row_data.DT_RowId; - - var submissiondateindex = table.column('.tableheaddate').index(); - var current_cell_data = current_row_data[submissiondateindex]; - if (current_cell_data) { - var tmp_node = $('
').html(current_cell_data.display); - var submisiondate = $(tmp_node).find('.new_deadline_extension'); - if (submisiondate.length > 0) { - var data_params = JSON.parse(submisiondate.attr('data-params')); - var data_name = submisiondate.attr('data-name'); - var data_time = JSON.parse(submisiondate.attr('data-time')); - extension_new_change_data_form(data_name, data_params, data_time, current_rowid); - } else { - submisiondate = $(tmp_node).find('.edit_deadline_extension'); - var data_params = JSON.parse(submisiondate.attr('data-params')); - var data_name = submisiondate.attr('data-name'); - var data_time = JSON.parse(submisiondate.attr('data-time')); - extension_edit_change_data_form(data_name, data_params, data_time, current_rowid); - } - } - } - else { - $('#extension-next').prop('disabled', true); - (new M.core.alert({ - message: datatables_lang_messages.alert_no_mitigation.replace(/\_/g, ' '), - title: datatables_lang_messages.notification_info, - })).show(); - } - } - } - } - - - }); - - /** - * Function back button - */ - $('.modal-footer').on('click', '#extension-back', function (e) { - e.preventDefault(); - if (is_data_extension_form_change()) { - var confirm = new M.core.confirm({ - title: datatables_lang_messages.notification_leave_form_title.replace(/\_/g, ' '), - question: datatables_lang_messages.notification_leave_form_message.replace(/\_/g, ' '), - yesLabel: datatables_lang_messages.notification_yes_label, - noLabel: datatables_lang_messages.notification_no_label, - }); - - confirm.on('complete-yes', function () { - confirm.hide(); - confirm.destroy(); - if (Object.keys(table_obj_list).length > 0) { - - var self = $(this); - var prev_rowid = $('#button-id').val(); - - // Get the first datatable object. - var table = table_obj_list[Object.keys(table_obj_list)[0]]; - - var prev_row_index = table.row('#' + prev_rowid).index(); - - - var current_row_index = prev_row_index - 1; - - if (table.row(current_row_index)) { - var current_row_data = table.row(current_row_index).data(); - if (current_row_data) { - var current_rowid = table.row(current_row_index).id(); - - var submissiondateindex = table.column('.tableheaddate').index(); - var current_cell_data = current_row_data[submissiondateindex]; - if (current_cell_data) { - var tmp_node = $('
').html(current_cell_data.display); - var submisiondate = $(tmp_node).find('.new_deadline_extension'); - if (submisiondate.length > 0) { - var data_params = JSON.parse(submisiondate.attr('data-params')); - var data_name = submisiondate.attr('data-name'); - var data_time = JSON.parse(submisiondate.attr('data-time')); - extension_new_change_data_form(data_name, data_params, data_time, current_rowid); - } else { - submisiondate = $(tmp_node).find('.edit_deadline_extension'); - var data_params = JSON.parse(submisiondate.attr('data-params')); - var data_name = submisiondate.attr('data-name'); - var data_time = JSON.parse(submisiondate.attr('data-time')); - extension_edit_change_data_form(data_name, data_params, data_time, current_rowid); - } - } - } - else { - $('#extension-back').prop('disabled', true); - (new M.core.alert({ - message: datatables_lang_messages.alert_no_mitigation.replace(/\_/g, ' '), - title: datatables_lang_messages.notification_info, - })).show(); - } - } - } - }); - - confirm.on('complete-no', function () { - confirm.hide(); - confirm.destroy(); - }); - - confirm.show(); - } else { - if (Object.keys(table_obj_list).length > 0) { - - var self = $(this); - var prev_rowid = $('#button-id').val(); - - // Get the first datatable object. - var table = table_obj_list[Object.keys(table_obj_list)[0]]; - - var ordereddata = table.rows( { order: 'applied', search: 'applied' } ).data().toArray(); - var prev_row_index = ordereddata.findIndex(compare_row, prev_rowid); - - - var current_row_index = prev_row_index - 1; - - if (table.row(current_row_index)) { - var current_row_data = ordereddata[current_row_index]; - if (typeof current_row_data != 'undefined') { - var current_rowid = current_row_data.DT_RowId; - - var submissiondateindex = table.column('.tableheaddate').index(); - var current_cell_data = current_row_data[submissiondateindex]; - if (current_cell_data) { - var tmp_node = $('
').html(current_cell_data.display); - var submisiondate = $(tmp_node).find('.new_deadline_extension'); - if (submisiondate.length > 0) { - var data_params = JSON.parse(submisiondate.attr('data-params')); - var data_name = submisiondate.attr('data-name'); - var data_time = JSON.parse(submisiondate.attr('data-time')); - extension_new_change_data_form(data_name, data_params, data_time, current_rowid); - } else { - submisiondate = $(tmp_node).find('.edit_deadline_extension'); - var data_params = JSON.parse(submisiondate.attr('data-params')); - var data_name = submisiondate.attr('data-name'); - var data_time = JSON.parse(submisiondate.attr('data-time')); - extension_edit_change_data_form(data_name, data_params, data_time, current_rowid); - } - } - } - else { - $('#extension-back').prop('disabled', true); - (new M.core.alert({ - message: datatables_lang_messages.alert_no_mitigation.replace(/\_/g, ' '), - title: datatables_lang_messages.notification_info, - })).show(); - } - } - } - } - - - }); - - function extension_edit_change_data_form(data_name, data_params, data_time, current_rowid) { - var title = 'Editing the extension for ' + data_name; - var time_content = 'Default deadline: ' + data_time.time_content; - $('#extension-modal-title').html(title); - $('#form-extension').find('input[type=hidden]').val(""); - $('#form-extension').find('textarea').val(""); - $('#button-id').val(current_rowid); - $('#extension-submissionid').val(data_params.submissionid); - $('#extension-name').val(data_name); - data_params.requesttype = 'edit'; - var url = datatables_lang_messages.url_root; - $.ajax({ - type: "GET", - url: url + "/mod/coursework/actions/ajax/deadline_extension/edit.php", - data: data_params, - beforeSend: function () { - change__status_extension_submit_button(true); - $('html, body').css("cursor", "wait"); - $('.modal-footer').children('img').css('visibility', 'visible'); - }, - success: function (response) { - var data_response = JSON.parse(response); - $('html, body').css("cursor", "auto"); - $('.modal-footer').children('img').css('visibility', 'hidden'); - if (data_response.error == 1) { - (new M.core.alert({ - message: data_response.message + ' .Please reload the page!', - title: datatables_lang_messages.notification_info, - })).show(); - } else { - var extension = data_response.data; - if (extension.time_content) { - $('#extension-time-content').html(extension.time_content); - } else { - $('#extension-time-content').html(time_content); - } - document.getElementById('extension-extend-deadline').value = data_response.data.time_iso_8601.slice(0,16); - $('#extension-reason-select').val(extension.pre_defined_reason); - $('#extension-allocatabletype').val(extension.allocatabletype); - $('#extension-allocatableid').val(extension.allocatableid); - $('#extension-courseworkid').val(extension.courseworkid); - $('#extension-id').val(extension.id); - - $('#id_extra_information').val(extension.text); - - $('#id_extra_information').prop('disabled', false); - $('#extension-extend-deadline').prop('disabled', false); - $('#extension-reason-select').prop('disabled', false); - save_extension_form_data(); - } - }, - error: function () { - $('html, body').css("cursor", "auto"); - change__status_extension_submit_button(false); - }, - complete: function () { - $('html, body').css("cursor", "auto"); - change__status_extension_submit_button(false); - } - }); - } - - function extension_new_change_data_form(data_name, data_params, data_time, current_rowid) { - var title = 'New extension for ' + data_name; - $('#extension-modal-title').html(title); - $('#form-extension').find('input[type=hidden]').val(''); - $('#form-extension').find('textarea').val(''); - - if(data_time.is_have_deadline == '1') { - var url = datatables_lang_messages.url_root; - $.ajax({ - type: "GET", - url: url + "/mod/coursework/actions/ajax/deadline_extension/new.php", - data: data_params, - beforeSend: function () { - change__status_extension_submit_button(true); - $('html, body').css("cursor", "wait"); - $('.modal-footer').children('img').css('visibility', 'visible'); - }, - success: function (response) { - $('html, body').css("cursor", "auto"); - $('.modal-footer').children('img').css('visibility', 'hidden'); - var data_response = JSON.parse(response); - $('#extension-time-content').html(data_response.data.time_content); - document.getElementById('extension-extend-deadline').value = data_response.data.time_iso_8601.slice(0,16); - save_extension_form_data(); - }, - error: function () { - $('html, body').css("cursor", "auto"); - }, - complete: function () { - $('html, body').css("cursor", "auto"); - } - }); - } else { - save_extension_form_data(); - } - $('#extension-reason-select').val(''); - $('#extension-allocatabletype').val(data_params.allocatabletype); - $('#extension-allocatableid').val(data_params.allocatableid); - $('#extension-courseworkid').val(data_params.courseworkid); - $('#extension-submissionid').val(data_params.submissionid); - $('#extension-name').val(data_name); - $('#button-id').val(current_rowid); - - $('#id_extra_information').prop('disabled', false); - $('#extension-extend-deadline').prop('disabled', false); - $('#extension-reason-select').prop('disabled', false); - } - - - $("#form-extension :input").change(function () { - extension_form_change = true; - change__status_extension_submit_button(false); - }); - - function change__status_extension_submit_button(status) { - $('#extension-submit').prop('disabled', status); - } - - function save_extension_form_data() { - extension_form_change = false; - } - - function is_data_extension_form_change() { - return extension_form_change; - } - - /** - * Feedback - */ - $('.datatabletest').on('click', '.new_final_feedback, .new_feedback, .edit_final_feedback, .edit_feedback, .show_feedback', function (e) { - e.preventDefault(); - var url = $(this).attr('href'); - $.ajax({ - type: "GET", - url: url+'&ajax=1' - }).done(function(response) { - response = $.parseJSON(response); - var modalbody = $('#modal-grading').find('.modal-body'); - // Careful as not all requests return a response.success value. Only if it's false, show error. - if ((response.success ?? true) === false && (response.message ?? null)) { - modalbody.html(response.message); - } else { - modalbody.html(response.formhtml); - var filemanager = modalbody.find('.filemanager'); - if (response.filemanageroptions && filemanager.length) { - var elementid = filemanager.attr('id'); - var clientid = elementid.substr(12); - if (clientid) { - response.filemanageroptions.client_id = clientid; - M.form_filemanager.init(Y, response.filemanageroptions); - } - } - if (response.editoroptions) { - require(['editor_tiny/editor'], (Tiny) => { - Tiny.setupForElementId({ - elementId: 'id_feedbackcomment', - options: JSON.parse(response.editoroptions), - }); - }); - } - - if (response.commentoptions) { - M.util.js_pending('gradingform_guide/comment_chooser'); - require(['gradingform_guide/comment_chooser'], function(amd) { - $(".remark").each( function (i,ele) { - buttonele = $(ele).find(".commentchooser"); - textele = $(ele).find(".markingguideremark"); - buttonid = $(buttonele).attr("id"); - textid = $(textele).attr("id"); - amd.initialise(1, buttonid, textid, response.commentoptions); - M.util.js_complete('gradingform_guide/comment_chooser'); - - }) - - }); - } - } - }); - var cell_td = $(this).closest('td'); - var cell_selector = get_td_cell_selector(cell_td); - var cell_type = cell_td.attr('data-class-name'); - show_loading_modal_grading(cell_selector, cell_type); - }); - - /** - * - * @param td_cell - * @returns {string} - */ - function get_td_cell_selector(td_cell) { - var result = '.' + td_cell.attr('class').replaceAll(' ', '.'); - var tr_cell = td_cell.closest('tr'); - if (tr_cell.attr('id')) { - result = '#' + tr_cell.attr('id') + ' ' + result; - } else { - result = '.' + tr_cell.attr('class').replaceAll(' ', '.') + ' ' + result; - } - return result; - } - - /** - * - * @param cell_selector - * @param cell_type - */ - function show_loading_modal_grading(cell_selector, cell_type) { - // Set row id. - var modal = $('#modal-grading'); - modal.find('#cell_selector').val(cell_selector); - modal.find('#cell_type').val(cell_type); - modal.find('.modal-body').html(' loading'); - $('#modal-grading').modal('show'); - } - - $('#modal-grading').on('click', '#id_submitfeedbackbutton, #id_submitbutton', function (e) { - e.preventDefault(); - var button = $(this); - button.prop('disabled', true); - var submitbutton = (button.attr('id') == 'id_submitbutton') ? 1 : 0; - var removefeedbackbutton = (button.attr('id') == 'id_removefeedbackbutton') ? 1 : 0; - var submitfeedbackbutton = (button.attr('id') == 'id_submitfeedbackbutton') ? 1 : 0; - var modal = $('#modal-grading'); - var url = '/mod/coursework/actions/feedbacks/create.php'; - var form_data = modal.find('form').serializeArray(); - for (var i = 0, length = form_data.length; i < length; i++) { - if (form_data[i].name == 'feedbackid' && !isNaN(parseInt(form_data[i].value)) && form_data[i].value != '0') { - url = '/mod/coursework/actions/feedbacks/update.php'; - break; - } - } - var cell_type = modal.find('#cell_type').val(); - update_feedback(form_data,url,cell_type,submitbutton,removefeedbackbutton,submitfeedbackbutton,0,button); - /* - form_data = form_data.concat({name: 'ajax', value: 1}, - {name: 'cell_type', value: cell_type}, - {name: 'submitbutton', value: submitbutton}, - {name: 'removefeedbackbutton', value: removefeedbackbutton}); - $.ajax({ - type: 'POST', - data: form_data, - url: url, - dataType: 'json' - }).done(function(response) { - console.log(response); - if (response.success) { - var cell_selector = modal.find('#cell_selector').val(); - $(cell_selector).html(response.html); - $('#modal-grading').modal('hide'); - if (submitbutton == 1) { - alert('Your data has been saved.'); - } else { - alert('The feedback has been removed.'); - } - } else { - alert('Sorry! There was an error with your request.'); - } - }).always(function() { - me.prop('disabled', false); - });*/ - }); - - $('#modal-grading').on('click', '#id_cancel', function (e) { - e.preventDefault(); - $('#modal-grading').modal('hide'); - }); - - $('#modal-grading').on('click', '#id_removefeedbackbutton', function (e) { - e.preventDefault(); - var button = $(this); - button.prop('disabled', true); - if (confirm('do you want to remove feedback')) { - var submitbutton = (button.attr('id') == 'id_submitbutton') ? 1 : 0; - var removefeedbackbutton = (button.attr('id') == 'id_removefeedbackbutton') ? 1 : 0; - var submitfeedbackbutton = (button.attr('id') == 'id_submitfeedbackbutton') ? 1 : 0; - var modal = $('#modal-grading'); - var url = '/mod/coursework/actions/feedbacks/update.php'; - var form_data = modal.find('form').serializeArray(); - var cell_type = modal.find('#cell_type').val(); - update_feedback(form_data, url, cell_type, submitbutton, removefeedbackbutton, submitfeedbackbutton,1, button); - } - }); - - function update_feedback(form_data,url,celltype,submitbutton,removefeedbackbutton,submitfeedbackbutton,confirm,button) { - - form_data = form_data.concat({name: 'ajax', value: 1}, - {name: 'cell_type', value: celltype}, - {name: 'submitbutton', value: submitbutton}, - {name: 'submitfeedbackbutton', value: submitfeedbackbutton}, - {name: 'removefeedbackbutton', value: removefeedbackbutton}, - {name: 'confirm', value: confirm}); - - $.ajax({ - type: 'POST', - data: form_data, - url: url, - dataType: 'json' - }).done(function(response) { - if ((response.success ?? true) === false && (response.message ?? null)) { - // Could be an error like "Please provide a valid grade for each criterion". - $('#modal-grading').find('.modal-body').html( - '
' + response.message + '
' - ); - } else if (response.success) { - var cell_selector = $('#modal-grading').find('#cell_selector').val(); - $(cell_selector).html(response.html); - - if (typeof response.extrahtml !== 'undefined' && response.extrahtml != '') { - $(cell_selector).next('td').html(response.extrahtml); - } - if (typeof response.assessdate !== 'undefined' && response.assessdate != '') { - $(cell_selector).next('td').html(response.assessdate); - } - - if (typeof response.assessorname !== 'undefined' && response.assessorname != '') { - $(cell_selector).prev('td').html(response.assessorname); - } - - if (typeof response.assessortwo !== 'undefined' && response.assessortwo != '') { - var tdcell = $(cell_selector).closest('tr').next().find('td')[1]; - $(tdcell).html(response.assessortwo); - } - - if (typeof response.finalhtml !== 'undefined' && response.assessortwo != '') { - var tablerowid = 'allocatable_' + response.allocatableid; - var tdcell2 = $('#' + tablerowid).find('.multiple_agreed_grade_cell')[0]; - $(tdcell2).html(response.finalhtml); - } - var datatables_lang_messages_two = JSON.parse($('#datatables_lang_messages').attr('data-lang')); - $('#modal-grading').modal('hide') - if (submitbutton === 1) { - (new M.core.alert({ - message: datatables_lang_messages_two.alert_feedback_save_successful.replace(/\_/g, ' '), - title: datatables_lang_messages_two.notification_info, - })).show(); - - } else if (submitfeedbackbutton === 1) { - (new M.core.alert({ - message: datatables_lang_messages_two.alert_feedback_draft_save_successful.replace(/\_/g, ' '), - title: datatables_lang_messages_two.notification_info, - })).show(); - - } else { - (new M.core.alert({ - message: datatables_lang_messages_two.alert_feedback_remove_successful.replace(/\_/g, ' '), - title: datatables_lang_messages_two.notification_info, - })).show(); - } - } else { - (new M.core.alert({ - message: response.message, - title: datatables_lang_messages_two.notification_info, - })).show(); - - error_wrapper_element.prepend('
' + response.message + '
'); - - } - }).always(function(){ - button.prop('disabled', false); - }); - } -}) diff --git a/module.js b/module.js index edb3a890..28dae3e9 100644 --- a/module.js +++ b/module.js @@ -30,7 +30,6 @@ M.mod_coursework = { init_allocate_page: function (e, wwwroot, coursemoduleid) { "use strict"; - // Make the changes to the moderations set dropdowns set the 'in moderations set' // checkboxes automatically. $('.assessor_id_dropdown').change(function () { diff --git a/tests/behat/submissions_early_finalisation.feature b/tests/behat/submissions_early_finalisation.feature index 3d566521..00eb4281 100644 --- a/tests/behat/submissions_early_finalisation.feature +++ b/tests/behat/submissions_early_finalisation.feature @@ -1,4 +1,4 @@ -@mod @mod_coursework +@mod @mod_coursework @mod_coursework_submissions_early_finalisation Feature: Early finalisation of student submissions As a teacher diff --git a/tests/behat/submissions_file_upload_types.feature b/tests/behat/submissions_file_upload_types.feature index 061ba499..630e2ed4 100644 --- a/tests/behat/submissions_file_upload_types.feature +++ b/tests/behat/submissions_file_upload_types.feature @@ -1,4 +1,4 @@ -@mod @mod_coursework +@mod @mod_coursework @mod_coursework_submissions_file_upload_types Feature: Restricting the types of files that students can upload As a teacher diff --git a/view.php b/view.php index 91f7a7eb..21dd257e 100644 --- a/view.php +++ b/view.php @@ -50,8 +50,6 @@ 'strings' => [], ]; -$PAGE->requires->yui_module('moodle-core-notification', 'notification_init'); - // Course_module ID, or coursework instance ID - it should be named as the first character of the module. $coursemoduleid = optional_param('id', 0, PARAM_INT); $courseworkid = optional_param('e', 0, PARAM_INT); @@ -529,11 +527,8 @@ // Require JS files. // Note that jquery datatables files not included as called by coursework.js. if ($cangrade || $canviewstudents) { - // TODO make these into AMD modules. - $jsfiles = ['coursework.js', 'coursework_edit.js']; - foreach ($jsfiles as $jsfile) { - $PAGE->requires->js(new moodle_url("/mod/coursework/$jsfile")); - } + $PAGE->requires->js_call_amd('mod_coursework/coursework', 'init'); + $PAGE->requires->js_call_amd('mod_coursework/coursework_edit', 'init'); } echo $OUTPUT->header();