• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP coursecat类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: definition

 /**
  * Form definition
  */
 public function definition()
 {
     global $CFG, $DB, $PAGE;
     require_once $CFG->libdir . '/coursecatlib.php';
     $PAGE->requires->js_call_amd('tool_cat/form', 'init', array());
     $mform =& $this->_form;
     // Global update button.
     $mform->registerNoSubmitButton('updateform');
     $mform->addElement('submit', 'updateform', 'Update Form', array('class' => 'hidden'));
     // Select a category.
     $mform->addElement('header', 'info', 'Category');
     $catlist = \coursecat::make_categories_list('tool/cat:manage');
     $categories = array(0 => 'Please select a category');
     foreach ($catlist as $k => $v) {
         $categories[$k] = $v;
     }
     $mform->addElement('select', 'categoryid', 'Category', $categories);
     // Do we have a category?
     $category = optional_param('categoryid', false, PARAM_INT);
     if (!empty($category)) {
         $mform->setDefault('categoryid', $category);
         // Populate existing rules.
         $this->add_rule_fieldsets($category);
         // Print a blank rule-add row.
         $mform->addElement('header', 'rule_new', 'Add a new rule');
         $mform->setExpanded('rule_new');
         $this->add_rule_fieldset();
     }
     $this->add_action_buttons(true, 'Save rules');
 }
开发者ID:unikent,项目名称:moodle-tool_cat,代码行数:33,代码来源:category_rules.php


示例2: get_category_tree

 private function get_category_tree($id)
 {
     global $DB;
     $category = $DB->get_record('course_categories', array('id' => $id));
     if ($id && !$category) {
         cli_error("Wrong category '{$id}'");
     } elseif (!$id) {
         $category = NULL;
     }
     $parentcategory = \coursecat::get($id);
     if ($parentcategory->has_children()) {
         $parentschildren = $parentcategory->get_children();
         foreach ($parentschildren as $singlecategory) {
             if ($singlecategory->has_children()) {
                 $childcategories = $this->get_category_tree($singlecategory->id);
                 $category->categories[] = $childcategories;
             } else {
                 // coursecat variables are protected, need to get data from db
                 $singlecategory = $DB->get_record('course_categories', array('id' => $singlecategory->id));
                 $category->categories[] = $singlecategory;
             }
         }
     }
     return $category;
 }
开发者ID:dariogs,项目名称:moosh,代码行数:25,代码来源:CategoryExport.php


示例3: category_selector

 function category_selector($url)
 {
     global $OUTPUT;
     $str = '';
     $choice = optional_param('category', 0, PARAM_INT);
     $categories = coursecat::make_categories_list();
     $str .= $OUTPUT->single_select($url, 'category', $categories, $choice, array('' => get_string('all', 'enrol_delayedcohort')));
     return $str;
 }
开发者ID:vfremaux,项目名称:moodle-enrol_delayedcohort,代码行数:9,代码来源:renderer.php


示例4: theme_campus_get_top_level_categories

/**
 * Campus theme with the underlying Bootstrap theme.
 *
 * @package    theme
 * @subpackage campus
 * @copyright  © 2014-onwards G J Barnard in respect to modifications of the Clean theme.
 * @copyright  © 2014-onwards Work undertaken for David Bogner of Edulabs.org.
 * @author     G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195}
 * @author     Based on code originally written by Mary Evans, Bas Brands, Stuart Lamour and David Scotson.
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function theme_campus_get_top_level_categories()
{
    global $CFG;
    include_once $CFG->libdir . '/coursecatlib.php';
    $categoryids = array();
    $categories = coursecat::get(0)->get_children();
    // Parent = 0 i.e. top-level categories only.
    foreach ($categories as $category) {
        $categoryids[$category->id] = $category->name;
    }
    return $categoryids;
}
开发者ID:amsibsam,项目名称:moodle3,代码行数:23,代码来源:campus-lib.php


示例5: definition

    function definition() {
        global $CFG, $DB;
        $mform =& $this->_form;
        $category = $this->_customdata['category'];
        $editoroptions = $this->_customdata['editoroptions'];

        // get list of categories to use as parents, with site as the first one
        $options = array();
        if (has_capability('moodle/category:manage', context_system::instance()) || $category->parent == 0) {
            $options[0] = get_string('top');
        }
        if ($category->id) {
            // Editing an existing category.
            $options += coursecat::make_categories_list('moodle/category:manage', $category->id);
            if (empty($options[$category->parent])) {
                $options[$category->parent] = $DB->get_field('course_categories', 'name', array('id'=>$category->parent));
            }
            $strsubmit = get_string('savechanges');
        } else {
            // Making a new category
            $options += coursecat::make_categories_list('moodle/category:manage');
            $strsubmit = get_string('createcategory');
        }

        $mform->addElement('select', 'parent', get_string('parentcategory'), $options);
        $mform->addElement('text', 'name', get_string('categoryname'), array('size'=>'30'));
        $mform->addRule('name', get_string('required'), 'required', null);
        $mform->setType('name', PARAM_TEXT);
        $mform->addElement('text', 'idnumber', get_string('idnumbercoursecategory'),'maxlength="100"  size="10"');
        $mform->addHelpButton('idnumber', 'idnumbercoursecategory');
        $mform->setType('idnumber', PARAM_RAW);
        $mform->addElement('editor', 'description_editor', get_string('description'), null, $editoroptions);
        $mform->setType('description_editor', PARAM_RAW);
        if (!empty($CFG->allowcategorythemes)) {
            $themes = array(''=>get_string('forceno'));
            $allthemes = get_list_of_themes();
            foreach ($allthemes as $key=>$theme) {
                if (empty($theme->hidefromselector)) {
                    $themes[$key] = get_string('pluginname', 'theme_'.$theme->name);
                }
            }
            $mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
        }

        $mform->addElement('hidden', 'id', 0);
        $mform->setType('id', PARAM_INT);
        $mform->setDefault('id', $category->id);

        $this->add_action_buttons(true, $strsubmit);
    }
开发者ID:number33,项目名称:moodle,代码行数:50,代码来源:editcategory_form.php


示例6: test_pre_course_category_delete_hook

 /**
  * Check that our hook is called when a course is deleted.
  */
 public function test_pre_course_category_delete_hook()
 {
     global $DB;
     // Should have nothing in the recycle bin.
     $this->assertEquals(0, $DB->count_records('tool_recyclebin_category'));
     delete_course($this->course, false);
     // Check the course is now in the recycle bin.
     $this->assertEquals(1, $DB->count_records('tool_recyclebin_category'));
     // Now let's delete the course category.
     $category = coursecat::get($this->course->category);
     $category->delete_full(false);
     // Check that the course was deleted from the category recycle bin.
     $this->assertEquals(0, $DB->count_records('tool_recyclebin_category'));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:17,代码来源:category_bin_test.php


示例7: create_category_pditt

function create_category_pditt($nama,$deskripsi=''){
    global $DB,  $CFG;
    $x = $DB->get_record('course_categories', array('name' => 'PDITT-' . $nama), '*');
    if (!$x){
        $data = new stdClass();
        $data->name='PDITT-' . $nama;
        $data->description=$deskripsi;
        $data->descriptionformat=0;
        $data->parent=0;
        $category = coursecat::create($data);
        return $category->id;
    } else {
        return $x->id;
    }
}
开发者ID:rm77,项目名称:pd1tt_module,代码行数:15,代码来源:fungsi_moodle.php


示例8: get_category_options

 protected function get_category_options($currentcontextid)
 {
     global $CFG;
     require_once $CFG->libdir . '/coursecatlib.php';
     $displaylist = coursecat::make_categories_list('moodle/cohort:manage');
     $options = array();
     $syscontext = context_system::instance();
     if (has_capability('moodle/cohort:manage', $syscontext)) {
         $options[$syscontext->id] = $syscontext->get_context_name();
     }
     foreach ($displaylist as $cid => $name) {
         $context = context_coursecat::instance($cid);
         $options[$context->id] = $name;
     }
     // Always add current - this is not likely, but if the logic gets changed it might be a problem.
     if (!isset($options[$currentcontextid])) {
         $context = context::instance_by_id($currentcontextid, MUST_EXIST);
         $options[$context->id] = $syscontext->get_context_name();
     }
     return $options;
 }
开发者ID:abhilash1994,项目名称:moodle,代码行数:21,代码来源:edit_form.php


示例9: get_courses

 public function get_courses(&$mform)
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/course/lib.php';
     $buttonarray = array();
     // Get courses with enabled completion.
     $courses = $DB->get_records('course', array('enablecompletion' => COMPLETION_ENABLED));
     if (!empty($courses)) {
         require_once $CFG->libdir . '/coursecatlib.php';
         $list = coursecat::make_categories_list();
         $select = array();
         $selected = array();
         foreach ($courses as $c) {
             $select[$c->id] = $list[$c->category] . ' / ' . format_string($c->fullname, true, array('context' => context_course::instance($c->id)));
         }
         if ($this->id !== 0) {
             $selected = array_keys($this->params);
         }
         $settings = array('multiple' => 'multiple', 'size' => 20, 'style' => 'width:300px');
         $mform->addElement('select', 'courses', get_string('addcourse', 'badges'), $select, $settings);
         $mform->addRule('courses', get_string('requiredcourse', 'badges'), 'required');
         $mform->addHelpButton('courses', 'addcourse', 'badges');
         $buttonarray[] =& $mform->createElement('submit', 'submitcourse', get_string('addcourse', 'badges'));
         $buttonarray[] =& $mform->createElement('submit', 'cancel', get_string('cancel'));
         $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
         $mform->addElement('hidden', 'addcourse', 'addcourse');
         $mform->setType('addcourse', PARAM_TEXT);
         if ($this->id !== 0) {
             $mform->setDefault('courses', $selected);
         }
         $mform->setType('agg', PARAM_INT);
     } else {
         $mform->addElement('static', 'nocourses', '', get_string('error:nocourses', 'badges'));
         $buttonarray[] =& $mform->createElement('submit', 'cancel', get_string('continue'));
         $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
     }
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:37,代码来源:award_criteria_courseset.php


示例10: definition

 function definition()
 {
     global $CFG, $DB, $USER;
     $mform =& $this->_form;
     if ($pending = $DB->get_records('course_request', array('requester' => $USER->id))) {
         $mform->addElement('header', 'pendinglist', get_string('coursespending'));
         $list = array();
         foreach ($pending as $cp) {
             $list[] = format_string($cp->fullname);
         }
         $list = implode(', ', $list);
         $mform->addElement('static', 'pendingcourses', get_string('courses'), $list);
     }
     $mform->addElement('header', 'coursedetails', get_string('courserequestdetails'));
     $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"');
     $mform->addHelpButton('fullname', 'fullnamecourse');
     $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
     $mform->setType('fullname', PARAM_TEXT);
     $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"');
     $mform->addHelpButton('shortname', 'shortnamecourse');
     $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
     $mform->setType('shortname', PARAM_TEXT);
     if (!empty($CFG->requestcategoryselection)) {
         $displaylist = coursecat::make_categories_list();
         $mform->addElement('select', 'category', get_string('category'), $displaylist);
         $mform->setDefault('category', $CFG->defaultrequestcategory);
         $mform->addHelpButton('category', 'category');
     }
     $mform->addElement('editor', 'summary_editor', get_string('summary'), null, course_request::summary_editor_options());
     $mform->addHelpButton('summary_editor', 'coursesummary');
     $mform->setType('summary_editor', PARAM_RAW);
     $mform->addElement('header', 'requestreason', get_string('courserequestreason'));
     $mform->addElement('textarea', 'reason', get_string('courserequestsupport'), array('rows' => '15', 'cols' => '50'));
     $mform->addRule('reason', get_string('missingreqreason'), 'required', null, 'client');
     $mform->setType('reason', PARAM_TEXT);
     $this->add_action_buttons(true, get_string('requestcourse'));
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:37,代码来源:request_form.php


示例11: build

 /**
  * Create the fixture
  *
  * This method must be safe to call multiple times.
  *
  * @return void
  * @throws moodle_exception
  */
 public function build()
 {
     global $CFG, $DB;
     require_once $CFG->libdir . '/coursecatlib.php';
     if (!$this->exists()) {
         $course = (object) $this->get_options();
         // Clean course table - can happen when unit tests fail...
         if (!empty($course->shortname) and $record = $DB->get_record('course', array('shortname' => $course->shortname))) {
             delete_course($record, false);
         }
         if (!empty($course->idnumber) and $record = $DB->get_record('course', array('idnumber' => $course->idnumber))) {
             delete_course($record, false);
         }
         // Try to help folks out...
         if (!property_exists($course, 'category')) {
             $course->category = coursecat::get_default()->id;
         }
         if (!property_exists($course, 'fullname')) {
             $course->fullname = '';
         }
         $course = create_course($course);
         $this->set_results($DB->get_record('course', array('id' => $course->id), '*', MUST_EXIST));
     }
 }
开发者ID:bgao-ca,项目名称:moodle-local_mr,代码行数:32,代码来源:course.php


示例12: definition

 function definition()
 {
     global $USER, $CFG, $DB, $PAGE;
     $mform = $this->_form;
     $PAGE->requires->yui_module('moodle-course-formatchooser', 'M.course.init_formatchooser', array(array('formid' => $mform->getAttribute('id'))));
     $course = $this->_customdata['course'];
     // this contains the data of this form
     $category = $this->_customdata['category'];
     $editoroptions = $this->_customdata['editoroptions'];
     $returnto = $this->_customdata['returnto'];
     $systemcontext = context_system::instance();
     $categorycontext = context_coursecat::instance($category->id);
     if (!empty($course->id)) {
         $coursecontext = context_course::instance($course->id);
         $context = $coursecontext;
     } else {
         $coursecontext = null;
         $context = $categorycontext;
     }
     $courseconfig = get_config('moodlecourse');
     $this->course = $course;
     $this->context = $context;
     /// form definition with new course defaults
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('hidden', 'returnto', null);
     $mform->setType('returnto', PARAM_ALPHANUM);
     $mform->setConstant('returnto', $returnto);
     $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"');
     $mform->addHelpButton('fullname', 'fullnamecourse');
     $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
     $mform->setType('fullname', PARAM_TEXT);
     if (!empty($course->id) and !has_capability('moodle/course:changefullname', $coursecontext)) {
         $mform->hardFreeze('fullname');
         $mform->setConstant('fullname', $course->fullname);
     }
     $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"');
     $mform->addHelpButton('shortname', 'shortnamecourse');
     $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
     $mform->setType('shortname', PARAM_TEXT);
     if (!empty($course->id) and !has_capability('moodle/course:changeshortname', $coursecontext)) {
         $mform->hardFreeze('shortname');
         $mform->setConstant('shortname', $course->shortname);
     }
     // Verify permissions to change course category or keep current.
     if (empty($course->id)) {
         if (has_capability('moodle/course:create', $categorycontext)) {
             $displaylist = coursecat::make_categories_list('moodle/course:create');
             $mform->addElement('select', 'category', get_string('coursecategory'), $displaylist);
             $mform->addHelpButton('category', 'coursecategory');
             $mform->setDefault('category', $category->id);
         } else {
             $mform->addElement('hidden', 'category', null);
             $mform->setType('category', PARAM_INT);
             $mform->setConstant('category', $category->id);
         }
     } else {
         if (has_capability('moodle/course:changecategory', $coursecontext)) {
             $displaylist = coursecat::make_categories_list('moodle/course:create');
             if (!isset($displaylist[$course->category])) {
                 //always keep current
                 $displaylist[$course->category] = coursecat::get($course->category)->get_formatted_name();
             }
             $mform->addElement('select', 'category', get_string('coursecategory'), $displaylist);
             $mform->addHelpButton('category', 'coursecategory');
         } else {
             //keep current
             $mform->addElement('hidden', 'category', null);
             $mform->setType('category', PARAM_INT);
             $mform->setConstant('category', $course->category);
         }
     }
     $choices = array();
     $choices['0'] = get_string('hide');
     $choices['1'] = get_string('show');
     $mform->addElement('select', 'visible', get_string('visible'), $choices);
     $mform->addHelpButton('visible', 'visible');
     $mform->setDefault('visible', $courseconfig->visible);
     if (!has_capability('moodle/course:visibility', $context)) {
         $mform->hardFreeze('visible');
         if (!empty($course->id)) {
             $mform->setConstant('visible', $course->visible);
         } else {
             $mform->setConstant('visible', $courseconfig->visible);
         }
     }
     $mform->addElement('date_selector', 'startdate', get_string('startdate'));
     $mform->addHelpButton('startdate', 'startdate');
     $mform->setDefault('startdate', time() + 3600 * 24);
     $mform->addElement('text', 'idnumber', get_string('idnumbercourse'), 'maxlength="100"  size="10"');
     $mform->addHelpButton('idnumber', 'idnumbercourse');
     $mform->setType('idnumber', PARAM_RAW);
     if (!empty($course->id) and !has_capability('moodle/course:changeidnumber', $coursecontext)) {
         $mform->hardFreeze('idnumber');
         $mform->setConstants('idnumber', $course->idnumber);
     }
     // Description.
     $mform->addElement('header', 'descriptionhdr', get_string('description'));
     $mform->setExpanded('descriptionhdr');
     $mform->addElement('editor', 'summary_editor', get_string('coursesummary'), null, $editoroptions);
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:edit_form.php


示例13: print_courses

/**
 * Print courses in category. If category is 0 then all courses are printed.
 *
 * @deprecated since 2.5
 *
 * To print a generic list of courses use:
 * $renderer = $PAGE->get_renderer('core', 'course');
 * echo $renderer->courses_list($courses);
 *
 * To print list of all courses:
 * $renderer = $PAGE->get_renderer('core', 'course');
 * echo $renderer->frontpage_available_courses();
 *
 * To print list of courses inside category:
 * $renderer = $PAGE->get_renderer('core', 'course');
 * echo $renderer->course_category($category); // this will also print subcategories
 *
 * @param int|stdClass $category category object or id.
 * @return bool true if courses found and printed, else false.
 */
function print_courses($category)
{
    global $CFG, $OUTPUT, $PAGE;
    require_once $CFG->libdir . '/coursecatlib.php';
    debugging('Function print_courses() is deprecated, please use course renderer', DEBUG_DEVELOPER);
    if (!is_object($category) && $category == 0) {
        $courses = coursecat::get(0)->get_courses(array('recursive' => true, 'summary' => true, 'coursecontacts' => true));
    } else {
        $courses = coursecat::get($category->id)->get_courses(array('summary' => true, 'coursecontacts' => true));
    }
    if ($courses) {
        $renderer = $PAGE->get_renderer('core', 'course');
        echo $renderer->courses_list($courses);
    } else {
        echo $OUTPUT->heading(get_string("nocoursesyet"));
        $context = context_system::instance();
        if (has_capability('moodle/course:create', $context)) {
            $options = array();
            if (!empty($category->id)) {
                $options['category'] = $category->id;
            } else {
                $options['category'] = $CFG->defaultrequestcategory;
            }
            echo html_writer::start_tag('div', array('class' => 'addcoursebutton'));
            echo $OUTPUT->single_button(new moodle_url('/course/edit.php', $options), get_string("addnewcourse"));
            echo html_writer::end_tag('div');
            return false;
        }
    }
    return true;
}
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:51,代码来源:deprecatedlib.php


示例14: get_course_categories

 /**
  * Returns an array of course categories
  * @return array of course categories
  */
 function get_course_categories()
 {
     global $CFG;
     require_once $CFG->libdir . '/coursecatlib.php';
     return array(0 => get_string('anycategory', 'filters')) + coursecat::make_categories_list();
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:10,代码来源:courserole.php


示例15: test_course_add_default_category

 /**
  * Add new course without a category.
  */
 public function test_course_add_default_category()
 {
     global $DB, $CFG;
     require_once $CFG->libdir . '/coursecatlib.php';
     $this->imsplugin->set_config('createnewcategories', false);
     // Delete the default category, to ensure the plugin handles this gracefully.
     $defaultcat = coursecat::get_default();
     $defaultcat->delete_full(false);
     // Create an course with the IMS plugin without a category.
     $course1 = new stdClass();
     $course1->idnumber = 'id1';
     $course1->imsshort = 'id1';
     $course1->category = '';
     $this->set_xml_file(false, array($course1));
     $this->imsplugin->cron();
     // Check the course has been created.
     $dbcourse = $DB->get_record('course', array('idnumber' => $course1->idnumber), '*', MUST_EXIST);
     // Check that it belongs to a category which exists.
     $this->assertTrue($DB->record_exists('course_categories', array('id' => $dbcourse->category)));
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:23,代码来源:imsenterprise_test.php


示例16: delete_categories

    /**
     * Delete categories
     *
     * @param array $categories A list of category ids
     * @return array
     * @since Moodle 2.3
     */
    public static function delete_categories($categories) {
        global $CFG, $DB;
        require_once($CFG->dirroot . "/course/lib.php");
        require_once($CFG->libdir . "/coursecatlib.php");

        // Validate parameters.
        $params = self::validate_parameters(self::delete_categories_parameters(), array('categories' => $categories));

        $transaction = $DB->start_delegated_transaction();

        foreach ($params['categories'] as $category) {
            $deletecat = coursecat::get($category['id'], MUST_EXIST);
            $context = context_coursecat::instance($deletecat->id);
            require_capability('moodle/category:manage', $context);
            self::validate_context($context);
            self::validate_context(get_category_or_system_context($deletecat->parent));

            if ($category['recursive']) {
                // If recursive was specified, then we recursively delete the category's contents.
                if ($deletecat->can_delete_full()) {
                    $deletecat->delete_full(false);
                } else {
                    throw new moodle_exception('youcannotdeletecategory', '', '', $deletecat->get_formatted_name());
                }
            } else {
                // In this situation, we don't delete the category's contents, we either move it to newparent or parent.
                // If the parent is the root, moving is not supported (because a course must always be inside a category).
                // We must move to an existing category.
                if (!empty($category['newparent'])) {
                    $newparentcat = coursecat::get($category['newparent']);
                } else {
                    $newparentcat = coursecat::get($deletecat->parent);
                }

                // This operation is not allowed. We must move contents to an existing category.
                if (!$newparentcat->id) {
                    throw new moodle_exception('movecatcontentstoroot');
                }

                self::validate_context(context_coursecat::instance($newparentcat->id));
                if ($deletecat->can_move_content_to($newparentcat->id)) {
                    $deletecat->delete_move($newparentcat->id, false);
                } else {
                    throw new moodle_exception('youcannotdeletecategory', '', '', $deletecat->get_formatted_name());
                }
            }
        }

        $transaction->allow_commit();
    }
开发者ID:rwijaya,项目名称:moodle,代码行数:57,代码来源:externallib.php


示例17: get_content

 function get_content()
 {
     global $CFG, $USER, $DB, $OUTPUT;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     $icon = '<img src="' . $OUTPUT->pix_url('i/course') . '" class="icon" alt="" />';
     $adminseesall = true;
     if (isset($CFG->block_course_list_adminview)) {
         if ($CFG->block_course_list_adminview == 'own') {
             $adminseesall = false;
         }
     }
     if (empty($CFG->disablemycourses) and isloggedin() and !isguestuser() and !(has_capability('moodle/course:update', context_system::instance()) and $adminseesall)) {
         // Just print My Courses
         if ($courses = enrol_get_my_courses(NULL, 'visible DESC, fullname ASC')) {
             foreach ($courses as $course) {
                 $coursecontext = context_course::instance($course->id);
                 $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
                 $this->content->items[] = "<a {$linkcss} title=\"" . format_string($course->shortname, true, array('context' => $coursecontext)) . "\" " . "href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}\">" . $icon . format_string(get_course_display_name_for_list($course)) . "</a>";
             }
             $this->title = get_string('mycourses');
             /// If we can update any course of the view all isn't hidden, show the view all courses link
             if (has_capability('moodle/course:update', context_system::instance()) || empty($CFG->block_course_list_hideallcourseslink)) {
                 $this->content->footer = "<a href=\"{$CFG->wwwroot}/course/index.php\">" . get_string("fulllistofcourses") . "</a> ...";
             }
         }
         $this->get_remote_courses();
         if ($this->content->items) {
             // make sure we don't return an empty list
             return $this->content;
         }
     }
     $categories = coursecat::get(0)->get_children();
     // Parent = 0   ie top-level categories only
     if ($categories) {
         //Check we have categories
         if (count($categories) > 1 || count($categories) == 1 && $DB->count_records('course') > 200) {
             // Just print top level category links
             foreach ($categories as $category) {
                 $categoryname = $category->get_formatted_name();
                 $linkcss = $category->visible ? "" : " class=\"dimmed\" ";
                 $this->content->items[] = "<a {$linkcss} href=\"{$CFG->wwwroot}/course/index.php?categoryid={$category->id}\">" . $icon . $categoryname . "</a>";
             }
             /// If we can update any course of the view all isn't hidden, show the view all courses link
             if (has_capability('moodle/course:update', context_system::instance()) || empty($CFG->block_course_list_hideallcourseslink)) {
                 $this->content->footer .= "<a href=\"{$CFG->wwwroot}/course/index.php\">" . get_string('fulllistofcourses') . '</a> ...';
             }
             $this->title = get_string('categories');
         } else {
             // Just print course names of single category
             $category = array_shift($categories);
             $courses = get_courses($category->id);
             if ($courses) {
                 foreach ($courses as $course) {
                     $coursecontext = context_course::instance($course->id);
                     $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
                     $this->content->items[] = "<a {$linkcss} title=\"" . format_string($course->shortname, true, array('context' => $coursecontext)) . "\" " . "href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}\">" . $icon . format_string(get_course_display_name_for_list($course), true, array('context' => context_course::instance($course->id))) . "</a>";
                 }
                 /// If we can update any course of the view all isn't hidden, show the view all courses link
                 if (has_capability('moodle/course:update', context_system::instance()) || empty($CFG->block_course_list_hideallcourseslink)) {
                     $this->content->footer .= "<a href=\"{$CFG->wwwroot}/course/index.php\">" . get_string('fulllistofcourses') . '</a> ...';
                 }
                 $this->get_remote_courses();
             } else {
                 $this->content->icons[] = '';
                 $this->content->items[] = get_string('nocoursesyet');
                 if (has_capability('moodle/course:create', context_coursecat::instance($category->id))) {
                     $this->content->footer = '<a href="' . $CFG->wwwroot . '/course/edit.php?category=' . $category->id . '">' . get_string("addnewcourse") . '</a> ...';
                 }
                 $this->get_remote_courses();
             }
             $this->title = get_string('courses');
         }
     }
     return $this->content;
 }
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:81,代码来源:block_course_list.php


示例18: list

         continue;
     }
     list($ignored, $roleid) = explode('_', $fieldname);
     $rolename = new stdClass();
     $rolename->catid = $id;
     $rolename->roleid = $roleid;
     $rolename->name = $value;
     $newrolenames[] = $rolename;
 }
 // This is for updating all categories and courses.
 $cats = array(coursecat::get($id));
 $courses = array();
 if ($categories = coursecat::get($id)->get_children()) {
     foreach ($categories as $cat) {
         array_push($cats, $cat);
         $cats = array_merge($cats, coursecat::get($cat->id)->get_children());
     }
 }
 // Update all the category's.
 foreach ($cats as $coursecat) {
     $courses = array_merge($courses, get_courses($coursecat->id));
     foreach ($newrolenames as $role) {
         if (!$role->name) {
             $DB->delete_records('cat_role_names', array('catid' => $coursecat->id, 'roleid' => $role->roleid));
         } else {
             if ($rolename = $DB->get_record('cat_role_names', array('catid' => $coursecat->id, 'roleid' => $role->roleid))) {
                 $rolename->name = $role->name;
                 $DB->update_record('cat_role_names', $rolename);
             } else {
                 $rolename = new stdClass();
                 $rolename->catid = $coursecat->id;
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:31,代码来源:categoryroles.php


示例19: coursecat_coursebox_content

 protected function coursecat_coursebox_content(coursecat_helper $chelper, $course)
 {
     global $CFG;
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         return '';
     }
     if ($course instanceof stdClass) {
         require_once $CFG->libdir . '/coursecatlib.php';
         $course = new course_in_list($course);
     }
     $content = '';
     // Display course overview files.
     $contentimages = $contentfiles = '';
     foreach ($course->get_course_overviewfiles() as $file) {
         $isimage = $file->is_valid_image();
         $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
         if ($isimage) {
             $contentimages .= html_writer::start_tag('div', array('class' => 'imagebox'));
             $images = html_writer::empty_tag('img', array('src' => $url, 'alt' => 'Course Image ' . $course->fullname, 'class' => 'courseimage'));
             $contentimages .= html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $images);
             $contentimages .= html_writer::end_tag('div');
         } else {
             $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
             $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename'));
             $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon'));
         }
     }
     $content .= $contentimages . $contentfiles;
     // Display course summary.
     if ($course->has_summary()) {
         $content .= $chelper->get_course_formatted_summary($course);
     }
     // Display course contacts. See course_in_list::get_course_contacts().
     if ($course->has_course_contacts()) {
         $content .= html_writer::start_tag('ul', array('class' => 'teachers'));
         foreach ($course->get_course_contacts() as $userid => $coursecontact) {
             $name = $coursecontact['rolename'] . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $userid, 'course' => SITEID)), $coursecontact['username']);
             $content .= html_writer::tag('li', $name);
         }
         $content .= html_writer::end_tag('ul');
         // End .teachers div.
     }
     // Display course category if necessary (for example in search results).
     if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) {
         require_once $CFG->libdir . '/coursecatlib.php';
         if ($cat = coursecat::get($course->category, IGNORE_MISSING)) {
             $content .= html_writer::start_tag('div', array('class' => 'coursecat'));
             $content .= get_string('category') . ': ' . html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)), $cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed'));
             $content .= html_writer::end_tag('div');
             // End .coursecat div.
         }
     }
     return $content;
 }
开发者ID:nadavkav,项目名称:moodle-accessibility,代码行数:54,代码来源:course_renderer.php


示例20: search_courses

 /**
  * Search courses following the specified criteria.
  *
  * @param string $criterianame  Criteria name (search, modulelist (only admins), blocklist (only admins), tagid)
  * @param string $criteriavalue Criteria value
  * @param int $page             Page number (for pagination)
  * @param int $perpage          Items per page
  * @param array $requiredca 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP cron类代码示例发布时间:2022-05-23
下一篇:
PHP course_modinfo类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap