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


PHP grade_course_category_delete函数代码示例

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


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

示例1: category_delete_move

/**
 * Delete category, but move contents to another category.
 * @param object $ccategory
 * @param int $newparentid category id
 * @return bool status
 */
function category_delete_move($category, $newparentid, $showfeedback = true)
{
    global $CFG, $DB, $OUTPUT;
    require_once $CFG->libdir . '/gradelib.php';
    require_once $CFG->libdir . '/questionlib.php';
    require_once $CFG->dirroot . '/cohort/lib.php';
    if (!($newparentcat = $DB->get_record('course_categories', array('id' => $newparentid)))) {
        return false;
    }
    if ($children = $DB->get_records('course_categories', array('parent' => $category->id), 'sortorder ASC')) {
        foreach ($children as $childcat) {
            move_category($childcat, $newparentcat);
        }
    }
    if ($courses = $DB->get_records('course', array('category' => $category->id), 'sortorder ASC', 'id')) {
        if (!move_courses(array_keys($courses), $newparentid)) {
            echo $OUTPUT->notification("Error moving courses");
            return false;
        }
        echo $OUTPUT->notification(get_string('coursesmovedout', '', format_string($category->name)), 'notifysuccess');
    }
    // move or delete cohorts in this context
    cohort_delete_category($category);
    // now delete anything that may depend on course category context
    grade_course_category_delete($category->id, $newparentid, $showfeedback);
    if (!question_delete_course_category($category, $newparentcat, $showfeedback)) {
        echo $OUTPUT->notification(get_string('errordeletingquestionsfromcategory', 'question', $category), 'notifysuccess');
        return false;
    }
    // finally delete the category and it's context
    $DB->delete_records('course_categories', array('id' => $category->id));
    delete_context(CONTEXT_COURSECAT, $category->id);
    events_trigger('course_category_deleted', $category);
    echo $OUTPUT->notification(get_string('coursecategorydeleted', '', format_string($category->name)), 'notifysuccess');
    return true;
}
开发者ID:numbas,项目名称:moodle,代码行数:42,代码来源:lib.php

示例2: delete_move

 /**
  * Deletes a category and moves all content (children, courses and questions) to the new parent
  *
  * Note that this function does not check capabilities, {@link coursecat::can_move_content_to()}
  * must be called prior
  *
  * @param int $newparentid
  * @param bool $showfeedback
  * @return bool
  */
 public function delete_move($newparentid, $showfeedback = false)
 {
     global $CFG, $DB, $OUTPUT;
     require_once $CFG->libdir . '/gradelib.php';
     require_once $CFG->libdir . '/questionlib.php';
     require_once $CFG->dirroot . '/cohort/lib.php';
     // get all objects and lists because later the caches will be reset so
     // we don't need to make extra queries
     $newparentcat = self::get($newparentid, MUST_EXIST, true);
     $catname = $this->get_formatted_name();
     $children = $this->get_children();
     $coursesids = $DB->get_fieldset_select('course', 'id', 'category = :category ORDER BY sortorder ASC', array('category' => $this->id));
     $context = context_coursecat::instance($this->id);
     if ($children) {
         foreach ($children as $childcat) {
             $childcat->change_parent_raw($newparentcat);
             // Log action.
             add_to_log(SITEID, "category", "move", "editcategory.php?id={$childcat->id}", $childcat->id);
         }
         fix_course_sortorder();
     }
     if ($coursesids) {
         if (!move_courses($coursesids, $newparentid)) {
             if ($showfeedback) {
                 echo $OUTPUT->notification("Error moving courses");
             }
             return false;
         }
         if ($showfeedback) {
             echo $OUTPUT->notification(get_string('coursesmovedout', '', $catname), 'notifysuccess');
         }
     }
     // move or delete cohorts in this context
     cohort_delete_category($this);
     // now delete anything that may depend on course category context
     grade_course_category_delete($this->id, $newparentid, $showfeedback);
     if (!question_delete_course_category($this, $newparentcat, $showfeedback)) {
         if ($showfeedback) {
             echo $OUTPUT->notification(get_string('errordeletingquestionsfromcategory', 'question', $catname), 'notifysuccess');
         }
         return false;
     }
     // finally delete the category and it's context
     $DB->delete_records('course_categories', array('id' => $this->id));
     $context->delete();
     add_to_log(SITEID, "category", "delete", "index.php", "{$this->name} (ID {$this->id})");
     events_trigger('course_category_deleted', $this);
     cache_helper::purge_by_event('changesincoursecat');
     if ($showfeedback) {
         echo $OUTPUT->notification(get_string('coursecategorydeleted', '', $catname), 'notifysuccess');
     }
     // If we deleted $CFG->defaultrequestcategory, make it point somewhere else.
     if ($this->id == $CFG->defaultrequestcategory) {
         set_config('defaultrequestcategory', $DB->get_field('course_categories', 'MIN(id)', array('parent' => 0)));
     }
     return true;
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:67,代码来源:coursecatlib.php

示例3: delete_move

 /**
  * Deletes a category and moves all content (children, courses and questions) to the new parent
  *
  * Note that this function does not check capabilities, {@link coursecat::can_move_content_to()}
  * must be called prior
  *
  * @param int $newparentid
  * @param bool $showfeedback
  * @return bool
  */
 public function delete_move($newparentid, $showfeedback = false)
 {
     global $CFG, $DB, $OUTPUT;
     require_once $CFG->libdir . '/gradelib.php';
     require_once $CFG->libdir . '/questionlib.php';
     require_once $CFG->dirroot . '/cohort/lib.php';
     // Get all objects and lists because later the caches will be reset so.
     // We don't need to make extra queries.
     $newparentcat = self::get($newparentid, MUST_EXIST, true);
     $catname = $this->get_formatted_name();
     $children = $this->get_children();
     $params = array('category' => $this->id);
     $coursesids = $DB->get_fieldset_select('course', 'id', 'category = :category ORDER BY sortorder ASC', $params);
     $context = $this->get_context();
     if ($children) {
         foreach ($children as $childcat) {
             $childcat->change_parent_raw($newparentcat);
             // Log action.
             $event = \core\event\course_category_updated::create(array('objectid' => $childcat->id, 'context' => $childcat->get_context()));
             $event->set_legacy_logdata(array(SITEID, 'category', 'move', 'editcategory.php?id=' . $childcat->id, $childcat->id));
             $event->trigger();
         }
         fix_course_sortorder();
     }
     if ($coursesids) {
         if (!move_courses($coursesids, $newparentid)) {
             if ($showfeedback) {
                 echo $OUTPUT->notification("Error moving courses");
             }
             return false;
         }
         if ($showfeedback) {
             echo $OUTPUT->notification(get_string('coursesmovedout', '', $catname), 'notifysuccess');
         }
     }
     // Move or delete cohorts in this context.
     cohort_delete_category($this);
     // Now delete anything that may depend on course category context.
     grade_course_category_delete($this->id, $newparentid, $showfeedback);
     if (!question_delete_course_category($this, $newparentcat, $showfeedback)) {
         if ($showfeedback) {
             echo $OUTPUT->notification(get_string('errordeletingquestionsfromcategory', 'question', $catname), 'notifysuccess');
         }
         return false;
     }
     // Finally delete the category and it's context.
     $DB->delete_records('course_categories', array('id' => $this->id));
     $context->delete();
     // Trigger a course category deleted event.
     /* @var \core\event\course_category_deleted $event */
     $event = \core\event\course_category_deleted::create(array('objectid' => $this->id, 'context' => $context, 'other' => array('name' => $this->name)));
     $event->set_coursecat($this);
     $event->trigger();
     cache_helper::purge_by_event('changesincoursecat');
     if ($showfeedback) {
         echo $OUTPUT->notification(get_string('coursecategorydeleted', '', $catname), 'notifysuccess');
     }
     // If we deleted $CFG->defaultrequestcategory, make it point somewhere else.
     if ($this->id == $CFG->defaultrequestcategory) {
         set_config('defaultrequestcategory', $DB->get_field('course_categories', 'MIN(id)', array('parent' => 0)));
     }
     return true;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:73,代码来源:coursecatlib.php

示例4: category_delete_move

/**
 * Delete category, but move contents to another category.
 * @param object $ccategory
 * @param int $newparentid category id
 * @return bool status
 */
function category_delete_move($category, $newparentid, $showfeedback = true)
{
    global $CFG;
    require_once $CFG->libdir . '/gradelib.php';
    require_once $CFG->libdir . '/questionlib.php';
    if (!($newparentcat = get_record('course_categories', 'id', $newparentid))) {
        return false;
    }
    if ($children = get_records('course_categories', 'parent', $category->id, 'sortorder ASC')) {
        foreach ($children as $childcat) {
            if (!move_category($childcat, $newparentcat)) {
                notify("Error moving category {$childcat->name}");
                return false;
            }
        }
    }
    if ($courses = get_records('course', 'category', $category->id, 'sortorder ASC', 'id')) {
        if (!move_courses(array_keys($courses), $newparentid)) {
            notify("Error moving courses");
            return false;
        }
        notify(get_string('coursesmovedout', '', format_string($category->name)), 'notifysuccess');
    }
    // now delete anything that may depend on course category context
    grade_course_category_delete($category->id, $newparentid, $showfeedback);
    if (!question_delete_course_category($category, $newparentcat, $showfeedback)) {
        notify(get_string('errordeletingquestionsfromcategory', 'question', $category), 'notifysuccess');
        return false;
    }
    // finally delete the category and it's context
    delete_records('course_categories', 'id', $category->id);
    delete_context(CONTEXT_COURSECAT, $category->id);
    events_trigger('course_category_deleted', $category);
    notify(get_string('coursecategorydeleted', '', format_string($category->name)), 'notifysuccess');
    return true;
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:42,代码来源:lib.php


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