Created
October 4, 2021 09:26
-
-
Save luukverhoeven/062ec084beafd352b3cb83b20432fda7 to your computer and use it in GitHub Desktop.
Moodle course customfields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get customfields on course context. | |
// Can be used for the plugin settings page (dropdown). | |
$handler = \core_course\customfield\course_handler::create(); | |
$fields = $handler->get_fields(); | |
// Get customfields with data for a course. | |
$courseid = 16; | |
$fields = \core_course\customfield\course_handler::create()->get_instance_data($courseid); | |
foreach($fields as $field){ | |
/** @var \customfield_text\data_controller $field */ | |
echo $field->get_field()->get_formatted_name() . '<br>'; | |
echo $field->get_value(). '<br>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment