[ Index ] |
PHP Cross Reference of Unnamed Project |
[Source view] [Print] [Project Stats]
A class for efficiently finds questions at random from the question bank.
Copyright: | 2015 The Open University |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 223 lines (9 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
random_question_loader:: (6 methods):
__construct()
get_next_question_id()
get_category_key()
ensure_questions_for_category_loaded()
use_question()
is_question_available()
Class: random_question_loader - X-Ref
This class efficiently finds questions at random from the question bank.__construct(\qubaid_condition $qubaids, array $usedquestions = array() X-Ref |
Constructor. param: \qubaid_condition $qubaids the usages to consider when counting previous uses of each question. param: array $usedquestions questionid => number of times used count. If we should allow for |
get_next_question_id($categoryid, $includesubcategories) X-Ref |
Pick a question at random from the given category, from among those with the fewest uses. It is up the the caller to verify that the cateogry exists. An unknown category behaves like an empty one. param: int $categoryid the id of a category in the question bank. param: bool $includesubcategories wether to pick a question from exactly return: int|null the id of the question picked, or null if there aren't any. |
get_category_key($categoryid, $includesubcategories) X-Ref |
Get the key into {@link $availablequestionscache} for this combination of options. param: int $categoryid the id of a category in the question bank. param: bool $includesubcategories wether to pick a question from exactly return: string the cache key. |
ensure_questions_for_category_loaded($categoryid, $includesubcategories) X-Ref |
Populate {@link $availablequestionscache} for this combination of options. param: int $categoryid the id of a category in the question bank. param: bool $includesubcategories wether to pick a question from exactly |
use_question($questionid) X-Ref |
Update the internal data structures to indicate that a given question has been used one more time. param: int $questionid the question that is being used. |
is_question_available($categoryid, $includesubcategories, $questionid) X-Ref |
Check whether a given question is available in a given category. If so, mark it used. param: int $categoryid the id of a category in the question bank. param: bool $includesubcategories wether to pick a question from exactly param: int $questionid the question that is being used. return: bool whether the question is available in the requested category. |
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |