diff --git a/classes/task/get_meeting_reports.php b/classes/task/get_meeting_reports.php index 178029bd..8ca5ee5d 100644 --- a/classes/task/get_meeting_reports.php +++ b/classes/task/get_meeting_reports.php @@ -983,19 +983,19 @@ public function normalize_meeting($meeting) { $normalizedmeeting->uuid = $meeting->uuid; $normalizedmeeting->topic = $meeting->topic; - // Dashboard API has duration as H:M:S while report has it in minutes. + // Dashboard API has duration as H:M:S while report has it in seconds. $timeparts = explode(':', $meeting->duration); - // Convert duration into minutes. + // Convert duration into seconds. if (count($timeparts) === 1) { - // Time is already in minutes. + // Time is already in seconds. $normalizedmeeting->duration = intval($meeting->duration); } else if (count($timeparts) === 2) { // Time is in MM:SS format. - $normalizedmeeting->duration = $timeparts[0]; + $normalizedmeeting->duration = 60 * $timeparts[0] + $timeparts[1]; } else { // Time is in HH:MM:SS format. - $normalizedmeeting->duration = 60 * $timeparts[0] + $timeparts[1]; + $normalizedmeeting->duration = 3600 * $timeparts[0] + 60 * $timeparts[1] + $timeparts[2]; } // Copy values that are named differently. diff --git a/db/upgrade.php b/db/upgrade.php index 707f5bc9..599209ca 100755 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -977,5 +977,18 @@ function xmldb_zoom_upgrade($oldversion) { upgrade_mod_savepoint(true, 2024041900, 'zoom'); } + if ($oldversion < 2024070300) { + // Update existing meeting occurrence duration to seconds. + $occurrences = $DB->get_records('zoom_meeting_details'); + + foreach ($occurrences as $occurrence) { + $duration = $occurrence->end_time - $occurrence->start_time; + $DB->set_field_select('zoom_meeting_details', 'duration', $duration, 'id = ?', [$occurrence->id]); + } + + // Zoom savepoint reached. + upgrade_mod_savepoint(true, 2024070300, 'zoom'); + } + return true; } diff --git a/lang/en/zoom.php b/lang/en/zoom.php index e6084ded..a19732c6 100644 --- a/lang/en/zoom.php +++ b/lang/en/zoom.php @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - /** * English strings for zoom. * @@ -103,7 +102,7 @@ $string['downloadical_desc'] = 'With this setting, you can control if a link to download an iCal file for the meeting will be shown on the activity instance overview page or not. This setting only affects the possibility to download an iCal file for third-party calendar tools. Regardless of this setting, the Zoom meeting activity will add a calendar entry into the Moodle calendar as soon as a meeting start date is set.'; $string['downloadical_disable'] = 'Disable download iCal link'; $string['downloadical_enable'] = 'Enable download iCal link'; -$string['duration'] = 'Duration (minutes)'; +$string['duration'] = 'Duration'; $string['encryptiontype'] = 'Encryption type'; $string['encryptiontype_alwaysshow'] = 'Always show encryption type chooser regardless if the user can use end-to-end encryption or not'; $string['encryptiontype_desc'] = 'With this setting, you can control if the option to choose end-to-end encryption over enhanced encryption is shown to users in the activity instance settings or not. This setting only affects the Moodle activity instance settings. Even if you decide to always show the option, the user will still need end-to-end encryption in Zoom to finally enable end-to-end encryption.'; diff --git a/participants.php b/participants.php index 2e90f46e..40c5a724 100644 --- a/participants.php +++ b/participants.php @@ -148,12 +148,7 @@ $row[] = userdate($p->leave_time, get_string('strftimedatetimeshort', 'langconfig')); // Duration. - $durationremainder = $p->duration % 60; - if ($durationremainder != 0) { - $p->duration += 60 - $durationremainder; - } - - $row[] = $p->duration / 60; + $row[] = format_time($p->duration); $table->data[] = $row; } diff --git a/report.php b/report.php index 3e8af364..7ee5b46e 100755 --- a/report.php +++ b/report.php @@ -68,7 +68,7 @@ $row[] = $meet['topic']; $row[] = $meet['starttime']; $row[] = $meet['endtime']; - $row[] = $meet['duration']; + $row[] = format_time($meet['duration']); if ($meet['count'] > 0) { if ($maskparticipantdata) { diff --git a/tests/advanced_passcode_test.php b/tests/advanced_passcode_test.php index 54d7e87e..331aac43 100644 --- a/tests/advanced_passcode_test.php +++ b/tests/advanced_passcode_test.php @@ -59,6 +59,7 @@ public static function assertMatchesRegularExpression($pattern, $string, $messag public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/mod/zoom/locallib.php'); + parent::setUpBeforeClass(); } /** diff --git a/tests/error_handling_test.php b/tests/error_handling_test.php index 729a4f1f..c0a4a0d8 100644 --- a/tests/error_handling_test.php +++ b/tests/error_handling_test.php @@ -62,12 +62,14 @@ final class error_handling_test extends basic_testcase { public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/mod/zoom/locallib.php'); + parent::setUpBeforeClass(); } /** * Setup before every test. */ public function setUp(): void { + parent::setUp(); $this->meetingnotfoundexception = new not_found_exception('meeting not found', 3001); $this->usernotfoundexception = new not_found_exception('user not found', 1001); $this->invaliduserexception = new not_found_exception('invalid user found', 1120); diff --git a/tests/get_meeting_reports_test.php b/tests/get_meeting_reports_test.php index 273b07b1..3f7d1354 100644 --- a/tests/get_meeting_reports_test.php +++ b/tests/get_meeting_reports_test.php @@ -69,6 +69,8 @@ public function mock_get_meeting_participants($meetinguuid, $webinar) { * Setup. */ public function setUp(): void { + parent::setUp(); + $this->resetAfterTest(true); $this->meetingtask = new \mod_zoom\task\get_meeting_reports(); @@ -286,7 +288,7 @@ public function test_invalid_userids(): void { $participant2->user_email = 'jane@test.com'; $participant2->join_time = '2020-04-01T15:00:00Z'; $participant2->leave_time = '2020-04-01T15:10:00Z'; - $participant2->duration = 10; + $participant2->duration = 10 * 60; $this->mockparticipantsdata['someuuid'][] = $participant2; // Make get_meeting_participants() return our results array. @@ -305,7 +307,7 @@ public function test_invalid_userids(): void { $meeting->start_time = '2020-04-01T15:00:00Z'; $meeting->end_time = '2020-04-01T16:00:00Z'; $meeting->uuid = 'someuuid'; - $meeting->duration = 60; + $meeting->duration = 60 * 60; $meeting->participants = 3; // Insert stub data for zoom table. @@ -334,7 +336,7 @@ public function test_invalid_userids(): void { $participant3->user_email = 'joe@test.com'; $participant3->join_time = '2020-04-01T15:05:00Z'; $participant3->leave_time = '2020-04-01T15:35:00Z'; - $participant3->duration = 30; + $participant3->duration = 30 * 60; $this->mockparticipantsdata['someuuid'][] = $participant3; $this->assertTrue($this->meetingtask->process_meeting_reports($meeting)); $this->assertEquals(1, $DB->count_records('zoom_meeting_details')); @@ -354,7 +356,7 @@ public function test_normalize_meeting(): void { 'email' => 'test@email.com', 'user_type' => 2, 'start_time' => '2019-07-14T09:05:19.754Z', - 'end_time' => '2019-08-14T09:05:19.754Z', + 'end_time' => '2019-07-14T10:26:37.754Z', 'duration' => '01:21:18', 'participants' => 4, 'has_pstn' => false, @@ -373,14 +375,14 @@ public function test_normalize_meeting(): void { $this->assertEquals($dashboardmeeting['topic'], $meeting->topic); $this->assertIsInt($meeting->start_time); $this->assertIsInt($meeting->end_time); - $this->assertEquals($meeting->duration, 81); + $this->assertEquals($meeting->duration, 1 * 3600 + 21 * 60 + 18); $this->assertEquals($dashboardmeeting['participants'], $meeting->participants_count); $this->assertNull($meeting->total_minutes); // Try duration under an hour. $dashboardmeeting['duration'] = '10:01'; $meeting = $this->meetingtask->normalize_meeting((object) $dashboardmeeting); - $this->assertEquals($meeting->duration, 10); + $this->assertEquals($meeting->duration, 10 * 60 + 1); $reportmeeting = [ 'uuid' => 'sfsdfsdfc6122222d', @@ -390,8 +392,8 @@ public function test_normalize_meeting(): void { 'user_name' => 'John Doe', 'user_email' => 'test@email.com', 'start_time' => '2019-07-14T09:05:19.754Z', - 'end_time' => '2019-08-14T09:05:19.754Z', - 'duration' => 11, + 'end_time' => '2019-07-14T09:16:19.754Z', + 'duration' => 11 * 60, 'total_minutes' => 11, 'participants_count' => 4, ]; @@ -442,7 +444,7 @@ public function test_grading_method(): void { $meeting->start_time = '2020-04-01T15:00:00Z'; $meeting->end_time = '2020-04-01T17:00:00Z'; $meeting->uuid = 'someuuid123'; - $meeting->duration = 120; // In minutes. + $meeting->duration = 120 * 60; // In seconds. $meeting->participants = 4; // Create a new zoom instance. diff --git a/tests/mod_zoom_grade_test.php b/tests/mod_zoom_grade_test.php index 8d8f41ad..1d661cb3 100644 --- a/tests/mod_zoom_grade_test.php +++ b/tests/mod_zoom_grade_test.php @@ -57,12 +57,14 @@ public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/mod/zoom/lib.php'); require_once($CFG->dirroot . '/mod/zoom/locallib.php'); + parent::setUpBeforeClass(); } /** * Setup before every test. */ public function setUp(): void { + parent::setUp(); $this->resetAfterTest(); $this->setAdminUser(); diff --git a/tests/mod_zoom_invitation_test.php b/tests/mod_zoom_invitation_test.php index 9b8f9004..1d06118b 100644 --- a/tests/mod_zoom_invitation_test.php +++ b/tests/mod_zoom_invitation_test.php @@ -41,12 +41,14 @@ final class mod_zoom_invitation_test extends advanced_testcase { public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->libdir . '/accesslib.php'); + parent::setUpBeforeClass(); } /** * Run before every test. */ protected function setUp(): void { + parent::setUp(); set_config('invitationregexenabled', 1, 'zoom'); } diff --git a/tests/mod_zoom_webservice_test.php b/tests/mod_zoom_webservice_test.php index 1e2ebd06..7fabce0a 100644 --- a/tests/mod_zoom_webservice_test.php +++ b/tests/mod_zoom_webservice_test.php @@ -42,12 +42,14 @@ final class mod_zoom_webservice_test extends advanced_testcase { public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/mod/zoom/locallib.php'); + parent::setUpBeforeClass(); } /** * Setup before every test. */ public function setUp(): void { + parent::setUp(); $this->resetAfterTest(); // Set fake values so we can test methods in class. set_config('clientid', 'test', 'zoom'); diff --git a/tests/privacy/mod_zoom_provider_test.php b/tests/privacy/mod_zoom_provider_test.php index 85efec3d..ce69d9d6 100644 --- a/tests/privacy/mod_zoom_provider_test.php +++ b/tests/privacy/mod_zoom_provider_test.php @@ -55,6 +55,7 @@ final class mod_zoom_provider_test extends provider_testcase { * {@inheritdoc} */ protected function setUp(): void { + parent::setUp(); $this->resetAfterTest(); $this->setAdminUser(); diff --git a/version.php b/version.php index f3a0bb44..b13a4338 100755 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_zoom'; -$plugin->version = 2024050900; -$plugin->release = 'v5.2.2'; +$plugin->version = 2024070300; +$plugin->release = 'v5.2.3'; $plugin->requires = 2019052000; $plugin->maturity = MATURITY_STABLE; $plugin->cron = 0;