first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
Binary file not shown.
@@ -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/>.
/**
* Provides the information for backup.
*
* @package mod_bigbluebuttonbn
* @copyright 2023 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Laurent David (laurent@call-learning.fr)
*/
class backup_bbbext_simple_subplugin extends backup_subplugin {
/**
* Returns the subplugin information to attach the BigBlueButton instance.
*
* @return backup_subplugin_element
*/
protected function define_bigbluebuttonbn_subplugin_structure() {
// Create XML elements.
$subplugin = $this->get_subplugin_element();
$subpluginwrapper = new backup_nested_element($this->get_recommended_name());
$subpluginelement = new backup_nested_element(
'bbbext_simple',
null,
['newfield', 'completionextraisehandtwice']
);
// Connect XML elements into the tree.
$subplugin->add_child($subpluginwrapper);
$subpluginwrapper->add_child($subpluginelement);
// Set source to populate the data.
$subpluginelement->set_source_table(
'bbbext_simple',
['bigbluebuttonbnid' => backup::VAR_PARENTID]
);
return $subplugin;
}
}
@@ -0,0 +1,57 @@
<?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/>.
/**
* Provides the information for restore.
*
*
* @package mod_bigbluebuttonbn
* @copyright 2023 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Laurent David (laurent@call-learning.fr)
*/
class restore_bbbext_simple_subplugin extends restore_subplugin {
/**
* Returns the paths to be handled by the subplugin.
*
* @return array
*/
protected function define_bigbluebuttonbn_subplugin_structure() {
$paths = [];
$elename = $this->get_namefor('bigbluebuttonbn');
// We used get_recommended_name() so this works.
$elepath = $this->get_pathfor('/bbbext_simple');
$paths[] = new restore_path_element($elename, $elepath);
return $paths;
}
/**
* Processes one subplugin instance additional parameter.
*
* @param mixed $data
*/
public function process_bbbext_simple_bigbluebuttonbn($data) {
global $DB;
$data = (object) $data;
$data->bigbluebuttonbnid = $this->get_new_parentid('bigbluebuttonbn');
$DB->insert_record('bbbext_simple', $data);
}
}
@@ -0,0 +1,58 @@
<?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 bbbext_simple\bigbluebuttonbn;
/**
* A single action class to mutate the action URL.
*
* @package mod_bigbluebuttonbn
* @copyright 2023 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Laurent David (laurent@call-learning.fr)
*/
class action_url_addons extends \mod_bigbluebuttonbn\local\extension\action_url_addons {
/**
* Sample mutate the action URL.
*
*
* @param string $action
* @param array $data
* @param array $metadata
* @param int|null $instanceid
* @return array associative array with the additional data and metadata (indexed by 'data' and
* 'metadata' keys)
*/
public function execute(
string $action = '',
array $data = [],
array $metadata = [],
?int $instanceid = null
): array {
if ($action == 'create' || $action == 'join') {
global $DB;
$record = $DB->get_record('bbbext_simple', [
'bigbluebuttonbnid' => $instanceid,
]);
if ($record) {
$metadata['newfield'] = $record->newfield ?? '';
}
}
return [
'data' => $data,
'metadata' => $metadata,
];
}
}
@@ -0,0 +1,82 @@
<?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 bbbext_simple\bigbluebuttonbn;
use mod_bigbluebuttonbn\instance;
use mod_bigbluebuttonbn\logger;
/**
* A class to deal with completion rules addons in a subplugin
*
* @package mod_bigbluebuttonbn
* @copyright 2023 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Laurent David (laurent@call-learning.fr)
*/
class custom_completion_addons extends \mod_bigbluebuttonbn\local\extension\custom_completion_addons {
/**
* Get defined custom rule
*
* @return string[]
*/
public static function get_defined_custom_rules(): array {
return ['completionextraisehandtwice'];
}
/**
* Get state
*
* @param string $rule
* @return int
*/
public function get_state(string $rule): int {
$instance = instance::get_from_cmid($this->cm->id);
$logs = logger::get_user_completion_logs($instance, $this->userid, [logger::EVENT_SUMMARY]);
$raisehandcount = 0;
foreach ($logs as $log) {
$summary = json_decode($log->meta);
$raisehandcount += intval($summary->data->engagement->raisehand ?? 0);
}
if ($raisehandcount >= 2) {
return COMPLETION_COMPLETE;
}
return COMPLETION_INCOMPLETE;
}
/**
* Get rule description
*
* @return array
* @throws \coding_exception
*/
public function get_custom_rule_descriptions(): array {
return [
'completionextraisehandtwice' => get_string('completionextraisehandtwice_desc', 'bbbext_simple'),
];
}
/**
* Get sort order
*
* @return string[]
*/
public function get_sort_order(): array {
return [
'completionattendance',
];
}
}
@@ -0,0 +1,126 @@
<?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 bbbext_simple\bigbluebuttonbn;
use stdClass;
/**
* A class for the main mod form extension
*
* @package mod_bigbluebuttonbn
* @copyright 2023 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Laurent David (laurent@call-learning.fr)
*/
class mod_form_addons extends \mod_bigbluebuttonbn\local\extension\mod_form_addons {
/**
* Allows modules to modify the data returned by form get_data().
* This method is also called in the bulk activity completion form.
*
* Only available on moodleform_mod.
*
* @param stdClass $data passed by reference
*/
public function data_postprocessing(\stdClass &$data): void {
// Nothing for now.
}
/**
* Allow module to modify the data at the pre-processing stage.
*
* This method is also called in the bulk activity completion form.
*
* @param array|null $defaultvalues
*/
public function data_preprocessing(?array &$defaultvalues): void {
// This is where we can add the data from the flexurl table to the data provided.
if (!empty($defaultvalues['id'])) {
global $DB;
$flexurlrecord = $DB->get_record('bbbext_simple', [
'bigbluebuttonbnid' => $defaultvalues['id'],
]);
if ($flexurlrecord) {
$defaultvalues['newfield'] = $flexurlrecord->newfield;
}
}
}
/**
* Can be overridden to add custom completion rules if the module wishes
* them. If overriding this, you should also override completion_rule_enabled.
* <p>
* Just add elements to the form as needed and return the list of IDs. The
* system will call disabledIf and handle other behaviour for each returned
* ID.
*
* @return array Array of string IDs of added items, empty array if none
*/
public function add_completion_rules(): array {
$this->mform->addElement('advcheckbox', 'completionextraisehandtwice',
get_string('completionextraisehandtwice', 'bbbext_simple'),
get_string('completionextraisehandtwice_desc', 'bbbext_simple'));
$this->mform->addHelpButton('completionextraisehandtwice', 'completionextraisehandtwice',
'bbbext_simple');
$this->mform->disabledIf('completionextraisehandtwice', 'completion', 'neq', COMPLETION_AGGREGATION_ANY);
return ['completionextraisehandtwice' . $this->suffix];
}
/**
* Called during validation. Override to indicate, based on the data, whether
* a custom completion rule is enabled (selected).
*
* @param array $data Input data (not yet validated)
* @return bool True if one or more rules is enabled, false if none are;
* default returns false
*/
public function completion_rule_enabled(array $data): bool {
return !empty($data['completionextraisehandtwice' . $this->suffix]);
}
/**
* Form adjustments after setting data
*
* @return void
*/
public function definition_after_data() {
// Nothing for now.
}
/**
* Add new form field definition
*/
public function add_fields(): void {
$this->mform->addElement('header', 'simple', get_string('pluginname', 'bbbext_simple'));
$this->mform->addElement('text', 'newfield', get_string('newfield', 'bbbext_simple'));
$this->mform->setType('newfield', PARAM_TEXT);
}
/**
* Validate form and returns an array of errors indexed by field name
*
* @param array $data
* @param array $files
* @return array
*/
public function validation(array $data, array $files): array {
$errors = [];
if (empty($data['newfield' . $this->suffix])) {
$errors['newfield'] = get_string('newfielderror', 'bbbext_simple');
}
return $errors;
}
}
@@ -0,0 +1,86 @@
<?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 bbbext_simple\bigbluebuttonbn;
use stdClass;
/**
* Class defining a way to deal with instance save/update/delete in extension
*
* @package mod_bigbluebuttonbn
* @copyright 2023 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Laurent David (laurent@call-learning.fr)
*/
class mod_instance_helper extends \mod_bigbluebuttonbn\local\extension\mod_instance_helper {
/**
* Runs any processes that must run before a bigbluebuttonbn insert/update.
*
* @param stdClass $bigbluebuttonbn BigBlueButtonBN form data
**/
public function add_instance(stdClass $bigbluebuttonbn) {
global $DB;
$DB->insert_record('bbbext_simple', (object) [
'bigbluebuttonbnid' => $bigbluebuttonbn->id,
'newfield' => $bigbluebuttonbn->newfield ?? '',
'completionextraisehandtwice' => $bigbluebuttonbn->completionextraisehandtwice ?? '',
]);
}
/**
* Runs any processes that must be run after a bigbluebuttonbn insert/update.
*
* @param stdClass $bigbluebuttonbn BigBlueButtonBN form data
**/
public function update_instance(stdClass $bigbluebuttonbn): void {
global $DB;
$record = $DB->get_record('bbbext_simple', [
'bigbluebuttonbnid' => $bigbluebuttonbn->id,
]);
// Just in case the instance was created before the extension was installed.
if (empty($record)) {
$record = new stdClass();
$record->bigbluebuttonbnid = $bigbluebuttonbn->id;
$record->newfield = $bigbluebuttonbn->newfield ?? '';
$record->completionextraisehandtwice = $bigbluebuttonbn->completionextraisehandtwice ?? 0;
$DB->insert_record('bbbext_simple', $record);
} else {
$record->newfield = $bigbluebuttonbn->newfield ?? '';
$record->completionextraisehandtwice = $bigbluebuttonbn->completionextraisehandtwice ?? 0;
$DB->update_record('bbbext_simple', $record);
}
}
/**
* Runs any processes that must be run after a bigbluebuttonbn delete.
*
* @param int $id
*/
public function delete_instance(int $id): void {
global $DB;
$DB->delete_records('bbbext_simple', [
'bigbluebuttonbnid' => $id,
]);
}
/**
* Get any join table name that is used to store additional data for the instance.
* @return string[]
*/
public function get_join_tables(): array {
return ['bbbext_simple'];
}
}
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/bigbluebuttonbn/tests/fixtures/extension/simple/db" VERSION="20230210" COMMENT="XMLDB file for Moodle mod/bigbluebuttonbn/extension/simple"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="bbbext_simple" COMMENT="Default comment for bbbext_simple, please edit me">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="bigbluebuttonbnid" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="newfield" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="completionextraisehandtwice" TYPE="int" LENGTH="9" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="fk_bigbluebuttonbnid" TYPE="foreign-unique" FIELDS="bigbluebuttonbnid" REFTABLE="bigbluebuttonbn" REFFIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
@@ -0,0 +1,32 @@
<?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/>.
/**
* Language File.
*
* @package mod_bigbluebuttonbn
* @copyright 2023 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Laurent David (laurent@call-learning.fr)
*/
defined('MOODLE_INTERNAL') || die();
$string['config_extension'] = 'Sample config extension setting';
$string['newfield'] = 'New field';
$string['newfielderror'] = 'New field cannot be empty';
$string['pluginname'] = 'Simple BigBlueButtonPlugin';
$string['completionextraisehandtwice'] = 'Raise hand twice';
$string['completionextraisehandtwice_desc'] = 'Raise hand twice in a meeting.';
$string['completionextraisehandtwice_help'] = 'Raise hand twice in a meeting.';
@@ -0,0 +1,34 @@
<?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/>.
/**
* This file defines the admin settings for this plugin
*
* @package mod_bigbluebuttonbn
* @copyright 2023 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Laurent David (laurent [at] call-learning [dt] fr)
*/
defined('MOODLE_INTERNAL') || die;
$settings->add(new admin_setting_configtext(
'bbbext_simple/config_extension',
new lang_string('config_extension', 'bbbext_simple'),
new lang_string('config_extension', 'bbbext_simple'),
1024,
PARAM_TEXT)
);
@@ -0,0 +1,29 @@
<?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/>.
/**
* This file contains the version information for the sample bigbluebuttonbn subplugin
*
* @package mod_bigbluebuttonbn
* @copyright 2023 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Laurent David (laurent [at] call-learning [dt] fr)
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2023020800;
$plugin->requires = 2023020300;
$plugin->component = 'bbbext_simple';