From 1156d38d944bbcd514b01c90db8d1df2b69d8c23 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Mon, 23 Apr 2012 20:25:12 +0800 Subject: [PATCH] MDL-32504 course: Add coursedisplay setting to course table This will replace the course_display database table --- course/edit_form.php | 6 ++++++ course/lib.php | 3 +++ lang/en/moodle.php | 4 ++++ lib/db/install.xml | 7 ++++--- lib/db/upgrade.php | 15 +++++++++++++++ version.php | 2 +- 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/course/edit_form.php b/course/edit_form.php index 44ed742f86c..19d1f98a760 100644 --- a/course/edit_form.php +++ b/course/edit_form.php @@ -120,6 +120,12 @@ class course_edit_form extends moodleform { $mform->addHelpButton('format', 'format'); $mform->setDefault('format', $courseconfig->format); + $mform->addElement('select', 'coursedisplay', get_string('coursedisplay'), + array(COURSE_DISPLAY_SINGLEPAGE => get_string('coursedisplay_single'), + COURSE_DISPLAY_MULTIPAGE => get_string('coursedisplay_multi'))); + $mform->addHelpButton('coursedisplay', 'coursedisplay'); + $mform->setDefault('coursedisplay', COURSE_DISPLAY_SINGLEPAGE); + for ($i = 0; $i <= $courseconfig->maxsections; $i++) { $sectionmenu[$i] = "$i"; } diff --git a/course/lib.php b/course/lib.php index 05e486effaf..8f7d6351f3a 100644 --- a/course/lib.php +++ b/course/lib.php @@ -46,6 +46,9 @@ define('FIRSTUSEDEXCELROW', 3); define('MOD_CLASS_ACTIVITY', 0); define('MOD_CLASS_RESOURCE', 1); +define('COURSE_DISPLAY_SINGLEPAGE', 0); // display all sections on one page +define('COURSE_DISPLAY_MULTIPAGE', 1); // split pages into a page per section + function make_log_url($module, $url) { switch ($module) { case 'course': diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 618e6b15c72..c02c0a19608 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -291,6 +291,10 @@ $string['coursecompletion'] = 'Course completion'; $string['coursecompletions'] = 'Course completions'; $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. 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}'; $string['coursefiles'] = 'Legacy course files'; $string['coursefilesedit'] = 'Edit legacy course files'; diff --git a/lib/db/install.xml b/lib/db/install.xml index d75c80ffdf1..76d469ec3c2 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -100,7 +100,8 @@ - + + @@ -2832,4 +2833,4 @@ - \ No newline at end of file + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 0834ac484a0..c13712a668b 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -441,5 +441,20 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2012050300.02); } + if ($oldversion < 2012050300.03) { + + // Define field coursedisplay to be added to course + $table = new xmldb_table('course'); + $field = new xmldb_field('coursedisplay', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'completionnotify'); + + // Conditionally launch add field coursedisplay + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // Main savepoint reached + upgrade_main_savepoint(true, 2012050300.03); + } + return true; } diff --git a/version.php b/version.php index 2267ddd5ccf..607d106aec7 100644 --- a/version.php +++ b/version.php @@ -30,7 +30,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2012050300.02; // YYYYMMDD = weekly release date of this DEV branch +$version = 2012050300.03; // YYYYMMDD = weekly release date of this DEV branch // RR = release increments - 00 in DEV branches // .XX = incremental changes