本文整理汇总了PHP中core_competency\api::user_competency_viewed_in_course方法的典型用法代码示例。如果您正苦于以下问题:PHP api::user_competency_viewed_in_course方法的具体用法?PHP api::user_competency_viewed_in_course怎么用?PHP api::user_competency_viewed_in_course使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_competency\api
的用法示例。
在下文中一共展示了api::user_competency_viewed_in_course方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_user_competency_viewed_in_course
/**
* Test the user competency viewed event in course.
*
*/
public function test_user_competency_viewed_in_course()
{
$this->resetAfterTest(true);
$this->setAdminUser();
$dg = $this->getDataGenerator();
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$user = $dg->create_user();
$course = $dg->create_course();
$fr = $lpg->create_framework();
$c = $lpg->create_competency(array('competencyframeworkid' => $fr->get_id()));
$pc = $lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $c->get_id()));
$params = array('userid' => $user->id, 'competencyid' => $c->get_id(), 'courseid' => $course->id);
$ucc = $lpg->create_user_competency_course($params);
// Trigger and capture the event.
$sink = $this->redirectEvents();
api::user_competency_viewed_in_course($ucc);
// 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_viewed_in_course', $event);
$this->assertEquals($ucc->get_id(), $event->objectid);
$this->assertEquals(context_course::instance($course->id)->id, $event->contextid);
$this->assertEquals($ucc->get_userid(), $event->relateduserid);
$this->assertEquals($course->id, $event->courseid);
$this->assertEquals($c->get_id(), $event->other['competencyid']);
$this->assertEventContextNotUsed($event);
$this->assertDebuggingNotCalled();
// Test validation.
$params = array('objectid' => $ucc->get_id(), 'contextid' => $ucc->get_context()->id, 'other' => null);
// Missing courseid.
try {
\core\event\competency_user_competency_viewed_in_course::create($params)->trigger();
$this->fail('The \'courseid\' value must be set.');
} catch (coding_exception $e) {
$this->assertRegExp("/The 'courseid' value must be set./", $e->getMessage());
}
$params['contextid'] = context_course::instance($course->id)->id;
$params['courseid'] = $course->id;
// Missing competencyid.
try {
\core\event\competency_user_competency_viewed_in_course::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());
}
}
示例2: user_competency_viewed_in_course
/**
* Log user competency viewed in course event.
*
* @param int $competencyid The competency ID.
* @param int $userid The user ID.
* @param int $courseid The course ID.
* @return boolean
*/
public static function user_competency_viewed_in_course($competencyid, $userid, $courseid)
{
$params = self::validate_parameters(self::user_competency_viewed_in_course_parameters(), array('competencyid' => $competencyid, 'userid' => $userid, 'courseid' => $courseid));
$ucc = api::get_user_competency_in_course($params['courseid'], $params['userid'], $params['competencyid']);
$result = api::user_competency_viewed_in_course($ucc);
return $result;
}
示例3: array
$user = $DB->get_record('user', array('id' => $userid));
}
$competency = new \core_competency\competency($competencyid);
// Does a permissions check for us.
if ($userid > 0) {
$usercompetencycourses = \core_competency\api::list_user_competencies_in_course($courseid, $userid);
}
$subtitle = $competency->get_shortname() . ' <em>' . $competency->get_idnumber() . '</em>';
list($title, $subtitle) = \tool_lp\page_helper::setup_for_course($url, $course, $subtitle);
$output = $PAGE->get_renderer('tool_lp');
if ($userid > 0) {
$userheading = array('heading' => fullname($user), 'user' => $user, 'usercontext' => $usercontext);
}
echo $output->header();
if ($userid > 0) {
echo $OUTPUT->context_header($userheading, 3);
}
$baseurl = new moodle_url('/admin/tool/lp/user_competency_in_course.php');
$nav = new \tool_lp\output\user_competency_course_navigation($userid, $competencyid, $courseid, $baseurl);
echo $output->render($nav);
if ($userid > 0) {
$page = new \tool_lp\output\user_competency_summary_in_course($userid, $competencyid, $courseid);
echo $output->render($page);
// Trigger the viewed event.
$uc = \core_competency\api::get_user_competency_in_course($courseid, $userid, $competencyid);
\core_competency\api::user_competency_viewed_in_course($uc, $courseid);
} else {
echo $output->container('', 'clearfix');
echo $output->notify_problem(get_string('noparticipants', 'tool_lp'));
}
echo $output->footer();