本文整理汇总了PHP中get_sorted_course_formats函数的典型用法代码示例。如果您正苦于以下问题:PHP get_sorted_course_formats函数的具体用法?PHP get_sorted_course_formats怎么用?PHP get_sorted_course_formats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_sorted_course_formats函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_plugins
/**
* Gathers and returns the information about all plugins of the given type
*
* @param string $type the name of the plugintype, eg. mod, auth or workshopform
* @param string $typerootdir full path to the location of the plugin dir
* @param string $typeclass the name of the actually called class
* @param core_plugin_manager $pluginman the plugin manager calling this method
* @return array of plugintype classes, indexed by the plugin name
*/
public static function get_plugins($type, $typerootdir, $typeclass, $pluginman)
{
global $CFG;
require_once $CFG->dirroot . '/course/lib.php';
$formats = parent::get_plugins($type, $typerootdir, $typeclass, $pluginman);
$order = get_sorted_course_formats();
$sortedformats = array();
foreach ($order as $formatname) {
$sortedformats[$formatname] = $formats[$formatname];
}
return $sortedformats;
}
示例2: get_format_or_default
/**
* Validates that course format exists and enabled and returns either itself or default format
*
* @param string $format
* @return string
*/
protected static final function get_format_or_default($format)
{
global $CFG;
require_once $CFG->dirroot . '/course/lib.php';
if (array_key_exists($format, self::$classesforformat)) {
return self::$classesforformat[$format];
}
$plugins = get_sorted_course_formats();
foreach ($plugins as $plugin) {
self::$classesforformat[$plugin] = $plugin;
}
if (array_key_exists($format, self::$classesforformat)) {
return self::$classesforformat[$format];
}
if (PHPUNIT_TEST && class_exists('format_' . $format)) {
// Allow unittests to use non-existing course formats.
return $format;
}
// Else return default format
$defaultformat = get_config('moodlecourse', 'format');
if (!in_array($defaultformat, $plugins)) {
// when default format is not set correctly, use the first available format
$defaultformat = reset($plugins);
}
debugging('Format plugin format_' . $format . ' is not found. Using default format_' . $defaultformat, DEBUG_DEVELOPER);
self::$classesforformat[$format] = $defaultformat;
return $defaultformat;
}
示例3: definition
//.........这里部分代码省略.........
} 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);
$mform->addHelpButton('summary_editor', 'coursesummary');
$mform->setType('summary_editor', PARAM_RAW);
$summaryfields = 'summary_editor';
if ($overviewfilesoptions = course_overviewfiles_options($course)) {
$mform->addElement('filemanager', 'overviewfiles_filemanager', get_string('courseoverviewfiles'), null, $overviewfilesoptions);
$mform->addHelpButton('overviewfiles_filemanager', 'courseoverviewfiles');
$summaryfields .= ',overviewfiles_filemanager';
}
if (!empty($course->id) and !has_capability('moodle/course:changesummary', $coursecontext)) {
// Remove the description header it does not contain anything any more.
$mform->removeElement('descriptionhdr');
$mform->hardFreeze($summaryfields);
}
// Course format.
$mform->addElement('header', 'courseformathdr', get_string('type_format', 'plugin'));
$courseformats = get_sorted_course_formats(true);
$formcourseformats = array();
foreach ($courseformats as $courseformat) {
$formcourseformats[$courseformat] = get_string('pluginname', "format_{$courseformat}");
}
if (isset($course->format)) {
$course->format = course_get_format($course)->get_format();
// replace with default if not found
if (!in_array($course->format, $courseformats)) {
// this format is disabled. Still display it in the dropdown
$formcourseformats[$course->format] = get_string('withdisablednote', 'moodle', get_string('pluginname', 'format_' . $course->format));
}
}
$mform->addElement('select', 'format', get_string('format'), $formcourseformats);
$mform->addHelpButton('format', 'format');
$mform->setDefault('format', $courseconfig->format);
// Button to update format-specific options on format change (will be hidden by JavaScript).
$mform->registerNoSubmitButton('updatecourseformat');
$mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
// Just a placeholder for the course format options.
$mform->addElement('hidden', 'addcourseformatoptionshere');
$mform->setType('addcourseformatoptionshere', PARAM_BOOL);
// Appearance.
$mform->addElement('header', 'appearancehdr', get_string('appearance'));
if (!empty($CFG->allowcoursethemes)) {
$themeobjects = get_list_of_themes();
$themes = array();
$themes[''] = get_string('forceno');
foreach ($themeobjects as $key => $theme) {
if (empty($theme->hidefromselector)) {
$themes[$key] = get_string('pluginname', 'theme_' . $theme->name);
}
}
示例4: admin_externalpage
// Speedup for non-admins, add all caps used on this page.
$ADMIN->add('courses', new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/management.php', array('moodle/category:manage', 'moodle/course:create')));
$ADMIN->add('courses', new admin_externalpage('addcategory', new lang_string('addcategory', 'admin'), new moodle_url('/course/editcategory.php', array('parent' => 0)), array('moodle/category:manage')));
$ADMIN->add('courses', new admin_externalpage('restorecourse', new lang_string('restorecourse', 'admin'), new moodle_url('/backup/restorefile.php', array('contextid' => context_system::instance()->id)), array('moodle/restore:restorecourse')));
// Course Default Settings Page.
// NOTE: these settings must be applied after all other settings because they depend on them.
// Main course settings.
$temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
require_once $CFG->dirroot . '/course/lib.php';
$choices = array();
$choices['0'] = new lang_string('hide');
$choices['1'] = new lang_string('show');
$temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'), 1, $choices));
// Course format.
$temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));
$courseformats = get_sorted_course_formats(true);
$formcourseformats = array();
foreach ($courseformats as $courseformat) {
$formcourseformats[$courseformat] = new lang_string('pluginname', "format_{$courseformat}");
}
$temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'), 'weeks', $formcourseformats));
$temp->add(new admin_setting_configtext('moodlecourse/maxsections', new lang_string('maxnumberweeks'), new lang_string('maxnumberweeks_desc'), 52));
$temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', new lang_string('numberweeks'), new lang_string('coursehelpnumberweeks'), 10));
$choices = array();
$choices['0'] = new lang_string('hiddensectionscollapsed');
$choices['1'] = new lang_string('hiddensectionsinvisible');
$temp->add(new admin_setting_configselect('moodlecourse/hiddensections', new lang_string('hiddensections'), new lang_string('coursehelphiddensections'), 0, $choices));
$choices = array();
$choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single');
$choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi');
$temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'), new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
示例5: definition
//.........这里部分代码省略.........
$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);
$mform->addHelpButton('summary_editor', 'coursesummary');
$mform->setType('summary_editor', PARAM_RAW);
$summaryfields = 'summary_editor';
if ($overviewfilesoptions = course_overviewfiles_options($course)) {
$mform->addElement('filemanager', 'overviewfiles_filemanager', get_string('courseoverviewfiles'), null, $overviewfilesoptions);
$mform->addHelpButton('overviewfiles_filemanager', 'courseoverviewfiles');
$summaryfields .= ',overviewfiles_filemanager';
}
if (!empty($course->id) and !has_capability('moodle/course:changesummary', $coursecontext)) {
// Remove the description header it does not contain anything any more.
$mform->removeElement('descriptionhdr');
$mform->hardFreeze($summaryfields);
}
// Course format.
$mform->addElement('header', 'courseformathdr', get_string('type_format', 'plugin'));
$courseformats = get_sorted_course_formats(true);
$formcourseformats = array();
foreach ($courseformats as $courseformat) {
$formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat");
}
if (isset($course->format)) {
$course->format = course_get_format($course)->get_format(); // replace with default if not found
if (!in_array($course->format, $courseformats)) {
// this format is disabled. Still display it in the dropdown
$formcourseformats[$course->format] = get_string('withdisablednote', 'moodle',
get_string('pluginname', 'format_'.$course->format));
}
}
$mform->addElement('select', 'format', get_string('format'), $formcourseformats);
$mform->addHelpButton('format', 'format');
$mform->setDefault('format', $courseconfig->format);
// Button to update format-specific options on format change (will be hidden by JavaScript).
$mform->registerNoSubmitButton('updatecourseformat');
$mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
// Just a placeholder for the course format options.
$mform->addElement('hidden', 'addcourseformatoptionshere');
$mform->setType('addcourseformatoptionshere', PARAM_BOOL);
// Appearance.
$mform->addElement('header', 'appearancehdr', get_string('appearance'));
if (!empty($CFG->allowcoursethemes)) {
$themeobjects = get_list_of_themes();
$themes=array();
$themes[''] = get_string('forceno');
示例6: get_format_or_default
/**
* Validates that course format exists and enabled and returns either itself or default format
*
* @param string $format
* @return string
*/
protected static final function get_format_or_default($format)
{
if (array_key_exists($format, self::$classesforformat)) {
return self::$classesforformat[$format];
}
$plugins = get_sorted_course_formats();
foreach ($plugins as $plugin) {
self::$classesforformat[$plugin] = $plugin;
}
if (array_key_exists($format, self::$classesforformat)) {
return self::$classesforformat[$format];
}
// Else return default format
$defaultformat = get_config('moodlecourse', 'format');
if (!in_array($defaultformat, $plugins)) {
// when default format is not set correctly, use the first available format
$defaultformat = reset($plugins);
}
debugging('Format plugin format_' . $format . ' is not found. Using default format_' . $defaultformat, DEBUG_DEVELOPER);
self::$classesforformat[$format] = $defaultformat;
return $defaultformat;
}
示例7: definition
/**
* The standard form definiton.
* @return void.
*/
public function definition()
{
global $CFG;
$mform = $this->_form;
$data = $this->_customdata['data'];
$courseconfig = get_config('moodlecourse');
// Import options.
$this->add_import_options();
// Course options.
$mform->addElement('header', 'courseoptionshdr', get_string('courseprocess', 'tool_uploadcourse'));
$mform->setExpanded('courseoptionshdr', true);
$mform->addElement('text', 'options[shortnametemplate]', get_string('shortnametemplate', 'tool_uploadcourse'), 'maxlength="100" size="20"');
$mform->setType('options[shortnametemplate]', PARAM_RAW);
$mform->addHelpButton('options[shortnametemplate]', 'shortnametemplate', 'tool_uploadcourse');
$mform->disabledIf('options[shortnametemplate]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE);
$mform->disabledIf('options[shortnametemplate]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_UPDATE_ONLY);
// Restore file is not in the array options on purpose, because formslib can't handle it!
$contextid = $this->_customdata['contextid'];
$mform->addElement('hidden', 'contextid', $contextid);
$mform->setType('contextid', PARAM_INT);
$mform->addElement('filepicker', 'restorefile', get_string('templatefile', 'tool_uploadcourse'));
$mform->addHelpButton('restorefile', 'templatefile', 'tool_uploadcourse');
$mform->addElement('text', 'options[templatecourse]', get_string('coursetemplatename', 'tool_uploadcourse'));
$mform->setType('options[templatecourse]', PARAM_TEXT);
$mform->addHelpButton('options[templatecourse]', 'coursetemplatename', 'tool_uploadcourse');
$mform->addElement('selectyesno', 'options[reset]', get_string('reset', 'tool_uploadcourse'));
$mform->setDefault('options[reset]', 0);
$mform->disabledIf('options[reset]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_NEW);
$mform->disabledIf('options[reset]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_ALL);
$mform->disabledIf('options[reset]', 'options[allowresets]', 'eq', 0);
$mform->addHelpButton('options[reset]', 'reset', 'tool_uploadcourse');
// Default values.
$mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'tool_uploadcourse'));
$mform->setExpanded('defaultheader', true);
$displaylist = coursecat::make_categories_list('moodle/course:create');
$mform->addElement('select', 'defaults[category]', get_string('coursecategory'), $displaylist);
$mform->addHelpButton('defaults[category]', 'coursecategory');
$choices = array();
$choices['0'] = get_string('hide');
$choices['1'] = get_string('show');
$mform->addElement('select', 'defaults[visible]', get_string('visible'), $choices);
$mform->addHelpButton('defaults[visible]', 'visible');
$mform->setDefault('defaults[visible]', $courseconfig->visible);
$mform->addElement('date_selector', 'defaults[startdate]', get_string('startdate'));
$mform->addHelpButton('defaults[startdate]', 'startdate');
$mform->setDefault('defaults[startdate]', time() + 3600 * 24);
$mform->addElement('date_selector', 'defaults[enddate]', get_string('enddate'), array('optional' => true));
$mform->addHelpButton('defaults[enddate]', 'enddate');
$courseformats = get_sorted_course_formats(true);
$formcourseformats = array();
foreach ($courseformats as $courseformat) {
$formcourseformats[$courseformat] = get_string('pluginname', "format_{$courseformat}");
}
$mform->addElement('select', 'defaults[format]', get_string('format'), $formcourseformats);
$mform->addHelpButton('defaults[format]', 'format');
$mform->setDefault('defaults[format]', $courseconfig->format);
if (!empty($CFG->allowcoursethemes)) {
$themeobjects = get_list_of_themes();
$themes = array();
$themes[''] = get_string('forceno');
foreach ($themeobjects as $key => $theme) {
if (empty($theme->hidefromselector)) {
$themes[$key] = get_string('pluginname', 'theme_' . $theme->name);
}
}
$mform->addElement('select', 'defaults[theme]', get_string('forcetheme'), $themes);
}
$languages = array();
$languages[''] = get_string('forceno');
$languages += get_string_manager()->get_list_of_translations();
$mform->addElement('select', 'defaults[lang]', get_string('forcelanguage'), $languages);
$mform->setDefault('defaults[lang]', $courseconfig->lang);
$options = range(0, 10);
$mform->addElement('select', 'defaults[newsitems]', get_string('newsitemsnumber'), $options);
$mform->addHelpButton('defaults[newsitems]', 'newsitemsnumber');
$mform->setDefault('defaults[newsitems]', $courseconfig->newsitems);
$mform->addElement('selectyesno', 'defaults[showgrades]', get_string('showgrades'));
$mform->addHelpButton('defaults[showgrades]', 'showgrades');
$mform->setDefault('defaults[showgrades]', $courseconfig->showgrades);
$mform->addElement('selectyesno', 'defaults[showreports]', get_string('showreports'));
$mform->addHelpButton('defaults[showreports]', 'showreports');
$mform->setDefault('defaults[showreports]', $courseconfig->showreports);
if (!empty($CFG->legacyfilesinnewcourses)) {
$mform->addElement('select', 'defaults[legacyfiles]', get_string('courselegacyfiles'), $choices);
$mform->addHelpButton('defaults[legacyfiles]', 'courselegacyfiles');
if (!isset($courseconfig->legacyfiles)) {
$courseconfig->legacyfiles = 0;
}
$mform->setDefault('defaults[legacyfiles]', $courseconfig->legacyfiles);
}
$choices = get_max_upload_sizes($CFG->maxbytes);
$mform->addElement('select', 'defaults[maxbytes]', get_string('maximumupload'), $choices);
$mform->addHelpButton('defaults[maxbytes]', 'maximumupload');
$mform->setDefault('defaults[maxbytes]', $courseconfig->maxbytes);
$choices = array();
$choices[NOGROUPS] = get_string('groupsnone', 'group');
//.........这里部分代码省略.........
示例8: get_format_or_default
/**
* Validates that course format exists and enabled and returns either itself or default format
*
* @param string $format
* @return string
*/
protected static final function get_format_or_default($format)
{
if ($format === 'site') {
return $format;
}
$plugins = get_sorted_course_formats();
if (in_array($format, $plugins)) {
return $format;
}
// Else return default format
$defaultformat = get_config('moodlecourse', 'format');
if (!in_array($defaultformat, $plugins)) {
// when default format is not set correctly, use the first available format
$defaultformat = reset($plugins);
}
static $warningprinted = array();
if (empty($warningprinted[$format])) {
debugging('Format plugin format_' . $format . ' is not found. Using default format_' . $defaultformat, DEBUG_DEVELOPER);
$warningprinted[$format] = true;
}
return $defaultformat;
}