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


PHP quiz_access_manager::delete_settings方法代码示例

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


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

示例1: 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));
    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:achocoza,项目名称:moodle26,代码行数:26,代码来源: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);
    // 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


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