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


PHP coursetag_delete_course_tags函数代码示例

本文整理汇总了PHP中coursetag_delete_course_tags函数的典型用法代码示例。如果您正苦于以下问题:PHP coursetag_delete_course_tags函数的具体用法?PHP coursetag_delete_course_tags怎么用?PHP coursetag_delete_course_tags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: remove_course_contents


//.........这里部分代码省略.........
    }
    // Cleanup the rest of plugins.
    $cleanuplugintypes = array('report', 'coursereport', 'format');
    foreach ($cleanuplugintypes as $type) {
        $plugins = get_plugin_list_with_function($type, 'delete_course', 'lib.php');
        foreach ($plugins as $plugin => $pluginfunction) {
            $pluginfunction($course->id, $showfeedback);
        }
        if ($showfeedback) {
            echo $OUTPUT->notification($strdeleted . get_string('type_' . $type . '_plural', 'plugin'), 'notifysuccess');
        }
    }
    // Delete questions and question categories.
    question_delete_course($course, $showfeedback);
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted . get_string('questions', 'question'), 'notifysuccess');
    }
    // Make sure there are no subcontexts left - all valid blocks and modules should be already gone.
    $childcontexts = $coursecontext->get_child_contexts();
    // Returns all subcontexts since 2.2.
    foreach ($childcontexts as $childcontext) {
        $childcontext->delete();
    }
    unset($childcontexts);
    // Remove all roles and enrolments by default.
    if (empty($options['keep_roles_and_enrolments'])) {
        // This hack is used in restore when deleting contents of existing course.
        role_unassign_all(array('contextid' => $coursecontext->id, 'component' => ''), true);
        enrol_course_delete($course);
        if ($showfeedback) {
            echo $OUTPUT->notification($strdeleted . get_string('type_enrol_plural', 'plugin'), 'notifysuccess');
        }
    }
    // Delete any groups, removing members and grouping/course links first.
    if (empty($options['keep_groups_and_groupings'])) {
        groups_delete_groupings($course->id, $showfeedback);
        groups_delete_groups($course->id, $showfeedback);
    }
    // Filters be gone!
    filter_delete_all_for_context($coursecontext->id);
    // Notes, you shall not pass!
    note_delete_all($course->id);
    // Die comments!
    comment::delete_comments($coursecontext->id);
    // Ratings are history too.
    $delopt = new stdclass();
    $delopt->contextid = $coursecontext->id;
    $rm = new rating_manager();
    $rm->delete_ratings($delopt);
    // Delete course tags.
    coursetag_delete_course_tags($course->id, $showfeedback);
    // Delete calendar events.
    $DB->delete_records('event', array('courseid' => $course->id));
    $fs->delete_area_files($coursecontext->id, 'calendar');
    // Delete all related records in other core tables that may have a courseid
    // This array stores the tables that need to be cleared, as
    // table_name => column_name that contains the course id.
    $tablestoclear = array('backup_courses' => 'courseid', 'user_lastaccess' => 'courseid');
    foreach ($tablestoclear as $table => $col) {
        $DB->delete_records($table, array($col => $course->id));
    }
    // Delete all course backup files.
    $fs->delete_area_files($coursecontext->id, 'backup');
    // Cleanup course record - remove links to deleted stuff.
    $oldcourse = new stdClass();
    $oldcourse->id = $course->id;
    $oldcourse->summary = '';
    $oldcourse->cacherev = 0;
    $oldcourse->legacyfiles = 0;
    $oldcourse->enablecompletion = 0;
    if (!empty($options['keep_groups_and_groupings'])) {
        $oldcourse->defaultgroupingid = 0;
    }
    $DB->update_record('course', $oldcourse);
    // Delete course sections.
    $DB->delete_records('course_sections', array('course' => $course->id));
    // Delete legacy, section and any other course files.
    $fs->delete_area_files($coursecontext->id, 'course');
    // Files from summary and section.
    // Delete all remaining stuff linked to context such as files, comments, ratings, etc.
    if (empty($options['keep_roles_and_enrolments']) and empty($options['keep_groups_and_groupings'])) {
        // Easy, do not delete the context itself...
        $coursecontext->delete_content();
    } else {
        // Hack alert!!!!
        // We can not drop all context stuff because it would bork enrolments and roles,
        // there might be also files used by enrol plugins...
    }
    // Delete legacy files - just in case some files are still left there after conversion to new file api,
    // also some non-standard unsupported plugins may try to store something there.
    fulldelete($CFG->dataroot . '/' . $course->id);
    // Delete from cache to reduce the cache size especially makes sense in case of bulk course deletion.
    $cachemodinfo = cache::make('core', 'coursemodinfo');
    $cachemodinfo->delete($courseid);
    // Trigger a course content deleted event.
    $event = \core\event\course_content_deleted::create(array('objectid' => $course->id, 'context' => $coursecontext, 'other' => array('shortname' => $course->shortname, 'fullname' => $course->fullname, 'options' => $options)));
    $event->add_record_snapshot('course', $course);
    $event->trigger();
    return true;
}
开发者ID:riawarra,项目名称:moodle,代码行数:101,代码来源:moodlelib.php

示例2: remove_course_contents


//.........这里部分代码省略.........
            if (function_exists($formatdelete)) {
                if ($showfeedback) {
                    echo $OUTPUT->notification($strdeleted . ' ' . $format);
                }
                $formatdelete($course->id);
            }
        }
    }
    // Remove all data from gradebook - this needs to be done before course modules
    // because while deleting this information, the system may need to reference
    // the course modules that own the grades.
    remove_course_grades($courseid, $showfeedback);
    remove_grade_letters($context, $showfeedback);
    // Remove all data from availability and completion tables that is associated
    // with course-modules belonging to this course. Note this is done even if the
    // features are not enabled now, in case they were enabled previously
    $DB->delete_records_select('course_modules_completion', 'coursemoduleid IN (SELECT id from {course_modules} WHERE course=?)', array($courseid));
    $DB->delete_records_select('course_modules_availability', 'coursemoduleid IN (SELECT id from {course_modules} WHERE course=?)', array($courseid));
    // Delete course blocks - they may depend on modules so delete them first
    blocks_delete_all_for_context($context->id);
    // Delete every instance of every module
    if ($allmods = $DB->get_records('modules')) {
        foreach ($allmods as $mod) {
            $modname = $mod->name;
            $modfile = $CFG->dirroot . '/mod/' . $modname . '/lib.php';
            $moddelete = $modname . '_delete_instance';
            // Delete everything connected to an instance
            $moddeletecourse = $modname . '_delete_course';
            // Delete other stray stuff (uncommon)
            $count = 0;
            if (file_exists($modfile)) {
                include_once $modfile;
                if (function_exists($moddelete)) {
                    if ($instances = $DB->get_records($modname, array('course' => $course->id))) {
                        foreach ($instances as $instance) {
                            if ($cm = get_coursemodule_from_instance($modname, $instance->id, $course->id)) {
                                /// Delete activity context questions and question categories
                                question_delete_activity($cm, $showfeedback);
                            }
                            if ($moddelete($instance->id)) {
                                $count++;
                            } else {
                                echo $OUTPUT->notification('Could not delete ' . $modname . ' instance ' . $instance->id . ' (' . format_string($instance->name) . ')');
                            }
                            if ($cm) {
                                // delete cm and its context in correct order
                                delete_context(CONTEXT_MODULE, $cm->id);
                                // some callbacks may try to fetch context, better delete first
                                $DB->delete_records('course_modules', array('id' => $cm->id));
                            }
                        }
                    }
                } else {
                    //note: we should probably delete these anyway
                    echo $OUTPUT->notification('Function ' . $moddelete . '() doesn\'t exist!');
                }
                if (function_exists($moddeletecourse)) {
                    $moddeletecourse($course, $showfeedback);
                }
            }
            if ($showfeedback) {
                echo $OUTPUT->notification($strdeleted . ' ' . $count . ' x ' . $modname);
            }
        }
    }
    // Delete any groups, removing members and grouping/course links first.
    groups_delete_groupings($course->id, $showfeedback);
    groups_delete_groups($course->id, $showfeedback);
    // Delete questions and question categories
    question_delete_course($course, $showfeedback);
    // Delete course tags
    coursetag_delete_course_tags($course->id, $showfeedback);
    // Delete legacy files (just in case some files are still left there after conversion to new file api)
    fulldelete($CFG->dataroot . '/' . $course->id);
    // cleanup course record - remove links to delted stuff
    $oldcourse = new stdClass();
    $oldcourse->id = $course->id;
    $oldcourse->summary = '';
    $oldcourse->modinfo = NULL;
    $oldcourse->legacyfiles = 0;
    $oldcourse->defaultgroupingid = 0;
    $oldcourse->enablecompletion = 0;
    $DB->update_record('course', $oldcourse);
    // Delete all related records in other tables that may have a courseid
    // This array stores the tables that need to be cleared, as
    // table_name => column_name that contains the course id.
    $tablestoclear = array('event' => 'courseid', 'log' => 'course', 'course_sections' => 'course', 'course_modules' => 'course', 'course_display' => 'course', 'backup_courses' => 'courseid', 'user_lastaccess' => 'courseid', 'backup_log' => 'courseid');
    foreach ($tablestoclear as $table => $col) {
        $DB->delete_records($table, array($col => $course->id));
    }
    // Delete all remaining stuff linked to context,
    // such as remaining roles, files, comments, etc.
    // Keep the context record for now.
    delete_context(CONTEXT_COURSE, $course->id, false);
    //trigger events
    $course->context = $context;
    // you can not access context in cron event later after course is deleted
    events_trigger('course_content_removed', $course);
    return true;
}
开发者ID:hitphp,项目名称:moodle,代码行数:101,代码来源:moodlelib.php

示例3: test_tag_deleted

 /**
  * Test the tag deleted event.
  */
 public function test_tag_deleted()
 {
     global $DB;
     $this->setAdminUser();
     // Create a course.
     $course = $this->getDataGenerator()->create_course();
     // Create tag we are going to delete.
     $tag = $this->getDataGenerator()->create_tag();
     // Trigger and capture the event for deleting a tag.
     $sink = $this->redirectEvents();
     tag_delete($tag->id);
     $events = $sink->get_events();
     $event = reset($events);
     // Check that the tag was deleted and the event data is valid.
     $this->assertEquals(0, $DB->count_records('tag'));
     $this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
     $this->assertEquals(context_system::instance(), $event->get_context());
     // Create two tags we are going to delete to ensure passing multiple tags work.
     $tag = $this->getDataGenerator()->create_tag();
     $tag2 = $this->getDataGenerator()->create_tag();
     // Trigger and capture the events for deleting multiple tags.
     $sink = $this->redirectEvents();
     tag_delete(array($tag->id, $tag2->id));
     $events = $sink->get_events();
     // Check that the tags were deleted and the events data is valid.
     $this->assertEquals(0, $DB->count_records('tag'));
     foreach ($events as $event) {
         $this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
         $this->assertEquals(context_system::instance(), $event->get_context());
     }
     // Create another tag to delete.
     $tag = $this->getDataGenerator()->create_tag();
     // Add a tag instance to a course.
     tag_assign('course', $course->id, $tag->id, 0, 2, 'course', context_course::instance($course->id)->id);
     // Trigger and capture the event for deleting a personal tag for a user for a course.
     $sink = $this->redirectEvents();
     coursetag_delete_keyword($tag->id, 2, $course->id);
     $events = $sink->get_events();
     $event = $events[1];
     // Check that the tag was deleted and the event data is valid.
     $this->assertEquals(0, $DB->count_records('tag'));
     $this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
     $this->assertEquals(context_system::instance(), $event->get_context());
     // Create a new tag we are going to delete.
     $tag = $this->getDataGenerator()->create_tag();
     // Add the tag instance to the course again as it was deleted.
     tag_assign('course', $course->id, $tag->id, 0, 2, 'course', context_course::instance($course->id)->id);
     // Trigger and capture the event for deleting all tags in a course.
     $sink = $this->redirectEvents();
     coursetag_delete_course_tags($course->id);
     $events = $sink->get_events();
     $event = $events[1];
     // Check that the tag was deleted and the event data is valid.
     $this->assertEquals(0, $DB->count_records('tag'));
     $this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
     $this->assertEquals(context_system::instance(), $event->get_context());
     // Create two tags we are going to delete to ensure passing multiple tags work.
     $tag = $this->getDataGenerator()->create_tag();
     $tag2 = $this->getDataGenerator()->create_tag();
     // Add multiple tag instances now and check that it still works.
     tag_assign('course', $course->id, $tag->id, 0, 2, 'course', context_course::instance($course->id)->id);
     tag_assign('course', $course->id, $tag2->id, 0, 2, 'course', context_course::instance($course->id)->id);
     // Trigger and capture the event for deleting all tags in a course.
     $sink = $this->redirectEvents();
     coursetag_delete_course_tags($course->id);
     $events = $sink->get_events();
     $events = array($events[2], $events[3]);
     // Check that the tags were deleted and the events data is valid.
     $this->assertEquals(0, $DB->count_records('tag'));
     foreach ($events as $event) {
         $this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
         $this->assertEquals(context_system::instance(), $event->get_context());
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:77,代码来源:events_test.php

示例4: remove_course_contents


//.........这里部分代码省略.........
                }
                $formatdelete($course->id);
            }
        }
    }
    /// Delete every instance of every module
    if ($allmods = $DB->get_records('modules')) {
        foreach ($allmods as $mod) {
            $modname = $mod->name;
            $modfile = $CFG->dirroot . '/mod/' . $modname . '/lib.php';
            $moddelete = $modname . '_delete_instance';
            // Delete everything connected to an instance
            $moddeletecourse = $modname . '_delete_course';
            // Delete other stray stuff (uncommon)
            $count = 0;
            if (file_exists($modfile)) {
                include_once $modfile;
                if (function_exists($moddelete)) {
                    if ($instances = $DB->get_records($modname, array('course' => $course->id))) {
                        foreach ($instances as $instance) {
                            if ($cm = get_coursemodule_from_instance($modname, $instance->id, $course->id)) {
                                /// Delete activity context questions and question categories
                                question_delete_activity($cm, $showfeedback);
                            }
                            if ($moddelete($instance->id)) {
                                $count++;
                            } else {
                                echo $OUTPUT->notification('Could not delete ' . $modname . ' instance ' . $instance->id . ' (' . format_string($instance->name) . ')');
                                $result = false;
                            }
                            if ($cm) {
                                // delete cm and its context in correct order
                                $DB->delete_records('course_modules', array('id' => $cm->id));
                                delete_context(CONTEXT_MODULE, $cm->id);
                            }
                        }
                    }
                } else {
                    echo $OUTPUT->notification('Function ' . $moddelete . '() doesn\'t exist!');
                    $result = false;
                }
                if (function_exists($moddeletecourse)) {
                    $moddeletecourse($course, $showfeedback);
                }
            }
            if ($showfeedback) {
                echo $OUTPUT->notification($strdeleted . ' ' . $count . ' x ' . $modname);
            }
        }
    } else {
        print_error('nomodules', 'debug');
    }
    /// Delete course blocks
    blocks_delete_all_for_context($context->id);
    /// Delete any groups, removing members and grouping/course links first.
    require_once $CFG->dirroot . '/group/lib.php';
    groups_delete_groupings($courseid, $showfeedback);
    groups_delete_groups($courseid, $showfeedback);
    /// Delete all related records in other tables that may have a courseid
    /// This array stores the tables that need to be cleared, as
    /// table_name => column_name that contains the course id.
    $tablestoclear = array('event' => 'courseid', 'log' => 'course', 'course_sections' => 'course', 'course_modules' => 'course', 'backup_courses' => 'courseid', 'user_lastaccess' => 'courseid', 'backup_log' => 'courseid');
    foreach ($tablestoclear as $table => $col) {
        if ($DB->delete_records($table, array($col => $course->id))) {
            if ($showfeedback) {
                echo $OUTPUT->notification($strdeleted . ' ' . $table);
            }
        } else {
            $result = false;
        }
    }
    /// Clean up metacourse stuff
    if ($course->metacourse) {
        $DB->delete_records("course_meta", array("parent_course" => $course->id));
        sync_metacourse($course->id);
        // have to do it here so the enrolments get nuked. sync_metacourses won't find it without the id.
        if ($showfeedback) {
            echo $OUTPUT->notification("{$strdeleted} course_meta");
        }
    } else {
        if ($parents = $DB->get_records("course_meta", array("child_course" => $course->id))) {
            foreach ($parents as $parent) {
                remove_from_metacourse($parent->parent_course, $parent->child_course);
                // this will do the unenrolments as well.
            }
            if ($showfeedback) {
                echo $OUTPUT->notification("{$strdeleted} course_meta");
            }
        }
    }
    /// Delete questions and question categories
    question_delete_course($course, $showfeedback);
    /// Remove all data from gradebook
    remove_course_grades($courseid, $showfeedback);
    remove_grade_letters($context, $showfeedback);
    /// Delete course tags
    require_once $CFG->dirroot . '/tag/coursetagslib.php';
    coursetag_delete_course_tags($course->id, $showfeedback);
    return $result;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:101,代码来源:moodlelib.php


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