예제 #1
0
function lesson_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 (!($lesson = $DB->get_record("lesson", array("id" => $id)))) {
        return false;
    }
    $result = true;
    if (!$DB->delete_records("lesson", array("id" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_pages", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_answers", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_attempts", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_grades", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_timer", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_branch", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_high_scores", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if ($events = $DB->get_records('event', array("modulename" => 'lesson', "instance" => $lesson->id))) {
        foreach ($events as $event) {
            delete_event($event->id);
        }
    }
    lesson_grade_item_delete($lesson);
    return $result;
}
예제 #2
0
function lesson_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 (!($lesson = get_record("lesson", "id", "{$id}"))) {
        return false;
    }
    $result = true;
    if (!delete_records("lesson", "id", "{$lesson->id}")) {
        $result = false;
    }
    if (!delete_records("lesson_pages", "lessonid", "{$lesson->id}")) {
        $result = false;
    }
    if (!delete_records("lesson_answers", "lessonid", "{$lesson->id}")) {
        $result = false;
    }
    if (!delete_records("lesson_attempts", "lessonid", "{$lesson->id}")) {
        $result = false;
    }
    if (!delete_records("lesson_grades", "lessonid", "{$lesson->id}")) {
        $result = false;
    }
    if (!delete_records("lesson_timer", "lessonid", "{$lesson->id}")) {
        $result = false;
    }
    if (!delete_records("lesson_branch", "lessonid", "{$lesson->id}")) {
        $result = false;
    }
    if (!delete_records("lesson_high_scores", "lessonid", "{$lesson->id}")) {
        $result = false;
    }
    if ($events = get_records_select('event', "modulename = 'lesson' and instance = '{$lesson->id}'")) {
        foreach ($events as $event) {
            delete_event($event->id);
        }
    }
    $pagetypes = page_import_types('mod/lesson/');
    foreach ($pagetypes as $pagetype) {
        if (!delete_records('block_instance', 'pageid', $lesson->id, 'pagetype', $pagetype)) {
            $result = false;
        }
    }
    lesson_grade_item_delete($lesson);
    return $result;
}
예제 #3
0
파일: lib.php 프로젝트: ajv/Offline-Caching
/**
 * 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 lesson_delete_instance($id)
{
    global $DB;
    if (!($lesson = $DB->get_record("lesson", array("id" => $id)))) {
        return false;
    }
    $result = true;
    if (!$DB->delete_records("lesson", array("id" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_pages", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_answers", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_attempts", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_grades", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_timer", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_branch", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if (!$DB->delete_records("lesson_high_scores", array("lessonid" => $lesson->id))) {
        $result = false;
    }
    if ($events = $DB->get_records('event', array("modulename" => 'lesson', "instance" => $lesson->id))) {
        foreach ($events as $event) {
            delete_event($event->id);
        }
    }
    lesson_grade_item_delete($lesson);
    return $result;
}