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


PHP quiz_grade_item_delete函數代碼示例

本文整理匯總了PHP中quiz_grade_item_delete函數的典型用法代碼示例。如果您正苦於以下問題:PHP quiz_grade_item_delete函數的具體用法?PHP quiz_grade_item_delete怎麽用?PHP quiz_grade_item_delete使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了quiz_grade_item_delete函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: quiz_delete_instance

function quiz_delete_instance($id)
{
    /// Given an ID of an instance of this module,
    /// this function will permanently delete the instance
    /// and any data that depends on it.
    if (!($quiz = get_record("quiz", "id", "{$id}"))) {
        return false;
    }
    $result = true;
    if ($attempts = get_records("quiz_attempts", "quiz", "{$quiz->id}")) {
        // TODO: this should use the delete_attempt($attempt->uniqueid) function in questionlib.php
        // require_once($CFG->libdir.'/questionlib.php');
        foreach ($attempts as $attempt) {
            if (!delete_records("question_states", "attempt", "{$attempt->uniqueid}")) {
                $result = false;
            }
            if (!delete_records("question_sessions", "attemptid", "{$attempt->uniqueid}")) {
                $result = false;
            }
        }
    }
    $tables_to_purge = array('quiz_attempts' => 'quiz', 'quiz_grades' => 'quiz', 'quiz_question_instances' => 'quiz', 'quiz_grades' => 'quiz', 'quiz_feedback' => 'quizid', 'quiz' => 'id');
    foreach ($tables_to_purge as $table => $keyfield) {
        if (!delete_records($table, $keyfield, $quiz->id)) {
            $result = false;
        }
    }
    $pagetypes = page_import_types('mod/quiz/');
    foreach ($pagetypes as $pagetype) {
        if (!delete_records('block_instance', 'pageid', $quiz->id, 'pagetype', $pagetype)) {
            $result = false;
        }
    }
    if ($events = get_records_select('event', "modulename = 'quiz' and instance = '{$quiz->id}'")) {
        foreach ($events as $event) {
            delete_event($event->id);
        }
    }
    quiz_grade_item_delete($quiz);
    return $result;
}
開發者ID:e-rasvet,項目名稱:reader,代碼行數:41,代碼來源:lib.php

示例2: quiz_delete_instance

/**
 * Given an ID of an instance of this module,
 * this function will permanently delete the instance
 * and any data that depends on it.
 *
 * @param int $id the id of the quiz to delete.
 * @return bool success or failure.
 */
function quiz_delete_instance($id) {
    global $DB;

    $quiz = $DB->get_record('quiz', array('id' => $id), '*', MUST_EXIST);

    quiz_delete_all_attempts($quiz);
    quiz_delete_all_overrides($quiz);

    $DB->delete_records('quiz_question_instances', array('quiz' => $quiz->id));
    $DB->delete_records('quiz_feedback', array('quizid' => $quiz->id));

    $events = $DB->get_records('event', array('modulename' => 'quiz', 'instance' => $quiz->id));
    foreach ($events as $event) {
        $event = calendar_event::load($event);
        $event->delete();
    }

    quiz_grade_item_delete($quiz);
    $DB->delete_records('quiz', array('id' => $quiz->id));

    return true;
}
開發者ID:nutanrajmalanai,項目名稱:moodle,代碼行數:30,代碼來源:lib.php

示例3: quiz_delete_instance

function quiz_delete_instance($id)
{
    global $DB;
    /// Given an ID of an instance of this module,
    /// this function will permanently delete the instance
    /// and any data that depends on it.
    if (!($quiz = $DB->get_record('quiz', array('id' => $id)))) {
        return false;
    }
    quiz_delete_all_attempts($quiz);
    $DB->delete_records('quiz_question_instances', array('quiz' => $quiz->id));
    $DB->delete_records('quiz_feedback', array('quizid' => $quiz->id));
    $events = $DB->get_records('event', array('modulename' => 'quiz', 'instance' => $quiz->id));
    foreach ($events as $event) {
        delete_event($event->id);
    }
    quiz_grade_item_delete($quiz);
    $DB->delete_records('quiz', array('id' => $quiz->id));
    return true;
}
開發者ID:nicolasconnault,項目名稱:moodle2.0,代碼行數:20,代碼來源:lib.php

示例4: quiz_delete_instance

/**
 * Given an ID of an instance of this module,
 * this function will permanently delete the instance
 * and any data that depends on it.
 *
 * @param int $id the id of the quiz to delete.
 * @return bool success or failure.
 */
function quiz_delete_instance($id)
{
    global $DB;
    $quiz = $DB->get_record('quiz', array('id' => $id), '*', MUST_EXIST);
    quiz_delete_all_attempts($quiz);
    quiz_delete_all_overrides($quiz);
    // Look for random questions that may no longer be used when this quiz is gone.
    $sql = "SELECT q.id\n              FROM {quiz_slots} slot\n              JOIN {question} q ON q.id = slot.questionid\n             WHERE slot.quizid = ? AND q.qtype = ?";
    $questionids = $DB->get_fieldset_sql($sql, array($quiz->id, 'random'));
    // We need to do this before we try and delete randoms, otherwise they would still be 'in use'.
    $DB->delete_records('quiz_slots', array('quizid' => $quiz->id));
    $DB->delete_records('quiz_sections', array('quizid' => $quiz->id));
    foreach ($questionids as $questionid) {
        question_delete_question($questionid);
    }
    $DB->delete_records('quiz_feedback', array('quizid' => $quiz->id));
    quiz_access_manager::delete_settings($quiz);
    $events = $DB->get_records('event', array('modulename' => 'quiz', 'instance' => $quiz->id));
    foreach ($events as $event) {
        $event = calendar_event::load($event);
        $event->delete();
    }
    quiz_grade_item_delete($quiz);
    $DB->delete_records('quiz', array('id' => $quiz->id));
    return true;
}
開發者ID:dg711,項目名稱:moodle,代碼行數:34,代碼來源:lib.php

示例5: quiz_delete_instance

/**
 * Given an ID of an instance of this module,
 * this function will permanently delete the instance
 * and any data that depends on it.
 *
 * @global object
 * @param int $id
 * @return bool
 */
function quiz_delete_instance($id)
{
    global $DB;
    if (!($quiz = $DB->get_record('quiz', array('id' => $id)))) {
        return false;
    }
    quiz_delete_all_attempts($quiz);
    $DB->delete_records('quiz_question_instances', array('quiz' => $quiz->id));
    $DB->delete_records('quiz_feedback', array('quizid' => $quiz->id));
    $events = $DB->get_records('event', array('modulename' => 'quiz', 'instance' => $quiz->id));
    foreach ($events as $event) {
        delete_event($event->id);
    }
    quiz_grade_item_delete($quiz);
    $DB->delete_records('quiz', array('id' => $quiz->id));
    return true;
}
開發者ID:ajv,項目名稱:Offline-Caching,代碼行數:26,代碼來源:lib.php


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