diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index cc862c2..f696e08 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -3,93 +3,90 @@ on: [push, pull_request]
jobs:
test:
- runs-on: 'ubuntu-latest'
- strategy:
- fail-fast: false
- matrix:
- include:
- - php: '7.4'
- moodle-branch: 'master'
- database: 'pgsql'
- - php: '7.4'
- moodle-branch: 'MOODLE_311_STABLE'
- database: 'mariadb'
+ runs-on: ubuntu-latest
services:
postgres:
- image: postgres
+ image: postgres:latest
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
- options: >-
- --health-cmd pg_isready
- --health-interval 10s
- --health-timeout 5s
- --health-retries 3
ports:
- 5432:5432
-
+ options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
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
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['8.2', '8.3']
+ moodle-branch: ['main']
+ database: [pgsql, mariadb]
+
steps:
- - name: Checkout
- uses: actions/checkout@v2
+ - name: Check out repository code
+ uses: actions/checkout@v4
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
-
- - name: Install Moodle
- run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
+ echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
+ - name: Install moodle-plugin-ci
+ run: |
+ moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
- - name: phplint
+ - name: PHP Lint
if: ${{ always() }}
run: moodle-plugin-ci phplint
- - name: phpcpd
+ - name: PHP Mess 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 phpmd
- - name: phpmd
+ - name: Moodle Code Checker
if: ${{ always() }}
- run: moodle-plugin-ci phpmd
+ run: moodle-plugin-ci codechecker --max-warnings 0
- - name: codechecker
+ - name: Moodle PHPDoc Checker
if: ${{ always() }}
- run: moodle-plugin-ci codechecker
+ run: moodle-plugin-ci phpdoc
- - name: validate
+ - 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
if: ${{ always() }}
run: moodle-plugin-ci mustache
diff --git a/blocks/example.php b/blocks/example.php
index cffda09..66285e4 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 {report_editdates_block_date_extractor} subclass.
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -40,25 +37,55 @@ class report_editdates_block_html_date_extractor extends report_editdates_block
* Constructor.
* @param object $course course settings from the DB.
*/
+ /**
+ * Constructor for the assignment date extractor.
+ *
+ * Initializes the date extractor for assignment modules by invoking
+ * the parent constructor with the course and 'assignment' as the module type.
+ * Additionally, it loads necessary data related to the assignments.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'html');
parent::load_data();
}
+ /**
+ * Return an array of settings for the dates that we handle.
+ *
+ * This function takes in the course module information and returns an associative array
+ * of date settings for the module. The keys of the returned array are the string names
+ * of the settings, and the values are objects of the report_editdates_date_setting class.
+ *
+ * @param block_base $block the block to get the settings for.
+ * @return array an associative array of date settings for the block.
+ */
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),
+ ];
}
}
+ /**
+ * Validate the submitted dates for this course_module instance.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param block_base $block the block to validate the dates for.
+ * @param array $dates an associative array of date settings for the block.
+ * @return array an associative array of validation errors.
+ */
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/classes/event/report_viewed.php b/classes/event/report_viewed.php
index 0181a89..15f75c9 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,11 @@ 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..cb90f19 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.
*
@@ -20,8 +21,9 @@
* @copyright 2018 The Open University
* @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.
*
@@ -35,7 +37,7 @@ class provider implements \core_privacy\local\metadata\null_provider {
*
* @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..907d97c 100644
--- a/db/install.php
+++ b/db/install.php
@@ -22,8 +22,26 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * Upgrades the editdates plugin after install.
+ *
+ * This function is needed when a site is upgrading from a version of Moodle
+ * that had the old 'coursereport_editdates' plugin. It is needed even if the
+ * site is not using the editdates plugin, because some things need to be
+ * fixed in the database.
+ *
+ * The first part of this function is a hack to copy the permission from the
+ * old place, if they were present. If this report is installed into a new
+ * Moodle, we just do what it says in access.php 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.
+ *
+ * The second part of this function is a hack which is needed for cleanup of
+ * original coursereport_completion stuff.
+ *
+ * The third part of this function is a hack to update existing block page patterns.
+ */
function xmldb_report_editdates_install() {
global $DB;
@@ -32,10 +50,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 +62,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..53f2384 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,26 +35,72 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class report_editdates_form extends moodleform {
+
+ /**
+ * Mod info instance set for the form.
+ * @var \course_modinfo|null
+ */
+ protected $modinfo;
+
+ /**
+ * Course.
+ * @var \stdClass
+ */
+ protected $course;
+
+ /**
+ * Selected activity type.
+ * @var string
+ */
+ protected $activitytype;
+
/**
+ * Get course mod info instance set for the form.
+ * @return course_modinfo | null
+ */
+ public function get_modinfo(): ?course_modinfo {
+ return $this->modinfo;
+ }
+
+ /**
+ * Course object.
+ * @return \stdClass
+ */
+ public function get_course(): stdClass {
+ return $this->course;
+ }
+
+ /**
+ * Selected activity type.
+ * @return string
+ */
+ public function get_activitytype(): string {
+ return $this->activitytype;
+ }
+
+ /**
+ * This function is used to define the form elements
+ * for the mod_form.php file.
+ *
* @see lib/moodleform#definition()
*/
public function definition() {
global $CFG, $DB, $PAGE;
$mform = $this->_form;
- $modinfo = $this->_customdata['modinfo'];
- $course = $this->_customdata['course'];
- $activitytype = $this->_customdata['activitytype'];
+ $this->modinfo = $this->_customdata['modinfo'];
+ $this->course = $this->_customdata['course'];
+ $this->activitytype = $this->_customdata['activitytype'];
$config = get_config('report_editdates');
$coursehasavailability = !empty($CFG->enableavailability);
- $coursehascompletion = !empty($CFG->enablecompletion) && !empty($course->enablecompletion);
+ $coursehascompletion = !empty($CFG->enablecompletion) && !empty($this->course->enablecompletion);
// Context instance of the course.
- $coursecontext = context_course::instance($course->id);
+ $coursecontext = context_course::instance($this->course->id);
// Store current activity type.
- $mform->addElement('hidden', 'activitytype', $activitytype);
+ $mform->addElement('hidden', 'activitytype', $this->activitytype);
$mform->setType('activitytype', PARAM_PLUGIN);
// Invisible static element. Used as the holder for a validation message sometimes.
@@ -71,11 +116,11 @@ public function definition() {
$mform->addElement('date_time_selector', 'coursestartdate', get_string('startdate'));
$mform->addHelpButton('coursestartdate', 'startdate');
- $mform->setDefault('coursestartdate', $course->startdate);
+ $mform->setDefault('coursestartdate', $this->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);
+ $mform->setDefault('courseenddate', $this->course->enddate);
// If user is not capable, make it read only.
if (!has_capability('moodle/course:update', $coursecontext)) {
@@ -93,9 +138,9 @@ public function definition() {
$prevsectionnum = -1;
// Cycle through all the sections in the course.
- $cms = $modinfo->get_cms();
- $sections = $modinfo->get_section_info_all();
- $timeline = array();
+ $cms = $this->modinfo->get_cms();
+ $sections = $this->modinfo->get_section_info_all();
+ $timeline = [];
foreach ($sections as $sectionnum => $section) {
$ismodadded = false;
$sectionname = '';
@@ -107,7 +152,7 @@ public function definition() {
// New section, create header.
if ($prevsectionnum != $sectionnum) {
- $sectionname = get_section_name($course, $section);
+ $sectionname = get_section_name($this->course, $section);
$headername = 'section' . $sectionnum . 'header';
$mform->addElement('header', $headername, $sectionname);
$mform->setExpanded($headername, false);
@@ -115,35 +160,36 @@ 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),
+ ['href' => $editsettingurl->out(false),
'target' => '_blank',
- 'class' => 'editdates_highlight'));
+ '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'));
+ ['href' => $editsettingurl->out(false),
+ 'target' => '_blank']);
$mform->addElement('static', '',
get_string('norestrictedaccess', 'report_editdates', ($sectionname)),
$editsettingurltext);
@@ -151,8 +197,8 @@ public function definition() {
}
// Cycle through each module in a section.
- if (isset($modinfo->sections[$sectionnum])) {
- foreach ($modinfo->sections[$sectionnum] as $cmid) {
+ if (isset($this->modinfo->sections[$sectionnum])) {
+ foreach ($this->modinfo->sections[$sectionnum] as $cmid) {
$cm = $cms[$cmid];
// No need to display/continue if this module is not visible to user.
@@ -161,7 +207,7 @@ public function definition() {
}
// If activity filter is on, then filter module by activity type.
- if ($activitytype && ($cm->modname != $activitytype && $activitytype != "all")) {
+ if ($this->activitytype && ($cm->modname != $this->activitytype && $this->activitytype != "all")) {
continue;
}
@@ -170,34 +216,45 @@ 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)',
+ ];
+
+ // Add a textbox for editing the activity name.
+ $elname = 'name_' . $cm->modname . '_' . $cm->id;
+ $mform->addElement('text', $elname, get_string('activityname', 'report_editdates'),
+ ['size' => '64']);
+ $mform->setType($elname, PARAM_TEXT);
+ $mform->setDefault($elname, $cm->name);
// Call get_settings method for the acitivity/module.
// Get instance of the mod's date exractor class.
- $mod = report_editdates_mod_date_extractor::make($cm->modname, $course);
+ $mod = report_editdates_mod_date_extractor::make($cm->modname, $this->course);
if ($mod && ($cmdatesettings = $mod->get_settings($cm))) {
// Added activity name on the form.
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));
+ [$cmdatesetting->label => $cmdatesetting->currentvalue]);
if ($ismodreadonly) {
$mform->hardFreeze($elname);
}
@@ -212,11 +269,11 @@ public function definition() {
$elname = 'date_mod_'.$cm->id.'_completionexpected';
$mform->addElement('date_time_selector', $elname,
get_string('completionexpected', 'completion'),
- array('optional' => true));
+ ['optional' => true]);
$mform->addHelpButton($elname, 'completionexpected', 'completion');
$mform->setDefault($elname, $cm->completionexpected);
$timeline[$cm->id] = array_merge($timeline[$cm->id],
- array('completionexpected' => $cm->completionexpected));
+ ['completionexpected' => $cm->completionexpected]);
if ($ismodreadonly) {
$mform->hardFreeze($elname);
}
@@ -229,22 +286,22 @@ 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));
+ $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'),
- array('href' => $editsettingurl->out(false),
+ ['href' => $editsettingurl->out(false),
'target' => '_blank',
- 'class' => 'editdates_highlight'));
+ '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));
+ $editsettingurl = new moodle_url('/course/modedit.php', ['update' => $cm->id]);
$editsettingurltext = html_writer::tag('a',
get_string('addrestrictedaccess', 'report_editdates'),
- array('href' => $editsettingurl->out(false), 'target' => '_blank'));
+ ['href' => $editsettingurl->out(false), 'target' => '_blank']);
if ($isdateadded) {
$mform->addElement('static', 'modrestrict' . $cm->id,
get_string('norestrictedaccess', 'report_editdates', ($cm->name)),
@@ -264,7 +321,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);
@@ -276,7 +333,7 @@ public function definition() {
// Iterate though blocks array.
foreach ($courseblocks as $blockid => $block) {
- $blockdatextrator = report_editdates_block_date_extractor::make($block->blockname, $course);
+ $blockdatextrator = report_editdates_block_date_extractor::make($block->blockname, $this->course);
if ($blockdatextrator) {
// Create the block instance.
$blockobj = block_instance($block->blockname, $block, $PAGE);
@@ -291,8 +348,8 @@ public function definition() {
// Add element.
$mform->addElement($blockdatesetting->type, $elname,
$blockdatesetting->label,
- array('optional' => $blockdatesetting->isoptional,
- 'step' => $blockdatesetting->getstep));
+ ['optional' => $blockdatesetting->isoptional,
+ 'step' => $blockdatesetting->getstep]);
$mform->setDefault($elname, $blockdatesetting->currentvalue);
if (!$canmanagesiteblocks || !$blockobj->user_can_edit()) {
$mform->hardFreeze($elname);
@@ -321,18 +378,30 @@ public function definition() {
$mform->addElement('static', 'timelineview', '');
$mform->addElement('html', self::render_timeline_view($timeline));
}
+
+ $callbacks = get_plugins_with_function('report_editdates_form_elements', 'lib.php');
+ foreach ($callbacks as $type => $plugins) {
+ foreach ($plugins as $plugin => $pluginfunction) {
+ // We have exposed all the important properties with public getters - and the callback can manipulate the mform
+ // directly.
+ $pluginfunction($this, $this->_form);
+ }
+ }
}
+ /**
+ * Validation function for form.
+ *
+ * @param array $data form data
+ * @param array $files files
+ * @return array errors
+ */
public function validation($data, $files) {
global $CFG;
$errors = parent::validation($data, $files);
- $modinfo = $this->_customdata['modinfo'];
- $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 +424,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.
@@ -365,13 +434,13 @@ public function validation($data, $files) {
}
}
- $cms = $modinfo->get_cms();
+ $cms = $this->modinfo->get_cms();
// Validating forced date settings.
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,9 +453,9 @@ 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)) {
+ if ($mod = report_editdates_mod_date_extractor::make($cm->modname, $this->course)) {
$moderrors = $mod->validate_dates($cm, $datesettings);
if (!empty($moderrors)) {
foreach ($moderrors as $errorfield => $errorstr) {
@@ -396,6 +465,16 @@ public function validation($data, $files) {
}
}
+ $callbacks = get_plugins_with_function('report_editdates_form_validation', 'lib.php');
+ foreach ($callbacks as $type => $plugins) {
+ foreach ($plugins as $plugin => $pluginfunction) {
+ $pluginerrors = $pluginfunction($this, $data);
+ if (!empty($pluginerrors)) {
+ $errors = array_merge($errors, $pluginerrors);
+ }
+ }
+ }
+
if (!empty($errors)) {
// If there are any validation errors, which may be hidden a long way down this
// very big form, put a message at the top too.
@@ -405,6 +484,35 @@ public function validation($data, $files) {
return $errors;
}
+ /**
+ * Executes callback functions after form data is defined.
+ *
+ * This method retrieves and executes plugin-specific callback functions
+ * that are registered to perform additional operations on the form data
+ * once it has been initially defined. This allows plugins to modify or
+ * extend the form fields and data.
+ */
+ public function definition_after_data() {
+ $callbacks = get_plugins_with_function('report_editdates_form_definition_after_data', 'lib.php');
+ foreach ($callbacks as $type => $plugins) {
+ foreach ($plugins as $plugin => $pluginfunction) {
+ $pluginfunction($this, $this->_form);
+ }
+ }
+ }
+
+ /**
+ * Render timeline view from activity data.
+ *
+ * This method renders a HTML table that displays a timeline view of the
+ * given activity data. The timeline view shows the activities in a vertical
+ * table, with columns representing individual days. The table is expanded
+ * by one day in either direction. The timeline view is only shown if the
+ * total time span is less than the configured maximum time span.
+ *
+ * @param array $data Activity data.
+ * @return string Rendered timeline view HTML.
+ */
public function render_timeline_view($data) {
$data = self::sort_timeline_data($data);
$config = get_config('report_editdates');
@@ -455,8 +563,14 @@ public function render_timeline_view($data) {
return $output;
}
+ /**
+ * Sorts the timeline data by time.
+ *
+ * @param array $data Activity data.
+ * @return array The 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 +578,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..bddb74f 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,22 +77,35 @@
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);
} else if ($data = $mform->get_data()) {
- // Process submitted data.
+ // Modify submitted data.
+ $callbacks = get_plugins_with_function('report_editdates_form_post_actions', 'lib.php');
+ foreach ($callbacks as $type => $plugins) {
+ foreach ($plugins as $plugin => $pluginfunction) {
+ $data = $pluginfunction($data, $course);
+ }
+ }
- $moddatesettings = array();
- $blockdatesettings = array();
- $sectiondatesettings = array();
- $forceddatesettings = array();
+ // Start transaction.
+ $transaction = $DB->start_delegated_transaction();
+
+ // Process submitted data.
+ $moddatesettings = [];
+ $blockdatesettings = [];
+ $sectiondatesettings = [];
+ $forceddatesettings = [];
foreach ($data as $key => $value) {
if ($key == "coursestartdate") {
@@ -141,15 +154,27 @@
}
}
}
+
+ // Update activity name.
+ if (count($cmsettings) == 3 && $cmsettings[0] == 'name') {
+ $modcontext = context_module::instance($cmsettings[2]);
+ // User should be capable of updating individual module.
+ if (has_capability('moodle/course:manageactivities', $modcontext)) {
+ $cm = $modinfo->get_cm($cmsettings[2]);
+ $update = new stdClass();
+ $update->id = $cm->instance;
+ $update->name = $value;
+ $update->timemodified = time();
+ $DB->update_record($cmsettings[1], $update);
+ }
+ }
}
}
- // Start transaction.
- $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 +190,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) {
@@ -183,13 +208,12 @@
$cm = $cms[$modid];
$mod = report_editdates_mod_date_extractor::make($cm->modname, $course);
if ($mod) {
- $mod->save_dates($cm, $datesettings);
+ $mod->save_new_dates($cm, $datesettings);
}
}
// Update block date settings.
- $courseblocks = $DB->get_records("block_instances",
- array('parentcontextid' => $coursecontext->id));
+ $courseblocks = $DB->get_records("block_instances", ['parentcontextid' => $coursecontext->id]);
foreach ($blockdatesettings as $blockid => $datesettings) {
$block = $courseblocks[$blockid];
@@ -200,14 +224,20 @@
$blockdatextrator =
report_editdates_block_date_extractor::make($block->blockname, $course);
if ($blockdatextrator) {
- $blockdatextrator->save_dates($blockobj, $datesettings);
+ $blockdatextrator->save_new_dates($blockobj, $datesettings);
}
}
}
// Commit transaction and finish up.
$transaction->allow_commit();
+
+ // Rebuild all course cache / calendar dates.
rebuild_course_cache($course->id);
+ $task = new \core\task\refresh_mod_calendar_events_task();
+ $task->set_custom_data(['courseid' => $course->id]);
+ \core\task\manager::queue_adhoc_task($task, true);
+
redirect($PAGE->url, get_string('changessaved'));
}
@@ -217,8 +247,10 @@
$select->set_help_icon('activitytypefilter', 'report_editdates');
// Making log entry.
-$event = \report_editdates\event\report_viewed::create(
- array('context' => $coursecontext, 'other' => array('activitytype' => $activitytype)));
+$event = \report_editdates\event\report_viewed::create([
+ '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..7184bb8 100644
--- a/lang/en/report_editdates.php
+++ b/lang/en/report_editdates.php
@@ -24,10 +24,11 @@
defined('MOODLE_INTERNAL') || die;
-
$string['activityfilter'] = 'Activity view filter (changing this filter will not save the remaining form data)';
+$string['activityname'] = 'Activity name';
$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..ba120ef 100644
--- a/lib.php
+++ b/lib.php
@@ -55,8 +55,16 @@ class report_editdates_date_setting {
* Option passed when adding the element to the form.
*/
public $getstep;
+
+
/**
- * Constructor. A quick way to create an initialise an instance.
+ * Constructor
+ *
+ * @param string $label the label for this setting displayed on the form
+ * @param int $currentvalue the current value of this setting, used to init the form
+ * @param string $type one of the consts DATE or DATETIME defined below
+ * @param bool $isoptional whether this date can be enabled/disabled
+ * @param int $getstep only relevant for datetime elements, option passed when adding the element to the form
*/
public function __construct($label, $currentvalue, $type, $isoptional, $getstep = 1) {
$this->label = $label;
@@ -76,8 +84,11 @@ 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 {
+ /** @var string contant type selector */
const DATE = 'date_selector';
+ /** @var string contant type selector */
const DATETIME = 'date_time_selector';
+
/** @var object the course database row. */
protected $course;
/**
@@ -89,7 +100,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.
@@ -102,9 +113,16 @@ 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'
- * @return report_editdates_mod_date_extractor|null the extractor
+ * Creates and caches an object of the module's date extractor class.
+ *
+ * This method checks if an instance of the module's date extractor class
+ * already exists in the cache. If not, it attempts to create one by
+ * checking for a class within the module's plugin folder or by including
+ * a module-specific date extractor file.
+ *
+ * @param string $modname The name of the module, e.g., 'quiz', 'forum'.
+ * @param stdClass $course The course object.
+ * @return report_editdates_mod_date_extractor|null The date extractor object or null if none found.
*/
public static function make($modname, $course) {
global $CFG;
@@ -140,7 +158,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]);
}
/**
@@ -165,10 +183,36 @@ abstract public function get_settings(cm_info $cm);
*/
abstract public function validate_dates(cm_info $cm, array $dates);
+ /**
+ * Save the new dates for this course_module instance.
+ *
+ * Having this method final gives us a possibilities to
+ * add any logic (e.g. triggering events) before or after saving dates for any activity.
+ *
+ * @param \cm_info $cm the activity to save the dates for.
+ * @param array $dates a list of new dates.
+ *
+ * @throws \coding_exception
+ */
+ final public function save_new_dates(cm_info $cm, array $dates) {
+ $this->save_dates($cm, $dates);
+ \core\event\course_module_updated::create_from_cm($cm)->trigger();
+ }
+
/**
* Save the new dates for this course_module instance.
* @param cm_info $cm the activity to save the dates for.
*/
+ /**
+ * Save the new dates for an assignment activity.
+ *
+ * This method updates the assignment instance with the new date values provided,
+ * and triggers the necessary calendar event updates and gradebook updates.
+ *
+ * @param cm_info $cm The course module information.
+ * @param array $dates An associative array where keys are date type strings
+ * and values are the new date values to be saved.
+ */
public function save_dates(cm_info $cm, array $dates) {
global $DB;
$updateobj = new stdClass();
@@ -189,8 +233,11 @@ 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 {
+ /** @var string contant type selector */
const DATE = 'date_selector';
+ /** @var string contant type selector */
const DATETIME = 'date_time_selector';
+
/** @var object the course database row. */
protected $course;
/**
@@ -202,12 +249,13 @@ 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 we handle.
+ * E.g. 'html' or 'calendar_month'.
*/
public function __construct($course, $type="block_instance") {
$this->course = $course;
@@ -215,9 +263,15 @@ 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'
- * @return report_editdates_block_date_extractor|null the extractor
+ * Make a date extractor object for the given block.
+ *
+ * This function first checks if the plugin has implemented support within itself.
+ * If not, it checks if the plugin has implemented support in a file of its own.
+ * If not, it returns null.
+ *
+ * @param string $blockname the name of the block.
+ * @param stdClass $course the course database row.
+ * @return report_editdates_block_date_extractor|null the date extractor object or null.
*/
public static function make($blockname, $course) {
global $CFG;
@@ -255,35 +309,55 @@ public static function make($blockname, $course) {
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));
+ $this->blocks = $DB->get_records('block_instances', [
+ '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.
- * @return array The array keys are strings that identif y each setting.
- * The values are report_editdates_date_setting objects.
+ * Return an array of settings for the dates that we handle.
+ *
+ * This function takes in the course module information and returns an associative array
+ * of date settings for the module. The keys of the returned array are the string names
+ * of the settings, and the values are objects of the report_editdates_date_setting class.
+ *
+ * @param block_base $block the block to get the settings for.
+ * @return array an associative array of date settings for the block.
*/
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 array $dates an array with array keys matching those
- * returned by get_settings(), and the new
- * dates as values.
- * @return array Any validation errors. The array keys need to
- * match the keys returned by get_settings().
- * Return an empty array if there are no erros.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param block_base $block the block to validate the dates for.
+ * @param array $dates an associative array of date settings for the block.
+ * @return array an associative array of validation errors.
*/
abstract public function validate_dates(block_base $block, array $dates);
+ /**
+ * Save the new dates for this block instance.
+ *
+ * Having this method final gives us a possibilities to
+ * add any logic (e.g. triggering events) before or after saving dates for any block.
+ *
+ * @param \block_base $block the block to save the dates for.
+ * @param array $dates a list of new dates.
+ */
+ final public function save_new_dates(block_base $block, array $dates) {
+ $this->save_dates($block, $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 block to save the dates for.
+ * @param array $dates a list of new dates.
*/
public function save_dates(block_base $block, array $dates) {
global $DB;
@@ -294,8 +368,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 +383,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 +400,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 +427,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) {
@@ -435,7 +508,7 @@ function report_editdates_update_dates_by_section($courseid, array $sectionnums,
$modinstance = report_editdates_mod_data_date_extractor::make($cm->modname, $course);
if ($modinstance) {
- $modinstance->save_dates($cm, $datesettings);
+ $modinstance->save_new_dates($cm, $datesettings);
}
}
$transaction->allow_commit();
diff --git a/mod/assigndates.php b/mod/assigndates.php
index ebf5ad1..91500ae 100644
--- a/mod/assigndates.php
+++ b/mod/assigndates.php
@@ -14,44 +14,88 @@
// 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
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
defined('MOODLE_INTERNAL') || die;
require_once($CFG->dirroot.'/mod/assign/locallib.php');
-
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the assign module
+ *
+ * @copyright 2011 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 for the assignment date extractor.
+ *
+ * Initializes the date extractor for assignment modules by calling the parent constructor
+ * with the course and 'assign' as the module type. Additionally, it loads necessary data.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'assign');
parent::load_data();
}
+ /**
+ * Retrieves the date settings for an assignment activity.
+ *
+ * This function returns an array of date settings specific to an assignment module.
+ * The settings include allowsubmissionsfromdate, duedate, cutoffdate, and gradingduedate.
+ * Each setting is represented by a report_editdates_date_setting object, which includes
+ * localization strings and date values.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An associative array of date settings for the assignment module.
+ */
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),
+ ];
}
+ /**
+ * Validates the submitted dates for an assignment activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the assignment module.
+ * @return array an associative array of validation errors.
+ */
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 +116,16 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ /**
+ * Save the new dates for an assignment activity.
+ *
+ * This method updates the assignment instance with the new date values provided,
+ * and triggers the necessary calendar event updates and gradebook updates.
+ *
+ * @param cm_info $cm The course module information.
+ * @param array $dates An associative array where keys are date type strings
+ * and values are the new date values to be saved.
+ */
public function save_dates(cm_info $cm, array $dates) {
global $DB, $COURSE;
diff --git a/mod/assignmentdates.php b/mod/assignmentdates.php
index 1286fab..ba3c294 100644
--- a/mod/assignmentdates.php
+++ b/mod/assignmentdates.php
@@ -14,40 +14,92 @@
// 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
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
defined('MOODLE_INTERNAL') || die;
require_once($CFG->dirroot.'/mod/assignment/lib.php');
-
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the assignments module
+ *
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class report_editdates_mod_assignment_date_extractor
extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor for the assignment date extractor.
+ *
+ * Initializes the date extractor for assignment modules by invoking
+ * the parent constructor with the course and 'assignment' as the module type.
+ * Additionally, it loads necessary data related to the assignments.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'assignment');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the assignment module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the assignment.
+ */
public function get_settings(cm_info $cm) {
$ass = $this->mods[$cm->instance];
// Availability and due date settings for an assignment.
- return array(
+ return [
'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)
- );
+ $ass->timedue, self::DATETIME, true),
+ ];
}
+ /**
+ * Validate the submitted dates for this course_module instance.
+ *
+ * @param cm_info $cm 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.
+ * @return array Any validation errors. The array keys need to
+ * match the keys returned by get_settings().
+ * Return an empty array if there are no erros.
+ */
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('timedue', 'report_editdates');
}
return $errors;
}
+ /**
+ * Save the new dates for an assignment activity.
+ *
+ * This method updates the assignment instance with the new date values provided,
+ * and triggers the necessary calendar event updates and gradebook updates.
+ *
+ * @param cm_info $cm The course module information.
+ * @param array $dates An associative array where keys are date type strings
+ * and values are the new date values to be saved.
+ */
public function save_dates(cm_info $cm, array $dates) {
// Fetch module instance from $mods array.
diff --git a/mod/chatdates.php b/mod/chatdates.php
index cde8488..2a9ecfa 100644
--- a/mod/chatdates.php
+++ b/mod/chatdates.php
@@ -14,31 +14,82 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the chat module
+ *
+ * @copyright 2011 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 {
+ /**
+ * Constructor for the chat date extractor.
+ *
+ * Initializes the date extractor for chat modules by invoking
+ * the parent constructor with the course and 'chat' as the module type.
+ * Additionally, it loads necessary data related to the chats.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'chat');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the chat module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the chat.
+ */
public function get_settings(cm_info $cm) {
$chat = $this->mods[$cm->instance];
- return array('chattime' => new report_editdates_date_setting(
+ return [
+ 'chattime' => new report_editdates_date_setting(
get_string('chattime', 'chat'),
$chat->chattime,
- self::DATETIME, false)
- );
+ self::DATETIME, false),
+ ];
}
+ /**
+ * Validates the submitted dates for an chat activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the chat module.
+ * @return array an associative array of validation errors.
+ */
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
return $errors;
}
+ /**
+ * Save the new dates for an chat activity.
+ *
+ * This method updates the chat instance with the new date values provided,
+ * and triggers the necessary calendar event updates and gradebook updates.
+ *
+ * @param cm_info $cm The course module information.
+ * @param array $dates An associative array where keys are date type strings
+ * and values are the new date values to be saved.
+ */
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..195f4b8 100644
--- a/mod/choicedates.php
+++ b/mod/choicedates.php
@@ -14,36 +14,76 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the choice module
+ *
+ * @copyright 2011 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 {
+ /**
+ * Constructor for the choice date extractor.
+ *
+ * Initializes the date extractor for choice modules by invoking
+ * the parent constructor with the course and 'choice' as the module type.
+ * Additionally, it loads necessary data related to the choices.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'choice');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the choice module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the choice.
+ */
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(
+ return [
+ 'timeopen' => new report_editdates_date_setting(
get_string('choiceopen', 'choice'),
$choice->timeopen,
self::DATETIME, false),
- 'timeclose' => new report_editdates_date_setting(
+ 'timeclose' => new report_editdates_date_setting(
get_string('choiceclose', 'choice'),
$choice->timeclose,
- self::DATETIME, false)
- );
+ self::DATETIME, false),
+ ];
}
return null;
}
-
+ /**
+ * Validates the submitted dates for an choice activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the choice module.
+ * @return array an associative array of validation errors.
+ */
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..d90bc80 100644
--- a/mod/datadates.php
+++ b/mod/datadates.php
@@ -14,21 +14,50 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the database module
+ *
+ * @copyright 2011 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 for the database date extractor.
+ *
+ * Initializes the date extractor for database modules by invoking
+ * the parent constructor with the course and 'database' as the module type.
+ * Additionally, it loads necessary data related to the databases.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'data');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the database module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the database.
+ */
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,
@@ -44,8 +73,8 @@ public function get_settings(cm_info $cm) {
'timeviewto' => new report_editdates_date_setting(
get_string('viewtodate', 'data'),
$data->timeviewto,
- self::DATETIME, true)
- );
+ self::DATETIME, true),
+ ];
if ($data->assessed && ($data->assesstimestart != 0 || $data->assesstimefinish != 0) ) {
$datadatesettings['assesstimestart'] = new report_editdates_date_setting(
get_string('from'),
@@ -58,9 +87,19 @@ public function get_settings(cm_info $cm) {
}
return $datadatesettings;
}
-
+ /**
+ * Validates the submitted dates for an database activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the database module.
+ * @return array an associative array of validation errors.
+ */
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..615988e 100644
--- a/mod/dataplusdates.php
+++ b/mod/dataplusdates.php
@@ -14,21 +14,50 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the dataplus module
+ *
+ * @copyright 2011 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 for the dataplus date extractor.
+ *
+ * Initializes the date extractor for dataplus modules by invoking
+ * the parent constructor with the course and 'dataplus' as the module type.
+ * Additionally, it loads necessary data related to the datapluss.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'dataplus');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the dataplus module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the dataplus.
+ */
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,
@@ -37,7 +66,7 @@ public function get_settings(cm_info $cm) {
get_string('availabletodate', 'dataplus'),
$data->timeavailableto,
self::DATE, true),
- );
+ ];
if ($data->assessed) {
$datadatesettings['assesstimestart'] = new report_editdates_date_setting(
get_string('from'),
@@ -51,8 +80,19 @@ public function get_settings(cm_info $cm) {
return $datadatesettings;
}
+ /**
+ * Validates the submitted dates for an dataplus activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the dataplus module.
+ * @return array an associative array of validation errors.
+ */
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..e39da97 100644
--- a/mod/externalquizdates.php
+++ b/mod/externalquizdates.php
@@ -14,33 +14,73 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the external module
+ *
+ * @copyright 2011 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 for the external date extractor.
+ *
+ * Initializes the date extractor for external modules by invoking
+ * the parent constructor with the course and 'external' as the module type.
+ * Additionally, it loads necessary data related to the externals.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'externalquiz');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the external module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the external.
+ */
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),
+ 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)
- );
+ 'timeclose' => new report_editdates_date_setting(
+ get_string('quizclose', 'externalquiz'),
+ $extquiz->timeclose,
+ self::DATETIME, true),
+ ];
}
-
+ /**
+ * Validates the submitted dates for an external activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the external module.
+ * @return array an associative array of validation errors.
+ */
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..7aa1efe 100644
--- a/mod/feedbackdates.php
+++ b/mod/feedbackdates.php
@@ -14,34 +14,74 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the feedback module
+ *
+ * @copyright 2011 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 {
+ /**
+ * Constructor for the feedback date extractor.
+ *
+ * Initializes the date extractor for feedback modules by invoking
+ * the parent constructor with the course and 'feedback' as the module type.
+ * Additionally, it loads necessary data related to the feedbacks.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'feedback');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the feedback module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the feedback.
+ */
public function get_settings(cm_info $cm) {
$feedback = $this->mods[$cm->instance];
- return array('timeopen' => new report_editdates_date_setting(
+ return [
+ 'timeopen' => new report_editdates_date_setting(
get_string('feedbackopen', 'feedback'),
$feedback->timeopen,
self::DATETIME, true),
- 'timeclose' => new report_editdates_date_setting(
+ 'timeclose' => new report_editdates_date_setting(
get_string('feedbackclose', 'feedback'),
$feedback->timeclose,
- self::DATETIME, true)
- );
+ self::DATETIME, true),
+ ];
return null;
}
-
+ /**
+ * Validates the submitted dates for an feedback activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the feedback module.
+ * @return array an associative array of validation errors.
+ */
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..de2427d 100644
--- a/mod/forumdates.php
+++ b/mod/forumdates.php
@@ -14,21 +14,50 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the forum module
+ *
+ * @copyright 2011 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 for the forum date extractor.
+ *
+ * Initializes the date extractor for forum modules by invoking
+ * the parent constructor with the course and 'forum' as the module type.
+ * Additionally, it loads necessary data related to the forums.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'forum');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the forum module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the forum.
+ */
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,
@@ -49,9 +78,19 @@ public function get_settings(cm_info $cm) {
}
return $fields;
}
-
+ /**
+ * Validates the submitted dates for an forum activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the forum module.
+ * @return array an associative array of validation errors.
+ */
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']) {
@@ -67,4 +106,27 @@ public function validate_dates(cm_info $cm, array $dates) {
}
return $errors;
}
+
+ /**
+ * Save the new dates for an forum activity.
+ *
+ * This method updates the forum instance with the new date values provided,
+ * and triggers the necessary calendar event updates and gradebook updates.
+ *
+ * @param cm_info $cm The course module information.
+ * @param array $dates An associative array where keys are date type strings
+ * and values are the new date values to be saved.
+ */
+ public function save_dates(cm_info $cm, array $dates) {
+ global $DB, $COURSE, $CFG;
+ parent::save_dates($cm, $dates);
+
+ require_once($CFG->dirroot.'/mod/forum/locallib.php');
+ $forum = $DB->get_record('forum', ['id' => $cm->instance]);
+ $forum->cmidnumber = $cm->id;
+
+ // Update the calendar and grades.
+ forum_update_calendar($forum, $cm->id);
+ forum_grade_item_update($forum);
+ }
}
diff --git a/mod/forumngdates.php b/mod/forumngdates.php
index 15380df..c9dd37b 100644
--- a/mod/forumngdates.php
+++ b/mod/forumngdates.php
@@ -14,20 +14,49 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the forumng module
+ *
+ * @copyright 2011 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 for the forumng date extractor.
+ *
+ * Initializes the date extractor for forumng modules by invoking
+ * the parent constructor with the course and 'forumng' as the module type.
+ * Additionally, it loads necessary data related to the forumngs.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'forumng');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the forumng module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the forumng.
+ */
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(
@@ -50,9 +79,19 @@ public function get_settings(cm_info $cm) {
self::DATETIME, true);
return $forumngdatesettings;
}
-
+ /**
+ * Validates the submitted dates for an forumng activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the forumng module.
+ * @return array an associative array of validation errors.
+ */
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..0aa4e35 100644
--- a/mod/glossarydates.php
+++ b/mod/glossarydates.php
@@ -14,36 +14,76 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the glossary module
+ *
+ * @copyright 2011 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 {
+ /**
+ * Constructor for the glossary date extractor.
+ *
+ * Initializes the date extractor for glossary modules by invoking
+ * the parent constructor with the course and 'glossary' as the module type.
+ * Additionally, it loads necessary data related to the glossarys.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'glossary');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the glossary module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the glossary.
+ */
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(
+ return [
+ 'assesstimestart' => new report_editdates_date_setting(
get_string('from'),
$mod->assesstimestart,
self::DATETIME, false),
- 'assesstimefinish' => new report_editdates_date_setting(
+ 'assesstimefinish' => new report_editdates_date_setting(
get_string('to'),
$mod->assesstimefinish,
- self::DATETIME, false)
- );
+ self::DATETIME, false),
+ ];
}
return null;
}
-
+ /**
+ * Validates the submitted dates for an glossary activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the glossary module.
+ * @return array an associative array of validation errors.
+ */
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..a128fa0 100644
--- a/mod/lessondates.php
+++ b/mod/lessondates.php
@@ -12,33 +12,73 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see ..
-
-defined('MOODLE_INTERNAL') || die;
+// along with Moodle. If not, see .
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the lesson module
+ *
+ * @copyright 2011 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 for the lesson date extractor.
+ *
+ * Initializes the date extractor for lesson modules by invoking
+ * the parent constructor with the course and 'lesson' as the module type.
+ * Additionally, it loads necessary data related to the lessons.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'lesson');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the lesson module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the lesson.
+ */
public function get_settings(cm_info $cm) {
$mod = $this->mods[$cm->instance];
- return array('available' => new report_editdates_date_setting(
+ return [
+ 'available' => new report_editdates_date_setting(
get_string('available', 'lesson'),
$mod->available, self::DATETIME, true),
- 'deadline' => new report_editdates_date_setting(
+ 'deadline' => new report_editdates_date_setting(
get_string('deadline', 'lesson'),
- $mod->deadline, self::DATETIME, true)
- );
+ $mod->deadline, self::DATETIME, true),
+ ];
}
-
+ /**
+ * Validates the submitted dates for an lesson activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the lesson module.
+ * @return array an associative array of validation errors.
+ */
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 +86,16 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ /**
+ * Save the new dates for an lesson activity.
+ *
+ * This method updates the lesson instance with the new date values provided,
+ * and triggers the necessary calendar event updates and gradebook updates.
+ *
+ * @param cm_info $cm The course module information.
+ * @param array $dates An associative array where keys are date type strings
+ * and values are the new date values to be saved.
+ */
public function save_dates(cm_info $cm, array $dates) {
global $DB, $COURSE;
diff --git a/mod/nanogongdates.php b/mod/nanogongdates.php
index c43ac10..19c12b2 100644
--- a/mod/nanogongdates.php
+++ b/mod/nanogongdates.php
@@ -14,33 +14,73 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the nanogong module
+ *
+ * @copyright 2011 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 for the nanogong date extractor.
+ *
+ * Initializes the date extractor for nanogong modules by invoking
+ * the parent constructor with the course and 'nanogong' as the module type.
+ * Additionally, it loads necessary data related to the nanogongs.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'nanogong');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the nanogong module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the nanogong.
+ */
public function get_settings(cm_info $cm) {
$nanogong = $this->mods[$cm->instance];
- return array('timeavailable' => new report_editdates_date_setting(
+ return [
+ 'timeavailable' => new report_editdates_date_setting(
get_string('availabledate', 'mod_nanogong'),
$nanogong->timeavailable,
self::DATETIME, true),
- 'timedue' => new report_editdates_date_setting(
+ 'timedue' => new report_editdates_date_setting(
get_string('duedate', 'mod_nanogong'),
$nanogong->timedue,
- self::DATETIME, true)
- );
+ self::DATETIME, true),
+ ];
}
-
+ /**
+ * Validates the submitted dates for an nanogong activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the nanogong module.
+ * @return array an associative array of validation errors.
+ */
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..b4a40a1 100644
--- a/mod/ouwikidates.php
+++ b/mod/ouwikidates.php
@@ -12,36 +12,77 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see ..
+// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+defined('MOODLE_INTERNAL') || die;
require_once($CFG->dirroot.'/mod/ouwiki/lib.php');
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the assignment module
+ *
+ * @copyright 2011 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 {
+ /**
+ * Constructor for the ouwiki date extractor.
+ *
+ * Initializes the date extractor for ouwiki modules by invoking
+ * the parent constructor with the course and 'ouwiki' as the module type.
+ * Additionally, it loads necessary data related to the ouwikis.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'ouwiki');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the ouwiki module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the ouwiki.
+ */
public function get_settings(cm_info $cm) {
$mod = $this->mods[$cm->instance];
- return array('editbegin' => new report_editdates_date_setting(
+ return [
+ 'editbegin' => new report_editdates_date_setting(
get_string('editbegin', 'ouwiki'),
$mod->editbegin, self::DATETIME, true),
- 'editend' => new report_editdates_date_setting(
+ 'editend' => new report_editdates_date_setting(
get_string('editend', 'ouwiki'),
- $mod->editend, self::DATETIME, true)
- );
-
+ $mod->editend, self::DATETIME, true),
+ ];
}
-
+ /**
+ * Validates the submitted dates for an ouwiki activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the ouwiki module.
+ * @return array an associative array of validation errors.
+ */
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..7e4e4e6 100644
--- a/mod/pcastdates.php
+++ b/mod/pcastdates.php
@@ -14,36 +14,76 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the pcast module
+ *
+ * @copyright 2011 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 {
+ /**
+ * Constructor for the pcast date extractor.
+ *
+ * Initializes the date extractor for pcast modules by invoking
+ * the parent constructor with the course and 'pcast' as the module type.
+ * Additionally, it loads necessary data related to the pcasts.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'pcast');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the pcast module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the pcast.
+ */
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(
+ return [
+ 'assesstimestart' => new report_editdates_date_setting(
get_string('from'),
$mod->assesstimestart,
self::DATETIME, false),
- 'assesstimefinish' => new report_editdates_date_setting(
+ 'assesstimefinish' => new report_editdates_date_setting(
get_string('to'),
$mod->assesstimefinish,
- self::DATETIME, false)
- );
+ self::DATETIME, false),
+ ];
}
return null;
}
-
+ /**
+ * Validates the submitted dates for an pcast activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the pcast module.
+ * @return array an associative array of validation errors.
+ */
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..adac5df 100644
--- a/mod/questionnairedates.php
+++ b/mod/questionnairedates.php
@@ -12,34 +12,76 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see ..
+// along with Moodle. If not, see .
+
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
defined('MOODLE_INTERNAL') || die;
require_once($CFG->dirroot.'/mod/questionnaire/lib.php');
-
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the questionnaire module
+ *
+ * @copyright 2011 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 for the questionnaire date extractor.
+ *
+ * Initializes the date extractor for questionnaire modules by invoking
+ * the parent constructor with the course and 'questionnaire' as the module type.
+ * Additionally, it loads necessary data related to the questionnaires.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'questionnaire');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the questionnaire module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the questionnaire.
+ */
public function get_settings(cm_info $cm) {
$mod = $this->mods[$cm->instance];
- return array('opendate' => new report_editdates_date_setting(
+ return [
+ 'opendate' => new report_editdates_date_setting(
get_string('opendate', 'questionnaire'),
$mod->opendate, self::DATETIME, true),
- 'closedate' => new report_editdates_date_setting(
+ 'closedate' => new report_editdates_date_setting(
get_string('closedate', 'questionnaire'),
$mod->closedate, self::DATETIME, true),
- );
+ ];
}
-
+ /**
+ * Validates the submitted dates for an questionnaire activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the questionnaire module.
+ * @return array an associative array of validation errors.
+ */
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 +89,16 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ /**
+ * Save the new dates for an questionnaire activity.
+ *
+ * This method updates the questionnaire instance with the new date values provided,
+ * and triggers the necessary calendar event updates and gradebook updates.
+ *
+ * @param cm_info $cm The course module information.
+ * @param array $dates An associative array where keys are date type strings
+ * and values are the new date values to be saved.
+ */
public function save_dates(cm_info $cm, array $dates) {
global $DB, $COURSE;
diff --git a/mod/quizdates.php b/mod/quizdates.php
index 30d077c..e35f594 100644
--- a/mod/quizdates.php
+++ b/mod/quizdates.php
@@ -12,34 +12,74 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see ..
+// along with Moodle. If not, see .
+
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
defined('MOODLE_INTERNAL') || die;
require_once($CFG->dirroot.'/mod/quiz/lib.php');
-
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the quiz module
+ *
+ * @copyright 2011 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 {
+ extends report_editdates_mod_date_extractor {
+ /**
+ * Constructor.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'quiz');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the quiz module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeopen', 'timeclose')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the quiz.
+ */
public function get_settings(cm_info $cm) {
$quiz = $this->mods[$cm->instance];
- return array('timeopen' => new report_editdates_date_setting(
+ return [
+ 'timeopen' => new report_editdates_date_setting(
get_string('quizopen', 'quiz'),
$quiz->timeopen, self::DATETIME, true),
- 'timeclose' => new report_editdates_date_setting(
+ 'timeclose' => new report_editdates_date_setting(
get_string('quizclose', 'quiz'),
- $quiz->timeclose, self::DATETIME, true)
- );
+ $quiz->timeclose, self::DATETIME, true),
+ ];
}
+
+ /**
+ * Validate the submitted dates for this course_module instance.
+ *
+ * @param cm_info $cm 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.
+ * @return array Any validation errors. The array keys need to
+ * match the keys returned by get_settings().
+ * Return an empty array if there are no erros.
+ */
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 +87,16 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ /**
+ * Save the new dates for an quiz activity.
+ *
+ * This method updates the quiz instance with the new date values provided,
+ * and triggers the necessary calendar event updates and gradebook updates.
+ *
+ * @param cm_info $cm The course module information.
+ * @param array $dates An associative array where keys are date type strings
+ * and values are the new date values to be saved.
+ */
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..d18a4aa 100644
--- a/mod/scormdates.php
+++ b/mod/scormdates.php
@@ -12,34 +12,76 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see ..
+// along with Moodle. If not, see .
+
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
defined('MOODLE_INTERNAL') || die;
require_once($CFG->dirroot.'/mod/scorm/lib.php');
-
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the scorm module
+ *
+ * @copyright 2011 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 for the scorm date extractor.
+ *
+ * Initializes the date extractor for scorm modules by invoking
+ * the parent constructor with the course and 'scorm' as the module type.
+ * Additionally, it loads necessary data related to the scorms.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'scorm');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the scorm module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the scorm.
+ */
public function get_settings(cm_info $cm) {
$mod = $this->mods[$cm->instance];
- return array('timeopen' => new report_editdates_date_setting(
+ return [
+ 'timeopen' => new report_editdates_date_setting(
get_string("scormopen", "scorm"),
$mod->timeopen, self::DATETIME, true),
- 'timeclose' => new report_editdates_date_setting(
+ 'timeclose' => new report_editdates_date_setting(
get_string("scormclose", "scorm"),
- $mod->timeclose, self::DATETIME, true)
- );
+ $mod->timeclose, self::DATETIME, true),
+ ];
}
-
+ /**
+ * Validates the submitted dates for an scorm activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the scorm module.
+ * @return array an associative array of validation errors.
+ */
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..4f034d8 100644
--- a/mod/turnitintooltwodates.php
+++ b/mod/turnitintooltwodates.php
@@ -14,17 +14,46 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die;
-
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the turnitintooltwo module
+ *
+ * @copyright 2011 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 {
+ /**
+ * Constructor for the turnitintooltwo date extractor.
+ *
+ * Initializes the date extractor for turnitintooltwo modules by invoking
+ * the parent constructor with the course and 'turnitintooltwo' as the module type.
+ * Additionally, it loads necessary data related to the turnitintooltwos.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'turnitintooltwo');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the turnitintooltwo module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the turnitintooltwo.
+ */
public function get_settings(cm_info $cm) {
global $DB;
$tii = $this->mods[$cm->instance];
@@ -51,11 +80,21 @@ public function get_settings(cm_info $cm) {
return $elems;
}
-
+ /**
+ * Validates the submitted dates for an turnitintooltwo activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the turnitintooltwo module.
+ * @return array an associative array of validation errors.
+ */
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 +111,16 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ /**
+ * Save the new dates for an turnitintooltwo activity.
+ *
+ * This method updates the turnitintooltwo instance with the new date values provided,
+ * and triggers the necessary calendar event updates and gradebook updates.
+ *
+ * @param cm_info $cm The course module information.
+ * @param array $dates An associative array where keys are date type strings
+ * and values are the new date values to be saved.
+ */
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..0754bc4 100644
--- a/mod/workshopdates.php
+++ b/mod/workshopdates.php
@@ -12,40 +12,82 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see ..
+// along with Moodle. If not, see .
+
+/**
+ * This is form to display the modules for editdates reports
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
defined('MOODLE_INTERNAL') || die;
require_once($CFG->dirroot.'/mod/quiz/lib.php');
-
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the workshop module
+ *
+ * @copyright 2011 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 for the workshop date extractor.
+ *
+ * Initializes the date extractor for workshop modules by invoking
+ * the parent constructor with the course and 'workshop' as the module type.
+ * Additionally, it loads necessary data related to the workshops.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'workshop');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the workshop module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the workshop.
+ */
public function get_settings(cm_info $cm) {
$workshop = $this->mods[$cm->instance];
- return array('submissionstart' => new report_editdates_date_setting(
+ return [
+ 'submissionstart' => new report_editdates_date_setting(
get_string('submissionstart', 'workshop'),
$workshop->submissionstart, self::DATETIME, true),
- 'submissionend' => new report_editdates_date_setting(
+ 'submissionend' => new report_editdates_date_setting(
get_string('submissionend', 'workshop'),
$workshop->submissionend, self::DATETIME, true),
- 'assessmentstart' => new report_editdates_date_setting(
+ 'assessmentstart' => new report_editdates_date_setting(
get_string('assessmentstart', 'workshop'),
$workshop->assessmentstart, self::DATETIME, true),
- 'assessmentend' => new report_editdates_date_setting(
+ 'assessmentend' => new report_editdates_date_setting(
get_string('assessmentend', 'workshop'),
$workshop->assessmentend, self::DATETIME, true),
- );
+ ];
}
-
+ /**
+ * Validates the submitted dates for an workshop activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the workshop module.
+ * @return array an associative array of validation errors.
+ */
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 +108,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 +120,16 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ /**
+ * Save the new dates for an workshop activity.
+ *
+ * This method updates the workshop instance with the new date values provided,
+ * and triggers the necessary calendar event updates and gradebook updates.
+ *
+ * @param cm_info $cm The course module information.
+ * @param array $dates An associative array where keys are date type strings
+ * and values are the new date values to be saved.
+ */
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..86ef17f 100644
--- a/mod/zoomdates.php
+++ b/mod/zoomdates.php
@@ -14,35 +14,76 @@
// 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
+ *
+ * @package report_editdates
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
defined('MOODLE_INTERNAL') || die;
require_once($CFG->dirroot.'/mod/zoom/locallib.php');
-
+/**
+ * Simple class capturing the information needed to check
+ * date settings for the zoom module
+ *
+ * @copyright 2011 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 for the zoom date extractor.
+ *
+ * Initializes the date extractor for zoom modules by invoking
+ * the parent constructor with the course and 'zoom' as the module type.
+ * Additionally, it loads necessary data related to the zooms.
+ *
+ * @param stdClass $course The course object.
+ */
public function __construct($course) {
parent::__construct($course, 'zoom');
parent::load_data();
}
+ /**
+ * Get a list of date settings for the zoom module instance.
+ *
+ * @param cm_info $cm The course module information.
+ * @return array An array where the keys are setting names ('timeavailable', 'timedue')
+ * and the values are report_editdates_date_setting objects containing
+ * the date settings for the zoom.
+ */
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),
- );
+ ];
}
}
-
+ /**
+ * Validates the submitted dates for an zoom activity.
+ *
+ * This function takes in the course module information and an associative array of date
+ * settings and returns an associative array of validation errors. The keys of the returned
+ * array are the same as the keys of the input array, and the values are error strings.
+ *
+ * @param cm_info $cm the course module information.
+ * @param array $dates an associative array of date settings for the zoom module.
+ * @return array an associative array of validation errors.
+ */
public function validate_dates(cm_info $cm, array $dates) {
- $errors = array();
+ $errors = [];
$zoom = $this->mods[$cm->instance];
if (empty($zoom->recurring)) {
@@ -56,6 +97,16 @@ public function validate_dates(cm_info $cm, array $dates) {
return $errors;
}
+ /**
+ * Save the new dates for an zoom activity.
+ *
+ * This method updates the zoom instance with the new date values provided,
+ * and triggers the necessary calendar event updates and gradebook updates.
+ *
+ * @param cm_info $cm The course module information.
+ * @param array $dates An associative array where keys are date type strings
+ * and values are the new date values to be saved.
+ */
public function save_dates(cm_info $cm, array $dates) {
// Fetch module instance from $mods array.
$zoom = $this->mods[$cm->instance];
diff --git a/readme.md b/readme.md
index 3bec416..32b1636 100644
--- a/readme.md
+++ b/readme.md
@@ -41,3 +41,15 @@ For other plugins, there is the option to put the class in the other plugin.
You need to make a class called `mod_`_mymodname_`_report_editdates_integration`,
which therefore goes in mod/_mymodname_/classes/report_editdates_integration.php.
For blocks, the equivalent class is `block_`_myblock_`_report_editdates_integration`.
+
+## Available callbacks
+
+To be aligned with a core extension point for the activity form via core callbacks,
+this plugin allows developers to extend dates form the same way.
+
+Supported callbacks:
+
+* report_editdates_form_elements
+* report_editdates_form_definition_after_data
+* report_editdates_form_validation
+* report_editdates_form_post_actions
\ No newline at end of file
diff --git a/tests/behat/basic.feature b/tests/behat/basic.feature
index 0469720..6651b51 100644
--- a/tests/behat/basic.feature
+++ b/tests/behat/basic.feature
@@ -15,11 +15,9 @@ Feature: Edit course plugin dates
| user | course | role |
| teacher1 | C1 | editingteacher |
| 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 |
+ And the following "activities" exist:
+ | activity | name | intro | course |
+ | quiz | Test quiz name 1 | Test quiz description | C1 |
Given I log out
@javascript @_switch_iframe
@@ -28,7 +26,7 @@ Feature: Edit course plugin dates
And I navigate to "Reports > Dates" in current page administration
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" "css_element"
Then I should see "Course start date"
And I should see "Test quiz name 1"
@@ -38,7 +36,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" "css_element"
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..7955c41 100644
--- a/tests/behat/course_report_editdates.feature
+++ b/tests/behat/course_report_editdates.feature
@@ -17,9 +17,10 @@ Feature: Edit dates report navigation
| student1 | C1 | student |
@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"
+ Scenario: Selector should be available in the Dates report page
+ Given I log in as "admin"
+ And I am on "Course 1" course homepage
+ 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..3c786f6 100644
--- a/tests/behat/timeline.feature
+++ b/tests/behat/timeline.feature
@@ -13,18 +13,9 @@ Feature: Timeline view
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
- 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 |
+ And the following "activities" exist:
+ | activity | name | course |
+ | quiz | Test quiz | C1 |
Given I log out
@javascript @_switch_iframe
@@ -32,17 +23,39 @@ Feature: Timeline view
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 follow "Test quiz"
+ And I follow "Settings"
+ And I expand all fieldsets
+ And I set the following fields to these values:
+ | timeopen[enabled] | 1 |
+ | timeopen[day] | 1 |
+ | timeopen[month] | January |
+ | timeopen[year] | 2025 |
+ | timeopen[hour] | 08 |
+ | timeopen[minute] | 00 |
+ And I press "Save and return to course"
And I navigate to "Reports > Dates" in current page administration
- Then I should see "12/31/2019"
- And I should see "1/1/2020"
- And I should see "1/2/2020"
+ Then I should see "12/31/2024"
+ And I should see "1/1/2025"
+ And I should see "1/2/2025"
@javascript @_switch_iframe
Scenario: Test edit dates report to see if timeline view is hidden
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 follow "Test quiz"
+ And I follow "Settings"
+ And I expand all fieldsets
+ And I set the following fields to these values:
+ | timeopen[enabled] | 1 |
+ | timeopen[day] | 1 |
+ | timeopen[month] | January |
+ | timeopen[year] | 2025 |
+ | timeopen[hour] | 08 |
+ | timeopen[minute] | 00 |
+ And I press "Save and return to course"
And I navigate to "Reports > Dates" in current page administration
- Then I should not see "12/31/2019"
- And I should not see "1/1/2020"
- And I should not see "1/2/2020"
+ Then I should not see "12/31/2024"
+ And I should not see "1/1/2025"
+ And I should not see "1/2/2025"
diff --git a/version.php b/version.php
index 0dfacb4..b29b2b5 100644
--- a/version.php
+++ b/version.php
@@ -24,10 +24,10 @@
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2022051600;
+$plugin->version = 2022051600.01;
$plugin->requires = 2020061500;
$plugin->component = 'report_editdates';
$plugin->maturity = MATURITY_STABLE;
-$plugin->release = '3.0 for Moodle 3.11+';
+$plugin->release = 'Custom Rose-Changes Build';
$plugin->outestssufficient = true;