-
Notifications
You must be signed in to change notification settings - Fork 141
/
lib.php
700 lines (639 loc) · 24.4 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Library calls for Moodle and BigBlueButton.
*
* @package mod_bigbluebuttonbn
* @copyright 2010 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
* @author Fred Dixon (ffdixon [at] blindsidenetworks [dt] com)
*/
defined('MOODLE_INTERNAL') || die;
use core_calendar\action_factory;
use core_calendar\local\event\entities\action_interface;
use mod_bigbluebuttonbn\completion\custom_completion;
use mod_bigbluebuttonbn\instance;
use mod_bigbluebuttonbn\local\bigbluebutton;
use mod_bigbluebuttonbn\local\helpers\files;
use mod_bigbluebuttonbn\local\helpers\mod_helper;
use mod_bigbluebuttonbn\local\helpers\reset;
use mod_bigbluebuttonbn\local\proxy\bigbluebutton_proxy;
use mod_bigbluebuttonbn\logger;
use mod_bigbluebuttonbn\meeting;
use mod_bigbluebuttonbn\recording;
use mod_bigbluebuttonbn\local\config;
global $CFG;
/**
* Indicates API features that the bigbluebuttonbn supports.
*
* @param string $feature
* @return mixed True if yes (some features may use other values)
* @uses FEATURE_IDNUMBER
* @uses FEATURE_GROUPS
* @uses FEATURE_GROUPINGS
* @uses FEATURE_GROUPMEMBERSONLY
* @uses FEATURE_MOD_INTRO
* @uses FEATURE_BACKUP_MOODLE2
* @uses FEATURE_COMPLETION_TRACKS_VIEWS
* @uses FEATURE_COMPLETION_HAS_RULES
* @uses FEATURE_GRADE_HAS_GRADE
* @uses FEATURE_GRADE_OUTCOMES
* @uses FEATURE_SHOW_DESCRIPTION
*/
function bigbluebuttonbn_supports($feature) {
if (!$feature) {
return null;
}
$features = [
FEATURE_IDNUMBER => true,
FEATURE_GROUPS => true,
FEATURE_GROUPINGS => true,
FEATURE_MOD_INTRO => true,
FEATURE_BACKUP_MOODLE2 => true,
FEATURE_COMPLETION_TRACKS_VIEWS => true,
FEATURE_COMPLETION_HAS_RULES => true,
FEATURE_GRADE_HAS_GRADE => false,
FEATURE_GRADE_OUTCOMES => false,
FEATURE_SHOW_DESCRIPTION => true,
];
if (isset($features[(string) $feature])) {
return $features[$feature];
}
return null;
}
/**
* Given an object containing all the necessary data,
* (defined by the form in mod_form.php) this function
* will create a new instance and return the id number
* of the new instance.
*
* @param stdClass $bigbluebuttonbn An object from the form in mod_form.php
* @return int The id of the newly inserted bigbluebuttonbn record
*/
function bigbluebuttonbn_add_instance($bigbluebuttonbn) {
global $DB;
// Excecute preprocess.
mod_helper::process_pre_save($bigbluebuttonbn);
// Pre-set initial values.
$bigbluebuttonbn->presentation = files::save_media_file($bigbluebuttonbn);
// Encode meetingid.
$bigbluebuttonbn->meetingid = meeting::get_unique_meetingid_seed();
// Insert a record.
$bigbluebuttonbn->id = $DB->insert_record('bigbluebuttonbn', $bigbluebuttonbn);
// Log insert action.
logger::log_instance_created($bigbluebuttonbn);
// Complete the process.
mod_helper::process_post_save($bigbluebuttonbn);
return $bigbluebuttonbn->id;
}
/**
* Given an object containing all the necessary data,
* (defined by the form in mod_form.php) this function
* will update an existing instance with new data.
*
* @param stdClass $bigbluebuttonbn An object from the form in mod_form.php
* @return bool Success/Fail
*/
function bigbluebuttonbn_update_instance($bigbluebuttonbn) {
global $DB;
// Excecute preprocess.
mod_helper::process_pre_save($bigbluebuttonbn);
// Pre-set initial values.
$bigbluebuttonbn->id = $bigbluebuttonbn->instance;
$bigbluebuttonbn->presentation = files::save_media_file($bigbluebuttonbn);
// Update a record.
$DB->update_record('bigbluebuttonbn', $bigbluebuttonbn);
// Get the meetingid column in the bigbluebuttonbn table.
$bigbluebuttonbn->meetingid = (string) $DB->get_field('bigbluebuttonbn', 'meetingid', ['id' => $bigbluebuttonbn->id]);
// Log update action.
logger::log_instance_updated(instance::get_from_instanceid($bigbluebuttonbn->id));
// Complete the process.
mod_helper::process_post_save($bigbluebuttonbn);
return true;
}
/**
* Given an ID of an instance of this module,
* this function will permanently delete the instance
* and any data that depends on it.
*
* @param int $id Id of the module instance
*
* @return bool Success/Failure
*/
function bigbluebuttonbn_delete_instance($id) {
global $DB;
$instance = instance::get_from_instanceid($id);
if (empty($instance)) {
return false;
}
// End all meeting if any still running.
try {
$meeting = new meeting($instance);
$meeting->end_meeting();
$groups = groups_get_course_group($instance->get_course());
if ($groups) {
foreach ($groups as $group) {
$instance->set_group_id($group->id);
$meeting = new meeting($instance);
$meeting->end_meeting();
}
}
} catch (moodle_exception $e) {
// Do not log any issue when testing and meeting is not running on deletion.
if (!(defined('PHPUNIT_TEST') && PHPUNIT_TEST) && !defined('BEHAT_SITE_RUNNING')
&& $e->getMessage() !== 'mod_bigbluebuttonbn/notFound') {
debugging($e->getMessage(), DEBUG_NORMAL, $e->getTrace());
}
}
$result = true;
// Delete the instance.
if (!$DB->delete_records('bigbluebuttonbn', ['id' => $id])) {
$result = false;
}
// Delete dependant events.
if (!$DB->delete_records('event', ['modulename' => 'bigbluebuttonbn', 'instance' => $id])) {
$result = false;
}
// Log action performed.
logger::log_instance_deleted($instance);
// Mark dependent recordings as headless.
foreach (recording::get_records(['bigbluebuttonbnid' => $id]) as $recording) {
$recording->set('headless', recording::RECORDING_HEADLESS);
$recording->update();
}
return $result;
}
/**
* Return a small object with summary information about what a
* user has done with a given particular instance of this module
* Used for user activity reports.
*
* @param stdClass $course
* @param stdClass $user
* @param cm_info $mod
* @param stdClass $bigbluebuttonbn
*
* @return stdClass with info and time (timestamp of the last log)
*/
function bigbluebuttonbn_user_outline(stdClass $course, stdClass $user, cm_info $mod, stdClass $bigbluebuttonbn): stdClass {
[$infos, $logtimestamps] = \mod_bigbluebuttonbn\local\helpers\user_info::get_user_info_outline($course, $user, $mod);
return (object) [
'info' => join(',', $infos),
'time' => !empty($logtimestamps) ? max($logtimestamps) : 0,
];
}
/**
* Print a detailed representation of what a user has done with
* a given particular instance of this module, for user activity reports.
*
* @param stdClass $course
* @param stdClass $user
* @param cm_info $mod
* @param stdClass $bigbluebuttonbn
*
*/
function bigbluebuttonbn_user_complete(stdClass $course, stdClass $user, cm_info $mod, stdClass $bigbluebuttonbn) {
[$infos] = \mod_bigbluebuttonbn\local\helpers\user_info::get_user_info_outline($course, $user, $mod);
echo join(', ', $infos);
}
/**
* This flags this module with the capability to override the completion status with the custom completion rules.
*
*
* @return int
*/
function bigbluebuttonbn_get_completion_aggregation_state() {
return COMPLETION_CUSTOM_MODULE_FLOW;
}
/**
* Returns all other caps used in module.
*
* @return string[]
*/
function bigbluebuttonbn_get_extra_capabilities() {
return ['moodle/site:accessallgroups'];
}
/**
* Called by course/reset.php
*
* @param object $mform
*/
function bigbluebuttonbn_reset_course_form_definition(object &$mform) {
$items = reset::reset_course_items();
$mform->addElement('header', 'bigbluebuttonbnheader', get_string('modulenameplural', 'bigbluebuttonbn'));
foreach ($items as $item => $default) {
$mform->addElement(
'advcheckbox',
"reset_bigbluebuttonbn_{$item}",
get_string("reset{$item}", 'bigbluebuttonbn')
);
if ($item == 'logs' || $item == 'recordings') {
$mform->addHelpButton("reset_bigbluebuttonbn_{$item}", "reset{$item}", 'bigbluebuttonbn');
}
}
}
/**
* Course reset form defaults.
*
* @param stdClass $course
* @return array
*/
function bigbluebuttonbn_reset_course_form_defaults(stdClass $course) {
$formdefaults = [];
$items = reset::reset_course_items();
// All unchecked by default.
foreach ($items as $item => $default) {
$formdefaults["reset_bigbluebuttonbn_{$item}"] = $default;
}
return $formdefaults;
}
/**
* This function is used by the reset_course_userdata function in moodlelib.
*
* @param stdClass $data the data submitted from the reset course.
* @return array status array
*/
function bigbluebuttonbn_reset_userdata(stdClass $data) {
$items = reset::reset_course_items();
$status = [];
// Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
// See MDL-9367.
if (array_key_exists('recordings', $items) && !empty($data->reset_bigbluebuttonbn_recordings)) {
// Remove all the recordings from a BBB server that are linked to the room/activities in this course.
reset::reset_recordings($data->courseid);
unset($items['recordings']);
$status[] = reset::reset_getstatus('recordings');
}
if (!empty($data->reset_bigbluebuttonbn_tags)) {
// Remove all the tags linked to the room/activities in this course.
reset::reset_tags($data->courseid);
unset($items['tags']);
$status[] = reset::reset_getstatus('tags');
}
if (!empty($data->reset_bigbluebuttonbn_logs)) {
// Remove all the tags linked to the room/activities in this course.
reset::reset_logs($data->courseid);
unset($items['logs']);
$status[] = reset::reset_getstatus('logs');
}
return $status;
}
/**
* Given a course_module object, this function returns any
* "extra" information that may be needed when printing
* this activity in a course listing.
* See get_array_of_activities() in course/lib.php.
*
* @param stdClass $coursemodule
*
* @return null|cached_cm_info
*/
function bigbluebuttonbn_get_coursemodule_info($coursemodule) {
global $DB;
$dbparams = ['id' => $coursemodule->instance];
$customcompletionfields = custom_completion::get_defined_custom_rules();
$fieldsarray = array_merge([
'id',
'name',
'intro',
'introformat',
], $customcompletionfields);
$fields = join(',', $fieldsarray);
$bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', $dbparams, $fields);
if (!$bigbluebuttonbn) {
return null;
}
$info = new cached_cm_info();
$info->name = $bigbluebuttonbn->name;
if ($coursemodule->showdescription) {
// Convert intro to html. Do not filter cached version, filters run at display time.
$info->content = format_module_intro('bigbluebuttonbn', $bigbluebuttonbn, $coursemodule->id, false);
}
// Populate the custom completion rules as key => value pairs, but only if the completion mode is 'automatic'.
if ($coursemodule->completion == COMPLETION_TRACKING_AUTOMATIC) {
foreach ($customcompletionfields as $completiontype) {
$info->customdata['customcompletionrules'][$completiontype] =
$bigbluebuttonbn->$completiontype ?? 0;
}
}
return $info;
}
/**
* Serves the bigbluebuttonbn attachments. Implements needed access control ;-).
*
* @param stdClass $course course object
* @param cm_info $cm course module object
* @param context $context context object
* @param string $filearea file area
* @param array $args extra arguments
* @param bool $forcedownload whether or not force download
* @param array $options additional options affecting the file serving
*
* @return false|null false if file not found, does not return if found - justsend the file
* @category files
*
*/
function bigbluebuttonbn_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = []) {
if (!files::pluginfile_valid($context, $filearea)) {
return false;
}
$file = files::pluginfile_file($course, $cm, $context, $filearea, $args);
if (empty($file)) {
return false;
}
// Finally send the file.
return send_stored_file($file, 0, 0, $forcedownload, $options); // Download MUST be forced - security!
}
/**
* Mark the activity completed (if required) and trigger the course_module_viewed event.
*
* @param stdClass $bigbluebuttonbn bigbluebuttonbn object
* @param stdClass $course course object
* @param cm_info $cm course module object
* @param context $context context object
* @since Moodle 3.0
*/
function bigbluebuttonbn_view($bigbluebuttonbn, $course, $cm, $context) {
// Trigger course_module_viewed event.
$params = [
'context' => $context,
'objectid' => $bigbluebuttonbn->id,
];
$event = \mod_bigbluebuttonbn\event\course_module_viewed::create($params); // Fix event name.
$cmrecord = $cm->get_course_module_record();
$event->add_record_snapshot('course_modules', $cmrecord);
$event->add_record_snapshot('course', $course);
$event->add_record_snapshot('bigbluebuttonbn', $bigbluebuttonbn);
$event->trigger();
// Completion.
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
}
/**
* Check if the module has any update that affects the current user since a given time.
*
* @param cm_info $cm course module data
* @param int $from the time to check updates from
* @param array $filter if we need to check only specific updates
* @return stdClass an object with the different type of areas indicating if they were updated or not
* @since Moodle 3.2
*/
function bigbluebuttonbn_check_updates_since(cm_info $cm, $from, $filter = []) {
$updates = course_check_module_updates_since($cm, $from, ['content'], $filter);
return $updates;
}
/**
* This function receives a calendar event and returns the action associated with it, or null if there is none.
*
* This is used by block_myoverview in order to display the event appropriately. If null is returned then the event
* is not displayed on the block.
*
* @param calendar_event $event
* @param action_factory $factory
* @return action_interface|null
*/
function mod_bigbluebuttonbn_core_calendar_provide_event_action(
calendar_event $event,
action_factory $factory
) {
global $DB;
$time = time();
// Get mod info.
$cm = get_fast_modinfo($event->courseid)->instances['bigbluebuttonbn'][$event->instance];
// Get bigbluebuttonbn activity.
$bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', ['id' => $event->instance], '*', MUST_EXIST);
// Set flag haspassed if closingtime has already passed only if it is defined.
$haspassed = ($bigbluebuttonbn->closingtime) && $bigbluebuttonbn->closingtime < $time;
// Set flag hasstarted if startingtime has already passed or not defined.
$hasstarted = $bigbluebuttonbn->openingtime < $time;
// Return null if it has passed or not started.
if ($haspassed || !$hasstarted) {
return null;
}
// Get if the user has joined in live session or viewed the recorded.
$customcompletion = new custom_completion($cm, $event->userid);
$usercomplete = $customcompletion->get_overall_completion_state();
$instance = instance::get_from_instanceid($bigbluebuttonbn->id);
// Get if the room is available.
$roomavailable = $instance->is_currently_open();
$meetinginfo = null;
// Check first if the server can be contacted.
try {
if (empty(bigbluebutton_proxy::get_server_version())) {
// In this case we should already have debugging message printed.
return null;
}
// Get if the user can join.
$meetinginfo = meeting::get_meeting_info_for_instance($instance);
} catch (moodle_exception $e) {
debugging('Error - Cannot retrieve info from meeting ('.$instance->get_meeting_id().') ' . $e->getMessage());
return null;
}
$usercanjoin = $meetinginfo->canjoin;
// Check if the room is closed and the user has already joined this session or played the record.
if (!$roomavailable && $usercomplete) {
return null;
}
// Check if the user can join this session.
$actionable = ($roomavailable && $usercanjoin);
// Action data.
$string = get_string('view_room', 'bigbluebuttonbn');
$url = new moodle_url('/mod/bigbluebuttonbn/view.php', ['id' => $cm->id]);
if (groups_get_activity_groupmode($cm) == NOGROUPS) {
// No groups mode.
$string = get_string('view_conference_action_join', 'bigbluebuttonbn');
$url = new moodle_url('/mod/bigbluebuttonbn/bbb_view.php', [
'action' => 'join',
'id' => $cm->id,
'bn' => $bigbluebuttonbn->id,
'timeline' => 1, ],
);
}
return $factory->create_instance($string, $url, 1, $actionable);
}
/**
* Is the event visible?
*
* @param calendar_event $event
* @return bool Returns true if the event is visible to the current user, false otherwise.
*/
function mod_bigbluebuttonbn_core_calendar_is_event_visible(calendar_event $event) {
$instance = instance::get_from_instanceid($event->instance);
if (!$instance) {
return false;
}
$activitystatus = mod_bigbluebuttonbn\local\proxy\bigbluebutton_proxy::view_get_activity_status($instance);
return $activitystatus != 'ended';
}
/**
* Adds module specific settings to the settings block
*
* @param settings_navigation $settingsnav The settings navigation object
* @param navigation_node $nodenav The node to add module settings to
*/
function bigbluebuttonbn_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $nodenav) {
global $PAGE, $USER;
// Don't add validate completion if the callback for meetingevents is NOT enabled.
if (!(boolean) \mod_bigbluebuttonbn\local\config::get('meetingevents_enabled')) {
return;
}
// Don't add validate completion if user is not allowed to edit the activity.
$context = context_module::instance($PAGE->cm->id);
if (!has_capability('moodle/course:manageactivities', $context, $USER->id)) {
return;
}
$completionvalidate = '#action=completion_validate&bigbluebuttonbn=' . $PAGE->cm->instance;
$nodenav->add(get_string('completionvalidatestate', 'bigbluebuttonbn'),
$completionvalidate, navigation_node::TYPE_CONTAINER);
}
/**
* In place editable for the recording table
*
* @param string $itemtype
* @param string $itemid
* @param mixed $newvalue
* @return mixed|null
*/
function bigbluebuttonbn_inplace_editable($itemtype, $itemid, $newvalue) {
$editableclass = "\\mod_bigbluebuttonbn\\output\\recording_{$itemtype}_editable";
if (class_exists($editableclass)) {
return call_user_func([$editableclass, 'update'], $itemid, $newvalue);
}
return null; // Will raise an exception in core update_inplace_editable method.
}
/**
* Returns all events since a given time in specified bigbluebutton activity.
* We focus here on the two events: play and join.
*
* @param array $activities
* @param int $index
* @param int $timestart
* @param int $courseid
* @param int $cmid
* @param int $userid
* @param int $groupid
* @return array
*/
function bigbluebuttonbn_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid = 0,
$groupid = 0): array {
$instance = instance::get_from_cmid($cmid);
$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();
$activity->type = 'bigbluebuttonbn';
$activity->cmid = $cm->id;
$activity->name = format_string($instance->get_meeting_name(), true);
$activity->sectionnum = $cm->sectionnum;
$activity->timestamp = $log->timecreated;
$activity->user = new stdClass();
$userfields = explode(',', implode(',', \core_user\fields::get_picture_fields()));
foreach ($userfields as $userfield) {
if ($userfield == 'id') {
// Aliased in SQL above.
$activity->user->{$userfield} = $log->userid;
} else {
$activity->user->{$userfield} = $log->{$userfield};
}
}
$activity->user->fullname = fullname($log);
$activity->content = '';
$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');
}
}
}
}
$activities[$index++] = $activity;
}
return $activities;
}
/**
* Outputs the bigbluebutton logs indicated by $activity.
*
* @param stdClass $activity the activity object the bigbluebuttonbn resides in
* @param int $courseid the id of the course the bigbluebuttonbn resides in
* @param bool $detail not used, but required for compatibilty with other modules
* @param array $modnames not used, but required for compatibilty with other modules
* @param bool $viewfullnames not used, but required for compatibilty with other modules
*/
function bigbluebuttonbn_print_recent_mod_activity(stdClass $activity, int $courseid, bool $detail, array $modnames,
bool $viewfullnames) {
global $OUTPUT;
$modinfo = [];
$userpicture = $OUTPUT->user_picture($activity->user);
$template = ['userpicture' => $userpicture,
'submissiontimestamp' => $activity->timestamp,
'modinfo' => $modinfo,
'userurl' => new moodle_url('/user/view.php', ['id' => $activity->user->id, 'course' => $courseid]),
'fullname' => $activity->user->fullname, ];
if (isset($activity->eventname)) {
$template['eventname'] = $activity->eventname;
}
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' => $course->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;
}