Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
/mod/survey/ -> lib.php (source)

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 402] [Versions 400 and 403]

(no description)

Copyright: 1999 onwards Martin Dougiamas {@link http://moodle.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1192 lines (39 kb)
Included or required: 5 times
Referenced: 1 time
Includes or requires: 1 file
 mod/survey/deprecatedlib.php

Defines 40 functions


Functions that are not part of a class:

survey_add_instance($survey)   X-Ref
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.

return: int|bool
param: object $survey

survey_update_instance($survey)   X-Ref
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.

return: bool
param: object $survey

survey_delete_instance($id)   X-Ref
Given an ID of an instance of this module,
this function will permanently delete the instance
and any data that depends on it.

return: bool
param: int $id

survey_user_outline($course, $user, $mod, $survey)   X-Ref

return: $result
param: object $course
param: object $user
param: object $mod
param: object $survey

survey_user_complete($course, $user, $mod, $survey)   X-Ref

param: object $course
param: object $user
param: object $mod
param: object $survey

survey_print_recent_activity($course, $viewfullnames, $timestart)   X-Ref

return: bool
param: object $course
param: mixed $viewfullnames
param: int $timestamp

survey_log_info($log)   X-Ref

return: array
param: sting $log

survey_get_responses($surveyid, $groupid, $groupingid)   X-Ref

return: array
param: int $surveyid
param: int $groupid
param: int $groupingid

survey_get_analysis($survey, $user)   X-Ref

return: array
param: int $survey
param: int $user

survey_update_analysis($survey, $user, $notes)   X-Ref

param: int $survey
param: int $user
param: string $notes

survey_get_user_answers($surveyid, $questionid, $groupid, $sort="sa.answer1,sa.answer2 ASC")   X-Ref

return: array
param: int $surveyid
param: int $groupid
param: string $sort

survey_get_user_answer($surveyid, $questionid, $userid)   X-Ref

return: array
param: int $surveyid
param: int $questionid
param: int $userid

survey_add_analysis($survey, $user, $notes)   X-Ref

return: bool|int
param: int $survey
param: int $user
param: string $notes

survey_already_done($survey, $user)   X-Ref

return: bool
param: int $survey
param: int $user

survey_count_responses($surveyid, $groupid, $groupingid)   X-Ref

return: int
param: int $surveyid
param: int $groupid
param: int $groupingid

survey_print_all_responses($cmid, $results, $courseid)   X-Ref

param: int $cmid
param: array $results
param: int $courseid

survey_get_template_name($templateid)   X-Ref

return: string
param: int $templateid

survey_shorten_name($name, $numwords)   X-Ref

return: string
param: string $name
param: array $numwords

survey_print_multi($question)   X-Ref

param: object $question

survey_print_single($question)   X-Ref

param: object $question

survey_question_rowclass($qnum)   X-Ref

return: string
param: int $qnum

survey_print_graph($url)   X-Ref

param: string $url

survey_get_view_actions()   X-Ref
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.

return: array

survey_get_post_actions()   X-Ref
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.

return: array

survey_reset_course_form_definition(&$mform)   X-Ref
Implementation of the function for printing the form elements that control
whether the course reset functionality affects the survey.

param: object $mform form passed by reference

survey_reset_course_form_defaults($course)   X-Ref
Course reset form defaults.

return: array

survey_reset_userdata($data)   X-Ref
Actual implementation of the reset course functionality, delete all the
survey responses for course $data->courseid.

return: array status array
param: $data the data submitted from the reset course.

survey_supports($feature)   X-Ref

return: mixed True if module supports feature, false if not, null if doesn't know or string for the module purpose.
param: string $feature FEATURE_xx constant for requested feature

survey_extend_settings_navigation(settings_navigation $settings, navigation_node $surveynode)   X-Ref
This function extends the settings navigation block for the site.

It is safe to rely on PAGE here as we will only ever be within the module
context when this is called

param: settings_navigation $settings
param: navigation_node $surveynode

survey_page_type_list($pagetype, $parentcontext, $currentcontext)   X-Ref
Return a list of page types

param: string $pagetype current page type
param: stdClass $parentcontext Block's parent context
param: stdClass $currentcontext Current context of block

survey_view($survey, $course, $cm, $context, $viewed)   X-Ref
Mark the activity completed (if required) and trigger the course_module_viewed event.

param: stdClass $survey     survey object
param: stdClass $course     course object
param: stdClass $cm         course module object
param: stdClass $context    context object
param: string $viewed       which page viewed

survey_order_questions($questions, $questionorder)   X-Ref
Helper function for ordering a set of questions by the given ids.

return: array                list of questions ordered
param: array $questions     array of questions objects
param: array $questionorder array of questions ids indicating the correct order

survey_translate_question($question)   X-Ref
Translate the question texts and options.

return: stdClass question object with all the text fields translated
param: stdClass $question question object

survey_get_questions($survey)   X-Ref
Returns the questions for a survey (ordered).

return: array list of questions ordered
param: stdClass $survey survey object

survey_get_subquestions($question)   X-Ref
Returns subquestions for a given question (ordered).

return: array list of subquestions ordered
param: stdClass $question questin object

survey_save_answers($survey, $answersrawdata, $course, $context)   X-Ref
Save the answer for the given survey

param: stdClass $survey   a survey object
param: array $answersrawdata the answers to be saved
param: stdClass $course   a course object (required for trigger the submitted event)
param: stdClass $context  a context object (required for trigger the submitted event)

survey_check_updates_since(cm_info $cm, $from, $filter = array()   X-Ref
Check if the module has any update that affects the current user since a given time.

return: stdClass an object with the different type of areas indicating if they were updated or not
param: cm_info $cm course module data
param: int $from the time to check updates from
param: array $filter  if we need to check only specific updates

mod_survey_core_calendar_provide_event_action(calendar_event $event,\core_calendar\action_factory $factory,int $userid = 0)   X-Ref
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.

return: \core_calendar\local\event\entities\action_interface|null
param: calendar_event $event
param: \core_calendar\action_factory $factory
param: int $userid User id to use for all capability checks, etc. Set to 0 for current user (default).

survey_get_coursemodule_info($coursemodule)   X-Ref
Add a get_coursemodule_info function in case any survey 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.

return: cached_cm_info An object on information that the courses
param: stdClass $coursemodule The coursemodule object (record).

mod_survey_get_completion_active_rule_descriptions($cm)   X-Ref
Callback which returns human-readable strings describing the active completion custom rules for the module instance.

return: array $descriptions the array of descriptions for the custom rules.
param: cm_info|stdClass $cm object with fields ->completion and ->customdata['customcompletionrules']