Exemplo n.º 1
0
 /**
  * Construct this renderable.
  *
  * @param int $competencyid
  */
 public function __construct($competencyid)
 {
     $this->competency = api::read_competency($competencyid);
     $this->context = $this->competency->get_context();
     $this->relatedcompetencies = api::list_related_competencies($competencyid);
 }
Exemplo n.º 2
0
 /**
  * Grade a competency in a course.
  *
  * @param int $courseid The course id
  * @param int $userid The user id
  * @param int $competencyid The competency id
  * @param int $grade The new grade value
  * @param string $note A note to add to the evidence
  * @return bool
  */
 public static function grade_competency_in_course($courseid, $userid, $competencyid, $grade, $note = null)
 {
     global $USER, $PAGE, $DB;
     $params = self::validate_parameters(self::grade_competency_in_course_parameters(), array('courseid' => $courseid, 'userid' => $userid, 'competencyid' => $competencyid, 'grade' => $grade, 'note' => $note));
     $course = $DB->get_record('course', array('id' => $params['courseid']));
     $context = context_course::instance($course->id);
     self::validate_context($context);
     $output = $PAGE->get_renderer('core');
     $evidence = api::grade_competency_in_course($params['courseid'], $params['userid'], $params['competencyid'], $params['grade'], $params['note']);
     $competency = api::read_competency($params['competencyid']);
     $scale = $competency->get_scale();
     $exporter = new evidence_exporter($evidence, array('actionuser' => $USER, 'scale' => $scale, 'usercompetency' => null, 'usercompetencyplan' => null));
     return $exporter->export($output);
 }
Exemplo n.º 3
0
}
// Get competency.
$competency = null;
if (!empty($id)) {
    $competency = \core_competency\api::read_competency($id);
    if (empty($competencyframework)) {
        $competencyframework = $competency->get_framework();
    }
}
// Get parent competency, if any.
$parent = null;
if ($competency) {
    $parent = $competency->get_parent();
} else {
    if ($parentid) {
        $parent = \core_competency\api::read_competency($parentid);
    }
}
// Get page URL.
$urloptions = ['id' => $id, 'competencyframeworkid' => $competencyframework->get_id(), 'parentid' => $parentid, 'pagecontextid' => $pagecontextid];
$url = new moodle_url("/admin/tool/lp/editcompetency.php", $urloptions);
// Set up the page.
list($title, $subtitle, $returnurl) = \tool_lp\page_helper::setup_for_competency($pagecontextid, $url, $competencyframework, $competency, $parent);
// Set up the form.
$formoptions = ['competencyframework' => $competencyframework, 'parent' => $parent, 'persistent' => $competency, 'pagecontextid' => $pagecontextid];
$form = new \tool_lp\form\competency($url->out(false), $formoptions);
// Form cancelled.
if ($form->is_cancelled()) {
    redirect($returnurl);
}
// Get form data.
Exemplo n.º 4
0
 /**
  * Data to render in the related competencies section.
  *
  * @param int $competencyid
  * @return array Related competencies and whether to show delete action button or not.
  */
 public static function data_for_related_competencies_section($competencyid)
 {
     global $PAGE;
     $params = self::validate_parameters(self::data_for_related_competencies_section_parameters(), array('competencyid' => $competencyid));
     $competency = api::read_competency($params['competencyid']);
     self::validate_context($competency->get_context());
     $renderable = new \tool_lp\output\related_competencies($params['competencyid']);
     $renderer = $PAGE->get_renderer('tool_lp');
     return $renderable->export_for_template($renderer);
 }