Moodle PHP Documentation 5.0
Moodle 5.0.1+ (Build: 20250711) (61af040cd5f)
mod_qbank

Namespaces

namespace  mod_qbank\event
  
 
namespace  mod_qbank\privacy
  
 
namespace  mod_qbank\task
  
 

Classes

class  backup_qbank_activity_structure_step
 
class  backup_qbank_activity_task
 
class  mod_qbank\event\course_module_instance_list_viewed
 
class  mod_qbank\privacy\provider
 
class  mod_qbank\task\transfer_question_categories
 
class  mod_qbank_generator
 
class  mod_qbank_mod_form
 
class  restore_qbank_activity_structure_step
 
class  restore_qbank_activity_task
 

Functions

 qbank_add_instance (stdClass $moduleinstance, ?mod_qbank_mod_form $mform)
 Saves a new instance of the mod_qbank into the database.
 
 qbank_course_backend_generator_create_activity (tool_generator_course_backend $backend, testing_data_generator $generator, int $courseid, int $number,)
 Callback for tool_generator so we can add qbanks to generated courses.
 
 qbank_delete_instance (int $id)
 Removes an instance of the mod_qbank from the database.
 
 qbank_supports (string $feature)
 Return if the plugin supports $feature.
 
 qbank_update_instance (stdClass $moduleinstance, ?mod_qbank_mod_form $mform)
 Updates an instance of the mod_qbank in the database.
 
 xmldb_qbank_install ()
 
 xmldb_qbank_upgrade ($oldversion)
 Execute mod_qbank upgrade from the given old version.
 

Variables

 $capabilities
 
global $CFG
 
global $CFG
 
global $CFG
 
 $plugin = 2025040800
 
$plugin component = 'mod_qbank'
 
$plugin version = 2025041400
 

Detailed Description

Function Documentation

◆ qbank_add_instance()

qbank_add_instance ( stdClass $moduleinstance,
?mod_qbank_mod_form $mform )

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.

Parameters
stdClass$moduleinstanceAn object from the form.
mod_qbank_mod_form | null$mformThe form. Not used in this function.
Return values
intThe id of the newly inserted record.

◆ qbank_course_backend_generator_create_activity()

qbank_course_backend_generator_create_activity ( tool_generator_course_backend $backend,
testing_data_generator $generator,
int $courseid,
int $number )

Callback for tool_generator so we can add qbanks to generated courses.

Parameters
tool_generator_course_backend$backend
testing_data_generator$generator
int$courseid
int$number
Return values
void
Exceptions
coding_exception

◆ qbank_delete_instance()

qbank_delete_instance ( int $id)

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.

Parameters
int$idid of the module instance.
Return values
boolTrue if successful, false on failure.

◆ qbank_supports()

qbank_supports ( string $feature)

Return if the plugin supports $feature.

Parameters
string$featureConstant representing the feature.
Return values
bool|string|nullTrue if module supports feature, false if not, null if it doesn't know or string for the module purpose.

◆ qbank_update_instance()

qbank_update_instance ( stdClass $moduleinstance,
?mod_qbank_mod_form $mform )

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.

Parameters
stdClass$moduleinstanceAn object from the form in mod_form.php.
mod_qbank_mod_form | null$mformThe form. Not used in this function.
Return values
boolTrue if successful, false otherwise.

◆ xmldb_qbank_upgrade()

xmldb_qbank_upgrade ( $oldversion)

Execute mod_qbank upgrade from the given old version.

Author
Simon Adams simon.nosp@m..ada.nosp@m.ms@ca.nosp@m.taly.nosp@m.st-eu.nosp@m..net
License
https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Parameters
int$oldversion
Return values
bool

Variable Documentation

◆ $capabilities

$capabilities
Initial value:
= [
'mod/qbank:view' => [
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => [
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
],
'mod/qbank:addinstance' => [
'riskbitmask' => RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => [
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/course:manageactivities',
],
]
const CONTEXT_COURSE
Course context level - one instances for each course.
Definition accesslib.php:128
const CAP_ALLOW
Allow permission, overrides CAP_PREVENT defined in parent contexts.
Definition accesslib.php:115
const RISK_XSS
Capability allows user to add scripted content - see
Definition accesslib.php:143
const CONTEXT_MODULE
Course module context level - one instance for each course module.
Definition accesslib.php:130