Skip to content

Commit

Permalink
codecleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaroWalter committed May 28, 2024
1 parent 730b256 commit 334f619
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions classes/task/send_daily_mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public function execute() {
$mail = [];
// Fill the $mail array.
foreach ($userdata as $row) {
$currentcourse = $DB->get_record('course', array('id' => $row->courseid), 'fullname, id');
$currentcourse = $DB->get_record('course', ['id' => $row->courseid], 'fullname, id');
// Check if the user is enrolled in the course, if not, go to the next row.
if (!is_enrolled(\context_course::instance($row->courseid), $user->userid, '', true)) {
continue;
}

$currentforum = $DB->get_record('moodleoverflow', array('id' => $row->forumid), 'name, id');
$currentforum = $DB->get_record('moodleoverflow', ['id' => $row->forumid], 'name, id');
$coursemoduleid = get_coursemodule_from_instance('moodleoverflow', $row->forumid);
$discussion = $DB->get_record('moodleoverflow_discussions', ['id' => $row->forumdiscussionid], 'name, id');
$unreadposts = $row->numberofposts;
Expand Down
4 changes: 2 additions & 2 deletions tests/dailymail_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function tearDown(): void {
public function helper_create_user_and_discussion($maildigest) {
// Create a user enrolled in the course as student.
$this->user = $this->getDataGenerator()->create_user(['firstname' => 'Tamaro', 'email' => '[email protected]',
'maildigest' => $maildigest]);
'maildigest' => $maildigest, ]);
$this->getDataGenerator()->enrol_user($this->user->id, $this->course->id, 'student');

// Create a new discussion and post within the moodleoverflow.
Expand Down Expand Up @@ -165,7 +165,7 @@ public function test_delivery_not_enrolled(): void {
$location = ['course' => $course->id, 'forcesubscribe' => MOODLEOVERFLOW_FORCESUBSCRIBE];
$moodleoverflow = $this->getDataGenerator()->create_module('moodleoverflow', $location);
$student = $this->getDataGenerator()->create_user(['firstname' => 'Ethan', 'email' => '[email protected]',
'maildigest' => '1']);
'maildigest' => '1', ]);
$this->getDataGenerator()->enrol_user($student->id, $course->id, 'teacher');
$discussion = $this->generator->post_to_forum($moodleoverflow, $student);

Expand Down
16 changes: 8 additions & 8 deletions tests/review_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,23 +307,23 @@ private function check_mail_records($teacherpost, $studentpost, $review1, $revie
global $DB;

// Fetch the posts directly after creation
$teacherpostDB = $DB->get_record('moodleoverflow_posts', ['id' => $teacherpost->id]);
$studentpostDB = $DB->get_record('moodleoverflow_posts', ['id' => $studentpost->id]);
$teacherpostdb = $DB->get_record('moodleoverflow_posts', ['id' => $teacherpost->id]);
$studentpostdb = $DB->get_record('moodleoverflow_posts', ['id' => $studentpost->id]);

// Assert initial state
$this->assert_matches_properties(['mailed' => MOODLEOVERFLOW_MAILED_PENDING, 'reviewed' => $review1, 'timereviewed' => null], $teacherpostDB);
$this->assert_matches_properties(['mailed' => MOODLEOVERFLOW_MAILED_PENDING, 'reviewed' => $review2, 'timereviewed' => null], $studentpostDB);
$this->assert_matches_properties(['mailed' => MOODLEOVERFLOW_MAILED_PENDING, 'reviewed' => $review1, 'timereviewed' => null], $teacherpostdb);
$this->assert_matches_properties(['mailed' => MOODLEOVERFLOW_MAILED_PENDING, 'reviewed' => $review2, 'timereviewed' => null], $studentpostdb);

$this->run_send_mails();
$this->run_send_mails(); // Execute twice to ensure no duplicate mails.

// Fetch the posts after mailing
$teacherpostDB = $DB->get_record('moodleoverflow_posts', ['id' => $teacherpost->id]);
$studentpostDB = $DB->get_record('moodleoverflow_posts', ['id' => $studentpost->id]);
$teacherpostdb = $DB->get_record('moodleoverflow_posts', ['id' => $teacherpost->id]);
$studentpostdb = $DB->get_record('moodleoverflow_posts', ['id' => $studentpost->id]);

// Assert post-mail state
$this->assert_matches_properties(['mailed' => MOODLEOVERFLOW_MAILED_SUCCESS, 'reviewed' => $review1, 'timereviewed' => null], $teacherpostDB);
$this->assert_matches_properties(['mailed' => $mailed, 'reviewed' => $review2, 'timereviewed' => null], $studentpostDB);
$this->assert_matches_properties(['mailed' => MOODLEOVERFLOW_MAILED_SUCCESS, 'reviewed' => $review1, 'timereviewed' => null], $teacherpostdb);
$this->assert_matches_properties(['mailed' => $mailed, 'reviewed' => $review2, 'timereviewed' => null], $studentpostdb);
}

}
4 changes: 2 additions & 2 deletions tests/subscriptions_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ public function is_subscribable_moodleoverflows() {
*
* @return array
*/
public function is_subscribable_provider() {
public function is_subscribable_provider(): array {
$data = [];
foreach ($this->is_subscribable_moodleoverflows() as $moodleoverflow) {
$data[] = [$moodleoverflow];
Expand Down Expand Up @@ -1440,7 +1440,7 @@ public function test_is_subscribable_is_guest($options): void {
* Returns subscription obtions.
* @return array
*/
public function is_subscribable_loggedin_provider() {
public function is_subscribable_loggedin_provider(): array {
return [
[
['forcesubscribe' => MOODLEOVERFLOW_DISALLOWSUBSCRIBE],
Expand Down

0 comments on commit 334f619

Please sign in to comment.