Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #223: Moodle 4.4 support #224

Merged
merged 6 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ More Information on Moodle events can be found in the Moodle documentation at th
## Branches ##
The following maps the plugin version to use depending on your Moodle version.

| Moodle verion | Branch |
| ------------------ | ------------------ |
| Moodle 3.5 to 3.10 | MOODLE_35_STABLE |
| Moodle 3.11+ | MOODLE_311_STABLE |
| Moodle verion | Branch |
|---------------------------|-------------------|
| Moodle 3.5 to 3.10 | MOODLE_35_STABLE |
| Moodle 3.11 to Moodle 4.1 | MOODLE_311_STABLE |
| Moodle 4.4+ | MOODLE_404_STABLE |


## Moodle Plugin Installation
The following sections outline how to install the Moodle plugin.
Expand Down
4 changes: 2 additions & 2 deletions classes/event_processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private function process_realtime_workflow($workflow, $evententry) {
* history and auditing.
*
* @param int $workflowid The workflow id to record.
* @param stdClass $event the event that triggered this workflow.
* @param \stdClass $event the event that triggered this workflow.
* @param int $attemptnum The number of attempts for this event.
* @return int|null the id of the recorded workflow record or null.
*/
Expand Down Expand Up @@ -799,7 +799,7 @@ public static function rerun_all_error_runs($workflow, $historic = false) {
* Records a cancelled workflow, used in debouncing.
*
* @param int $workflowid
* @param stdClass $event
* @param \stdClass $event
* @param int $runid
* @param boolean $deferred
* @return void
Expand Down
1 change: 0 additions & 1 deletion classes/output/manageworkflows/renderable.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public function __construct($uniqueid, \moodle_url $url, $perpage = 100) {
$this->pageable(true);
$this->is_downloadable(false);
$this->define_baseurl($url);
$this->workflowid = 0;
}

/**
Expand Down
7 changes: 3 additions & 4 deletions classes/output/manageworkflows/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class renderer extends \plugin_renderer_base {
* @return string to display on the mangerules page.
*/
protected function render_renderable(renderable $renderable) {
$o = $this->render_add_button($renderable->workflowid);
$o = $this->render_add_button();
$o .= ' ';
$o .= $this->render_import_button();
$o .= $this->render_table($renderable);
Expand Down Expand Up @@ -69,14 +69,13 @@ protected function render_table(renderable $renderable) {
/**
* Html to add a button for adding a new workflow.
*
* @param int $workflowid The workflow the button applies too.
* @return string html for the button.
*/
protected function render_add_button($workflowid) {
protected function render_add_button() {
global $CFG;

$button = \html_writer::tag('button', get_string('addworkflow', 'tool_trigger'), ['class' => 'btn btn-primary']);
$addurl = new \moodle_url($CFG->wwwroot. '/admin/tool/trigger/edit.php', array('workflowid' => $workflowid));
$addurl = new \moodle_url($CFG->wwwroot. '/admin/tool/trigger/edit.php', array('workflowid' => 0));
return \html_writer::link($addurl, $button);
}

Expand Down
6 changes: 3 additions & 3 deletions classes/output/workflowhistory/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function render_workflowhistory_table($workflowid, $searchparams = [], $d
$url = new \moodle_url('/admin/tool/trigger/history.php', $searchparams);
$renderable = new \tool_trigger\output\workflowhistory\workflowhistory_renderable('triggerhistory', $url, $searchparams, $download, 100);

$namefields = get_all_user_name_fields(true, 'u');
$namefields = implode(',', \core_user\fields::get_name_fields());
$sqlfields = "tfh.*, {$namefields}";
$sqlfrom = '{tool_trigger_workflow_hist} tfh LEFT JOIN {user} u ON tfh.userid = u.id';
$sqlwhere = 'tfh.workflowid = :workflow';
Expand Down Expand Up @@ -274,7 +274,7 @@ public function run_actions_button($run, $statusonly = false, $searchparams = []
private function rerun_all_historic_button($workflowid) {
$url = new \moodle_url('/admin/tool/trigger/history.php',
['action' => 'rerunallhist', 'sesskey' => sesskey(), 'id' => $workflowid, 'workflow' => $workflowid]);
$btn = new \single_button($url, get_string('rerunallhist', 'tool_trigger'), 'get', true);
$btn = new \single_button($url, get_string('rerunallhist', 'tool_trigger'), 'get', \single_button::BUTTON_PRIMARY);
echo $this->render($btn);
}

Expand All @@ -286,7 +286,7 @@ private function rerun_all_historic_button($workflowid) {
private function rerun_all_current_button($workflowid) {
$url = new \moodle_url('/admin/tool/trigger/history.php',
['action' => 'rerunallcurr', 'sesskey' => sesskey(), 'id' => $workflowid, 'workflow' => $workflowid]);
$btn = new \single_button($url, get_string('rerunallcurr', 'tool_trigger'), 'get', true);
$btn = new \single_button($url, get_string('rerunallcurr', 'tool_trigger'), 'get', \single_button::BUTTON_PRIMARY);
echo $this->render($btn);
}
}
11 changes: 10 additions & 1 deletion classes/steps/actions/assign_cohort_action_step.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@
require_once($CFG->dirroot.'/cohort/lib.php');

class assign_cohort_action_step extends base_action_step {
use \tool_trigger\helper\datafield_manager;

/** User field.
* @var int
*/
protected $useridfield;

use \tool_trigger\helper\datafield_manager;
/**
* Cohort field.
* @var int
*/
protected $cohortidfield;

/**
* The fields supplied by this step.
Expand Down
9 changes: 3 additions & 6 deletions classes/steps/actions/http_post_action_step.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

/**
* HTTP action step class.
*
* @package tool_trigger
* @copyright Matt Porritt <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -51,6 +50,8 @@ class http_post_action_step extends base_action_step {
protected $headers;
protected $params;
private $httphandler = null;
private $expectedresponse;
private $jsonencode;

/**
* The fields supplied by this step.
Expand Down Expand Up @@ -127,15 +128,11 @@ public function get_http_client() {
* @return array if execution was succesful and the response from the execution.
*/
public function execute($step, $trigger, $event, $stepresults) {
global $CFG;
require_once($CFG->dirroot . '/admin/tool/trigger/guzzle/autoloader.php');

$this->update_datafields($event, $stepresults);

$headers = $this->render_datafields($this->headers);
$headers = explode("\n", str_replace("\r\n", "\n", $headers));
$headers = \GuzzleHttp\headers_from_lines($headers);

$headers = \GuzzleHttp\Utils::headersFromLines($headers);
// ... urlencode the values of any substitutions being placed into the URL
// or the POST params.
$urlencodecallback = function($v) {
Expand Down
3 changes: 3 additions & 0 deletions classes/steps/filters/numcompare_filter_step.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class numcompare_filter_step extends base_filter_step {
const OPERATOR_GTE = '>=';
const OPERATOR_GT = '>';

protected $field1;
protected $field2;
protected $operator;


/**
Expand Down
7 changes: 7 additions & 0 deletions classes/steps/filters/stringcompare_filter_step.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ class stringcompare_filter_step extends base_filter_step {
*/
protected $wantmatch = true;

/**
* Error on fail.
*
* @var bool
*/
protected $erroronfail;

/**
* {@inheritDoc}
* @see \tool_trigger\steps\base\base_step::init()
Expand Down
7 changes: 7 additions & 0 deletions classes/steps/lookups/cohort_lookup_step.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class cohort_lookup_step extends base_lookup_step {
*/
private $outputprefix = null;

/**
* User field.
*
* @var string
*/
private $useridfield;

/**
* The fields supplied by this step.
* A string containing all the cohorts a user is assigned to.
Expand Down
5 changes: 5 additions & 0 deletions classes/workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ class workflow {
*/
public $numsteps;

/**
* @var int
*/
public $debug;

/**
* Constructor.
*
Expand Down
12 changes: 7 additions & 5 deletions edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@
// Group the events by plugin.
$pluginlist = \tool_monitor\eventlist::get_plugin_list($eventlist);
$plugineventlist = [];
foreach ($pluginlist as $plugin => $pluginname) {
foreach ($eventlist[$plugin] as $event => $eventname) {
// Filter out events which cannot be triggered for some reason.
if (!$event::is_deprecated()) {
$plugineventlist[$event] = "${pluginname}: ${eventname}";
foreach ($pluginlist as $plugintype) {
foreach ($plugintype as $plugin => $pluginname) {
foreach ($eventlist[$plugin] as $event => $eventname) {
// Filter out events which cannot be triggered for some reason.
if (!$event::is_deprecated()) {
$plugineventlist[$event] = "$pluginname: $eventname";
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion export.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

$workflowrecord = \tool_trigger\workflow_manager::get_workflow_data_with_steps($workflowid);
if (!$workflowrecord) {
print_error('invaliditemid');
throw new moodle_exception('invaliditemid');
}

$jsonexporter = new \tool_trigger\json\json_export($workflowrecord);
Expand Down
2 changes: 1 addition & 1 deletion exportrun.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

$workflowdata = \tool_trigger\workflow_manager::export_workflow_and_run_history($workflowid, $runid);
if (!$workflowdata) {
print_error('$workflowdata');
throw new moodle_exception('workflowdata');
}

$jsonexporter = new \tool_trigger\json\json_export($workflowdata);
Expand Down
Loading
Loading