Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
/mod/survey/ -> lib.php (source)

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 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: 0 times
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.

param: object $survey
return: int|bool

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.

param: object $survey
return: bool

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.

param: int $id
return: bool

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

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

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

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

survey_log_info($log)   X-Ref

param: sting $log
return: array

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

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

survey_get_analysis($survey, $user)   X-Ref

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

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

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

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

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

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

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

survey_already_done($survey, $user)   X-Ref

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

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

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

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

param: int $templateid
return: string

survey_shorten_name($name, $numwords)   X-Ref

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

survey_print_multi($question)   X-Ref

param: object $question

survey_print_single($question)   X-Ref

param: object $question

survey_question_rowclass($qnum)   X-Ref

param: int $qnum
return: string

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.

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

survey_supports($feature)   X-Ref

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

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.

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

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

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

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

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

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

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

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.

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
return: stdClass an object with the different type of areas indicating if they were updated or not

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.

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).
return: \core_calendar\local\event\entities\action_interface|null

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.

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

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.

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