本文整理汇总了PHP中scorm_delete_attempt函数的典型用法代码示例。如果您正苦于以下问题:PHP scorm_delete_attempt函数的具体用法?PHP scorm_delete_attempt怎么用?PHP scorm_delete_attempt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scorm_delete_attempt函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_attempt_deleted_event
/** Tests for attempt deleted event */
public function test_attempt_deleted_event()
{
global $USER;
$this->resetAfterTest();
scorm_insert_track(2, $this->eventscorm->id, 1, 4, 'cmi.core.score.raw', 10);
$sink = $this->redirectEvents();
scorm_delete_attempt(2, $this->eventscorm, 4);
$events = $sink->get_events();
$sink->close();
$event = reset($events);
// Verify data.
$this->assertCount(3, $events);
$this->assertInstanceOf('\\mod_scorm\\event\\attempt_deleted', $event);
$this->assertEquals($USER->id, $event->userid);
$this->assertEquals(context_module::instance($this->eventcm->id), $event->get_context());
$this->assertEquals(4, $event->other['attemptid']);
$this->assertEquals(2, $event->relateduserid);
$expected = array($this->eventcourse->id, 'scorm', 'delete attempts', 'report.php?id=' . $this->eventcm->id, 4, $this->eventcm->id);
$this->assertEventLegacyLogData($expected, $events[0]);
$this->assertEventContextNotUsed($event);
// Test event validations.
$this->setExpectedException('coding_exception');
\mod_scorm\event\attempt_deleted::create(array('contextid' => 5, 'relateduserid' => 2));
$this->fail('event \\mod_scorm\\event\\attempt_deleted is not validating events properly');
}
示例2: scorm_delete_responses
/**
* Delete Scorm tracks for selected users
*
* @param array $attemptids list of attempts that need to be deleted
* @param int $scorm instance
*
* return bool true deleted all responses, false failed deleting an attempt - stopped here
*/
function scorm_delete_responses($attemptids, $scorm)
{
if (!is_array($attemptids) || empty($attemptids)) {
return false;
}
foreach ($attemptids as $num => $attemptid) {
if (empty($attemptid)) {
unset($attemptids[$num]);
}
}
foreach ($attemptids as $attempt) {
$keys = explode(':', $attempt);
if (count($keys) == 2) {
$userid = clean_param($keys[0], PARAM_INT);
$attemptid = clean_param($keys[1], PARAM_INT);
if (!$userid || !$attemptid || !scorm_delete_attempt($userid, $scorm, $attemptid)) {
return false;
}
} else {
return false;
}
}
return true;
}