Skip to content

Commit ddca69a

Browse files
committed
added hook for gradebook
1 parent 056f473 commit ddca69a

File tree

3 files changed

+112
-1
lines changed

3 files changed

+112
-1
lines changed

mod/bigbluebuttonbn/classes/extension.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use cm_info;
2020
use mod_bigbluebuttonbn\local\extension\action_url_addons;
2121
use mod_bigbluebuttonbn\local\extension\custom_completion_addons;
22+
use mod_bigbluebuttonbn\local\extension\gradebook_addons;
2223
use mod_bigbluebuttonbn\local\extension\mod_form_addons;
2324
use mod_bigbluebuttonbn\local\extension\mod_instance_helper;
2425
use stdClass;
@@ -217,4 +218,23 @@ public static function delete_instance(int $id): void {
217218
$fmclass->delete_instance($id);
218219
}
219220
}
221+
222+
/**
223+
* Get all gradebook addons classes.
224+
*
225+
* @return array of gradebook addon classes.
226+
*/
227+
public static function gradebook_addons_classes(): array {
228+
return self::get_classes_implementing(gradebook_addons::class);
229+
}
230+
231+
/**
232+
* Get all gradebook addons classes instances
233+
*
234+
* @param stdClass|null $modinstance
235+
* @return array of gradebook addon classes instances
236+
*/
237+
public static function gradebook_addons_instances(stdClass $modinstance): array {
238+
return self::get_instances_implementing(gradebook_addons::class, [$modinstance]);
239+
}
220240
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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\local\extension;
18+
19+
use stdClass;
20+
use mod_bigbluebuttonbn\instance;
21+
22+
/**
23+
* A class to deal with broker addons in a subplugin
24+
*
25+
* @package mod_bigbluebuttonbn
26+
* @copyright 2024 onwards, Blindside Networks Inc
27+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28+
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
29+
*/
30+
abstract class broker_meeting_events_addons {
31+
32+
/**
33+
* @var stdClass $modinstance The instance of the activity in the database
34+
*/
35+
protected $modinstance;
36+
37+
/**
38+
* Constructor
39+
*
40+
* @param instance $instance BigBlueButton instance
41+
*/
42+
public function __construct(stdClass $modinstance) {
43+
$this->modinstance = $modinstance;
44+
}
45+
46+
/**
47+
* Update the grade item for a given activity
48+
*/
49+
abstract public function grade_item_update($grades=NULL);
50+
51+
/**
52+
* Update the grade(s) for the supplied user
53+
*/
54+
abstract public function update_grades($userid=0, $nullifnone=true);
55+
}

mod/bigbluebuttonbn/lib.php

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function bigbluebuttonbn_supports($feature) {
7272
FEATURE_BACKUP_MOODLE2 => true,
7373
FEATURE_COMPLETION_TRACKS_VIEWS => true,
7474
FEATURE_COMPLETION_HAS_RULES => true,
75-
FEATURE_GRADE_HAS_GRADE => false,
75+
FEATURE_GRADE_HAS_GRADE => true,
7676
FEATURE_GRADE_OUTCOMES => false,
7777
FEATURE_SHOW_DESCRIPTION => true,
7878
FEATURE_MOD_PURPOSE => MOD_PURPOSE_COMMUNICATION,
@@ -279,6 +279,42 @@ function bigbluebuttonbn_get_extra_capabilities() {
279279
return ['moodle/site:accessallgroups'];
280280
}
281281

282+
/**
283+
* Create grade item for given activity.
284+
*
285+
* @param stdClass $bigbluebuttonbn record with extra cmidnumber
286+
* @param array $grades optional array/object of grade(s); 'reset' means reset grades in gradebook
287+
* @return int 0 if ok, error code otherwise
288+
*/
289+
function bigbluebuttonbn_grade_item_update($bigbluebuttonbn, $grades=null) {
290+
global $CFG;
291+
require_once($CFG->libdir.'/gradelib.php');
292+
293+
// Hooks for extensions.
294+
$extensions = extension::gradebook_addons_instances($bigbluebuttonbn);
295+
foreach ($extensions as $extension) {
296+
$extension->grade_item_update($grades);
297+
}
298+
}
299+
300+
/**
301+
* Update activity grades.
302+
*
303+
* @param stdClass $bigbluebuttonbn database record
304+
* @param int $userid specific user only, 0 means all
305+
* @param bool $nullifnone - not used
306+
*/
307+
function bigbluebuttonbn_update_grades($bigbluebuttonbn, $userid=0, $nullifnone=true) {
308+
global $CFG;
309+
require_once($CFG->libdir.'/gradelib.php');
310+
311+
// Hooks for extensions.
312+
$extensions = extension::gradebook_addons_instances($bigbluebuttonbn);
313+
foreach ($extensions as $extension) {
314+
$extension->update_grades($userid, $nullifnone);
315+
}
316+
}
317+
282318
/**
283319
* Called by course/reset.php
284320
*

0 commit comments

Comments
 (0)