Skip to content

Commit 371895d

Browse files
Use field courseid for logging events
1 parent 33cbd05 commit 371895d

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

classes/event/process_proceeded.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
* - int processid: the id of the process.
3636
* - int workflowid: the id of the workflow.
3737
* - int stepindex: the index of the step.
38-
* - int courseid: the id of the course.
3938
* }
4039
*
4140
* @package tool_lifecycle
@@ -54,12 +53,12 @@ class process_proceeded extends \core\event\base {
5453
*/
5554
public static function event_from_process($process) {
5655
$data = [
57-
'context' => \context_system::instance(),
56+
'context' => \context_course::instance($process->courseid),
57+
'courseid' => $process->courseid,
5858
'other' => [
5959
'processid' => $process->id,
6060
'workflowid' => $process->workflowid,
6161
'stepindex' => $process->stepindex,
62-
'courseid' => $process->courseid,
6362
],
6463
];
6564
return self::create($data);
@@ -84,7 +83,7 @@ public function get_description() {
8483
$processid = $this->other['processid'];
8584
$workflowid = $this->other['workflowid'];
8685
$stepindex = $this->other['stepindex'];
87-
$courseid = $this->other['courseid'];
86+
$courseid = $this->courseid;
8887

8988
return "The workflow with id '$workflowid' finished step '$stepindex' successfully for course '$courseid' " .
9089
"in the process with id '$processid'";
@@ -130,7 +129,7 @@ protected function validate_data() {
130129
throw new \coding_exception('The \'stepindex\' value must be set');
131130
}
132131

133-
if (!isset($this->other['courseid'])) {
132+
if (!isset($this->courseid)) {
134133
throw new \coding_exception('The \'courseid\' value must be set');
135134
}
136135
}

classes/event/process_rollback.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ class process_rollback extends \core\event\base {
5454
*/
5555
public static function event_from_process($process) {
5656
$data = [
57-
'context' => \context_system::instance(),
57+
'context' => \context_course::instance($process->courseid),
58+
'courseid' => $process->courseid,
5859
'other' => [
59-
'processid' => $process->id,
60-
'workflowid' => $process->workflowid,
61-
'stepindex' => $process->stepindex,
62-
'courseid' => $process->courseid,
60+
'processid' => $process->id,
61+
'workflowid' => $process->workflowid,
62+
'stepindex' => $process->stepindex,
6363
],
6464
];
6565
return self::create($data);
@@ -84,7 +84,7 @@ public function get_description() {
8484
$processid = $this->other['processid'];
8585
$workflowid = $this->other['workflowid'];
8686
$stepindex = $this->other['stepindex'];
87-
$courseid = $this->other['courseid'];
87+
$courseid = $this->courseid;
8888

8989
return "The workflow with id '$workflowid' was rolled back on step '$stepindex' for course '$courseid' " .
9090
"in the process with id '$processid'";
@@ -130,7 +130,7 @@ protected function validate_data() {
130130
throw new \coding_exception('The \'stepindex\' value must be set');
131131
}
132132

133-
if (!isset($this->other['courseid'])) {
133+
if (!isset($this->courseid)) {
134134
throw new \coding_exception('The \'courseid\' value must be set');
135135
}
136136
}

classes/event/process_triggered.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ class process_triggered extends \core\event\base {
5353
*/
5454
public static function event_from_process($process) {
5555
$data = [
56-
'context' => \context_system::instance(),
56+
'context' => \context_course::instance($process->courseid),
57+
'courseid' => $process->courseid,
5758
'other' => [
5859
'processid' => $process->id,
5960
'workflowid' => $process->workflowid,
60-
'courseid' => $process->courseid,
6161
],
6262
];
6363
return self::create($data);
@@ -81,7 +81,7 @@ protected function init() {
8181
public function get_description() {
8282
$processid = $this->other['processid'];
8383
$workflowid = $this->other['workflowid'];
84-
$courseid = $this->other['courseid'];
84+
$courseid = $this->courseid;
8585

8686
return "The workflow with id '$workflowid' triggered for course '$courseid' and created process with id '$processid'";
8787
}
@@ -122,7 +122,7 @@ protected function validate_data() {
122122
throw new \coding_exception('The \'workflowid\' value must be set');
123123
}
124124

125-
if (!isset($this->other['courseid'])) {
125+
if (!isset($this->courseid)) {
126126
throw new \coding_exception('The \'courseid\' value must be set');
127127
}
128128
}

0 commit comments

Comments
 (0)