mirror of
https://github.com/moodle/moodle.git
synced 2025-03-04 08:06:30 +01:00
Merge branch 'MDL-73306' of https://github.com/call-learning/moodle
This commit is contained in:
commit
a20f151438
@ -460,4 +460,29 @@ EOF;
|
||||
[self::EVENT_CALLBACK, '%recordid%', "%$recordid%", "%$callbacktype%"]);
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log event to string that can be internationalised via get_string.
|
||||
*/
|
||||
const LOG_TO_STRING = [
|
||||
self::EVENT_JOIN => 'event_meeting_joined',
|
||||
self::EVENT_PLAYED => 'event_recording_viewed',
|
||||
self::EVENT_IMPORT => 'event_recording_imported',
|
||||
self::EVENT_ADD => 'event_activity_created',
|
||||
self::EVENT_DELETE => 'event_activity_deleted',
|
||||
self::EVENT_EDIT => 'event_activity_updated',
|
||||
self::EVENT_SUMMARY => 'event_meeting_summary',
|
||||
self::EVENT_LOGOUT => 'event_meeting_left',
|
||||
self::EVENT_MEETING_START => 'event_meeting_joined',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the event name (human friendly version)
|
||||
*
|
||||
* @param object $log object as returned by get_user_completion_logs_with_userfields
|
||||
*/
|
||||
public static function get_printable_event_name(object $log) {
|
||||
$logstringname = self::LOG_TO_STRING[$log->log] ?? 'event_unknown';
|
||||
return get_string($logstringname, 'mod_bigbluebuttonbn');
|
||||
}
|
||||
}
|
||||
|
@ -569,6 +569,7 @@ $string['event_recording_unpublished'] = 'Recording unpublished';
|
||||
$string['event_recording_protected'] = 'Recording protected';
|
||||
$string['event_recording_unprotected'] = 'Recording unprotected';
|
||||
$string['event_live_session'] = 'Live session event';
|
||||
$string['event_unknown'] = 'Unknown event';
|
||||
|
||||
$string['instance_type_default'] = 'Room/Activity with recordings';
|
||||
$string['instance_type_room_only'] = 'Room/Activity only';
|
||||
@ -576,6 +577,7 @@ $string['instance_type_recording_only'] = 'Recordings only';
|
||||
|
||||
$string['messageprovider:instance_updated'] = 'BigBlueButton meeting updated';
|
||||
$string['messageprovider:recording_ready'] = 'BigBlueButton recording ready to view';
|
||||
$string['new_bigblubuttonbn_activities'] = 'BigBlueButton activity';
|
||||
$string['notification_instance_created_intro'] = 'The <a href="{$a->link}">{$a->name}</a> BigBlueButton activity has been created.';
|
||||
$string['notification_instance_created_small'] = 'A new BigBlueButton meeting named {$a->name} was created';
|
||||
$string['notification_instance_created_subject'] = 'A new BigBlueButton meeting activity has been created';
|
||||
|
@ -582,11 +582,11 @@ function bigbluebuttonbn_get_recent_mod_activity(&$activities, &$index, $timesta
|
||||
$instance->set_group_id($groupid);
|
||||
$cm = $instance->get_cm();
|
||||
$logs =
|
||||
|
||||
logger::get_user_completion_logs_with_userfields($instance,
|
||||
$userid ?? null,
|
||||
[logger::EVENT_JOIN, logger::EVENT_PLAYED],
|
||||
$timestart);
|
||||
|
||||
foreach ($logs as $log) {
|
||||
$activity = new stdClass();
|
||||
|
||||
@ -607,22 +607,17 @@ function bigbluebuttonbn_get_recent_mod_activity(&$activities, &$index, $timesta
|
||||
}
|
||||
$activity->user->fullname = fullname($log);
|
||||
$activity->content = '';
|
||||
switch ($log->log) {
|
||||
case logger::EVENT_JOIN:
|
||||
$activity->eventname = get_string('event_meeting_joined', 'mod_bigbluebuttonbn');
|
||||
break;
|
||||
case logger::EVENT_PLAYED:
|
||||
$activity->eventname = get_string('event_recording_viewed', 'mod_bigbluebuttonbn');
|
||||
if (!empty($log->meta)) {
|
||||
$meta = json_decode($log->meta);
|
||||
if (!empty($meta->recordingid)) {
|
||||
$recording = recording::get_record(['id' => $meta->recordingid]);
|
||||
if ($recording) {
|
||||
$activity->content = $recording->get('name');
|
||||
}
|
||||
$activity->eventname = logger::get_printable_event_name($log);
|
||||
if ($log->log == logger::EVENT_PLAYED) {
|
||||
if (!empty($log->meta)) {
|
||||
$meta = json_decode($log->meta);
|
||||
if (!empty($meta->recordingid)) {
|
||||
$recording = recording::get_record(['id' => $meta->recordingid]);
|
||||
if ($recording) {
|
||||
$activity->content = $recording->get('name');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$activities[$index++] = $activity;
|
||||
}
|
||||
@ -654,3 +649,45 @@ function bigbluebuttonbn_print_recent_mod_activity(stdClass $activity, int $cour
|
||||
}
|
||||
echo $OUTPUT->render_from_template('mod_bigbluebuttonbn/recentactivity', $template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a course and a date, prints a summary of all the activity for this module
|
||||
*
|
||||
* @param object $course
|
||||
* @param bool $viewfullnames capability
|
||||
* @param int $timestart
|
||||
* @return bool success
|
||||
*/
|
||||
function bigbluebuttonbn_print_recent_activity(object $course, bool $viewfullnames, int $timestart): bool {
|
||||
global $OUTPUT;
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
if (empty($modinfo->instances['bigbluebuttonbn'])) {
|
||||
return true;
|
||||
}
|
||||
$out = '';
|
||||
foreach ($modinfo->instances['bigbluebuttonbn'] as $cm) {
|
||||
if (!$cm->uservisible) {
|
||||
continue;
|
||||
}
|
||||
$instance = instance::get_from_cmid($cm->id);
|
||||
$logs = logger::get_user_completion_logs_with_userfields($instance,
|
||||
null,
|
||||
[logger::EVENT_JOIN, logger::EVENT_PLAYED],
|
||||
$timestart);
|
||||
if ($logs) {
|
||||
echo $OUTPUT->heading(get_string('new_bigblubuttonbn_activities', 'bigbluebuttonbn') . ':', 6);
|
||||
foreach ($logs as $log) {
|
||||
$activityurl = new moodle_url('/mod/bigbluebuttonbn/index.php', ['id' => $instance->get_instance_id()]);
|
||||
print_recent_activity_note($log->timecreated,
|
||||
$log,
|
||||
logger::get_printable_event_name($log) . ' - ' . $instance->get_meeting_name(),
|
||||
$activityurl->out(),
|
||||
false,
|
||||
$viewfullnames);
|
||||
}
|
||||
}
|
||||
|
||||
echo $out;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -284,6 +284,56 @@ class lib_test extends \advanced_testcase {
|
||||
$this->assertStringContainsString('Meeting joined', $output);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check recent activity for the course
|
||||
*
|
||||
* @covers ::bigbluebuttonbn_print_recent_activity
|
||||
*/
|
||||
public function test_bigbluebuttonbn_print_recent_activity() {
|
||||
global $CFG;
|
||||
$this->initialise_mock_server();
|
||||
$this->resetAfterTest();
|
||||
|
||||
$generator = $this->getDataGenerator();
|
||||
$user = $generator->create_and_enrol($this->get_course());
|
||||
list($bbactivitycontext, $bbactivitycm, $bbactivity) = $this->create_instance();
|
||||
// Now create a couple of logs.
|
||||
$timestart = time() - 3600;
|
||||
$instance = instance::get_from_instanceid($bbactivity->id);
|
||||
$recordings = $this->create_recordings_for_instance($instance, [['name' => "Pre-Recording 1"]]);
|
||||
|
||||
$this->setUser($user); // Important so the logs are set to this user.
|
||||
logger::log_meeting_joined_event($instance, 0);
|
||||
logger::log_meeting_joined_event($instance, 0);
|
||||
logger::log_recording_played_event($instance, $recordings[0]->id);
|
||||
|
||||
$this->setAdminUser();
|
||||
// Test that everything is displayed.
|
||||
ob_start();
|
||||
bigbluebuttonbn_print_recent_activity($this->get_course(), true, $timestart);
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertStringContainsString('Meeting joined', $output);
|
||||
$this->assertStringContainsString(fullname($user), $output);
|
||||
// Test that username are displayed in a different format.
|
||||
$CFG->alternativefullnameformat = 'firstname lastname firstnamephonetic lastnamephonetic middlename alternatename';
|
||||
$expectedname = "$user->firstname $user->lastname $user->firstnamephonetic "
|
||||
. "$user->lastnamephonetic $user->middlename $user->alternatename";
|
||||
ob_start();
|
||||
bigbluebuttonbn_print_recent_activity($this->get_course(), false, $timestart);
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertStringContainsString('Meeting joined', $output);
|
||||
$this->assertStringNotContainsString($expectedname, $output);
|
||||
// Test that nothing is displayed as per timestart.
|
||||
ob_start();
|
||||
bigbluebuttonbn_print_recent_activity($this->get_course(), true, $timestart + 3600);
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertEmpty($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check extra capabilities return value
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user