/** * Do the job. */ public function execute() { if (!api::is_enabled()) { return; } $records = plan::get_recordset_for_due_and_incomplete(); foreach ($records as $record) { $plan = new plan(0, $record); api::complete_plan($plan); } $records->close(); }
/** * Do the job. */ public function execute() { if (!api::is_enabled()) { return; } $missingplans = template_cohort::get_all_missing_plans(self::get_last_run_time()); foreach ($missingplans as $missingplan) { foreach ($missingplan['userids'] as $userid) { try { api::create_plan_from_template($missingplan['template'], $userid); } catch (\Exception $e) { debugging(sprintf('Exception caught while creating plan for user %d from template %d. Message: %s', $userid, $missingplan['template']->get_id(), $e->getMessage()), DEBUG_DEVELOPER); } } } }
/** * Return an object with the list of navigation options in a course that are avaialable or not for the current user. * This function also handles the frontpage course. * * @param stdClass $context context object (it can be a course context or the system context for frontpage settings) * @param stdClass $course the course where the settings are being rendered * @return stdClass the navigation options in a course and their availability status * @since Moodle 3.2 */ function course_get_user_navigation_options($context, $course = null) { global $CFG; $isloggedin = isloggedin(); $isguestuser = isguestuser(); $isfrontpage = $context->contextlevel == CONTEXT_SYSTEM; if ($isfrontpage) { $sitecontext = $context; } else { $sitecontext = context_system::instance(); } // Sets defaults for all options. $options = (object) ['badges' => false, 'blogs' => false, 'calendar' => false, 'competencies' => false, 'grades' => false, 'notes' => false, 'participants' => false, 'search' => false, 'tags' => false]; $options->blogs = !empty($CFG->enableblogs) && ($CFG->bloglevel == BLOG_GLOBAL_LEVEL || ($CFG->bloglevel == BLOG_SITE_LEVEL and ($isloggedin and !$isguestuser))) && has_capability('moodle/blog:view', $sitecontext); $options->notes = !empty($CFG->enablenotes) && has_any_capability(array('moodle/notes:manage', 'moodle/notes:view'), $context); // Frontpage settings? if ($isfrontpage) { if ($course->id == SITEID) { $options->participants = has_capability('moodle/site:viewparticipants', $sitecontext); } else { $options->participants = has_capability('moodle/course:viewparticipants', context_course::instance($course->id)); } $options->badges = !empty($CFG->enablebadges) && has_capability('moodle/badges:viewbadges', $sitecontext); $options->tags = !empty($CFG->usetags) && $isloggedin; $options->search = !empty($CFG->enableglobalsearch) && has_capability('moodle/search:query', $sitecontext); $options->calendar = $isloggedin; } else { $options->participants = has_capability('moodle/course:viewparticipants', $context); $options->badges = !empty($CFG->enablebadges) && !empty($CFG->badges_allowcoursebadges) && has_capability('moodle/badges:viewbadges', $context); // Add view grade report is permitted. $grades = false; if (has_capability('moodle/grade:viewall', $context)) { $grades = true; } else { if (!empty($course->showgrades)) { $reports = core_component::get_plugin_list('gradereport'); if (is_array($reports) && count($reports) > 0) { // Get all installed reports. arsort($reports); // User is last, we want to test it first. foreach ($reports as $plugin => $plugindir) { if (has_capability('gradereport/' . $plugin . ':view', $context)) { // Stop when the first visible plugin is found. $grades = true; break; } } } } } $options->grades = $grades; } if (\core_competency\api::is_enabled()) { $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'); $options->competencies = has_any_capability($capabilities, $context); } return $options; }
/** * backup_competencies_setting constructor. */ public function __construct() { $defaultvalue = false; $visibility = base_setting::HIDDEN; $status = base_setting::LOCKED_BY_CONFIG; if (\core_competency\api::is_enabled()) { $defaultvalue = true; $visibility = base_setting::VISIBLE; $status = base_setting::NOT_LOCKED; } parent::__construct('competencies', base_setting::IS_BOOLEAN, $defaultvalue, $visibility, $status); }