diff --git a/classes/task/get_meeting_reports.php b/classes/task/get_meeting_reports.php index 22efd7fd..75c0d0a8 100644 --- a/classes/task/get_meeting_reports.php +++ b/classes/task/get_meeting_reports.php @@ -268,7 +268,7 @@ public function format_participant($participant, $detailsid, $names, $emails) { } } - if ($participant->user_email == '') { + if ($participant->user_email === '') { if (!empty($moodleuserid)) { $participant->user_email = $DB->get_field('user', 'email', ['id' => $moodleuserid]); } else { @@ -276,7 +276,7 @@ public function format_participant($participant, $detailsid, $names, $emails) { } } - if ($participant->id == '') { + if ($participant->id === '') { $participant->id = null; } @@ -484,7 +484,7 @@ public function debugmsg($msg) { * @return boolean */ public function process_meeting_reports($meeting) { - global $DB, $CFG; + global $DB; $this->debugmsg(sprintf( 'Processing meeting %s|%s that occurred at %s', @@ -558,7 +558,7 @@ public function process_meeting_reports($meeting) { 'detailsid' => $participant['detailsid'], 'zoomuserid' => $participant['zoomuserid'], 'join_time' => $participant['join_time'], - 'leave_time' => $participant['leave_time'] + 'leave_time' => $participant['leave_time'], ]; // Check if the record already exists. @@ -648,7 +648,7 @@ public function grading_participant_upon_duration($zoomrecord, $detailsid) { // Check if there is old duration stored for this user. if (!empty($durations[$userid])) { - $old = new \stdClass; + $old = new \stdClass(); $old->duration = $durations[$userid]; $old->join_time = $join[$userid]; $old->leave_time = $leave[$userid]; @@ -725,7 +725,6 @@ public function grading_participant_upon_duration($zoomrecord, $detailsid) { } else { $notenrolled[$userid] = fullname(\core_user::get_user($userid)); } - } else { // This means that this user was not identified. // Provide information about participants that need to be graded manually. @@ -825,7 +824,7 @@ public function notify_teachers($data) { $needgradenumber = count($data['needgrade']); // List of users need grading. $needstring = get_string('grading_needgrade', 'mod_zoom'); - $needgrade = (!empty($data['needgrade'])) ? $needstring.implode('
', $data['needgrade'])."\n" : ''; + $needgrade = (!empty($data['needgrade'])) ? $needstring . implode('
', $data['needgrade']) . "\n" : ''; $zoomid = $data['zoomid']; $itemid = $data['itemid']; @@ -903,7 +902,7 @@ public function notify_teachers($data) { $message->contexturl = $gurl; // This link redirect the teacher to the page of item's grades. $message->contexturlname = get_string('gradinglink', 'mod_zoom'); // Email content. - $content = array('*' => array('header' => $message->subject, 'footer' => '')); + $content = ['*' => ['header' => $message->subject, 'footer' => '']]; $message->set_additional_content('email', $content); $messageids = []; if (!empty($teachers)) { @@ -995,9 +994,10 @@ public function get_users_clicked_join($zoomrecord) { $userids = []; foreach ($events as $event) { - if ($event->other['meetingid'] == $zoomrecord->meeting_id && - !in_array($event->userid, $userids)) { - + if ( + $event->other['meetingid'] === $zoomrecord->meeting_id && + !in_array($event->userid, $userids, true) + ) { $userids[] = $event->userid; } } diff --git a/settings.php b/settings.php index 9ca96cb6..a5405c24 100644 --- a/settings.php +++ b/settings.php @@ -254,8 +254,13 @@ 'idfullname' => get_string('displayidfullname', 'mod_zoom'), 'id' => get_string('displayid', 'mod_zoom'), ]; - $settings->add(new admin_setting_configselect('zoom/unamedisplay', get_string('unamedisplay', 'mod_zoom'), - get_string('unamedisplay_help', 'mod_zoom'), 'fullname', $options)); + $settings->add(new admin_setting_configselect( + 'zoom/unamedisplay', + get_string('unamedisplay', 'mod_zoom'), + get_string('unamedisplay_help', 'mod_zoom'), + 'fullname', + $options + )); // Supplementary features settings. $settings->add(new admin_setting_heading( @@ -627,9 +632,11 @@ } // Adding options for grading methods. - $settings->add(new admin_setting_heading('zoom/gradingmethod', - get_string('gradingmethod_heading', 'mod_zoom'), - get_string('gradingmethod_heading_help', 'mod_zoom'))); + $settings->add(new admin_setting_heading( + 'zoom/gradingmethod', + get_string('gradingmethod_heading', 'mod_zoom'), + get_string('gradingmethod_heading_help', 'mod_zoom') + )); // Grading method upon entry: the user gets the full score when clicking to join the session through Moodle. // Grading method upon period: the user is graded based on how long they attended the actual session. @@ -637,6 +644,11 @@ 'entry' => get_string('gradingentry', 'mod_zoom'), 'period' => get_string('gradingperiod', 'mod_zoom'), ]; - $settings->add(new admin_setting_configselect('zoom/gradingmethod', get_string('gradingmethod', 'mod_zoom'), - get_string('gradingmethod_help', 'mod_zoom'), 'entry', $options)); + $settings->add(new admin_setting_configselect( + 'zoom/gradingmethod', + get_string('gradingmethod', 'mod_zoom'), + get_string('gradingmethod_help', 'mod_zoom'), + 'entry', + $options + )); } diff --git a/tests/get_meeting_reports_test.php b/tests/get_meeting_reports_test.php index df52875a..66019ac9 100644 --- a/tests/get_meeting_reports_test.php +++ b/tests/get_meeting_reports_test.php @@ -430,7 +430,7 @@ public function test_grading_method() { $context = \context_course::instance($course->id); $graders = get_users_by_capability($context, 'moodle/grade:edit'); $this->assertEquals(1, count($graders)); - $firstkey = array_key_first($graders); + $firstkey = key($graders); $this->assertEquals($graders[$firstkey]->id, $teacher->id); // Now fake the meeting details. $meeting = new stdClass(); @@ -444,14 +444,14 @@ public function test_grading_method() { // Create a new zoom instance. $params = [ - 'course' => $course->id, - 'meeting_id' => $meeting->id, - 'grade' => 60, - 'name' => 'Zoom', - 'exists_on_zoom' => ZOOM_MEETING_EXISTS, - 'start_time' => strtotime('2020-04-01T15:00:00Z'), - 'duration' => 120 * 60, // In seconds. - ]; + 'course' => $course->id, + 'meeting_id' => $meeting->id, + 'grade' => 60, + 'name' => 'Zoom', + 'exists_on_zoom' => ZOOM_MEETING_EXISTS, + 'start_time' => strtotime('2020-04-01T15:00:00Z'), + 'duration' => 120 * 60, // In seconds. + ]; $generator = $this->getDataGenerator()->get_plugin_generator('mod_zoom'); $instance = $generator->create_instance($params); @@ -494,7 +494,7 @@ public function test_grading_method() { foreach ($users as $user) { $this->getDataGenerator()->enrol_user($user->id, $course->id); } - list($names, $emails) = $this->meetingtask->get_enrollments($course->id); + [$names, $emails] = $this->meetingtask->get_enrollments($course->id); // Create a participant with 5 min overlap. // Total time 35 min, total grade 17.5 . @@ -505,7 +505,7 @@ public function test_grading_method() { 'user_email' => '', 'join_time' => '2023-05-01T15:05:00Z', 'leave_time' => '2023-05-01T15:35:00Z', - 'duration' => 30 * 60 + 'duration' => 30 * 60, ]; $participants[1] = (object)$this->meetingtask->format_participant($rawparticipants[1], $detailsid, $names, $emails); $rawparticipants[2] = (object)[ @@ -515,7 +515,7 @@ public function test_grading_method() { 'user_email' => '', 'join_time' => '2023-05-01T15:30:00Z', 'leave_time' => '2023-05-01T15:40:00Z', - 'duration' => 10 * 60 + 'duration' => 10 * 60, ]; $participants[2] = (object)$this->meetingtask->format_participant($rawparticipants[2], $detailsid, $names, $emails); $overlap = $this->meetingtask->get_participant_overlap_time($participants[1], $participants[2]); @@ -533,7 +533,7 @@ public function test_grading_method() { 'user_email' => '', 'join_time' => '2023-05-01T15:00:00Z', 'leave_time' => '2023-05-01T16:00:00Z', - 'duration' => 60 * 60 + 'duration' => 60 * 60, ]; $participants[3] = (object)$this->meetingtask->format_participant($rawparticipants[3], $detailsid, $names, $emails); $rawparticipants[4] = (object)[ @@ -543,7 +543,7 @@ public function test_grading_method() { 'user_email' => '', 'join_time' => '2023-05-01T15:30:00Z', 'leave_time' => '2023-05-01T16:00:00Z', - 'duration' => 30 * 60 + 'duration' => 30 * 60, ]; $participants[4] = (object)$this->meetingtask->format_participant($rawparticipants[4], $detailsid, $names, $emails); $overlap = $this->meetingtask->get_participant_overlap_time($participants[3], $participants[4]); @@ -561,7 +561,7 @@ public function test_grading_method() { 'user_email' => '', 'join_time' => '2023-05-01T15:10:00Z', 'leave_time' => '2023-05-01T16:00:00Z', - 'duration' => 50 * 60 + 'duration' => 50 * 60, ]; $participants[5] = (object)$this->meetingtask->format_participant($rawparticipants[5], $detailsid, $names, $emails); $rawparticipants[6] = (object)[ @@ -571,7 +571,7 @@ public function test_grading_method() { 'user_email' => '', 'join_time' => '2023-05-01T16:30:00Z', 'leave_time' => '2023-05-01T16:40:00Z', - 'duration' => 10 * 60 + 'duration' => 10 * 60, ]; $participants[6] = (object)$this->meetingtask->format_participant($rawparticipants[6], $detailsid, $names, $emails); @@ -590,7 +590,7 @@ public function test_grading_method() { 'user_email' => '', 'join_time' => '2023-05-01T15:30:00Z', 'leave_time' => '2023-05-01T17:00:00Z', - 'duration' => 90 * 60 + 'duration' => 90 * 60, ]; // Adding a participant at which matching names will fail. @@ -602,19 +602,21 @@ public function test_grading_method() { 'user_email' => '', 'join_time' => '2023-05-01T15:10:00Z', 'leave_time' => '2023-05-01T17:00:00Z', - 'duration' => 110 * 60 + 'duration' => 110 * 60, ]; $this->mockparticipantsdata['someuuid123'] = $rawparticipants; // First mock the webservice object, so we can inject the return values // for get_meeting_participants. - $mockwwebservice = $this->createMock('\mod_zoom_webservice'); + $mockwwebservice = $this->createMock('\mod_zoom\webservice'); $this->meetingtask->service = $mockwwebservice; // Make get_meeting_participants() return our results array. $mockwwebservice->method('get_meeting_participants') ->will($this->returnCallback([$this, 'mock_get_meeting_participants'])); - $this->assertEquals($this->mockparticipantsdata['someuuid123'], - $mockwwebservice->get_meeting_participants('someuuid123', false)); + $this->assertEquals( + $this->mockparticipantsdata['someuuid123'], + $mockwwebservice->get_meeting_participants('someuuid123', false) + ); // Now let's test the grads. set_config('gradingmethod', 'period', 'zoom'); @@ -661,13 +663,13 @@ public function test_grading_method() { // Check the content of the message. // Grading item url. $gurl = new \moodle_url( - '/grade/report/singleview/index.php', - [ - 'id' => $course->id, - 'item' => 'grade', - 'itemid' => $gradelistitems[0]->id, - ] - ); + '/grade/report/singleview/index.php', + [ + 'id' => $course->id, + 'item' => 'grade', + 'itemid' => $gradelistitems[0]->id, + ] + ); $gradeurl = \html_writer::link($gurl, get_string('gradinglink', 'mod_zoom')); // Zoom instance url. @@ -676,7 +678,7 @@ public function test_grading_method() { // The user need grading. $needgradestr = get_string('grading_needgrade', 'mod_zoom'); $needgrade[] = '(Name: Farouk, grade: 55)'; - $needgrade = $needgradestr.implode('
', $needgrade)."\n"; + $needgrade = $needgradestr . implode('
', $needgrade) . "\n"; $a = (object)[ 'name' => $zoomrecord->name,