Skip to content

Commit

Permalink
Revert "MDL-35260 Course formats may have settings, be enabled, disab…
Browse files Browse the repository at this point in the history
…led and uninstalled"

This reverts commit 45f93db.
This reverts commit 3f798d4.
  • Loading branch information
danpoltawski committed Nov 5, 2012
1 parent c296ab7 commit 918085d
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 433 deletions.
131 changes: 0 additions & 131 deletions admin/courseformats.php

This file was deleted.

5 changes: 2 additions & 3 deletions admin/settings/courses.php
Expand Up @@ -15,10 +15,9 @@
/// 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');
$courseformats = get_sorted_course_formats(true);
$courseformats = get_plugin_list('format');
$formcourseformats = array();
foreach ($courseformats as $courseformat) {
foreach ($courseformats as $courseformat => $courseformatdir) {
$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));
Expand Down
9 changes: 0 additions & 9 deletions admin/settings/plugins.php
Expand Up @@ -20,15 +20,6 @@
// hidden script for converting journals to online assignments (or something like that) linked from elsewhere
$ADMIN->add('modsettings', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));

// course formats
$ADMIN->add('modules', new admin_category('formatsettings', new lang_string('courseformats')));
$temp = new admin_settingpage('manageformats', new lang_string('manageformats', 'core_admin'));
$temp->add(new admin_setting_manageformats());
$ADMIN->add('formatsettings', $temp);
foreach ($allplugins['format'] as $format) {
$format->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
}

// blocks
$ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
$ADMIN->add('blocksettings', new admin_page_manageblocks());
Expand Down
13 changes: 2 additions & 11 deletions course/edit_form.php
Expand Up @@ -113,20 +113,11 @@ function definition() {
$mform->hardFreeze('summary_editor');
}

$courseformats = get_sorted_course_formats(true);
$courseformats = get_plugin_list('format');
$formcourseformats = array();
foreach ($courseformats as $courseformat) {
foreach ($courseformats as $courseformat => $formatdir) {
$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);
Expand Down
18 changes: 3 additions & 15 deletions course/format/formatlegacy.php
Expand Up @@ -329,21 +329,9 @@ public function update_course_format_options($data, $oldcourse = null) {
if ($oldcourse !== null) {
$data = (array)$data;
$oldcourse = (array)$oldcourse;
$options = $this->course_format_options();
foreach ($options as $key => $unused) {
if (!array_key_exists($key, $data)) {
if (array_key_exists($key, $oldcourse)) {
$data[$key] = $oldcourse[$key];
} else if ($key === 'numsections') {
// If previous format does not have the field 'numsections' and this one does,
// and $data['numsections'] is not set fill it with the maximum section number from the DB
$maxsection = $DB->get_field_sql('SELECT max(section) from {course_sections}
WHERE course = ?', array($this->courseid));
if ($maxsection) {
// If there are no sections, or just default 0-section, 'numsections' will be set to default
$data['numsections'] = $maxsection;
}
}
foreach ($this->course_format_options() as $key => $unused) {
if (array_key_exists($key, $oldcourse) && !array_key_exists($key, $data)) {
$data[$key] = $oldcourse[$key];
}
}
}
Expand Down
16 changes: 4 additions & 12 deletions course/format/lib.php
Expand Up @@ -97,21 +97,13 @@ protected static final function get_format_or_default($format) {
if ($format === 'site') {
return $format;
}
$plugins = get_sorted_course_formats();
if (in_array($format, $plugins)) {
$plugins = get_plugin_list('format'); // TODO MDL-35260 filter only enabled
if (isset($plugins[$format])) {
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;
}
$defaultformat = reset($plugins); // TODO MDL-35260 get default format from config
debugging('Format plugin format_'.$format.' is not found or is not enabled. Using default format_'.$defaultformat, DEBUG_DEVELOPER);
return $defaultformat;
}

Expand Down
1 change: 0 additions & 1 deletion course/format/upgrade.txt
Expand Up @@ -12,7 +12,6 @@ format.
functions callback_XXXX_request_key() are no longer used (where XXXX is the course format name)
* functions get_generic_section_name(), get_all_sections(), add_mod_to_section(), get_all_mods()
are deprecated. See their phpdocs in lib/deprecatedlib.php on how to replace them
* Course formats may now have their settings.php file as the most of other plugin types

=== 2.3 ===

Expand Down
29 changes: 0 additions & 29 deletions course/lib.php
Expand Up @@ -4511,35 +4511,6 @@ function include_course_ajax($course, $usedmodules = array(), $enabledmodules =
return true;
}

/**
* Returns the sorted list of available course formats, filtered by enabled if necessary
*
* @param bool $enabledonly return only formats that are enabled
* @return array array of sorted format names
*/
function get_sorted_course_formats($enabledonly = false) {
global $CFG;
$formats = get_plugin_list('format');

$sortorderstr = '';
if (isset($CFG->format_plugins_sortorder)) {
$sortorderstr = $CFG->format_plugins_sortorder;
}
$order = explode(',', $sortorderstr);
$order = array_merge(array_intersect($order, array_keys($formats)),
array_diff(array_keys($formats), $order));
if ($sortorderstr !== join(',', $order)) {
set_config('format_plugins_sortorder', join(',', $order));
}
$sortedformats = array();
foreach ($order as $formatname) {
if (!$enabledonly || !get_config('format_'.$formatname, 'disabled')) {
$sortedformats[] = $formatname;
}
}
return $sortedformats;
}

/**
* The URL to use for the specified course (with section)
*
Expand Down
7 changes: 0 additions & 7 deletions lang/en/admin.php
Expand Up @@ -95,7 +95,6 @@
$string['calendarsettings'] = 'Calendar';
$string['calendar_weekend'] = 'Weekend days';
$string['cannotdeletemodfilter'] = 'You cannot uninstall the \'{$a->filter}\' because it is part of the \'{$a->module}\' module.';
$string['cannotuninstall'] = '{$a} can not be uninstalled.';
$string['cfgwwwrootslashwarning'] = 'You have defined $CFG->wwwroot incorrectly in your config.php file. You have included a \'/\' character at the end. Please remove it, or you will experience strange bugs like <a href=\'http://tracker.moodle.org/browse/MDL-11061\'>MDL-11061</a>.';
$string['cfgwwwrootwarning'] = 'You have defined $CFG->wwwroot incorrectly in your config.php file. It does not match the URL you are using to access this page. Please correct it, or you will experience strange bugs like <a href=\'http://tracker.moodle.org/browse/MDL-11061\'>MDL-11061</a>.';
$string['clamfailureonupload'] = 'On clam AV failure';
Expand Down Expand Up @@ -417,7 +416,6 @@
$string['debugvalidators'] = 'Show validator links';
$string['defaultcity'] = 'Default city';
$string['defaultcity_help'] = 'A city entered here will be the default city when creating new user accounts.';
$string['defaultformatnotset'] = 'Error determining default course format. Please check site settings.';
$string['defaulthomepage'] = 'Default home page for users';
$string['defaultrequestcategory'] = 'Default category for course requests';
$string['defaultsettinginfo'] = 'Default: {$a}';
Expand Down Expand Up @@ -534,9 +532,6 @@
$string['forceloginforprofileimage_help'] = 'If enabled, users must login in order to view user profile pictures and the default user picture will be used in all notification emails.';
$string['forceloginforprofiles'] = 'Force users to login for profiles';
$string['forcetimezone'] = 'Force default timezone';
$string['formatuninstallwithcourses'] = 'There are {$a->count} courses using {$a->format}. Their format will be changed to {$a->defaultformat} (default format for this site). Some format-specific data may be lost. Are you sure you want to proceed?';
$string['formatuninstallconfirm'] = '{$a} will be uninstalled. No courses currently use it. Continue?';
$string['formatuninstalled'] = 'All data associated with the format plugin \'{$a->plugin}\' has been deleted from the database. To complete the deletion (and prevent the plugin re-installing itself), you should now delete this directory from your server: {$a->directory}';
$string['frontpage'] = 'Front page';
$string['frontpagebackup'] = 'Front page backup';
$string['frontpagedefaultrole'] = 'Default frontpage role';
Expand Down Expand Up @@ -645,8 +640,6 @@
$string['maintenancemode'] = 'In maintenance mode';
$string['maintfileopenerror'] = 'Error opening maintenance files!';
$string['maintinprogress'] = 'Maintenance is in progress...';
$string['manageformats'] = 'Manage course formats';
$string['manageformatsgotosettings'] = 'Default format can be changed in {$a}';
$string['managelang'] = 'Manage';
$string['managelicenses'] = 'Manage licences';
$string['manageqbehaviours'] = 'Manage question behaviours';
Expand Down
3 changes: 1 addition & 2 deletions lang/en/error.php
Expand Up @@ -65,7 +65,6 @@
$string['cannotdeleterole'] = 'It cannot be deleted, because {$a}';
$string['cannotdeleterolewithid'] = 'Could not delete role with ID {$a}';
$string['cannotdeletethisrole'] = 'You cannot delete this role because it is used by the system, or because it is the last role with administrator capabilities.';
$string['cannotdisableformat'] = 'You can not disable the default format';
$string['cannotdownloadcomponents'] = 'Cannot download components';
$string['cannotdownloadlanguageupdatelist'] = 'Cannot download list of language updates from download.moodle.org';
$string['cannotdownloadzipfile'] = 'Cannot download ZIP file';
Expand Down Expand Up @@ -543,4 +542,4 @@
$string['xmldberror'] = 'XMLDB error!';
$string['alreadyloggedin'] = 'You are already logged in as {$a}, you need to log out before logging in as different user.';
$string['youcannotdeletecategory'] = 'You cannot delete category \'{$a}\' because you can neither delete the contents, nor move them elsewhere.';
$string['protected_cc_not_supported'] = 'Protected cartridges not supported.';
$string['protected_cc_not_supported'] = 'Protected cartridges not supported.';
3 changes: 1 addition & 2 deletions lang/en/moodle.php
Expand Up @@ -297,7 +297,7 @@
$string['coursecreators'] = 'Course creator';
$string['coursecreatorsdescription'] = 'Course creators can create new courses.';
$string['coursedisplay'] = 'Course layout';
$string['coursedisplay_help'] = 'This setting determines whether the whole course is displayed on one page or split over several pages.';
$string['coursedisplay_help'] = 'This setting determines whether the whole course is displayed on one page or split over several pages. The setting has no affect on certain course formats, such as SCORM format.';
$string['coursedisplay_single'] = 'Show all sections on one page';
$string['coursedisplay_multi'] = 'Show one section per page';
$string['coursedeleted'] = 'Deleted course {$a}';
Expand Down Expand Up @@ -1802,7 +1802,6 @@
$string['whattodo'] = 'What to do';
$string['windowclosing'] = 'This window should close automatically. If not, please close it now.';
$string['withchosenfiles'] = 'With chosen files';
$string['withdisablednote'] = '{$a} (disabled)';
$string['withoutuserdata'] = 'without user data';
$string['withselectedusers'] = 'With selected users...';
$string['withselectedusers_help'] = '* Send message - For sending a message to one or more participants
Expand Down

0 comments on commit 918085d

Please sign in to comment.