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


PHP coursecat类代码示例

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


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


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