コード例 #1
0
ファイル: external.php プロジェクト: evltuma/moodle
 /**
  * Update an existing competency
  *
  * @param array $competency The array of competency fields (id is required).
  * @return boolean
  */
 public static function update_competency($competency)
 {
     $params = self::validate_parameters(self::update_competency_parameters(), array('competency' => $competency));
     $params = $params['competency'];
     $competency = api::read_competency($params['id']);
     self::validate_context($competency->get_context());
     $params = (object) $params;
     return api::update_competency($params);
 }
コード例 #2
0
ファイル: editcompetency.php プロジェクト: evltuma/moodle
// 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.
$data = $form->get_data();
if ($data) {
    if (empty($competency)) {
        \core_competency\api::create_competency($data);
        $returnmsg = get_string('competencycreated', 'tool_lp');
    } else {
        \core_competency\api::update_competency($data);
        $returnmsg = get_string('competencyupdated', 'tool_lp');
    }
    redirect($returnurl, $returnmsg, null, \core\output\notification::NOTIFY_SUCCESS);
}
// Render the page.
$output = $PAGE->get_renderer('tool_lp');
echo $output->header();
echo $output->heading($title);
echo $output->heading($subtitle, 3);
$form->display();
echo $output->footer();
コード例 #3
0
ファイル: event_test.php プロジェクト: evltuma/moodle
 /**
  * Test the competency updated event.
  *
  */
 public function test_competency_updated()
 {
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $f1 = $lpg->create_framework();
     $competency = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
     $c1 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
     $c2 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
     $c12 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1->get_id()));
     $c13 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1->get_id()));
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     $competency->set_shortname('Shortname modified');
     api::update_competency($competency->to_record());
     // Get our event event.
     $events = $sink->get_events();
     $event = reset($events);
     // Check that the event data is valid.
     $this->assertInstanceOf('\\core\\event\\competency_updated', $event);
     $this->assertEquals($competency->get_id(), $event->objectid);
     $this->assertEquals($competency->get_context()->id, $event->contextid);
     $this->assertEventContextNotUsed($event);
     $this->assertDebuggingNotCalled();
 }