From 680018c95d73845335ad24a70d34ebbfb5527d54 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Mon, 8 Mar 2021 20:46:52 +0800 Subject: [PATCH] MDL-70782 course: add setting to show activity dates Part of MDL-70817 --- admin/settings/courses.php | 7 +++++++ course/edit_form.php | 5 +++++ lang/en/moodle.php | 2 ++ lib/db/install.xml | 1 + lib/db/upgrade.php | 14 ++++++++++++++ version.php | 2 +- 6 files changed, 30 insertions(+), 1 deletion(-) diff --git a/admin/settings/courses.php b/admin/settings/courses.php index c0da1aa113b..c6fce346ff2 100644 --- a/admin/settings/courses.php +++ b/admin/settings/courses.php @@ -139,6 +139,13 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { new lang_string('coursehelpshowgrades'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes')))); $temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0, array(0 => new lang_string('no'), 1 => new lang_string('yes')))); + $temp->add(new admin_setting_configselect('moodlecourse/showactivitydates', + new lang_string('showactivitydates'), + new lang_string('showactivitydates_help'), 1, [ + 0 => new lang_string('no'), + 1 => new lang_string('yes') + ] + )); // Files and uploads. $temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), '')); diff --git a/course/edit_form.php b/course/edit_form.php index 9e7773dbd6e..399ea7a6ff8 100644 --- a/course/edit_form.php +++ b/course/edit_form.php @@ -278,6 +278,11 @@ class course_edit_form extends moodleform { $mform->addHelpButton('showreports', 'showreports'); $mform->setDefault('showreports', $courseconfig->showreports); + // Show activity dates. + $mform->addElement('selectyesno', 'showactivitydates', get_string('showactivitydates')); + $mform->addHelpButton('showactivitydates', 'showactivitydates'); + $mform->setDefault('showactivitydates', $courseconfig->showactivitydates); + // Files and uploads. $mform->addElement('header', 'filehdr', get_string('filesanduploads')); diff --git a/lang/en/moodle.php b/lang/en/moodle.php index ef3cdfd1d7a..1090198974a 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1907,6 +1907,8 @@ $string['shortnameuser'] = 'User short name'; $string['shortsitename'] = 'Short name for site (eg single word)'; $string['show'] = 'Show'; $string['showactions'] = 'Show actions'; +$string['showactivitydates'] = 'Show activity dates'; +$string['showactivitydates_help'] = 'The activity dates are displayed in the list of activities on the course page.'; $string['showadvancededitor'] = 'Advanced'; $string['showadvancedsettings'] = 'Show advanced settings'; $string['showall'] = 'Show all {$a}'; diff --git a/lib/db/install.xml b/lib/db/install.xml index 372d962907b..01a1fcd1157 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -103,6 +103,7 @@ + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 7fc56aa1700..792ecc8eeda 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2517,5 +2517,19 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2021052500.69); } + if ($oldversion < 2021052500.74) { + // Define field 'showactivitydates' to be added to course table. + $table = new xmldb_table('course'); + $field = new xmldb_field('showactivitydates', XMLDB_TYPE_INTEGER, '1', null, + XMLDB_NOTNULL, null, '0', 'originalcourseid'); + + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2021052500.74); + } + return true; } diff --git a/version.php b/version.php index 6797a5a73f8..2d0aa19bea6 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2021052500.73; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2021052500.74; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '4.0dev (Build: 20210330)'; // Human-friendly version name