MDL-78048 Site Registration: Course Dates

Course date registration data reports correctly.

MDL-77306 added a count of how many courses there are
without start and end dates. However, all courses have
a start date, it is only the end date that is optional.
This patch fixes the data collection and makes the lang
string describing it clearer.
This commit is contained in:
Matt Porritt 2023-04-27 17:46:38 +10:00
parent 063ffc8073
commit 9fa50d04d6
3 changed files with 11 additions and 2 deletions

View file

@ -37,7 +37,7 @@ $string['badgesnumber'] = 'Number of badges ({$a})';
$string['communityremoved'] = 'That course link has been removed from your list'; $string['communityremoved'] = 'That course link has been removed from your list';
$string['confirmregistration'] = 'Confirm registration'; $string['confirmregistration'] = 'Confirm registration';
$string['coursename'] = 'Name'; $string['coursename'] = 'Name';
$string['coursesnodates'] = 'Number of courses without start and end dates set ({$a})'; $string['coursesnodates'] = 'Number of courses without an end date set ({$a})';
$string['coursepublished'] = 'This course has been shared successfully on \'{$a}\'.'; $string['coursepublished'] = 'This course has been shared successfully on \'{$a}\'.';
$string['courseshortname'] = 'Shortname'; $string['courseshortname'] = 'Shortname';
$string['courseshortname_help'] = 'Enter a short name for your course. It does not need to be unique.'; $string['courseshortname_help'] = 'Enter a short name for your course. It does not need to be unique.';

View file

@ -183,7 +183,7 @@ class registration {
$siteinfo['activeparticipantnumberaverage'] = average_number_of_participants(true, time() - DAYSECS * 30); $siteinfo['activeparticipantnumberaverage'] = average_number_of_participants(true, time() - DAYSECS * 30);
$siteinfo['modulenumberaverage'] = average_number_of_courses_modules(); $siteinfo['modulenumberaverage'] = average_number_of_courses_modules();
$siteinfo['dbtype'] = $CFG->dbtype; $siteinfo['dbtype'] = $CFG->dbtype;
$siteinfo['coursesnodates'] = $DB->count_records_select('course', 'startdate = ? AND enddate = ?', [0, 0]) - 1; $siteinfo['coursesnodates'] = $DB->count_records_select('course', 'enddate = ?', [0]) - 1;
$siteinfo['sitetheme'] = get_config('core', 'theme'); $siteinfo['sitetheme'] = get_config('core', 'theme');
// Primary auth type. // Primary auth type.

View file

@ -34,11 +34,20 @@ class registration_test extends \advanced_testcase {
*/ */
public function test_get_site_info(): void { public function test_get_site_info(): void {
global $CFG; global $CFG;
$this->resetAfterTest();
// Create some courses with end dates.
$generator = $this->getDataGenerator();
$generator->create_course(['enddate' => time() + 1000]);
$generator->create_course(['enddate' => time() + 1000]);
$generator->create_course(); // Course with no end date.
$siteinfo = registration::get_site_info(); $siteinfo = registration::get_site_info();
$this->assertNull($siteinfo['policyagreed']); $this->assertNull($siteinfo['policyagreed']);
$this->assertEquals($CFG->dbtype, $siteinfo['dbtype']); $this->assertEquals($CFG->dbtype, $siteinfo['dbtype']);
$this->assertEquals('manual', $siteinfo['primaryauthtype']); $this->assertEquals('manual', $siteinfo['primaryauthtype']);
$this->assertEquals(1, $siteinfo['coursesnodates']);
} }
} }