当前位置: 首页>>代码示例>>PHP>>正文


PHP api::user_competency_plan_viewed方法代码示例

本文整理汇总了PHP中core_competency\api::user_competency_plan_viewed方法的典型用法代码示例。如果您正苦于以下问题:PHP api::user_competency_plan_viewed方法的具体用法?PHP api::user_competency_plan_viewed怎么用?PHP api::user_competency_plan_viewed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core_competency\api的用法示例。


在下文中一共展示了api::user_competency_plan_viewed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_user_competency_plan_viewed

 /**
  * Test the user competency plan viewed event.
  *
  */
 public function test_user_competency_plan_viewed()
 {
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $dg = $this->getDataGenerator();
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $user = $dg->create_user();
     $plan = $lpg->create_plan(array('userid' => $user->id));
     $fr = $lpg->create_framework();
     $c = $lpg->create_competency(array('competencyframeworkid' => $fr->get_id()));
     $ucp = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c->get_id(), 'planid' => $plan->get_id()));
     // Can not log the event for user competency using non completed plan.
     try {
         api::user_competency_plan_viewed($ucp);
         $this->fail('To log the user competency in non-completed plan ' . 'use user_competency_viewed_in_plan method.');
     } catch (coding_exception $e) {
         $this->assertRegExp('/To log the user competency in non-completed plan ' . 'use user_competency_viewed_in_plan method./', $e->getMessage());
     }
     // Complete the plan.
     api::complete_plan($plan);
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     api::user_competency_plan_viewed($ucp);
     // Get our event event.
     $events = $sink->get_events();
     $event = reset($events);
     // Check that the event data is valid.
     $this->assertInstanceOf('\\core\\event\\competency_user_competency_plan_viewed', $event);
     $this->assertEquals($ucp->get_id(), $event->objectid);
     $this->assertEquals($ucp->get_context()->id, $event->contextid);
     $this->assertEquals($ucp->get_userid(), $event->relateduserid);
     $this->assertEquals($plan->get_id(), $event->other['planid']);
     $this->assertEquals($c->get_id(), $event->other['competencyid']);
     $this->assertEventContextNotUsed($event);
     $this->assertDebuggingNotCalled();
     // Test validation.
     $params = array('objectid' => $ucp->get_id(), 'contextid' => $ucp->get_context()->id, 'other' => null);
     // Other value null.
     try {
         \core\event\competency_user_competency_plan_viewed::create($params)->trigger();
         $this->fail('The \'competencyid\' and \'planid\' values must be set.');
     } catch (coding_exception $e) {
         $this->assertRegExp("/The 'competencyid' and 'planid' values must be set./", $e->getMessage());
     }
     $params['other']['anythingelse'] = '';
     // Missing competencyid.
     try {
         \core\event\competency_user_competency_plan_viewed::create($params)->trigger();
         $this->fail('The \'competencyid\' value must be set.');
     } catch (coding_exception $e) {
         $this->assertRegExp("/The 'competencyid' value must be set./", $e->getMessage());
     }
     $params['other']['competencyid'] = $c->get_id();
     // Missing planid.
     try {
         \core\event\competency_user_competency_plan_viewed::create($params)->trigger();
         $this->fail('The \'planid\' value must be set.');
     } catch (coding_exception $e) {
         $this->assertRegExp("/The 'planid' value must be set./", $e->getMessage());
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:65,代码来源:event_test.php

示例2: user_competency_plan_viewed

 /**
  * Log user competency plan viewed event.
  *
  * @param int $competencyid The competency ID.
  * @param int $userid The user ID.
  * @param int $planid The plan ID.
  * @return boolean
  */
 public static function user_competency_plan_viewed($competencyid, $userid, $planid)
 {
     $params = self::validate_parameters(self::user_competency_viewed_in_plan_parameters(), array('competencyid' => $competencyid, 'userid' => $userid, 'planid' => $planid));
     $pl = api::get_plan_competency($params['planid'], $params['competencyid']);
     $result = api::user_competency_plan_viewed($pl->usercompetencyplan);
     return $result;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:15,代码来源:external.php

示例3: require_login

require_login(null, false);
if (isguestuser()) {
    throw new require_login_exception('Guests are not allowed here.');
}
\core_competency\api::require_enabled();
$params = array('userid' => $userid, 'competencyid' => $competencyid);
$params['planid'] = $planid;
$plan = \core_competency\api::read_plan($planid);
$url = new moodle_url('/admin/tool/lp/user_competency_in_plan.php', $params);
$competency = new \core_competency\competency($competencyid);
$framework = $competency->get_framework();
list($title, $subtitle) = \tool_lp\page_helper::setup_for_plan($userid, $url, $plan);
$output = $PAGE->get_renderer('tool_lp');
echo $output->header();
echo $output->heading($title);
// User competency plan navigation.
$baseurl = new moodle_url('/admin/tool/lp/user_competency_in_plan.php');
$nav = new \tool_lp\output\competency_plan_navigation($userid, $competencyid, $planid, $baseurl);
echo $output->render($nav);
$page = new \tool_lp\output\user_competency_summary_in_plan($competencyid, $planid);
echo $output->render($page);
// Trigger the viewed event.
$pc = \core_competency\api::get_plan_competency($plan, $competency->get_id());
if ($plan->get_status() == \core_competency\plan::STATUS_COMPLETE) {
    $usercompetencyplan = $pc->usercompetencyplan;
    \core_competency\api::user_competency_plan_viewed($usercompetencyplan);
} else {
    $usercompetency = $pc->usercompetency;
    \core_competency\api::user_competency_viewed_in_plan($usercompetency, $plan->get_id());
}
echo $output->footer();
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:user_competency_in_plan.php


注:本文中的core_competency\api::user_competency_plan_viewed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。