|
Moodle
2.2.1
http://www.collinsharper.com
|
Go to the source code of this file.
Data Structures | |
| class | context_to_string_translator |
| class | question_edit_contexts |
Namespaces | |
| namespace | moodlecore |
Enumerations | |
| enum | QUESTION_NUMANS |
| CONSTANTS ///////////////////////////////////. More... | |
| enum | QUESTION_NUMANS_START |
| enum | QUESTION_NUMANS_ADD |
Functions | |
| question_reorder_qtypes ($sortedqtypes, $tomove, $direction) | |
| question_save_qtype_order ($neworder, $config=null) | |
| question_list_instances ($questionid) | |
| FUNCTIONS //////////////////////////////////////////////////////. | |
| questions_in_use ($questionids) | |
| question_context_has_any_questions ($context) | |
| get_grade_options () | |
| match_grade_options ($gradeoptionsfull, $grade, $matchgrades='error') | |
| question_category_isused ($categoryid, $recursive=false) | |
| question_category_in_use ($categoryid, $recursive=false) | |
| question_delete_question ($questionid) | |
| question_delete_course ($course, $feedback=true) | |
| question_delete_course_category ($category, $newcategory, $feedback=true) | |
| question_save_from_deletion ($questionids, $newcontextid, $oldplace, $newcategory=null) | |
| question_delete_activity ($cm, $feedback=true) | |
| question_move_questions_to_category ($questionids, $newcategoryid) | |
| question_move_category_to_context ($categoryid, $oldcontextid, $newcontextid) | |
| question_preview_url ($questionid, $preferredbehaviour=null, $maxmark=null, $displayoptions=null, $variant=null, $context=null) | |
| question_preview_popup_params () | |
| question_preload_questions ($questionids, $extrafields= '', $join= '', $extraparams=array()) | |
| question_load_questions ($questionids, $extrafields= '', $join= '') | |
| _tidy_question ($question, $loadtags=false) | |
| get_question_options (&$questions, $loadtags=false) | |
| print_question_icon ($question) | |
| question_hash ($question) | |
| save_question_options ($question) | |
| FUNCTIONS THAT SIMPLY WRAP QUESTIONTYPE METHODS //////////////////////////////////. | |
| sort_categories_by_tree (&$categories, $id=0, $level=1) | |
| CATEGORY FUNCTIONS /////////////////////////////////////////////////////////////////. | |
| flatten_category_tree (&$categories, $id, $depth=0, $nochildrenof=-1) | |
| add_indented_names ($categories, $nochildrenof=-1) | |
| question_category_select_menu ($contexts, $top=false, $currentcat=0, $selected="", $nochildrenof=-1) | |
| question_get_default_category ($contextid) | |
| question_make_default_categories ($contexts) | |
| get_categories_for_contexts ($contexts, $sortorder= 'parent, sortorder, name ASC') | |
| question_category_options ($contexts, $top=false, $currentcat=0, $popupform=false, $nochildrenof=-1) | |
| question_add_context_in_key ($categories) | |
| question_add_tops ($categories, $pcontexts) | |
| question_categorylist ($categoryid) | |
| get_import_export_formats ($type) | |
| question_default_export_filename ($course, $category) | |
| question_has_capability_on ($question, $cap, $cachecat=-1) | |
| question_require_capability_on ($question, $cap) | |
| question_get_real_state ($state) | |
| question_edit_url ($context) | |
| question_extend_settings_navigation (navigation_node $navigationnode, $context) | |
| question_get_question_capabilities () | |
| question_get_all_capabilities () | |
| question_rewrite_question_urls ($text, $file, $contextid, $component, $filearea, array $ids, $itemid, array $options=null) | |
| question_rewrite_questiontext_preview_urls ($questiontext, $contextid, $component, $questionid, $options=null) | |
| question_send_questiontext_file ($questionid, $args, $forcedownload) | |
| question_pluginfile ($course, $context, $component, $filearea, $args, $forcedownload) | |
| core_question_questiontext_preview_pluginfile ($context, $questionid, $args, $forcedownload) | |
| question_make_export_url ($contextid, $categoryid, $format, $withcategories, $withcontexts, $filename) | |
| question_page_type_list ($pagetype, $parentcontext, $currentcontext) | |
| enum QUESTION_NUMANS |
CONSTANTS ///////////////////////////////////.
Constant determines the number of answer boxes supplied in the editing form for multiple choice and similar question types.
Definition at line 48 of file questionlib.php.
| enum QUESTION_NUMANS_ADD |
Constant determines the number of answer boxes to add in the editing form for multiple choice and similar question types when the user presses 'add form fields button'.
Definition at line 62 of file questionlib.php.
Constant determines the number of answer boxes supplied in the editing form for multiple choice and similar question types to start with, with the option of adding QUESTION_NUMANS_ADD more answers.
Definition at line 55 of file questionlib.php.
| _tidy_question | ( | $ | question, |
| $ | loadtags = false |
||
| ) |
Private function to factor common code out of get_question_options().
| object | $question | the question to tidy. |
| boolean | $loadtags | load the question tags from the tags table. Optional, default false. |
Definition at line 781 of file questionlib.php.


| add_indented_names | ( | $ | categories, |
| $ | nochildrenof = -1 |
||
| ) |
Format categories into an indented list reflecting the tree structure.
| array | $categories | An array of category objects, for example from the. |
Definition at line 937 of file questionlib.php.


| core_question_questiontext_preview_pluginfile | ( | $ | context, |
| $ | questionid, | ||
| $ | args, | ||
| $ | forcedownload | ||
| ) |
Serve questiontext files in the question text when they are displayed in this report.
| context | $context | the context |
| int | $questionid | the question id |
| array | $args | remaining file args |
| bool | $forcedownload |
Definition at line 1848 of file questionlib.php.

| flatten_category_tree | ( | &$ | categories, |
| $ | id, | ||
| $ | depth = 0, |
||
| $ | nochildrenof = -1 |
||
| ) |
Private method, only for the use of add_indented_names().
Recursively adds an indentedname field to each category, starting with the category with id $id, and dealing with that category and all its children, and return a new array, with those categories in the right order.
| array | $categories | an array of categories which has had childids fields added by flatten_category_tree(). Passed by reference for performance only. It is not modfied. |
| int | $id | the category to start the indenting process from. |
| int | $depth | the indent depth. Used in recursive calls. |
Definition at line 909 of file questionlib.php.

| get_categories_for_contexts | ( | $ | contexts, |
| $ | sortorder = 'parent, |
||
| sortorder | , | ||
| name ASC' | |||
| ) |
Get all the category objects, including a count of the number of questions in that category, for all the categories in the lists $contexts.
| mixed | $contexts | either a single contextid, or a comma-separated list of context ids. |
| string | $sortorder | used as the ORDER BY clause in the select statement. |
Definition at line 1071 of file questionlib.php.

Returns list of 'allowed' grades for grade selection formatted suitably for dropdown box function
Definition at line 203 of file questionlib.php.

| get_import_export_formats | ( | $ | type | ) |
Get list of available import or export formats
| string | $type | 'import' if import list, otherwise export list assumed |
Definition at line 1184 of file questionlib.php.


| get_question_options | ( | &$ | questions, |
| $ | loadtags = false |
||
| ) |
Updates the question objects with question type specific information by calling get_question_options()
Can be called either with an array of question objects or with a single question object.
| mixed | $questions | Either an array of question objects to be updated or just a single question object |
| boolean | $loadtags | load the question tags from the tags table. Optional, default false. |
Definition at line 809 of file questionlib.php.


| match_grade_options | ( | $ | gradeoptionsfull, |
| $ | grade, | ||
| $ | matchgrades = 'error' |
||
| ) |
match grade options if no match return error or match nearest
| array | $gradeoptionsfull | list of valid options |
| int | $grade | grade to be tested |
| string | $matchgrades | 'error' or 'nearest' |
Definition at line 219 of file questionlib.php.

| print_question_icon | ( | $ | question | ) |
Print the icon for the question type
| object | $question | The question object for which the icon is required. Only $question->qtype is used. |
Definition at line 827 of file questionlib.php.

| question_add_context_in_key | ( | $ | categories | ) |
| question_add_tops | ( | $ | categories, |
| $ | pcontexts | ||
| ) |
| question_category_in_use | ( | $ | categoryid, |
| $ | recursive = false |
||
| ) |
Tests whether any question in a category is used by any part of Moodle.
| integer | $categoryid | a question category id. |
| boolean | $recursive | whether to check child categories too. |
Definition at line 266 of file questionlib.php.

| question_category_isused | ( | $ | categoryid, |
| $ | recursive = false |
||
| ) |
| integer | $categoryid | a question category id. |
| boolean | $recursive | whether to check child categories too. |
Definition at line 254 of file questionlib.php.
| question_category_options | ( | $ | contexts, |
| $ | top = false, |
||
| $ | currentcat = 0, |
||
| $ | popupform = false, |
||
| $ | nochildrenof = -1 |
||
| ) |
Output an array of question categories.
Definition at line 1084 of file questionlib.php.


| question_category_select_menu | ( | $ | contexts, |
| $ | top = false, |
||
| $ | currentcat = 0, |
||
| $ | selected = "", |
||
| $ | nochildrenof = -1 |
||
| ) |
Output a select menu of question categories.
Categories from this course and (optionally) published categories from other courses are included. Optionally, only categories the current user may edit can be included.
| integer | $courseid | the id of the course to get the categories for. |
| integer | $published | if true, include publised categories from other courses. |
| integer | $only_editable | if true, exclude categories this user is not allowed to edit. |
| integer | $selected | optionally, the id of a category to be selected by default in the dropdown. |
Definition at line 981 of file questionlib.php.


| question_categorylist | ( | $ | categoryid | ) |
Definition at line 1161 of file questionlib.php.

| question_context_has_any_questions | ( | $ | context | ) |
Determine whether there arey any questions belonging to this context, that is whether any of its question categories contain any questions. This will return true even if all the questions are hidden.
| mixed | $context | either a context object, or a context id. |
Definition at line 179 of file questionlib.php.


| question_default_export_filename | ( | $ | course, |
| $ | category | ||
| ) |
Create a reasonable default file name for exporting questions from a particular category.
| object | $course | the course the questions are in. |
| object | $category | the question category. |
Definition at line 1218 of file questionlib.php.

| question_delete_activity | ( | $ | cm, |
| $ | feedback = true |
||
| ) |
All question categories and their questions are deleted for this activity.
| object | $cm | the course module object representing the activity |
| boolean | $feedback | to specify if the process must output a summary of its work |
Definition at line 524 of file questionlib.php.


| question_delete_course | ( | $ | course, |
| $ | feedback = true |
||
| ) |
All question categories and their questions are deleted for this course.
| stdClass | $course | an object representing the activity |
| boolean | $feedback | to specify if the process must output a summary of its work |
Definition at line 350 of file questionlib.php.


| question_delete_course_category | ( | $ | category, |
| $ | newcategory, | ||
| $ | feedback = true |
||
| ) |
Category is about to be deleted, 1/ All question categories and their questions are deleted for this course category. 2/ All questions are moved to new category
| object | $category | course category object |
| object | $newcategory | empty means everything deleted, otherwise id of category where content moved |
| boolean | $feedback | to specify if the process must output a summary of its work |
Definition at line 407 of file questionlib.php.


| question_delete_question | ( | $ | questionid | ) |
Deletes question and all associated data from the database
It will not delete a question if it is used by an activity module
| object | $question | The question being deleted |
Definition at line 299 of file questionlib.php.


| question_edit_url | ( | $ | context | ) |
| object | $context | a context |
Definition at line 1386 of file questionlib.php.

| question_extend_settings_navigation | ( | navigation_node $ | navigationnode, |
| $ | context | ||
| ) |
Adds question bank setting links to the given navigation node if caps are met.
| navigation_node | $navigationnode | The navigation node to add the question branch to |
| object | $context |
Definition at line 1418 of file questionlib.php.


Definition at line 1477 of file questionlib.php.


| question_get_default_category | ( | $ | contextid | ) |
| integer | $contextid | a context id. |
Definition at line 1003 of file questionlib.php.

Definition at line 1460 of file questionlib.php.

| question_get_real_state | ( | $ | state | ) |
Get the real state - the correct question id and answer - for a random question.
| object | $state | with property answer. |
Definition at line 1368 of file questionlib.php.
| question_has_capability_on | ( | $ | question, |
| $ | cap, | ||
| $ | cachecat = -1 |
||
| ) |
Check capability on category
| mixed | $question | object or id |
| string | $cap | 'add', 'edit', 'view', 'use', 'move' |
| integer | $cachecat | useful to cache all question records in a category |
Definition at line 1299 of file questionlib.php.


| question_hash | ( | $ | question | ) |
Creates a stamp that uniquely identifies this version of the question
In future we want this to use a hash of the question data to guarantee that identical versions have the same version stamp.
| object | $question |
Definition at line 841 of file questionlib.php.


| question_list_instances | ( | $ | questionid | ) |
FUNCTIONS //////////////////////////////////////////////////////.
Returns an array of names of activity modules that use this question
| object | $questionid |
Definition at line 125 of file questionlib.php.
| question_load_questions | ( | $ | questionids, |
| $ | extrafields = '', |
||
| $ | join = '' |
||
| ) |
Load a set of questions, given a list of ids. The $join and $extrafields arguments can be used together to pull in extra data. See, for example, the usage in mod/quiz/attempt.php, and read the code below to see how the SQL is assembled. Throws exceptions on error.
| array | $questionids | array of question ids. |
| string | $extrafields | extra SQL code to be added to the query. |
| string | $join | extra SQL code to be added to the query. |
| array | $extraparams | values for any placeholders in $join. You are strongly recommended to use named placeholder. |
Definition at line 764 of file questionlib.php.


| question_make_default_categories | ( | $ | contexts | ) |
Gets the default category in the most specific context. If no categories exist yet then default ones are created in all contexts.
| array | $contexts | The context objects for this context and all parent contexts. |
Definition at line 1021 of file questionlib.php.


| question_make_export_url | ( | $ | contextid, |
| $ | categoryid, | ||
| $ | format, | ||
| $ | withcategories, | ||
| $ | withcontexts, | ||
| $ | filename | ||
| ) |
Create url for question export
| int | $contextid,current | context |
| int | $categoryid,categoryid | |
| string | $format | |
| string | $withcategories | |
| string | $ithcontexts | |
| moodle_url | export file url |
Definition at line 1878 of file questionlib.php.

| question_move_category_to_context | ( | $ | categoryid, |
| $ | oldcontextid, | ||
| $ | newcontextid | ||
| ) |
This function helps move a question cateogry to a new context by moving all the files belonging to all the questions to the new context. Also moves subcategories.
| integer | $categoryid | the id of the category being moved. |
| integer | $oldcontextid | the old context id. |
| integer | $newcontextid | the new context id. |
Definition at line 616 of file questionlib.php.


| question_move_questions_to_category | ( | $ | questionids, |
| $ | newcategoryid | ||
| ) |
This function should be considered private to the question bank, it is called from question/editlib.php question/contextmoveq.php and a few similar places to to the work of acutally moving questions and associated data. However, callers of this function also have to do other work, which is why you should not call this method directly from outside the questionbank.
| array | $questionids | of question ids. |
| integer | $newcategoryid | the id of the category to move to. |
Definition at line 577 of file questionlib.php.


| question_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 |
Definition at line 1893 of file questionlib.php.

| question_pluginfile | ( | $ | course, |
| $ | context, | ||
| $ | component, | ||
| $ | filearea, | ||
| $ | args, | ||
| $ | forcedownload | ||
| ) |
Called by pluginfile.php to serve files related to the 'question' core component and for files belonging to qtypes.
For files that relate to questions in a question_attempt, then we delegate to a function in the component that owns the attempt (for example in the quiz, or in core question preview) to get necessary inforation.
(Note that, at the moment, all question file areas relate to questions in attempts, so the If at the start of the last paragraph is always true.)
Does not return, either calls send_file_not_found(); or serves the file.
| object | $course | course settings object |
| object | $context | context object |
| string | $component | the name of the component we are serving files for. |
| string | $filearea | the name of the file area. |
| array | $args | the remaining bits of the file path. |
| bool | $forcedownload | whether the user must be forced to download the file. |
Definition at line 1739 of file questionlib.php.


| question_preload_questions | ( | $ | questionids, |
| $ | extrafields = '', |
||
| $ | join = '', |
||
| $ | extraparams = array() |
||
| ) |
Given a list of ids, load the basic information about a set of questions from the questions table. The $join and $extrafields arguments can be used together to pull in extra data. See, for example, the usage in mod/quiz/attemptlib.php, and read the code below to see how the SQL is assembled. Throws exceptions on error.
object object
| array | $questionids | array of question ids. |
| string | $extrafields | extra SQL code to be added to the query. |
| string | $join | extra SQL code to be added to the query. |
| array | $extraparams | values for any placeholders in $join. You are strongly recommended to use named placeholder. |
Definition at line 714 of file questionlib.php.

Definition at line 690 of file questionlib.php.

| question_preview_url | ( | $ | questionid, |
| $ | preferredbehaviour = null, |
||
| $ | maxmark = null, |
||
| $ | displayoptions = null, |
||
| $ | variant = null, |
||
| $ | context = null |
||
| ) |
Generate the URL for starting a new preview of a given question with the given options.
| integer | $questionid | the question to preview. |
| string | $preferredbehaviour | the behaviour to use for the preview. |
| float | $maxmark | the maximum to mark the question out of. |
| question_display_options | $displayoptions | the display options to use. |
| int | $variant | the variant of the question to preview. If null, one will be picked randomly. |
| object | $context | context to run the preview in (affects things like filter settings, theme, lang, etc.) Defaults to $PAGE->context. |
Definition at line 647 of file questionlib.php.

| question_reorder_qtypes | ( | $ | sortedqtypes, |
| $ | tomove, | ||
| $ | direction | ||
| ) |
Move one question type in a list of question types. If you try to move one element off of the end, nothing will change.
| array | $sortedqtypes | An array $qtype => anything. |
| string | $tomove | one of the keys from $sortedqtypes |
| integer | $direction | +1 or -1 |
Definition at line 75 of file questionlib.php.

| question_require_capability_on | ( | $ | question, |
| $ | cap | ||
| ) |
Require capability on question.
Definition at line 1354 of file questionlib.php.


| question_rewrite_question_urls | ( | $ | text, |
| $ | file, | ||
| $ | contextid, | ||
| $ | component, | ||
| $ | filearea, | ||
| array $ | ids, | ||
| $ | itemid, | ||
| array $ | options = null |
||
| ) |
Helps call file_rewrite_pluginfile_urls with the right parameters.
| string | $text | text being processed |
| string | $file | the php script used to serve files |
| int | $contextid | |
| string | $component | component |
| string | $filearea | filearea |
| array | $ids | other IDs will be used to check file permission |
| int | $itemid | |
| array | $options |
Definition at line 1662 of file questionlib.php.


| question_rewrite_questiontext_preview_urls | ( | $ | questiontext, |
| $ | contextid, | ||
| $ | component, | ||
| $ | questionid, | ||
| $ | options = null |
||
| ) |
Rewrite the PLUGINFILE urls in the questiontext, when viewing the question text outside and attempt (for example, in the question bank listing or in the quiz statistics report).
| string | $questiontext | the question text. |
| int | $contextid | the context the text is being displayed in. |
| string | $component | component |
| array | $ids | other IDs will be used to check file permission |
| array | $options |
Definition at line 1688 of file questionlib.php.


| question_save_from_deletion | ( | $ | questionids, |
| $ | newcontextid, | ||
| $ | oldplace, | ||
| $ | newcategory = null |
||
| ) |
Enter description here...
| array | $questionids | of question ids |
| object | $newcontext | the context to create the saved category in. |
| string | $oldplace | a textual description of the think being deleted, e.g. from get_context_name |
| object | $newcategory |
Definition at line 494 of file questionlib.php.


| question_save_qtype_order | ( | $ | neworder, |
| $ | config = null |
||
| ) |
Save a new question type order to the config_plugins table. object
| $neworder | An arra $index => $qtype. Indices should start at 0 and be in order. |
| $config | get_config('question'), if you happen to have it around, to save one DB query. |
Definition at line 100 of file questionlib.php.

| question_send_questiontext_file | ( | $ | questionid, |
| $ | args, | ||
| $ | forcedownload | ||
| ) |
Send a file from the question text of a question.
| int | $questionid | the question id |
| array | $args | the remaining file arguments (file path). |
| bool | $forcedownload | whether the user must be forced to download the file. |
Definition at line 1701 of file questionlib.php.


| questions_in_use | ( | $ | questionids | ) |
| array | $questionids | of question ids. |
Definition at line 134 of file questionlib.php.


| save_question_options | ( | $ | question | ) |
FUNCTIONS THAT SIMPLY WRAP QUESTIONTYPE METHODS //////////////////////////////////.
Saves question options
Simply calls the question type specific save_question_options() method.
Definition at line 851 of file questionlib.php.

| sort_categories_by_tree | ( | &$ | categories, |
| $ | id = 0, |
||
| $ | level = 1 |
||
| ) |
CATEGORY FUNCTIONS /////////////////////////////////////////////////////////////////.
returns the categories with their names ordered following parent-child relationships finally it tries to return pending categories (those being orphaned, whose parent is incorrect) to avoid missing any category from original array.
Definition at line 862 of file questionlib.php.
