Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
Namespaces | |
namespace | mod_choice |
| |
namespace | mod_choice\analytics\indicator |
| |
namespace | mod_choice\completion |
| |
namespace | mod_choice\event |
| |
namespace | mod_choice\privacy |
| |
namespace | mod_choice\search |
| |
Classes | |
class | backup_choice_activity_structure_step |
Define all the backup steps that will be used by the backup_choice_activity_task. More... | |
class | backup_choice_activity_task |
Provides the steps to perform one complete backup of the Choice instance. More... | |
class | behat_mod_choice |
Choice activity definitions. More... | |
class | mod_choice\analytics\indicator\activity_base |
Activity base class. More... | |
class | mod_choice\analytics\indicator\cognitive_depth |
Cognitive depth indicator - choice. More... | |
class | mod_choice\analytics\indicator\social_breadth |
Social breadth indicator - choice. More... | |
class | mod_choice\completion\custom_completion |
class | mod_choice\dates |
Class for fetching the important dates in mod_choice for a given module instance and a user. More... | |
class | mod_choice\event\answer_created |
class | mod_choice\event\answer_deleted |
class | mod_choice\event\course_module_instance_list_viewed |
The mod_choice instance list viewed event class. More... | |
class | mod_choice\event\course_module_viewed |
The mod_choice course module viewed event class. More... | |
class | mod_choice\event\report_viewed |
class | mod_choice\privacy\provider |
Implementation of the privacy subsystem plugin provider for the choice activity module. More... | |
class | mod_choice\search\activity |
Search area for mod_choice activities. More... | |
class | mod_choice_external |
Choice module external functions. More... | |
class | mod_choice_generator |
mod_choice data generator class. More... | |
class | mod_choice_renderer |
class | moodle1_mod_choice_handler |
Choice conversion handler. More... | |
class | restore_choice_activity_structure_step |
Define all the restore steps that will be used by the restore_choice_activity_task. More... | |
class | restore_choice_activity_task |
choice restore task that provides all the settings and steps to perform one complete restore of the activity More... | |
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. | |
choice_can_view_results ($choice, $current=null, $choiceopen=null) | |
Return true if we are allowd to view the choice results. | |
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. | |
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. | |
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. | |
choice_get_all_responses ($choice) | |
Get all the responses on a given choice. | |
choice_get_availability_status ($choice) | |
Check if a choice is available for the current user. | |
object | choice_get_choice ($choiceid) |
Gets a full choice record. | |
choice_get_completion_state ($course, $cm, $userid, $type) | |
Obtains the automatic completion state for this choice based on any conditions in forum settings. | |
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). | |
choice_get_my_response ($choice) | |
Get my responses on a given choice. | |
object | choice_get_option_text ($choice, $id) |
Returns text string which is the answer that matches the id. | |
choice_get_post_actions () | |
List the actions that correspond to a post of this module. | |
object | choice_get_response_data ($choice, $cm, $groupmode, $onlyactive) |
@global object @global object @uses CONTEXT_MODULE | |
choice_get_user_response ($choice, $userid) | |
Get responses of a given user on a given choice. | |
choice_get_view_actions () | |
List the actions that correspond to a view of this module. | |
choice_modify_responses ($userids, $answerids, $newoptionid, $choice, $cm, $course) | |
Modifies responses of other users adding the option $newoptionid to them. | |
choice_page_type_list ($pagetype, $parentcontext, $currentcontext) | |
Return a list of page types. | |
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. | |
choice_reset_course_form_defaults ($course) | |
Course reset form defaults. | |
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 | choice_reset_userdata ($data) |
Actual implementation of the reset course functionality, delete all the choice responses for course $data->courseid. | |
choice_set_events ($choice) | |
This creates new calendar events given as timeopen and timeclose by $choice. | |
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 | |
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. | |
choice_user_complete ($course, $user, $mod, $choice) | |
Callback for the "Complete" report - prints the activity summary for the given user. | |
object | choice_user_outline ($course, $user, $mod, $choice) |
Standard functions /////////////////////////////////////////////////////////. | |
choice_user_submit_response ($formanswer, $choice, $userid, $course, $cm) | |
Process user submitted answers for a choice, and either updating them or saving new answers. | |
choice_view ($choice, $course, $cm, $context) | |
Mark the activity completed (if required) and trigger the course_module_viewed event. | |
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. | |
mod_choice_core_calendar_get_event_action_string (string $eventtype) | |
Callback to fetch the activity event type lang string. | |
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. | |
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. | |
mod_choice_get_completion_active_rule_descriptions ($cm) | |
Callback which returns human-readable strings describing the active completion custom rules for the module instance. | |
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 | |
global array | $CHOICE_PUBLISH |
$CHOICE_PUBLISH | |
global array | $CHOICE_SHOWRESULTS |
$CHOICE_SHOWRESULTS | |
$functions | |
$logs | |
$plugin = 2023041800 | |
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 |
$plugin | version = 2023042400 |
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.
MoodleQuickForm | $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, false if not, null if doesn't know or string for the module purpose. |
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_event_action_string | ( | string | $eventtype | ) |
Callback to fetch the activity event type lang string.
string | $eventtype | The event type. |
lang_string | The event type lang string. |
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 |