";
- $definitions = get_records('quiz_dataset_definitions',
+ $definitions = get_records('question_dataset_definitions',
'category',
$category->id);
for ($idef = 1, $total = max(5, count($definitions)) ; $idef <= $total ; ++$idef) {
diff --git a/question/questiontypes/datasetdependent/datasetitems.php b/question/questiontypes/datasetdependent/datasetitems.php
index 89a000bbd89..b94571f61e7 100644
--- a/question/questiontypes/datasetdependent/datasetitems.php
+++ b/question/questiontypes/datasetdependent/datasetitems.php
@@ -37,7 +37,7 @@
if (isset($datasetdef->id)
&& $datasetdef->options != $olddatasetdefs[$defid]->options) {
// Save the new value for options
- update_record('quiz_dataset_definitions', $datasetdef);
+ update_record('question_dataset_definitions', $datasetdef);
}
// Get maxnumber
@@ -56,12 +56,12 @@
if ($form->itemid[$key]) {
// Reuse an previously used record
$addeditem->id = $form->itemid[$key];
- if (!update_record('quiz_dataset_items', $addeditem)) {
+ if (!update_record('question_dataset_items', $addeditem)) {
error("Error: Unable to update dataset item");
}
} else {
unset($addeditem->id);
- if (!insert_record('quiz_dataset_items', $addeditem)) {
+ if (!insert_record('question_dataset_items', $addeditem)) {
error("Error: Unable to insert dataset item");
}
}
@@ -70,7 +70,7 @@
if (isset($newdef->id) && $newdef->itemcount <= $maxnumber) {
$newdef->itemcount = $maxnumber+1;
// Save the new value for options
- update_record('quiz_dataset_definitions', $newdef);
+ update_record('question_dataset_definitions', $newdef);
}
}
}
@@ -83,7 +83,7 @@
foreach ($datasetdefs as $datasetdef) {
if ($datasetdef->itemcount == $maxnumber) {
$datasetdef->itemcount--;
- if (!update_record('quiz_dataset_definitions',
+ if (!update_record('question_dataset_definitions',
$datasetdef)) {
error("Error: Unable to update itemcount");
}
@@ -107,7 +107,7 @@
if (isset($datasetdef->id)) {
$datasetdefs[$defid]->items = get_records_sql( // Use number as key!!
" SELECT number, definition, id, value
- FROM {$CFG->prefix}quiz_dataset_items
+ FROM {$CFG->prefix}question_dataset_items
WHERE definition = $datasetdef->id ");
}
diff --git a/question/questiontypes/essay/editquestion.php b/question/questiontypes/essay/editquestion.php
index f5215c5e968..8434ad7fab4 100644
--- a/question/questiontypes/essay/editquestion.php
+++ b/question/questiontypes/essay/editquestion.php
@@ -1,7 +1,7 @@
id)) {
- $options = get_record("quiz_essay", "question", "$question->id");
+ $options = get_record("question_essay", "question", "$question->id");
}
if (!empty($options->answer)) {
diff --git a/question/questiontypes/essay/questiontype.php b/question/questiontypes/essay/questiontype.php
index 08cc69718df..9e02af48a3e 100644
--- a/question/questiontypes/essay/questiontype.php
+++ b/question/questiontypes/essay/questiontype.php
@@ -5,7 +5,7 @@
/////////////////
/// QUESTION TYPE CLASS //////////////////
-class quiz_essay_qtype extends quiz_default_questiontype {
+class question_essay_qtype extends quiz_default_questiontype {
function name() {
return 'essay';
@@ -14,7 +14,7 @@ class quiz_essay_qtype extends quiz_default_questiontype {
function get_question_options(&$question) {
// Get additional information from database
// and attach it to the question object
- if (!$question->options = get_record('quiz_essay', 'question', $question->id)) {
+ if (!$question->options = get_record('question_essay', 'question', $question->id)) {
notify('Error: Missing question options!');
return false;
}
@@ -48,11 +48,11 @@ class quiz_essay_qtype extends quiz_default_questiontype {
return $result;
}
}
- if ($options = get_record("quiz_essay", "question", $question->id)) {
+ if ($options = get_record("question_essay", "question", $question->id)) {
// No need to do anything, since the answer IDs won't have changed
// But we'll do it anyway, just for robustness
$options->answer = $answer->id;
- if (!update_record("quiz_essay", $options)) {
+ if (!update_record("question_essay", $options)) {
$result->error = "Could not update quiz essay options! (id=$options->id)";
return $result;
}
@@ -60,7 +60,7 @@ class quiz_essay_qtype extends quiz_default_questiontype {
unset($options);
$options->question = $question->id;
$options->answer = $answer->id;
- if (!insert_record("quiz_essay", $options)) {
+ if (!insert_record("question_essay", $options)) {
$result->error = "Could not insert quiz essay options!";
return $result;
}
@@ -75,7 +75,7 @@ class quiz_essay_qtype extends quiz_default_questiontype {
* @param object $question The question being deleted
*/
function delete_question($question) {
- delete_records("quiz_essay", "question", $question->id);
+ delete_records("question_essay", "question", $question->id);
return true;
}
@@ -198,7 +198,7 @@ class quiz_essay_qtype extends quiz_default_questiontype {
}
function restore_session_and_responses(&$question, &$state) {
- if (!$options = get_record('quiz_essay_states', 'stateid', $state->id)) {
+ if (!$options = get_record('question_essay_states', 'stateid', $state->id)) {
return false;
}
$state->options->graded = $options->graded;
@@ -224,14 +224,14 @@ class quiz_essay_qtype extends quiz_default_questiontype {
$options->response = addslashes( clean_param($state->responses['response'], PARAM_CLEANHTML) );
}
if (isset($state->update)) {
- if (!$options->id = get_field('quiz_essay_states', 'id', 'stateid', $state->id)) {
+ if (!$options->id = get_field('question_essay_states', 'id', 'stateid', $state->id)) {
return false;
}
- if (!update_record('quiz_essay_states', $options)) {
+ if (!update_record('question_essay_states', $options)) {
return false;
}
} else {
- if (!insert_record('quiz_essay_states', $options)) {
+ if (!insert_record('question_essay_states', $options)) {
return false;
}
}
@@ -289,7 +289,7 @@ class quiz_essay_qtype extends quiz_default_questiontype {
if (!$neweststate = get_record('question_sessions', 'attemptid', $attempt->uniqueid, 'questionid', $question->id)) {
error("Can not find newest states for attempt $attempt->uniqueid for question $question->id");
}
- if (!$questionstate = get_record('quiz_essay_states', 'stateid', $neweststate->newest)) {
+ if (!$questionstate = get_record('question_essay_states', 'stateid', $neweststate->newest)) {
error('Could not find question state');
}
if (!$questionstate->graded) {
@@ -311,6 +311,6 @@ class quiz_essay_qtype extends quiz_default_questiontype {
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-$QTYPES[ESSAY] = new quiz_essay_qtype();
+$QTYPES[ESSAY] = new question_essay_qtype();
?>
diff --git a/question/questiontypes/match/editquestion.php b/question/questiontypes/match/editquestion.php
index e0051d73789..8cb31fff3be 100644
--- a/question/questiontypes/match/editquestion.php
+++ b/question/questiontypes/match/editquestion.php
@@ -1,9 +1,9 @@
id)) {
- $options = get_record("quiz_match", "question", $question->id);
+ $options = get_record("question_match", "question", $question->id);
if (!empty($options->subquestions)) {
- $oldsubquestions = get_records_list("quiz_match_sub", "id", $options->subquestions);
+ $oldsubquestions = get_records_list("question_match_sub", "id", $options->subquestions);
}
} else {
$options->shuffleanswers = 1;
diff --git a/question/questiontypes/match/questiontype.php b/question/questiontypes/match/questiontype.php
index 6444c39eaa8..57a5285c071 100644
--- a/question/questiontypes/match/questiontype.php
+++ b/question/questiontypes/match/questiontype.php
@@ -5,21 +5,21 @@
/////////////
/// QUESTION TYPE CLASS //////////////////
-class quiz_match_qtype extends quiz_default_questiontype {
+class question_match_qtype extends quiz_default_questiontype {
function name() {
return 'match';
}
function get_question_options(&$question) {
- $question->options = get_record('quiz_match', 'question', $question->id);
- $question->options->subquestions = get_records("quiz_match_sub", "question", $question->id, "id ASC" );
+ $question->options = get_record('question_match', 'question', $question->id);
+ $question->options->subquestions = get_records("question_match_sub", "question", $question->id, "id ASC" );
return true;
}
function save_question_options($question) {
- if (!$oldsubquestions = get_records("quiz_match_sub", "question", $question->id, "id ASC")) {
+ if (!$oldsubquestions = get_records("question_match_sub", "question", $question->id, "id ASC")) {
$oldsubquestions = array();
}
@@ -47,7 +47,7 @@ class quiz_match_qtype extends quiz_default_questiontype {
if ($subquestion = array_shift($oldsubquestions)) { // Existing answer, so reuse it
$subquestion->questiontext = $questiontext;
$subquestion->answertext = $answertext;
- if (!update_record("quiz_match_sub", $subquestion)) {
+ if (!update_record("question_match_sub", $subquestion)) {
$result->error = "Could not insert quiz match subquestion! (id=$subquestion->id)";
return $result;
}
@@ -55,13 +55,13 @@ class quiz_match_qtype extends quiz_default_questiontype {
unset($subquestion);
// Determine a unique random code
$subquestion->code = rand(1,999999999);
- while (record_exists('quiz_match_sub', 'code', $subquestion->code)) {
+ while (record_exists('question_match_sub', 'code', $subquestion->code)) {
$subquestion->code = rand();
}
$subquestion->question = $question->id;
$subquestion->questiontext = $questiontext;
$subquestion->answertext = $answertext;
- if (!$subquestion->id = insert_record("quiz_match_sub", $subquestion)) {
+ if (!$subquestion->id = insert_record("question_match_sub", $subquestion)) {
$result->error = "Could not insert quiz match subquestion!";
return $result;
}
@@ -73,7 +73,7 @@ class quiz_match_qtype extends quiz_default_questiontype {
// delete old subquestions records
if (!empty($oldsubquestions)) {
foreach($oldsubquestions as $os) {
- delete_records('quiz_match_sub', 'id', $os->id);
+ delete_records('question_match_sub', 'id', $os->id);
}
}
@@ -82,10 +82,10 @@ class quiz_match_qtype extends quiz_default_questiontype {
return $result;
}
- if ($options = get_record("quiz_match", "question", $question->id)) {
+ if ($options = get_record("question_match", "question", $question->id)) {
$options->subquestions = implode(",",$subquestions);
$options->shuffleanswers = $question->shuffleanswers;
- if (!update_record("quiz_match", $options)) {
+ if (!update_record("question_match", $options)) {
$result->error = "Could not update quiz match options! (id=$options->id)";
return $result;
}
@@ -94,7 +94,7 @@ class quiz_match_qtype extends quiz_default_questiontype {
$options->question = $question->id;
$options->subquestions = implode(",",$subquestions);
$options->shuffleanswers = $question->shuffleanswers;
- if (!insert_record("quiz_match", $options)) {
+ if (!insert_record("question_match", $options)) {
$result->error = "Could not insert quiz match options!";
return $result;
}
@@ -109,13 +109,13 @@ class quiz_match_qtype extends quiz_default_questiontype {
* @param integer $question->id
*/
function delete_question($question) {
- delete_records("quiz_match", "question", $question->id);
- delete_records("quiz_match_sub", "question", $question->id);
+ delete_records("question_match", "question", $question->id);
+ delete_records("question_match_sub", "question", $question->id);
return true;
}
function create_session_and_responses(&$question, &$state, $cmoptions, $attempt) {
- if (!$state->options->subquestions = get_records('quiz_match_sub',
+ if (!$state->options->subquestions = get_records('question_match_sub',
'question', $question->id)) {
notify('Error: Missing subquestions!');
return false;
@@ -147,12 +147,12 @@ class quiz_match_qtype extends quiz_default_questiontype {
function restore_session_and_responses(&$question, &$state) {
// The serialized format for matching questions is a comma separated
// list of question answer pairs (e.g. 1-1,2-3,3-2), where the ids of
- // both refer to the id in the table quiz_match_sub.
+ // both refer to the id in the table question_match_sub.
$responses = explode(',', $state->responses['']);
$responses = array_map(create_function('$val',
'return explode("-", $val);'), $responses);
- if (!$questions = get_records('quiz_match_sub',
+ if (!$questions = get_records('question_match_sub',
'question', $question->id)) {
notify('Error: Missing subquestions!');
return false;
@@ -337,6 +337,6 @@ class quiz_match_qtype extends quiz_default_questiontype {
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-$QTYPES[MATCH]= new quiz_match_qtype();
+$QTYPES[MATCH]= new question_match_qtype();
?>
diff --git a/question/questiontypes/multianswer/questiontype.php b/question/questiontypes/multianswer/questiontype.php
index c6352960ea0..8afc0249eb5 100644
--- a/question/questiontypes/multianswer/questiontype.php
+++ b/question/questiontypes/multianswer/questiontype.php
@@ -23,7 +23,7 @@ class quiz_embedded_cloze_qtype extends quiz_default_questiontype {
global $QTYPES;
// Get relevant data indexed by positionkey from the multianswers table
- if (!$sequence = get_field('quiz_multianswers', 'sequence', 'question', $question->id)) {
+ if (!$sequence = get_field('question_multianswer', 'sequence', 'question', $question->id)) {
notify('Error: Missing question options!');
return false;
}
@@ -89,15 +89,15 @@ class quiz_embedded_cloze_qtype extends quiz_default_questiontype {
$multianswer->question = $question->id;
$multianswer->sequence = implode(',', $sequence);
if ($oldid =
- get_field('quiz_multianswers', 'id', 'question', $question->id)) {
+ get_field('question_multianswer', 'id', 'question', $question->id)) {
$multianswer->id = $oldid;
- if (!update_record("quiz_multianswers", $multianswer)) {
+ if (!update_record("question_multianswer", $multianswer)) {
$result->error = "Could not update quiz multianswer! " .
"(id=$multianswer->id)";
return $result;
}
} else {
- if (!insert_record("quiz_multianswers", $multianswer)) {
+ if (!insert_record("question_multianswer", $multianswer)) {
$result->error = "Could not insert quiz multianswer!";
return $result;
}
@@ -172,7 +172,7 @@ class quiz_embedded_cloze_qtype extends quiz_default_questiontype {
* @param object $question The question being deleted
*/
function delete_question($question) {
- delete_records("quiz_multianswers", "question", $question->id);
+ delete_records("question_multianswer", "question", $question->id);
return true;
}
diff --git a/question/questiontypes/multichoice/editquestion.php b/question/questiontypes/multichoice/editquestion.php
index 6b1e85850bc..a3313c54da0 100644
--- a/question/questiontypes/multichoice/editquestion.php
+++ b/question/questiontypes/multichoice/editquestion.php
@@ -1,7 +1,7 @@
id)) {
- $options = get_record("quiz_multichoice", "question", $question->id);
+ $options = get_record("question_multichoice", "question", $question->id);
} else {
$options->single = 1;
$options->shuffleanswers = 1;
diff --git a/question/questiontypes/multichoice/questiontype.php b/question/questiontypes/multichoice/questiontype.php
index d53664f2e68..fa4ad22d8ed 100644
--- a/question/questiontypes/multichoice/questiontype.php
+++ b/question/questiontypes/multichoice/questiontype.php
@@ -11,7 +11,7 @@
/// question type embeddable within a multianswer (cloze) question
///
-class quiz_multichoice_qtype extends quiz_default_questiontype {
+class question_multichoice_qtype extends quiz_default_questiontype {
function name() {
return 'multichoice';
@@ -20,7 +20,7 @@ class quiz_multichoice_qtype extends quiz_default_questiontype {
function get_question_options(&$question) {
// Get additional information from database
// and attach it to the question object
- if (!$question->options = get_record('quiz_multichoice', 'question',
+ if (!$question->options = get_record('question_multichoice', 'question',
$question->id)) {
notify('Error: Missing question options!');
return false;
@@ -93,11 +93,11 @@ class quiz_multichoice_qtype extends quiz_default_questiontype {
}
}
- if ($options = get_record("quiz_multichoice", "question", $question->id)) {
+ if ($options = get_record("question_multichoice", "question", $question->id)) {
$options->answers = implode(",",$answers);
$options->single = $question->single;
$options->shuffleanswers = $question->shuffleanswers;
- if (!update_record("quiz_multichoice", $options)) {
+ if (!update_record("question_multichoice", $options)) {
$result->error = "Could not update quiz multichoice options! (id=$options->id)";
return $result;
}
@@ -107,7 +107,7 @@ class quiz_multichoice_qtype extends quiz_default_questiontype {
$options->answers = implode(",",$answers);
$options->single = $question->single;
$options->shuffleanswers = $question->shuffleanswers;
- if (!insert_record("quiz_multichoice", $options)) {
+ if (!insert_record("question_multichoice", $options)) {
$result->error = "Could not insert quiz multichoice options!";
return $result;
}
@@ -145,7 +145,7 @@ class quiz_multichoice_qtype extends quiz_default_questiontype {
* @param object $question The question being deleted
*/
function delete_question($question) {
- delete_records("quiz_multichoice", "question", $question->id);
+ delete_records("question_multichoice", "question", $question->id);
return true;
}
@@ -372,6 +372,6 @@ class quiz_multichoice_qtype extends quiz_default_questiontype {
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-$QTYPES[MULTICHOICE]= new quiz_multichoice_qtype();
+$QTYPES[MULTICHOICE]= new question_multichoice_qtype();
?>
diff --git a/question/questiontypes/numerical/questiontype.php b/question/questiontypes/numerical/questiontype.php
index 48662dd4aae..a5a53c16009 100644
--- a/question/questiontypes/numerical/questiontype.php
+++ b/question/questiontypes/numerical/questiontype.php
@@ -16,7 +16,7 @@
require_once("$CFG->dirroot/question/questiontypes/shortanswer/questiontype.php");
-class quiz_numerical_qtype extends quiz_shortanswer_qtype {
+class question_numerical_qtype extends question_shortanswer_qtype {
function name() {
return 'numerical';
@@ -24,14 +24,14 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
function get_question_options(&$question) {
// Get the question answers and their respective tolerances
- // Note: quiz_numerical is an extension of the answer table rather than
+ // Note: question_numerical is an extension of the answer table rather than
// the question table as is usually the case for qtype
// specific tables.
global $CFG;
if (!$question->options->answers = get_records_sql(
"SELECT a.*, n.tolerance " .
"FROM {$CFG->prefix}question_answers a, " .
- " {$CFG->prefix}quiz_numerical n " .
+ " {$CFG->prefix}question_numerical n " .
"WHERE a.question = $question->id " .
"AND a.id = n.answer;")) {
notify('Error: Missing question answer!');
@@ -55,7 +55,7 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
}
function get_numerical_units(&$question) {
- if ($question->options->units = get_records('quiz_numerical_units',
+ if ($question->options->units = get_records('question_numerical_units',
'question', $question->id, 'id ASC')) {
$question->options->units = array_values($question->options->units);
usort($question->options->units, create_function('$a, $b', // make sure the default unit is at index 0
@@ -98,7 +98,7 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
$oldanswers = array();
}
- if (!$oldoptions = get_records("quiz_numerical", "question", $question->id)) {
+ if (!$oldoptions = get_records("question_numerical", "question", $question->id)) {
$oldoptions = array();
}
@@ -141,12 +141,12 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
// Save options
if (isset($options->id)) { // reusing existing record
- if (! update_record('quiz_numerical', $options)) {
+ if (! update_record('question_numerical', $options)) {
$result->error = "Could not update quiz numerical options! (id=$options->id)";
return $result;
}
} else { // new options
- if (! insert_record('quiz_numerical', $options)) {
+ if (! insert_record('question_numerical', $options)) {
$result->error = "Could not insert quiz numerical options!";
return $result;
}
@@ -162,7 +162,7 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
// delete old answer records
if (!empty($oldoptions)) {
foreach($oldoptions as $oo) {
- delete_records('quiz_numerical', 'id', $oo->id);
+ delete_records('question_numerical', 'id', $oo->id);
}
}
@@ -171,7 +171,7 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
}
function save_numerical_units($question) {
- if (!$oldunits = get_records("quiz_numerical_units", "question", $question->id)) {
+ if (!$oldunits = get_records("question_numerical_units", "question", $question->id)) {
$oldunits = array();
}
@@ -202,16 +202,16 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
/// Save units
for ($i = 0; $i < $n; $i++) {
if (!isset($units[$i]) && isset($oldunits[$i])) { // Delete if it hasn't been resubmitted
- delete_records('quiz_numerical_units', 'id', $oldunits[$i]->id);
+ delete_records('question_numerical_units', 'id', $oldunits[$i]->id);
} else if ($oldunits != $units) { // answer has changed or is new
if (isset($oldunits[$i]->id)) { // answer has changed
$units[$i]->id = $oldunits[$i]->id;
- if (! update_record('quiz_numerical_units', $units[$i])) {
- $result->error = "Could not update quiz_numerical_unit $units[$i]->unit";
+ if (! update_record('question_numerical_units', $units[$i])) {
+ $result->error = "Could not update question_numerical_unit $units[$i]->unit";
return $result;
}
} else if (isset($units[$i])) { // answer is new
- if (! insert_record('quiz_numerical_units', $units[$i])) {
+ if (! insert_record('question_numerical_units', $units[$i])) {
$result->error = "Unable to insert new unit $units[$i]->unit";
return $result;
}
@@ -229,8 +229,8 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
* @param object $question The question being deleted
*/
function delete_question($question) {
- delete_records("quiz_numerical", "question", $question->id);
- delete_records("quiz_numerical_units", "question", $question->id);
+ delete_records("question_numerical", "question", $question->id);
+ delete_records("question_numerical_units", "question", $question->id);
return true;
}
@@ -409,6 +409,6 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-$QTYPES[NUMERICAL]= new quiz_numerical_qtype();
+$QTYPES[NUMERICAL]= new question_numerical_qtype();
?>
diff --git a/question/questiontypes/randomsamatch/editquestion.php b/question/questiontypes/randomsamatch/editquestion.php
index 1b861422468..cf5b4d28c8a 100644
--- a/question/questiontypes/randomsamatch/editquestion.php
+++ b/question/questiontypes/randomsamatch/editquestion.php
@@ -1,6 +1,6 @@
id)) {
- $options = get_record("quiz_randomsamatch", "question", $question->id);
+ $options = get_record("question_randomsamatch", "question", $question->id);
} else {
$options->choose = "";
$options->shuffleanswers = 1;
diff --git a/question/questiontypes/randomsamatch/questiontype.php b/question/questiontypes/randomsamatch/questiontype.php
index b78c8b84880..af53bf07f7e 100644
--- a/question/questiontypes/randomsamatch/questiontype.php
+++ b/question/questiontypes/randomsamatch/questiontype.php
@@ -8,7 +8,7 @@
/// can not also be used by a random question
/// QUESTION TYPE CLASS //////////////////
-class quiz_randomsamatch_qtype extends quiz_match_qtype {
+class question_randomsamatch_qtype extends question_match_qtype {
/// Extends MATCH as there are quite a few simularities...
function name() {
@@ -16,7 +16,7 @@ class quiz_randomsamatch_qtype extends quiz_match_qtype {
}
function get_question_options(&$question) {
- if (!$question->options = get_record('quiz_randomsamatch', 'question', $question->id)) {
+ if (!$question->options = get_record('question_randomsamatch', 'question', $question->id)) {
notify('Error: Missing question options!');
return false;
}
@@ -39,15 +39,15 @@ class quiz_randomsamatch_qtype extends quiz_match_qtype {
return $result;
}
- if ($existing = get_record("quiz_randomsamatch",
+ if ($existing = get_record("question_randomsamatch",
"question", $options->question)) {
$options->id = $existing->id;
- if (!update_record("quiz_randomsamatch", $options)) {
+ if (!update_record("question_randomsamatch", $options)) {
$result->error = "Could not update quiz randomsamatch options!";
return $result;
}
} else {
- if (!insert_record("quiz_randomsamatch", $options)) {
+ if (!insert_record("question_randomsamatch", $options)) {
$result->error = "Could not insert quiz randomsamatch options!";
return $result;
}
@@ -62,7 +62,7 @@ class quiz_randomsamatch_qtype extends quiz_match_qtype {
* @param object $question The question being deleted
*/
function delete_question($question) {
- delete_records("quiz_randomsamatch", "question", $question->id);
+ delete_records("question_randomsamatch", "question", $question->id);
return true;
}
@@ -248,6 +248,6 @@ class quiz_randomsamatch_qtype extends quiz_match_qtype {
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-$QTYPES[RANDOMSAMATCH]= new quiz_randomsamatch_qtype();
+$QTYPES[RANDOMSAMATCH]= new question_randomsamatch_qtype();
?>
diff --git a/question/questiontypes/rqp/editquestion.php b/question/questiontypes/rqp/editquestion.php
index 25207404022..945b3196b2e 100644
--- a/question/questiontypes/rqp/editquestion.php
+++ b/question/questiontypes/rqp/editquestion.php
@@ -14,7 +14,7 @@
error("Could not load the options for this question");
}
- if (!$type = get_record('quiz_rqp_types', 'id', $question->options->type)) {
+ if (!$type = get_record('question_rqp_types', 'id', $question->options->type)) {
error("Invalid remote question type");
}
diff --git a/question/questiontypes/rqp/lib.php b/question/questiontypes/rqp/lib.php
index 9ac8e2528c5..c03153171bd 100644
--- a/question/questiontypes/rqp/lib.php
+++ b/question/questiontypes/rqp/lib.php
@@ -11,15 +11,15 @@
*/
-function quiz_rqp_save_type($type) {
+function question_rqp_save_type($type) {
if (empty($type->id)) {
- return insert_record('quiz_rqp_types', $type, false);
+ return insert_record('question_rqp_types', $type, false);
}
- return update_record('quiz_rqp_types', $type);
+ return update_record('question_rqp_types', $type);
}
-function quiz_rqp_delete_type($id) {
- return delete_records('quiz_rqp_type', 'id', $id);
+function question_rqp_delete_type($id) {
+ return delete_records('question_rqp_type', 'id', $id);
}
/**
@@ -28,14 +28,14 @@ function quiz_rqp_delete_type($id) {
*
* An associative array of values or an associative array of arrays is imploded
* to a string by creating a colon separated list of space separated values. The
-* key is treated as the first value. The {@link quiz_rqp_explode} function can
+* key is treated as the first value. The {@link question_rqp_explode} function can
* restore the array from this string representation.
* @return string The string representation of the array. This is a colon
* separated list of space separated values.
* @param array $array An associative array of single values or an associative
* array of arrays to be imploded.
*/
-function quiz_rqp_implode($array) {
+function question_rqp_implode($array) {
if (count($array) < 1) {
return '';
}
@@ -64,7 +64,7 @@ function quiz_rqp_implode($array) {
* string representation
*
* Takes a colon separated list of space separated values as produced by
-* {@link quiz_rqp_implode} and recreates the array. If an array of single values
+* {@link question_rqp_implode} and recreates the array. If an array of single values
* is expected then an error results if an element has more than one value.
* Otherwise every value is an array.
* @return array The associative array restored from the string. Every
@@ -78,7 +78,7 @@ function quiz_rqp_implode($array) {
* The default is false indicating an array of single
* values is expected.
*/
-function quiz_rqp_explode($str, $multi=false) {
+function question_rqp_explode($str, $multi=false) {
// Explode by colon
if ($str === '') {
return array();
@@ -107,7 +107,7 @@ function quiz_rqp_explode($str, $multi=false) {
return $return;
}
-function quiz_rqp_print_serverinfo($serverinfo) {
+function question_rqp_print_serverinfo($serverinfo) {
$info->align = array('right', 'left');
$info->data = array(); // will hold the data for the info table
$info->data[] = array(''.get_string('url', 'quiz').':',$serverinfo->url);
@@ -117,7 +117,7 @@ function quiz_rqp_print_serverinfo($serverinfo) {
print_table($info);
}
-function quiz_rqp_debug_soap($item) {
+function question_rqp_debug_soap($item) {
global $CFG;
if ($CFG->debug) {
echo 'Here is the dump of the soap fault:';
diff --git a/question/questiontypes/rqp/questiontype.php b/question/questiontypes/rqp/questiontype.php
index 5681e4f291a..95e42e3c95d 100644
--- a/question/questiontypes/rqp/questiontype.php
+++ b/question/questiontypes/rqp/questiontype.php
@@ -16,7 +16,7 @@ require_once($CFG->dirroot . '/question/questiontypes/rqp/remote.php');
/**
* RQP question type class
*/
-class quiz_rqp_qtype extends quiz_default_questiontype {
+class question_rqp_qtype extends quiz_default_questiontype {
/**
* Name of the rqp question type
@@ -37,12 +37,12 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
global $CFG;
// Check source type
- if (!$type = get_record('quiz_rqp_types', 'id', $form->type)) {
+ if (!$type = get_record('question_rqp_types', 'id', $form->type)) {
$result->notice = get_string('invalidsourcetype', 'quiz');
return $result;
}
- // Create the object to be stored in quiz_rqp table
+ // Create the object to be stored in question_rqp table
$options = new object;
$options->question = $form->id;
$options->type = $form->type;
@@ -58,7 +58,7 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
}
if (is_soap_fault($item)) {
$result->notice = get_string('invalidsource', 'quiz', $item);
- quiz_rqp_debug_soap($item);
+ question_rqp_debug_soap($item);
return $result;
}
if ($item->error) {
@@ -83,18 +83,18 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
$options->flags |= $item->adaptive ? REMOTE_ADAPTIVE : 0;
// Save the options
- if ($old = get_record('quiz_rqp', 'question', $form->id)) {
+ if ($old = get_record('question_rqp', 'question', $form->id)) {
$old->type = $options->type;
$old->source = $options->source;
$old->format = $options->format;
$old->flags = $options->flags;
$old->maxscore = $options->maxscore;
- if (!update_record('quiz_rqp', $old)) {
+ if (!update_record('question_rqp', $old)) {
$result->error = "Could not update quiz rqp options! (id=$old->id)";
return $result;
}
} else {
- if (!insert_record('quiz_rqp', $options)) {
+ if (!insert_record('question_rqp', $options)) {
$result->error = 'Could not insert quiz rqp options!';
return $result;
}
@@ -113,10 +113,10 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
function get_question_options(&$question) {
$options =& $question->options;
- if (! ($options = get_record('quiz_rqp', 'question', $question->id))) {
+ if (! ($options = get_record('question_rqp', 'question', $question->id))) {
return false;
}
- if (!$type = get_record('quiz_rqp_types', 'id', $options->type)) {
+ if (!$type = get_record('question_rqp_types', 'id', $options->type)) {
return false;
}
$options->type_name = $type->name;
@@ -130,8 +130,8 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
* @param object $question The question being deleted
*/
function delete_question($question) {
- delete_records("quiz_rqp", "question", $questionid);
- //TODO: delete also the states from quiz_rqp_states
+ delete_records("question_rqp", "question", $questionid);
+ //TODO: delete also the states from question_rqp_states
return true;
}
@@ -180,7 +180,7 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
* Restores the session data and most recent responses for the given state
*
* This function loads any session data associated with the question session
- * in the given state from the quiz_rqp_states table into the state object.
+ * in the given state from the question_rqp_states table into the state object.
* @return bool Indicates success or failure.
* @param object $question The question object for the question including any
* question type specific information.
@@ -190,13 +190,13 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
* (it is passed by reference).
*/
function restore_session_and_responses(&$question, &$state) {
- if (!$options = get_record('quiz_rqp_states', 'stateid', $state->id)) {
+ if (!$options = get_record('question_rqp_states', 'stateid', $state->id)) {
return false;
}
- $state->responses = quiz_rqp_explode($options->responses);
+ $state->responses = question_rqp_explode($options->responses);
$state->options->persistent_data = $options->persistent_data;
$state->options->template_vars =
- quiz_rqp_explode($options->template_vars, true);
+ question_rqp_explode($options->template_vars, true);
return true;
}
@@ -204,7 +204,7 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
* Saves the session data and responses for the question in a new state
*
* This function saves all session data from the state object into the
- * quiz_rqp_states table
+ * question_rqp_states table
* @return bool Indicates success or failure.
* @param object $question The question object for the question including
* the question type specific information.
@@ -213,19 +213,19 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
*/
function save_session_and_responses(&$question, &$state) {
$options->stateid = $state->id;
- $options->responses = quiz_rqp_implode($state->responses);
+ $options->responses = question_rqp_implode($state->responses);
$options->persistent_data = $state->options->persistent_data;
$options->template_vars =
- quiz_rqp_implode($state->options->template_vars);
+ question_rqp_implode($state->options->template_vars);
if ($state->update) {
- if (!$options->id = get_field('quiz_rqp_states', 'id', 'stateid', $state->id)) {
+ if (!$options->id = get_field('question_rqp_states', 'id', 'stateid', $state->id)) {
return false;
}
- if (!update_record('quiz_rqp_states', $options)) {
+ if (!update_record('question_rqp_states', $options)) {
return false;
}
} else {
- if (!insert_record('quiz_rqp_states', $options)) {
+ if (!insert_record('question_rqp_states', $options)) {
return false;
}
}
@@ -264,7 +264,7 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
}
if (is_soap_fault($output)) {
notify(get_string('errorrendering', 'quiz'));
- quiz_rqp_debug_soap($output);
+ question_rqp_debug_soap($output);
unset($output);
exit;
}
@@ -437,6 +437,6 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-$QTYPES[RQP]= new quiz_rqp_qtype();
+$QTYPES[RQP]= new question_rqp_qtype();
?>
diff --git a/question/questiontypes/rqp/remote.php b/question/questiontypes/rqp/remote.php
index d1d5862e9e2..75bfd45740f 100644
--- a/question/questiontypes/rqp/remote.php
+++ b/question/questiontypes/rqp/remote.php
@@ -38,7 +38,7 @@ function remote_connect($typeid) {
if (!array_key_exists($typeid, $remote_connections)) {
// get the available servers
- if (!$servers = get_records('quiz_rqp_servers', 'typeid', $typeid)) {
+ if (!$servers = get_records('question_rqp_servers', 'typeid', $typeid)) {
// we don't have a server for this question type
return false;
}
@@ -84,7 +84,7 @@ function remote_server_info($url) {
/**
* Create connection to an RQP server and requests server information
*
-* @param object $options The RQP question options as stored in the quiz_rqp table
+* @param object $options The RQP question options as stored in the question_rqp table
* @return object An object holding the results of the ItemInformation call
* Returns false in the case of failure
*/
diff --git a/question/questiontypes/rqp/types.php b/question/questiontypes/rqp/types.php
index ce5a32fe9ee..a38b6cb442d 100644
--- a/question/questiontypes/rqp/types.php
+++ b/question/questiontypes/rqp/types.php
@@ -54,24 +54,24 @@
break;
}
// add new type to database unless it exists already
- if (!$type = get_record('quiz_rqp_types', 'name', $form->name)) {
+ if (!$type = get_record('question_rqp_types', 'name', $form->name)) {
$type->name = $form->name;
- if (!$type->id = insert_record('quiz_rqp_types', $type)) {
+ if (!$type->id = insert_record('question_rqp_types', $type)) {
error("Could not save type $type");
}
}
// add new server to database unless it exists already
- if (!$server = get_record('quiz_rqp_servers', 'url', $form->url)) {
+ if (!$server = get_record('question_rqp_servers', 'url', $form->url)) {
$server->typeid = $type->id;
$server->url = $form->url;
$server->can_render = $serverinfo->rendering ? 1 : 0;
- if (!insert_record('quiz_rqp_servers', $server)) {
+ if (!insert_record('question_rqp_servers', $server)) {
error("Could not save server $form->url");
}
}
// print info about new server
print_heading(get_string('serveradded', 'quiz'));
- quiz_rqp_print_serverinfo($serverinfo);
+ question_rqp_print_serverinfo($serverinfo);
break;
@@ -80,14 +80,14 @@
if ($delete and confirm_sesskey()) { // delete server
if ($confirm) {
- delete_records('quiz_rqp_servers', 'id', $delete);
+ delete_records('question_rqp_servers', 'id', $delete);
} else {
- if (!$server = get_record('quiz_rqp_servers', 'id', $delete)) {
+ if (!$server = get_record('question_rqp_servers', 'id', $delete)) {
error('Invalid server id');
}
- if ((count_records('quiz_rqp_servers', 'typeid', $server->typeid) == 1) // this is the last server of its type
- and record_exists('quiz_rqp', 'type', $server->typeid)) { // and there are questions using it
- $type = get_record('quiz_rqp_types', 'id', $server->typeid);
+ if ((count_records('question_rqp_servers', 'typeid', $server->typeid) == 1) // this is the last server of its type
+ and record_exists('question_rqp', 'type', $server->typeid)) { // and there are questions using it
+ $type = get_record('question_rqp_types', 'id', $server->typeid);
notify(get_string('serverinuse', 'quiz', $type->name));
}
notice_yesno(get_string('confirmserverdelete', 'quiz', $server->url), 'types.php?delete='.$delete.'&sesskey='.sesskey().'&confirm=true', 'types.php');
@@ -95,7 +95,7 @@
}
if ($info) { // show info for server
- if (!$server = get_record('quiz_rqp_servers', 'id', $info)) {
+ if (!$server = get_record('question_rqp_servers', 'id', $info)) {
error('Invalid server id');
}
// Check server exists and works
@@ -104,7 +104,7 @@
} else {
// print the info
print_heading(get_string('serverinfo', 'quiz'));
- quiz_rqp_print_serverinfo($serverinfo);
+ question_rqp_print_serverinfo($serverinfo);
}
}
@@ -130,7 +130,7 @@
/// Create table rows
// Get list of types
- $types = get_records('quiz_rqp_types', '', '', 'name ASC');
+ $types = get_records('question_rqp_types', '', '', 'name ASC');
$strinfo = get_string('info');
$strdelete = get_string('delete');
@@ -138,8 +138,8 @@
if ($types) {
foreach ($types as $type) {
- if (!$servers = get_records('quiz_rqp_servers', 'typeid', $type->id)) {
- delete_records('quiz_rqp_types', 'id', $type->id);
+ if (!$servers = get_records('question_rqp_servers', 'typeid', $type->id)) {
+ delete_records('question_rqp_types', 'id', $type->id);
} else {
foreach ($servers as $server) {
$actions = ' ';
diff --git a/question/questiontypes/shortanswer/editquestion.php b/question/questiontypes/shortanswer/editquestion.php
index e50c151047f..23808ecd5d9 100644
--- a/question/questiontypes/shortanswer/editquestion.php
+++ b/question/questiontypes/shortanswer/editquestion.php
@@ -1,6 +1,6 @@
id)) {
- $options = get_record("quiz_shortanswer", "question", $question->id);
+ $options = get_record("question_shortanswer", "question", $question->id);
} else {
$options->usecase = 0;
}
diff --git a/question/questiontypes/shortanswer/questiontype.php b/question/questiontypes/shortanswer/questiontype.php
index 6481f8b161a..aa488cf9fba 100644
--- a/question/questiontypes/shortanswer/questiontype.php
+++ b/question/questiontypes/shortanswer/questiontype.php
@@ -11,7 +11,7 @@
/// question type embeddable within a multianswer (cloze) question
///
-class quiz_shortanswer_qtype extends quiz_default_questiontype {
+class question_shortanswer_qtype extends quiz_default_questiontype {
function name() {
return 'shortanswer';
@@ -20,7 +20,7 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype {
function get_question_options(&$question) {
// Get additional information from database
// and attach it to the question object
- if (!$question->options = get_record('quiz_shortanswer', 'question', $question->id)) {
+ if (!$question->options = get_record('question_shortanswer', 'question', $question->id)) {
notify('Error: Missing question options!');
return false;
}
@@ -71,10 +71,10 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype {
}
}
- if ($options = get_record("quiz_shortanswer", "question", $question->id)) {
+ if ($options = get_record("question_shortanswer", "question", $question->id)) {
$options->answers = implode(",",$answers);
$options->usecase = $question->usecase;
- if (!update_record("quiz_shortanswer", $options)) {
+ if (!update_record("question_shortanswer", $options)) {
$result->error = "Could not update quiz shortanswer options! (id=$options->id)";
return $result;
}
@@ -83,7 +83,7 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype {
$options->question = $question->id;
$options->answers = implode(",",$answers);
$options->usecase = $question->usecase;
- if (!insert_record("quiz_shortanswer", $options)) {
+ if (!insert_record("question_shortanswer", $options)) {
$result->error = "Could not insert quiz shortanswer options!";
return $result;
}
@@ -113,8 +113,8 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype {
* @param object $question The question being deleted
*/
function delete_question($question) {
- delete_records("quiz_shortanswer", "question", $question->id);
- //TODO: delete also the states from quiz_rqp_states
+ delete_records("question_shortanswer", "question", $question->id);
+ //TODO: delete also the states from question_rqp_states
return true;
}
@@ -246,6 +246,6 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype {
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-$QTYPES[SHORTANSWER]= new quiz_shortanswer_qtype();
+$QTYPES[SHORTANSWER]= new question_shortanswer_qtype();
?>
diff --git a/question/questiontypes/truefalse/editquestion.php b/question/questiontypes/truefalse/editquestion.php
index 1bc06c9e09e..ee3ca68b3ad 100644
--- a/question/questiontypes/truefalse/editquestion.php
+++ b/question/questiontypes/truefalse/editquestion.php
@@ -1,7 +1,7 @@
id)) {
- $options = get_record("quiz_truefalse", "question", "$question->id");
+ $options = get_record("question_truefalse", "question", "$question->id");
}
if (!empty($options->trueanswer)) {
$true = get_record("question_answers", "id", $options->trueanswer);
diff --git a/question/questiontypes/truefalse/questiontype.php b/question/questiontypes/truefalse/questiontype.php
index 045c09502fb..461136e7472 100644
--- a/question/questiontypes/truefalse/questiontype.php
+++ b/question/questiontypes/truefalse/questiontype.php
@@ -5,7 +5,7 @@
/////////////////
/// QUESTION TYPE CLASS //////////////////
-class quiz_truefalse_qtype extends quiz_default_questiontype {
+class question_truefalse_qtype extends quiz_default_questiontype {
function name() {
return 'truefalse';
@@ -67,13 +67,13 @@ class quiz_truefalse_qtype extends quiz_default_questiontype {
}
}
- // Save question options in quiz_truefalse table
- if ($options = get_record("quiz_truefalse", "question", $question->id)) {
+ // Save question options in question_truefalse table
+ if ($options = get_record("question_truefalse", "question", $question->id)) {
// No need to do anything, since the answer IDs won't have changed
// But we'll do it anyway, just for robustness
$options->trueanswer = $true->id;
$options->falseanswer = $false->id;
- if (!update_record("quiz_truefalse", $options)) {
+ if (!update_record("question_truefalse", $options)) {
$result->error = "Could not update quiz truefalse options! (id=$options->id)";
return $result;
}
@@ -82,7 +82,7 @@ class quiz_truefalse_qtype extends quiz_default_questiontype {
$options->question = $question->id;
$options->trueanswer = $true->id;
$options->falseanswer = $false->id;
- if (!insert_record("quiz_truefalse", $options)) {
+ if (!insert_record("question_truefalse", $options)) {
$result->error = "Could not insert quiz truefalse options!";
return $result;
}
@@ -96,7 +96,7 @@ class quiz_truefalse_qtype extends quiz_default_questiontype {
function get_question_options(&$question) {
// Get additional information from database
// and attach it to the question object
- if (!$question->options = get_record('quiz_truefalse', 'question', $question->id)) {
+ if (!$question->options = get_record('question_truefalse', 'question', $question->id)) {
notify('Error: Missing question options!');
return false;
}
@@ -116,7 +116,7 @@ class quiz_truefalse_qtype extends quiz_default_questiontype {
* @param object $question The question being deleted
*/
function delete_question($question) {
- delete_records("quiz_truefalse", "question", $question->id);
+ delete_records("question_truefalse", "question", $question->id);
return true;
}
@@ -211,6 +211,6 @@ class quiz_truefalse_qtype extends quiz_default_questiontype {
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-$QTYPES[TRUEFALSE]= new quiz_truefalse_qtype();
+$QTYPES[TRUEFALSE]= new question_truefalse_qtype();
?>