Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
Functions used to show question editing interface
Copyright: | 1999 onwards Martin Dougiamas and others {@link http://moodle.com} |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 659 lines (24 kb) |
Included or required: | 2 times |
Referenced: | 3 times |
Includes or requires: | 0 files |
get_module_from_cmid($cmid) X-Ref |
No description |
get_questions_category( $category, $noparent=false, $recurse=true, $export=true ) X-Ref |
Function to read all questions for category into big array param: int $category category number param: bool $noparent if true only questions with NO parent will be selected param: bool $recurse include subdirectories param: bool $export set true if this is called by questionbank export |
question_is_only_child_of_top_category_in_context($categoryid) X-Ref |
Checks whether this is the only child of a top category in a context. param: int $categoryid a category id. return: bool |
question_is_top_category($categoryid) X-Ref |
Checks whether the category is a "Top" category (with no parent). param: int $categoryid a category id. return: bool |
question_can_delete_cat($todelete) X-Ref |
Ensures that this user is allowed to delete this category. param: int $todelete a category id. |
question_edit_setup($edittab, $baseurl, $requirecmid = false, $unused = null) X-Ref |
Common setup for all pages for editing questions. param: string $baseurl the name of the script calling this funciton. For examle 'qusetion/edit.php'. param: string $edittab code for this edit tab param: bool $requirecmid require cmid? default false param: bool $unused no longer used, do no pass return: array $thispageurl, $contexts, $cmid, $cm, $module, $pagevars |
question_build_edit_resources($edittab, $baseurl, $params) X-Ref |
Common function for building the generic resources required by the editing questions pages. Either a cmid or a course id must be provided as keys in $params or an exception will be thrown. All other params are optional and will have sane default applied if not provided. The acceptable keys for $params are: [ 'cmid' => PARAM_INT, 'courseid' => PARAM_INT, 'qpage' => PARAM_INT, 'cat' => PARAM_SEQUENCE, 'category' => PARAM_SEQUENCE, 'qperpage' => PARAM_INT, 'recurse' => PARAM_INT, 'showhidden' => PARAM_INT, 'qbshowtext' => PARAM_INT, 'cpage' => PARAM_INT, 'recurse' => PARAM_BOOL, 'showhidden' => PARAM_BOOL, 'qbshowtext' => PARAM_BOOL, 'qtagids' => [PARAM_INT], (array of integers) 'qbs1' => PARAM_TEXT, 'qbs2' => PARAM_TEXT, 'qbs3' => PARAM_TEXT, ... and more qbs keys up to question_bank_view::MAX_SORTS ... ]; param: string $edittab Code for this edit tab param: string $baseurl The name of the script calling this funciton. For examle 'qusetion/edit.php'. param: array $params The provided parameters to construct the resources with. return: array $thispageurl, $contexts, $cmid, $cm, $module, $pagevars |
question_get_category_id_from_pagevars(array $pagevars) X-Ref |
Get the category id from $pagevars. param: array $pagevars from {@link question_edit_setup()}. return: int the category id. |
question_get_display_preference($param, $default, $type, $thispageurl) X-Ref |
Get a particular question preference that is also stored as a user preference. If the the value is given in the GET/POST request, then that value is used, and the user preference is updated to that value. Otherwise, the last set value of the user preference is used, or if it has never been set the default passed to this function. param: string $param the param name. The URL parameter set, and the GET/POST param: mixed $default The default value to use, if not otherwise set. param: int $type one of the PARAM_... constants. param: moodle_url $thispageurl if the value has been explicitly set, we add return: mixed the parameter value to use. |
question_set_or_get_user_preference($name, $value, $default, $thispageurl) X-Ref |
Get a user preference by name or set the user preference to a given value. If $value is null then the function will only attempt to retrieve the user preference requested by $name. If no user preference is found then the $default value will be returned. In this case the user preferences are not modified and nor are the params on $thispageurl. If $value is anything other than null then the function will set the user preference $name to the provided $value and will also set it as a param on $thispageurl. param: string $name The user_preference name is 'question_bank_' . $name. param: mixed $value The preference value. param: mixed $default The default value to use, if not otherwise set. param: moodle_url $thispageurl if the value has been explicitly set, we add return: mixed the parameter value to use. |
require_login_in_context($contextorid = null) X-Ref |
Make sure user is logged in as required in this context. |
print_choose_qtype_to_add_form($hiddenparams, array $allowedqtypes = null, $enablejs = true) X-Ref |
Print a form to let the user choose which question type to add. When the form is submitted, it goes to the question.php script. param: $hiddenparams hidden parameters to add to the form, in addition to param: $allowedqtypes optional list of qtypes that are allowed. If given, only |
create_new_question_button($categoryid, $params, $caption, $tooltip = '', $disabled = false) X-Ref |
Print a button for creating a new question. This will open question/addquestion.php, which in turn goes to question/question.php before getting back to $params['returnurl'] (by default the question bank screen). param: int $categoryid The id of the category that the new question should be added to. param: array $params Other paramters to add to the URL. You need either $params['cmid'] or param: string $caption the text to display on the button. param: string $tooltip a tooltip to add to the button (optional). param: bool $disabled if true, the button will be disabled. |