|
24 | 24 | * @author Fred Dixon (ffdixon [at] blindsidenetworks [dt] com)
|
25 | 25 | */
|
26 | 26 | defined('MOODLE_INTERNAL') || die;
|
| 27 | +require_once("$CFG->libdir/gradelib.php"); |
27 | 28 |
|
28 | 29 | use core_calendar\action_factory;
|
29 | 30 | use core_calendar\local\event\entities\action_interface;
|
@@ -72,7 +73,7 @@ function bigbluebuttonbn_supports($feature) {
|
72 | 73 | FEATURE_BACKUP_MOODLE2 => true,
|
73 | 74 | FEATURE_COMPLETION_TRACKS_VIEWS => true,
|
74 | 75 | FEATURE_COMPLETION_HAS_RULES => true,
|
75 |
| - FEATURE_GRADE_HAS_GRADE => false, |
| 76 | + FEATURE_GRADE_HAS_GRADE => true, |
76 | 77 | FEATURE_GRADE_OUTCOMES => false,
|
77 | 78 | FEATURE_SHOW_DESCRIPTION => true,
|
78 | 79 | FEATURE_MOD_PURPOSE => MOD_PURPOSE_COMMUNICATION,
|
@@ -111,6 +112,9 @@ function bigbluebuttonbn_add_instance($bigbluebuttonbn) {
|
111 | 112 |
|
112 | 113 | // Call any active subplugin so to signal a new creation.
|
113 | 114 | extension::add_instance($bigbluebuttonbn);
|
| 115 | + |
| 116 | + bigbluebuttonbn_grade_item_update($bigbluebuttonbn); |
| 117 | + |
114 | 118 | return $bigbluebuttonbn->id;
|
115 | 119 | }
|
116 | 120 |
|
@@ -138,6 +142,8 @@ function bigbluebuttonbn_update_instance($bigbluebuttonbn) {
|
138 | 142 | // Update a record.
|
139 | 143 | $DB->update_record('bigbluebuttonbn', $bigbluebuttonbn);
|
140 | 144 |
|
| 145 | + bigbluebuttonbn_grade_item_update($bigbluebuttonbn); |
| 146 | + |
141 | 147 | // Get the meetingid column in the bigbluebuttonbn table.
|
142 | 148 | $bigbluebuttonbn->meetingid = (string) $DB->get_field('bigbluebuttonbn', 'meetingid', ['id' => $bigbluebuttonbn->id]);
|
143 | 149 |
|
@@ -757,3 +763,27 @@ function bigbluebuttonbn_course_backend_generator_create_activity(tool_generator
|
757 | 763 | function bigbluebuttonbn_is_branded(): bool {
|
758 | 764 | return true;
|
759 | 765 | }
|
| 766 | + |
| 767 | +/** |
| 768 | + * Update/create grade item for given BigBlueButtonBN activity |
| 769 | + * |
| 770 | + * @category grade |
| 771 | + * @param stdClass $instance A BBB instance object with extra cmidnumber |
| 772 | + * @param mixed $grades Optional array/object of grade(s); 'reset' means reset grades in gradebook |
| 773 | + * @return object grade_item |
| 774 | + */ |
| 775 | +function bigbluebuttonbn_grade_item_update(stdclass $bigbluebuttonbn, $grades=NULL) { |
| 776 | + if (!function_exists('grade_update')) { //workaround for buggy PHP versions |
| 777 | + require_once($CFG->libdir.'/gradelib.php'); |
| 778 | + } |
| 779 | + $params = array('itemname' => $bigbluebuttonbn->name); |
| 780 | + if ($bigbluebuttonbn->grade > 0) { |
| 781 | + $params['gradetype'] = GRADE_TYPE_VALUE; |
| 782 | + $params['grademax'] = $bigbluebuttonbn->grade; |
| 783 | + $params['grademin'] = 0; |
| 784 | + |
| 785 | + } else { |
| 786 | + $params['gradetype'] = GRADE_TYPE_NONE; |
| 787 | + } |
| 788 | + return grade_update('mod/bigbluebuttonbn', $bigbluebuttonbn->course, 'mod', 'bigbluebuttonbn', $bigbluebuttonbn->id, 0, $grades, $params); |
| 789 | +} |
0 commit comments