Skip to content
Merged
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
8 changes: 6 additions & 2 deletions lbplanner/classes/helpers/modules_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,19 @@ public static function map_status(bool $submitted, bool $done, bool $late): int
*
* @param int $moduleid The ID of the module.
* @return int The enum value for the module type.
* @throws \moodle_exception
*/
public static function determine_type(int $moduleid): int {
$catid = config_helper::get_category_id();
if ($catid === -1) {
throw new \moodle_exception('couldn\'t find custom fields category ID');
}
$categorycontroller = category_controller::create($catid);
$datacontroller = $categorycontroller->get_handler()->get_instance_data($moduleid)[0];
$type = intval($datacontroller->get('value'));
$instancedata = $categorycontroller->get_handler()->get_instance_data($moduleid);
if (count($instancedata) === 0) {
throw new \moodle_exception("couldn't find any instance data for module ID {$moduleid} in category ID {$catid}");
}
$type = intval($instancedata[1]->get('value')); // NOTE: why the hell is this on index one?
MODULE_TYPE::name_from($type); // Basically asserting that this value exists as a module type.
return $type;
}
Expand Down
Loading