Skip to content

Commit

Permalink
phpcs: small cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
jrchamp committed Sep 28, 2023
1 parent 37c227a commit c7acfdc
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 38 deletions.
22 changes: 11 additions & 11 deletions classes/task/get_meeting_reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@ 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 {
$participant->user_email = null;
}
}

if ($participant->id == '') {
if ($participant->id === '') {
$participant->id = null;
}

Expand Down Expand Up @@ -469,7 +469,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',
$meeting->meeting_id, $meeting->uuid, $meeting->start_time));
Expand Down Expand Up @@ -540,7 +540,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.
Expand Down Expand Up @@ -631,7 +631,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];
Expand Down Expand Up @@ -708,7 +708,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.
Expand Down Expand Up @@ -808,7 +807,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('<br>', $data['needgrade'])."\n" : '';
$needgrade = (!empty($data['needgrade'])) ? $needstring . implode('<br>', $data['needgrade']) . "\n" : '';

$zoomid = $data['zoomid'];
$itemid = $data['itemid'];
Expand Down Expand Up @@ -886,7 +885,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)) {
Expand Down Expand Up @@ -980,9 +979,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;
}
}
Expand Down
26 changes: 19 additions & 7 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,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('zoom/supplementaryfeaturessettings',
Expand Down Expand Up @@ -436,16 +441,23 @@
}

// 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.
$options = [
'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
));
}
42 changes: 22 additions & 20 deletions tests/get_meeting_reports_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,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();
Expand Down Expand Up @@ -505,7 +505,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 .
Expand All @@ -516,7 +516,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)[
Expand All @@ -526,7 +526,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]);
Expand All @@ -544,7 +544,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)[
Expand All @@ -554,7 +554,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]);
Expand All @@ -572,7 +572,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)[
Expand All @@ -582,7 +582,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);

Expand All @@ -601,7 +601,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.
Expand All @@ -613,7 +613,7 @@ 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
Expand All @@ -624,8 +624,10 @@ public function test_grading_method() {
$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');
Expand Down Expand Up @@ -672,13 +674,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.
Expand All @@ -687,7 +689,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('<br>', $needgrade)."\n";
$needgrade = $needgradestr . implode('<br>', $needgrade) . "\n";

$a = (object)[
'name' => $zoomrecord->name,
Expand Down

0 comments on commit c7acfdc

Please sign in to comment.