Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions form.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public function definition() {
$mform->addElement('hidden', 'activitytype', $activitytype);
$mform->setType('activitytype', PARAM_PLUGIN);

// Add number activities warning
$mform->addElement('html', '<p>' . get_string('numactivitieswarning', 'report_editdates') . '</p>');

// Invisible static element. Used as the holder for a validation message sometimes.
$mform->addElement('static', 'topvalidationsite', '', '');

Expand Down
16 changes: 16 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
require_once(dirname(__FILE__) . '/form.php');
use core\report_helper;

$enablefilterthreshold = get_config('report_editdates', 'enablefilterthreshold');

$id = required_param('id', PARAM_INT);
$activitytype = optional_param('activitytype', '', PARAM_PLUGIN);

Expand Down Expand Up @@ -76,6 +78,20 @@
}
core_collator::asort($activitytypes);

// Append number of activities to the all activities option
$activitytypes["all"] .= (' (' . $activitiesdisplayed . ')');

// If activity count is above the threshold, activate the filter controls.
if (!$activitytype && $activitiesdisplayed > $enablefilterthreshold) {
if (count($activitytypes) > 1) {
$activitytypekey = array_keys($activitytypes)[1];
} else {
$activitytypekey = array_keys($activitytypes)[0];
}
redirect(new moodle_url('/report/editdates/index.php',
array('id' => $id, 'activitytype' => $activitytypekey)));
}

// Creating the form.
$baseurl = new moodle_url('/report/editdates/index.php', ['id' => $id]);
$mform = new report_editdates_form(
Expand Down
3 changes: 3 additions & 0 deletions lang/en/report_editdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
$string['editdates'] = 'Dates';
$string['editdates:view'] = 'View edit dates course report';
$string['editend'] = 'Prevent editing from cannot be less than Allow editing from';
$string['enablefilterthreshold'] = 'Enable filter threshold';
$string['enablefilterthresholddesc'] = 'Maximum number of activities before enabling filter.';
$string['numactivitieswarning'] = 'With a large number of activites, this form may take a long time to display.';
$string['editrestrictedaccess'] = 'Edit restricted access (opens a new window)';
$string['event:reportviewed'] = 'Edit dates report viewed';
$string['hasrestrictedaccess'] = '{$a} has restricted date access settings';
Expand Down
5 changes: 5 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@
get_string('timelinemaxdesc', 'report_editdates'),
3,
$options));
$settings->add(new admin_setting_configtext('report_editdates/enablefilterthreshold',
get_string('enablefilterthreshold', 'report_editdates'),
get_string('enablefilterthresholddesc', 'report_editdates'),
40,
PARAM_INT));
}