Skip to content

Commit

Permalink
added course custom fields to variables
Browse files Browse the repository at this point in the history
  • Loading branch information
justinhunt committed Mar 24, 2022
1 parent 7ef2f20 commit ee3e86b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Change List
=========
Version 1.4.14(Build 2022032400)
- Added course custom variables to variables to use in filter

Version 1.4.13(Build 2021080600)
- fixed issue where numeric variables to dataset where forced as int
- fixed issue where in the case of only 1 returned entry in dataset it was not available in JS
Expand Down
24 changes: 23 additions & 1 deletion filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,29 @@ function filter_generico_callback(array $link) {

//if we have course variables e.g @@COURSE:ID@@
if (strpos($genericotemplate . ' ' . $dataset_vars, '@@COURSE:') !== false) {
$coursevars = get_object_vars($COURSE);
$coursevars=false;
if(!empty($filterprops['courseid']) && is_numeric($filterprops['courseid'] )){
$thecourse = get_course($filterprops['courseid']);
if($thecourse){
$coursevars = get_object_vars($thecourse);
//custom fields
if(class_exists('\core_customfield\handler')) {
$handler = \core_customfield\handler::get_handler('core_course', 'course');
$customfields = $handler->get_instance_data($filterprops['courseid']);
foreach ($customfields as $customfield) {
if (empty($customfield->get_value())) {
continue;
}
$shortname = $customfield->get_field()->get('shortname');
$coursevars[$shortname] = $customfield->get_value();
}
}
}
}
if(!$coursevars){
$coursevars = get_object_vars($COURSE);
}

$coursepropstubs = explode('@@COURSE:', $genericotemplate);
$d_stubs = explode('@@COURSE:', $dataset_vars);
if ($d_stubs) {
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2021080600; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2022032400; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011070100; // Requires this Moodle version
$plugin->component = 'filter_generico'; // Full name of the plugin (used for diagnostics)
$plugin->maturity = MATURITY_STABLE;
$plugin->release = 'Version 1.4.13(Build 2021080600)';
$plugin->release = 'Version 1.4.14(Build 2022032400)';

0 comments on commit ee3e86b

Please sign in to comment.