Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Files | |
file | access.php |
Plugin capabilities. | |
file | activity.php |
Search area for mod_choice activities. | |
file | activity_base.php |
Activity base class. | |
file | answer_created.php |
The mod_choice answer created event. | |
file | answer_deleted.php |
The mod_choice answer deleted event. | |
file | answer_submitted.php |
The mod_choice answer submitted event. | |
file | answer_updated.php |
The mod_choice answer updated event. | |
file | backup_choice_activity_task.class.php |
Defines backup_choice_activity_task class. | |
file | backup_choice_settingslib.php |
@subpackage backup-moodle2 | |
file | backup_choice_stepslib.php |
@subpackage backup-moodle2 | |
file | behat_mod_choice.php |
Steps definitions for choice activity. | |
file | cognitive_depth.php |
Cognitive depth indicator - choice. | |
file | course_module_instance_list_viewed.php |
The mod_choice instance list viewed event. | |
file | course_module_viewed.php |
The mod_choice course module viewed event. | |
file | external.php |
Choice module external API. | |
file | lib.php |
Provides support for the conversion of moodle1 backup to the moodle2 format. | |
file | lib.php |
file | lib.php |
mod_choice data generator. | |
file | locallib.php |
Internal library of functions for choice module. | |
file | log.php |
Definition of log events. | |
file | provider.php |
Privacy Subsystem implementation for mod_choice. | |
file | renderer.php |
Moodle renderer used to display special elements of the lesson module. | |
file | report_downloaded.php |
The mod_choice report viewed event. | |
file | report_viewed.php |
The mod_choice report viewed event. | |
file | restore_choice_activity_task.class.php |
@subpackage backup-moodle2 | |
file | restore_choice_stepslib.php |
@subpackage backup-moodle2 | |
file | services.php |
Choice external functions and service definitions. | |
file | social_breadth.php |
Social breadth indicator - choice. | |
file | version.php |
Version information. | |
Namespaces | |
namespace | mod_choice\analytics\indicator |
| |
namespace | mod_choice\event |
| |
namespace | mod_choice\privacy |
| |
namespace | mod_choice\search |
| |
Functions | |
object | choice_add_instance ($choice) |
Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will create a new instance and return the id number of the new instance. More... | |
choice_can_view_results ($choice, $current=null, $choiceopen=null) | |
Return true if we are allowd to view the choice results. More... | |
choice_check_updates_since (cm_info $cm, $from, $filter=array()) | |
Check if the module has any update that affects the current user since a given time. More... | |
object | choice_delete_instance ($id) |
Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it. More... | |
object | choice_delete_responses ($attemptids, $choice, $cm, $course) |
choice_extend_settings_navigation (settings_navigation $settings, navigation_node $choicenode) | |
Adds module specific settings to the settings block. More... | |
choice_get_all_responses ($choice) | |
Get all the responses on a given choice. More... | |
choice_get_availability_status ($choice) | |
Check if a choice is available for the current user. More... | |
object | choice_get_choice ($choiceid) |
Gets a full choice record. More... | |
choice_get_completion_state ($course, $cm, $userid, $type) | |
Obtains the automatic completion state for this choice based on any conditions in forum settings. More... | |
choice_get_coursemodule_info ($coursemodule) | |
Add a get_coursemodule_info function in case any choice type wants to add 'extra' information for the course (see resource). More... | |
choice_get_my_response ($choice) | |
Get my responses on a given choice. More... | |
object | choice_get_option_text ($choice, $id) |
Returns text string which is the answer that matches the id. More... | |
choice_get_post_actions () | |
List the actions that correspond to a post of this module. More... | |
object | choice_get_response_data ($choice, $cm, $groupmode, $onlyactive) |
@global object @global object @uses CONTEXT_MODULE More... | |
choice_get_user_response ($choice, $userid) | |
Get responses of a given user on a given choice. More... | |
choice_get_view_actions () | |
List the actions that correspond to a view of this module. More... | |
choice_modify_responses ($userids, $answerids, $newoptionid, $choice, $cm, $course) | |
Modifies responses of other users adding the option $newoptionid to them. More... | |
choice_page_type_list ($pagetype, $parentcontext, $currentcontext) | |
Return a list of page types. More... | |
object | choice_prepare_options ($choice, $user, $coursemodule, $allresponses) |
choice_print_overview () | |
choice_refresh_events ($courseid=0, $instance=null, $cm=null) | |
This standard function will check all instances of this module and make sure there are up-to-date events created for each of them. More... | |
choice_reset_course_form_defaults ($course) | |
Course reset form defaults. More... | |
choice_reset_course_form_definition (&$mform) | |
Implementation of the function for printing the form elements that control whether the course reset functionality affects the choice. More... | |
object | choice_reset_userdata ($data) |
Actual implementation of the reset course functionality, delete all the choice responses for course $data->courseid. More... | |
choice_set_events ($choice) | |
This creates new calendar events given as timeopen and timeclose by $choice. More... | |
choice_show_reportlink ($user, $cm) | |
choice_supports ($feature) | |
@uses FEATURE_GROUPS @uses FEATURE_GROUPINGS @uses FEATURE_MOD_INTRO @uses FEATURE_COMPLETION_TRACKS_VIEWS @uses FEATURE_GRADE_HAS_GRADE @uses FEATURE_GRADE_OUTCOMES More... | |
object | choice_update_instance ($choice) |
Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will update an existing instance with new data. More... | |
choice_user_complete ($course, $user, $mod, $choice) | |
Callback for the "Complete" report - prints the activity summary for the given user. More... | |
object | choice_user_outline ($course, $user, $mod, $choice) |
Standard functions /////////////////////////////////////////////////////////. More... | |
choice_user_submit_response ($formanswer, $choice, $userid, $course, $cm) | |
Process user submitted answers for a choice, and either updating them or saving new answers. More... | |
choice_view ($choice, $course, $cm, $context) | |
Mark the activity completed (if required) and trigger the course_module_viewed event. More... | |
mod_choice_core_calendar_event_timestart_updated (\calendar_event $event, stdClass $choice) | |
This function will update the choice module according to the event that has been modified. More... | |
mod_choice_core_calendar_get_valid_event_timestart_range (\calendar_event $event, stdClass $choice) | |
This function calculates the minimum and maximum cutoff values for the timestart of the given event. More... | |
mod_choice_core_calendar_provide_event_action (calendar_event $event, core_calendar\action_factory $factory, int $userid=0) | |
This function receives a calendar event and returns the action associated with it, or null if there is none. More... | |
mod_choice_get_completion_active_rule_descriptions ($cm) | |
Callback which returns human-readable strings describing the active completion custom rules for the module instance. More... | |
mod_choice_get_fontawesome_icon_map () | |
Get icon mapping for font-awesome. | |
object | prepare_choice_show_results ($choice, $course, $cm, $allresponses) |
Variables | |
$capabilities | |
global int | $CHOICE_COLUMN_HEIGHT = 300 |
$CHOICE_COLUMN_HEIGHT | |
global int | $CHOICE_COLUMN_WIDTH = 300 |
$CHOICE_COLUMN_WIDTH | |
global array | $CHOICE_DISPLAY |
$CHOICE_DISPLAY More... | |
global array | $CHOICE_PUBLISH |
$CHOICE_PUBLISH More... | |
global array | $CHOICE_SHOWRESULTS |
$CHOICE_SHOWRESULTS More... | |
$functions | |
$logs | |
$plugin = 2020060900 | |
const | CHOICE_DISPLAY_HORIZONTAL '0' |
const | CHOICE_DISPLAY_VERTICAL '1' |
const | CHOICE_EVENT_TYPE_CLOSE 'close' |
const | CHOICE_EVENT_TYPE_OPEN 'open' |
const | CHOICE_PUBLISH_ANONYMOUS '0' |
const | CHOICE_PUBLISH_NAMES '1' |
const | CHOICE_SHOWRESULTS_AFTER_ANSWER '1' |
const | CHOICE_SHOWRESULTS_AFTER_CLOSE '2' |
const | CHOICE_SHOWRESULTS_ALWAYS '3' |
const | CHOICE_SHOWRESULTS_NOT '0' |
$plugin | component = 'mod_choice' |
$plugin | cron = 0 |
const | DISPLAY_HORIZONTAL_LAYOUT 0 |
const | DISPLAY_VERTICAL_LAYOUT 1 |
$plugin | version = 2020061500 |
object choice_add_instance | ( | $choice | ) |
Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will create a new instance and return the id number of the new instance.
object | $choice |
int |
choice_can_view_results | ( | $choice, | |
$current = null , |
|||
$choiceopen = null |
|||
) |
Return true if we are allowd to view the choice results.
stdClass | $choice | Choice record |
rows | null | $current | my choice responses |
bool | null | $choiceopen | if the choice is open |
bool | true if we can view the results, false otherwise. |
choice_check_updates_since | ( | cm_info | $cm, |
$from, | |||
$filter = array() |
|||
) |
Check if the module has any update that affects the current user since a given time.
cm_info | $cm | course module data |
int | $from | the time to check updates from |
array | $filter | if we need to check only specific updates |
stdClass | an object with the different type of areas indicating if they were updated or not |
object choice_delete_instance | ( | $id | ) |
Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it.
int | $id |
bool |
object choice_delete_responses | ( | $attemptids, | |
$choice, | |||
$cm, | |||
$course | |||
) |
array | $attemptids | |
object | $choice | Choice main table row |
object | $cm | Course-module object |
object | $course | Course object |
bool |
choice_extend_settings_navigation | ( | settings_navigation | $settings, |
navigation_node | $choicenode | ||
) |
Adds module specific settings to the settings block.
settings_navigation | $settings | The settings navigation object |
navigation_node | $choicenode | The node to add module settings to |
choice_get_all_responses | ( | $choice | ) |
Get all the responses on a given choice.
stdClass | $choice | Choice record |
array | of choice answers records |
choice_get_availability_status | ( | $choice | ) |
Check if a choice is available for the current user.
stdClass | $choice | choice record |
array | status (available or not and possible warnings) |
object choice_get_choice | ( | $choiceid | ) |
Gets a full choice record.
int | $choiceid |
object|bool | The choice or false |
choice_get_completion_state | ( | $course, | |
$cm, | |||
$userid, | |||
$type | |||
) |
Obtains the automatic completion state for this choice based on any conditions in forum settings.
object | $course | Course |
object | $cm | Course-module |
int | $userid | User ID |
bool | $type | Type of comparison (or/and; can be used as return value if no conditions) |
bool | True if completed, false if not, $type if conditions not set. |
choice_get_coursemodule_info | ( | $coursemodule | ) |
Add a get_coursemodule_info function in case any choice type wants to add 'extra' information for the course (see resource).
Given a course_module object, this function returns any "extra" information that may be needed when printing this activity in a course listing. See get_array_of_activities() in course/lib.php.
stdClass | $coursemodule | The coursemodule object (record). |
cached_cm_info | An object on information that the courses will know about (most noticeably, an icon). |
choice_get_my_response | ( | $choice | ) |
Get my responses on a given choice.
stdClass | $choice | Choice record |
array | of choice answers records |
object choice_get_option_text | ( | $choice, | |
$id | |||
) |
Returns text string which is the answer that matches the id.
object | $choice | |
int | $id |
string |
choice_get_post_actions | ( | ) |
List the actions that correspond to a post of this module.
This is used by the participation report.
Note: This is not used by new logging system. Event with crud = ('c' || 'u' || 'd') and edulevel = LEVEL_PARTICIPATING will be considered as post action.
array |
object choice_get_response_data | ( | $choice, | |
$cm, | |||
$groupmode, | |||
$onlyactive | |||
) |
@global object @global object @uses CONTEXT_MODULE
object | $choice | |
object | $cm | |
int | $groupmode | |
bool | $onlyactive | Whether to get response data for active users only. |
array |
choice_get_user_response | ( | $choice, | |
$userid | |||
) |
Get responses of a given user on a given choice.
stdClass | $choice | Choice record |
int | $userid | User id |
array | of choice answers records |
choice_get_view_actions | ( | ) |
List the actions that correspond to a view of this module.
This is used by the participation report.
Note: This is not used by new logging system. Event with crud = 'r' and edulevel = LEVEL_PARTICIPATING will be considered as view action.
array |
choice_modify_responses | ( | $userids, | |
$answerids, | |||
$newoptionid, | |||
$choice, | |||
$cm, | |||
$course | |||
) |
Modifies responses of other users adding the option $newoptionid to them.
array | $userids | list of users to add option to (must be users without any answers yet) |
array | $answerids | list of existing attempt ids of users (will be either appended or substituted with the newoptionid, depending on $choice->allowmultiple) |
int | $newoptionid | |
stdClass | $choice | choice object, result of choice_get_choice() |
stdClass | $cm | |
stdClass | $course |
choice_page_type_list | ( | $pagetype, | |
$parentcontext, | |||
$currentcontext | |||
) |
Return a list of page types.
string | $pagetype | current page type |
stdClass | $parentcontext | Block's parent context |
stdClass | $currentcontext | Current context of block |
object choice_prepare_options | ( | $choice, | |
$user, | |||
$coursemodule, | |||
$allresponses | |||
) |
object | $choice | |
object | $user | |
object | $coursemodule | |
array | $allresponses |
array |
choice_print_overview | ( | ) |
choice_refresh_events | ( | $courseid = 0 , |
|
$instance = null , |
|||
$cm = null |
|||
) |
This standard function will check all instances of this module and make sure there are up-to-date events created for each of them.
If courseid = 0, then every choice event in the site is checked, else only choice events belonging to the course specified are checked. This function is used, in its new format, by restore_refresh_events()
int | $courseid | |
int | stdClass | $instance | Choice module instance or ID. |
int | stdClass | $cm | Course module object or ID (not used in this module). |
bool |
choice_reset_course_form_defaults | ( | $course | ) |
Course reset form defaults.
array |
choice_reset_course_form_definition | ( | & | $mform | ) |
Implementation of the function for printing the form elements that control whether the course reset functionality affects the choice.
object | $mform | form passed by reference |
object choice_reset_userdata | ( | $data | ) |
Actual implementation of the reset course functionality, delete all the choice responses for course $data->courseid.
@global object
object | $data | the data submitted from the reset course. |
array | status array |
choice_set_events | ( | $choice | ) |
This creates new calendar events given as timeopen and timeclose by $choice.
stdClass | $choice |
void |
choice_show_reportlink | ( | $user, | |
$cm | |||
) |
array | $user | |
object | $cm |
void | Output is echo'd |
choice_supports | ( | $feature | ) |
@uses FEATURE_GROUPS @uses FEATURE_GROUPINGS @uses FEATURE_MOD_INTRO @uses FEATURE_COMPLETION_TRACKS_VIEWS @uses FEATURE_GRADE_HAS_GRADE @uses FEATURE_GRADE_OUTCOMES
string | $feature | FEATURE_xx constant for requested feature |
mixed | True if module supports feature, null if doesn't know |
object choice_update_instance | ( | $choice | ) |
Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will update an existing instance with new data.
object | $choice |
bool |
choice_user_complete | ( | $course, | |
$user, | |||
$mod, | |||
$choice | |||
) |
Callback for the "Complete" report - prints the activity summary for the given user.
object | $course | |
object | $user | |
object | $mod | |
object | $choice |
object choice_user_outline | ( | $course, | |
$user, | |||
$mod, | |||
$choice | |||
) |
Standard functions /////////////////////////////////////////////////////////.
object | $course | |
object | $user | |
object | $mod | |
object | $choice |
object|null |
choice_user_submit_response | ( | $formanswer, | |
$choice, | |||
$userid, | |||
$course, | |||
$cm | |||
) |
Process user submitted answers for a choice, and either updating them or saving new answers.
int | array | $formanswer | the id(s) of the user submitted choice options. |
object | $choice | the selected choice. |
int | $userid | user identifier. |
object | $course | current course. |
object | $cm | course context. |
void |
choice_view | ( | $choice, | |
$course, | |||
$cm, | |||
$context | |||
) |
Mark the activity completed (if required) and trigger the course_module_viewed event.
stdClass | $choice | choice object |
stdClass | $course | course object |
stdClass | $cm | course module object |
stdClass | $context | context object |
mod_choice_core_calendar_event_timestart_updated | ( | \calendar_event | $event, |
stdClass | $choice | ||
) |
This function will update the choice module according to the event that has been modified.
It will set the timeopen or timeclose value of the choice instance according to the type of event provided.
moodle_exception |
calendar_event | $event | |
stdClass | $choice | The module instance to get the range from |
mod_choice_core_calendar_get_valid_event_timestart_range | ( | \calendar_event | $event, |
stdClass | $choice | ||
) |
This function calculates the minimum and maximum cutoff values for the timestart of the given event.
It will return an array with two values, the first being the minimum cutoff value and the second being the maximum cutoff value. Either or both values can be null, which indicates there is no minimum or maximum, respectively.
If a cutoff is required then the function must return an array containing the cutoff timestamp and error string to display to the user if the cutoff value is violated.
A minimum and maximum cutoff return value will look like: [ [1505704373, 'The date must be after this date'], [1506741172, 'The date must be before this date'] ]
calendar_event | $event | The calendar event to get the time range for |
stdClass | $choice | The module instance to get the range from |
mod_choice_core_calendar_provide_event_action | ( | calendar_event | $event, |
core_calendar\action_factory | $factory, | ||
int | $userid = 0 |
||
) |
This function receives a calendar event and returns the action associated with it, or null if there is none.
This is used by block_myoverview in order to display the event appropriately. If null is returned then the event is not displayed on the block.
calendar_event | $event | |
core_calendar::action_factory | $factory | |
int | $userid | User id to use for all capability checks, etc. Set to 0 for current user (default). |
core_calendar::local::event::entities::action_interface|null |
mod_choice_get_completion_active_rule_descriptions | ( | $cm | ) |
Callback which returns human-readable strings describing the active completion custom rules for the module instance.
cm_info | stdClass | $cm | object with fields ->completion and ->customdata['customcompletionrules'] |
array::$descriptions | the array of descriptions for the custom rules. |
object prepare_choice_show_results | ( | $choice, | |
$course, | |||
$cm, | |||
$allresponses | |||
) |
object | $choice | |
object | $course | |
object | $coursemodule | |
array | $allresponses |
bool | $allresponses |
object |
$CHOICE_DISPLAY |
$CHOICE_DISPLAY
$CHOICE_PUBLISH |
$CHOICE_PUBLISH
$CHOICE_SHOWRESULTS |
$CHOICE_SHOWRESULTS
$logs |