Skip to content
Snippets Groups Projects
Unverified Commit 9dbce83b authored by Laur0r's avatar Laur0r Committed by GitHub
Browse files

Merge pull request #136 from justusdieckmann/feature/admin-error-page

Implement Process error table
parents 1c70de06 39f85972
No related branches found
No related tags found
No related merge requests found
Showing
with 141 additions and 35 deletions
define ("tool_lifecycle/tablebulkactions",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=function(){var a=document.querySelectorAll("input[name=\"procerror-select\"]"),b=document.querySelectorAll("*[data-lifecycle-action]");b.forEach(function(b){b.onclick=function(c){c.preventDefault();var d=[{k:"action",v:b.getAttribute("data-lifecycle-action")},{k:"sesskey",v:M.cfg.sesskey}];if("1"===b.getAttribute("data-lifecycle-forall")){d.push({k:"all",v:"1"});e(window.location,d)}else{a.forEach(function(a){if(a.checked){d.push({k:"id[]",v:a.value})}});e(window.location,d)}}})};function b(a){if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(a=c(a))){var b=0,d=function(){};return{s:d,n:function n(){if(b>=a.length)return{done:!0};return{done:!1,value:a[b++]}},e:function e(a){throw a},f:d}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f=!0,g=!1,h;return{s:function s(){e=a[Symbol.iterator]()},n:function n(){var a=e.next();f=a.done;return a},e:function e(a){g=!0;h=a},f:function f(){try{if(!f&&null!=e.return)e.return()}finally{if(g)throw h}}}}function c(a,b){if(!a)return;if("string"==typeof a)return d(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return d(a,b)}function d(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c<b;c++){d[c]=a[c]}return d}function e(a,c){var d=document.createElement("form");document.body.appendChild(d);d.method="post";d.action=a;var e=b(c),f;try{for(e.s();!(f=e.n()).done;){var g=f.value,h=document.createElement("input");h.type="hidden";h.name=g.k;h.value=g.v;d.appendChild(h)}}catch(a){e.e(a)}finally{e.f()}d.submit()}});
//# sourceMappingURL=tablebulkactions.min.js.map
{"version":3,"sources":["../src/tablebulkactions.js"],"names":["checkboxes","document","querySelectorAll","action","forEach","a","onclick","e","preventDefault","data","k","v","getAttribute","M","cfg","sesskey","push","redirectPost","window","location","c","checked","value","url","form","createElement","body","appendChild","method","pair","input","type","name","submit"],"mappings":"uIA6CO,UAAgB,IACbA,CAAAA,CAAU,CAAGC,QAAQ,CAACC,gBAAT,CAA0B,kCAA1B,CADA,CAGbC,CAAM,CAAGF,QAAQ,CAACC,gBAAT,CAA0B,0BAA1B,CAHI,CAInBC,CAAM,CAACC,OAAP,CAAe,SAACC,CAAD,CAAO,CAClBA,CAAC,CAACC,OAAF,CAAY,SAACC,CAAD,CAAO,CACfA,CAAC,CAACC,cAAF,GACA,GAAIC,CAAAA,CAAI,CAAG,CACP,CAACC,CAAC,CAAE,QAAJ,CAAcC,CAAC,CAAEN,CAAC,CAACO,YAAF,CAAe,uBAAf,CAAjB,CADO,CAEP,CAACF,CAAC,CAAE,SAAJ,CAAeC,CAAC,CAAEE,CAAC,CAACC,GAAF,CAAMC,OAAxB,CAFO,CAAX,CAIA,GAAgD,GAA5C,GAAAV,CAAC,CAACO,YAAF,CAAe,uBAAf,CAAJ,CAAqD,CACjDH,CAAI,CAACO,IAAL,CAAU,CAACN,CAAC,CAAE,KAAJ,CAAWC,CAAC,CAAE,GAAd,CAAV,EACAM,CAAY,CAACC,MAAM,CAACC,QAAR,CAAkBV,CAAlB,CACf,CAHD,IAGQ,CACJT,CAAU,CAACI,OAAX,CAAmB,SAACgB,CAAD,CAAO,CACtB,GAAIA,CAAC,CAACC,OAAN,CAAe,CACXZ,CAAI,CAACO,IAAL,CAAU,CAACN,CAAC,CAAE,MAAJ,CAAYC,CAAC,CAAES,CAAC,CAACE,KAAjB,CAAV,CACH,CACJ,CAJD,EAKAL,CAAY,CAACC,MAAM,CAACC,QAAR,CAAkBV,CAAlB,CACf,CACJ,CACJ,CAnBD,CAoBH,C,u/BA1CD,QAASQ,CAAAA,CAAT,CAAsBM,CAAtB,CAA2Bd,CAA3B,CAAiC,CAC7B,GAAMe,CAAAA,CAAI,CAAGvB,QAAQ,CAACwB,aAAT,CAAuB,MAAvB,CAAb,CACAxB,QAAQ,CAACyB,IAAT,CAAcC,WAAd,CAA0BH,CAA1B,EACAA,CAAI,CAACI,MAAL,CAAc,MAAd,CACAJ,CAAI,CAACrB,MAAL,CAAcoB,CAAd,CAJ6B,QAKVd,CALU,QAK7B,2BAAyB,IAAdoB,CAAAA,CAAc,SACfC,CAAK,CAAG7B,QAAQ,CAACwB,aAAT,CAAuB,OAAvB,CADO,CAErBK,CAAK,CAACC,IAAN,CAAa,QAAb,CACAD,CAAK,CAACE,IAAN,CAAaH,CAAI,CAACnB,CAAlB,CACAoB,CAAK,CAACR,KAAN,CAAcO,CAAI,CAAClB,CAAnB,CACAa,CAAI,CAACG,WAAL,CAAiBG,CAAjB,CACH,CAX4B,+BAY7BN,CAAI,CAACS,MAAL,EACH,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Javascript controller for checkboxed table.\n * @module tool_lifecycle/tablebulkactions\n * @copyright 2021 Justus Dieckmann WWU\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * Helper function to redirect via POST\n * @param {String} url redirect to\n * @param {Array} data redirect with data\n */\nfunction redirectPost(url, data) {\n const form = document.createElement('form');\n document.body.appendChild(form);\n form.method = 'post';\n form.action = url;\n for (const pair of data) {\n const input = document.createElement('input');\n input.type = 'hidden';\n input.name = pair.k;\n input.value = pair.v;\n form.appendChild(input);\n }\n form.submit();\n}\n\n/**\n * Init function\n */\nexport function init() {\n const checkboxes = document.querySelectorAll('input[name=\"procerror-select\"]');\n\n const action = document.querySelectorAll('*[data-lifecycle-action]');\n action.forEach((a) => {\n a.onclick = (e) => {\n e.preventDefault();\n let data = [\n {k: 'action', v: a.getAttribute('data-lifecycle-action')},\n {k: 'sesskey', v: M.cfg.sesskey}\n ];\n if (a.getAttribute('data-lifecycle-forall') === '1') {\n data.push({k: 'all', v: '1'});\n redirectPost(window.location, data);\n } else {\n checkboxes.forEach((c) => {\n if (c.checked) {\n data.push({k: 'id[]', v: c.value});\n }\n });\n redirectPost(window.location, data);\n }\n };\n });\n}"],"file":"tablebulkactions.min.js"}
\ No newline at end of file
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Javascript controller for checkboxed table.
* @module tool_lifecycle/tablebulkactions
* @copyright 2021 Justus Dieckmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Helper function to redirect via POST
* @param {String} url redirect to
* @param {Array} data redirect with data
*/
function redirectPost(url, data) {
const form = document.createElement('form');
document.body.appendChild(form);
form.method = 'post';
form.action = url;
for (const pair of data) {
const input = document.createElement('input');
input.type = 'hidden';
input.name = pair.k;
input.value = pair.v;
form.appendChild(input);
}
form.submit();
}
/**
* Init function
*/
export function init() {
const checkboxes = document.querySelectorAll('input[name="procerror-select"]');
const action = document.querySelectorAll('*[data-lifecycle-action]');
action.forEach((a) => {
a.onclick = (e) => {
e.preventDefault();
let data = [
{k: 'action', v: a.getAttribute('data-lifecycle-action')},
{k: 'sesskey', v: M.cfg.sesskey}
];
if (a.getAttribute('data-lifecycle-forall') === '1') {
data.push({k: 'all', v: '1'});
redirectPost(window.location, data);
} else {
checkboxes.forEach((c) => {
if (c.checked) {
data.push({k: 'id[]', v: c.value});
}
});
redirectPost(window.location, data);
}
};
});
}
\ No newline at end of file
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
*/ */
namespace tool_lifecycle; namespace tool_lifecycle;
defined('MOODLE_INTERNAL') || die();
/** /**
* Delivers all available action names throughout the plugin. * Delivers all available action names throughout the plugin.
* @package tool_lifecycle * @package tool_lifecycle
......
...@@ -26,8 +26,6 @@ namespace tool_lifecycle\event; ...@@ -26,8 +26,6 @@ namespace tool_lifecycle\event;
use moodle_url; use moodle_url;
use tool_lifecycle\local\entity\process; use tool_lifecycle\local\entity\process;
defined('MOODLE_INTERNAL') || die();
/** /**
* The process_proceeded event class. * The process_proceeded event class.
* *
......
...@@ -27,8 +27,6 @@ namespace tool_lifecycle\event; ...@@ -27,8 +27,6 @@ namespace tool_lifecycle\event;
use moodle_url; use moodle_url;
use tool_lifecycle\local\entity\process; use tool_lifecycle\local\entity\process;
defined('MOODLE_INTERNAL') || die();
/** /**
* The process_rollback event class. * The process_rollback event class.
* *
......
...@@ -27,8 +27,6 @@ namespace tool_lifecycle\event; ...@@ -27,8 +27,6 @@ namespace tool_lifecycle\event;
use moodle_url; use moodle_url;
use tool_lifecycle\local\entity\process; use tool_lifecycle\local\entity\process;
defined('MOODLE_INTERNAL') || die();
/** /**
* The process_triggered event class. * The process_triggered event class.
* *
......
...@@ -31,8 +31,6 @@ use tool_lifecycle\local\manager\trigger_manager; ...@@ -31,8 +31,6 @@ use tool_lifecycle\local\manager\trigger_manager;
use tool_lifecycle\local\manager\settings_manager; use tool_lifecycle\local\manager\settings_manager;
use tool_lifecycle\settings_type; use tool_lifecycle\settings_type;
defined('MOODLE_INTERNAL') || die();
/** /**
* Class to backup a workflow. * Class to backup a workflow.
* @package tool_lifecycle * @package tool_lifecycle
......
...@@ -31,8 +31,6 @@ use tool_lifecycle\local\manager\trigger_manager; ...@@ -31,8 +31,6 @@ use tool_lifecycle\local\manager\trigger_manager;
use tool_lifecycle\local\manager\settings_manager; use tool_lifecycle\local\manager\settings_manager;
use tool_lifecycle\settings_type; use tool_lifecycle\settings_type;
defined('MOODLE_INTERNAL') || die();
/** /**
* Class to restore a workflow. * Class to restore a workflow.
* @package tool_lifecycle * @package tool_lifecycle
......
...@@ -25,8 +25,6 @@ namespace tool_lifecycle\local\data; ...@@ -25,8 +25,6 @@ namespace tool_lifecycle\local\data;
use renderable; use renderable;
defined('MOODLE_INTERNAL') || die();
/** /**
* Class representing a manual trigger tool * Class representing a manual trigger tool
* *
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
*/ */
namespace tool_lifecycle\local\entity; namespace tool_lifecycle\local\entity;
defined('MOODLE_INTERNAL') || die();
/** /**
* Life Cycle Process class * Life Cycle Process class
* *
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
*/ */
namespace tool_lifecycle\local\entity; namespace tool_lifecycle\local\entity;
defined('MOODLE_INTERNAL') || die();
/** /**
* Subplugin class * Subplugin class
* *
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
*/ */
namespace tool_lifecycle\local\entity; namespace tool_lifecycle\local\entity;
defined('MOODLE_INTERNAL') || die();
/** /**
* Subplugin class * Subplugin class
* *
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
*/ */
namespace tool_lifecycle\local\entity; namespace tool_lifecycle\local\entity;
defined('MOODLE_INTERNAL') || die();
/** /**
* Trigger subplugin class * Trigger subplugin class
* *
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
*/ */
namespace tool_lifecycle\local\entity; namespace tool_lifecycle\local\entity;
defined('MOODLE_INTERNAL') || die();
/** /**
* Life Cycle Workflow class * Life Cycle Workflow class
* *
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
*/ */
namespace tool_lifecycle\local\manager; namespace tool_lifecycle\local\manager;
defined('MOODLE_INTERNAL') || die();
/** /**
* Manager for Delayed Courses. * Manager for Delayed Courses.
* *
......
...@@ -27,8 +27,6 @@ use tool_lifecycle\local\entity\process; ...@@ -27,8 +27,6 @@ use tool_lifecycle\local\entity\process;
use tool_lifecycle\processor; use tool_lifecycle\processor;
use tool_lifecycle\local\response\step_interactive_response; use tool_lifecycle\local\response\step_interactive_response;
defined('MOODLE_INTERNAL') || die();
/** /**
* Manager to handle interactions by users * Manager to handle interactions by users
* *
......
...@@ -28,8 +28,6 @@ use tool_lifecycle\trigger\base; ...@@ -28,8 +28,6 @@ use tool_lifecycle\trigger\base;
use tool_lifecycle\trigger\base_automatic; use tool_lifecycle\trigger\base_automatic;
use tool_lifecycle\trigger\base_manual; use tool_lifecycle\trigger\base_manual;
defined('MOODLE_INTERNAL') || die();
/** /**
* Manager to retrive the lib of each subplugin. * Manager to retrive the lib of each subplugin.
* *
......
...@@ -30,8 +30,6 @@ namespace tool_lifecycle\local\manager; ...@@ -30,8 +30,6 @@ namespace tool_lifecycle\local\manager;
use tool_lifecycle\local\entity\process; use tool_lifecycle\local\entity\process;
use tool_lifecycle\local\entity\trigger_subplugin; use tool_lifecycle\local\entity\trigger_subplugin;
defined('MOODLE_INTERNAL') || die();
/** /**
* Manager for data of Life Cycle Processes. * Manager for data of Life Cycle Processes.
* *
......
...@@ -24,12 +24,11 @@ ...@@ -24,12 +24,11 @@
namespace tool_lifecycle\local\manager; namespace tool_lifecycle\local\manager;
use core\event\course_deleted; use core\event\course_deleted;
use Exception;
use tool_lifecycle\local\entity\process; use tool_lifecycle\local\entity\process;
use tool_lifecycle\event\process_proceeded; use tool_lifecycle\event\process_proceeded;
use tool_lifecycle\event\process_rollback; use tool_lifecycle\event\process_rollback;
defined('MOODLE_INTERNAL') || die();
/** /**
* Manager for Life Cycle Processes * Manager for Life Cycle Processes
* *
...@@ -245,4 +244,69 @@ class process_manager { ...@@ -245,4 +244,69 @@ class process_manager {
$steplib->abort_course($process); $steplib->abort_course($process);
self::remove_process($process); self::remove_process($process);
} }
/**
* Moves a process into the procerror table.
*
* @param process $process The process
* @param Exception $e The exception
* @return void
*/
public static function insert_process_error(process $process, Exception $e) {
global $DB;
$procerror = (object) clone $process;
$procerror->errormessage = get_class($e) . ': ' . $e->getMessage();
$procerror->errortrace = $e->getTraceAsString();
$procerror->errortimecreated = time();
$m = '';
foreach ($e->getTrace() as $v) {
$m .= $v['file'] . ':' . $v['line'] . '::';
}
$procerror->errorhash = md5($m);
$procerror->waiting = intval($procerror->waiting);
$DB->insert_record_raw('tool_lifecycle_proc_error', $procerror, false, false, true);
$DB->delete_records('tool_lifecycle_process', ['id' => $process->id]);
}
/**
* Proceed process from procerror back into the process board.
* @param int $processid the processid
* @return void
*/
public static function proceed_process_after_error(int $processid) {
global $DB;
$process = $DB->get_record('tool_lifecycle_proc_error', ['id' => $processid]);
// Unset process error entries.
unset($process->errormessage);
unset($process->errortrace);
unset($process->errorhash);
unset($process->errortimecreated);
$DB->insert_record_raw('tool_lifecycle_process', $process, false, false, true);
$DB->delete_records('tool_lifecycle_proc_error', ['id' => $process->id]);
}
/**
* Rolls back a process from procerror table
* @param int $processid the processid
* @return void
*/
public static function rollback_process_after_error(int $processid) {
global $DB;
$process = $DB->get_record('tool_lifecycle_proc_error', ['id' => $processid]);
// Unset process error entries.
unset($process->errormessage);
unset($process->errortrace);
unset($process->errorhash);
unset($process->errortimecreated);
$DB->insert_record_raw('tool_lifecycle_process', $process, false, false, true);
$DB->delete_records('tool_lifecycle_proc_error', ['id' => $process->id]);
delayed_courses_manager::set_course_delayed_for_workflow($process->courseid, true, $process->workflowid);
self::rollback_process($process);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment