');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 0000000..df58bec
--- /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,UAAY,WAG9DE,QAAS,GAGTC,IAAK,UACLC,WAAY,CACR,CACIN,YAAa,CAACO,MAAM,GACpBC,QAAS,CAAC,cAAe,4BACzBC,WAAW,GAEf,CACIT,YAAa,CAACO,M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GpE,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 0000000..11b65b1
--- /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('
'
+ );
+ 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'));
- }
- $(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 a43000e..0000000
--- 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(
- '
');
-
- }
- }).always(function(){
- button.prop('disabled', false);
- });
- }
-})
diff --git a/module.js b/module.js
index edb3a89..28dae3e 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 3d56652..00eb428 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 061ba49..630e2ed 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 91f7a7e..21dd257 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();