|
Moodle
2.2.1
http://www.collinsharper.com
|
This class controls the loading and saving of question engine data to and from the database.
Definition at line 56 of file datalib.php.
| __construct | ( | $ | db = null | ) |
| moodle_database | $db | a database connectoin. Defaults to global $DB. |
Definition at line 66 of file datalib.php.
| delete_attempt_steps_for_mysql | ( | $ | test, |
| $ | params | ||
| ) | [protected] |
This function is a work-around for poor MySQL performance with DELETE FROM x WHERE id IN (SELECT ...). We have to use a non-standard syntax to get good performance. See MDL-29520.
| string | $test | sql fragment. |
| array | $params | used by $test. |
Definition at line 778 of file datalib.php.
| delete_previews | ( | $ | questionid | ) |
Delete all the previews for a given question.
| int | $questionid | question id. |
Definition at line 833 of file datalib.php.
| delete_questions_usage_by_activities | ( | qubaid_condition $ | qubaids | ) |
Delete a question_usage_by_activity and all its associated question_attempts and question_attempt_steps from the database.
| qubaid_condition | $qubaids | identifies which question useages to delete. |
Definition at line 713 of file datalib.php.

| delete_response_files | ( | $ | contextid, |
| $ | itemidstest, | ||
| $ | params | ||
| ) | [protected] |
Delete all the files belonging to the response variables in the gives question attempt steps.
| int | $contextid | the context these attempts belong to. |
| string | $itemidstest | a bit of SQL that can be used in a WHERE itemid $itemidstest clause. Must use named params. |
| array | $params | any query parameters used in $itemidstest. |
Definition at line 821 of file datalib.php.

| delete_steps | ( | $ | stepids, |
| $ | context | ||
| ) |
Delete all the steps for a question attempt.
| int | $qaids | question_attempt id. |
| context | $context | the context that the $quba belongs to. |
Definition at line 792 of file datalib.php.

| delete_usage_records_for_mysql | ( | qubaid_condition $ | qubaids | ) | [protected] |
This function is a work-around for poor MySQL performance with DELETE FROM x WHERE id IN (SELECT ...). We have to use a non-standard syntax to get good performance. See MDL-29520.
| qubaid_condition | $qubaids | identifies which question useages to delete. |
Definition at line 759 of file datalib.php.

| full_states_to_summary_state_sql | ( | ) | [protected] |
Get all the WHEN 'x' THEN 'y' terms needed to convert the question_attempt_steps.state column to a summary state. Use this like CASE qas.state {$this->full_states_to_summary_state_sql()} END AS summarystate,
| string | SQL fragment. |
Definition at line 868 of file datalib.php.

| in_summary_state_test | ( | $ | summarystate, |
| $ | equal = true, |
||
| $ | prefix = 'summarystates' |
||
| ) |
Get the SQL needed to test that question_attempt_steps.state is in a state corresponding to $summarystate.
| string | $summarystate | one of inprogress, needsgrading, manuallygraded or autograded |
| bool | $equal | if false, do a NOT IN test. Default true. |
Definition at line 884 of file datalib.php.

| insert_question_attempt | ( | question_attempt $ | qa, |
| $ | context | ||
| ) |
Store an entire question_attempt in the database, including all the question_attempt_steps that comprise it.
| question_attempt | $qa | the question attempt to store. |
| context | $context | the context of the owning question_usage_by_activity. |
Definition at line 100 of file datalib.php.


| insert_question_attempt_step | ( | question_attempt_step $ | step, |
| $ | questionattemptid, | ||
| $ | seq, | ||
| $ | context | ||
| ) |
Store a question_attempt_step in the database.
| question_attempt_step | $step | the step to store. |
| int | $questionattemptid | the question attept id this step belongs to. |
| int | $seq | the sequence number of this stop. |
| context | $context | the context of the owning question_usage_by_activity. |
Definition at line 171 of file datalib.php.


Store an entire question_usage_by_activity in the database, including all the question_attempts that comprise it.
| question_usage_by_activity | $quba | the usage to store. |
Definition at line 80 of file datalib.php.

| insert_step_data | ( | question_attempt_step $ | step, |
| $ | stepid, | ||
| $ | context | ||
| ) | [protected] |
Helper method used by insert_question_attempt_step and update_question_attempt_step
| question_attempt_step | $step | the step to store. |
| int | $stepid | the id of the step. |
| context | $context | the context of the owning question_usage_by_activity. |
Definition at line 150 of file datalib.php.


| latest_step_for_qa_subquery | ( | $ | questionattemptid = 'qa.id' | ) | [protected] |
Definition at line 973 of file datalib.php.
| load_attempts_at_question | ( | $ | questionid, |
| qubaid_condition $ | qubaids | ||
| ) |
Load a question_attempt from the database, including all its steps.
| int | $questionid | the question to load all the attempts fors. |
| qubaid_condition | $qubaids | used to restrict which usages are included in the query. See qubaid_condition. |
Definition at line 613 of file datalib.php.

| load_average_marks | ( | qubaid_condition $ | qubaids, |
| $ | slots = null |
||
| ) |
Load a question_usage_by_activity from the database, including all its question_attempts and all their steps.
| qubaid_condition | $qubaids | used to restrict which usages are included in the query. See qubaid_condition. |
| array | $slots | if null, load info for all quesitions, otherwise only load the averages for the specified questions. |
Definition at line 564 of file datalib.php.

| load_question_attempt | ( | $ | questionattemptid | ) |
Load a question_attempt from the database, including all its steps.
| int | $questionattemptid | the id of the question attempt to load. |
| question_attempt | the question attempt that was loaded. |
Definition at line 240 of file datalib.php.

| load_question_attempt_step | ( | $ | stepid | ) |
Load a question_attempt_step from the database.
| int | $stepid | the id of the step to load. |
| question_attempt_step | the step that was loaded. |
Definition at line 204 of file datalib.php.

| load_questions_usage_by_activity | ( | $ | qubaid | ) |
Load a question_usage_by_activity from the database, including all its question_attempts and all their steps.
| int | $qubaid | the id of the usage to load. |
| question_usage_by_activity | the usage that was loaded. |
Definition at line 297 of file datalib.php.

| load_questions_usages_latest_steps | ( | qubaid_condition $ | qubaids, |
| $ | slots | ||
| ) |
Load information about the latest state of each question from the database.
| qubaid_condition | $qubaids | used to restrict which usages are included in the query. See qubaid_condition. |
| array | $slots | A list of slots for the questions you want to konw about. |
Definition at line 357 of file datalib.php.

| load_questions_usages_question_state_summary | ( | qubaid_condition $ | qubaids, |
| $ | slots | ||
| ) |
Load summary information about the state of each question in a group of attempts. This is used, for example, by the quiz manual grading report, to show how many attempts at each question need to be graded.
| qubaid_condition | $qubaids | used to restrict which usages are included in the query. See qubaid_condition. |
| array | $slots | A list of slots for the questions you want to konw about. |
Definition at line 407 of file datalib.php.

| load_questions_usages_where_question_in_state | ( | qubaid_condition $ | qubaids, |
| $ | summarystate, | ||
| $ | slot, | ||
| $ | questionid = null, |
||
| $ | orderby = 'random', |
||
| $ | params, | ||
| $ | limitfrom = 0, |
||
| $ | limitnum = null |
||
| ) |
Get a list of usage ids where the question with slot $slot, and optionally also with question id $questionid, is in summary state $summarystate. Also return the total count of such states.
Only a subset of the ids can be returned by using $orderby, $limitfrom and $limitnum. A special value 'random' can be passed as $orderby, in which case $limitfrom is ignored.
| qubaid_condition | $qubaids | used to restrict which usages are included in the query. See qubaid_condition. |
| int | $slot | The slot for the questions you want to konw about. |
| int | $questionid | (optional) Only return attempts that were of this specific question. |
| string | $summarystate | the summary state of interest, or 'all'. |
| string | $orderby | the column to order by. |
| array | $params | any params required by any of the SQL fragments. |
| int | $limitfrom | implements paging of the results. Ignored if $orderby = random or $limitnum is null. |
| int | $limitnum | implements paging of the results. null = all. |
Definition at line 492 of file datalib.php.

| make_step_record | ( | question_attempt_step $ | step, |
| $ | questionattemptid, | ||
| $ | seq | ||
| ) | [protected] |
Helper method used by insert_question_attempt_step and update_question_attempt_step
| question_attempt_step | $step | the step to store. |
| int | $questionattemptid | the question attept id this step belongs to. |
| int | $seq | the sequence number of this stop. |
Definition at line 133 of file datalib.php.


| question_attempt_latest_state_view | ( | $ | alias, |
| qubaid_condition $ | qubaids | ||
| ) |
Get a subquery that returns the latest step of every qa in some qubas. Currently, this is only used by the quiz reports. See quiz_attempt_report_table::add_latest_state_join().
| string | $alias | alias to use for this inline-view. |
| qubaid_condition | $qubaids | restriction on which question_usages we are interested in. This is important for performance. |
Definition at line 944 of file datalib.php.

| questions_in_use | ( | array $ | questionids, |
| qubaid_condition $ | qubaids | ||
| ) |
| array | $questionids | of question ids. |
| qubaid_condition | $qubaids | ids of the usages to consider. |
Definition at line 987 of file datalib.php.

| set_max_mark_in_attempts | ( | qubaid_condition $ | qubaids, |
| $ | slot, | ||
| $ | newmaxmark | ||
| ) |
Change the maxmark for the question_attempt with number in usage $slot for all the specified question_attempts.
| qubaid_condition | $qubaids | Selects which usages are updated. |
| int | $slot | the number is usage to affect. |
| number | $newmaxmark | the new max mark to set. |
Definition at line 897 of file datalib.php.

| sum_usage_marks_subquery | ( | $ | qubaid | ) |
Return a subquery that computes the sum of the marks for all the questions in a usage. Which useage to compute the sum for is controlled bu the $qubaid parameter.
See quiz_update_all_attempt_sumgrades() for an example of the usage of this method.
| string | $qubaid | SQL fragment that controls which usage is summed. This will normally be the name of a column in the outer query. Not that this SQL fragment must not contain any placeholders. |
Definition at line 916 of file datalib.php.
Update a question_attempts row to refect any changes in a question_attempt (but not any of its steps).
| question_attempt | $qa | the question attempt that has changed. |
Definition at line 693 of file datalib.php.


| update_question_attempt_flag | ( | $ | qubaid, |
| $ | questionid, | ||
| $ | qaid, | ||
| $ | slot, | ||
| $ | newstate | ||
| ) |
Update the flagged state of a question in the database.
| int | $qubaid | the question usage id. |
| int | $questionid | the question id. |
| int | $sessionid | the question_attempt id. |
| bool | $newstate | the new state of the flag. true = flagged. |
Definition at line 853 of file datalib.php.
| update_question_attempt_step | ( | question_attempt_step $ | step, |
| $ | questionattemptid, | ||
| $ | seq, | ||
| $ | context | ||
| ) |
Update a question_attempt_step in the database.
| question_attempt_step | $qa | the step to store. |
| int | $questionattemptid | the question attept id this step belongs to. |
| int | $seq | the sequence number of this stop. |
| context | $context | the context of the owning question_usage_by_activity. |
Definition at line 187 of file datalib.php.


Update a question_usages row to refect any changes in a usage (but not any of its question_attempts.
| question_usage_by_activity | $quba | the usage that has changed. |
Definition at line 678 of file datalib.php.


$db [protected] |
Definition at line 61 of file datalib.php.