MDL-71378 mod_qbank: Add initial plugin structure

This commit is contained in:
Simon Adams
2024-11-15 15:18:46 +00:00
parent 269a8a8a1b
commit 78d73cc9b7
20 changed files with 749 additions and 9 deletions
+2 -9
View File
@@ -163,17 +163,10 @@ class mod extends base {
}
/**
* Allow all activity modules but Forum to be uninstalled.
*
* This exception for the Forum has been hard-coded in Moodle since ages,
* we may want to re-think it one day.
* Activity modules that declare feature flag FEATURE_CAN_UNINSTALL as false cannot be uninstalled.
*/
public function is_uninstall_allowed() {
if ($this->name === 'forum') {
return false;
} else {
return true;
}
return plugin_supports('mod', $this->name, FEATURE_CAN_UNINSTALL, true);
}
/**
+9
View File
@@ -451,6 +451,15 @@ define('FEATURE_RATE', 'rate');
/** True if module supports backup/restore of moodle2 format */
define('FEATURE_BACKUP_MOODLE2', 'backup_moodle2');
/** True if module shares questions with other modules. */
define('FEATURE_PUBLISHES_QUESTIONS', 'publishesquestions');
/** Used to determine if a plugin should render to display */
define('FEATURE_CAN_DISPLAY', 'candisplay');
/** Can this module type be uninstalled */
define('FEATURE_CAN_UNINSTALL', 'canuninstall');
/** True if module can show description on course main page */
define('FEATURE_SHOW_DESCRIPTION', 'showdescription');
+1
View File
@@ -325,6 +325,7 @@
"lesson",
"lti",
"page",
"qbank",
"quiz",
"resource",
"scorm",
+2
View File
@@ -371,6 +371,8 @@ function forum_supports($feature) {
case FEATURE_PLAGIARISM: return true;
case FEATURE_ADVANCED_GRADING: return true;
case FEATURE_MOD_PURPOSE: return MOD_PURPOSE_COLLABORATION;
case FEATURE_CAN_UNINSTALL:
return false;
default: return null;
}
@@ -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/>.
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/qbank/backup/moodle2/backup_qbank_stepslib.php');
/**
* Qbank module backup task that provides all the settings and steps to perform one complete backup of the activity.
*
* @package mod_qbank
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_qbank_activity_task extends backup_activity_task {
/**
* Define (add) particular settings this activity can have
*/
protected function define_my_settings() {
// No particular settings for this activity.
}
/**
* Define (add) particular steps this activity can have
*/
protected function define_my_steps() {
// Qbank only has one structure step
$this->add_step(new backup_qbank_activity_structure_step('qbank_structure', 'qbank.xml'));
}
/**
* Code the transformations to perform in the activity in
* order to get transportable (encoded) links
*
* @param string $content some HTML text that eventually contains URLs to the activity instance scripts
* @return string encoded content
*/
public static function encode_content_links($content) {
return $content;
}
}
@@ -0,0 +1,63 @@
<?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/>.
/**
* Define the complete qbank structure for backup, with file and id annotations.
*
* @package mod_qbank
* @category backup
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_qbank_activity_structure_step extends backup_activity_structure_step {
/**
* Define the mod_qbank activity structure.
*
* @return backup_nested_element
*/
protected function define_structure(): backup_nested_element {
// Define each element separated.
$qbank = new backup_nested_element(
'qbank',
['id'],
[
'name',
'timecreated',
'timemodified',
'intro',
'introformat',
'type',
],
);
// Build the tree.
// (No tree).
// Define sources.
$qbank->set_source_table('qbank', ['id' => backup::VAR_ACTIVITYID]);
// Define id annotations.
// (none).
// Define file annotations.
$qbank->annotate_files('mod_qbank', 'intro', null); // This file area does not have an itemid.
// Return the root element (qbank), wrapped into standard activity structure.
return $this->prepare_activity_structure($qbank);
}
}
@@ -0,0 +1,76 @@
<?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/>.
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/qbank/backup/moodle2/restore_qbank_stepslib.php');
/**
* The task that provides a complete restore of mod_qbank.
*
* @package mod_qbank
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_qbank_activity_task extends restore_activity_task {
/**
* Defines particular settings that this activity can have.
*/
protected function define_my_settings(): void {
// No particular settings for this activity.
}
/**
* Defines particular steps that this activity can have.
*
* @return void.
*/
protected function define_my_steps(): void {
// Qbank only has one structure step.
$this->add_step(new restore_qbank_activity_structure_step('qbank_structure', 'qbank.xml'));
}
/**
* Defines the contents in the activity that must be processed by the link decoder.
*
* @return array.
*/
public static function define_decode_contents(): array {
return [];
}
/**
* Defines the decoding rules for links belonging to the activity to be executed by the link decoder.
*
* @return restore_decode_rule[].
*/
public static function define_decode_rules(): array {
return [];
}
/**
* Defines the restore log rules that will be applied by the
* {@see restore_logs_processor} when restoring mod_qbank logs. It
* must return one array of {@see restore_log_rule} objects.
*
* @return restore_log_rule[].
*/
public static function define_restore_log_rules(): array {
return [];
}
}
@@ -0,0 +1,63 @@
<?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/>.
/**
* Defines the structure step to restore one mod_qbank activity.
*
* @package mod_qbank
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_qbank_activity_structure_step extends restore_activity_structure_step {
/**
* Defines the structure to be restored.
*
* @return restore_path_element[].
*/
protected function define_structure(): array {
$paths = [];
$paths[] = new restore_path_element('qbank', '/activity/qbank');
// Return the paths wrapped into standard activity structure.
return $this->prepare_activity_structure($paths);
}
/**
* Processes the qbank restore data.
*
* @param array $data Parsed element data.
*/
protected function process_qbank(array $data): void {
global $DB;
$data['course'] = $this->get_courseid();
// Insert the record.
$newitemid = $DB->insert_record('qbank', $data);
// Immediately after inserting "activity" record, call this.
$this->apply_activity_instance($newitemid);
}
/**
* Defines post-execution actions.
*/
protected function after_execute(): void {
// Add qbank related files, no need to match by itemname (just internally handled context).
$this->add_related_files('mod_qbank', 'intro', null);
}
}
@@ -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/>.
namespace mod_qbank\event;
/**
* The mod_qbank instance list viewed event class.
*
* @package mod_qbank
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed {
// No code required here as the parent class handles it all.
}
+37
View File
@@ -0,0 +1,37 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
namespace mod_qbank\privacy;
/**
* Privacy Subsystem implementation for mod_qbank.
*
* @package mod_qbank
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Return lang string identifier.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
/**
* Capability definitions for the question bank module.
*
* @package mod_qbank
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = [
// Ability to see that the question bank exists, and the basic information about it.
'mod/qbank:view' => [
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => [
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
],
// Ability to add a new question bank to the course.
'mod/qbank:addinstance' => [
'riskbitmask' => RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => [
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/course:manageactivities',
],
];
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/qbank/db" VERSION="20210420" COMMENT="XMLDB file for Moodle mod_qbank"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="qbank" COMMENT="Stores the qbank activity module instances.">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="ID of the course this activity is part of."/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The name of the activity module instance"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Timestamp of when the instance was added to the course."/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Timestamp of when the instance was last modified."/>
<FIELD NAME="intro" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Activity description."/>
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the intro field."/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="fk_course" TYPE="foreign" FIELDS="course" REFTABLE="course" REFFIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
+39
View File
@@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
/**
* Plugin upgrade steps are defined here.
*
* @package mod_qbank
* @category upgrade
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Execute mod_qbank upgrade from the given old version.
*
* @param int $oldversion
* @return bool
*/
function xmldb_qbank_upgrade($oldversion) {
global $DB;
$dbman = $DB->get_manager();
return true;
}
+33
View File
@@ -0,0 +1,33 @@
<?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 redirect to /question/banks.php to list all the instances of mod_qbank in a particular course.
*
* @package mod_qbank
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php");
$id = required_param('id', PARAM_INT);
$course = get_course($id);
require_login($course);
// Redirect to /question/banks.php as that page shows all the available banks on the course.
redirect(new moodle_url('/question/banks.php', ['courseid' => $course->id]));
+27
View File
@@ -0,0 +1,27 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
/**
* Plugin strings are defined here.
*
* @package mod_qbank
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Question bank';
$string['privacy:metadata'] = 'The Question bank plugin does not store any personal data, core_question automatically tracks all sorts of data for questions.';
+109
View File
@@ -0,0 +1,109 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
/**
* Library of interface functions and constants.
*
* @package mod_qbank
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Return if the plugin supports $feature.
*
* @param string $feature Constant representing the feature.
* @return bool|string|null True if module supports feature, false if not, null if it doesn't know or string for the module purpose.
*/
function qbank_supports(string $feature) {
switch ($feature) {
case FEATURE_BACKUP_MOODLE2:
case FEATURE_PUBLISHES_QUESTIONS:
case FEATURE_SHOW_DESCRIPTION:
case FEATURE_USES_QUESTIONS:
return true;
case FEATURE_CAN_DISPLAY:
case FEATURE_CAN_UNINSTALL:
case FEATURE_COMMENT:
case FEATURE_COMPLETION_HAS_RULES:
case FEATURE_COMPLETION_TRACKS_VIEWS:
case FEATURE_CONTROLS_GRADE_VISIBILITY:
case FEATURE_GRADE_OUTCOMES:
case FEATURE_MODEDIT_DEFAULT_COMPLETION:
return false;
case FEATURE_MOD_PURPOSE:
return MOD_PURPOSE_CONTENT;
default:
return null;
}
}
/**
* Saves a new instance of the mod_qbank into the database.
*
* Given an object containing all the necessary data,
* this function will create a new instance and return the id number of the instance.
*
* @param stdClass $moduleinstance An object from the form.
* @param mod_qbank_mod_form|null $mform The form. Not used in this function.
* @return int The id of the newly inserted record.
*/
function qbank_add_instance(stdClass $moduleinstance, ?mod_qbank_mod_form $mform): int {
global $DB;
$moduleinstance->timecreated = time();
return $DB->insert_record('qbank', $moduleinstance);
}
/**
* Updates an instance of the mod_qbank in the database.
* Given an object containing all the necessary data,
* this function will update an existing instance with new data.
*
* @param stdClass $moduleinstance An object from the form in mod_form.php.
* @param mod_qbank_mod_form|null $mform The form. Not used in this function.
* @return bool True if successful, false otherwise.
*/
function qbank_update_instance(stdClass $moduleinstance, ?mod_qbank_mod_form $mform): bool {
global $DB;
$moduleinstance->timemodified = time();
$moduleinstance->id = $moduleinstance->instance;
return $DB->update_record('qbank', $moduleinstance);
}
/**
* Removes an instance of the mod_qbank from the database.
* We don't need to do anything for questions, question_categories, or user records here
* as the module deletion API cleans that up for us.
*
* @param int $id id of the module instance.
* @return bool True if successful, false on failure.
*/
function qbank_delete_instance(int $id): bool {
global $DB;
if (!$DB->record_exists('qbank', ['id' => $id])) {
return false;
}
$DB->delete_records('qbank', ['id' => $id]);
return true;
}
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 25.2.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg width="24px" height="24px" version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
<g>
<path d="M15.2,7.6L10.8,7c-0.2,0-0.4,0.1-0.4,0.3v0.3c0,0.1,0.1,0.2,0.3,0.3l4.3,0.6c0.2,0,0.4-0.1,0.4-0.3V7.8
C15.4,7.7,15.3,7.6,15.2,7.6z"/>
<path d="M10.4,4.3c-0.1,0-0.3,0-0.3,0.1C8.9,6,8,7.9,7.6,8.9c0,0.1-0.2,0.1-0.3,0C7.2,8.5,6.9,8,6.5,7.5C6.4,7.3,6.2,7.3,6,7.4l0,0
C5.9,7.5,5.8,7.7,5.9,7.9c0.5,0.9,1,2,1.3,2.8c0.1,0.3,0.5,0.3,0.7,0c0.7-1.9,1.7-4.3,2.7-5.8C10.8,4.6,10.7,4.3,10.4,4.3z"/>
<path d="M5.9,16.9l4.4,0.7c0.4,0.1,0.6-0.1,0.6-0.5v-2c0-0.3-0.2-0.5-0.5-0.5l-4.5-0.8c-0.3,0-0.5,0.2-0.5,0.5v2
C5.4,16.6,5.5,16.8,5.9,16.9z M6.1,15.1c0-0.2,0.2-0.4,0.4-0.4l3.1,0.5c0.2,0,0.4,0.2,0.4,0.4v0.8c0,0.3-0.1,0.4-0.4,0.4l-3.1-0.5
c-0.2,0-0.4-0.2-0.4-0.4V15.1z"/>
<path d="M15.1,10l-4.4-0.6c-0.2,0-0.4,0.1-0.4,0.3v0.3c0,0.1,0.1,0.3,0.3,0.3l4.4,0.6c0.2,0,0.4-0.1,0.4-0.3v-0.3
C15.4,10.2,15.3,10.1,15.1,10z"/>
<path d="M22,8.6l-1.9-0.3V2.4c0-0.4-0.3-0.7-0.6-0.7L7.8,0.1C7.4,0,7,0.4,7,0.8v1.7L5.6,2.3C5.1,2.3,4.7,2.6,4.7,3v6.1l-2.9,1.7
c-0.2,0.1-0.4,0.3-0.4,0.6v9.2c0,0.4,0.3,0.7,0.6,0.8l12.9,2.5v0l0,0l0,0v0l7.2-4.6c0.2-0.2,0.3-0.4,0.3-0.8V9.3
C22.5,9,22.5,8.7,22,8.6z M21.2,9.3L20.1,10l0-0.8L21.2,9.3z M7.7,1.1c0-0.2,0.2-0.4,0.4-0.3l11,1.6c0.2,0,0.3,0.2,0.3,0.3l0,7.6
l-1.5,0.9V4.6c0-0.4-0.3-0.7-0.6-0.7L7.7,2.6V1.1z M4.7,10v1.3L3.1,11L4.7,10z M14.4,22.9L2.6,20.7c-0.2,0-0.4-0.3-0.4-0.5v-7.9
c0-0.3,0.3-0.5,0.5-0.5l11.7,1.9L14.4,22.9L14.4,22.9z M14.9,13l-9.4-1.6l0-8C5.5,3.2,5.7,3,5.9,3l10.9,1.5c0.2,0,0.3,0.2,0.3,0.3
v6.9L14.9,13z M21.8,18.3c0,0.2-0.1,0.5-0.2,0.5l-6.2,3.8v-9l5.9-3.4c0.2-0.1,0.4,0.1,0.4,0.4V18.3z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

@@ -0,0 +1,49 @@
<?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_qbank\backup;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->libdir . "/phpunit/classes/restore_date_testcase.php");
/**
* Restore test for mod_qbank.
*
* @package mod_qbank
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class restore_date_test extends \restore_date_testcase {
/**
* When restoring a course, you can change the start date, which shifts other dates.
* This test checks that certain dates are correctly modified.
*
* @covers \restore_dbops::create_new_course()
* @return void
*/
public function test_restore_dates(): void {
global $DB;
[$course, $module] = $this->create_course_and_module('qbank', ['timemodified' => time()]);
$newcourseid = $this->backup_and_restore($course);
$newmodule = $DB->get_record('qbank', ['course' => $newcourseid]);
$this->assertFieldsNotRolledForward($module, $newmodule, ['timemodified']);
}
}
+26
View File
@@ -0,0 +1,26 @@
<?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/>.
/**
* Generator for mod_qbank.
* Required by the module generator but intentionally blank until we need to extend
*
* @package mod_qbank
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_qbank_generator extends testing_module_generator {}
+30
View File
@@ -0,0 +1,30 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
/**
* Plugin version and other meta-data are defined here.
*
* @package mod_qbank
* @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net}
* @author Simon Adams <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'mod_qbank';
$plugin->version = 2024080800;
$plugin->requires = 2024080200;