Skip to content

Commit

Permalink
Adding course custom fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdcastro committed May 23, 2024
1 parent 9b2526f commit b1c96c0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion classes/steps/lookups/course_lookup_step.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ public function execute($step, $trigger, $event, $stepresults) {
foreach ($coursedata as $key => $value) {
$stepresults[$this->outputprefix . $key] = $value;
}

$handler = \core_customfield\handler::get_handler('core_course', 'course');
$datas = $handler->get_instance_data($courseid);
foreach ($datas as $data) {
if (empty($data->get_value())) {
continue;
}
$key = $data->get_field()->get('shortname');
$stepresults[$this->outputprefix . $key] = $data->get_value();
}

return [true, $stepresults];
}

Expand Down Expand Up @@ -175,7 +186,11 @@ public static function get_privacyfields() {
* @return array $stepfields The fields this step provides.
*/
public static function get_fields() {
return self::$stepfields;
$handler = \core_customfield\handler::get_handler('core_course', 'course');
$customfields = array_walk($handler->get_fields(), function(&$field) {
$field = $field->get('shortname');
});

return self::$stepfields + $customfields;
}
}

0 comments on commit b1c96c0

Please sign in to comment.