Skip to content

Commit

Permalink
feature - Course Size tool empty array fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaoticDalo committed Feb 15, 2024
1 parent b8034f6 commit 4001d78
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions theme/lsu.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,40 +321,31 @@ public static function role_check_course_size($cid = 0) {
$found = false;
$access = false;

$results = array(
"found" => false,
"access" => false
);
$context = context_course::instance($cid);
$roles = get_user_roles($context, $USER->id, true);

if (empty($roles)) {
return array(
"found" => false,
"access" => false
);
return $results;
}
$role = key($roles);
$rolename = $roles[$role]->shortname;
$customroles = self::config_to_array('report_coursesize_manualroles', "comma", true);


foreach ($customroles as $k => $v) {
if (strtolower($k) == strtolower($rolename)) {
$found = true;
$access = $v;
if ($customroles = self::config_to_array('report_coursesize_manualroles', "comma", true)) {
foreach ($customroles as $k => $v) {
if (strtolower($k) == strtolower($rolename)) {
$found = true;
$access = $v;
}
}
} else {
return $results;
}
return array(
"found" => $found,
"access" => $access
);
}

public static function testy() {

global $DB;

$courseid = 38581;
$course = $DB->get_record('course', array('id' => $courseid));
$info = get_fast_modinfo($course);

print_object($info);
}
}

0 comments on commit 4001d78

Please sign in to comment.