More renamings to separate questions from quiz. Some other small fixes.

This commit is contained in:
gustav_delius 2006-03-12 21:17:42 +00:00
parent 4352f048f5
commit 32a189d636
42 changed files with 730 additions and 625 deletions

View File

@ -596,15 +596,15 @@
}
/**
* Returns the best quiz category (id) found to restore one
* quiz category from a backup file. Works by stamp (since Moodle 1.1)
* Returns the best question category (id) found to restore one
* question category from a backup file. Works by stamp (since Moodle 1.1)
* or by name (for older versions).
*
* @param object $cat the quiz_categories record to be searched
* @param object $cat the question_categories record to be searched
* @param integer $courseid the course where we are restoring
* @return integer the id of a existing quiz_category or 0 (not found)
* @return integer the id of a existing question_category or 0 (not found)
*/
function restore_get_best_quiz_category($cat, $courseid) {
function restore_get_best_question_category($cat, $courseid) {
$found = 0;
@ -618,10 +618,10 @@
}
//First shot. Try to get the category from the course being restored
if ($fcat = get_record('quiz_categories','course',$courseid,$searchfield,$searchvalue)) {
if ($fcat = get_record('question_categories','course',$courseid,$searchfield,$searchvalue)) {
$found = $fcat->id;
//Second shot. Try to obtain any concordant category and check its publish status and editing rights
} else if ($fcats = get_records('quiz_categories', $searchfield, $searchvalue, 'id', 'id, publish, course')) {
} else if ($fcats = get_records('question_categories', $searchfield, $searchvalue, 'id', 'id, publish, course')) {
foreach ($fcats as $fcat) {
if ($fcat->publish == 1 && isteacheredit($fcat->course)) {
$found = $fcat->id;
@ -1820,7 +1820,7 @@
}
//This function creates all the categories and questions
//from xml (STEP1 of quiz restore)
//from xml
function restore_create_questions($restore,$xml_file) {
global $CFG, $db;
@ -1844,7 +1844,7 @@
foreach ($info as $category) {
//Skip empty categories (some backups can contain them)
if (!empty($category->id)) {
$catrestore = "quiz_restore_question_categories";
$catrestore = "restore_question_categories";
if (function_exists($catrestore)) {
//print_object ($category); //Debug
$status = $catrestore($category,$restore);
@ -1859,20 +1859,20 @@
$categories = get_records_sql("SELECT old_id, new_id
FROM {$CFG->prefix}backup_ids
WHERE backup_code = $restore->backup_unique_code AND
table_name = 'quiz_categories'");
table_name = 'question_categories'");
if ($categories) {
foreach ($categories as $category) {
$restoredcategory = get_record('quiz_categories','id',$category->new_id);
$restoredcategory = get_record('question_categories','id',$category->new_id);
if ($restoredcategory->parent != 0) {
//echo 'Parent '.$restoredcategory->parent.' is '; //Debug
$idcat = backup_getid($restore->backup_unique_code,'quiz_categories',$restoredcategory->parent);
$idcat = backup_getid($restore->backup_unique_code,'question_categories',$restoredcategory->parent);
if ($idcat->new_id) {
$restoredcategory->parent = $idcat->new_id;
} else {
$restoredcategory->parent = 0;
}
//echo $restoredcategory->parent.' now<br />'; //Debug
update_record('quiz_categories', $restoredcategory);
update_record('question_categories', $restoredcategory);
}
}
}
@ -4153,7 +4153,7 @@
//Get id from data
$category_id = $data["QUESTION_CATEGORY"]["#"]["ID"]["0"]["#"];
//Save to db
$status = backup_putid($this->preferences->backup_unique_code,"quiz_categories",$category_id,
$status = backup_putid($this->preferences->backup_unique_code,"question_categories",$category_id,
null,$data);
//Create returning info
$ret_info->id = $category_id;
@ -4822,6 +4822,8 @@
}
}
}
// The following will be enabled once the quiz and question restore code are separated
//include_once("$CFG->dirroot/question/restorelib.php");
if (!defined('RESTORE_SILENTLY')) {
//Start the main table

View File

@ -13,43 +13,43 @@
// | | | | |.......................................
// | quiz_grades | quiz_question_versions | .
// | (UL,pk->id,fk->quiz) | (CL,pk->id,fk->quiz) | .
// | | . | ----quiz_question_datasets---- .
// | | . | ----question_datasets---- .
// quiz_attempts quiz_question_instances . | | (CL,pk->id,fk->question, | .
// (UL,pk->id,fk->quiz) (CL,pk->id,fk->quiz,question) . | | fk->dataset_definition) | .
// | | . | | | .
// | question_sessions | . | | | .
// |---------(UL,pk->id,fk->attempt,question)-----| . | | | .
// | . | . | | quiz_dataset_definitions
// | . | . | | question_dataset_definitions
// | . | . | | (CL,pk->id,fk->category)
// | question_states | question |
// ----------(UL,pk->id,fk->attempt,question)--------------------------(CL,pk->id,fk->category,files) |
// | | quiz_dataset_items
// | | question_dataset_items
// | | (CL,pk->id,fk->definition)
// --------- |
// | |
// quiz_rqp_states |
// (UL,pk->id,fk->stateid) | quiz_rqp_type
// question_rqp_states |
// (UL,pk->id,fk->stateid) | question_rqp_type
// | (SL,pk->id)
// | |
// -------------------------------------------------------------------------------------------------------------- |
// | | | | | | | quiz_rqp
// | | | | | | | question_rqp
// | | | | | | |--(CL,pk->id,fk->question)
// | | | | quiz_calculated | |
// quiz_truefalse | quiz_multichoice | (CL,pl->id,fk->question) | |
// (CL,pk->id,fk->question) | (CL,pk->id,fk->question) | . | | quiz_randomsamatch
// | | | | question_calculated | |
// question_truefalse | question_multichoice | (CL,pl->id,fk->question) | |
// (CL,pk->id,fk->question) | (CL,pk->id,fk->question) | . | | question_randomsamatch
// . | . | . | |--(CL,pk->id,fk->question)
// . quiz_shortanswer . quiz_numerical . quiz_multianswer. |
// . question_shortanswer . question_numerical . question_multianswer. |
// . (CL,pk->id,fk->question) . (CL,pk->id,fk->question) . (CL,pk->id,fk->question) |
// . . . . . . | quiz_match
// . . . . . . | question_match
// . . . . . . |--(CL,pk->id,fk->question)
// . . . . . . | .
// . . . . . . | .
// . . . . . . | .
// . . . . . . | quiz_match_sub
// . . . . . . | question_match_sub
// ........................................................................................ |--(CL,pk->id,fk->question)
// . |
// . |
// . | quiz_numerical_units
// . | question_numerical_units
// question_answers |--(CL,pk->id,fk->question)
// (CL,pk->id,fk->question)----------------------------------------------------------
//
@ -70,21 +70,21 @@
// 1.-We backup every category and their questions (complete structure). It includes this tables:
// - question_categories
// - question
// - quiz_rqp
// - quiz_truefalse
// - quiz_shortanswer
// - quiz_multianswer
// - quiz_multichoice
// - quiz_numerical
// - quiz_randomsamatch
// - quiz_match
// - quiz_match_sub
// - quiz_calculated
// - question_rqp
// - question_truefalse
// - question_shortanswer
// - question_multianswer
// - question_multichoice
// - question_numerical
// - question_randomsamatch
// - question_match
// - question_match_sub
// - question_calculated
// - question_answers
// - quiz_numerical_units
// - quiz_question_datasets
// - quiz_dataset_definitions
// - quiz_dataset_items
// - question_numerical_units
// - question_datasets
// - question_dataset_definitions
// - question_dataset_items
// All this backup info have its own section in moodle.xml (QUESTION_CATEGORIES) and it's generated
// before every module backup standard invocation. And only if to backup quizzes has been selected !!
// It's invoked with quiz_backup_question_categories. (course independent).
@ -363,7 +363,7 @@
$status = true;
$truefalses = get_records("quiz_truefalse","question",$question,"id");
$truefalses = get_records("question_truefalse","question",$question,"id");
//If there are truefalses
if ($truefalses) {
//Iterate over each truefalse
@ -388,7 +388,7 @@
$status = true;
$shortanswers = get_records("quiz_shortanswer","question",$question,"id");
$shortanswers = get_records("question_shortanswer","question",$question,"id");
//If there are shortanswers
if ($shortanswers) {
//Iterate over each shortanswer
@ -415,7 +415,7 @@
$status = true;
$multichoices = get_records("quiz_multichoice","question",$question,"id");
$multichoices = get_records("question_multichoice","question",$question,"id");
//If there are multichoices
if ($multichoices) {
//Iterate over each multichoice
@ -444,7 +444,7 @@
$status = true;
$randomsamatchs = get_records("quiz_randomsamatch","question",$question,"id");
$randomsamatchs = get_records("question_randomsamatch","question",$question,"id");
//If there are randomsamatchs
if ($randomsamatchs) {
//Iterate over each randomsamatch
@ -467,7 +467,7 @@
$status = true;
$matchs = get_records("quiz_match_sub","question",$question,"id");
$matchs = get_records("question_match_sub","question",$question,"id");
//If there are matchs
if ($matchs) {
$status = fwrite ($bf,start_tag("MATCHS",6,true));
@ -494,7 +494,7 @@
$status = true;
$numericals = get_records("quiz_numerical","question",$question,"id");
$numericals = get_records("question_numerical","question",$question,"id");
//If there are numericals
if ($numericals) {
//Iterate over each numerical
@ -521,7 +521,7 @@
$status = true;
$multianswers = get_records("quiz_multianswers","question",$question,"id");
$multianswers = get_records("question_multianswer","question",$question,"id");
//If there are multianswers
if ($multianswers) {
//Print multianswers header
@ -551,7 +551,7 @@
$status = true;
$calculateds = get_records("quiz_calculated","question",$question,"id");
$calculateds = get_records("question_calculated","question",$question,"id");
//If there are calculated-s
if ($calculateds) {
//Iterate over each calculateds
@ -586,7 +586,7 @@
$status = true;
$rqp = get_records("quiz_rqp","question",$question,"id");
$rqp = get_records("question_rqp","question",$question,"id");
//If there are rqps
if ($rqps) {
//Iterate over each rqp
@ -612,7 +612,7 @@
$status = true;
$essays = get_records('quiz_essay', 'question', $question, "id");
$essays = get_records('question_essay', 'question', $question, "id");
//If there are essays
if ($essays) {
//Iterate over each essay
@ -656,14 +656,14 @@
return $status;
}
//This function backups quiz_numerical_units from different question types
//This function backups question_numerical_units from different question types
function quiz_backup_numerical_units($bf,$preferences,$question,$level=7) {
global $CFG;
$status = true;
$numerical_units = get_records("quiz_numerical_units","question",$question,"id");
$numerical_units = get_records("question_numerical_units","question",$question,"id");
//If there are numericals_units
if ($numerical_units) {
$status = fwrite ($bf,start_tag("NUMERICAL_UNITS",$level,true));
@ -691,7 +691,7 @@
$status = true;
//First, we get the used datasets for this question
$question_datasets = get_records("quiz_question_datasets","question",$question,"id");
$question_datasets = get_records("question_datasets","question",$question,"id");
//If there are question_datasets
if ($question_datasets) {
$status = $status &&fwrite ($bf,start_tag("DATASET_DEFINITIONS",$level,true));
@ -699,7 +699,7 @@
foreach ($question_datasets as $question_dataset) {
$def = NULL;
//Get dataset_definition
if ($def = get_record("quiz_dataset_definitions","id",$question_dataset->datasetdefinition)) {;
if ($def = get_record("question_dataset_definitions","id",$question_dataset->datasetdefinition)) {;
$status = $status &&fwrite ($bf,start_tag("DATASET_DEFINITION",$level+1,true));
//Print question_dataset contents
fwrite ($bf,full_tag("CATEGORY",$level+2,false,$def->category));
@ -728,7 +728,7 @@
$status = true;
//First, we get the datasets_items for this dataset_definition
$dataset_items = get_records("quiz_dataset_items","definition",$datasetdefinition,"id");
$dataset_items = get_records("question_dataset_items","definition",$datasetdefinition,"id");
//If there are dataset_items
if ($dataset_items) {
$status = $status &&fwrite ($bf,start_tag("DATASET_ITEMS",$level,true));
@ -986,8 +986,8 @@
fwrite ($bf,full_tag("RAW_GRADE",8,false,$state->raw_grade));
fwrite ($bf,full_tag("PENALTY",8,false,$state->penalty));
// now back up question type specific state information
$status = backup_quiz_rqp_state ($bf,$preferences,$state->id);
$status = backup_quiz_essay_state ($bf,$preferences,$state->id);
$status = backup_question_rqp_state ($bf,$preferences,$state->id);
$status = backup_question_essay_state ($bf,$preferences,$state->id);
//End state
$status = fwrite ($bf,end_tag("STATE",7,true));
}
@ -1059,14 +1059,14 @@
return $info;
}
//Backup quiz_rqp_state contents (executed from backup_question_states)
function backup_quiz_rqp_state ($bf,$preferences,$state) {
//Backup question_rqp_state contents (executed from backup_question_states)
function backup_question_rqp_state ($bf,$preferences,$state) {
global $CFG;
$status = true;
$rqp_state = get_record("quiz_rqp_states","stateid",$state);
$rqp_state = get_record("question_rqp_states","stateid",$state);
//If there is a state
if ($rqp_state) {
//Write start tag
@ -1081,14 +1081,14 @@
return $status;
}
//Backup quiz_essay_state contents (executed from backup_question_states)
function backup_quiz_essay_state ($bf,$preferences,$state) {
//Backup question_essay_state contents (executed from backup_question_states)
function backup_question_essay_state ($bf,$preferences,$state) {
global $CFG;
$status = true;
$essay_state = get_record("quiz_essay_states", "stateid", $state);
$essay_state = get_record("question_essay_states", "stateid", $state);
//If there is a state
if ($essay_state) {
//Write start tag

View File

@ -99,7 +99,7 @@ function migrate2utf8_question_questiontext($recordid){
}
function migrate2utf8_quiz_numerical_units_unit($recordid){
function migrate2utf8_question_numerical_units_unit($recordid){
global $CFG, $globallang;
/// Some trivial checks
@ -111,7 +111,7 @@ function migrate2utf8_quiz_numerical_units_unit($recordid){
$SQL = "SELECT qc.course
FROM {$CFG->prefix}question_categories qc,
{$CFG->prefix}question qq,
{$CFG->prefix}quiz_numerical_units qnu
{$CFG->prefix}question_numerical_units qnu
WHERE qc.id = qq.category
AND qq.id = qnu.question
AND qnu.id = $recordid";
@ -121,7 +121,7 @@ function migrate2utf8_quiz_numerical_units_unit($recordid){
return false;
}
if (!$quiznumericalunits = get_record('quiz_numerical_units','id',$recordid)) {
if (!$quiznumericalunits = get_record('question_numerical_units','id',$recordid)) {
log_the_problem_somewhere();
return false;
}
@ -145,13 +145,13 @@ function migrate2utf8_quiz_numerical_units_unit($recordid){
$newquiznumericalunits = new object;
$newquiznumericalunits->id = $recordid;
$newquiznumericalunits->unit = $result;
update_record('quiz_numerical_units',$newquiznumericalunits);
update_record('question_numerical_units',$newquiznumericalunits);
}
/// And finally, just return the converted field
return $result;
}
function migrate2utf8_quiz_match_sub_questiontext($recordid){
function migrate2utf8_question_match_sub_questiontext($recordid){
global $CFG, $globallang;
/// Some trivial checks
@ -163,7 +163,7 @@ function migrate2utf8_quiz_match_sub_questiontext($recordid){
$SQL = "SELECT qc.course
FROM {$CFG->prefix}question_categories qc,
{$CFG->prefix}question qq,
{$CFG->prefix}quiz_match_sub qms
{$CFG->prefix}question_match_sub qms
WHERE qc.id = qq.category
AND qq.id = qms.question
AND qms.id = $recordid";
@ -173,7 +173,7 @@ function migrate2utf8_quiz_match_sub_questiontext($recordid){
return false;
}
if (!$quizmatchsub = get_record('quiz_match_sub','id',$recordid)) {
if (!$quizmatchsub = get_record('question_match_sub','id',$recordid)) {
log_the_problem_somewhere();
return false;
}
@ -197,13 +197,13 @@ function migrate2utf8_quiz_match_sub_questiontext($recordid){
$newquizmatchsub = new object;
$newquizmatchsub->id = $recordid;
$newquizmatchsub->questiontext = $result;
update_record('quiz_match_sub',$newquizmatchsub);
update_record('question_match_sub',$newquizmatchsub);
}
/// And finally, just return the converted field
return $result;
}
function migrate2utf8_quiz_match_sub_answertext($recordid){
function migrate2utf8_question_match_sub_answertext($recordid){
global $CFG, $globallang;
/// Some trivial checks
@ -215,7 +215,7 @@ function migrate2utf8_quiz_match_sub_answertext($recordid){
$SQL = "SELECT qc.course
FROM {$CFG->prefix}question_categories qc,
{$CFG->prefix}question qq,
{$CFG->prefix}quiz_match_sub qms
{$CFG->prefix}question_match_sub qms
WHERE qc.id = qq.category
AND qq.id = qms.question
AND qms.id = $recordid";
@ -225,7 +225,7 @@ function migrate2utf8_quiz_match_sub_answertext($recordid){
return false;
}
if (!$quizmatchsub = get_record('quiz_match_sub','id',$recordid)) {
if (!$quizmatchsub = get_record('question_match_sub','id',$recordid)) {
log_the_problem_somewhere();
return false;
}
@ -249,7 +249,7 @@ function migrate2utf8_quiz_match_sub_answertext($recordid){
$newquizmatchsub = new object;
$newquizmatchsub->id = $recordid;
$newquizmatchsub->answertext = $result;
update_record('quiz_match_sub',$newquizmatchsub);
update_record('question_match_sub',$newquizmatchsub);
}
/// And finally, just return the converted field
return $result;
@ -363,7 +363,7 @@ function migrate2utf8_question_answers_feedback($recordid){
function migrate2utf8_quiz_dataset_definitions_name($recordid){
function migrate2utf8_question_dataset_definitions_name($recordid){
global $CFG, $globallang;
/// Some trivial checks
@ -374,7 +374,7 @@ function migrate2utf8_quiz_dataset_definitions_name($recordid){
$SQL = "SELECT qc.course
FROM {$CFG->prefix}question_categories qc,
{$CFG->prefix}quiz_dataset_definitions qdd
{$CFG->prefix}question_dataset_definitions qdd
WHERE qc.id = qdd.category
AND qdd.id = $recordid";
@ -383,7 +383,7 @@ function migrate2utf8_quiz_dataset_definitions_name($recordid){
return false;
}
if (!$quizdatasetdefinition = get_record('quiz_dataset_definitions','id',$recordid)) {
if (!$quizdatasetdefinition = get_record('question_dataset_definitions','id',$recordid)) {
log_the_problem_somewhere();
return false;
}
@ -407,7 +407,7 @@ function migrate2utf8_quiz_dataset_definitions_name($recordid){
$newquizdatasetdefinition = new object;
$newquizdatasetdefinition->id = $recordid;
$newquizdatasetdefinition->name = $result;
update_record('quiz_dataset_definitions',$newquizdatasetdefinition);
update_record('question_dataset_definitions',$newquizdatasetdefinition);
}
/// And finally, just return the converted field
return $result;

View File

@ -2,70 +2,70 @@
<TABLES>
<TABLE name="quiz_attemptonlast_datasets" />
<TABLE name="quiz_grades" />
<TABLE name="quiz_question_datasets" />
<TABLE name="question_datasets" />
<TABLE name="quiz_question_instances" />
<TABLE name="quiz_question_versions" />
<TABLE name="quiz_randomsamatch" />
<TABLE name="quiz_truefalse" />
<TABLE name="quiz_rqp">
<TABLE name="question_randomsamatch" />
<TABLE name="question_truefalse" />
<TABLE name="question_rqp">
<FIELDS>
<FIELD name="format" method="NO_CONV" type="varchar" length="255" />
</FIELDS>
</TABLE>
<TABLE name="quiz_rqp_servers">
<TABLE name="question_rqp_servers">
<FIELDS>
<FIELD name="url" method="NO_CONV" type="varchar" length="255" />
</FIELDS>
</TABLE>
<TABLE name="quiz_rqp_states">
<TABLE name="question_rqp_states">
<FIELDS>
<FIELD name="responses" method="NO_CONV" type="text" length="0" />
<FIELD name="persistent_data" method="NO_CONV" type="text" length="0" />
<FIELD name="template_vars" method="NO_CONV" type="text" length="0" />
</FIELDS>
</TABLE>
<TABLE name="quiz_rqp_types">
<TABLE name="question_rqp_types">
<FIELDS>
<FIELD name="name" method="NO_CONV" type="varchar" length="255" dropindex="name" adduniqueindex="name (name(255))"/>
</FIELDS>
</TABLE>
<TABLE name="quiz_shortanswer">
<TABLE name="question_shortanswer">
<FIELDS>
<FIELD name="answers" method="NO_CONV" type="varchar" length="255" />
</FIELDS>
</TABLE>
<TABLE name="quiz_numerical">
<TABLE name="question_numerical">
<FIELDS>
<FIELD name="tolerance" method="NO_CONV" type="varchar" length="255" default="0.0" />
</FIELDS>
</TABLE>
<TABLE name="question_sessions" />
<TABLE name="quiz_multichoice">
<TABLE name="question_multichoice">
<FIELDS>
<FIELD name="answers" method="NO_CONV" type="varchar" length="255" />
</FIELDS>
</TABLE>
<TABLE name="quiz_multianswers">
<TABLE name="question_multianswer">
<FIELDS>
<FIELD name="sequence" method="NO_CONV" type="varchar" length="255" />
</FIELDS>
</TABLE>
<TABLE name="quiz_match">
<TABLE name="question_match">
<FIELDS>
<FIELD name="subquestions" method="NO_CONV" type="varchar" length="255" />
</FIELDS>
</TABLE>
<TABLE name="quiz_essay">
<TABLE name="question_essay">
<FIELDS>
<FIELD name="answer" method="NO_CONV" type="varchar" length="255" />
</FIELDS>
</TABLE>
<TABLE name="quiz_dataset_items">
<TABLE name="question_dataset_items">
<FIELDS>
<FIELD name="value" method="NO_CONV" type="varchar" length="255" />
</FIELDS>
</TABLE>
<TABLE name="quiz_calculated">
<TABLE name="question_calculated">
<FIELDS>
<FIELD name="tolerance" method="NO_CONV" type="varchar" length="20" default="0.0" />
</FIELDS>
@ -113,25 +113,25 @@
<FIELD name="stamp" method="NO_CONV" type="varchar" length="255" />
</FIELDS>
</TABLE>
<TABLE name="quiz_numerical_units">
<TABLE name="question_numerical_units">
<FIELDS>
<FIELD name="unit" method="PHP_FUNCTION" type="varchar" length="50">
<PHP_FUNCTION>
migrate2utf8_quiz_numerical_units_unit(RECORDID)
migrate2utf8_question_numerical_units_unit(RECORDID)
</PHP_FUNCTION>
</FIELD>
</FIELDS>
</TABLE>
<TABLE name="quiz_match_sub">
<TABLE name="question_match_sub">
<FIELDS>
<FIELD name="questiontext" method="PHP_FUNCTION" type="text" length="0">
<PHP_FUNCTION>
migrate2utf8_quiz_match_sub_questionext(RECORDID)
migrate2utf8_question_match_sub_questionext(RECORDID)
</PHP_FUNCTION>
</FIELD>
<FIELD name="answertext" method="PHP_FUNCTION" type="varchar" length="255">
<PHP_FUNCTION>
migrate2utf8_quiz_match_sub_answertext(RECORDID)
migrate2utf8_question_match_sub_answertext(RECORDID)
</PHP_FUNCTION>
</FIELD>
</FIELDS>
@ -150,24 +150,24 @@
</FIELD>
</FIELDS>
</TABLE>
<TABLE name="quiz_dataset_definitions">
<TABLE name="question_dataset_definitions">
<FIELDS>
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
<PHP_FUNCTION>
migrate2utf8_quiz_dataset_definitions_name(RECORDID)
migrate2utf8_question_dataset_definitions_name(RECORDID)
</PHP_FUNCTION>
</FIELD>
<FIELD name="options" method="NO_CONV" type="varchar" length="255" />
</FIELDS>
</TABLE>
<TABLE name="quiz_essay_states">
<TABLE name="question_essay_states">
<FIELDS>
<FIELD name="response" method="PLAIN_SQL_UPDATE" type="text" length="0">
<SQL_DETECT_USER>
SELECT qa.userid
FROM {$CFG->prefix}question_states qs,
{$CFG->prefix}quiz_attempts qa,
{$CFG->prefix}quiz_essay_states qes
{$CFG->prefix}question_essay_states qes
WHERE qa.id = qs.attempt
AND qs.id = qes.stateid
AND qes.id = RECORDID
@ -177,7 +177,7 @@
FROM {$CFG->prefix}quiz q,
{$CFG->prefix}quiz_attempts qa,
{$CFG->prefix}question_states qs,
{$CFG->prefix}quiz_essay_states qes
{$CFG->prefix}question_essay_states qes
WHERE q.id = qa.quiz
AND qa.id = qs.attempt
AND qs.id = qes.stateid

View File

@ -506,7 +506,7 @@ function quiz_upgrade($oldversion) {
modify_database('', 'ALTER TABLE `prefix_quiz_numerical` DROP `max`'); // Replaced by tolerance
/// Tables for Remote Questions
modify_database ('', "CREATE TABLE `prefix_quiz_rqp` (
modify_database ('', "CREATE TABLE `prefix_question_rqp` (
`id` int(10) unsigned NOT NULL auto_increment,
`question` int(10) unsigned NOT NULL default '0',
`type` int(10) unsigned NOT NULL default '0',
@ -518,7 +518,7 @@ function quiz_upgrade($oldversion) {
KEY `question` (`question`)
) TYPE=MyISAM COMMENT='Options for RQP questions';");
modify_database ('', "CREATE TABLE `prefix_quiz_rqp_type` (
modify_database ('', "CREATE TABLE `prefix_question_rqp_type` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL default '',
`rendering_server` varchar(255) NOT NULL default '',
@ -528,7 +528,7 @@ function quiz_upgrade($oldversion) {
UNIQUE KEY `name` (`name`)
) TYPE=MyISAM COMMENT='RQP question types and the servers to be used to process them';");
modify_database ('', "CREATE TABLE `prefix_quiz_rqp_states` (
modify_database ('', "CREATE TABLE `prefix_question_rqp_states` (
`id` int(10) unsigned NOT NULL auto_increment,
`stateid` int(10) unsigned NOT NULL default '0',
`responses` text NOT NULL default '',
@ -551,8 +551,8 @@ function quiz_upgrade($oldversion) {
}
if ($oldversion < 2005051400) {
modify_database('', 'ALTER TABLE prefix_quiz_rqp_type RENAME prefix_quiz_rqp_types;');
modify_database('', "CREATE TABLE `prefix_quiz_rqp_servers` (
modify_database('', 'ALTER TABLE prefix_question_rqp_type RENAME prefix_question_rqp_types;');
modify_database('', "CREATE TABLE `prefix_question_rqp_servers` (
id int(10) unsigned NOT NULL auto_increment,
typeid int(10) unsigned NOT NULL default '0',
url varchar(255) NOT NULL default '',
@ -560,17 +560,17 @@ function quiz_upgrade($oldversion) {
can_author tinyint(2) unsigned NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM COMMENT='Information about RQP servers';");
if ($types = get_records('quiz_rqp_types')) {
if ($types = get_records('question_rqp_types')) {
foreach($types as $type) {
$server->typeid = $type->id;
$server->url = $type->rendering_server;
$server->can_render = 1;
insert_record('quiz_rqp_servers', $server);
insert_record('question_rqp_servers', $server);
}
}
modify_database('', 'ALTER TABLE prefix_quiz_rqp_types DROP rendering_server');
modify_database('', 'ALTER TABLE prefix_quiz_rqp_types DROP cloning_server');
modify_database('', 'ALTER TABLE prefix_quiz_rqp_types DROP flags');
modify_database('', 'ALTER TABLE prefix_question_rqp_types DROP rendering_server');
modify_database('', 'ALTER TABLE prefix_question_rqp_types DROP cloning_server');
modify_database('', 'ALTER TABLE prefix_question_rqp_types DROP flags');
}
if ($oldversion < 2005051401) {
@ -950,6 +950,28 @@ function quiz_upgrade($oldversion) {
execute_sql("ALTER TABLE {$CFG->prefix}quiz_categories RENAME {$CFG->prefix}question_categories", false);
}
if ($oldversion < 2006031202) {
execute_sql("ALTER TABLE {$CFG->prefix}quiz_truefalse RENAME {$CFG->prefix}question_truefalse", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_shortanswer RENAME {$CFG->prefix}question_shortanswer", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_multianswers RENAME {$CFG->prefix}question_multianswer", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_multichoice RENAME {$CFG->prefix}question_multichoice", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_numerical RENAME {$CFG->prefix}question_numerical", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_numerical_units RENAME {$CFG->prefix}question_numerical_units", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_randomsamatch RENAME {$CFG->prefix}question_randomsamatch", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_match RENAME {$CFG->prefix}question_match", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_match_sub RENAME {$CFG->prefix}question_match_sub", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_calculated RENAME {$CFG->prefix}question_calculated", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_dataset_definitions RENAME {$CFG->prefix}question_dataset_definitions", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_dataset_items RENAME {$CFG->prefix}question_dataset_items", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_question_datasets RENAME {$CFG->prefix}question_datasets", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp RENAME {$CFG->prefix}question_rqp", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp_servers RENAME {$CFG->prefix}question_rqp_servers", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp_states RENAME {$CFG->prefix}question_rqp_states", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp_types RENAME {$CFG->prefix}question_rqp_types", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_essay RENAME {$CFG->prefix}question_essay", false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_essay_states RENAME {$CFG->prefix}question_essay_states", false);
}
return true;
}

View File

@ -106,10 +106,10 @@ CREATE TABLE prefix_quiz_attempts (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_calculated`
-- Table structure for table `prefix_question_calculated`
--
CREATE TABLE prefix_quiz_calculated (
CREATE TABLE prefix_question_calculated (
id int(10) unsigned NOT NULL auto_increment,
question int(10) unsigned NOT NULL default '0',
answer int(10) unsigned NOT NULL default '0',
@ -144,10 +144,10 @@ CREATE TABLE prefix_question_categories (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_dataset_definitions`
-- Table structure for table `prefix_question_dataset_definitions`
--
CREATE TABLE prefix_quiz_dataset_definitions (
CREATE TABLE prefix_question_dataset_definitions (
id int(10) unsigned NOT NULL auto_increment,
category int(10) unsigned NOT NULL default '0',
name varchar(255) NOT NULL default '',
@ -161,10 +161,10 @@ CREATE TABLE prefix_quiz_dataset_definitions (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_dataset_items`
-- Table structure for table `prefix_question_dataset_items`
--
CREATE TABLE prefix_quiz_dataset_items (
CREATE TABLE prefix_question_dataset_items (
id int(10) unsigned NOT NULL auto_increment,
definition int(10) unsigned NOT NULL default '0',
number int(10) unsigned NOT NULL default '0',
@ -176,10 +176,10 @@ CREATE TABLE prefix_quiz_dataset_items (
-- --------------------------------------------------------
--
-- Table structure for table `mdl_quiz_essay`
-- Table structure for table `mdl_question_essay`
--
CREATE TABLE `prefix_quiz_essay` (
CREATE TABLE `prefix_question_essay` (
`id` int(10) unsigned NOT NULL auto_increment,
`question` int(10) unsigned NOT NULL default '0',
`answer` varchar(255) NOT NULL default '',
@ -190,10 +190,10 @@ CREATE TABLE `prefix_quiz_essay` (
-- --------------------------------------------------------
--
-- Table structure for table `mdl_quiz_essay_states`
-- Table structure for table `mdl_question_essay_states`
--
CREATE TABLE `prefix_quiz_essay_states` (
CREATE TABLE `prefix_question_essay_states` (
`id` int(10) unsigned NOT NULL auto_increment,
`stateid` int(10) unsigned NOT NULL default '0',
`graded` tinyint(4) unsigned NOT NULL default '0',
@ -222,10 +222,10 @@ CREATE TABLE prefix_quiz_grades (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_match`
-- Table structure for table `prefix_question_match`
--
CREATE TABLE prefix_quiz_match (
CREATE TABLE prefix_question_match (
id int(10) unsigned NOT NULL auto_increment,
question int(10) unsigned NOT NULL default '0',
subquestions varchar(255) NOT NULL default '',
@ -237,10 +237,10 @@ CREATE TABLE prefix_quiz_match (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_match_sub`
-- Table structure for table `prefix_question_match_sub`
--
CREATE TABLE prefix_quiz_match_sub (
CREATE TABLE prefix_question_match_sub (
id int(10) unsigned NOT NULL auto_increment,
code int(10) unsigned NOT NULL default '0',
question int(10) unsigned NOT NULL default '0',
@ -253,10 +253,10 @@ CREATE TABLE prefix_quiz_match_sub (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_multianswers`
-- Table structure for table `prefix_question_multianswer`
--
CREATE TABLE prefix_quiz_multianswers (
CREATE TABLE prefix_question_multianswer (
id int(10) unsigned NOT NULL auto_increment,
question int(10) unsigned NOT NULL default '0',
sequence text NOT NULL default '',
@ -267,10 +267,10 @@ CREATE TABLE prefix_quiz_multianswers (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_multichoice`
-- Table structure for table `prefix_question_multichoice`
--
CREATE TABLE prefix_quiz_multichoice (
CREATE TABLE prefix_question_multichoice (
id int(10) unsigned NOT NULL auto_increment,
question int(10) unsigned NOT NULL default '0',
layout tinyint(4) NOT NULL default '0',
@ -301,10 +301,10 @@ CREATE TABLE prefix_question_sessions (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_numerical`
-- Table structure for table `prefix_question_numerical`
--
CREATE TABLE prefix_quiz_numerical (
CREATE TABLE prefix_question_numerical (
id int(10) unsigned NOT NULL auto_increment,
question int(10) unsigned NOT NULL default '0',
answer int(10) unsigned NOT NULL default '0',
@ -317,10 +317,10 @@ CREATE TABLE prefix_quiz_numerical (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_numerical_units`
-- Table structure for table `prefix_question_numerical_units`
--
CREATE TABLE prefix_quiz_numerical_units (
CREATE TABLE prefix_question_numerical_units (
id int(10) unsigned NOT NULL auto_increment,
question int(10) unsigned NOT NULL default '0',
multiplier decimal(40,20) NOT NULL default '1.00000000000000000000',
@ -332,10 +332,10 @@ CREATE TABLE prefix_quiz_numerical_units (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_question_datasets`
-- Table structure for table `prefix_question_datasets`
--
CREATE TABLE prefix_quiz_question_datasets (
CREATE TABLE prefix_question_datasets (
id int(10) unsigned NOT NULL auto_increment,
question int(10) unsigned NOT NULL default '0',
datasetdefinition int(10) unsigned NOT NULL default '0',
@ -404,10 +404,10 @@ CREATE TABLE prefix_question (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_randomsamatch`
-- Table structure for table `prefix_question_randomsamatch`
--
CREATE TABLE prefix_quiz_randomsamatch (
CREATE TABLE prefix_question_randomsamatch (
id int(10) unsigned NOT NULL auto_increment,
question int(10) unsigned NOT NULL default '0',
choose int(10) unsigned NOT NULL default '4',
@ -419,10 +419,10 @@ CREATE TABLE prefix_quiz_randomsamatch (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_rqp`
-- Table structure for table `prefix_question_rqp`
--
CREATE TABLE prefix_quiz_rqp (
CREATE TABLE prefix_question_rqp (
id int(10) unsigned NOT NULL auto_increment,
question int(10) unsigned NOT NULL default '0',
type int(10) unsigned NOT NULL default '0',
@ -437,10 +437,10 @@ CREATE TABLE prefix_quiz_rqp (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_rqp_servers`
-- Table structure for table `prefix_question_rqp_servers`
--
CREATE TABLE prefix_quiz_rqp_servers (
CREATE TABLE prefix_question_rqp_servers (
id int(10) unsigned NOT NULL auto_increment,
typeid int(10) unsigned NOT NULL default '0',
url varchar(255) NOT NULL default '',
@ -452,10 +452,10 @@ CREATE TABLE prefix_quiz_rqp_servers (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_rqp_states`
-- Table structure for table `prefix_question_rqp_states`
--
CREATE TABLE prefix_quiz_rqp_states (
CREATE TABLE prefix_question_rqp_states (
id int(10) unsigned NOT NULL auto_increment,
stateid int(10) unsigned NOT NULL default '0',
responses text NOT NULL default '',
@ -467,10 +467,10 @@ CREATE TABLE prefix_quiz_rqp_states (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_rqp_types`
-- Table structure for table `prefix_question_rqp_types`
--
CREATE TABLE prefix_quiz_rqp_types (
CREATE TABLE prefix_question_rqp_types (
id int(10) unsigned NOT NULL auto_increment,
name varchar(255) NOT NULL default '',
PRIMARY KEY (id),
@ -480,10 +480,10 @@ CREATE TABLE prefix_quiz_rqp_types (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_shortanswer`
-- Table structure for table `prefix_question_shortanswer`
--
CREATE TABLE prefix_quiz_shortanswer (
CREATE TABLE prefix_question_shortanswer (
id int(10) unsigned NOT NULL auto_increment,
question int(10) unsigned NOT NULL default '0',
answers varchar(255) NOT NULL default '',
@ -518,10 +518,10 @@ CREATE TABLE prefix_question_states (
-- --------------------------------------------------------
--
-- Table structure for table `prefix_quiz_truefalse`
-- Table structure for table `prefix_question_truefalse`
--
CREATE TABLE prefix_quiz_truefalse (
CREATE TABLE prefix_question_truefalse (
id int(10) unsigned NOT NULL auto_increment,
question int(10) unsigned NOT NULL default '0',
trueanswer int(10) unsigned NOT NULL default '0',

View File

@ -1062,6 +1062,85 @@ function quiz_upgrade($oldversion) {
execute_sql('ALTER TABLE '.$CFG->prefix.'question_categories ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_categories_id_seq\')',false);
}
if ($oldversion < 2006031202) {
execute_sql("ALTER TABLE {$CFG->prefix}quiz_truefalse RENAME TO {$CFG->prefix}question_truefalse", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_truefalse_id_seq RENAME TO '.$CFG->prefix.'question_truefalse_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_truefalse ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_truefalse_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_shortanswer RENAME TO {$CFG->prefix}question_shortanswer", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_shortanswer_id_seq RENAME TO '.$CFG->prefix.'question_shortanswer_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_shortanswer ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_shortanswer_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_multianswers RENAME TO {$CFG->prefix}question_multianswer", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_multianswers_id_seq RENAME TO '.$CFG->prefix.'question_multianswer_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_multianswer ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_multianswer_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_multichoice RENAME TO {$CFG->prefix}question_multichoice", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_multichoice_id_seq RENAME TO '.$CFG->prefix.'question_multichoice_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_multichoice ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_multichoice_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_numerical RENAME TO {$CFG->prefix}question_numerical", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_numerical_id_seq RENAME TO '.$CFG->prefix.'question_numerical_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_numerical ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_numerical_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_numerical_units RENAME TO {$CFG->prefix}question_numerical_units", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_numerical_units_id_seq RENAME TO '.$CFG->prefix.'question_numerical_units_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_numerical_units ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_numerical_units_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_randomsamatch RENAME TO {$CFG->prefix}question_randomsamatch", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_randomsamatch_id_seq RENAME TO '.$CFG->prefix.'question_randomsamatch_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_randomsamatch ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_randomsamatch_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_match RENAME TO {$CFG->prefix}question_match", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_match_id_seq RENAME TO '.$CFG->prefix.'question_match_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_match ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_match_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_match_sub RENAME TO {$CFG->prefix}question_match_sub", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_match_sub_id_seq RENAME TO '.$CFG->prefix.'question_match_sub_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_match_sub ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_match_sub_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_calculated RENAME TO {$CFG->prefix}question_calculated", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_calculated_id_seq RENAME TO '.$CFG->prefix.'question_calculated_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_calculated ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_calculated_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_dataset_definitions RENAME TO {$CFG->prefix}question_dataset_definitions", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_dataset_definitions_id_seq RENAME TO '.$CFG->prefix.'question_dataset_definitions_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_dataset_definitions ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_dataset_definitions_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_dataset_items RENAME TO {$CFG->prefix}question_dataset_items", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_dataset_items_id_seq RENAME TO '.$CFG->prefix.'question_dataset_items_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_dataset_items ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_dataset_items_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_question_datasets RENAME TO {$CFG->prefix}question_datasets", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_question_datasets_id_seq RENAME TO '.$CFG->prefix.'question_datasets_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_datasets ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_datasets_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp RENAME TO {$CFG->prefix}question_rqp", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_rqp_id_seq RENAME TO '.$CFG->prefix.'question_rqp_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_rqp ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_rqp_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp_servers RENAME TO {$CFG->prefix}question_rqp_servers", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_rqp_servers_id_seq RENAME TO '.$CFG->prefix.'question_rqp_servers_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_rqp_servers ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_rqp_servers_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp_states RENAME TO {$CFG->prefix}question_rqp_states", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_rqp_states_id_seq RENAME TO '.$CFG->prefix.'question_rqp_states_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_rqp_states ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_rqp_states_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp_types RENAME TO {$CFG->prefix}question_rqp_types", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_rqp_types_id_seq RENAME TO '.$CFG->prefix.'question_rqp_types_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_rqp_types ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_rqp_types_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_essay RENAME TO {$CFG->prefix}question_essay", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_essay_id_seq RENAME TO '.$CFG->prefix.'question_essay_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_essay ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_essay_id_seq\')',false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_essay_states RENAME TO {$CFG->prefix}question_essay_states", false);
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_essay_states_id_seq RENAME TO '.$CFG->prefix.'question_essay_states_id_seq',false);
execute_sql('ALTER TABLE '.$CFG->prefix.'question_essay_states ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_essay_states_id_seq\')',false);
}
return true;
}

View File

@ -101,10 +101,10 @@ CREATE UNIQUE INDEX prefix_quiz_attempts_uniqueid_uk ON prefix_quiz_attempts (un
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_calculated
# Table structure for table prefix_question_calculated
#
CREATE TABLE prefix_quiz_calculated (
CREATE TABLE prefix_question_calculated (
id SERIAL8 PRIMARY KEY,
question INT8 NOT NULL default '0',
answer INT8 NOT NULL default '0',
@ -114,8 +114,8 @@ CREATE TABLE prefix_quiz_calculated (
correctanswerformat INT8 NOT NULL default '2'
);
CREATE INDEX prefix_quiz_calculated_question_idx ON prefix_quiz_calculated (question);
CREATE INDEX prefix_quiz_calculated_answer_idx ON prefix_quiz_calculated (answer);
CREATE INDEX prefix_question_calculated_question_idx ON prefix_question_calculated (question);
CREATE INDEX prefix_question_calculated_answer_idx ON prefix_question_calculated (answer);
# --------------------------------------------------------
@ -139,11 +139,11 @@ CREATE INDEX prefix_question_categories_course_idx ON prefix_question_categories
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_dataset_definitions
# Table structure for table prefix_question_dataset_definitions
#
CREATE TABLE prefix_quiz_dataset_definitions (
CREATE TABLE prefix_question_dataset_definitions (
id SERIAL8 PRIMARY KEY,
category INT8 NOT NULL default '0',
name varchar(255) NOT NULL default '',
@ -152,29 +152,29 @@ CREATE TABLE prefix_quiz_dataset_definitions (
itemcount INT8 NOT NULL default '0'
);
CREATE INDEX prefix_quiz_dataset_definitions_category_idx ON prefix_quiz_dataset_definitions (category);
CREATE INDEX prefix_question_dataset_definitions_category_idx ON prefix_question_dataset_definitions (category);
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_dataset_items
# Table structure for table prefix_question_dataset_items
#
CREATE TABLE prefix_quiz_dataset_items (
CREATE TABLE prefix_question_dataset_items (
id SERIAL8 PRIMARY KEY,
definition INT8 NOT NULL default '0',
number INT8 NOT NULL default '0',
value varchar(255) NOT NULL default ''
);
CREATE INDEX prefix_quiz_dataset_items_definition_idx ON prefix_quiz_dataset_items (definition);
CREATE INDEX prefix_question_dataset_items_definition_idx ON prefix_question_dataset_items (definition);
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_essay
# Table structure for table prefix_question_essay
#
CREATE TABLE mdl_quiz_essay (
CREATE TABLE mdl_question_essay (
id serial NOT NULL,
question integer NOT NULL DEFAULT 0,
answer varchar(255) NOT NULL DEFAULT ''
@ -184,10 +184,10 @@ CREATE TABLE mdl_quiz_essay (
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_essay_states
# Table structure for table prefix_question_essay_states
#
CREATE TABLE mdl_quiz_essay_states (
CREATE TABLE mdl_question_essay_states (
id serial NOT NULL,
stateid integer NOT NULL DEFAULT 0,
graded integer NOT NULL DEFAULT 0,
@ -214,54 +214,54 @@ CREATE INDEX prefix_quiz_grades_userid_idx ON prefix_quiz_grades (userid);
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_match
# Table structure for table prefix_question_match
#
CREATE TABLE prefix_quiz_match (
CREATE TABLE prefix_question_match (
id SERIAL PRIMARY KEY,
question integer NOT NULL default '0',
subquestions varchar(255) NOT NULL default '',
shuffleanswers integer NOT NULL default '1'
);
CREATE INDEX prefix_quiz_match_question_idx ON prefix_quiz_match (question);
CREATE INDEX prefix_question_match_question_idx ON prefix_question_match (question);
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_match_sub
# Table structure for table prefix_question_match_sub
#
CREATE TABLE prefix_quiz_match_sub (
CREATE TABLE prefix_question_match_sub (
id SERIAL PRIMARY KEY,
code integer NOT NULL default '0',
question integer NOT NULL default '0',
questiontext text NOT NULL default '',
answertext varchar(255) NOT NULL default ''
);
CREATE INDEX prefix_quiz_match_sub_question_idx ON prefix_quiz_match_sub (question);
CREATE INDEX prefix_question_match_sub_question_idx ON prefix_question_match_sub (question);
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_multianswers
# Table structure for table prefix_question_multianswer
#
CREATE TABLE prefix_quiz_multianswers (
CREATE TABLE prefix_question_multianswer (
id SERIAL PRIMARY KEY,
question integer NOT NULL default '0',
sequence text NOT NULL default ''
);
CREATE INDEX prefix_quiz_multianswers_question_idx ON prefix_quiz_multianswers (question);
CREATE INDEX prefix_question_multianswer_question_idx ON prefix_question_multianswer (question);
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_multichoice
# Table structure for table prefix_question_multichoice
#
CREATE TABLE prefix_quiz_multichoice (
CREATE TABLE prefix_question_multichoice (
id SERIAL PRIMARY KEY,
question integer NOT NULL default '0',
layout integer NOT NULL default '0',
@ -270,7 +270,7 @@ CREATE TABLE prefix_quiz_multichoice (
shuffleanswers integer NOT NULL default '1'
);
CREATE INDEX prefix_quiz_multichoice_question_idx ON prefix_quiz_multichoice (question);
CREATE INDEX prefix_question_multichoice_question_idx ON prefix_question_multichoice (question);
# --------------------------------------------------------
@ -294,45 +294,45 @@ CREATE UNIQUE INDEX prefix_question_sessions_attempt_idx ON prefix_question_sess
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_numerical
# Table structure for table prefix_question_numerical
#
CREATE TABLE prefix_quiz_numerical (
CREATE TABLE prefix_question_numerical (
id SERIAL PRIMARY KEY,
question integer NOT NULL default '0',
answer integer NOT NULL default '0',
tolerance varchar(255) NOT NULL default '0.0'
);
CREATE INDEX prefix_quiz_numerical_answer_idx ON prefix_quiz_numerical (answer);
CREATE INDEX prefix_quiz_numerical_question_idx ON prefix_quiz_numerical (question);
CREATE INDEX prefix_question_numerical_answer_idx ON prefix_question_numerical (answer);
CREATE INDEX prefix_question_numerical_question_idx ON prefix_question_numerical (question);
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_numerical_units
# Table structure for table prefix_question_numerical_units
#
CREATE TABLE prefix_quiz_numerical_units (
CREATE TABLE prefix_question_numerical_units (
id SERIAL8 PRIMARY KEY,
question INT8 NOT NULL default '0',
multiplier decimal(40,20) NOT NULL default '1.00000000000000000000',
unit varchar(50) NOT NULL default ''
);
CREATE INDEX prefix_quiz_numerical_units_question_idx ON prefix_quiz_numerical_units (question);
CREATE INDEX prefix_question_numerical_units_question_idx ON prefix_question_numerical_units (question);
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_question_datasets
# Table structure for table prefix_question_datasets
#
CREATE TABLE prefix_quiz_question_datasets (
CREATE TABLE prefix_question_datasets (
id SERIAL8 PRIMARY KEY,
question INT8 NOT NULL default '0',
datasetdefinition INT8 NOT NULL default '0'
);
CREATE INDEX prefix_quiz_question_datasets_question_datasetdefinition_idx ON prefix_quiz_question_datasets (question,datasetdefinition);
CREATE INDEX prefix_question_datasets_question_datasetdefinition_idx ON prefix_question_datasets (question,datasetdefinition);
# --------------------------------------------------------
@ -394,25 +394,25 @@ CREATE INDEX prefix_question_category_idx ON prefix_question (category);
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_randomsamatch
# Table structure for table prefix_question_randomsamatch
#
CREATE TABLE prefix_quiz_randomsamatch (
CREATE TABLE prefix_question_randomsamatch (
id SERIAL PRIMARY KEY,
question integer NOT NULL default '0',
choose integer NOT NULL default '4',
shuffleanswers integer NOT NULL default '1'
);
CREATE INDEX prefix_quiz_randomsamatch_question_idx ON prefix_quiz_randomsamatch (question);
CREATE INDEX prefix_question_randomsamatch_question_idx ON prefix_question_randomsamatch (question);
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_rqp
# Table structure for table prefix_question_rqp
#
CREATE TABLE prefix_quiz_rqp (
CREATE TABLE prefix_question_rqp (
id SERIAL PRIMARY KEY,
question integer NOT NULL default '0',
type integer NOT NULL default '0',
@ -422,16 +422,16 @@ CREATE TABLE prefix_quiz_rqp (
maxscore integer NOT NULL default '1'
);
CREATE INDEX prefix_quiz_rqp_question_idx ON prefix_quiz_rqp (question);
CREATE INDEX prefix_question_rqp_question_idx ON prefix_question_rqp (question);
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_rqp_states
# Table structure for table prefix_question_rqp_states
#
CREATE TABLE prefix_quiz_rqp_states (
CREATE TABLE prefix_question_rqp_states (
id SERIAL PRIMARY KEY,
stateid integer NOT NULL default '0',
responses text NOT NULL,
@ -442,10 +442,10 @@ CREATE TABLE prefix_quiz_rqp_states (
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_rqp_type
# Table structure for table prefix_question_rqp_type
#
CREATE TABLE prefix_quiz_rqp_types (
CREATE TABLE prefix_question_rqp_types (
id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL default '',
rendering_server varchar(255) NOT NULL default '',
@ -453,22 +453,22 @@ CREATE TABLE prefix_quiz_rqp_types (
flags integer NOT NULL default '0'
);
CREATE UNIQUE INDEX prefix_quiz_rqp_types_name_uk ON prefix_quiz_rqp_types (name);
CREATE UNIQUE INDEX prefix_question_rqp_types_name_uk ON prefix_question_rqp_types (name);
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_shortanswer
# Table structure for table prefix_question_shortanswer
#
CREATE TABLE prefix_quiz_shortanswer (
CREATE TABLE prefix_question_shortanswer (
id SERIAL PRIMARY KEY,
question integer NOT NULL default '0',
answers varchar(255) NOT NULL default '',
usecase integer NOT NULL default '0'
);
CREATE INDEX prefix_quiz_shortanswer_question_idx ON prefix_quiz_shortanswer (question);
CREATE INDEX prefix_question_shortanswer_question_idx ON prefix_question_shortanswer (question);
# --------------------------------------------------------
@ -497,16 +497,16 @@ CREATE INDEX prefix_question_states_question_idx ON prefix_question_states (ques
# --------------------------------------------------------
#
# Table structure for table prefix_quiz_truefalse
# Table structure for table prefix_question_truefalse
#
CREATE TABLE prefix_quiz_truefalse (
CREATE TABLE prefix_question_truefalse (
id SERIAL PRIMARY KEY,
question integer NOT NULL default '0',
trueanswer integer NOT NULL default '0',
falseanswer integer NOT NULL default '0'
);
CREATE INDEX prefix_quiz_truefalse_question_idx ON prefix_quiz_truefalse (question);
CREATE INDEX prefix_question_truefalse_question_idx ON prefix_question_truefalse (question);
INSERT INTO prefix_log_display VALUES ('quiz', 'add', 'quiz', 'name');

View File

@ -115,6 +115,8 @@ if (self.name == 'editquestion') {
$modform->grades = quiz_get_all_question_grades($modform);
}
$SESSION->returnurl = $FULLME;
/// Now, check for commands on this page and modify variables as necessary
if (isset($_REQUEST['up']) and confirm_sesskey()) { /// Move the given question up a slot

View File

@ -279,7 +279,7 @@
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) {
@ -369,7 +369,7 @@
error("Can not find newest states for attempt $attempt->uniqueid for question $questionid");
}
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');
}
// change the color of the link based on being graded or not

View File

@ -21,43 +21,43 @@
// | | | | |.......................................
// | quiz_grades | quiz_question_versions | .
// | (UL,pk->id,fk->quiz) | (CL,pk->id,fk->quiz) | .
// | | . | ----quiz_question_datasets---- .
// | | . | ------question_datasets------- .
// quiz_attempts quiz_question_instances . | | (CL,pk->id,fk->question, | .
// (UL,pk->id,fk->quiz) (CL,pk->id,fk->quiz,question) . | | fk->dataset_definition) | .
// | | . | | | .
// | question_sessions | . | | | .
// |---------(UL,pk->id,fk->attempt,question)-----| . | | | .
// | . | . | | quiz_dataset_definitions
// | . | . | | question_dataset_definitions
// | . | . | | (CL,pk->id,fk->category)
// | question_states | question |
// ----------(UL,pk->id,fk->attempt,question)--------------------------(CL,pk->id,fk->category,files) |
// | | quiz_dataset_items
// | | question_dataset_items
// | | (CL,pk->id,fk->definition)
// --------- |
// | |
// quiz_rqp_states |
// (UL,pk->id,fk->stateid) | quiz_rqp_type
// question_rqp_states |
// (UL,pk->id,fk->stateid) | question_rqp_type
// | (SL,pk->id)
// | |
// -------------------------------------------------------------------------------------------------------------- |
// | | | | | | | quiz_rqp
// | | | | | | | question_rqp
// | | | | | | |--(CL,pk->id,fk->question)
// | | | | quiz_calculated | |
// quiz_truefalse | quiz_multichoice | (CL,pl->id,fk->question) | |
// (CL,pk->id,fk->question) | (CL,pk->id,fk->question) | . | | quiz_randomsamatch
// | | | | question_calculated | |
// question_truefalse | question_multichoice | (CL,pl->id,fk->question) | |
// (CL,pk->id,fk->question) | (CL,pk->id,fk->question) | . | | question_randomsamatch
// . | . | . | |--(CL,pk->id,fk->question)
// . quiz_shortanswer . quiz_numerical . quiz_multianswer. |
// . question_shortanswer . question_numerical . question_multianswer. |
// . (CL,pk->id,fk->question) . (CL,pk->id,fk->question) . (CL,pk->id,fk->question) |
// . . . . . . | quiz_match
// . . . . . . | question_match
// . . . . . . |--(CL,pk->id,fk->question)
// . . . . . . | .
// . . . . . . | .
// . . . . . . | .
// . . . . . . | quiz_match_sub
// . . . . . . | question_match_sub
// ........................................................................................ |--(CL,pk->id,fk->question)
// . |
// . |
// . | quiz_numerical_units
// . | question_numerical_units
// question_answers |--(CL,pk->id,fk->question)
// (CL,pk->id,fk->question)----------------------------------------------------------
//
@ -76,23 +76,23 @@
// 1.-We restore every category and their questions (complete structure). It includes this tables:
// - question_categories
// - question
// - quiz_truefalse
// - quiz_shortanswer
// - quiz_multianswer
// - quiz_multichoice
// - quiz_numerical
// - quiz_randomsamatch
// - quiz_match
// - quiz_match_sub
// - quiz_calculated
// - question_truefalse
// - question_shortanswer
// - question_multianswer
// - question_multichoice
// - question_numerical
// - question_randomsamatch
// - question_match
// - question_match_sub
// - question_calculated
// - question_answers
// - quiz_numerical_units
// - quiz_question_datasets
// - quiz_dataset_definitions
// - quiz_dataset_items
// - question_numerical_units
// - question_datasets
// - question_dataset_definitions
// - question_dataset_items
// All this backup info has its own section in moodle.xml (QUESTION_CATEGORIES) and it's generated
// before every module backup standard invocation. And only if to restore quizzes has been selected !!
// It's invoked with quiz_restore_question_categories. (course independent).
// It's invoked with restore_question_categories. (course independent).
// 2.-Standard module restore (Invoked via quiz_restore_mods). It includes thes tables:
// - quiz
@ -104,7 +104,7 @@
// This step is the standard mod backup. (course dependent).
//STEP 1. Restore categories/questions and associated structures (course independent)
function quiz_restore_question_categories($category,$restore) {
function restore_question_categories($category,$restore) {
global $CFG;
@ -127,32 +127,32 @@
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the question_categories record structure
$quiz_cat->course = $restore->course_id;
$quiz_cat->name = backup_todb($info['QUESTION_CATEGORY']['#']['NAME']['0']['#']);
$quiz_cat->info = backup_todb($info['QUESTION_CATEGORY']['#']['INFO']['0']['#']);
$quiz_cat->publish = backup_todb($info['QUESTION_CATEGORY']['#']['PUBLISH']['0']['#']);
$quiz_cat->stamp = backup_todb($info['QUESTION_CATEGORY']['#']['STAMP']['0']['#']);
$quiz_cat->parent = backup_todb($info['QUESTION_CATEGORY']['#']['PARENT']['0']['#']);
$quiz_cat->sortorder = backup_todb($info['QUESTION_CATEGORY']['#']['SORTORDER']['0']['#']);
$question_cat->course = $restore->course_id;
$question_cat->name = backup_todb($info['QUESTION_CATEGORY']['#']['NAME']['0']['#']);
$question_cat->info = backup_todb($info['QUESTION_CATEGORY']['#']['INFO']['0']['#']);
$question_cat->publish = backup_todb($info['QUESTION_CATEGORY']['#']['PUBLISH']['0']['#']);
$question_cat->stamp = backup_todb($info['QUESTION_CATEGORY']['#']['STAMP']['0']['#']);
$question_cat->parent = backup_todb($info['QUESTION_CATEGORY']['#']['PARENT']['0']['#']);
$question_cat->sortorder = backup_todb($info['QUESTION_CATEGORY']['#']['SORTORDER']['0']['#']);
if ($catfound = restore_get_best_question_category($quiz_cat, $restore->course)) {
if ($catfound = restore_get_best_question_category($question_cat, $restore->course)) {
$newid = $catfound;
} else {
if (!$quiz_cat->stamp) {
$quiz_cat->stamp = make_unique_id_code();
if (!$question_cat->stamp) {
$question_cat->stamp = make_unique_id_code();
}
$newid = insert_record ("question_categories",$quiz_cat);
$newid = insert_record ("question_categories",$question_cat);
}
//Do some output
if ($newid) {
if (!defined('RESTORE_SILENTLY')) {
echo "<li>".get_string('category', 'quiz')." \"".$quiz_cat->name."\"<br />";
echo "<li>".get_string('category', 'quiz')." \"".$question_cat->name."\"<br />";
}
} else {
//We must never arrive here !!
if (!defined('RESTORE_SILENTLY')) {
echo "<li>".get_string('category', 'quiz')." \"".$quiz_cat->name."\" Error!<br />";
echo "<li>".get_string('category', 'quiz')." \"".$question_cat->name."\" Error!<br />";
}
$status = false;
}
@ -164,7 +164,7 @@
backup_putid($restore->backup_unique_code,"question_categories",
$category->id, $newid);
//Now restore question
$status = quiz_restore_questions ($category->id, $newid,$info,$restore);
$status = restore_questions ($category->id, $newid,$info,$restore);
} else {
$status = false;
}
@ -176,7 +176,7 @@
return $status;
}
function quiz_restore_questions ($old_category_id,$new_category_id,$info,$restore) {
function restore_questions ($old_category_id,$new_category_id,$info,$restore) {
global $CFG;
@ -261,38 +261,38 @@
//If it's a new question in the DB, restore it
if ($restored_questions[$i]->is_new) {
//Now, restore every question_answers in this question
$status = quiz_restore_answers($oldid,$newid,$que_info,$restore);
$status = question_restore_answers($oldid,$newid,$que_info,$restore);
//Now, depending of the type of questions, invoke different functions
if ($question->qtype == "1") {
$status = quiz_restore_shortanswer($oldid,$newid,$que_info,$restore);
$status = question_restore_shortanswer($oldid,$newid,$que_info,$restore);
} else if ($question->qtype == "2") {
$status = quiz_restore_truefalse($oldid,$newid,$que_info,$restore);
$status = question_restore_truefalse($oldid,$newid,$que_info,$restore);
} else if ($question->qtype == "3") {
$status = quiz_restore_multichoice($oldid,$newid,$que_info,$restore);
$status = question_restore_multichoice($oldid,$newid,$que_info,$restore);
} else if ($question->qtype == "4") {
//Random question. Nothing to do.
} else if ($question->qtype == "5") {
$status = quiz_restore_match($oldid,$newid,$que_info,$restore);
$status = question_restore_match($oldid,$newid,$que_info,$restore);
} else if ($question->qtype == "6") {
$status = quiz_restore_randomsamatch($oldid,$newid,$que_info,$restore);
$status = question_restore_randomsamatch($oldid,$newid,$que_info,$restore);
} else if ($question->qtype == "7") {
//Description question. Nothing to do.
} else if ($question->qtype == "8") {
$status = quiz_restore_numerical($oldid,$newid,$que_info,$restore);
$status = question_restore_numerical($oldid,$newid,$que_info,$restore);
} else if ($question->qtype == "9") {
$status = quiz_restore_multianswer($oldid,$newid,$que_info,$restore);
$status = question_restore_multianswer($oldid,$newid,$que_info,$restore);
} else if ($question->qtype == "10") {
$status = quiz_restore_calculated($oldid,$newid,$que_info,$restore);
$status = question_restore_calculated($oldid,$newid,$que_info,$restore);
} else if ($question->qtype == "11") {
$status = quiz_restore_rqp($oldid,$newid,$que_info,$restore);
$status = question_restore_rqp($oldid,$newid,$que_info,$restore);
} else if ($question->qtype == "12") {
$status = quiz_restore_essay($oldid,$newid,$que_info,$restore);
$status = question_restore_essay($oldid,$newid,$que_info,$restore);
}
} else {
//We are NOT creating the question, but we need to know every question_answers
//map between the XML file and the database to be able to restore the states
//in each attempt.
$status = quiz_restore_map_answers($oldid,$newid,$que_info,$restore);
$status = question_restore_map_answers($oldid,$newid,$que_info,$restore);
//Now, depending of the type of questions, invoke different functions
//to create the necessary mappings in backup_ids, because we are not
//creating the question, but need some records in backup table
@ -305,7 +305,7 @@
} else if ($question->qtype == "4") {
//Random question. Nothing to remap
} else if ($question->qtype == "5") {
$status = quiz_restore_map_match($oldid,$newid,$que_info,$restore);
$status = question_restore_map_match($oldid,$newid,$que_info,$restore);
} else if ($question->qtype == "6") {
//Randomsamatch question. Nothing to remap
} else if ($question->qtype == "7") {
@ -313,7 +313,7 @@
} else if ($question->qtype == "8") {
//Numerical question. Nothing to remap
} else if ($question->qtype == "9") {
$status = quiz_restore_map_multianswer($oldid,$newid,$que_info,$restore);
$status = question_restore_map_multianswer($oldid,$newid,$que_info,$restore);
} else if ($question->qtype == "10") {
//Calculated question. Nothing to remap
}
@ -333,7 +333,7 @@
return $status;
}
function quiz_restore_answers ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_answers ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -386,7 +386,7 @@
return $status;
}
function quiz_restore_map_answers ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_map_answers ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -447,7 +447,7 @@
return $status;
}
function quiz_restore_shortanswer ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_shortanswer ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -463,7 +463,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_SHORTANSWER record structure
//Now, build the QUESTION_SHORTANSWER record structure
$shortanswer->question = $new_question_id;
$shortanswer->answers = backup_todb($sho_info['#']['ANSWERS']['0']['#']);
$shortanswer->usecase = backup_todb($sho_info['#']['USECASE']['0']['#']);
@ -490,8 +490,8 @@
//We have the answers field recoded to its new ids
$shortanswer->answers = $answers_field;
//The structure is equal to the db, so insert the quiz_shortanswer
$newid = insert_record ("quiz_shortanswer",$shortanswer);
//The structure is equal to the db, so insert the question_shortanswer
$newid = insert_record ("question_shortanswer",$shortanswer);
//Do some output
if (($i+1) % 50 == 0) {
@ -512,7 +512,7 @@
return $status;
}
function quiz_restore_truefalse ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_truefalse ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -528,7 +528,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_TRUEFALSE record structure
//Now, build the QUESTION_TRUEFALSE record structure
$truefalse->question = $new_question_id;
$truefalse->trueanswer = backup_todb($tru_info['#']['TRUEANSWER']['0']['#']);
$truefalse->falseanswer = backup_todb($tru_info['#']['FALSEANSWER']['0']['#']);
@ -545,8 +545,8 @@
$truefalse->falseanswer = $answer->new_id;
}
//The structure is equal to the db, so insert the quiz_truefalse
$newid = insert_record ("quiz_truefalse",$truefalse);
//The structure is equal to the db, so insert the question_truefalse
$newid = insert_record ("question_truefalse",$truefalse);
//Do some output
if (($i+1) % 50 == 0) {
@ -567,7 +567,7 @@
return $status;
}
function quiz_restore_multichoice ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_multichoice ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -583,7 +583,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_MULTICHOICE record structure
//Now, build the QUESTION_MULTICHOICE record structure
$multichoice->question = $new_question_id;
$multichoice->layout = backup_todb($mul_info['#']['LAYOUT']['0']['#']);
$multichoice->answers = backup_todb($mul_info['#']['ANSWERS']['0']['#']);
@ -612,8 +612,8 @@
//We have the answers field recoded to its new ids
$multichoice->answers = $answers_field;
//The structure is equal to the db, so insert the quiz_shortanswer
$newid = insert_record ("quiz_multichoice",$multichoice);
//The structure is equal to the db, so insert the question_shortanswer
$newid = insert_record ("question_multichoice",$multichoice);
//Do some output
if (($i+1) % 50 == 0) {
@ -634,7 +634,7 @@
return $status;
}
function quiz_restore_match ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_match ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -657,13 +657,13 @@
//We'll need this later!!
$oldid = backup_todb($mat_info['#']['ID']['0']['#']);
//Now, build the QUIZ_MATCH_SUB record structure
//Now, build the QUESTION_MATCH_SUB record structure
$match_sub->question = $new_question_id;
$match_sub->questiontext = backup_todb($mat_info['#']['QUESTIONTEXT']['0']['#']);
$match_sub->answertext = backup_todb($mat_info['#']['ANSWERTEXT']['0']['#']);
//The structure is equal to the db, so insert the quiz_match_sub
$newid = insert_record ("quiz_match_sub",$match_sub);
//The structure is equal to the db, so insert the question_match_sub
$newid = insert_record ("question_match_sub",$match_sub);
//Do some output
if (($i+1) % 50 == 0) {
@ -678,7 +678,7 @@
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,"quiz_match_sub",$oldid,
backup_putid($restore->backup_unique_code,"question_match_sub",$oldid,
$newid);
//We have a new match_sub, append it to subquestions_field
if ($in_first) {
@ -696,8 +696,8 @@
$match->question = $new_question_id;
$match->subquestions = $subquestions_field;
//The structure is equal to the db, so insert the quiz_match_sub
$newid = insert_record ("quiz_match",$match);
//The structure is equal to the db, so insert the question_match_sub
$newid = insert_record ("question_match",$match);
if (!$newid) {
$status = false;
@ -706,7 +706,7 @@
return $status;
}
function quiz_restore_map_match ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_map_match ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -729,7 +729,7 @@
//We'll need this later!!
$oldid = backup_todb($mat_info['#']['ID']['0']['#']);
//Now, build the QUIZ_MATCH_SUB record structure
//Now, build the QUESTION_MATCH_SUB record structure
$match_sub->question = $new_question_id;
$match_sub->questiontext = backup_todb($mat_info['#']['QUESTIONTEXT']['0']['#']);
$match_sub->answertext = backup_todb($mat_info['#']['ANSWERTEXT']['0']['#']);
@ -740,7 +740,7 @@
//mappings in backup_ids to use them later where restoring states (user level).
//Get the match_sub from DB (by question, questiontext and answertext)
$db_match_sub = get_record ("quiz_match_sub","question",$new_question_id,
$db_match_sub = get_record ("question_match_sub","question",$new_question_id,
"questiontext",$match_sub->questiontext,
"answertext",$match_sub->answertext);
//Do some output
@ -757,7 +757,7 @@
//We have the database match_sub, so update backup_ids
if ($db_match_sub) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,"quiz_match_sub",$oldid,
backup_putid($restore->backup_unique_code,"question_match_sub",$oldid,
$db_match_sub->id);
} else {
$status = false;
@ -767,7 +767,7 @@
return $status;
}
function quiz_restore_map_multianswer ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_map_multianswer ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -785,7 +785,7 @@
//We need this later
$oldid = backup_todb($mul_info['#']['ID']['0']['#']);
//Now, build the QUIZ_MULTIANSWER record structure
//Now, build the QUESTION_MULTIANSWER record structure
$multianswer->question = $new_question_id;
$multianswer->answers = backup_todb($mul_info['#']['ANSWERS']['0']['#']);
$multianswer->positionkey = backup_todb($mul_info['#']['POSITIONKEY']['0']['#']);
@ -798,7 +798,7 @@
//mappings in backup_ids to use them later where restoring states (user level).
//Get the multianswer from DB (by question and positionkey)
$db_multianswer = get_record ("quiz_multianswers","question",$new_question_id,
$db_multianswer = get_record ("question_multianswer","question",$new_question_id,
"positionkey",$multianswer->positionkey);
//Do some output
if (($i+1) % 50 == 0) {
@ -814,7 +814,7 @@
//We have the database multianswer, so update backup_ids
if ($db_multianswer) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,"quiz_multianswers",$oldid,
backup_putid($restore->backup_unique_code,"question_multianswer",$oldid,
$db_multianswer->id);
} else {
$status = false;
@ -824,7 +824,7 @@
return $status;
}
function quiz_restore_randomsamatch ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_randomsamatch ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -840,13 +840,13 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_RANDOMSAMATCH record structure
//Now, build the QUESTION_RANDOMSAMATCH record structure
$randomsamatch->question = $new_question_id;
$randomsamatch->choose = backup_todb($ran_info['#']['CHOOSE']['0']['#']);
$randomsamatch->shuffleanswers = backup_todb($ran_info['#']['SHUFFLEANSWERS']['0']['#']);
//The structure is equal to the db, so insert the quiz_randomsamatch
$newid = insert_record ("quiz_randomsamatch",$randomsamatch);
//The structure is equal to the db, so insert the question_randomsamatch
$newid = insert_record ("question_randomsamatch",$randomsamatch);
//Do some output
if (($i+1) % 50 == 0) {
@ -867,7 +867,7 @@
return $status;
}
function quiz_restore_numerical ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_numerical ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -883,7 +883,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_NUMERICAL record structure
//Now, build the QUESTION_NUMERICAL record structure
$numerical->question = $new_question_id;
$numerical->answer = backup_todb($num_info['#']['ANSWER']['0']['#']);
$numerical->tolerance = backup_todb($num_info['#']['TOLERANCE']['0']['#']);
@ -894,8 +894,8 @@
$numerical->answer = $answer->new_id;
}
//The structure is equal to the db, so insert the quiz_numerical
$newid = insert_record ("quiz_numerical",$numerical);
//The structure is equal to the db, so insert the question_numerical
$newid = insert_record ("question_numerical",$numerical);
//Do some output
if (($i+1) % 50 == 0) {
@ -909,7 +909,7 @@
}
//Now restore numerical_units
$status = quiz_restore_numerical_units ($old_question_id,$new_question_id,$num_info,$restore);
$status = question_restore_numerical_units ($old_question_id,$new_question_id,$num_info,$restore);
if (!$newid) {
$status = false;
@ -919,7 +919,7 @@
return $status;
}
function quiz_restore_calculated ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_calculated ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -935,7 +935,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_CALCULATED record structure
//Now, build the QUESTION_CALCULATED record structure
$calculated->question = $new_question_id;
$calculated->answer = backup_todb($cal_info['#']['ANSWER']['0']['#']);
$calculated->tolerance = backup_todb($cal_info['#']['TOLERANCE']['0']['#']);
@ -949,8 +949,8 @@
$calculated->answer = $answer->new_id;
}
//The structure is equal to the db, so insert the quiz_calculated
$newid = insert_record ("quiz_calculated",$calculated);
//The structure is equal to the db, so insert the question_calculated
$newid = insert_record ("question_calculated",$calculated);
//Do some output
if (($i+1) % 50 == 0) {
@ -964,11 +964,11 @@
}
//Now restore numerical_units
$status = quiz_restore_numerical_units ($old_question_id,$new_question_id,$cal_info,$restore);
$status = question_restore_numerical_units ($old_question_id,$new_question_id,$cal_info,$restore);
//Now restore dataset_definitions
if ($status && $newid) {
$status = quiz_restore_dataset_definitions ($old_question_id,$new_question_id,$cal_info,$restore);
$status = question_restore_dataset_definitions ($old_question_id,$new_question_id,$cal_info,$restore);
}
if (!$newid) {
@ -979,7 +979,7 @@
return $status;
}
function quiz_restore_multianswer ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_multianswer ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -997,7 +997,7 @@
//We need this later
$oldid = backup_todb($mul_info['#']['ID']['0']['#']);
//Now, build the QUIZ_MULTIANSWER record structure
//Now, build the QUESTION_MULTIANSWER record structure
$multianswer->question = $new_question_id;
$multianswer->sequence = backup_todb($mul_info['#']['SEQUENCE']['0']['#']);
@ -1022,12 +1022,12 @@
}
//We have the answers field recoded to its new ids
$multianswer->sequence = $sequence_field;
//The structure is equal to the db, so insert the quiz_multianswers
$newid = insert_record ("quiz_multianswers",$multianswer);
//The structure is equal to the db, so insert the question_multianswer
$newid = insert_record ("question_multianswer",$multianswer);
//Save ids in backup_ids
if ($newid) {
backup_putid($restore->backup_unique_code,"quiz_multianswers",
backup_putid($restore->backup_unique_code,"question_multianswer",
$oldid, $newid);
}
@ -1042,15 +1042,15 @@
backup_flush(300);
}
/*
//If we have created the quiz_multianswers record, now, depending of the
//If we have created the question_multianswer record, now, depending of the
//answertype, delegate the restore to every qtype function
if ($newid) {
if ($multianswer->answertype == "1") {
$status = quiz_restore_shortanswer ($old_question_id,$new_question_id,$mul_info,$restore);
$status = question_restore_shortanswer ($old_question_id,$new_question_id,$mul_info,$restore);
} else if ($multianswer->answertype == "3") {
$status = quiz_restore_multichoice ($old_question_id,$new_question_id,$mul_info,$restore);
$status = question_restore_multichoice ($old_question_id,$new_question_id,$mul_info,$restore);
} else if ($multianswer->answertype == "8") {
$status = quiz_restore_numerical ($old_question_id,$new_question_id,$mul_info,$restore);
$status = question_restore_numerical ($old_question_id,$new_question_id,$mul_info,$restore);
}
} else {
$status = false;
@ -1061,7 +1061,7 @@
return $status;
}
function quiz_restore_rqp ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_rqp ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -1077,7 +1077,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_RQP record structure
//Now, build the QUESTION_RQP record structure
$rqp->question = $new_question_id;
$rqp->type = backup_todb($tru_info['#']['TYPE']['0']['#']);
$rqp->source = backup_todb($tru_info['#']['SOURCE']['0']['#']);
@ -1085,8 +1085,8 @@
$rqp->flags = backup_todb($tru_info['#']['FLAGS']['0']['#']);
$rqp->maxscore = backup_todb($tru_info['#']['MAXSCORE']['0']['#']);
//The structure is equal to the db, so insert the quiz_rqp
$newid = insert_record ("quiz_rqp",$rqp);
//The structure is equal to the db, so insert the question_rqp
$newid = insert_record ("question_rqp",$rqp);
//Do some output
if (($i+1) % 50 == 0) {
@ -1107,7 +1107,7 @@
return $status;
}
function quiz_restore_essay ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_essay ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -1123,7 +1123,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_TRUEFALSE record structure
//Now, build the QUESTION_TRUEFALSE record structure
$essay->question = $new_question_id;
$essay->answer = backup_todb($essay_info['#']['ANSWER']['0']['#']);
@ -1133,8 +1133,8 @@
$essay->answer = $answer->new_id;
}
//The structure is equal to the db, so insert the quiz_truefalse
$newid = insert_record ("quiz_essay",$essay);
//The structure is equal to the db, so insert the question_truefalse
$newid = insert_record ("question_essay",$essay);
//Do some output
if (($i+1) % 50 == 0) {
@ -1153,7 +1153,7 @@
return $status;
}
function quiz_restore_numerical_units ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_numerical_units ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -1169,13 +1169,13 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_NUMERICAL_UNITS record structure
//Now, build the QUESTION_NUMERICAL_UNITS record structure
$numerical_unit->question = $new_question_id;
$numerical_unit->multiplier = backup_todb($nu_info['#']['MULTIPLIER']['0']['#']);
$numerical_unit->unit = backup_todb($nu_info['#']['UNIT']['0']['#']);
//The structure is equal to the db, so insert the quiz_numerical_units
$newid = insert_record ("quiz_numerical_units",$numerical_unit);
//The structure is equal to the db, so insert the question_numerical_units
$newid = insert_record ("question_numerical_units",$numerical_unit);
if (!$newid) {
$status = false;
@ -1185,7 +1185,7 @@
return $status;
}
function quiz_restore_dataset_definitions ($old_question_id,$new_question_id,$info,$restore) {
function question_restore_dataset_definitions ($old_question_id,$new_question_id,$info,$restore) {
global $CFG;
@ -1201,7 +1201,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_DATASET_DEFINITION record structure
//Now, build the QUESTION_DATASET_DEFINITION record structure
$dataset_definition->category = backup_todb($dd_info['#']['CATEGORY']['0']['#']);
$dataset_definition->name = backup_todb($dd_info['#']['NAME']['0']['#']);
$dataset_definition->type = backup_todb($dd_info['#']['TYPE']['0']['#']);
@ -1226,7 +1226,7 @@
//The category isn't 0, so it's a category question dataset_definition, we have to see if it exists
//Look for a definition with the same category, name and type
if ($definitionrec = get_record_sql("SELECT d.*
FROM {$CFG->prefix}quiz_dataset_definitions d
FROM {$CFG->prefix}question_dataset_definitions d
WHERE d.category = '$dataset_definition->category' AND
d.name = '$dataset_definition->name' AND
d.type = '$dataset_definition->type'")) {
@ -1248,20 +1248,20 @@
//If we've to create the definition, do it
if ($create_definition) {
//The structure is equal to the db, so insert the quiz_dataset_definitions
$newid = insert_record ("quiz_dataset_definitions",$dataset_definition);
//The structure is equal to the db, so insert the question_dataset_definitions
$newid = insert_record ("question_dataset_definitions",$dataset_definition);
if ($newid) {
//Restore quiz_dataset_items
$status = quiz_restore_dataset_items($newid,$dd_info,$restore);
//Restore question_dataset_items
$status = question_restore_dataset_items($newid,$dd_info,$restore);
}
}
//Now, we must have a definition (created o reused). Its id is in newid. Create the quiz_question_datasets record
//Now, we must have a definition (created o reused). Its id is in newid. Create the question_datasets record
//to join the question and the dataset_definition
if ($newid) {
$question_dataset->question = $new_question_id;
$question_dataset->datasetdefinition = $newid;
$newid = insert_record ("quiz_question_datasets",$question_dataset);
$newid = insert_record ("question_datasets",$question_dataset);
}
if (!$newid) {
@ -1272,7 +1272,7 @@
return $status;
}
function quiz_restore_dataset_items ($definitionid,$info,$restore) {
function question_restore_dataset_items ($definitionid,$info,$restore) {
global $CFG;
@ -1288,13 +1288,13 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_DATASET_ITEMS record structure
//Now, build the QUESTION_DATASET_ITEMS record structure
$dataset_item->definition = $definitionid;
$dataset_item->number = backup_todb($di_info['#']['NUMBER']['0']['#']);
$dataset_item->value = backup_todb($di_info['#']['VALUE']['0']['#']);
//The structure is equal to the db, so insert the quiz_dataset_items
$newid = insert_record ("quiz_dataset_items",$dataset_item);
//The structure is equal to the db, so insert the question_dataset_items
$newid = insert_record ("question_dataset_items",$dataset_item);
if (!$newid) {
$status = false;
@ -1707,9 +1707,9 @@
$match_question_id = $exploded[0];
$match_answer_id = $exploded[1];
//Get the match_sub from backup_ids (for the question)
$match_que = backup_getid($restore->backup_unique_code,"quiz_match_sub",$match_question_id);
$match_que = backup_getid($restore->backup_unique_code,"question_match_sub",$match_question_id);
//Get the match_sub from backup_ids (for the answer)
$match_ans = backup_getid($restore->backup_unique_code,"quiz_match_sub",$match_answer_id);
$match_ans = backup_getid($restore->backup_unique_code,"question_match_sub",$match_answer_id);
if ($match_que) {
//It the question hasn't response, it must be 0
if (!$match_ans and $match_answer_id == 0) {
@ -1776,11 +1776,11 @@
$multianswer_id = $exploded[0];
$answer = $exploded[1];
//Get the multianswer from backup_ids
$mul = backup_getid($restore->backup_unique_code,"quiz_multianswers",$multianswer_id);
$mul = backup_getid($restore->backup_unique_code,"question_multianswer",$multianswer_id);
if ($mul) {
//Now, depending of the answertype field in quiz_multianswers
//Now, depending of the answertype field in question_multianswer
//we do diferent things
$mul_db = get_record ("quiz_multianswers","id",$mul->new_id);
$mul_db = get_record ("question_multianswer","id",$mul->new_id);
if ($mul_db->answertype == "1") {
//Shortanswer
//The answer is text, do nothing
@ -1838,8 +1838,8 @@
backup_putid($restore->backup_unique_code,"question_states",$oldid,
$newid);
//Now process question type specific state information
$status = quiz_rqp_states_restore_mods($newid,$res_info,$restore);
$status = quiz_essay_states_restore_mods($newid,$res_info,$restore);
$status = question_rqp_states_restore_mods($newid,$res_info,$restore);
$status = question_essay_states_restore_mods($newid,$res_info,$restore);
} else {
$status = false;
}
@ -1887,14 +1887,14 @@
return $status;
}
//This function restores the quiz_rqp_states
function quiz_rqp_states_restore_mods($state_id,$info,$restore) {
//This function restores the question_rqp_states
function question_rqp_states_restore_mods($state_id,$info,$restore) {
global $CFG;
$status = true;
//Get the quiz_rqp_state
//Get the question_rqp_state
$rqp_state = $info['#']['RQP_STATE']['0'];
if ($rqp_state) {
@ -1905,20 +1905,20 @@
$state->template_vars = backup_todb($rqp_state['#']['TEMPLATE_VARS']['0']['#']);
//The structure is equal to the db, so insert the question_states
$newid = insert_record ("quiz_rqp_states",$state);
$newid = insert_record ("question_rqp_states",$state);
}
return $status;
}
//This function restores the quiz_essay_states
function quiz_essay_states_restore_mods($state_id,$info,$restore) {
//This function restores the question_essay_states
function question_essay_states_restore_mods($state_id,$info,$restore) {
global $CFG;
$status = true;
//Get the quiz_essay_state
//Get the question_essay_state
$essay_state = $info['#']['ESSAY_STATE']['0'];
if ($essay_state) {
@ -1929,7 +1929,7 @@
$state->response = backup_todb($essay_state['#']['RESPONSE']['0']['#']);
//The structure is equal to the db, so insert the question_states
$newid = insert_record ("quiz_essay_states",$state);
$newid = insert_record ("question_essay_states",$state);
}
return $status;

View File

@ -13,18 +13,18 @@
// | | | | |.......................................
// | | | | | .
// | | | | | .
// quiz_attempts quiz_grades quiz_question_grades quiz_question_versions | ----quiz_question_datasets---- .
// quiz_attempts quiz_grades quiz_question_grades quiz_question_versions | ----question_datasets---- .
// (UL,pk->id, fk->quiz) (UL,pk->id,fk->quiz) (CL,pk->id,fk->quiz) (CL,pk->id,fk->quiz) | | (CL,pk->id,fk->question, | .
// | | . | | fk->dataset_definition) | .
// | | . | | | .
// | | . | | | .
// | | . | | | .
// quiz_responses | question quiz_dataset_definitions
// quiz_responses | question question_dataset_definitions
// (UL,pk->id, fk->attempt)----------------------------------------------------(CL,pk->id,fk->category,files) (CL,pk->id,fk->category)
// | |
// | |
// | |
// | quiz_dataset_items
// | question_dataset_items
// | (CL,pk->id,fk->definition)
// |
// |
@ -32,22 +32,22 @@
// --------------------------------------------------------------------------------------------------------------
// | | | | | | |
// | | | | | | |
// | | | | quiz_calculated | | quiz_randomsamatch
// quiz_truefalse | quiz_multichoice | (CL,pl->id,fk->question) | |--(CL,pl->id,fk->question)
// | | | | question_calculated | | question_randomsamatch
// question_truefalse | question_multichoice | (CL,pl->id,fk->question) | |--(CL,pl->id,fk->question)
// (CL,pl->id,fk->question) | (CL,pl->id,fk->question) | . | |
// . | . | . | |
// . quiz_shortanswer . quiz_numerical . quiz_multianswer. |
// . (CL,pl->id,fk->question) . (CL,pl->id,fk->question) . (CL,pl->id,fk->question) | quiz_match
// . question_shortanswer . question_numerical . question_multianswer. |
// . (CL,pl->id,fk->question) . (CL,pl->id,fk->question) . (CL,pl->id,fk->question) | question_match
// . . . . . . |--(CL,pl->id,fk->question)
// . . . . . . | .
// . . . . . . | .
// . . . . . . | .
// . . . . . . | quiz_match_sub
// . . . . . . | question_match_sub
// . . . . . . |--(CL,pl->id,fk->question)
// ........................................................................................ |
// . |
// . |
// . | quiz_numerical_units
// . | question_numerical_units
// question_answers |--(CL,pl->id,fk->question)
// (CL,pk->id,fk->question)----------------------------------------------------------
//
@ -64,20 +64,20 @@
// 1.-We restore every category and their questions (complete structure). It includes this tables:
// - question_categories
// - question
// - quiz_truefalse
// - quiz_shortanswer
// - quiz_multianswer
// - quiz_multichoice
// - quiz_numerical
// - quiz_randomsamatch
// - quiz_match
// - quiz_match_sub
// - quiz_calculated
// - question_truefalse
// - question_shortanswer
// - question_multianswer
// - question_multichoice
// - question_numerical
// - question_randomsamatch
// - question_match
// - question_match_sub
// - question_calculated
// - question_answers
// - quiz_numerical_units
// - quiz_question_datasets
// - quiz_dataset_definitions
// - quiz_dataset_items
// - question_numerical_units
// - question_datasets
// - question_dataset_definitions
// - question_dataset_items
// All this backup info have its own section in moodle.xml (QUESTION_CATEGORIES) and it's generated
// before every module backup standard invocation. And only if to restore quizzes has been selected !!
// It's invoked with quiz_restore_question_categories. (course independent).
@ -458,7 +458,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_SHORTANSWER record structure
//Now, build the question_shortanswer record structure
$shortanswer->question = $new_question_id;
$shortanswer->answers = backup_todb($sho_info['#']['ANSWERS']['0']['#']);
$shortanswer->usecase = backup_todb($sho_info['#']['USECASE']['0']['#']);
@ -485,10 +485,10 @@
//We have the answers field recoded to its new ids
$shortanswer->answers = $answers_field;
//The structure is equal to the db, so insert the quiz_shortanswer
//The structure is equal to the db, so insert the question_shortanswer
//Only if there aren't restrictions or there are restriction concordance
if (empty($restrictto) || (!empty($restrictto) && $shortanswer->answers == $restrictto)) {
$newid = insert_record ("quiz_shortanswer",$shortanswer);
$newid = insert_record ("question_shortanswer",$shortanswer);
}
//Do some output
@ -526,7 +526,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_TRUEFALSE record structure
//Now, build the question_truefalse record structure
$truefalse->question = $new_question_id;
$truefalse->trueanswer = backup_todb($tru_info['#']['TRUEANSWER']['0']['#']);
$truefalse->falseanswer = backup_todb($tru_info['#']['FALSEANSWER']['0']['#']);
@ -543,8 +543,8 @@
$truefalse->falseanswer = $answer->new_id;
}
//The structure is equal to the db, so insert the quiz_truefalse
$newid = insert_record ("quiz_truefalse",$truefalse);
//The structure is equal to the db, so insert the question_truefalse
$newid = insert_record ("question_truefalse",$truefalse);
//Do some output
if (($i+1) % 50 == 0) {
@ -581,7 +581,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_MULTICHOICE record structure
//Now, build the question_multichoice record structure
$multichoice->question = $new_question_id;
$multichoice->layout = backup_todb($mul_info['#']['LAYOUT']['0']['#']);
$multichoice->answers = backup_todb($mul_info['#']['ANSWERS']['0']['#']);
@ -609,10 +609,10 @@
//We have the answers field recoded to its new ids
$multichoice->answers = $answers_field;
//The structure is equal to the db, so insert the quiz_shortanswer
//The structure is equal to the db, so insert the question_shortanswer
//Only if there aren't restrictions or there are restriction concordance
if (empty($restrictto) || (!empty($restrictto) && $multichoice->answers == $restrictto)) {
$newid = insert_record ("quiz_multichoice",$multichoice);
$newid = insert_record ("question_multichoice",$multichoice);
}
//Do some output
@ -657,13 +657,13 @@
//We'll need this later!!
$oldid = backup_todb($mat_info['#']['ID']['0']['#']);
//Now, build the QUIZ_MATCH_SUB record structure
//Now, build the question_match_SUB record structure
$match_sub->question = $new_question_id;
$match_sub->questiontext = backup_todb($mat_info['#']['QUESTIONTEXT']['0']['#']);
$match_sub->answertext = backup_todb($mat_info['#']['ANSWERTEXT']['0']['#']);
//The structure is equal to the db, so insert the quiz_match_sub
$newid = insert_record ("quiz_match_sub",$match_sub);
//The structure is equal to the db, so insert the question_match_sub
$newid = insert_record ("question_match_sub",$match_sub);
//Do some output
if (($i+1) % 50 == 0) {
@ -678,7 +678,7 @@
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,"quiz_match_sub",$oldid,
backup_putid($restore->backup_unique_code,"question_match_sub",$oldid,
$newid);
//We have a new match_sub, append it to subquestions_field
if ($in_first) {
@ -696,8 +696,8 @@
$match->question = $new_question_id;
$match->subquestions = $subquestions_field;
//The structure is equal to the db, so insert the quiz_match_sub
$newid = insert_record ("quiz_match",$match);
//The structure is equal to the db, so insert the question_match_sub
$newid = insert_record ("question_match",$match);
if (!$newid) {
$status = false;
@ -729,7 +729,7 @@
//We'll need this later!!
$oldid = backup_todb($mat_info['#']['ID']['0']['#']);
//Now, build the QUIZ_MATCH_SUB record structure
//Now, build the question_match_SUB record structure
$match_sub->question = $new_question_id;
$match_sub->questiontext = backup_todb($mat_info['#']['QUESTIONTEXT']['0']['#']);
$match_sub->answertext = backup_todb($mat_info['#']['ANSWERTEXT']['0']['#']);
@ -740,7 +740,7 @@
//mappings in backup_ids to use them later where restoring responses (user level).
//Get the match_sub from DB (by question, questiontext and answertext)
$db_match_sub = get_record ("quiz_match_sub","question",$new_question_id,
$db_match_sub = get_record ("question_match_sub","question",$new_question_id,
"questiontext",$match_sub->questiontext,
"answertext",$match_sub->answertext);
//Do some output
@ -757,7 +757,7 @@
//We have the database match_sub, so update backup_ids
if ($db_match_sub) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,"quiz_match_sub",$oldid,
backup_putid($restore->backup_unique_code,"question_match_sub",$oldid,
$db_match_sub->id);
} else {
$status = false;
@ -783,12 +783,12 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_RANDOMSAMATCH record structure
//Now, build the question_randomsamatch record structure
$randomsamatch->question = $new_question_id;
$randomsamatch->choose = backup_todb($ran_info['#']['CHOOSE']['0']['#']);
//The structure is equal to the db, so insert the quiz_randomsamatch
$newid = insert_record ("quiz_randomsamatch",$randomsamatch);
//The structure is equal to the db, so insert the question_randomsamatch
$newid = insert_record ("question_randomsamatch",$randomsamatch);
//Do some output
if (($i+1) % 50 == 0) {
@ -825,7 +825,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_NUMERICAL record structure
//Now, build the question_numerical record structure
$numerical->question = $new_question_id;
$numerical->answer = backup_todb($num_info['#']['ANSWER']['0']['#']);
$numerical->min = backup_todb($num_info['#']['MIN']['0']['#']);
@ -844,10 +844,10 @@
//We have to calculate the tolerance field of the numerical question
$numerical->tolerance = ($numerical->max - $numerical->min)/2;
//The structure is equal to the db, so insert the quiz_numerical
//The structure is equal to the db, so insert the question_numerical
//Only if there aren't restrictions or there are restriction concordance
if (empty($restrictto) || (!empty($restrictto) && in_array($numerical->answer,explode(",",$restrictto)))) {
$newid = insert_record ("quiz_numerical",$numerical);
$newid = insert_record ("question_numerical",$numerical);
}
//Do some output
@ -890,7 +890,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_CALCULATED record structure
//Now, build the question_calculated record structure
$calculated->question = $new_question_id;
$calculated->answer = backup_todb($cal_info['#']['ANSWER']['0']['#']);
$calculated->tolerance = backup_todb($cal_info['#']['TOLERANCE']['0']['#']);
@ -909,8 +909,8 @@
$calculated->correctanswerformat = 2;
}
//The structure is equal to the db, so insert the quiz_calculated
$newid = insert_record ("quiz_calculated",$calculated);
//The structure is equal to the db, so insert the question_calculated
$newid = insert_record ("question_calculated",$calculated);
//Do some output
if (($i+1) % 50 == 0) {
@ -968,7 +968,7 @@
//We need this later
$oldid = backup_todb($mul_info['#']['ID']['0']['#']);
//Now, build the QUIZ_MULTIANSWER record structure
//Now, build the question_multianswer record structure
$multianswer->question = $new_question_id;
$multianswer->answers = backup_todb($mul_info['#']['ANSWERS']['0']['#']);
$multianswer->positionkey = backup_todb($mul_info['#']['POSITIONKEY']['0']['#']);
@ -1051,7 +1051,7 @@
$multianswerdb = new object;
$multianswerdb->question = $parentquestion->id;
$multianswerdb->sequence = implode(",",$createdquestions);
$mid = insert_record('quiz_multianswers', $multianswerdb);
$mid = insert_record('question_multianswer', $multianswerdb);
if (!$mid) {
$status = false;
@ -1077,13 +1077,13 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_NUMERICAL_UNITS record structure
//Now, build the question_numerical_UNITS record structure
$numerical_unit->question = $new_question_id;
$numerical_unit->multiplier = backup_todb($nu_info['#']['MULTIPLIER']['0']['#']);
$numerical_unit->unit = backup_todb($nu_info['#']['UNIT']['0']['#']);
//The structure is equal to the db, so insert the quiz_numerical_units
$newid = insert_record ("quiz_numerical_units",$numerical_unit);
//The structure is equal to the db, so insert the question_numerical_units
$newid = insert_record ("question_numerical_units",$numerical_unit);
if (!$newid) {
$status = false;
@ -1109,7 +1109,7 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_DATASET_DEFINITION record structure
//Now, build the question_dataset_DEFINITION record structure
$dataset_definition->category = backup_todb($dd_info['#']['CATEGORY']['0']['#']);
$dataset_definition->name = backup_todb($dd_info['#']['NAME']['0']['#']);
$dataset_definition->type = backup_todb($dd_info['#']['TYPE']['0']['#']);
@ -1134,7 +1134,7 @@
//The category isn't 0, so it's a category question dataset_definition, we have to see if it exists
//Look for a definition with the same category, name and type
if ($definitionrec = get_record_sql("SELECT d.*
FROM {$CFG->prefix}quiz_dataset_definitions d
FROM {$CFG->prefix}question_dataset_definitions d
WHERE d.category = '$dataset_definition->category' AND
d.name = '$dataset_definition->name' AND
d.type = '$dataset_definition->type'")) {
@ -1156,20 +1156,20 @@
//If we've to create the definition, do it
if ($create_definition) {
//The structure is equal to the db, so insert the quiz_dataset_definitions
$newid = insert_record ("quiz_dataset_definitions",$dataset_definition);
//The structure is equal to the db, so insert the question_dataset_definitions
$newid = insert_record ("question_dataset_definitions",$dataset_definition);
if ($newid) {
//Restore quiz_dataset_items
//Restore question_dataset_items
$status = quiz_restore_pre15_dataset_items($newid,$dd_info,$restore);
}
}
//Now, we must have a definition (created o reused). Its id is in newid. Create the quiz_question_datasets record
//Now, we must have a definition (created o reused). Its id is in newid. Create the question_datasets record
//to join the question and the dataset_definition
if ($newid) {
$question_dataset->question = $new_question_id;
$question_dataset->datasetdefinition = $newid;
$newid = insert_record ("quiz_question_datasets",$question_dataset);
$newid = insert_record ("question_datasets",$question_dataset);
}
if (!$newid) {
@ -1196,13 +1196,13 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ_DATASET_ITEMS record structure
//Now, build the question_dataset_ITEMS record structure
$dataset_item->definition = $definitionid;
$dataset_item->number = backup_todb($di_info['#']['NUMBER']['0']['#']);
$dataset_item->value = backup_todb($di_info['#']['VALUE']['0']['#']);
//The structure is equal to the db, so insert the quiz_dataset_items
$newid = insert_record ("quiz_dataset_items",$dataset_item);
//The structure is equal to the db, so insert the question_dataset_items
$newid = insert_record ("question_dataset_items",$dataset_item);
if (!$newid) {
$status = false;
@ -1627,9 +1627,9 @@
$match_question_id = $exploded[0];
$match_answer_id = $exploded[1];
//Get the match_sub from backup_ids (for the question)
$match_que = backup_getid($restore->backup_unique_code,"quiz_match_sub",$match_question_id);
$match_que = backup_getid($restore->backup_unique_code,"question_match_sub",$match_question_id);
//Get the match_sub from backup_ids (for the answer)
$match_ans = backup_getid($restore->backup_unique_code,"quiz_match_sub",$match_answer_id);
$match_ans = backup_getid($restore->backup_unique_code,"question_match_sub",$match_answer_id);
if ($match_que) {
//It the question hasn't response, it must be 0
if (!$match_ans and $match_answer_id == 0) {
@ -1688,7 +1688,7 @@
case 9: //MULTIANSWER QTYPE
//The answer is a comma separated list of hypen separated multianswer ids and answers. We must recode them.
//We need to have the sequence of questions here to be able to detect qtypes
$multianswerdb = get_record('quiz_multianswers','question',$response->question);
$multianswerdb = get_record('question_multianswer','question',$response->question);
//Make an array of sequence to easy access
$sequencearr = explode(",",$multianswerdb->sequence);
$answer_field = "";
@ -1711,7 +1711,7 @@
//Calculate question type
$questiondb = get_record('question','id',$sequencearr[$counter-1]);
$questiontype = $questiondb->qtype;
//Now, depending of the answertype field in quiz_multianswers
//Now, depending of the answertype field in question_multianswer
//we do diferent things
if ($questiontype == "1") {
//Shortanswer

View File

@ -5,7 +5,7 @@
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2006030101; // The (date) version of this module
$module->version = 2006031202; // The (date) version of this module
$module->requires = 2006022400; // Requires this Moodle version
$module->cron = 0; // How often should cron check this module (seconds)?

View File

@ -35,7 +35,7 @@ $QTYPE_MENU = array ( MULTICHOICE => get_string("multichoice", "quiz"),
ESSAY => get_string("essay", "quiz")
);
// add remote question types
if ($rqp_types = get_records('quiz_rqp_types')) {
if ($rqp_types = get_records('question_rqp_types')) {
foreach($rqp_types as $type) {
$QTYPE_MENU[100+$type->id] = $type->name;
}

View File

@ -156,7 +156,7 @@ class qformat_aon extends qformat_default {
$extracts = get_records_sql("SELECT q.questiontext, a.answer
FROM {$CFG->prefix}question q,
{$CFG->prefix}quiz_shortanswer sa,
{$CFG->prefix}question_shortanswer sa,
{$CFG->prefix}question_answers a
WHERE q.id in ($extractids)
AND sa.question = q.id
@ -194,7 +194,7 @@ class qformat_aon extends qformat_default {
/// Delete the old short-answer questions
execute_sql("DELETE FROM {$CFG->prefix}question WHERE id IN ($extractids)", false);
execute_sql("DELETE FROM {$CFG->prefix}quiz_shortanswer WHERE question IN ($extractids)", false);
execute_sql("DELETE FROM {$CFG->prefix}question_shortanswer WHERE question IN ($extractids)", false);
execute_sql("DELETE FROM {$CFG->prefix}question_answers WHERE question IN ($extractids)", false);
}
@ -202,7 +202,7 @@ class qformat_aon extends qformat_default {
if ($count) { /// Delete the remaining ones
foreach ($shortanswerids as $shortanswerid) {
delete_records("question", "id", $shortanswerid);
delete_records("quiz_shortanswer", "question", $shortanswerid);
delete_records("question_shortanswer", "question", $shortanswerid);
delete_records("question_answers", "question", $shortanswerid);
}
}

View File

@ -72,7 +72,7 @@ class qformat_hotpot extends qformat_default {
// detect old Moodles (1.4 and earlier)
global $CFG, $db;
$moodle_14 = false;
if ($columns = $db->MetaColumns("{$CFG->prefix}quiz_multianswers")) {
if ($columns = $db->MetaColumns("{$CFG->prefix}question_multianswer")) {
foreach ($columns as $column) {
if ($column->name=='answers' || $column->name=='positionkey' || $column->name=='answertype' || $column->name=='norm') {
$moodle_14 = true;

View File

@ -735,7 +735,7 @@ function xml_entitize(&$collection) {
$questiontext = strip_tags($question->questiontext, $allowabletags);
if (preg_match_all('/(.*){#([0-9]+)}/U', $questiontext, $matches)) {
// matches[1] contains the text inbetween the question blanks
// matches[2] contains the id of the question blanks (db: quiz_multianswers.positionkey)
// matches[2] contains the id of the question blanks (db: question_multianswer.positionkey)
// find any trailing text after the last {#XX} and add it to the array
if (preg_match('/.*{#[0-9]+}(.*)$/', $questiontext, $tail)) {

View File

@ -58,7 +58,7 @@ function unhtmlentities($string){
return preg_replace ($search, $replace, $string);
}
class qformat_webct_modified_calculated_qtype extends quiz_calculated_qtype {
class qformat_webct_modified_calculated_qtype extends question_calculated_qtype {
// We need to make a modification of this qtype so that
// it will be able to save webct style calculated questions
// The difference between webct and Moodle is that webct
@ -98,8 +98,8 @@ class qformat_webct_modified_calculated_qtype extends quiz_calculated_qtype {
global $CFG;
$datasetdefs = get_records_sql(
"SELECT a.*
FROM {$CFG->prefix}quiz_dataset_definitions a,
{$CFG->prefix}quiz_question_datasets b
FROM {$CFG->prefix}question_dataset_definitions a,
{$CFG->prefix}question_datasets b
WHERE a.id = b.datasetdefinition
AND b.question = '$question->id' ");
@ -110,7 +110,7 @@ class qformat_webct_modified_calculated_qtype extends quiz_calculated_qtype {
$item->definition = $datasetdef->id;
for ($item->number=1 ; isset($datasetdata->items["$item->number"]) ; ++$item->number) {
$item->value = $datasetdata->items["$item->number"];
if (!insert_record('quiz_dataset_items', $item)) {
if (!insert_record('question_dataset_items', $item)) {
error("Unable to insert dataset item $item->number with $item->value for $datasetdef->name");
}
}
@ -132,7 +132,7 @@ class qformat_webct_modified_calculated_qtype extends quiz_calculated_qtype {
// Save definition
if ($datasetdef->itemcount || $datasetdef->options) {
if (!update_record('quiz_dataset_definitions', $datasetdef)) {
if (!update_record('question_dataset_definitions', $datasetdef)) {
error("Unable to update dataset definition $datasetdef->name on question $question->id");
}
}

View File

@ -48,7 +48,7 @@ if (empty($form)) {
$units[$i]->unit = '';
}
if (!empty($question->id) and $unitsraw = get_records(
'quiz_numerical_units', 'question', $question->id)) {
'question_numerical_units', 'question', $question->id)) {
/// Find default unit and have it put in the zero slot
/// This procedure might be overridden later when
/// the unit is stripped form an answer...

View File

@ -8,7 +8,7 @@
require_once("$CFG->dirroot/question/questiontypes/datasetdependent/abstractqtype.php");
class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
class question_calculated_qtype extends question_dataset_dependent_questiontype {
// Used by the function custom_generator_tools:
var $calcgenerateidhasbeenadded = false;
@ -23,7 +23,7 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
return false;
}
if (!$options = get_record('quiz_calculated', 'question', $question->id)) {
if (!$options = get_record('question_calculated', 'question', $question->id)) {
notify("No options were found for calculated question
#{$question->id}! Proceeding with defaults.");
$options = new stdClass;
@ -59,7 +59,7 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
"SELECT a.*, c.tolerance, c.tolerancetype,
c.correctanswerlength, c.id AS calcid
FROM {$CFG->prefix}question_answers a,
{$CFG->prefix}quiz_calculated c
{$CFG->prefix}question_calculated c
WHERE c.question = $question->id AND a.id = c.answer")) {
$oldanswers = array();
}
@ -94,7 +94,7 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
} else {
// notify("Answer updated successfully for calculated question $question->name");
}
if (!update_record('quiz_calculated', $calcrec)) {
if (!update_record('question_calculated', $calcrec)) {
error("Unable to update options for calculated question #{$question->id}!");
} else {
// notify("Options updated successfully for calculated question $question->name");
@ -108,7 +108,7 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
} else {
// notify("Answer inserted successfully for calculated question $question->id");
}
if (!insert_record('quiz_calculated', $calcrec)) {
if (!insert_record('question_calculated', $calcrec)) {
error("Unable to insert options calculared question $question->id");
} else {
// notify("Options inserted successfully for calculated question $question->id");
@ -123,7 +123,7 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
} else {
// notify("Old answers deleted successfully for calculated question $question->id");
}
if (!delete_records('quiz_calculated', 'id', $oldanswer->calcid)) {
if (!delete_records('question_calculated', 'id', $oldanswer->calcid)) {
error("Unable to delete old options for calculated question $question->id");
} else {
// notify("Old options deleted successfully for calculated question $question->id");
@ -204,10 +204,10 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
* @param object $question The question being deleted
*/
function delete_question($question) {
delete_records("quiz_calculated", "question", $question->id);
delete_records("quiz_numerical_units", "question", $question->id);
delete_records("quiz_question_datasets", "question", $question->id);
//TODO: delete entries from the quiz_dataset_items and quiz_dataset_definitions tables
delete_records("question_calculated", "question", $question->id);
delete_records("question_numerical_units", "question", $question->id);
delete_records("question_datasets", "question", $question->id);
//TODO: delete entries from the question_dataset_items and question_dataset_definitions tables
return true;
}
@ -309,7 +309,7 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
function create_virtual_qtype() {
global $CFG;
require_once("$CFG->dirroot/question/questiontypes/numerical/questiontype.php");
return new quiz_numerical_qtype();
return new question_numerical_qtype();
}
function supports_dataset_item_generation() {
@ -477,7 +477,7 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
function comment_on_datasetitems($question, $data, $number) {
/// Find a default unit:
if (!empty($question->id) && $unit = get_record('quiz_numerical_units',
if (!empty($question->id) && $unit = get_record('question_numerical_units',
'question', $question->id, 'multiplier', 1.0)) {
$unit = $unit->unit;
} else {
@ -593,7 +593,7 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
$QTYPES[CALCULATED]= new quiz_calculated_qtype();
$QTYPES[CALCULATED]= new question_calculated_qtype();
function quiz_qtype_calculated_calculate_answer($formula, $individualdata,
$tolerance, $tolerancetype, $answerlength, $answerformat='1', $unit='') {

View File

@ -10,7 +10,7 @@ define("LITERAL", "1");
define("FILE", "2");
define("LINK", "3");
class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
class question_dataset_dependent_questiontype extends quiz_default_questiontype {
var $virtualqtype = false;
@ -28,8 +28,8 @@ class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
global $CFG;
if(!$maxnumber = (int)get_field_sql(
"SELECT MAX(a.itemcount)
FROM {$CFG->prefix}quiz_dataset_definitions a,
{$CFG->prefix}quiz_question_datasets b
FROM {$CFG->prefix}question_dataset_definitions a,
{$CFG->prefix}question_datasets b
WHERE b.question = $question->id
AND a.id = b.datasetdefinition")) {
error("Couldn't get the specified dataset for a calculated " .
@ -125,9 +125,9 @@ class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
// dataset item on this question...
global $CFG;
if (get_record_sql(" SELECT *
FROM {$CFG->prefix}quiz_dataset_items i,
{$CFG->prefix}quiz_dataset_definitions d,
{$CFG->prefix}quiz_question_datasets q
FROM {$CFG->prefix}question_dataset_items i,
{$CFG->prefix}question_dataset_definitions d,
{$CFG->prefix}question_datasets q
WHERE i.value = '$relativefilepath'
AND d.id = i.definition AND d.type = 2
AND d.id = q.datasetdefinition
@ -223,8 +223,8 @@ class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
if (!empty($form->id)) {
global $CFG;
$sql = "SELECT i.*
FROM {$CFG->prefix}quiz_question_datasets d,
{$CFG->prefix}quiz_dataset_definitions i
FROM {$CFG->prefix}question_datasets d,
{$CFG->prefix}question_dataset_definitions i
WHERE d.question = '$form->id'
AND d.datasetdefinition = i.id
";
@ -265,13 +265,13 @@ class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
if (isset($datasetdef->id)) {
// This dataset is not used any more, delete it
if (!isset($tmpdatasets[$defid])) {
delete_records('quiz_question_datasets',
delete_records('question_datasets',
'question', $form->id,
'datasetdefinition', $datasetdef->id);
if ($datasetdef->category == 0) { // Question local dataset
delete_records('quiz_dataset_definitions',
delete_records('question_dataset_definitions',
'id', $datasetdef->id);
delete_records('quiz_dataset_items',
delete_records('question_dataset_items',
'definition', $datasetdef->id);
}
}
@ -281,7 +281,7 @@ class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
}
if (!$datasetdef->id = insert_record(
'quiz_dataset_definitions', $datasetdef)) {
'question_dataset_definitions', $datasetdef)) {
error("Unable to create dataset $defid");
}
@ -292,7 +292,7 @@ class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
// can manage to automatically take care of
// some possible realtime concurrence
if ($olderdatasetdefs = get_records_select(
'quiz_dataset_definitions',
'question_dataset_definitions',
"type = '$datasetdef->type'
AND name = '$datasetdef->name'
AND category = '$datasetdef->category'
@ -300,7 +300,7 @@ class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
ORDER BY id DESC")) {
while ($olderdatasetdef = array_shift($olderdatasetdefs)) {
delete_records('quiz_dataset_definitions',
delete_records('question_dataset_definitions',
'id', $datasetdef->id);
$datasetdef = $olderdatasetdef;
}
@ -311,7 +311,7 @@ class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
$questiondataset = new stdClass;
$questiondataset->question = $form->id;
$questiondataset->datasetdefinition = $datasetdef->id;
if (!insert_record('quiz_question_datasets',
if (!insert_record('question_datasets',
$questiondataset)) {
error("Unable to create relation to dataset $name");
}
@ -322,13 +322,13 @@ class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
// to datasets in other categories:
if (!empty($datasetdefinitions)) {
foreach ($datasetdefinitions as $def) {
delete_records('quiz_question_datasets',
delete_records('question_datasets',
'question', $form->id,
'datasetdefinition', $def->id);
if ($def->category == 0) { // Question local dataset
delete_records('quiz_dataset_definitions', 'id', $def->id);
delete_records('quiz_dataset_items',
delete_records('question_dataset_definitions', 'id', $def->id);
delete_records('question_dataset_items',
'definition', $def->id);
}
}
@ -455,9 +455,9 @@ class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
global $CFG;
if (!$dataset = get_records_sql(
"SELECT d.name, i.value
FROM {$CFG->prefix}quiz_dataset_definitions d,
{$CFG->prefix}quiz_dataset_items i,
{$CFG->prefix}quiz_question_datasets q
FROM {$CFG->prefix}question_dataset_definitions d,
{$CFG->prefix}question_dataset_items i,
{$CFG->prefix}question_datasets q
WHERE q.question = $question->id
AND q.datasetdefinition = d.id
AND d.id = i.definition
@ -528,8 +528,8 @@ class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
global $CFG;
$currentdatasetdef = get_record_sql(
"SELECT a.*
FROM {$CFG->prefix}quiz_dataset_definitions a,
{$CFG->prefix}quiz_question_datasets b
FROM {$CFG->prefix}question_dataset_definitions a,
{$CFG->prefix}question_datasets b
WHERE a.id = b.datasetdefinition
AND b.question = '$form->id'
AND a.name = '$name'")
@ -547,8 +547,8 @@ class quiz_dataset_dependent_questiontype extends quiz_default_questiontype {
// Construct question category options
$categorydatasetdefs = get_records_sql(
"SELECT a.type, a.id
FROM {$CFG->prefix}quiz_dataset_definitions a,
{$CFG->prefix}quiz_question_datasets b
FROM {$CFG->prefix}question_dataset_definitions a,
{$CFG->prefix}question_datasets b
WHERE a.id = b.datasetdefinition
AND a.category = '$form->category'
AND a.name = '$name'");

View File

@ -43,12 +43,12 @@
$definition->type = $form->type[$key];
if ($definition->id) {
if (!update_record('quiz_dataset_definitions', $definition)) {
if (!update_record('question_dataset_definitions', $definition)) {
notify("Could not update dataset item definition");
}
} else if ($definition->name) {
if (!insert_record('quiz_dataset_definitions', $definition)) {
if (!insert_record('question_dataset_definitions', $definition)) {
notify("Could not insert dataset item defintion");
}
@ -76,7 +76,7 @@
echo "<table cellpadding=\"5\">";
$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) {

View File

@ -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 ");
}

View File

@ -1,7 +1,7 @@
<?php // $Id$
if (!empty($question->id)) {
$options = get_record("quiz_essay", "question", "$question->id");
$options = get_record("question_essay", "question", "$question->id");
}
if (!empty($options->answer)) {

View File

@ -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();
?>

View File

@ -1,9 +1,9 @@
<?php // $Id$
if (!empty($question->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;

View File

@ -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();
?>

View File

@ -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;
}

View File

@ -1,7 +1,7 @@
<?php // $Id$
if (!empty($question->id)) {
$options = get_record("quiz_multichoice", "question", $question->id);
$options = get_record("question_multichoice", "question", $question->id);
} else {
$options->single = 1;
$options->shuffleanswers = 1;

View File

@ -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();
?>

View File

@ -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();
?>

View File

@ -1,6 +1,6 @@
<?php // $Id$
if (!empty($question->id)) {
$options = get_record("quiz_randomsamatch", "question", $question->id);
$options = get_record("question_randomsamatch", "question", $question->id);
} else {
$options->choose = "";
$options->shuffleanswers = 1;

View File

@ -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();
?>

View File

@ -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");
}

View File

@ -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('<b>'.get_string('url', 'quiz').':</b>',$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:<pre>';

View File

@ -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();
?>

View File

@ -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
*/

View File

@ -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.'&amp;sesskey='.sesskey().'&amp;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 = '<a title="' . $strinfo . '" href="types.php?info='.$server->id.'&amp;sesskey='.sesskey().'"><img src="'.$CFG->pixpath.'/i/info.gif" border="0" alt="'.$strinfo.'" align="absbottom" /></a>&nbsp;<a title="'.$strdelete.'" href="types.php?delete='.$server->id.'&amp;sesskey='.sesskey().'"><img src="../../../../pix/t/delete.gif" border="0" alt="'.$strdelete.'" /></a>';

View File

@ -1,6 +1,6 @@
<?php // $Id$
if (!empty($question->id)) {
$options = get_record("quiz_shortanswer", "question", $question->id);
$options = get_record("question_shortanswer", "question", $question->id);
} else {
$options->usecase = 0;
}

View File

@ -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();
?>

View File

@ -1,7 +1,7 @@
<?php // $Id$
if (!empty($question->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);

View File

@ -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();
?>