diff --git a/lang/en/hub.php b/lang/en/hub.php index dbc1d1e2e70..424a0c57b86 100644 --- a/lang/en/hub.php +++ b/lang/en/hub.php @@ -37,7 +37,7 @@ $string['badgesnumber'] = 'Number of badges ({$a})'; $string['communityremoved'] = 'That course link has been removed from your list'; $string['confirmregistration'] = 'Confirm registration'; $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['courseshortname'] = 'Shortname'; $string['courseshortname_help'] = 'Enter a short name for your course. It does not need to be unique.'; diff --git a/lib/classes/hub/registration.php b/lib/classes/hub/registration.php index 7b67c9e5b59..6a301fa6315 100644 --- a/lib/classes/hub/registration.php +++ b/lib/classes/hub/registration.php @@ -183,7 +183,7 @@ class registration { $siteinfo['activeparticipantnumberaverage'] = average_number_of_participants(true, time() - DAYSECS * 30); $siteinfo['modulenumberaverage'] = average_number_of_courses_modules(); $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'); // Primary auth type. diff --git a/lib/tests/hub/registration_test.php b/lib/tests/hub/registration_test.php index a7d25a7a59a..d0ab3885d8a 100644 --- a/lib/tests/hub/registration_test.php +++ b/lib/tests/hub/registration_test.php @@ -34,11 +34,20 @@ class registration_test extends \advanced_testcase { */ public function test_get_site_info(): void { 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(); $this->assertNull($siteinfo['policyagreed']); $this->assertEquals($CFG->dbtype, $siteinfo['dbtype']); $this->assertEquals('manual', $siteinfo['primaryauthtype']); + $this->assertEquals(1, $siteinfo['coursesnodates']); } }