當前位置: 首頁>>代碼示例>>PHP>>正文


PHP scorm_delete_attempt函數代碼示例

本文整理匯總了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');
 }
開發者ID:rushi963,項目名稱:moodle,代碼行數:26,代碼來源:events_test.php

示例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;
}
開發者ID:helenagarcia90,項目名稱:moodle,代碼行數:32,代碼來源:locallib.php


注:本文中的scorm_delete_attempt函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。