Reopen Learning plan.

@param int $planid plan id (id is required)
@return boolean
185198
public static function reopen_plan($planid) {
        $params = self::validate_parameters(self::reopen_plan_parameters(), array(
            'planid' => $planid
        ));

        return api::reopen_plan($params['planid']);
    }
393269
public function restart($taskId) {
		if ($this->TaskClient->restart($taskId)) {
			$this->Session->setFlash("Task $taskId will be restarted shortly", 'alert/simple', array(
				'class' => 'alert-success', 'title' => 'Ok!'
			));
		} else {
			$this->Session->setFlash("Can't restart task $taskId!", 'alert/simple', array(
				'class' => 'alert-error', 'title' => 'Error!'
			));
		}
		$this->redirect($this->referer());
	}
1101485
public static function approve_plan($planorid) {
        static::require_enabled();
        $plan = $planorid;
        if (!is_object($plan)) {
            $plan = new plan($plan);
        }

        // We need to be able to view the plan at least.
        if (!$plan->can_read()) {
            throw new required_capability_exception($plan->get_context(), 'moodle/competency:planview', 'nopermissions', '');
        }

        // We can approve a plan that is either a draft, in review, or waiting for review.
        if ($plan->is_based_on_template()) {
            throw new coding_exception('Template plans are already approved.');   // This should never happen.
        } else if (!$plan->is_draft()) {
            throw new coding_exception('The plan cannot be approved at this stage.');
        } else if (!$plan->can_review()) {
            throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', '');
        }

        $plan->set('status', plan::STATUS_ACTIVE);
        $plan->set('reviewerid', null);
        $result = $plan->update();

        // Trigger approved event.
        \core\event\competency_plan_approved::create_from_plan($plan)->trigger();

        return $result;
    }
331129
public static function data_for_plan_page($planid) {
        global $PAGE;
        $params = self::validate_parameters(self::data_for_plan_page_parameters(), array(
            'planid' => $planid
        ));
        $plan = api::read_plan($params['planid']);
        self::validate_context($plan->get_context());

        $renderable = new output\plan_page($plan);
        $renderer = $PAGE->get_renderer('tool_lp');

        $data = $renderable->export_for_template($renderer);

        return $data;
    }
1015212
public function restart($id = false)
    {
        if ($id) {
            $this->_id = $id;
        }

        $this->_user->put('pylon/start', array('id' => $this->_id));
    }
198291
function canBeRemoved( $sectionID = false )
    {
        if ( $sectionID === false )
        {
            $sectionID = $this->attribute( 'id' );
        }

        $objects = eZPersistentObject::fetchObjectList( eZContentObject::definition(), null,
                                                        array( 'section_id' => $sectionID ) );
        $limitations = eZPolicyLimitation::findByType( 'Section', $sectionID, true, false );
        $userRoles = eZRole::fetchRolesByLimitation( 'section', $sectionID );

        if ( count( $objects ) > 0 or
             count( $limitations ) > 0 or
             count( $userRoles ) > 0 )
        {
            return false;
        }
        else
        {
            return true;
        }
    }
975067
public function create($data, $planId = null)
    {
        if (isset($planId)) {
            return $this->client()->put($data, 'plans/{planId}', ['planId' => $planId]);
        }

        return $this->client()->post($data, 'plans');
    }
187065
protected function get_course($courseid) {
        if (!empty($this->cachedcourses[$courseid])) {
            return $this->cachedcourses[$courseid];
        }

        // No need to clone, only read.
        $this->cachedcourses[$courseid] = get_course($courseid, false);

        return $this->cachedcourses[$courseid];
    }
1132995
public function renew(int $id)
    {
        $this->updates[$id] = $this->now + $this->timeout;
    }
1044593
public static function can_manage_user($planuserid) {
        global $USER;
        $context = context_user::instance($planuserid);

        $capabilities = array('moodle/competency:planmanage');
        if ($context->instanceid == $USER->id) {
            $capabilities[] = 'moodle/competency:planmanageown';
        }

        return has_any_capability($capabilities, $context);
    }
487907
protected function is_temporary_course_created($courseid) {
        global $DB;
        // Check if current controller instance has created new course.
        if ($this->controller->get_target() == backup::TARGET_NEW_COURSE) {
            $results = $DB->record_exists_sql("SELECT bc.itemid
                                               FROM {backup_controllers} bc, {course} c
                                               WHERE bc.operation = 'restore'
                                                 AND bc.type = 'course'
                                                 AND bc.itemid = c.id
                                                 AND bc.itemid = ?",
                                               array($courseid)
                                             );
            return $results;
        }
        return false;
    }
1325864
public static function launch_feedback($feedbackid, $courseid = 0) {
        global $PAGE;

        $params = array('feedbackid' => $feedbackid, 'courseid' => $courseid);
        $params = self::validate_parameters(self::launch_feedback_parameters(), $params);
        $warnings = array();

        list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'],
            $params['courseid']);
        // Check we can do a new submission (or continue an existing).
        $feedbackcompletion = self::validate_feedback_access($feedback, $completioncourse, $cm, $context, true);

        $gopage = $feedbackcompletion->get_resume_page();
        if ($gopage === null) {
            $gopage = -1; // Last page.
        }

        $result = array(
            'gopage' => $gopage,
            'warnings' => $warnings
        );
        return $result;
    }
1323244
public static function plan_cancel_review_request($planorid) {
        static::require_enabled();
        $plan = $planorid;
        if (!is_object($plan)) {
            $plan = new plan($plan);
        }

        // We need to be able to view the plan at least.
        if (!$plan->can_read()) {
            throw new required_capability_exception($plan->get_context(), 'moodle/competency:planview', 'nopermissions', '');
        }

        if ($plan->is_based_on_template()) {
            throw new coding_exception('Template plans cannot be reviewed.');   // This should never happen.
        } else if ($plan->get('status') != plan::STATUS_WAITING_FOR_REVIEW) {
            throw new coding_exception('The plan review cannot be cancelled at this stage.');
        } else if (!$plan->can_request_review()) {
            throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', '');
        }

        $plan->set('status', plan::STATUS_DRAFT);
        $result = $plan->update();

        // Trigger review request cancelled event.
        \core\event\competency_plan_review_request_cancelled::create_from_plan($plan)->trigger();

        return $result;
    }
1334371
public static function add_competency_to_plan($planid, $competencyid) {
        $params = self::validate_parameters(self::add_competency_to_plan_parameters(), array(
            'planid' => $planid,
            'competencyid' => $competencyid,
        ));

        $plan = api::read_plan($params['planid']);
        self::validate_context($plan->get_context());

        return api::add_competency_to_plan($params['planid'], $params['competencyid']);
    }
416742
def check_plan_id(self, plan_id) -> bool:
        
        for plan in self.catalog().plans:
            if plan.id == plan_id:
                return True
        return False
190312
public static function get_sections_from_courseid($courseid) {
        global $DB;

        // Get all sections belonging to requested course
        $sectionsarr = array();
        $sections = $DB->get_records('course_sections', array('course' => $courseid), 'section');
        foreach ($sections as $section) {
            $sectionsarr[] = $section->id;
        }
        return $sectionsarr;
    }
111258
function _get_plan_by_id( $id ) {
            $this->_logger->entrance();

            if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
                $this->_sync_plans();
            }

            foreach ( $this->_plans as $plan ) {
                if ( $id == $plan->id ) {
                    return $plan;
                }
            }

            return false;
        }