Skip to content

Commit

Permalink
Merge branch 'master_MDL-78048' of https://github.com/mattporritt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed May 18, 2023
2 parents 63290dc + 9fa50d0 commit 5fd0a51
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lang/en/hub.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
$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.';
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/hub/registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public static function get_site_info($defaults = []) {
$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.
Expand Down
9 changes: 9 additions & 0 deletions lib/tests/hub/registration_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}

0 comments on commit 5fd0a51

Please sign in to comment.