1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
namespace mod_bigbluebuttonbn\task;
|
|
|
18 |
|
|
|
19 |
use core\task\adhoc_task;
|
|
|
20 |
use core_user;
|
|
|
21 |
use mod_bigbluebuttonbn\local\proxy\bigbluebutton_proxy;
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* Class containing the scheduled task for updating the completion state.
|
|
|
25 |
*
|
|
|
26 |
* @package mod_bigbluebuttonbn
|
|
|
27 |
* @copyright 2019 onwards, Blindside Networks Inc
|
|
|
28 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
29 |
*/
|
|
|
30 |
class completion_update_state extends adhoc_task {
|
|
|
31 |
/**
|
|
|
32 |
* Run bigbluebuttonbn cron.
|
|
|
33 |
*/
|
|
|
34 |
public function execute() {
|
|
|
35 |
// Get the custom data.
|
|
|
36 |
$data = $this->get_custom_data();
|
|
|
37 |
|
|
|
38 |
// Ensure the customdata structure is corect.
|
|
|
39 |
if (empty($data->bigbluebuttonbn->id) || empty($data->userid)) {
|
|
|
40 |
throw new \coding_exception("Task customdata was missing bigbluebuttonbn->id or userid");
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
// If coursemodule does not exist, ignore (likely has been deleted).
|
|
|
44 |
if (get_coursemodule_from_instance('bigbluebuttonbn', $data->bigbluebuttonbn->id) === false) {
|
|
|
45 |
mtrace("Course module does not exist, ignoring.");
|
|
|
46 |
return;
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
// If user does not exist, ignore (likely has been deleted).
|
|
|
50 |
if (core_user::get_user($data->userid) === false) {
|
|
|
51 |
mtrace("User does not exist, ignoring.");
|
|
|
52 |
return;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
mtrace("Task completion_update_state running for user {$data->userid}");
|
|
|
56 |
|
|
|
57 |
// Process the completion.
|
|
|
58 |
bigbluebutton_proxy::update_completion_state($data->bigbluebuttonbn, $data->userid);
|
|
|
59 |
}
|
|
|
60 |
}
|