diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index cc862c2..7757aaf 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,16 +8,22 @@ jobs:
fail-fast: false
matrix:
include:
- - php: '7.4'
- moodle-branch: 'master'
+ - php: '8.3'
+ moodle-branch: 'main'
database: 'pgsql'
- - php: '7.4'
- moodle-branch: 'MOODLE_311_STABLE'
+ - php: '8.3'
+ moodle-branch: 'MOODLE_500_STABLE'
+ database: 'mariadb'
+ - php: '8.2'
+ moodle-branch: 'MOODLE_405_STABLE'
+ database: 'pgsql'
+ - php: '8.2'
+ moodle-branch: 'MOODLE_404_STABLE'
database: 'mariadb'
services:
postgres:
- image: postgres
+ image: postgres:14
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
@@ -30,34 +36,37 @@ jobs:
- 5432:5432
mariadb:
- image: mariadb
+ image: mariadb:10
env:
MYSQL_USER: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
+ MYSQL_CHARACTER_SET_SERVER: "utf8mb4"
+ MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3
steps:
- - name: Checkout
+ - name: Checkout repository code
uses: actions/checkout@v2
with:
path: plugin
- - name: Setup PHP
+ - name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- extensions: mbstring, pgsql, mysqli
+ extensions: ${{ matrix.extensions }}
+ ini-values: max_input_vars=5000
+ coverage: none
- - name: Deploy moodle-plugin-ci
+ - name: Initialise moodle-plugin-ci
run: |
- composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
- # Add dirs to $PATH
+ composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
- # PHPUnit depends on en_AU.UTF-8 locale
sudo locale-gen en_AU.UTF-8
+ echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
- name: Install Moodle
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
@@ -65,42 +74,47 @@ jobs:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
- - name: phplint
+ - name: PHP Lint
if: ${{ always() }}
run: moodle-plugin-ci phplint
- - name: phpcpd
+ - name: PHP Copy/Paste Detector
+ continue-on-error: true # This step will show errors but will not fail.
if: ${{ always() }}
- run: moodle-plugin-ci phpcpd || true
+ run: moodle-plugin-ci phpcpd
- - name: phpmd
+ - name: PHP Mess Detector
if: ${{ always() }}
run: moodle-plugin-ci phpmd
- - name: codechecker
+ - name: Moodle Code Checker
if: ${{ always() }}
- run: moodle-plugin-ci codechecker
+ run: moodle-plugin-ci codechecker --max-warnings 0
- - name: validate
+ - name: Moodle PHPDoc Checker
+ if: ${{ always() }}
+ run: moodle-plugin-ci phpdoc
+
+ - name: Validating
if: ${{ always() }}
run: moodle-plugin-ci validate
- - name: savepoints
+ - name: Check upgrade savepoints
if: ${{ always() }}
run: moodle-plugin-ci savepoints
- - name: mustache
+ - name: Mustache Lint
+ continue-on-error: true # We are getting a false positive due to MDLSITE-6744 so ignore.
if: ${{ always() }}
run: moodle-plugin-ci mustache
- - name: grunt
- if: ${{ always() }}
- run: moodle-plugin-ci grunt
+ - name: Grunt
+ run: moodle-plugin-ci grunt --max-lint-warnings 4
- - name: phpunit
+ - name: PHPUnit tests
if: ${{ always() }}
- run: moodle-plugin-ci phpunit
+ run: moodle-plugin-ci phpunit --fail-on-warning
- - name: behat
+ - name: Behat features
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome
diff --git a/blocks/example.php b/blocks/example.php
index cffda09..4e0d445 100644
--- a/blocks/example.php
+++ b/blocks/example.php
@@ -25,11 +25,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
-
-
/**
- * Example {@link report_editdates_block_date_extractor} subclass.
+ * Example {@see report_editdates_block_date_extractor} subclass.
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -45,20 +42,24 @@ public function __construct($course) {
parent::load_data();
}
+ #[\Override]
public function get_settings(block_base $block) {
// Check if title text is a valid date then return the array.
$title = $block->title;
if ((string) (int) $title === $title) {
- return array('title' => new report_editdates_date_setting
- (get_string('availabledate', 'assignment'),
- $block->title,
- self::DATETIME, false, 5)
- );
+ return [
+ 'title' => new report_editdates_date_setting(
+ get_string('availabledate', 'assignment'),
+ $block->title,
+ self::DATETIME, false, 5
+ ),
+ ];
}
}
+ #[\Override]
public function validate_dates(block_base $block, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['title'] == 0 ) {
$errors['title'] = get_string('datemustnotzero', 'report_editdates');
}
diff --git a/changes.md b/changes.md
index b032b20..4ffd1d6 100644
--- a/changes.md
+++ b/changes.md
@@ -1,5 +1,13 @@
# Change log for the Edit dates report
+## Changes in 3.1
+
+* This version is compatible with Moodle 5.0.
+* Updated automated tests to support newer Moodle versions.
+* Fixed coding style issues.
+* Log events: removed legacy logging methods for compatibility with Moodle 4.2.
+* Removed references to mod_assignment, which was deprecated and removed from core in Moodle 4.2.
+
## Changes in 3.0
* This version works with Moodle 4.0.
diff --git a/classes/event/report_viewed.php b/classes/event/report_viewed.php
index 0181a89..e29fdd2 100644
--- a/classes/event/report_viewed.php
+++ b/classes/event/report_viewed.php
@@ -23,8 +23,6 @@
namespace report_editdates\event;
-defined('MOODLE_INTERNAL') || die();
-
/**
*
* @package report_editdates
@@ -72,30 +70,10 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
- $params = array('id' => $this->courseid);
+ $params = ['id' => $this->courseid];
if ($this->other['activitytype']) {
$params['activitytype'] = $this->other['activitytype'];
}
return new \moodle_url('/report/editdates/index.php', $params);
}
-
- public static function get_legacy_eventname() {
- return 'report edit dates';
- }
-
- /**
- * Return the legacy event log data.
- *
- * @return array|null
- */
- protected function get_legacy_logdata() {
- return array(
- $this->courseid,
- "course",
- "report edit dates",
- "report/editdates/index.php?id={$this->courseid}",
- $this->contextinstanceid
- );
- }
-
}
diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php
index 220ef15..b4d8d10 100644
--- a/classes/privacy/provider.php
+++ b/classes/privacy/provider.php
@@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+
/**
* Privacy Subsystem implementation for report_editdates.
*
@@ -21,7 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace report_editdates\privacy;
-defined('MOODLE_INTERNAL') || die();
+
/**
* Privacy Subsystem for report_editdates implementing null_provider.
*
@@ -33,9 +34,9 @@ class provider implements \core_privacy\local\metadata\null_provider {
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
- * @return string
+ * @return string
*/
- public static function get_reason() : string {
+ public static function get_reason(): string {
return 'privacy:metadata';
}
}
diff --git a/db/access.php b/db/access.php
index b8bd723..cb33e0f 100644
--- a/db/access.php
+++ b/db/access.php
@@ -24,15 +24,15 @@
defined('MOODLE_INTERNAL') || die;
-$capabilities = array(
- 'report/editdates:view' => array(
+$capabilities = [
+ 'report/editdates:view' => [
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
- 'archetypes' => array(
+ 'archetypes' => [
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- ),
+ 'manager' => CAP_ALLOW,
+ ],
'clonepermissionsfrom' => 'moodle/site:viewreports',
- )
-);
+ ],
+];
diff --git a/db/install.php b/db/install.php
index 7eaf9ed..a2353c6 100644
--- a/db/install.php
+++ b/db/install.php
@@ -21,9 +21,6 @@
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-
-defined('MOODLE_INTERNAL') || die;
-
function xmldb_report_editdates_install() {
global $DB;
@@ -32,10 +29,10 @@ function xmldb_report_editdates_install() {
// and clone the permissions from moodle/site:viewreports, but if we are upgrading
// a Moodle that had the old course report plugin installed, then we get rid of the
// new cloned capabilities, and transfer the old permissions.
- if ($DB->record_exists('role_capabilities', array('capability' => 'coursereport/editdates:view'))) {
- $DB->delete_records('role_capabilities', array('capability' => 'report/editdates:view'));
+ if ($DB->record_exists('role_capabilities', ['capability' => 'coursereport/editdates:view'])) {
+ $DB->delete_records('role_capabilities', ['capability' => 'report/editdates:view']);
$DB->set_field('role_capabilities', 'capability', 'report/editdates:view',
- array('capability' => 'coursereport/editdates:view'));
+ ['capability' => 'coursereport/editdates:view']);
}
// This is a hack which is needed for cleanup of original coursereport_completion stuff.
@@ -44,6 +41,6 @@ function xmldb_report_editdates_install() {
// Update existing block page patterns.
$DB->set_field('block_instances', 'pagetypepattern', 'report-editdates-index',
- array('pagetypepattern' => 'course-report-editdates-index'));
+ ['pagetypepattern' => 'course-report-editdates-index']);
}
diff --git a/form.php b/form.php
index aa6a258..30c6c47 100644
--- a/form.php
+++ b/form.php
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-
/**
* This is form to display the modules for editdates reports
*
@@ -36,9 +35,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class report_editdates_form extends moodleform {
- /**
- * @see lib/moodleform#definition()
- */
+
+ #[\Override]
public function definition() {
global $CFG, $DB, $PAGE;
$mform = $this->_form;
@@ -73,7 +71,7 @@ public function definition() {
$mform->addHelpButton('coursestartdate', 'startdate');
$mform->setDefault('coursestartdate', $course->startdate);
- $mform->addElement('date_time_selector', 'courseenddate', get_string('enddate'), array('optional' => true));
+ $mform->addElement('date_time_selector', 'courseenddate', get_string('enddate'), ['optional' => true]);
$mform->addHelpButton('courseenddate', 'enddate');
$mform->setDefault('courseenddate', $course->enddate);
@@ -95,7 +93,7 @@ public function definition() {
// Cycle through all the sections in the course.
$cms = $modinfo->get_cms();
$sections = $modinfo->get_section_info_all();
- $timeline = array();
+ $timeline = [];
foreach ($sections as $sectionnum => $section) {
$ismodadded = false;
$sectionname = '';
@@ -115,35 +113,49 @@ public function definition() {
}
if ($sectionnum > 0 && $coursehasavailability) {
- $editsettingurl = new moodle_url('/course/editsection.php', array('id' => $section->id));
+ $editsettingurl = new moodle_url('/course/editsection.php', ['id' => $section->id]);
if ($section->availability) {
// If there are retricted access date settings.
if (strpos($section->availability, '"type":"date"') !== false) {
- $editsettingurltext = html_writer::tag('a',
- get_string('editrestrictedaccess', 'report_editdates'),
- array('href' => $editsettingurl->out(false),
- 'target' => '_blank',
- 'class' => 'editdates_highlight'));
+ $editsettingurltext = html_writer::tag(
+ 'a',
+ get_string('editrestrictedaccess', 'report_editdates'),
+ [
+ 'href' => $editsettingurl->out(false),
+ 'target' => '_blank',
+ 'class' => 'editdates_highlight',
+ ]
+ );
$mform->addElement('static', '',
get_string('hasrestrictedaccess', 'report_editdates', ($sectionname)),
$editsettingurltext);
- $iconmarkup = html_writer::tag('i', '', array('class' => 'icon fa fa-folder-open',
- 'style' => 'margin: 4px;'));
- $timeline['section'.$sectionnum] = array('type' => 'section',
- 'name' => $sectionname,
- 'icon' => $iconmarkup,
- 'url' => $editsettingurl,
- 'restrict' => $section->availability,
- 'color' => 'rgb(' . mt_rand( 0, 255 ) . ',' .
- mt_rand( 0, 255 ) . ',' .
- mt_rand( 0, 255 ) . ', .5)'
- );
+ $iconmarkup = html_writer::tag(
+ 'i',
+ '',
+ [
+ 'class' => 'icon fa fa-folder-open',
+ 'style' => 'margin: 4px;',
+ ]
+ );
+ $timeline['section'.$sectionnum] = [
+ 'type' => 'section',
+ 'name' => $sectionname,
+ 'icon' => $iconmarkup,
+ 'url' => $editsettingurl,
+ 'restrict' => $section->availability,
+ 'color' => 'rgb(' . mt_rand( 0, 255 ) . ',' .
+ mt_rand( 0, 255 ) . ',' . mt_rand( 0, 255 ) . ', .5)',
+ ];
}
} else {
- $editsettingurltext = html_writer::tag('a',
- get_string('addrestrictedaccess', 'report_editdates', ($sectionname)),
- array('href' => $editsettingurl->out(false),
- 'target' => '_blank'));
+ $editsettingurltext = html_writer::tag(
+ 'a',
+ get_string('addrestrictedaccess', 'report_editdates', ($sectionname)),
+ [
+ 'href' => $editsettingurl->out(false),
+ 'target' => '_blank',
+ ]
+ );
$mform->addElement('static', '',
get_string('norestrictedaccess', 'report_editdates', ($sectionname)),
$editsettingurltext);
@@ -170,19 +182,20 @@ public function definition() {
$ismodreadonly = !has_capability('moodle/course:manageactivities', $modulecontext);
// Display activity name.
- $iconmarkup = html_writer::empty_tag('img', array(
- 'src' => $cm->get_icon_url(), 'class' => 'activityicon', 'alt' => ''));
+ $iconmarkup = html_writer::empty_tag('img', [
+ 'src' => $cm->get_icon_url(), 'class' => 'activityicon', 'alt' => '']);
$stractivityname = html_writer::tag('strong' , $iconmarkup . ' ' . $cm->name . '
');
$mform->addElement('html', $stractivityname);
$isdateadded = false;
- $timeline[$cm->id] = array('type' => $cm->modname,
- 'name' => $cm->name,
- 'icon' => $iconmarkup,
- 'url' => new moodle_url('/course/modedit.php', array('update' => $cm->id)),
- 'color' => 'rgb(' . mt_rand( 0, 255 ) . ',' .
- mt_rand( 0, 255 ) . ',' .
- mt_rand( 0, 255 ) . ', .5)'
- );
+ $timeline[$cm->id] = [
+ 'type' => $cm->modname,
+ 'name' => $cm->name,
+ 'icon' => $iconmarkup,
+ 'url' => new moodle_url('/course/modedit.php', ['update' => $cm->id]),
+ 'color' => 'rgb(' . mt_rand( 0, 255 ) . ',' .
+ mt_rand( 0, 255 ) . ',' .
+ mt_rand( 0, 255 ) . ', .5)',
+ ];
// Call get_settings method for the acitivity/module.
// Get instance of the mod's date exractor class.
@@ -192,12 +205,16 @@ public function definition() {
foreach ($cmdatesettings as $cmdatetype => $cmdatesetting) {
$elname = 'date_mod_'.$cm->id.'_'.$cmdatetype;
$mform->addElement($cmdatesetting->type, $elname,
- $cmdatesetting->label, array(
+ $cmdatesetting->label, [
'optional' => $cmdatesetting->isoptional,
- 'step' => $cmdatesetting->getstep));
+ 'step' => $cmdatesetting->getstep]);
$mform->setDefault($elname, $cmdatesetting->currentvalue);
- $timeline[$cm->id] = array_merge($timeline[$cm->id],
- array($cmdatesetting->label => $cmdatesetting->currentvalue));
+ $timeline[$cm->id] = array_merge(
+ $timeline[$cm->id],
+ [
+ $cmdatesetting->label => $cmdatesetting->currentvalue,
+ ]
+ );
if ($ismodreadonly) {
$mform->hardFreeze($elname);
}
@@ -211,12 +228,17 @@ public function definition() {
if ($coursehascompletion && isset($cm->completionexpected)) {
$elname = 'date_mod_'.$cm->id.'_completionexpected';
$mform->addElement('date_time_selector', $elname,
- get_string('completionexpected', 'completion'),
- array('optional' => true));
+ get_string('completionexpected', 'completion'),
+ ['optional' => true]
+ );
$mform->addHelpButton($elname, 'completionexpected', 'completion');
$mform->setDefault($elname, $cm->completionexpected);
- $timeline[$cm->id] = array_merge($timeline[$cm->id],
- array('completionexpected' => $cm->completionexpected));
+ $timeline[$cm->id] = array_merge(
+ $timeline[$cm->id],
+ [
+ 'completionexpected' => $cm->completionexpected,
+ ]
+ );
if ($ismodreadonly) {
$mform->hardFreeze($elname);
}
@@ -229,22 +251,28 @@ public function definition() {
if ($cm->availability) {
// If there are retricted access date settings.
if (strpos($cm->availability, '"type":"date"') !== false) {
- $timeline[$cm->id] = array_merge($timeline[$cm->id], array('restrict' => $cm->availability));
- $editsettingurl = new moodle_url('/course/modedit.php', array('update' => $cm->id));
- $editsettingurltext = html_writer::tag('a',
- get_string('editrestrictedaccess', 'report_editdates'),
- array('href' => $editsettingurl->out(false),
- 'target' => '_blank',
- 'class' => 'editdates_highlight'));
+ $timeline[$cm->id] = array_merge($timeline[$cm->id], ['restrict' => $cm->availability]);
+ $editsettingurl = new moodle_url('/course/modedit.php', ['update' => $cm->id]);
+ $editsettingurltext = html_writer::tag(
+ 'a',
+ get_string('editrestrictedaccess', 'report_editdates'),
+ [
+ 'href' => $editsettingurl->out(false),
+ 'target' => '_blank',
+ 'class' => 'editdates_highlight',
+ ]
+ );
$mform->addElement('static', '',
get_string('hasrestrictedaccess', 'report_editdates', ($cm->name)),
$editsettingurltext);
}
} else {
- $editsettingurl = new moodle_url('/course/modedit.php', array('update' => $cm->id));
- $editsettingurltext = html_writer::tag('a',
- get_string('addrestrictedaccess', 'report_editdates'),
- array('href' => $editsettingurl->out(false), 'target' => '_blank'));
+ $editsettingurl = new moodle_url('/course/modedit.php', ['update' => $cm->id]);
+ $editsettingurltext = html_writer::tag(
+ 'a',
+ get_string('addrestrictedaccess', 'report_editdates'),
+ ['href' => $editsettingurl->out(false), 'target' => '_blank']
+ );
if ($isdateadded) {
$mform->addElement('static', 'modrestrict' . $cm->id,
get_string('norestrictedaccess', 'report_editdates', ($cm->name)),
@@ -264,7 +292,7 @@ public function definition() {
// Fetching all the blocks added directly under the course.
// That is, parentcontextid = coursecontextid.
- $courseblocks = $DB->get_records('block_instances', array('parentcontextid' => $coursecontext->id));
+ $courseblocks = $DB->get_records('block_instances', ['parentcontextid' => $coursecontext->id]);
// Check capability of current user.
$canmanagesiteblocks = has_capability('moodle/site:manageblocks', $coursecontext);
@@ -289,10 +317,15 @@ public function definition() {
foreach ($blockdatesettings as $blockdatetype => $blockdatesetting) {
$elname = 'date_block_'.$block->id.'_'.$blockdatetype;
// Add element.
- $mform->addElement($blockdatesetting->type, $elname,
- $blockdatesetting->label,
- array('optional' => $blockdatesetting->isoptional,
- 'step' => $blockdatesetting->getstep));
+ $mform->addElement(
+ $blockdatesetting->type,
+ $elname,
+ $blockdatesetting->label,
+ [
+ 'optional' => $blockdatesetting->isoptional,
+ 'step' => $blockdatesetting->getstep,
+ ]
+ );
$mform->setDefault($elname, $blockdatesetting->currentvalue);
if (!$canmanagesiteblocks || !$blockobj->user_can_edit()) {
$mform->hardFreeze($elname);
@@ -323,6 +356,7 @@ public function definition() {
}
}
+ #[\Override]
public function validation($data, $files) {
global $CFG;
$errors = parent::validation($data, $files);
@@ -331,8 +365,8 @@ public function validation($data, $files) {
$course = $this->_customdata['course'];
$coursecontext = context_course::instance($course->id);
- $moddatesettings = array();
- $forceddatesettings = array();
+ $moddatesettings = [];
+ $forceddatesettings = [];
foreach ($data as $key => $value) {
if ($key == "coursestartdate") {
continue;
@@ -355,7 +389,7 @@ public function validation($data, $files) {
// Check if config date settings are forced
// and this is one of the forced date setting.
if (($CFG->enableavailability || $CFG->enablecompletion )
- && in_array($cmsettings['3'], array('completionexpected', 'availablefrom', 'availableuntil'))) {
+ && in_array($cmsettings['3'], ['completionexpected', 'availablefrom', 'availableuntil'])) {
$forceddatesettings[$cmsettings['2']][$cmsettings['3']] = $value;
} else {
// It is module date setting.
@@ -371,7 +405,7 @@ public function validation($data, $files) {
foreach ($forceddatesettings as $modid => $datesettings) {
// Course module object.
$cm = $cms[$modid];
- $moderrors = array();
+ $moderrors = [];
if (isset($datesettings['availablefrom']) && isset($datesettings['availableuntil'])
&& $datesettings['availablefrom'] != 0 && $datesettings['availableuntil'] != 0
&& $datesettings['availablefrom'] > $datesettings['availableuntil'] ) {
@@ -384,7 +418,7 @@ public function validation($data, $files) {
foreach ($moddatesettings as $modid => $datesettings) {
// Course module object.
$cm = $cms[$modid];
- $moderrors = array();
+ $moderrors = [];
if ($mod = report_editdates_mod_date_extractor::make($cm->modname, $course)) {
$moderrors = $mod->validate_dates($cm, $datesettings);
@@ -405,7 +439,13 @@ public function validation($data, $files) {
return $errors;
}
- public function render_timeline_view($data) {
+ /**
+ * Renders a timeline view of activities and their associated dates.
+ *
+ * @param array $data An array of timeline data.
+ * @return string HTML output for the timeline view.
+ */
+ public function render_timeline_view($data): string {
$data = self::sort_timeline_data($data);
$config = get_config('report_editdates');
@@ -455,8 +495,14 @@ public function render_timeline_view($data) {
return $output;
}
+ /**
+ * Sorts and processes timeline data for activities and their associated dates.
+ *
+ * @param array $data An array of timeline data.
+ * @return array Sorted timeline data.
+ */
private function sort_timeline_data($data) {
- $sorted = array();
+ $sorted = [];
// Find earliest and latest date.
foreach ($data as $mod) {
foreach ($mod as $key => $value) {
@@ -464,22 +510,26 @@ private function sort_timeline_data($data) {
$objects = json_decode($value);
foreach ($objects->c as $obj) {
if (property_exists($obj, 't') && is_numeric($obj->t) && $obj->t > 0) {
- $sorted[] = array('type' => $mod["type"],
- 'restric' => true,
- 'name' => $mod["name"] . ": Restrict Access",
- 'icon' => $mod["icon"],
- 'url' => $mod["url"],
- 'color' => $mod["color"],
- 'time' => $obj->t);
+ $sorted[] = [
+ 'type' => $mod["type"],
+ 'restric' => true,
+ 'name' => $mod["name"] . ": Restrict Access",
+ 'icon' => $mod["icon"],
+ 'url' => $mod["url"],
+ 'color' => $mod["color"],
+ 'time' => $obj->t,
+ ];
}
}
} else if (is_numeric($value) && $value > 0 && $key !== "name") {
- $sorted[] = array('type' => $mod["type"],
- 'name' => $mod["name"] . ": $key",
- 'icon' => $mod["icon"],
- 'url' => $mod["url"],
- 'color' => $mod["color"],
- 'time' => $value);
+ $sorted[] = [
+ 'type' => $mod["type"],
+ 'name' => $mod["name"] . ": $key",
+ 'icon' => $mod["icon"],
+ 'url' => $mod["url"],
+ 'color' => $mod["color"],
+ 'time' => $value,
+ ];
}
}
}
diff --git a/index.php b/index.php
index edef980..87e8ef5 100644
--- a/index.php
+++ b/index.php
@@ -31,12 +31,12 @@
$activitytype = optional_param('activitytype', '', PARAM_PLUGIN);
// Should be a valid course id.
-$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
+$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST);
require_login($course);
// Setup page.
-$urlparams = array('id' => $id);
+$urlparams = ['id' => $id];
if ($activitytype) {
$urlparams['activitytype'] = $activitytype;
}
@@ -56,7 +56,7 @@
// Prepare a list of activity types used in this course, and count the number that
// might be displayed.
$activitiesdisplayed = 0;
-$activitytypes = array("all" => get_string('allactivities'));
+$activitytypes = ["all" => get_string('allactivities')];
foreach ($modinfo->get_sections() as $sectionnum => $section) {
foreach ($section as $cmid) {
$cm = $cms[$cmid];
@@ -77,11 +77,17 @@
core_collator::asort($activitytypes);
// Creating the form.
-$baseurl = new moodle_url('/report/editdates/index.php', array('id' => $id));
-$mform = new report_editdates_form($baseurl, array('modinfo' => $modinfo,
- 'course' => $course, 'activitytype' => $activitytype));
-
-$returnurl = new moodle_url('/course/view.php', array('id' => $id));
+$baseurl = new moodle_url('/report/editdates/index.php', ['id' => $id]);
+$mform = new report_editdates_form(
+ $baseurl,
+ [
+ 'modinfo' => $modinfo,
+ 'course' => $course,
+ 'activitytype' => $activitytype,
+ ]
+);
+
+$returnurl = new moodle_url('/course/view.php', ['id' => $id]);
if ($mform->is_cancelled()) {
// Redirect to course view page if form is cancelled.
redirect($returnurl);
@@ -89,10 +95,10 @@
} else if ($data = $mform->get_data()) {
// Process submitted data.
- $moddatesettings = array();
- $blockdatesettings = array();
- $sectiondatesettings = array();
- $forceddatesettings = array();
+ $moddatesettings = [];
+ $blockdatesettings = [];
+ $sectiondatesettings = [];
+ $forceddatesettings = [];
foreach ($data as $key => $value) {
if ($key == "coursestartdate") {
@@ -148,8 +154,8 @@
$transaction = $DB->start_delegated_transaction();
// Allow to update only if user is capable.
if (has_capability('moodle/course:update', $coursecontext)) {
- $DB->set_field('course', 'startdate', $course->startdate, array('id' => $course->id));
- $DB->set_field('course', 'enddate', $course->enddate, array('id' => $course->id));
+ $DB->set_field('course', 'startdate', $course->startdate, ['id' => $course->id]);
+ $DB->set_field('course', 'enddate', $course->enddate, ['id' => $course->id]);
}
// Update forced date settings.
@@ -165,7 +171,7 @@
// Update section date settings.
foreach ($sectiondatesettings as $sectionid => $datesettings) {
- $sectionsettings = array('availablefrom', 'availableuntil');
+ $sectionsettings = ['availablefrom', 'availableuntil'];
$section = new stdClass();
$section->id = $sectionid;
foreach ($sectionsettings as $setting) {
@@ -189,7 +195,7 @@
// Update block date settings.
$courseblocks = $DB->get_records("block_instances",
- array('parentcontextid' => $coursecontext->id));
+ ['parentcontextid' => $coursecontext->id]);
foreach ($blockdatesettings as $blockid => $datesettings) {
$block = $courseblocks[$blockid];
@@ -218,7 +224,7 @@
// Making log entry.
$event = \report_editdates\event\report_viewed::create(
- array('context' => $coursecontext, 'other' => array('activitytype' => $activitytype)));
+ ['context' => $coursecontext, 'other' => ['activitytype' => $activitytype]]);
$event->trigger();
// Set page title and page heading.
diff --git a/lang/en/report_editdates.php b/lang/en/report_editdates.php
index 8970b88..1b621c3 100644
--- a/lang/en/report_editdates.php
+++ b/lang/en/report_editdates.php
@@ -28,6 +28,7 @@
$string['activityfilter'] = 'Activity view filter (changing this filter will not save the remaining form data)';
$string['activitytypefilter'] = 'Activity type';
$string['activitytypefilter_help'] = 'Use the filter to select activities to view and modify. Applying the filter will change the form display but will not save any existing changes.';
+$string['addrestrictedaccess'] = 'Add restricted access (opens a new window)';
$string['applyactivitytypefilter'] = 'Apply activity type filter';
$string['assesstimefinish'] = 'Time To cannot be less than Time From';
$string['assesstimefrom'] = 'Rate items posted From';
@@ -40,19 +41,18 @@
$string['editdates'] = 'Dates';
$string['editdates:view'] = 'View edit dates course report';
$string['editend'] = 'Prevent editing from cannot be less than Allow editing from';
+$string['editrestrictedaccess'] = 'Edit restricted access (opens a new window)';
+$string['event:reportviewed'] = 'Edit dates report viewed';
+$string['hasrestrictedaccess'] = '{$a} has restricted date access settings';
+$string['norestrictedaccess'] = 'No restricted date access settings on {$a}';
$string['page-report-editdates-index'] = 'Edit course dates';
$string['pluginname'] = 'Dates';
+$string['privacy:metadata'] = 'The Dates plugin does not store any personal data.';
$string['timeclose'] = 'Time Close cannot be less than Time Open';
$string['timedue'] = 'Time Due cannot be less than Time available';
-$string['timeuntil'] = 'Time From cannot be less than Time Until';
$string['timeend'] = 'Prevent from cannot be less than Allow From';
+$string['timelinedonotshow'] = 'Do not show the timeline';
$string['timelinemax'] = 'Time-line limit (years)';
$string['timelinemaxdesc'] = 'Maximum number of years shown on timeline.';
-$string['timelinedonotshow'] = 'Do not show the timeline';
+$string['timeuntil'] = 'Time From cannot be less than Time Until';
$string['toomuchtime'] = 'Timeline not created: Times were spread over {$a}+ years.';
-$string['hasrestrictedaccess'] = '{$a} has restricted date access settings';
-$string['norestrictedaccess'] = 'No restricted date access settings on {$a}';
-$string['addrestrictedaccess'] = 'Add restricted access (opens a new window)';
-$string['editrestrictedaccess'] = 'Edit restricted access (opens a new window)';
-$string['event:reportviewed'] = 'Edit dates report viewed';
-$string['privacy:metadata'] = 'The Dates plugin does not store any personal data.';
diff --git a/lib.php b/lib.php
index f569753..9b2c953 100644
--- a/lib.php
+++ b/lib.php
@@ -57,6 +57,12 @@ class report_editdates_date_setting {
public $getstep;
/**
* Constructor. A quick way to create an initialise an instance.
+ *
+ * @param string $label The label to be displayed on the form.
+ * @param int $currentvalue The current value of this setting, used to initialize the form.
+ * @param string $type One of the constants DATE or DATETIME defined in the class.
+ * @param bool $isoptional Whether this date can be enabled/disabled.
+ * @param int $getstep Only relevant for datetime elements, defines the step value.
*/
public function __construct($label, $currentvalue, $type, $isoptional, $getstep = 1) {
$this->label = $label;
@@ -76,7 +82,9 @@ public function __construct($label, $currentvalue, $type, $isoptional, $getstep
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class report_editdates_mod_date_extractor {
+ /** Constant for a date selector type. */
const DATE = 'date_selector';
+ /** Constant for a date-time selector type. */
const DATETIME = 'date_time_selector';
/** @var object the course database row. */
protected $course;
@@ -89,7 +97,7 @@ abstract class report_editdates_mod_date_extractor {
protected $mods;
/** @var array a static array to cache the objects of child classes */
- private static $moddateextractor = array();
+ private static $moddateextractor = [];
/**
* Constructor.
@@ -104,6 +112,7 @@ public function __construct($course, $type) {
/**
* This static function is used to create and cache objects of mod's date extractor classes
* @param String $modname the name of activity/resource e.g 'assignment', 'quiz'
+ * @param stdClass $course the course object.
* @return report_editdates_mod_date_extractor|null the extractor
*/
public static function make($modname, $course) {
@@ -140,7 +149,7 @@ public static function make($modname, $course) {
*/
public function load_data() {
global $DB;
- $this->mods = $DB->get_records($this->type, array('course' => $this->course->id));
+ $this->mods = $DB->get_records($this->type, ['course' => $this->course->id]);
}
/**
@@ -168,6 +177,7 @@ abstract public function validate_dates(cm_info $cm, array $dates);
/**
* Save the new dates for this course_module instance.
* @param cm_info $cm the activity to save the dates for.
+ * @param array $dates an array of dates to save.
*/
public function save_dates(cm_info $cm, array $dates) {
global $DB;
@@ -189,7 +199,9 @@ public function save_dates(cm_info $cm, array $dates) {
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class report_editdates_block_date_extractor {
+ /** Constant for a date selector type. */
const DATE = 'date_selector';
+ /** Constant for a date-time selector type. */
const DATETIME = 'date_time_selector';
/** @var object the course database row. */
protected $course;
@@ -202,12 +214,12 @@ abstract class report_editdates_block_date_extractor {
protected $blocks;
/** @var array a static array to cache the objects of child classes */
- private static $blockdateextractor = array();
+ private static $blockdateextractor = [];
/**
* Constructor.
* @param object $course the course database row.
- * @param $type the type of block to handle.
+ * @param string $type the type of block to handle.
*/
public function __construct($course, $type="block_instance") {
$this->course = $course;
@@ -217,6 +229,7 @@ public function __construct($course, $type="block_instance") {
/**
* This static function is used to create and cache objects of block's date extractor classes
* @param String $blockname the name of the block e.g 'html'
+ * @param stdClass $course the course object.
* @return report_editdates_block_date_extractor|null the extractor
*/
public static function make($blockname, $course) {
@@ -256,13 +269,13 @@ public function load_data() {
global $DB;
$coursecontext = context_course::instance($this->course->id);
$this->blocks = $DB->get_records('block_instances',
- array('blockname' => $this->type, 'parentcontextid' => $coursecontext->id));
+ ['blockname' => $this->type, 'parentcontextid' => $coursecontext->id]);
}
/**
* Get a list of the settings required for this course_module instance.
* (See the quiz example below.)
- * @param cm_info $cm the activity to return the settings for.
+ * @param block_base $block The activity to return the settings for.
* @return array The array keys are strings that identif y each setting.
* The values are report_editdates_date_setting objects.
*/
@@ -271,7 +284,7 @@ abstract public function get_settings(block_base $block);
/**
* Validate the submitted dates for this course_module instance.
* (See the quiz example below.)
- * @param cm_info $cm the activity to validate the dates for.
+ * @param block_base $block The activity to validate the dates for.
* @param array $dates an array with array keys matching those
* returned by get_settings(), and the new
* dates as values.
@@ -283,7 +296,8 @@ abstract public function validate_dates(block_base $block, array $dates);
/**
* Save the new dates for this course_module instance.
- * @param cm_info $cm the activity to save the dates for.
+ * @param block_base $block The activity to save the dates for.
+ * @param array $dates an array of dates to save.
*/
public function save_dates(block_base $block, array $dates) {
global $DB;
@@ -294,7 +308,7 @@ public function save_dates(block_base $block, array $dates) {
}
$DB->set_field('block_instances', 'configdata', base64_encode(serialize($block->config)),
- array('id' => $block->instance->id));
+ ['id' => $block->instance->id]);
}
}
@@ -310,7 +324,7 @@ public function save_dates(block_base $block, array $dates) {
function report_editdates_extend_navigation_course($navigation, $course, $context) {
global $CFG, $OUTPUT;
if (has_capability('report/editdates:view', $context)) {
- $url = new moodle_url('/report/editdates/index.php', array('id' => $course->id));
+ $url = new moodle_url('/report/editdates/index.php', ['id' => $course->id]);
if ($activitytype = optional_param('activitytype', '', PARAM_PLUGIN)) {
$url->param('activitytype', $activitytype);
}
@@ -327,11 +341,11 @@ function report_editdates_extend_navigation_course($navigation, $course, $contex
* @return array
*/
function report_editdates_page_type_list($pagetype, $parentcontext, $currentcontext) {
- return array(
+ return [
'*' => get_string('page-x', 'pagetype'),
'report-*' => get_string('page-report-x', 'pagetype'),
'report-editdates-index' => get_string('page-report-editdates-index', 'report_editdates'),
- );
+ ];
}
/**
@@ -354,11 +368,11 @@ function report_editdates_update_dates_by_section($courseid, array $sectionnums,
return false;
}
- $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
+ $course = $DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST);
$modinfo = get_fast_modinfo($course);
- $forceddatesettings = array();
- $moddatesettings = array();
+ $forceddatesettings = [];
+ $moddatesettings = [];
// Loop through each section in the course.
foreach ($sectionnums as $sectionnum => $value) {
diff --git a/mod/assigndates.php b/mod/assigndates.php
index ebf5ad1..8a0689a 100644
--- a/mod/assigndates.php
+++ b/mod/assigndates.php
@@ -19,39 +19,60 @@
require_once($CFG->dirroot.'/mod/assign/locallib.php');
+/**
+ * Class report_editdates_mod_assign_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Assignment" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_assign_date_extractor
-extends report_editdates_mod_date_extractor {
+ extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'assign');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$assign = $this->mods[$cm->instance];
- return array(
- 'allowsubmissionsfromdate' => new report_editdates_date_setting(
- get_string('allowsubmissionsfromdate', 'assign'),
- $assign->allowsubmissionsfromdate,
- self::DATETIME, true),
- 'duedate' => new report_editdates_date_setting(
- get_string('duedate', 'assign'),
- $assign->duedate,
- self::DATETIME, true),
- 'cutoffdate' => new report_editdates_date_setting(
- get_string('cutoffdate', 'assign'),
- $assign->cutoffdate,
- self::DATETIME, true),
- 'gradingduedate' => new report_editdates_date_setting(
- get_string('gradingduedate', 'assign'),
- $assign->gradingduedate,
- self::DATETIME, true),
- );
+ return [
+ 'allowsubmissionsfromdate' => new report_editdates_date_setting(
+ get_string('allowsubmissionsfromdate', 'assign'),
+ $assign->allowsubmissionsfromdate,
+ self::DATETIME, true
+ ),
+ 'duedate' => new report_editdates_date_setting(
+ get_string('duedate', 'assign'),
+ $assign->duedate,
+ self::DATETIME, true
+ ),
+ 'cutoffdate' => new report_editdates_date_setting(
+ get_string('cutoffdate', 'assign'),
+ $assign->cutoffdate,
+ self::DATETIME, true
+ ),
+ 'gradingduedate' => new report_editdates_date_setting(
+ get_string('gradingduedate', 'assign'),
+ $assign->gradingduedate,
+ self::DATETIME, true
+ ),
+ ];
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['allowsubmissionsfromdate'] && $dates['duedate']
&& $dates['duedate'] < $dates['allowsubmissionsfromdate']) {
$errors['duedate'] = get_string('duedatevalidation', 'assign');
@@ -72,6 +93,7 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ #[\Override]
public function save_dates(cm_info $cm, array $dates) {
global $DB, $COURSE;
diff --git a/mod/assignmentdates.php b/mod/assignmentdates.php
deleted file mode 100644
index 1286fab..0000000
--- a/mod/assignmentdates.php
+++ /dev/null
@@ -1,70 +0,0 @@
-.
-
-defined('MOODLE_INTERNAL') || die;
-
-require_once($CFG->dirroot.'/mod/assignment/lib.php');
-
-
-class report_editdates_mod_assignment_date_extractor
-extends report_editdates_mod_date_extractor {
-
- public function __construct($course) {
- parent::__construct($course, 'assignment');
- parent::load_data();
- }
-
- public function get_settings(cm_info $cm) {
- $ass = $this->mods[$cm->instance];
- // Availability and due date settings for an assignment.
- return array(
- 'timeavailable' => new report_editdates_date_setting(
- get_string('availabledate', 'assignment'),
- $ass->timeavailable, self::DATETIME, true),
- 'timedue' => new report_editdates_date_setting(
- get_string('duedate', 'assignment'),
- $ass->timedue, self::DATETIME, true)
- );
- }
-
- public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
- if ($dates['timeavailable'] != 0 && $dates['timedue'] != 0 && $dates['timedue'] < $dates['timeavailable']) {
- $errors['timedue'] = get_string('timedue', 'report_editdates');
- }
- return $errors;
- }
-
- public function save_dates(cm_info $cm, array $dates) {
-
- // Fetch module instance from $mods array.
- $assignment = $this->mods[$cm->instance];
-
- $assignment->instance = $cm->instance;
- $assignment->coursemodule = $cm->id;
- $assignment->cmidnumber = $cm->id;
-
- // Updating date values.
- foreach ($dates as $datetype => $datevalue) {
- $assignment->$datetype = $datevalue;
- }
-
- // Method name to udpate the instance and associated events.
- $methodname = $cm->modname.'_update_instance';
- // Calling the method.
- $methodname($assignment);
- }
-}
diff --git a/mod/chatdates.php b/mod/chatdates.php
index cde8488..5871fb8 100644
--- a/mod/chatdates.php
+++ b/mod/chatdates.php
@@ -14,31 +14,48 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_chat_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Chat" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_chat_date_extractor
- extends report_editdates_mod_date_extractor {
+ extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'chat');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$chat = $this->mods[$cm->instance];
- return array('chattime' => new report_editdates_date_setting(
- get_string('chattime', 'chat'),
- $chat->chattime,
- self::DATETIME, false)
- );
+ return [
+ 'chattime' => new report_editdates_date_setting(
+ get_string('chattime', 'chat'),
+ $chat->chattime,
+ self::DATETIME, false
+ ),
+ ];
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
return $errors;
}
+ #[\Override]
public function save_dates(cm_info $cm, array $dates) {
// Fetch module instance from $mods array.
diff --git a/mod/choicedates.php b/mod/choicedates.php
index 8605569..a525f4b 100644
--- a/mod/choicedates.php
+++ b/mod/choicedates.php
@@ -14,36 +14,52 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_choice_date_extractor
+ *
+ * This class is responsible for extracting and managing date settings
+ * for the "Choice" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_choice_date_extractor
- extends report_editdates_mod_date_extractor {
+ extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ * @param object $course the course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'choice');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$choice = $this->mods[$cm->instance];
if ($choice->timeopen != 0 && $choice->timeclose != 0) {
- return array('timeopen' => new report_editdates_date_setting(
- get_string('choiceopen', 'choice'),
- $choice->timeopen,
- self::DATETIME, false),
+ return [
+ 'timeopen' => new report_editdates_date_setting(
+ get_string('choiceopen', 'choice'),
+ $choice->timeopen,
+ self::DATETIME, false
+ ),
- 'timeclose' => new report_editdates_date_setting(
- get_string('choiceclose', 'choice'),
- $choice->timeclose,
- self::DATETIME, false)
- );
+ 'timeclose' => new report_editdates_date_setting(
+ get_string('choiceclose', 'choice'),
+ $choice->timeclose,
+ self::DATETIME, false
+ ),
+ ];
}
return null;
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if (!empty($dates['timeopen']) && !empty($dates['timeclose']) &&
$dates['timeclose'] < $dates['timeopen']) {
$errors['timeclose'] = get_string('timeclose', 'report_editdates');
diff --git a/mod/datadates.php b/mod/datadates.php
index e5e1995..f86113f 100644
--- a/mod/datadates.php
+++ b/mod/datadates.php
@@ -14,38 +14,52 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_data_date_extractor
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_data_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'data');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$data = $this->mods[$cm->instance];
- $datadatesettings = array(
+ $datadatesettings = [
'timeavailablefrom' => new report_editdates_date_setting(
- get_string('availablefromdate', 'data'),
- $data->timeavailablefrom,
- self::DATETIME, true),
+ get_string('availablefromdate', 'data'),
+ $data->timeavailablefrom,
+ self::DATETIME, true
+ ),
'timeavailableto' => new report_editdates_date_setting(
- get_string('availabletodate', 'data'),
- $data->timeavailableto,
- self::DATETIME, true),
+ get_string('availabletodate', 'data'),
+ $data->timeavailableto,
+ self::DATETIME, true
+ ),
'timeviewfrom' => new report_editdates_date_setting(
- get_string('viewfromdate', 'data'),
- $data->timeviewfrom,
- self::DATETIME, true),
+ get_string('viewfromdate', 'data'),
+ $data->timeviewfrom,
+ self::DATETIME, true
+ ),
'timeviewto' => new report_editdates_date_setting(
- get_string('viewtodate', 'data'),
- $data->timeviewto,
- self::DATETIME, true)
- );
+ get_string('viewtodate', 'data'),
+ $data->timeviewto,
+ self::DATETIME, true
+ ),
+ ];
if ($data->assessed && ($data->assesstimestart != 0 || $data->assesstimefinish != 0) ) {
$datadatesettings['assesstimestart'] = new report_editdates_date_setting(
get_string('from'),
@@ -59,8 +73,9 @@ public function get_settings(cm_info $cm) {
return $datadatesettings;
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['timeavailablefrom'] != 0 && $dates['timeavailableto'] != 0
&& $dates['timeavailableto'] < $dates['timeavailablefrom']) {
$errors['timeavailableto'] = get_string('assesstimefinish', 'report_editdates');
diff --git a/mod/dataplusdates.php b/mod/dataplusdates.php
index 69800fd..ecff2b1 100644
--- a/mod/dataplusdates.php
+++ b/mod/dataplusdates.php
@@ -14,30 +14,45 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_dataplus_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Dataplus" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_dataplus_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'dataplus');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$data = $this->mods[$cm->instance];
- $datadatesettings = array(
+ $datadatesettings = [
'timeavailablefrom' => new report_editdates_date_setting(
- get_string('availablefromdate', 'dataplus'),
- $data->timeavailablefrom,
- self::DATE, true),
+ get_string('availablefromdate', 'dataplus'),
+ $data->timeavailablefrom,
+ self::DATE, true
+ ),
'timeavailableto' => new report_editdates_date_setting(
- get_string('availabletodate', 'dataplus'),
- $data->timeavailableto,
- self::DATE, true),
- );
+ get_string('availabletodate', 'dataplus'),
+ $data->timeavailableto,
+ self::DATE, true
+ ),
+ ];
if ($data->assessed) {
$datadatesettings['assesstimestart'] = new report_editdates_date_setting(
get_string('from'),
@@ -51,8 +66,9 @@ public function get_settings(cm_info $cm) {
return $datadatesettings;
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['timeavailablefrom'] != 0 && $dates['timeavailableto'] != 0
&& $dates['timeavailableto'] < $dates['timeavailablefrom']) {
$errors['timeavailableto'] = get_string('assesstimefinish', 'report_editdates');
diff --git a/mod/externalquizdates.php b/mod/externalquizdates.php
index 1103ed4..dbf87dc 100644
--- a/mod/externalquizdates.php
+++ b/mod/externalquizdates.php
@@ -14,33 +14,49 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_externalquiz_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "External Quiz" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_externalquiz_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'externalquiz');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$extquiz = $this->mods[$cm->instance];
- return array('timeopen' => new report_editdates_date_setting(
- get_string('quizopen', 'externalquiz'),
- $extquiz->timeopen,
- self::DATETIME, true),
-
- 'timeclose' => new report_editdates_date_setting(
- get_string('quizclose', 'externalquiz'),
- $extquiz->timeclose,
- self::DATETIME, true)
- );
+ return [
+ 'timeopen' => new report_editdates_date_setting(
+ get_string('quizopen', 'externalquiz'),
+ $extquiz->timeopen,
+ self::DATETIME, true
+ ),
+ 'timeclose' => new report_editdates_date_setting(
+ get_string('quizclose', 'externalquiz'),
+ $extquiz->timeclose,
+ self::DATETIME, true
+ ),
+ ];
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['timeopen'] != 0 && $dates['timeclose'] != 0 &&
$dates['timeclose'] < $dates['timeopen']) {
$errors['timeclose'] = get_string('timeclose', 'report_editdates');
diff --git a/mod/feedbackdates.php b/mod/feedbackdates.php
index 0604d43..aefeff3 100644
--- a/mod/feedbackdates.php
+++ b/mod/feedbackdates.php
@@ -14,34 +14,50 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_feedback_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Feedback" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_feedback_date_extractor
- extends report_editdates_mod_date_extractor {
+ extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'feedback');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$feedback = $this->mods[$cm->instance];
- return array('timeopen' => new report_editdates_date_setting(
- get_string('feedbackopen', 'feedback'),
- $feedback->timeopen,
- self::DATETIME, true),
+ return [
+ 'timeopen' => new report_editdates_date_setting(
+ get_string('feedbackopen', 'feedback'),
+ $feedback->timeopen,
+ self::DATETIME, true
+ ),
- 'timeclose' => new report_editdates_date_setting(
- get_string('feedbackclose', 'feedback'),
- $feedback->timeclose,
- self::DATETIME, true)
- );
- return null;
+ 'timeclose' => new report_editdates_date_setting(
+ get_string('feedbackclose', 'feedback'),
+ $feedback->timeclose,
+ self::DATETIME, true
+ ),
+ ];
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if (!empty($dates['timeopen']) && !empty($dates['timeclose']) &&
$dates['timeclose'] < $dates['timeopen']) {
$errors['timeclose'] = get_string('timeclose', 'report_editdates');
diff --git a/mod/forumdates.php b/mod/forumdates.php
index 82815e8..a2dbf32 100644
--- a/mod/forumdates.php
+++ b/mod/forumdates.php
@@ -14,21 +14,34 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_forum_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Forum" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_forum_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'forum');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$forum = $this->mods[$cm->instance];
- $fields = array();
+ $fields = [];
$fields['duedate'] = new report_editdates_date_setting(
get_string('duedate', 'forum'),
$forum->duedate,
@@ -50,8 +63,9 @@ public function get_settings(cm_info $cm) {
return $fields;
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
$forum = $this->mods[$cm->instance];
if ($forum->assessed && $dates['assesstimestart'] != 0 && $dates['assesstimefinish'] != 0 &&
$dates['assesstimefinish'] < $dates['assesstimestart']) {
diff --git a/mod/forumngdates.php b/mod/forumngdates.php
index 15380df..a93375a 100644
--- a/mod/forumngdates.php
+++ b/mod/forumngdates.php
@@ -14,20 +14,33 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_forumng_date_extractor
+ *
+ * This class is responsible for extracting, validating, and managing date settings
+ * for the "ForumNG" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_forumng_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'forumng');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$forumng = $this->mods[$cm->instance];
- $forumngdatesettings = array();
+ $forumngdatesettings = [];
if ($forumng->ratingscale != 0) {
$forumngdatesettings['ratingfrom'] = new report_editdates_date_setting(
@@ -51,8 +64,9 @@ public function get_settings(cm_info $cm) {
return $forumngdatesettings;
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if (isset($dates['ratingfrom']) && isset($dates['ratinguntil'])
&& $dates['ratingfrom'] != 0 && $dates['ratinguntil'] != 0
&& $dates['ratinguntil'] < $dates['ratingfrom']) {
diff --git a/mod/glossarydates.php b/mod/glossarydates.php
index 421be26..fc60d2d 100644
--- a/mod/glossarydates.php
+++ b/mod/glossarydates.php
@@ -14,36 +14,53 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_glossary_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Glossary" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_glossary_date_extractor
-extends report_editdates_mod_date_extractor {
+ extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'glossary');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$mod = $this->mods[$cm->instance];
if ($mod->assessed && ( $mod->assesstimestart != 0 || $mod->assesstimefinish != 0) ) {
- return array('assesstimestart' => new report_editdates_date_setting(
- get_string('from'),
- $mod->assesstimestart,
- self::DATETIME, false),
- 'assesstimefinish' => new report_editdates_date_setting(
- get_string('to'),
- $mod->assesstimefinish,
- self::DATETIME, false)
- );
+ return [
+ 'assesstimestart' => new report_editdates_date_setting(
+ get_string('from'),
+ $mod->assesstimestart,
+ self::DATETIME, false
+ ),
+ 'assesstimefinish' => new report_editdates_date_setting(
+ get_string('to'),
+ $mod->assesstimefinish,
+ self::DATETIME, false
+ ),
+ ];
}
return null;
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['assesstimestart'] != 0 && $dates['assesstimefinish'] != 0
&& $dates['assesstimefinish'] < $dates['assesstimestart']) {
$errors['assesstimefinish'] = get_string('assesstimefinish', 'report_editdates');
diff --git a/mod/lessondates.php b/mod/lessondates.php
index 3be0a8a..fc4e1fa 100644
--- a/mod/lessondates.php
+++ b/mod/lessondates.php
@@ -14,31 +14,48 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see ..
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_lesson_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Lesson" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_lesson_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'lesson');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$mod = $this->mods[$cm->instance];
- return array('available' => new report_editdates_date_setting(
- get_string('available', 'lesson'),
- $mod->available, self::DATETIME, true),
- 'deadline' => new report_editdates_date_setting(
- get_string('deadline', 'lesson'),
- $mod->deadline, self::DATETIME, true)
- );
+ return [
+ 'available' => new report_editdates_date_setting(
+ get_string('available', 'lesson'),
+ $mod->available, self::DATETIME, true
+ ),
+ 'deadline' => new report_editdates_date_setting(
+ get_string('deadline', 'lesson'),
+ $mod->deadline, self::DATETIME, true
+ ),
+ ];
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['available'] != 0 && $dates['deadline'] != 0
&& $dates['deadline'] < $dates['available']) {
$errors['deadline'] = get_string('deadline', 'report_editdates');
@@ -46,6 +63,7 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ #[\Override]
public function save_dates(cm_info $cm, array $dates) {
global $DB, $COURSE;
diff --git a/mod/nanogongdates.php b/mod/nanogongdates.php
index c43ac10..cbe8b36 100644
--- a/mod/nanogongdates.php
+++ b/mod/nanogongdates.php
@@ -14,33 +14,50 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_nanogong_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Nanogong" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_nanogong_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'nanogong');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$nanogong = $this->mods[$cm->instance];
- return array('timeavailable' => new report_editdates_date_setting(
- get_string('availabledate', 'mod_nanogong'),
- $nanogong->timeavailable,
- self::DATETIME, true),
- 'timedue' => new report_editdates_date_setting(
- get_string('duedate', 'mod_nanogong'),
- $nanogong->timedue,
- self::DATETIME, true)
- );
+ return [
+ 'timeavailable' => new report_editdates_date_setting(
+ get_string('availabledate', 'mod_nanogong'),
+ $nanogong->timeavailable,
+ self::DATETIME, true
+ ),
+ 'timedue' => new report_editdates_date_setting(
+ get_string('duedate', 'mod_nanogong'),
+ $nanogong->timedue,
+ self::DATETIME, true
+ ),
+ ];
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['timeavailable'] != 0 && $dates['timedue'] != 0 &&
$dates['timedue'] < $dates['timeavailable']) {
$errors['timedue'] = get_string('deadline', 'report_editdates');
diff --git a/mod/ouwikidates.php b/mod/ouwikidates.php
index 821d147..eb4ba8d 100644
--- a/mod/ouwikidates.php
+++ b/mod/ouwikidates.php
@@ -19,29 +19,49 @@
require_once($CFG->dirroot.'/mod/ouwiki/lib.php');
+/**
+ * Class report_editdates_mod_ouwiki_date_extractor
+ *
+ * This class is responsible for extracting and managing date settings
+ * for the "OU Wiki" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_ouwiki_date_extractor
-extends report_editdates_mod_date_extractor {
+ extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course the course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'ouwiki');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$mod = $this->mods[$cm->instance];
- return array('editbegin' => new report_editdates_date_setting(
- get_string('editbegin', 'ouwiki'),
- $mod->editbegin, self::DATETIME, true),
- 'editend' => new report_editdates_date_setting(
- get_string('editend', 'ouwiki'),
- $mod->editend, self::DATETIME, true)
- );
+ return [
+ 'editbegin' => new report_editdates_date_setting(
+ get_string('editbegin', 'ouwiki'),
+ $mod->editbegin, self::DATETIME, true
+ ),
+ 'editend' => new report_editdates_date_setting(
+ get_string('editend', 'ouwiki'),
+ $mod->editend, self::DATETIME, true
+ ),
+ ];
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['editbegin'] != 0 && $dates['editend'] != 0
&& $dates['editend'] < $dates['editbegin']) {
$errors['editend'] = get_string('editend', 'report_editdates');
diff --git a/mod/pcastdates.php b/mod/pcastdates.php
index 3d15de6..5e7eb3d 100644
--- a/mod/pcastdates.php
+++ b/mod/pcastdates.php
@@ -14,36 +14,53 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_pcast_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Pcast" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2015 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_pcast_date_extractor
-extends report_editdates_mod_date_extractor {
+ extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'pcast');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$mod = $this->mods[$cm->instance];
if ($mod->assessed && ( $mod->assesstimestart != 0 || $mod->assesstimefinish != 0) ) {
- return array('assesstimestart' => new report_editdates_date_setting(
- get_string('from'),
- $mod->assesstimestart,
- self::DATETIME, false),
- 'assesstimefinish' => new report_editdates_date_setting(
- get_string('to'),
- $mod->assesstimefinish,
- self::DATETIME, false)
- );
+ return [
+ 'assesstimestart' => new report_editdates_date_setting(
+ get_string('from'),
+ $mod->assesstimestart,
+ self::DATETIME, false
+ ),
+ 'assesstimefinish' => new report_editdates_date_setting(
+ get_string('to'),
+ $mod->assesstimefinish,
+ self::DATETIME, false
+ ),
+ ];
}
return null;
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['assesstimestart'] != 0 && $dates['assesstimefinish'] != 0
&& $dates['assesstimefinish'] < $dates['assesstimestart']) {
$errors['assesstimefinish'] = get_string('assesstimefinish', 'report_editdates');
diff --git a/mod/questionnairedates.php b/mod/questionnairedates.php
index 8353b99..d6853b5 100644
--- a/mod/questionnairedates.php
+++ b/mod/questionnairedates.php
@@ -19,27 +19,47 @@
require_once($CFG->dirroot.'/mod/questionnaire/lib.php');
+/**
+ * Class report_editdates_mod_questionnaire_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Questionnaire" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_questionnaire_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'questionnaire');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$mod = $this->mods[$cm->instance];
- return array('opendate' => new report_editdates_date_setting(
- get_string('opendate', 'questionnaire'),
- $mod->opendate, self::DATETIME, true),
- 'closedate' => new report_editdates_date_setting(
- get_string('closedate', 'questionnaire'),
- $mod->closedate, self::DATETIME, true),
- );
+ return [
+ 'opendate' => new report_editdates_date_setting(
+ get_string('opendate', 'questionnaire'),
+ $mod->opendate, self::DATETIME, true
+ ),
+ 'closedate' => new report_editdates_date_setting(
+ get_string('closedate', 'questionnaire'),
+ $mod->closedate, self::DATETIME, true
+ ),
+ ];
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['opendate'] != 0 && $dates['closedate'] != 0
&& $dates['closedate'] < $dates['opendate']) {
$errors['closedate'] = get_string('closedate', 'report_editdates');
@@ -47,6 +67,7 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ #[\Override]
public function save_dates(cm_info $cm, array $dates) {
global $DB, $COURSE;
diff --git a/mod/quizdates.php b/mod/quizdates.php
index 30d077c..d9a88b2 100644
--- a/mod/quizdates.php
+++ b/mod/quizdates.php
@@ -19,27 +19,47 @@
require_once($CFG->dirroot.'/mod/quiz/lib.php');
+/**
+ * Class report_editdates_mod_quiz_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Quiz" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_quiz_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'quiz');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$quiz = $this->mods[$cm->instance];
- return array('timeopen' => new report_editdates_date_setting(
- get_string('quizopen', 'quiz'),
- $quiz->timeopen, self::DATETIME, true),
- 'timeclose' => new report_editdates_date_setting(
- get_string('quizclose', 'quiz'),
- $quiz->timeclose, self::DATETIME, true)
- );
+ return [
+ 'timeopen' => new report_editdates_date_setting(
+ get_string('quizopen', 'quiz'),
+ $quiz->timeopen, self::DATETIME, true
+ ),
+ 'timeclose' => new report_editdates_date_setting(
+ get_string('quizclose', 'quiz'),
+ $quiz->timeclose, self::DATETIME, true
+ ),
+ ];
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['timeopen'] != 0 && $dates['timeclose'] != 0
&& $dates['timeclose'] < $dates['timeopen']) {
$errors['timeclose'] = get_string('timeclose', 'report_editdates');
@@ -47,6 +67,7 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ #[\Override]
public function save_dates(cm_info $cm, array $dates) {
parent::save_dates($cm, $dates);
diff --git a/mod/scormdates.php b/mod/scormdates.php
index ceb4796..82001ae 100644
--- a/mod/scormdates.php
+++ b/mod/scormdates.php
@@ -19,27 +19,47 @@
require_once($CFG->dirroot.'/mod/scorm/lib.php');
+/**
+ * Class report_editdates_mod_scorm_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "SCORM" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_scorm_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'scorm');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$mod = $this->mods[$cm->instance];
- return array('timeopen' => new report_editdates_date_setting(
- get_string("scormopen", "scorm"),
- $mod->timeopen, self::DATETIME, true),
- 'timeclose' => new report_editdates_date_setting(
- get_string("scormclose", "scorm"),
- $mod->timeclose, self::DATETIME, true)
- );
+ return [
+ 'timeopen' => new report_editdates_date_setting(
+ get_string("scormopen", "scorm"),
+ $mod->timeopen, self::DATETIME, true
+ ),
+ 'timeclose' => new report_editdates_date_setting(
+ get_string("scormclose", "scorm"),
+ $mod->timeclose, self::DATETIME, true
+ ),
+ ];
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
if ($dates['timeopen'] != 0 && $dates['timeclose'] != 0
&& $dates['timeclose'] < $dates['timeopen']) {
$errors['timeclose'] = get_string('timeclose', 'report_editdates');
diff --git a/mod/turnitintooltwodates.php b/mod/turnitintooltwodates.php
index 16288c2..384d83c 100644
--- a/mod/turnitintooltwodates.php
+++ b/mod/turnitintooltwodates.php
@@ -14,17 +14,30 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
-
+/**
+ * Class report_editdates_mod_turnitintooltwo_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Turnitin Tool Two" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2016 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_turnitintooltwo_date_extractor
-extends report_editdates_mod_date_extractor {
+ extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'turnitintooltwo');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
global $DB;
$tii = $this->mods[$cm->instance];
@@ -52,10 +65,11 @@ public function get_settings(cm_info $cm) {
return $elems;
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
global $DB;
$now = new DateTime("now", core_date::get_user_timezone_object());
- $errors = array();
+ $errors = [];
$parts = $DB->get_records_select("turnitintooltwo_parts", "turnitintooltwoid = ?", [$cm->instance], 'id ASC');
foreach ($parts as $id => $part) {
if ($dates["startdate$id"] > $dates["duedate$id"]) {
@@ -72,6 +86,7 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ #[\Override]
public function save_dates(cm_info $cm, array $dates) {
global $DB, $COURSE, $CFG;
diff --git a/mod/workshopdates.php b/mod/workshopdates.php
index 5817b48..6339701 100644
--- a/mod/workshopdates.php
+++ b/mod/workshopdates.php
@@ -19,33 +19,55 @@
require_once($CFG->dirroot.'/mod/quiz/lib.php');
+/**
+ * Class report_editdates_mod_workshop_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Workshop" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_workshop_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'workshop');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$workshop = $this->mods[$cm->instance];
- return array('submissionstart' => new report_editdates_date_setting(
- get_string('submissionstart', 'workshop'),
- $workshop->submissionstart, self::DATETIME, true),
- 'submissionend' => new report_editdates_date_setting(
- get_string('submissionend', 'workshop'),
- $workshop->submissionend, self::DATETIME, true),
- 'assessmentstart' => new report_editdates_date_setting(
- get_string('assessmentstart', 'workshop'),
- $workshop->assessmentstart, self::DATETIME, true),
- 'assessmentend' => new report_editdates_date_setting(
- get_string('assessmentend', 'workshop'),
- $workshop->assessmentend, self::DATETIME, true),
- );
+ return [
+ 'submissionstart' => new report_editdates_date_setting(
+ get_string('submissionstart', 'workshop'),
+ $workshop->submissionstart, self::DATETIME, true
+ ),
+ 'submissionend' => new report_editdates_date_setting(
+ get_string('submissionend', 'workshop'),
+ $workshop->submissionend, self::DATETIME, true
+ ),
+ 'assessmentstart' => new report_editdates_date_setting(
+ get_string('assessmentstart', 'workshop'),
+ $workshop->assessmentstart, self::DATETIME, true
+ ),
+ 'assessmentend' => new report_editdates_date_setting(
+ get_string('assessmentend', 'workshop'),
+ $workshop->assessmentend, self::DATETIME, true
+ ),
+ ];
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
// Check the phases borders are valid.
if ($dates['submissionstart'] > 0 && $dates['submissionend'] > 0 &&
@@ -66,7 +88,7 @@ public function validate_dates(cm_info $cm, array $dates) {
$phaseassessmentstart = max($dates['assessmentstart'], $dates['assessmentend']);
}
if ($phasesubmissionend > 0 && $phaseassessmentstart > 0 && $phaseassessmentstart < $phasesubmissionend) {
- foreach (array('submissionend', 'submissionstart', 'assessmentstart', 'assessmentend') as $f) {
+ foreach (['submissionend', 'submissionstart', 'assessmentstart', 'assessmentend'] as $f) {
if ($dates[$f] > 0) {
$errors[$f] = get_string('phasesoverlap', 'mod_workshop');
break;
@@ -78,6 +100,7 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ #[\Override]
public function save_dates(cm_info $cm, array $dates) {
parent::save_dates($cm, $dates);
diff --git a/mod/zoomdates.php b/mod/zoomdates.php
index 4b2f5b8..0c0a1ae 100644
--- a/mod/zoomdates.php
+++ b/mod/zoomdates.php
@@ -19,30 +19,48 @@
require_once($CFG->dirroot.'/mod/zoom/locallib.php');
+/**
+ * Class report_editdates_mod_zoom_date_extractor
+ *
+ * This class is responsible for extracting, validating, and saving date settings
+ * for the "Zoom" activity module in Moodle.
+ *
+ * @package report_editdates
+ * @copyright 2014 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_zoom_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course database row.
+ */
public function __construct($course) {
parent::__construct($course, 'zoom');
parent::load_data();
}
+ #[\Override]
public function get_settings(cm_info $cm) {
$zoom = $this->mods[$cm->instance];
if (!empty($zoom->recurring)) {
- return array();
+ return [];
} else {
// Underscores currently don't behave well with this report, so we'll omit them.
- return array(
+ return [
'starttime' => new report_editdates_date_setting(
- get_string('meeting_time', 'zoom'),
- $zoom->start_time, self::DATETIME, false),
- );
+ get_string('meeting_time', 'zoom'),
+ $zoom->start_time, self::DATETIME, false
+ ),
+ ];
}
}
+ #[\Override]
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
$zoom = $this->mods[$cm->instance];
if (empty($zoom->recurring)) {
@@ -56,6 +74,7 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ #[\Override]
public function save_dates(cm_info $cm, array $dates) {
// Fetch module instance from $mods array.
$zoom = $this->mods[$cm->instance];
diff --git a/tests/behat/basic.feature b/tests/behat/basic.feature
index 0469720..c9f3b07 100644
--- a/tests/behat/basic.feature
+++ b/tests/behat/basic.feature
@@ -17,18 +17,19 @@ Feature: Edit course plugin dates
| student1 | C1 | student |
And I am on the "Course 1" "course" page logged in as "teacher1"
And I turn editing mode on
- And I add a "Quiz" to section "1" and I fill the form with:
- | Name | Test quiz name 1 |
- | Description | Test quiz description |
- Given I log out
+ And the following "activities" exist:
+ | activity | name | intro | course |
+ | quiz | Test quiz name 1 | Test quiz description | C1 |
+ And I log out
@javascript @_switch_iframe
Scenario: Test edit dates report can be used to change plugin instance dates
When I am on the "Course 1" "course" page logged in as "admin"
- And I navigate to "Reports > Dates" in current page administration
+ And I navigate to "Reports" in current page administration
+ And I click on "Dates" "link"
Then I should see "Course 1"
And I should see "Activity view filter "
- And I follow "Expand all"
+ And I click on "Expand all" "link" in the "region-main" "region"
Then I should see "Course start date"
And I should see "Test quiz name 1"
@@ -38,7 +39,7 @@ Feature: Edit course plugin dates
And I press "Save changes"
Then I should see "Course 1"
And I should see "Activity view filter "
- And I follow "Expand all"
+ And I click on "Expand all" "link" in the "region-main" "region"
Then I should see "Course start date"
And I should see "Test quiz name 1"
And I should see "1" in the "Open the quiz" "fieldset"
diff --git a/tests/behat/course_report_editdates.feature b/tests/behat/course_report_editdates.feature
index 1035118..f33e08e 100644
--- a/tests/behat/course_report_editdates.feature
+++ b/tests/behat/course_report_editdates.feature
@@ -19,7 +19,7 @@ Feature: Edit dates report navigation
@javascript
Scenario: Selector should be available in the Activities and resources page
Given I am on the "Course 1" "course" page logged in as "admin"
- When I navigate to "Reports > Dates" in current page administration
- Then "Report" "field" should exist
- And the "Report" select box should contain "Dates"
- And the field "Report" matches value "Dates"
+ When I navigate to "Reports" in current page administration
+ And I click on "Dates" "link"
+ Then "Report" "field" should exist in the "tertiary-navigation" "region"
+ And I should see "Dates" in the "tertiary-navigation" "region"
diff --git a/tests/behat/timeline.feature b/tests/behat/timeline.feature
index 6c2ccc8..67ecbc0 100644
--- a/tests/behat/timeline.feature
+++ b/tests/behat/timeline.feature
@@ -16,23 +16,18 @@ Feature: Timeline view
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I turn editing mode on
- And I add a "Quiz" to section "1" and I fill the form with:
- | Name | Test quiz |
- | Description | Test forum description |
- | timeopen[enabled] | 1 |
- | timeopen[day] | 1 |
- | timeopen[month] | January |
- | timeopen[year] | 2020 |
- | timeopen[hour] | 08 |
- | timeopen[minute] | 00 |
- Given I log out
+ And the following "activities" exist:
+ | activity | name | course | section | timeopen |
+ | quiz | Test quiz | C1 | 1 | 1577865600 |
+ And I log out
@javascript @_switch_iframe
Scenario: Test edit dates report to see if timeline view shows
Given the following config values are set as admin:
| timelinemax | 1 | report_editdates |
When I am on the "Course 1" "course" page logged in as "admin"
- And I navigate to "Reports > Dates" in current page administration
+ And I navigate to "Reports" in current page administration
+ And I click on "Dates" "link"
Then I should see "12/31/2019"
And I should see "1/1/2020"
And I should see "1/2/2020"
@@ -42,7 +37,8 @@ Feature: Timeline view
Given the following config values are set as admin:
| timelinemax | 0 | report_editdates |
When I am on the "Course 1" "course" page logged in as "admin"
- And I navigate to "Reports > Dates" in current page administration
+ And I navigate to "Reports" in current page administration
+ And I click on "Dates" "link"
Then I should not see "12/31/2019"
And I should not see "1/1/2020"
And I should not see "1/2/2020"
diff --git a/version.php b/version.php
index 0dfacb4..571f956 100644
--- a/version.php
+++ b/version.php
@@ -24,10 +24,10 @@
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2022051600;
-$plugin->requires = 2020061500;
+$plugin->version = 2025072300;
+$plugin->requires = 2024042200;
$plugin->component = 'report_editdates';
$plugin->maturity = MATURITY_STABLE;
-$plugin->release = '3.0 for Moodle 3.11+';
+$plugin->release = '3.1 for Moodle 4.4+';
$plugin->outestssufficient = true;