Skip to content

Commit

Permalink
Merge pull request #250 from abias/patch-3
Browse files Browse the repository at this point in the history
Change duration string to what it really should say
  • Loading branch information
jrchamp authored Jul 25, 2024
2 parents 37b958b + b6df07b commit fa3a509
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 25 deletions.
10 changes: 5 additions & 5 deletions classes/task/get_meeting_reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 1 addition & 2 deletions lang/en/zoom.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.


/**
* English strings for zoom.
*
Expand Down Expand Up @@ -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.';
Expand Down
7 changes: 1 addition & 6 deletions participants.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion report.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions tests/advanced_passcode_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/error_handling_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 11 additions & 9 deletions tests/get_meeting_reports_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -286,7 +288,7 @@ public function test_invalid_userids(): void {
$participant2->user_email = '[email protected]';
$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.
Expand All @@ -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.
Expand Down Expand Up @@ -334,7 +336,7 @@ public function test_invalid_userids(): void {
$participant3->user_email = '[email protected]';
$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'));
Expand All @@ -354,7 +356,7 @@ public function test_normalize_meeting(): void {
'email' => '[email protected]',
'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,
Expand All @@ -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',
Expand All @@ -390,8 +392,8 @@ public function test_normalize_meeting(): void {
'user_name' => 'John Doe',
'user_email' => '[email protected]',
'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,
];
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions tests/mod_zoom_grade_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 2 additions & 0 deletions tests/mod_zoom_invitation_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
2 changes: 2 additions & 0 deletions tests/mod_zoom_webservice_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions tests/privacy/mod_zoom_provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ final class mod_zoom_provider_test extends provider_testcase {
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->resetAfterTest();
$this->setAdminUser();

Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit fa3a509

Please sign in to comment.