Skip to content

Commit

Permalink
added hook for gradebook
Browse files Browse the repository at this point in the history
  • Loading branch information
jfederico committed Aug 27, 2024
1 parent 056f473 commit ddca69a
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 1 deletion.
20 changes: 20 additions & 0 deletions mod/bigbluebuttonbn/classes/extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use cm_info;
use mod_bigbluebuttonbn\local\extension\action_url_addons;
use mod_bigbluebuttonbn\local\extension\custom_completion_addons;
use mod_bigbluebuttonbn\local\extension\gradebook_addons;
use mod_bigbluebuttonbn\local\extension\mod_form_addons;
use mod_bigbluebuttonbn\local\extension\mod_instance_helper;
use stdClass;
Expand Down Expand Up @@ -217,4 +218,23 @@ public static function delete_instance(int $id): void {
$fmclass->delete_instance($id);
}
}

/**
* Get all gradebook addons classes.
*
* @return array of gradebook addon classes.
*/
public static function gradebook_addons_classes(): array {
return self::get_classes_implementing(gradebook_addons::class);
}

/**
* Get all gradebook addons classes instances
*
* @param stdClass|null $modinstance
* @return array of gradebook addon classes instances
*/
public static function gradebook_addons_instances(stdClass $modinstance): array {
return self::get_instances_implementing(gradebook_addons::class, [$modinstance]);
}
}
55 changes: 55 additions & 0 deletions mod/bigbluebuttonbn/classes/local/extension/gradebook_addons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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/>.

namespace mod_bigbluebuttonbn\local\extension;

use stdClass;
use mod_bigbluebuttonbn\instance;

/**
* A class to deal with broker addons in a subplugin
*
* @package mod_bigbluebuttonbn
* @copyright 2024 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)
*/
abstract class broker_meeting_events_addons {

/**
* @var stdClass $modinstance The instance of the activity in the database
*/
protected $modinstance;

/**
* Constructor
*
* @param instance $instance BigBlueButton instance
*/
public function __construct(stdClass $modinstance) {
$this->modinstance = $modinstance;
}

/**
* Update the grade item for a given activity
*/
abstract public function grade_item_update($grades=NULL);

/**
* Update the grade(s) for the supplied user
*/
abstract public function update_grades($userid=0, $nullifnone=true);
}
38 changes: 37 additions & 1 deletion mod/bigbluebuttonbn/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function bigbluebuttonbn_supports($feature) {
FEATURE_BACKUP_MOODLE2 => true,
FEATURE_COMPLETION_TRACKS_VIEWS => true,
FEATURE_COMPLETION_HAS_RULES => true,
FEATURE_GRADE_HAS_GRADE => false,
FEATURE_GRADE_HAS_GRADE => true,
FEATURE_GRADE_OUTCOMES => false,
FEATURE_SHOW_DESCRIPTION => true,
FEATURE_MOD_PURPOSE => MOD_PURPOSE_COMMUNICATION,
Expand Down Expand Up @@ -279,6 +279,42 @@ function bigbluebuttonbn_get_extra_capabilities() {
return ['moodle/site:accessallgroups'];
}

/**
* Create grade item for given activity.
*
* @param stdClass $bigbluebuttonbn record with extra cmidnumber
* @param array $grades optional array/object of grade(s); 'reset' means reset grades in gradebook
* @return int 0 if ok, error code otherwise
*/
function bigbluebuttonbn_grade_item_update($bigbluebuttonbn, $grades=null) {
global $CFG;
require_once($CFG->libdir.'/gradelib.php');

// Hooks for extensions.
$extensions = extension::gradebook_addons_instances($bigbluebuttonbn);
foreach ($extensions as $extension) {
$extension->grade_item_update($grades);
}
}

/**
* Update activity grades.
*
* @param stdClass $bigbluebuttonbn database record
* @param int $userid specific user only, 0 means all
* @param bool $nullifnone - not used
*/
function bigbluebuttonbn_update_grades($bigbluebuttonbn, $userid=0, $nullifnone=true) {
global $CFG;
require_once($CFG->libdir.'/gradelib.php');

// Hooks for extensions.
$extensions = extension::gradebook_addons_instances($bigbluebuttonbn);
foreach ($extensions as $extension) {
$extension->update_grades($userid, $nullifnone);
}
}

/**
* Called by course/reset.php
*
Expand Down

0 comments on commit ddca69a

Please sign in to comment.