Some little fixes and more renaming to cleanly separate question code from quiz code
Renaming tables: quiz_answers -> question_answers quiz_categories -> question_categories Renaming functions: quiz_get_category_menu -> question_category_menu quiz_get_category_coursename -> question_category_coursename quiz_categorylist -> question_categorylist
This commit is contained in:
+24
-25
@@ -150,23 +150,25 @@ class cmoptions {
|
||||
/**
|
||||
* Deletes question and all associated data from the database
|
||||
*
|
||||
* TODO: remove quiz dependence
|
||||
*
|
||||
* @param object $question The question being deleted
|
||||
*/
|
||||
function delete_question($question) {
|
||||
global $QTYPES;
|
||||
$QTYPES[$question->qtype]->delete_question($question);
|
||||
delete_records("quiz_answers", "question", $question->id);
|
||||
delete_records("question_answers", "question", $question->id);
|
||||
delete_records("question_states", "question", $question->id);
|
||||
delete_records("question_sessions", "questionid", $question->id);
|
||||
if ($newversions = get_records('quiz_question_versions', 'oldquestion', $question->id)) {
|
||||
foreach ($newversions as $newversion) {
|
||||
$newquestion = get_record('quiz_questions', 'id', $newversion->newquestion);
|
||||
$newquestion = get_record('question', 'id', $newversion->newquestion);
|
||||
delete_question($newquestion);
|
||||
}
|
||||
delete_records("quiz_question_versions", "oldquestion", $question->id);
|
||||
}
|
||||
delete_records("quiz_question_versions", "newquestion", $question->id);
|
||||
if ($children = get_records('quiz_questions', 'parent', $question->id)) {
|
||||
if ($children = get_records('question', 'parent', $question->id)) {
|
||||
foreach ($children as $child) {
|
||||
delete_question($child);
|
||||
}
|
||||
@@ -217,7 +219,6 @@ function get_question_options(&$questions) {
|
||||
* created representing the start of a session and empty question
|
||||
* type specific information and responses are created by calling
|
||||
* {@link create_session_and_responses()}.
|
||||
* @todo Allow new attempt to be based on last attempt
|
||||
*
|
||||
* @return array An array of state objects representing the most recent
|
||||
* states of the question sessions.
|
||||
@@ -722,7 +723,7 @@ function question_isgradingevent($event) {
|
||||
function question_search_for_duplicate_responses(&$question, &$state) {
|
||||
// get all previously graded question states
|
||||
global $QTYPES;
|
||||
if (!$oldstates = get_records('quiz_question_states', "event = '" .
|
||||
if (!$oldstates = get_records('question_states', "event = '" .
|
||||
QUESTION_EVENTGRADE . "' AND " . "question = '" . $question->id .
|
||||
"'", 'seq_number DESC')) {
|
||||
return false;
|
||||
@@ -797,7 +798,7 @@ function question_apply_penalty_and_timelimit(&$question, &$state, $attempt, $cm
|
||||
function print_question_icon($question, $editlink=true, $return = false) {
|
||||
// returns a question icon
|
||||
|
||||
global $QUIZ_QUESTION_TYPE, $QTYPES, $CFG;
|
||||
global $QTYPES, $CFG;
|
||||
|
||||
$html = '<img border="0" height="16" width="16" src="'.$CFG->wwwroot.'/question/questiontypes/'.
|
||||
$QTYPES[$question->qtype]->name().'/icon.gif" alt="'.
|
||||
@@ -927,7 +928,7 @@ function get_question_responses($question, $state) {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the response given by the user in a particular attempt
|
||||
* Gets the response given by the user in a particular state
|
||||
*
|
||||
* Simply calls the question type specific get_actual_response() method.
|
||||
*/
|
||||
@@ -940,9 +941,7 @@ function get_question_actual_response($question, $state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the response given by the user in a particular attempt
|
||||
*
|
||||
* Simply calls the question type specific get_actual_response() method.
|
||||
* TODO: document this
|
||||
*/
|
||||
// ULPGc ecastro
|
||||
function get_question_fraction_grade($question, $state) {
|
||||
@@ -966,7 +965,7 @@ function get_question_fraction_grade($question, $state) {
|
||||
function get_default_question_category($courseid) {
|
||||
/// Returns the current category
|
||||
|
||||
if ($categories = get_records_select("quiz_categories", "course = '$courseid' AND parent = '0'", "id")) {
|
||||
if ($categories = get_records_select("question_categories", "course = '$courseid' AND parent = '0'", "id")) {
|
||||
foreach ($categories as $category) {
|
||||
return $category; // Return the first one (lowest id)
|
||||
}
|
||||
@@ -982,14 +981,14 @@ function get_default_question_category($courseid) {
|
||||
$category->publish = 0;
|
||||
$category->stamp = make_unique_id_code();
|
||||
|
||||
if (!$category->id = insert_record("quiz_categories", $category)) {
|
||||
if (!$category->id = insert_record("question_categories", $category)) {
|
||||
notify("Error creating a default category!");
|
||||
return false;
|
||||
}
|
||||
return $category;
|
||||
}
|
||||
|
||||
function quiz_get_category_menu($courseid, $published=false) {
|
||||
function question_category_menu($courseid, $published=false) {
|
||||
/// Returns the list of categories
|
||||
$publish = "";
|
||||
if ($published) {
|
||||
@@ -997,9 +996,9 @@ function quiz_get_category_menu($courseid, $published=false) {
|
||||
}
|
||||
|
||||
if (!isadmin()) {
|
||||
$categories = get_records_select("quiz_categories", "course = '$courseid' $publish", 'parent, sortorder, name ASC');
|
||||
$categories = get_records_select("question_categories", "course = '$courseid' $publish", 'parent, sortorder, name ASC');
|
||||
} else {
|
||||
$categories = get_records_select("quiz_categories", '', 'parent, sortorder, name ASC');
|
||||
$categories = get_records_select("question_categories", '', 'parent, sortorder, name ASC');
|
||||
}
|
||||
if (!$categories) {
|
||||
return false;
|
||||
@@ -1035,7 +1034,7 @@ function sort_categories_by_tree(&$categories, $id = 0, $level = 1) {
|
||||
if ($level == 1) {
|
||||
foreach ($keys as $key) {
|
||||
//If not processed and it's a good candidate to start (because its parent doesn't exist in the course)
|
||||
if (!isset($categories[$key]->processed) && !record_exists('quiz_categories', 'course', $categories[$key]->course, 'id', $categories[$key]->parent)) {
|
||||
if (!isset($categories[$key]->processed) && !record_exists('question_categories', 'course', $categories[$key]->course, 'id', $categories[$key]->parent)) {
|
||||
$children[$key] = $categories[$key];
|
||||
$categories[$key]->processed = true;
|
||||
$children = $children + sort_categories_by_tree($categories, $children[$key]->id, $level+1);
|
||||
@@ -1069,7 +1068,7 @@ function add_indented_names(&$categories, $id = 0, $indent = 0) {
|
||||
* Optionaly non editable categories may be excluded.
|
||||
* @author Howard Miller June '04
|
||||
*/
|
||||
function quiz_category_select_menu($courseid,$published=false,$only_editable=false,$selected="") {
|
||||
function question_category_select_menu($courseid,$published=false,$only_editable=false,$selected="") {
|
||||
|
||||
// get sql fragment for published
|
||||
$publishsql="";
|
||||
@@ -1077,14 +1076,14 @@ function quiz_category_select_menu($courseid,$published=false,$only_editable=fal
|
||||
$publishsql = "or publish=1";
|
||||
}
|
||||
|
||||
$categories = get_records_select("quiz_categories","course=$courseid $publishsql", 'parent, sortorder, name ASC');
|
||||
$categories = get_records_select("question_categories","course=$courseid $publishsql", 'parent, sortorder, name ASC');
|
||||
|
||||
$categories = add_indented_names($categories);
|
||||
|
||||
echo "<select name=\"category\">\n";
|
||||
foreach ($categories as $category) {
|
||||
$cid = $category->id;
|
||||
$cname = quiz_get_category_coursename($category, $courseid);
|
||||
$cname = question_category_coursename($category, $courseid);
|
||||
$seltxt = "";
|
||||
if ($cid==$selected) {
|
||||
$seltxt = "selected=\"selected\"";
|
||||
@@ -1096,7 +1095,7 @@ function quiz_category_select_menu($courseid,$published=false,$only_editable=fal
|
||||
echo "</select>\n";
|
||||
}
|
||||
|
||||
function quiz_get_category_coursename($category, $courseid = 0) {
|
||||
function question_category_coursename($category, $courseid = 0) {
|
||||
/// if the category is not from this course and is published , adds on the course
|
||||
/// name
|
||||
$cname = (isset($category->indentedname)) ? $category->indentedname : $category->name;
|
||||
@@ -1112,12 +1111,12 @@ function quiz_get_category_coursename($category, $courseid = 0) {
|
||||
/**
|
||||
* Returns a comma separated list of ids of the category and all subcategories
|
||||
*/
|
||||
function quiz_categorylist($categoryid) {
|
||||
function question_categorylist($categoryid) {
|
||||
// returns a comma separated list of ids of the category and all subcategories
|
||||
$categorylist = $categoryid;
|
||||
if ($subcategories = get_records('quiz_categories', 'parent', $categoryid, 'sortorder ASC', 'id, id')) {
|
||||
if ($subcategories = get_records('question_categories', 'parent', $categoryid, 'sortorder ASC', 'id, id')) {
|
||||
foreach ($subcategories as $subcategory) {
|
||||
$categorylist .= ','. quiz_categorylist($subcategory->id);
|
||||
$categorylist .= ','. question_categorylist($subcategory->id);
|
||||
}
|
||||
}
|
||||
return $categorylist;
|
||||
@@ -1145,7 +1144,7 @@ function get_questions_category( $category, $noparent=false ) {
|
||||
}
|
||||
|
||||
// get the list of questions for the category
|
||||
if ($questions = get_records_select("quiz_questions","category={$category->id} $npsql", "qtype, name ASC")) {
|
||||
if ($questions = get_records_select("question","category={$category->id} $npsql", "qtype, name ASC")) {
|
||||
|
||||
// iterate through questions, getting stuff we need
|
||||
foreach($questions as $question) {
|
||||
@@ -1166,7 +1165,7 @@ function get_questions_category( $category, $noparent=false ) {
|
||||
function get_import_export_formats( $type ) {
|
||||
|
||||
global $CFG;
|
||||
$fileformats = get_list_of_plugins("mod/quiz/format");
|
||||
$fileformats = get_list_of_plugins("question/format");
|
||||
|
||||
$fileformatname=array();
|
||||
require_once( "format.php" );
|
||||
|
||||
+30
-30
@@ -6,7 +6,7 @@
|
||||
//To see, put your terminal to 160cc
|
||||
|
||||
//
|
||||
// quiz quiz_categories
|
||||
// quiz question_categories
|
||||
// (CL,pk->id) (CL,pk->id)
|
||||
// | |
|
||||
// ------------------------------------------------------------------- |
|
||||
@@ -50,7 +50,7 @@
|
||||
// . |
|
||||
// . |
|
||||
// . | quiz_numerical_units
|
||||
// quiz_answers |--(CL,pk->id,fk->question)
|
||||
// question_answers |--(CL,pk->id,fk->question)
|
||||
// (CL,pk->id,fk->question)----------------------------------------------------------
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
@@ -68,7 +68,7 @@
|
||||
|
||||
//This module is special, because we make the backup in two steps:
|
||||
// 1.-We backup every category and their questions (complete structure). It includes this tables:
|
||||
// - quiz_categories
|
||||
// - question_categories
|
||||
// - question
|
||||
// - quiz_rqp
|
||||
// - quiz_truefalse
|
||||
@@ -80,7 +80,7 @@
|
||||
// - quiz_match
|
||||
// - quiz_match_sub
|
||||
// - quiz_calculated
|
||||
// - quiz_answers
|
||||
// - question_answers
|
||||
// - quiz_numerical_units
|
||||
// - quiz_question_datasets
|
||||
// - quiz_dataset_definitions
|
||||
@@ -122,7 +122,7 @@
|
||||
//Detect used categories (by category in questions)
|
||||
$status = execute_sql("INSERT INTO {$CFG->prefix}backup_ids
|
||||
(backup_code, table_name, old_id)
|
||||
SELECT DISTINCT $backup_unique_code,'quiz_categories',t.category
|
||||
SELECT DISTINCT $backup_unique_code,'question_categories',t.category
|
||||
FROM {$CFG->prefix}question t,
|
||||
{$CFG->prefix}quiz_question_instances g
|
||||
$from
|
||||
@@ -132,24 +132,24 @@
|
||||
$categories = get_records_sql("SELECT old_id, old_id
|
||||
FROM {$CFG->prefix}backup_ids
|
||||
WHERE backup_code = $backup_unique_code AND
|
||||
table_name = 'quiz_categories'");
|
||||
table_name = 'question_categories'");
|
||||
|
||||
if ($categories) {
|
||||
foreach ($categories as $category) {
|
||||
if ($dbcat = get_record('quiz_categories','id',$category->old_id)) {
|
||||
if ($dbcat = get_record('question_categories','id',$category->old_id)) {
|
||||
//echo $dbcat->name; //Debug
|
||||
//Go up to 0
|
||||
while ($dbcat->parent != 0) {
|
||||
//echo '->'; //Debug
|
||||
$current = $dbcat->id;
|
||||
if ($dbcat = get_record('quiz_categories','id',$dbcat->parent)) {
|
||||
if ($dbcat = get_record('question_categories','id',$dbcat->parent)) {
|
||||
//Found parent, add it to backup_ids (by using backup_putid
|
||||
//we ensure no duplicates!)
|
||||
$status = backup_putid($backup_unique_code,'quiz_categories',$dbcat->id,0);
|
||||
$status = backup_putid($backup_unique_code,'question_categories',$dbcat->id,0);
|
||||
//echo $dbcat->name; //Debug
|
||||
} else {
|
||||
//Parent not found, fix it (set its parent to 0)
|
||||
set_field ('quiz_categories','parent',0,'id',$current);
|
||||
set_field ('question_categories','parent',0,'id',$current);
|
||||
//echo 'assigned to top!'; //Debug
|
||||
}
|
||||
}
|
||||
@@ -180,8 +180,8 @@
|
||||
* Helper function adding the id of a category and all its descendents to the backup_ids
|
||||
*/
|
||||
function quiz_backup_add_category_tree($backup_unique_code, $categoryid) {
|
||||
$status = backup_putid($backup_unique_code,'quiz_categories',$categoryid,0);
|
||||
if ($subcategories = get_records('quiz_categories', 'parent', $categoryid, 'sortorder ASC', 'id, id')) {
|
||||
$status = backup_putid($backup_unique_code,'question_categories',$categoryid,0);
|
||||
if ($subcategories = get_records('question_categories', 'parent', $categoryid, 'sortorder ASC', 'id, id')) {
|
||||
foreach ($subcategories as $subcategory) {
|
||||
$status = quiz_backup_add_category_tree($backup_unique_code, $subcategory->id);
|
||||
}
|
||||
@@ -207,7 +207,7 @@
|
||||
g.question = t.id",false);
|
||||
if ($categories) {
|
||||
foreach ($categories as $key => $category) {
|
||||
$exist = get_record('quiz_categories','id', $key);
|
||||
$exist = get_record('question_categories','id', $key);
|
||||
//If the category doesn't exist
|
||||
if (!$exist) {
|
||||
//Build a new category
|
||||
@@ -217,7 +217,7 @@
|
||||
$db_cat->publish = 1;
|
||||
$db_cat->stamp = make_unique_id_code();
|
||||
//Insert the new category
|
||||
$catid = insert_record('quiz_categories',$db_cat);
|
||||
$catid = insert_record('question_categories',$db_cat);
|
||||
unset ($db_cat);
|
||||
if ($catid) {
|
||||
//Reasign orphaned questions to their new category
|
||||
@@ -244,7 +244,7 @@
|
||||
$status = true;
|
||||
|
||||
//First, we get the used categories from backup_ids
|
||||
$categories = quiz_category_ids_by_backup ($preferences->backup_unique_code);
|
||||
$categories = question_category_ids_by_backup ($preferences->backup_unique_code);
|
||||
|
||||
//If we've categories
|
||||
if ($categories) {
|
||||
@@ -254,8 +254,8 @@
|
||||
foreach ($categories as $cat) {
|
||||
//Start category
|
||||
$status = fwrite ($bf,start_tag("QUESTION_CATEGORY",3,true));
|
||||
//Get category data from quiz_categories
|
||||
$category = get_record ("quiz_categories","id",$cat->old_id);
|
||||
//Get category data from question_categories
|
||||
$category = get_record ("question_categories","id",$cat->old_id);
|
||||
//Print category contents
|
||||
fwrite($bf,full_tag("ID",4,false,$category->id));
|
||||
fwrite($bf,full_tag("NAME",4,false,$category->name));
|
||||
@@ -374,7 +374,7 @@
|
||||
fwrite ($bf,full_tag("FALSEANSWER",7,false,$truefalse->falseanswer));
|
||||
$status = fwrite ($bf,end_tag("TRUEFALSE",6,true));
|
||||
}
|
||||
//Now print quiz_answers
|
||||
//Now print question_answers
|
||||
$status = quiz_backup_answers($bf,$preferences,$question);
|
||||
}
|
||||
return $status;
|
||||
@@ -399,7 +399,7 @@
|
||||
fwrite ($bf,full_tag("USECASE",$level+1,false,$shortanswer->usecase));
|
||||
$status = fwrite ($bf,end_tag("SHORTANSWER",$level,true));
|
||||
}
|
||||
//Now print quiz_answers
|
||||
//Now print question_answers
|
||||
if ($include_answers) {
|
||||
$status = quiz_backup_answers($bf,$preferences,$question);
|
||||
}
|
||||
@@ -428,7 +428,7 @@
|
||||
fwrite ($bf,full_tag("SHUFFLEANSWERS",$level+1,false,$randomsamatch->shuffleanswers));
|
||||
$status = fwrite ($bf,end_tag("MULTICHOICE",$level,true));
|
||||
}
|
||||
//Now print quiz_answers
|
||||
//Now print question_answers
|
||||
if ($include_answers) {
|
||||
$status = quiz_backup_answers($bf,$preferences,$question);
|
||||
}
|
||||
@@ -507,7 +507,7 @@
|
||||
$status = quiz_backup_numerical_units($bf,$preferences,$question,7);
|
||||
$status = fwrite ($bf,end_tag("NUMERICAL",$level,true));
|
||||
}
|
||||
//Now print quiz_answers
|
||||
//Now print question_answers
|
||||
$status = quiz_backup_answers($bf,$preferences,$question);
|
||||
}
|
||||
return $status;
|
||||
@@ -537,7 +537,7 @@
|
||||
}
|
||||
//Print multianswers footer
|
||||
$status = fwrite ($bf,end_tag("MULTIANSWERS",6,true));
|
||||
//Now print quiz_answers
|
||||
//Now print question_answers
|
||||
$status = quiz_backup_answers($bf,$preferences,$question);
|
||||
}
|
||||
return $status;
|
||||
@@ -570,7 +570,7 @@
|
||||
//End calculated data
|
||||
$status = $status &&fwrite ($bf,end_tag("CALCULATED",$level,true));
|
||||
}
|
||||
//Now print quiz_answers
|
||||
//Now print question_answers
|
||||
if ($include_answers) {
|
||||
$status = quiz_backup_answers($bf,$preferences,$question);
|
||||
}
|
||||
@@ -622,7 +622,7 @@
|
||||
fwrite ($bf,full_tag("ANSWER",$level+1,false,$essay->answer));
|
||||
$status = fwrite ($bf,end_tag("ESSAY",$level,true));
|
||||
}
|
||||
//Now print quiz_answers
|
||||
//Now print question_answers
|
||||
$status = quiz_backup_answers($bf,$preferences,$question);
|
||||
}
|
||||
return $status;
|
||||
@@ -637,7 +637,7 @@
|
||||
|
||||
$status = true;
|
||||
|
||||
$answers = get_records("quiz_answers","question",$question,"id");
|
||||
$answers = get_records("question_answers","question",$question,"id");
|
||||
//If there are answers
|
||||
if ($answers) {
|
||||
$status = fwrite ($bf,start_tag("ANSWERS",6,true));
|
||||
@@ -1033,7 +1033,7 @@
|
||||
|
||||
//Categories
|
||||
$info[$instance->id.'1'][0] = get_string("categories","quiz");
|
||||
if ($ids = quiz_category_ids_by_backup ($backup_unique_code)) {
|
||||
if ($ids = question_category_ids_by_backup ($backup_unique_code)) {
|
||||
$info[$instance->id.'1'][1] = count($ids);
|
||||
} else {
|
||||
$info[$instance->id.'1'][1] = 0;
|
||||
@@ -1127,7 +1127,7 @@
|
||||
}
|
||||
//Categories
|
||||
$info[1][0] = get_string("categories","quiz");
|
||||
if ($ids = quiz_category_ids_by_backup ($backup_unique_code)) {
|
||||
if ($ids = question_category_ids_by_backup ($backup_unique_code)) {
|
||||
$info[1][1] = count($ids);
|
||||
} else {
|
||||
$info[1][1] = 0;
|
||||
@@ -1186,14 +1186,14 @@
|
||||
}
|
||||
|
||||
//Returns an array of categories id
|
||||
function quiz_category_ids_by_backup ($backup_unique_code) {
|
||||
function question_category_ids_by_backup ($backup_unique_code) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT a.old_id, a.backup_code
|
||||
FROM {$CFG->prefix}backup_ids a
|
||||
WHERE a.backup_code = '$backup_unique_code' AND
|
||||
a.table_name = 'quiz_categories'");
|
||||
a.table_name = 'question_categories'");
|
||||
}
|
||||
|
||||
function quiz_question_ids_by_backup ($backup_unique_code) {
|
||||
@@ -1205,7 +1205,7 @@
|
||||
{$CFG->prefix}question q
|
||||
WHERE a.backup_code = '$backup_unique_code' AND
|
||||
q.category = a.old_id AND
|
||||
a.table_name = 'quiz_categories'");
|
||||
a.table_name = 'question_categories'");
|
||||
}
|
||||
|
||||
function quiz_grade_ids_by_course ($course) {
|
||||
|
||||
@@ -9,7 +9,7 @@ function migrate2utf8_question_name($recordid){
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
FROM {$CFG->prefix}question_categories qc,
|
||||
{$CFG->prefix}question qq
|
||||
WHERE qc.id = qq.category
|
||||
AND qq.id = $recordid";
|
||||
@@ -58,7 +58,7 @@ function migrate2utf8_question_questiontext($recordid){
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
FROM {$CFG->prefix}question_categories qc,
|
||||
{$CFG->prefix}question qq
|
||||
WHERE qc.id = qq.category
|
||||
AND qq.id = $recordid";
|
||||
@@ -109,7 +109,7 @@ function migrate2utf8_quiz_numerical_units_unit($recordid){
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
FROM {$CFG->prefix}question_categories qc,
|
||||
{$CFG->prefix}question qq,
|
||||
{$CFG->prefix}quiz_numerical_units qnu
|
||||
WHERE qc.id = qq.category
|
||||
@@ -161,7 +161,7 @@ function migrate2utf8_quiz_match_sub_questiontext($recordid){
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
FROM {$CFG->prefix}question_categories qc,
|
||||
{$CFG->prefix}question qq,
|
||||
{$CFG->prefix}quiz_match_sub qms
|
||||
WHERE qc.id = qq.category
|
||||
@@ -213,7 +213,7 @@ function migrate2utf8_quiz_match_sub_answertext($recordid){
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
FROM {$CFG->prefix}question_categories qc,
|
||||
{$CFG->prefix}question qq,
|
||||
{$CFG->prefix}quiz_match_sub qms
|
||||
WHERE qc.id = qq.category
|
||||
@@ -255,7 +255,7 @@ function migrate2utf8_quiz_match_sub_answertext($recordid){
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_answers_answer($recordid){
|
||||
function migrate2utf8_question_answers_answer($recordid){
|
||||
global $CFG, $globallang;
|
||||
|
||||
/// Some trivial checks
|
||||
@@ -265,9 +265,9 @@ function migrate2utf8_quiz_answers_answer($recordid){
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
FROM {$CFG->prefix}question_categories qc,
|
||||
{$CFG->prefix}question qq,
|
||||
{$CFG->prefix}quiz_answers qa
|
||||
{$CFG->prefix}question_answers qa
|
||||
WHERE qc.id = qq.category
|
||||
AND qq.id = qa.question
|
||||
AND qa.id = $recordid";
|
||||
@@ -277,7 +277,7 @@ function migrate2utf8_quiz_answers_answer($recordid){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quizanswer= get_record('quiz_answers','id',$recordid)) {
|
||||
if (!$quizanswer= get_record('question_answers','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
@@ -301,13 +301,13 @@ function migrate2utf8_quiz_answers_answer($recordid){
|
||||
$newquizanswer = new object;
|
||||
$newquizanswer->id = $recordid;
|
||||
$newquizanswer->answer = $result;
|
||||
update_record('quiz_answers',$newquizanswer);
|
||||
update_record('question_answers',$newquizanswer);
|
||||
}
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_answers_feedback($recordid){
|
||||
function migrate2utf8_question_answers_feedback($recordid){
|
||||
global $CFG, $globallang;
|
||||
|
||||
/// Some trivial checks
|
||||
@@ -317,9 +317,9 @@ function migrate2utf8_quiz_answers_feedback($recordid){
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
FROM {$CFG->prefix}question_categories qc,
|
||||
{$CFG->prefix}question qq,
|
||||
{$CFG->prefix}quiz_answers qa
|
||||
{$CFG->prefix}question_answers qa
|
||||
WHERE qc.id = qq.category
|
||||
AND qq.id = qa.question
|
||||
AND qa.id = $recordid";
|
||||
@@ -329,7 +329,7 @@ function migrate2utf8_quiz_answers_feedback($recordid){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quizanswer= get_record('quiz_answers','id',$recordid)) {
|
||||
if (!$quizanswer= get_record('question_answers','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
@@ -353,7 +353,7 @@ function migrate2utf8_quiz_answers_feedback($recordid){
|
||||
$newquizanswer = new object;
|
||||
$newquizanswer->id = $recordid;
|
||||
$newquizanswer->feedback = $result;
|
||||
update_record('quiz_answers',$newquizanswer);
|
||||
update_record('question_answers',$newquizanswer);
|
||||
}
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
@@ -373,7 +373,7 @@ function migrate2utf8_quiz_dataset_definitions_name($recordid){
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
FROM {$CFG->prefix}question_categories qc,
|
||||
{$CFG->prefix}quiz_dataset_definitions qdd
|
||||
WHERE qc.id = qdd.category
|
||||
AND qdd.id = $recordid";
|
||||
@@ -413,7 +413,7 @@ function migrate2utf8_quiz_dataset_definitions_name($recordid){
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_categories_name($recordid){
|
||||
function migrate2utf8_question_categories_name($recordid){
|
||||
global $CFG, $globallang;
|
||||
|
||||
/// Some trivial checks
|
||||
@@ -423,7 +423,7 @@ function migrate2utf8_quiz_categories_name($recordid){
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc
|
||||
FROM {$CFG->prefix}question_categories qc
|
||||
WHERE qc.id = $recordid";
|
||||
|
||||
if (!$quiz = get_record_sql($SQL)) {
|
||||
@@ -431,7 +431,7 @@ function migrate2utf8_quiz_categories_name($recordid){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quizcategory = get_record('quiz_categories','id',$recordid)) {
|
||||
if (!$quizcategory = get_record('question_categories','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
@@ -455,13 +455,13 @@ function migrate2utf8_quiz_categories_name($recordid){
|
||||
$newquizcategory = new object;
|
||||
$newquizcategory->id = $recordid;
|
||||
$newquizcategory->name = $result;
|
||||
update_record('quiz_categories',$newquizcategory);
|
||||
update_record('question_categories',$newquizcategory);
|
||||
}
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_categories_info($recordid){
|
||||
function migrate2utf8_question_categories_info($recordid){
|
||||
global $CFG, $globallang;
|
||||
|
||||
/// Some trivial checks
|
||||
@@ -471,7 +471,7 @@ function migrate2utf8_quiz_categories_info($recordid){
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc
|
||||
FROM {$CFG->prefix}question_categories qc
|
||||
WHERE qc.id = $recordid";
|
||||
|
||||
if (!$quiz = get_record_sql($SQL)) {
|
||||
@@ -479,7 +479,7 @@ function migrate2utf8_quiz_categories_info($recordid){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quizcategory = get_record('quiz_categories','id',$recordid)) {
|
||||
if (!$quizcategory = get_record('question_categories','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
@@ -503,7 +503,7 @@ function migrate2utf8_quiz_categories_info($recordid){
|
||||
$newquizcategory = new object;
|
||||
$newquizcategory->id = $recordid;
|
||||
$newquizcategory->info = $result;
|
||||
update_record('quiz_categories',$newquizcategory);
|
||||
update_record('question_categories',$newquizcategory);
|
||||
}
|
||||
/// And finally, just return the converted field
|
||||
|
||||
|
||||
@@ -136,16 +136,16 @@
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_answers">
|
||||
<TABLE name="question_answers">
|
||||
<FIELDS>
|
||||
<FIELD name="answer" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_answers_answer(RECORDID)
|
||||
migrate2utf8_question_answers_answer(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="feedback" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_answers_feedback(RECORDID)
|
||||
migrate2utf8_question_answers_feedback(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
@@ -186,16 +186,16 @@
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_categories">
|
||||
<TABLE name="question_categories">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_categories_name(RECORDID)
|
||||
migrate2utf8_question_categories_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="info" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_categories_info(RECORDID)
|
||||
migrate2utf8_question_categories_info(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="stamp" method="NO_CONV" type="varchar" length="255" />
|
||||
|
||||
@@ -945,6 +945,11 @@ function quiz_upgrade($oldversion) {
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}quiz_states RENAME {$CFG->prefix}question_states", false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2006022800) {
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}quiz_answers RENAME {$CFG->prefix}question_answers", false);
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}quiz_categories RENAME {$CFG->prefix}question_categories", false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,10 +51,10 @@ CREATE TABLE prefix_quiz (
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `prefix_quiz_answers`
|
||||
-- Table structure for table `prefix_question_answers`
|
||||
--
|
||||
|
||||
CREATE TABLE prefix_quiz_answers (
|
||||
CREATE TABLE prefix_question_answers (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
question int(10) unsigned NOT NULL default '0',
|
||||
answer text NOT NULL default '',
|
||||
@@ -125,10 +125,10 @@ CREATE TABLE prefix_quiz_calculated (
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `prefix_quiz_categories`
|
||||
-- Table structure for table `prefix_question_categories`
|
||||
--
|
||||
|
||||
CREATE TABLE prefix_quiz_categories (
|
||||
CREATE TABLE prefix_question_categories (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
course int(10) unsigned NOT NULL default '0',
|
||||
name varchar(255) NOT NULL default '',
|
||||
|
||||
@@ -1044,6 +1044,24 @@ function quiz_upgrade($oldversion) {
|
||||
execute_sql('ALTER TABLE '.$CFG->prefix.'question_sessions ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_sessions_id_seq\')',false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2006030101) {
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}quiz_questions RENAME {$CFG->prefix}question", false);
|
||||
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_questions_id_seq RENAME TO '.$CFG->prefix.'question_id_seq',false);
|
||||
execute_sql('ALTER TABLE '.$CFG->prefix.'question ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_id_seq\')',false);
|
||||
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}quiz_states RENAME {$CFG->prefix}question_states", false);
|
||||
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states_id_seq RENAME TO '.$CFG->prefix.'question_states_id_seq',false);
|
||||
execute_sql('ALTER TABLE '.$CFG->prefix.'question_states ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_states_id_seq\')',false);
|
||||
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}quiz_answers RENAME {$CFG->prefix}question_answers", false);
|
||||
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_answers_id_seq RENAME TO '.$CFG->prefix.'question_answers_id_seq',false);
|
||||
execute_sql('ALTER TABLE '.$CFG->prefix.'question_answers ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_answers_id_seq\')',false);
|
||||
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}quiz_categories RENAME {$CFG->prefix}question_categories", false);
|
||||
execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_categories_id_seq RENAME TO '.$CFG->prefix.'question_categories_id_seq',false);
|
||||
execute_sql('ALTER TABLE '.$CFG->prefix.'question_categories ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_categories_id_seq\')',false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,10 @@ CREATE INDEX prefix_quiz_course_idx ON prefix_quiz (course);
|
||||
# --------------------------------------------------------
|
||||
|
||||
#
|
||||
# Table structure for table prefix_quiz_answers
|
||||
# Table structure for table prefix_question_answers
|
||||
#
|
||||
|
||||
CREATE TABLE prefix_quiz_answers (
|
||||
CREATE TABLE prefix_question_answers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
question integer NOT NULL default '0',
|
||||
answer text NOT NULL default '',
|
||||
@@ -59,7 +59,7 @@ CREATE TABLE prefix_quiz_answers (
|
||||
feedback text NOT NULL default ''
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_quiz_answers_question_idx ON prefix_quiz_answers (question);
|
||||
CREATE INDEX prefix_question_answers_question_idx ON prefix_question_answers (question);
|
||||
|
||||
|
||||
# --------------------------------------------------------
|
||||
@@ -121,10 +121,10 @@ CREATE INDEX prefix_quiz_calculated_answer_idx ON prefix_quiz_calculated (answer
|
||||
# --------------------------------------------------------
|
||||
|
||||
#
|
||||
# Table structure for table prefix_quiz_categories
|
||||
# Table structure for table prefix_question_categories
|
||||
#
|
||||
|
||||
CREATE TABLE prefix_quiz_categories (
|
||||
CREATE TABLE prefix_question_categories (
|
||||
id SERIAL PRIMARY KEY,
|
||||
course integer NOT NULL default '0',
|
||||
name varchar(255) NOT NULL default '',
|
||||
@@ -135,7 +135,7 @@ CREATE TABLE prefix_quiz_categories (
|
||||
sortorder integer NOT NULL default '999'
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_quiz_categories_course_idx ON prefix_quiz_categories (course);
|
||||
CREATE INDEX prefix_question_categories_course_idx ON prefix_question_categories (course);
|
||||
|
||||
# --------------------------------------------------------
|
||||
#
|
||||
|
||||
+2
-2
@@ -176,7 +176,7 @@ if (self.name == 'editquestion') {
|
||||
$categoryid = required_param('categoryid', PARAM_INT);
|
||||
$randomcount = required_param('randomcount', PARAM_INT);
|
||||
// load category
|
||||
if (! $category = get_record('quiz_categories', 'id', $categoryid)) {
|
||||
if (! $category = get_record('question_categories', 'id', $categoryid)) {
|
||||
error('Category ID is incorrect');
|
||||
}
|
||||
// find existing random questions in this category
|
||||
@@ -295,7 +295,7 @@ if (self.name == 'editquestion') {
|
||||
|
||||
/// all commands have been dealt with, now print the page
|
||||
|
||||
if (empty($modform->category) or !record_exists('quiz_categories', 'id', $modform->category)) {
|
||||
if (empty($modform->category) or !record_exists('question_categories', 'id', $modform->category)) {
|
||||
$category = get_default_question_category($course->id);
|
||||
$modform->category = $category->id;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ function quiz_print_question_list($quiz, $allowdelete=true, $showbreaks=true, $r
|
||||
|
||||
if (!$questions = get_records_sql("SELECT q.*,c.course
|
||||
FROM {$CFG->prefix}question q,
|
||||
{$CFG->prefix}quiz_categories c
|
||||
{$CFG->prefix}question_categories c
|
||||
WHERE q.id in ($quiz->questions)
|
||||
AND q.category = c.id")) {
|
||||
echo "<p align=\"center\">";
|
||||
|
||||
@@ -255,7 +255,7 @@
|
||||
// get the essay questions
|
||||
$questionlist = quiz_questions_in_quiz($quiz->questions);
|
||||
$sql = "SELECT q.*, i.grade AS maxgrade, i.id AS instance".
|
||||
" FROM {$CFG->prefix}quiz_questions q,".
|
||||
" FROM {$CFG->prefix}question q,".
|
||||
" {$CFG->prefix}quiz_question_instances i".
|
||||
" WHERE i.quiz = '$quiz->id' AND q.id = i.question".
|
||||
" AND q.id IN ($questionlist)".
|
||||
|
||||
+6
-6
@@ -287,7 +287,7 @@ function quiz_delete_course($course, $feedback=true) {
|
||||
$strcatmoved = get_string('usedcategorymoved', 'quiz');
|
||||
$strcatdeleted = get_string('unusedcategorydeleted', 'quiz');
|
||||
|
||||
if ($categories = get_records('quiz_categories', 'course', $course->id, 'parent', 'id, parent, name, course')) {
|
||||
if ($categories = get_records('question_categories', 'course', $course->id, 'parent', 'id, parent, name, course')) {
|
||||
require_once("locallib.php");
|
||||
//Sort categories following their tree (parent-child) relationships
|
||||
$categories = sort_categories_by_tree($categories);
|
||||
@@ -295,7 +295,7 @@ function quiz_delete_course($course, $feedback=true) {
|
||||
foreach ($categories as $cat) {
|
||||
|
||||
//Get the full record
|
||||
$category = get_record('quiz_categories', 'id', $cat->id);
|
||||
$category = get_record('question_categories', 'id', $cat->id);
|
||||
|
||||
//Check if the category is being used anywhere
|
||||
if($usedbyquiz = quizzes_category_used($category->id,true)) {
|
||||
@@ -310,7 +310,7 @@ function quiz_delete_course($course, $feedback=true) {
|
||||
$concat->info = $concat->name;
|
||||
$concat->publish = 1;
|
||||
$concat->stamp = make_unique_id_code();
|
||||
$concatid = insert_record('quiz_categories', $concat);
|
||||
$concatid = insert_record('question_categories', $concat);
|
||||
|
||||
//Fill feedback
|
||||
$feedbackdata[] = array($concat->name, $strcatcontainer);
|
||||
@@ -324,7 +324,7 @@ function quiz_delete_course($course, $feedback=true) {
|
||||
//If it's being used, its publish field should be 1
|
||||
$category->publish = 1;
|
||||
//Let's update it
|
||||
update_record('quiz_categories', $category);
|
||||
update_record('question_categories', $category);
|
||||
|
||||
//Save this parent change for future use
|
||||
$parentchanged[$category->id] = $category->parent;
|
||||
@@ -343,7 +343,7 @@ function quiz_delete_course($course, $feedback=true) {
|
||||
delete_records("question", "category", $category->id);
|
||||
}
|
||||
//delete the category
|
||||
delete_records('quiz_categories', 'id', $category->id);
|
||||
delete_records('question_categories', 'id', $category->id);
|
||||
|
||||
//Save this parent change for future use
|
||||
if (!empty($category->parent)) {
|
||||
@@ -353,7 +353,7 @@ function quiz_delete_course($course, $feedback=true) {
|
||||
}
|
||||
|
||||
//Update all its child categories to re-parent them to grandparent.
|
||||
set_field ('quiz_categories', 'parent', $parentchanged[$category->id], 'parent', $category->id);
|
||||
set_field ('question_categories', 'parent', $parentchanged[$category->id], 'parent', $category->id);
|
||||
|
||||
//Fill feedback
|
||||
$feedbackdata[] = array($category->name, $strcatdeleted);
|
||||
|
||||
@@ -562,7 +562,7 @@ function quizzes_category_used($id, $recursive = false) {
|
||||
|
||||
//Look under child categories recursively
|
||||
if ($recursive) {
|
||||
if ($childs = get_records('quiz_categories', 'parent', $id)) {
|
||||
if ($childs = get_records('question_categories', 'parent', $id)) {
|
||||
foreach ($childs as $child) {
|
||||
$quizlist = $quizlist + quizzes_category_used($child->id, $recursive);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
error('No valid arguments supplied');
|
||||
}
|
||||
|
||||
if (!($questioncategory = get_record('quiz_categories', 'id', $question->category))) {
|
||||
if (!($questioncategory = get_record('question_categories', 'id', $question->category))) {
|
||||
error('No valid arguments supplied');
|
||||
}
|
||||
|
||||
|
||||
+30
-30
@@ -14,7 +14,7 @@
|
||||
//To see, put your terminal to 160cc
|
||||
|
||||
//
|
||||
// quiz quiz_categories
|
||||
// quiz question_categories
|
||||
// (CL,pk->id) (CL,pk->id)
|
||||
// | |
|
||||
// ------------------------------------------------------------------- |
|
||||
@@ -58,7 +58,7 @@
|
||||
// . |
|
||||
// . |
|
||||
// . | quiz_numerical_units
|
||||
// quiz_answers |--(CL,pk->id,fk->question)
|
||||
// question_answers |--(CL,pk->id,fk->question)
|
||||
// (CL,pk->id,fk->question)----------------------------------------------------------
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
@@ -74,7 +74,7 @@
|
||||
// Comments
|
||||
//This module is special, because we make the restore in two steps:
|
||||
// 1.-We restore every category and their questions (complete structure). It includes this tables:
|
||||
// - quiz_categories
|
||||
// - question_categories
|
||||
// - question
|
||||
// - quiz_truefalse
|
||||
// - quiz_shortanswer
|
||||
@@ -85,7 +85,7 @@
|
||||
// - quiz_match
|
||||
// - quiz_match_sub
|
||||
// - quiz_calculated
|
||||
// - quiz_answers
|
||||
// - question_answers
|
||||
// - quiz_numerical_units
|
||||
// - quiz_question_datasets
|
||||
// - quiz_dataset_definitions
|
||||
@@ -117,7 +117,7 @@
|
||||
}
|
||||
|
||||
//Get record from backup_ids
|
||||
$data = backup_getid($restore->backup_unique_code,"quiz_categories",$category->id);
|
||||
$data = backup_getid($restore->backup_unique_code,"question_categories",$category->id);
|
||||
|
||||
if ($data) {
|
||||
//Now get completed xmlized object
|
||||
@@ -126,7 +126,7 @@
|
||||
//print_object ($GLOBALS['traverse_array']); //Debug
|
||||
//$GLOBALS['traverse_array']=""; //Debug
|
||||
|
||||
//Now, build the QUIZ_CATEGORIES record structure
|
||||
//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']['#']);
|
||||
@@ -135,13 +135,13 @@
|
||||
$quiz_cat->parent = backup_todb($info['QUESTION_CATEGORY']['#']['PARENT']['0']['#']);
|
||||
$quiz_cat->sortorder = backup_todb($info['QUESTION_CATEGORY']['#']['SORTORDER']['0']['#']);
|
||||
|
||||
if ($catfound = restore_get_best_quiz_category($quiz_cat, $restore->course)) {
|
||||
if ($catfound = restore_get_best_question_category($quiz_cat, $restore->course)) {
|
||||
$newid = $catfound;
|
||||
} else {
|
||||
if (!$quiz_cat->stamp) {
|
||||
$quiz_cat->stamp = make_unique_id_code();
|
||||
}
|
||||
$newid = insert_record ("quiz_categories",$quiz_cat);
|
||||
$newid = insert_record ("question_categories",$quiz_cat);
|
||||
}
|
||||
|
||||
//Do some output
|
||||
@@ -161,7 +161,7 @@
|
||||
//Here category has been created or selected, so save results in backup_ids and start with questions
|
||||
if ($newid and $status) {
|
||||
//We have the newid, update backup_ids
|
||||
backup_putid($restore->backup_unique_code,"quiz_categories",
|
||||
backup_putid($restore->backup_unique_code,"question_categories",
|
||||
$category->id, $newid);
|
||||
//Now restore question
|
||||
$status = quiz_restore_questions ($category->id, $newid,$info,$restore);
|
||||
@@ -260,7 +260,7 @@
|
||||
|
||||
//If it's a new question in the DB, restore it
|
||||
if ($restored_questions[$i]->is_new) {
|
||||
//Now, restore every quiz_answers in this question
|
||||
//Now, restore every question_answers in this question
|
||||
$status = quiz_restore_answers($oldid,$newid,$que_info,$restore);
|
||||
//Now, depending of the type of questions, invoke different functions
|
||||
if ($question->qtype == "1") {
|
||||
@@ -289,7 +289,7 @@
|
||||
$status = quiz_restore_essay($oldid,$newid,$que_info,$restore);
|
||||
}
|
||||
} else {
|
||||
//We are NOT creating the question, but we need to know every quiz_answers
|
||||
//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);
|
||||
@@ -353,14 +353,14 @@
|
||||
//We'll need this later!!
|
||||
$oldid = backup_todb($ans_info['#']['ID']['0']['#']);
|
||||
|
||||
//Now, build the QUIZ_ANSWERS record structure
|
||||
//Now, build the question_answers record structure
|
||||
$answer->question = $new_question_id;
|
||||
$answer->answer = backup_todb($ans_info['#']['ANSWER_TEXT']['0']['#']);
|
||||
$answer->fraction = backup_todb($ans_info['#']['FRACTION']['0']['#']);
|
||||
$answer->feedback = backup_todb($ans_info['#']['FEEDBACK']['0']['#']);
|
||||
|
||||
//The structure is equal to the db, so insert the quiz_answers
|
||||
$newid = insert_record ("quiz_answers",$answer);
|
||||
//The structure is equal to the db, so insert the question_answers
|
||||
$newid = insert_record ("question_answers",$answer);
|
||||
|
||||
//Do some output
|
||||
if (($i+1) % 50 == 0) {
|
||||
@@ -375,7 +375,7 @@
|
||||
|
||||
if ($newid) {
|
||||
//We have the newid, update backup_ids
|
||||
backup_putid($restore->backup_unique_code,"quiz_answers",$oldid,
|
||||
backup_putid($restore->backup_unique_code,"question_answers",$oldid,
|
||||
$newid);
|
||||
} else {
|
||||
$status = false;
|
||||
@@ -409,7 +409,7 @@
|
||||
//We'll need this later!!
|
||||
$oldid = backup_todb($ans_info['#']['ID']['0']['#']);
|
||||
|
||||
//Now, build the QUIZ_ANSWERS record structure
|
||||
//Now, build the question_answers record structure
|
||||
$answer->question = $new_question_id;
|
||||
$answer->answer = backup_todb($ans_info['#']['ANSWER_TEXT']['0']['#']);
|
||||
$answer->fraction = backup_todb($ans_info['#']['FRACTION']['0']['#']);
|
||||
@@ -421,7 +421,7 @@
|
||||
//mappings in backup_ids to use them later where restoring states (user level).
|
||||
|
||||
//Get the answer from DB (by question and answer)
|
||||
$db_answer = get_record ("quiz_answers","question",$new_question_id,
|
||||
$db_answer = get_record ("question_answers","question",$new_question_id,
|
||||
"answer",$answer->answer);
|
||||
|
||||
//Do some output
|
||||
@@ -437,7 +437,7 @@
|
||||
|
||||
if ($db_answer) {
|
||||
//We have the database answer, update backup_ids
|
||||
backup_putid($restore->backup_unique_code,"quiz_answers",$oldid,
|
||||
backup_putid($restore->backup_unique_code,"question_answers",$oldid,
|
||||
$db_answer->id);
|
||||
} else {
|
||||
$status = false;
|
||||
@@ -475,7 +475,7 @@
|
||||
$tok = strtok($shortanswer->answers,",");
|
||||
while ($tok) {
|
||||
//Get the answer from backup_ids
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$tok);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$tok);
|
||||
if ($answer) {
|
||||
if ($in_first) {
|
||||
$answers_field .= $answer->new_id;
|
||||
@@ -534,13 +534,13 @@
|
||||
$truefalse->falseanswer = backup_todb($tru_info['#']['FALSEANSWER']['0']['#']);
|
||||
|
||||
////We have to recode the trueanswer field
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$truefalse->trueanswer);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$truefalse->trueanswer);
|
||||
if ($answer) {
|
||||
$truefalse->trueanswer = $answer->new_id;
|
||||
}
|
||||
|
||||
////We have to recode the falseanswer field
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$truefalse->falseanswer);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$truefalse->falseanswer);
|
||||
if ($answer) {
|
||||
$truefalse->falseanswer = $answer->new_id;
|
||||
}
|
||||
@@ -597,7 +597,7 @@
|
||||
$tok = strtok($multichoice->answers,",");
|
||||
while ($tok) {
|
||||
//Get the answer from backup_ids
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$tok);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$tok);
|
||||
if ($answer) {
|
||||
if ($in_first) {
|
||||
$answers_field .= $answer->new_id;
|
||||
@@ -889,7 +889,7 @@
|
||||
$numerical->tolerance = backup_todb($num_info['#']['TOLERANCE']['0']['#']);
|
||||
|
||||
////We have to recode the answer field
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$numerical->answer);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$numerical->answer);
|
||||
if ($answer) {
|
||||
$numerical->answer = $answer->new_id;
|
||||
}
|
||||
@@ -944,7 +944,7 @@
|
||||
$calculated->correctanswerformat = backup_todb($cal_info['#']['CORRECTANSWERFORMAT']['0']['#']);
|
||||
|
||||
////We have to recode the answer field
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$calculated->answer);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$calculated->answer);
|
||||
if ($answer) {
|
||||
$calculated->answer = $answer->new_id;
|
||||
}
|
||||
@@ -1128,7 +1128,7 @@
|
||||
$essay->answer = backup_todb($essay_info['#']['ANSWER']['0']['#']);
|
||||
|
||||
////We have to recode the answer field
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$essay->answer);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$essay->answer);
|
||||
if ($answer) {
|
||||
$essay->answer = $answer->new_id;
|
||||
}
|
||||
@@ -1210,7 +1210,7 @@
|
||||
|
||||
//We have to recode the category field (only if the category != 0)
|
||||
if ($dataset_definition->category != 0) {
|
||||
$category = backup_getid($restore->backup_unique_code,"quiz_categories",$dataset_definition->category);
|
||||
$category = backup_getid($restore->backup_unique_code,"question_categories",$dataset_definition->category);
|
||||
if ($category) {
|
||||
$dataset_definition->category = $category->new_id;
|
||||
}
|
||||
@@ -1663,7 +1663,7 @@
|
||||
break;
|
||||
case 2: //TRUEFALSE QTYPE
|
||||
//The answer is one answer id. We must recode it
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$state->answer);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$state->answer);
|
||||
if ($answer) {
|
||||
$state->answer = $answer->new_id;
|
||||
}
|
||||
@@ -1675,7 +1675,7 @@
|
||||
$tok = strtok($state->answer,",");
|
||||
while ($tok) {
|
||||
//Get the answer from backup_ids
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$tok);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$tok);
|
||||
if ($answer) {
|
||||
if ($in_first) {
|
||||
$answer_field .= $answer->new_id;
|
||||
@@ -1740,7 +1740,7 @@
|
||||
//Get the question from backup_ids
|
||||
$que = backup_getid($restore->backup_unique_code,"question",$question_id);
|
||||
//Get the answer from backup_ids
|
||||
$ans = backup_getid($restore->backup_unique_code,"quiz_answers",$answer_id);
|
||||
$ans = backup_getid($restore->backup_unique_code,"question_answers",$answer_id);
|
||||
if ($que) {
|
||||
//It the question hasn't response, it must be 0
|
||||
if (!$ans and $answer_id == 0) {
|
||||
@@ -1787,7 +1787,7 @@
|
||||
} else if ($mul_db->answertype == "3") {
|
||||
//Multichoice
|
||||
//The answer is an answer_id, look for it in backup_ids
|
||||
$ans = backup_getid($restore->backup_unique_code,"quiz_answers",$answer);
|
||||
$ans = backup_getid($restore->backup_unique_code,"question_answers",$answer);
|
||||
$answer = $ans->new_id;
|
||||
} else if ($mul_db->answertype == "8") {
|
||||
//Numeric
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
//This is the "graphical" structure of the quiz mod:
|
||||
//
|
||||
// quiz quiz_categories
|
||||
// quiz question_categories
|
||||
// (CL,pk->id) (CL,pk->id)
|
||||
// | |
|
||||
// ------------------------------------------------------------------- |
|
||||
@@ -48,7 +48,7 @@
|
||||
// . |
|
||||
// . |
|
||||
// . | quiz_numerical_units
|
||||
// quiz_answers |--(CL,pl->id,fk->question)
|
||||
// question_answers |--(CL,pl->id,fk->question)
|
||||
// (CL,pk->id,fk->question)----------------------------------------------------------
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
@@ -62,7 +62,7 @@
|
||||
|
||||
//This module is special, because we make the restore in two steps:
|
||||
// 1.-We restore every category and their questions (complete structure). It includes this tables:
|
||||
// - quiz_categories
|
||||
// - question_categories
|
||||
// - question
|
||||
// - quiz_truefalse
|
||||
// - quiz_shortanswer
|
||||
@@ -73,7 +73,7 @@
|
||||
// - quiz_match
|
||||
// - quiz_match_sub
|
||||
// - quiz_calculated
|
||||
// - quiz_answers
|
||||
// - question_answers
|
||||
// - quiz_numerical_units
|
||||
// - quiz_question_datasets
|
||||
// - quiz_dataset_definitions
|
||||
@@ -103,7 +103,7 @@
|
||||
$status = true;
|
||||
|
||||
//Get record from backup_ids
|
||||
$data = backup_getid($restore->backup_unique_code,"quiz_categories",$category->id);
|
||||
$data = backup_getid($restore->backup_unique_code,"question_categories",$category->id);
|
||||
|
||||
if ($data) {
|
||||
//Now get completed xmlized object
|
||||
@@ -112,7 +112,7 @@
|
||||
//print_object ($GLOBALS['traverse_array']); //Debug
|
||||
//$GLOBALS['traverse_array']=""; //Debug
|
||||
|
||||
//Now, build the QUIZ_CATEGORIES record structure
|
||||
//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']['#']);
|
||||
@@ -121,13 +121,13 @@
|
||||
$quiz_cat->parent = backup_todb($info['QUESTION_CATEGORY']['#']['PARENT']['0']['#']);
|
||||
$quiz_cat->sortorder = backup_todb($info['QUESTION_CATEGORY']['#']['SORTORDER']['0']['#']);
|
||||
|
||||
if ($catfound = restore_get_best_quiz_category($quiz_cat, $restore->course_id)) {
|
||||
if ($catfound = restore_get_best_question_category($quiz_cat, $restore->course_id)) {
|
||||
$newid = $catfound;
|
||||
} else {
|
||||
if (!$quiz_cat->stamp) {
|
||||
$quiz_cat->stamp = make_unique_id_code();
|
||||
}
|
||||
$newid = insert_record ("quiz_categories",$quiz_cat);
|
||||
$newid = insert_record ("question_categories",$quiz_cat);
|
||||
}
|
||||
|
||||
//Do some output
|
||||
@@ -147,7 +147,7 @@
|
||||
//Here category has been created or selected, so save results in backup_ids and start with questions
|
||||
if ($newid and $status) {
|
||||
//We have the newid, update backup_ids
|
||||
backup_putid($restore->backup_unique_code,"quiz_categories",
|
||||
backup_putid($restore->backup_unique_code,"question_categories",
|
||||
$category->id, $newid);
|
||||
//Now restore question
|
||||
$status = quiz_restore_pre15_questions ($category->id, $newid,$info,$restore);
|
||||
@@ -269,7 +269,7 @@
|
||||
}
|
||||
//If it's a new question in the DB, restore it
|
||||
if ($creatingnewquestion) {
|
||||
//Now, restore every quiz_answers in this question
|
||||
//Now, restore every question_answers in this question
|
||||
$status = quiz_restore_pre15_answers($oldid,$newid,$que_info,$restore);
|
||||
//Now, depending of the type of questions, invoke different functions
|
||||
if ($question->qtype == "1") {
|
||||
@@ -294,7 +294,7 @@
|
||||
$status = quiz_restore_pre15_calculated($oldid,$newid,$que_info,$restore);
|
||||
}
|
||||
} else {
|
||||
//We are NOT creating the question, but we need to know every quiz_answers
|
||||
//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 responses
|
||||
//in each attempt.
|
||||
$status = quiz_restore_pre15_map_answers($oldid,$newid,$que_info,$restore);
|
||||
@@ -347,14 +347,14 @@
|
||||
//We'll need this later!!
|
||||
$oldid = backup_todb($ans_info['#']['ID']['0']['#']);
|
||||
|
||||
//Now, build the QUIZ_ANSWERS record structure
|
||||
//Now, build the question_answers record structure
|
||||
$answer->question = $new_question_id;
|
||||
$answer->answer = backup_todb($ans_info['#']['ANSWER_TEXT']['0']['#']);
|
||||
$answer->fraction = backup_todb($ans_info['#']['FRACTION']['0']['#']);
|
||||
$answer->feedback = backup_todb($ans_info['#']['FEEDBACK']['0']['#']);
|
||||
|
||||
//The structure is equal to the db, so insert the quiz_answers
|
||||
$newid = insert_record ("quiz_answers",$answer);
|
||||
//The structure is equal to the db, so insert the question_answers
|
||||
$newid = insert_record ("question_answers",$answer);
|
||||
|
||||
//Do some output
|
||||
if (($i+1) % 50 == 0) {
|
||||
@@ -369,7 +369,7 @@
|
||||
|
||||
if ($newid) {
|
||||
//We have the newid, update backup_ids
|
||||
backup_putid($restore->backup_unique_code,"quiz_answers",$oldid,
|
||||
backup_putid($restore->backup_unique_code,"question_answers",$oldid,
|
||||
$newid);
|
||||
} else {
|
||||
$status = false;
|
||||
@@ -403,7 +403,7 @@
|
||||
//We'll need this later!!
|
||||
$oldid = backup_todb($ans_info['#']['ID']['0']['#']);
|
||||
|
||||
//Now, build the QUIZ_ANSWERS record structure
|
||||
//Now, build the question_answers record structure
|
||||
$answer->question = $new_question_id;
|
||||
$answer->answer = backup_todb($ans_info['#']['ANSWER_TEXT']['0']['#']);
|
||||
$answer->fraction = backup_todb($ans_info['#']['FRACTION']['0']['#']);
|
||||
@@ -415,7 +415,7 @@
|
||||
//mappings in backup_ids to use them later where restoring responses (user level).
|
||||
|
||||
//Get the answer from DB (by question, answer and fraction)
|
||||
$db_answer = get_record ("quiz_answers","question",$new_question_id,
|
||||
$db_answer = get_record ("question_answers","question",$new_question_id,
|
||||
"answer",$answer->answer,
|
||||
"fraction",$answer->fraction);
|
||||
|
||||
@@ -432,7 +432,7 @@
|
||||
|
||||
if ($db_answer) {
|
||||
//We have the database answer, update backup_ids
|
||||
backup_putid($restore->backup_unique_code,"quiz_answers",$oldid,
|
||||
backup_putid($restore->backup_unique_code,"question_answers",$oldid,
|
||||
$db_answer->id);
|
||||
} else {
|
||||
$status = false;
|
||||
@@ -470,7 +470,7 @@
|
||||
$tok = strtok($shortanswer->answers,",");
|
||||
while ($tok) {
|
||||
//Get the answer from backup_ids
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$tok);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$tok);
|
||||
if ($answer) {
|
||||
if ($in_first) {
|
||||
$answers_field .= $answer->new_id;
|
||||
@@ -532,13 +532,13 @@
|
||||
$truefalse->falseanswer = backup_todb($tru_info['#']['FALSEANSWER']['0']['#']);
|
||||
|
||||
////We have to recode the trueanswer field
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$truefalse->trueanswer);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$truefalse->trueanswer);
|
||||
if ($answer) {
|
||||
$truefalse->trueanswer = $answer->new_id;
|
||||
}
|
||||
|
||||
////We have to recode the falseanswer field
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$truefalse->falseanswer);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$truefalse->falseanswer);
|
||||
if ($answer) {
|
||||
$truefalse->falseanswer = $answer->new_id;
|
||||
}
|
||||
@@ -594,7 +594,7 @@
|
||||
$tok = strtok($multichoice->answers,",");
|
||||
while ($tok) {
|
||||
//Get the answer from backup_ids
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$tok);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$tok);
|
||||
if ($answer) {
|
||||
if ($in_first) {
|
||||
$answers_field .= $answer->new_id;
|
||||
@@ -832,7 +832,7 @@
|
||||
$numerical->max = backup_todb($num_info['#']['MAX']['0']['#']);
|
||||
|
||||
////We have to recode the answer field
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$numerical->answer);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$numerical->answer);
|
||||
if ($answer) {
|
||||
$numerical->answer = $answer->new_id;
|
||||
}
|
||||
@@ -899,7 +899,7 @@
|
||||
$calculated->correctanswerformat = backup_todb($cal_info['#']['CORRECTANSWERFORMAT']['0']['#']);
|
||||
|
||||
////We have to recode the answer field
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$calculated->answer);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$calculated->answer);
|
||||
if ($answer) {
|
||||
$calculated->answer = $answer->new_id;
|
||||
}
|
||||
@@ -982,7 +982,7 @@
|
||||
$ansarr = explode(",", $multianswer->answers);
|
||||
foreach ($ansarr as $key => $value) {
|
||||
//Get the answer from backup_ids
|
||||
$answer = backup_getid($restore->backup_unique_code,'quiz_answers',$value);
|
||||
$answer = backup_getid($restore->backup_unique_code,'question_answers',$value);
|
||||
$ansarr[$key] = $answer->new_id;
|
||||
}
|
||||
$multianswer->answers = implode(",",$ansarr);
|
||||
@@ -1020,12 +1020,12 @@
|
||||
backup_flush(300);
|
||||
}
|
||||
|
||||
//Remap quiz_answers records from the original multianswer question
|
||||
//Remap question_answers records from the original multianswer question
|
||||
//to their newly created question
|
||||
if ($newid) {
|
||||
$answersdb = get_records_list('quiz_answers','id',$multianswer->answers);
|
||||
$answersdb = get_records_list('question_answers','id',$multianswer->answers);
|
||||
foreach ($answersdb as $answerdb) {
|
||||
set_field('quiz_answers','question',$newid,'id',$answerdb->id);
|
||||
set_field('question_answers','question',$newid,'id',$answerdb->id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1118,7 +1118,7 @@
|
||||
|
||||
//We have to recode the category field (only if the category != 0)
|
||||
if ($dataset_definition->category != 0) {
|
||||
$category = backup_getid($restore->backup_unique_code,"quiz_categories",$dataset_definition->category);
|
||||
$category = backup_getid($restore->backup_unique_code,"question_categories",$dataset_definition->category);
|
||||
if ($category) {
|
||||
$dataset_definition->category = $category->new_id;
|
||||
}
|
||||
@@ -1583,7 +1583,7 @@
|
||||
break;
|
||||
case 2: //TRUEFALSE QTYPE
|
||||
//The answer is one answer id. We must recode it
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$response->answer);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$response->answer);
|
||||
if ($answer) {
|
||||
$response->answer = $answer->new_id;
|
||||
}
|
||||
@@ -1595,7 +1595,7 @@
|
||||
$tok = strtok($response->answer,",");
|
||||
while ($tok) {
|
||||
//Get the answer from backup_ids
|
||||
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$tok);
|
||||
$answer = backup_getid($restore->backup_unique_code,"question_answers",$tok);
|
||||
if ($answer) {
|
||||
if ($in_first) {
|
||||
$answer_field .= $answer->new_id;
|
||||
@@ -1660,7 +1660,7 @@
|
||||
//Get the question from backup_ids
|
||||
$que = backup_getid($restore->backup_unique_code,"question",$question_id);
|
||||
//Get the answer from backup_ids
|
||||
$ans = backup_getid($restore->backup_unique_code,"quiz_answers",$answer_id);
|
||||
$ans = backup_getid($restore->backup_unique_code,"question_answers",$answer_id);
|
||||
if ($que) {
|
||||
//It the question hasn't response, it must be 0
|
||||
if (!$ans and $answer_id == 0) {
|
||||
@@ -1719,7 +1719,7 @@
|
||||
} else if ($questiontype == "3") {
|
||||
//Multichoice
|
||||
//The answer is an answer_id, look for it in backup_ids
|
||||
$ans = backup_getid($restore->backup_unique_code,"quiz_answers",$answer);
|
||||
$ans = backup_getid($restore->backup_unique_code,"question_answers",$answer);
|
||||
$answer = $ans->new_id;
|
||||
} else if ($questiontype == "8") {
|
||||
//Numeric
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2006030100; // The (date) version of this module
|
||||
$module->version = 2006030101; // The (date) version of this module
|
||||
$module->requires = 2006022400; // Requires this Moodle version
|
||||
$module->cron = 0; // How often should cron check this module (seconds)?
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
error("Only teachers authorized to edit the course '{$course->fullname}' can use this page!");
|
||||
}
|
||||
|
||||
$qcobject = new quiz_category_object();
|
||||
$qcobject = new question_category_object();
|
||||
$qcobject->set_course($course);
|
||||
|
||||
//==========
|
||||
|
||||
+26
-26
@@ -1,6 +1,6 @@
|
||||
<? // $Id:
|
||||
/**
|
||||
* Class quiz_category_object
|
||||
* Class question_category_object
|
||||
*
|
||||
* Used for handling changes to the quiz categories
|
||||
*
|
||||
@@ -13,7 +13,7 @@
|
||||
// number of categories to display on page
|
||||
define( "PAGE_LENGTH",25 );
|
||||
|
||||
class quiz_category_object {
|
||||
class question_category_object {
|
||||
|
||||
var $str;
|
||||
var $pixpath;
|
||||
@@ -33,7 +33,7 @@ class quiz_category_object {
|
||||
* Gets necessary strings and sets relevant path information
|
||||
*
|
||||
*/
|
||||
function quiz_category_object() {
|
||||
function question_category_object() {
|
||||
global $CFG;
|
||||
|
||||
$this->tab = str_repeat(' ', $this->tabsize);
|
||||
@@ -108,7 +108,7 @@ class quiz_category_object {
|
||||
error("Error: Could not find or make a category!");
|
||||
}
|
||||
|
||||
$this->categories = $this->get_quiz_categories(null, "parent, sortorder, name ASC");
|
||||
$this->categories = $this->get_question_categories(null, "parent, sortorder, name ASC");
|
||||
|
||||
$this->categories = $this->arrange_categories($this->categories);
|
||||
|
||||
@@ -374,7 +374,7 @@ class quiz_category_object {
|
||||
$this->initialize();
|
||||
|
||||
/// Interface for editing existing categories
|
||||
if ($category = get_record("quiz_categories", "id", $categoryid)) {
|
||||
if ($category = get_record("question_categories", "id", $categoryid)) {
|
||||
echo '<h2 align="center">';
|
||||
echo $this->str->edit;
|
||||
helpbutton("categories_edit", $this->str->editcategory, "quiz");
|
||||
@@ -552,13 +552,13 @@ class quiz_category_object {
|
||||
* @param string sort - [[sortfield [,sortfield]] {ASC|DESC}]
|
||||
* @return array categories
|
||||
*/
|
||||
function get_quiz_categories($parent=null, $sort="sortorder ASC") {
|
||||
function get_question_categories($parent=null, $sort="sortorder ASC") {
|
||||
|
||||
if (is_null($parent)) {
|
||||
$categories = get_records('quiz_categories', 'course', "{$this->course->id}", $sort);
|
||||
$categories = get_records('question_categories', 'course', "{$this->course->id}", $sort);
|
||||
} else {
|
||||
$select = "parent = '$parent' AND course = '{$this->course->id}'";
|
||||
$categories = get_records_select('quiz_categories', $select, $sort);
|
||||
$categories = get_records_select('question_categories', $select, $sort);
|
||||
}
|
||||
return $categories;
|
||||
}
|
||||
@@ -573,12 +573,12 @@ class quiz_category_object {
|
||||
function delete_category($deletecat, $destcategoryid = null) {
|
||||
global $USER;
|
||||
|
||||
if (!$category = get_record("quiz_categories", "id", $deletecat)) { // security
|
||||
if (!$category = get_record("question_categories", "id", $deletecat)) { // security
|
||||
error("No such category $deletecat!", "category.php?id={$this->course->id}");
|
||||
}
|
||||
|
||||
if (!is_null($destcategoryid)) { // Need to move some questions before deleting the category
|
||||
if (!$category2 = get_record("quiz_categories", "id", $destcategoryid)) { // security
|
||||
if (!$category2 = get_record("question_categories", "id", $destcategoryid)) { // security
|
||||
error("No such category $destcategoryid!", "category.php?id={$this->course->id}");
|
||||
}
|
||||
if (! set_field('question', 'category', $category2, 'category', $category1)) {
|
||||
@@ -606,19 +606,19 @@ class quiz_category_object {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
delete_records("quiz_categories", "id", $category->id);
|
||||
delete_records("question_categories", "id", $category->id);
|
||||
|
||||
/// Send the children categories to live with their grandparent
|
||||
if ($childcats = get_records("quiz_categories", "parent", $category->id)) {
|
||||
if ($childcats = get_records("question_categories", "parent", $category->id)) {
|
||||
foreach ($childcats as $childcat) {
|
||||
if (! set_field("quiz_categories", "parent", $category->parent, "id", $childcat->id)) {
|
||||
if (! set_field("question_categories", "parent", $category->parent, "id", $childcat->id)) {
|
||||
error("Could not update a child category!", "category.php?id={$this->course->id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Finally delete the category itself
|
||||
if (delete_records("quiz_categories", "id", $category->id)) {
|
||||
if (delete_records("question_categories", "id", $category->id)) {
|
||||
notify(get_string("categorydeleted", "quiz", $category->name), 'green');
|
||||
}
|
||||
}
|
||||
@@ -635,8 +635,8 @@ class quiz_category_object {
|
||||
$movecategory = NULL;
|
||||
|
||||
if ($direction == 'up') {
|
||||
if ($movecategory = get_record("quiz_categories", "id", $categoryid)) {
|
||||
$categories = $this->get_quiz_categories("$movecategory->parent", 'parent, sortorder, name');
|
||||
if ($movecategory = get_record("question_categories", "id", $categoryid)) {
|
||||
$categories = $this->get_question_categories("$movecategory->parent", 'parent, sortorder, name');
|
||||
|
||||
foreach ($categories as $category) {
|
||||
if ($category->id == $movecategory->id) {
|
||||
@@ -647,8 +647,8 @@ class quiz_category_object {
|
||||
}
|
||||
}
|
||||
if ($direction == 'down') {
|
||||
if ($movecategory = get_record("quiz_categories", "id", $categoryid)) {
|
||||
$categories = $this->get_quiz_categories("$movecategory->parent", 'parent, sortorder, name');
|
||||
if ($movecategory = get_record("question_categories", "id", $categoryid)) {
|
||||
$categories = $this->get_question_categories("$movecategory->parent", 'parent, sortorder, name');
|
||||
$choosenext = false;
|
||||
foreach ($categories as $category) {
|
||||
if ($choosenext) {
|
||||
@@ -670,7 +670,7 @@ class quiz_category_object {
|
||||
} else if ($category->id == $movecategory->id) {
|
||||
$category = $swapcategory;
|
||||
}
|
||||
if (! set_field("quiz_categories", "sortorder", $count, "id", $category->id)) {
|
||||
if (! set_field("question_categories", "sortorder", $count, "id", $category->id)) {
|
||||
notify("Could not update that category!");
|
||||
}
|
||||
}
|
||||
@@ -686,9 +686,9 @@ class quiz_category_object {
|
||||
function move_category($categoryid, $parentid) {
|
||||
/// Move a category to a new parent
|
||||
|
||||
if ($tempcat = get_record("quiz_categories", "id", $categoryid)) {
|
||||
if ($tempcat = get_record("question_categories", "id", $categoryid)) {
|
||||
if ($tempcat->parent != $parentid) {
|
||||
if (! set_field("quiz_categories", "parent", $parentid, "id", $tempcat->id)) {
|
||||
if (! set_field("question_categories", "parent", $parentid, "id", $tempcat->id)) {
|
||||
notify("Could not update that category!");
|
||||
}
|
||||
}
|
||||
@@ -705,9 +705,9 @@ class quiz_category_object {
|
||||
/// Hide or publish a category
|
||||
|
||||
$publish = ($publish == false) ? 0 : 1;
|
||||
$tempcat = get_record("quiz_categories", "id", $categoryid);
|
||||
$tempcat = get_record("question_categories", "id", $categoryid);
|
||||
if ($tempcat) {
|
||||
if (! set_field("quiz_categories", "publish", $publish, "id", $tempcat->id)) {
|
||||
if (! set_field("question_categories", "publish", $publish, "id", $tempcat->id)) {
|
||||
notify("Could not update that category!");
|
||||
}
|
||||
}
|
||||
@@ -726,7 +726,7 @@ class quiz_category_object {
|
||||
|
||||
if ($newparent) {
|
||||
// first check that the parent category is in the correct course
|
||||
if(!(get_field('quiz_categories', 'course', 'id', $newparent) == $newcourse)) {
|
||||
if(!(get_field('question_categories', 'course', 'id', $newparent) == $newcourse)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -739,7 +739,7 @@ class quiz_category_object {
|
||||
$cat->course = $newcourse;
|
||||
$cat->sortorder = 999;
|
||||
$cat->stamp = make_unique_id_code();
|
||||
if (!insert_record("quiz_categories", $cat)) {
|
||||
if (!insert_record("question_categories", $cat)) {
|
||||
error("Could not insert the new quiz category '$newcategory'", "category.php?id={$newcourse}");
|
||||
} else {
|
||||
notify(get_string("categoryadded", "quiz", $newcategory), 'green');
|
||||
@@ -765,7 +765,7 @@ class quiz_category_object {
|
||||
$cat->name = $updatename;
|
||||
$cat->info = $updateinfo;
|
||||
$cat->publish = $updatepublish;
|
||||
if (!update_record("quiz_categories", $cat)) {
|
||||
if (!update_record("question_categories", $cat)) {
|
||||
error("Could not update the category '$updatename'", "category.php?id={$courseid}");
|
||||
} else {
|
||||
notify(get_string("categoryupdated", 'quiz'), 'green');
|
||||
|
||||
+10
-10
@@ -18,12 +18,12 @@
|
||||
/**
|
||||
* Array of question types names translated to the user's language
|
||||
*
|
||||
* The $QUIZ_QUESTION_TYPE array holds the names of all the question types that the user should
|
||||
* The $QTYPE_MENU array holds the names of all the question types that the user should
|
||||
* be able to create directly. Some internal question types like random questions are excluded.
|
||||
* The complete list of question types can be found in {@link $QTYPES}.
|
||||
*/
|
||||
|
||||
$QUIZ_QUESTION_TYPE = array ( MULTICHOICE => get_string("multichoice", "quiz"),
|
||||
$QTYPE_MENU = array ( MULTICHOICE => get_string("multichoice", "quiz"),
|
||||
TRUEFALSE => get_string("truefalse", "quiz"),
|
||||
SHORTANSWER => get_string("shortanswer", "quiz"),
|
||||
NUMERICAL => get_string("numerical", "quiz"),
|
||||
@@ -37,7 +37,7 @@ $QUIZ_QUESTION_TYPE = array ( MULTICHOICE => get_string("multichoice", "quiz")
|
||||
// add remote question types
|
||||
if ($rqp_types = get_records('quiz_rqp_types')) {
|
||||
foreach($rqp_types as $type) {
|
||||
$QUIZ_QUESTION_TYPE[100+$type->id] = $type->name;
|
||||
$QTYPE_MENU[100+$type->id] = $type->name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,14 +46,14 @@ function question_category_form($course, $current, $recurse=1, $showhidden=false
|
||||
/// Prints a form to choose categories
|
||||
|
||||
/// Make sure the default category exists for this course
|
||||
if (!$categories = get_records("quiz_categories", "course", $course->id, "id ASC")) {
|
||||
if (!$categories = get_records("question_categories", "course", $course->id, "id ASC")) {
|
||||
if (!$category = get_default_question_category($course->id)) {
|
||||
notify("Error creating a default category!");
|
||||
}
|
||||
}
|
||||
|
||||
/// Get all the existing categories now
|
||||
if (!$categories = get_records_select("quiz_categories", "course = '{$course->id}' OR publish = '1'", "parent, sortorder, name ASC")) {
|
||||
if (!$categories = get_records_select("question_categories", "course = '{$course->id}' OR publish = '1'", "parent, sortorder, name ASC")) {
|
||||
notify("Could not find any question categories!");
|
||||
return false; // Something is really wrong
|
||||
}
|
||||
@@ -117,7 +117,7 @@ function question_category_form($course, $current, $recurse=1, $showhidden=false
|
||||
*/
|
||||
function question_list($course, $categoryid, $quizid,
|
||||
$recurse=1, $page, $perpage, $showhidden=false, $sortorder='qtype, name ASC') {
|
||||
global $QUIZ_QUESTION_TYPE, $USER, $CFG;
|
||||
global $QTYPE_MENU, $USER, $CFG;
|
||||
|
||||
$strcategory = get_string("category", "quiz");
|
||||
$strquestion = get_string("question", "quiz");
|
||||
@@ -152,7 +152,7 @@ function question_list($course, $categoryid, $quizid,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$category = get_record("quiz_categories", "id", "$categoryid")) {
|
||||
if (!$category = get_record("question_categories", "id", "$categoryid")) {
|
||||
notify("Category not found!");
|
||||
return;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ function question_list($course, $categoryid, $quizid,
|
||||
if (isteacheredit($category->course)) {
|
||||
echo "<td valign=\"top\"><b>$strcreatenewquestion:</b></td>";
|
||||
echo '<td valign="top" align="right">';
|
||||
popup_form ("$CFG->wwwroot/question/question.php?category=$category->id&qtype=", $QUIZ_QUESTION_TYPE, "addquestion",
|
||||
popup_form ("$CFG->wwwroot/question/question.php?category=$category->id&qtype=", $QTYPE_MENU, "addquestion",
|
||||
"", "choose", "", "", false, "self");
|
||||
echo '</td><td width="10" valign="top" align="right">';
|
||||
helpbutton("questiontypes", $strcreatenewquestion, "quiz");
|
||||
@@ -191,7 +191,7 @@ function question_list($course, $categoryid, $quizid,
|
||||
|
||||
echo '</center>';
|
||||
|
||||
$categorylist = ($recurse) ? quiz_categorylist($category->id) : $category->id;
|
||||
$categorylist = ($recurse) ? question_categorylist($category->id) : $category->id;
|
||||
|
||||
// hide-feature
|
||||
$showhidden = $showhidden ? '' : " AND hidden = '0'";
|
||||
@@ -287,7 +287,7 @@ function question_list($course, $categoryid, $quizid,
|
||||
if ($canedit) {
|
||||
echo '<input type="submit" name="deleteselected" value="'.$strdelete."\" /></td><td>\n";
|
||||
echo '<input type="submit" name="move" value="'.get_string('moveto', 'quiz')."\" />\n";
|
||||
quiz_category_select_menu($course->id, false, true, $category->id);
|
||||
question_category_select_menu($course->id, false, true, $category->id);
|
||||
}
|
||||
echo "</td></tr></table>";
|
||||
|
||||
|
||||
+3
-3
@@ -28,7 +28,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (! $category = get_record("quiz_categories", "id", $categoryid)) {
|
||||
if (! $category = get_record("question_categories", "id", $categoryid)) {
|
||||
$category = get_default_question_category($courseid);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@
|
||||
}
|
||||
|
||||
/// Get all the existing categories now
|
||||
if (!$categories = get_records_select("quiz_categories", "course = '{$course->id}' OR publish = '1'", "parent, sortorder, name ASC")) {
|
||||
if (!$categories = get_records_select("question_categories", "course = '{$course->id}' OR publish = '1'", "parent, sortorder, name ASC")) {
|
||||
error("Could not find any question categories!");
|
||||
}
|
||||
$categories = add_indented_names($categories);
|
||||
@@ -159,7 +159,7 @@
|
||||
print_string("category", "quiz");
|
||||
echo ":</td><td>";
|
||||
if (!$showcatmenu) { // category already specified
|
||||
echo quiz_get_category_coursename($category);
|
||||
echo question_category_coursename($category);
|
||||
echo " <input type=\"hidden\" name=\"category\" value=\"$category->id\" />";
|
||||
} else { // no category specified, let user choose
|
||||
choose_from_menu($catmenu, "category", $category->id, "");
|
||||
|
||||
@@ -157,7 +157,7 @@ class quiz_format_aon extends quiz_default_format {
|
||||
$extracts = get_records_sql("SELECT q.questiontext, a.answer
|
||||
FROM {$CFG->prefix}question q,
|
||||
{$CFG->prefix}quiz_shortanswer sa,
|
||||
{$CFG->prefix}quiz_answers a
|
||||
{$CFG->prefix}question_answers a
|
||||
WHERE q.id in ($extractids)
|
||||
AND sa.question = q.id
|
||||
AND a.id = sa.answers");
|
||||
@@ -195,7 +195,7 @@ class quiz_format_aon extends quiz_default_format {
|
||||
|
||||
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}quiz_answers WHERE question IN ($extractids)", false);
|
||||
execute_sql("DELETE FROM {$CFG->prefix}question_answers WHERE question IN ($extractids)", false);
|
||||
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ class quiz_format_aon extends quiz_default_format {
|
||||
foreach ($shortanswerids as $shortanswerid) {
|
||||
delete_records("question", "id", $shortanswerid);
|
||||
delete_records("quiz_shortanswer", "question", $shortanswerid);
|
||||
delete_records("quiz_answers", "question", $shortanswerid);
|
||||
delete_records("question_answers", "question", $shortanswerid);
|
||||
}
|
||||
}
|
||||
$info = "$shortanswercount ".get_string("shortanswer", "quiz").
|
||||
|
||||
@@ -113,7 +113,7 @@ class quiz_format_coursetestmanager extends quiz_default_format {
|
||||
// don't have to do this on linux, since it's alreay been done in the test above
|
||||
if (PHP_OS == "WINNT") { $question_categories = $this->getquestioncategories($filename); }
|
||||
// print the intermediary form
|
||||
if (!$categories = quiz_get_category_menu($course->id, true)) {
|
||||
if (!$categories = question_category_menu($course->id, true)) {
|
||||
error("No categories!");
|
||||
}
|
||||
print_heading_with_help($strimportquestions, "import", "quiz");
|
||||
|
||||
+4
-4
@@ -23,7 +23,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (! $category = get_record("quiz_categories", "id", $categoryid)) {
|
||||
if (! $category = get_record("question_categories", "id", $categoryid)) {
|
||||
// if no valid category was given, use the default category
|
||||
if ($courseid) {
|
||||
$category = get_default_question_category($courseid);
|
||||
@@ -134,12 +134,12 @@
|
||||
|
||||
/// Get all the existing categories now
|
||||
if (isadmin()) { // the admin can import into all categories
|
||||
if (!$categories = get_records_select("quiz_categories", "course = '{$course->id}' OR publish = '1'", "parent, sortorder, name ASC")) {
|
||||
if (!$categories = get_records_select("question_categories", "course = '{$course->id}' OR publish = '1'", "parent, sortorder, name ASC")) {
|
||||
error("Could not find any question categories!"); // Something is really wrong
|
||||
}
|
||||
} else { // select only the categories to which the teacher has write access
|
||||
$sql = "SELECT c.*
|
||||
FROM {$CFG->prefix}quiz_categories AS c,
|
||||
FROM {$CFG->prefix}question_categories AS c,
|
||||
{$CFG->prefix}user_teachers AS t
|
||||
WHERE t.userid = '$USER->id'
|
||||
AND t.course = c.course
|
||||
@@ -169,7 +169,7 @@
|
||||
print_string("category", "quiz");
|
||||
echo ":</td><td>";
|
||||
if (!showcatmenu) { // category already specified
|
||||
echo quiz_get_category_coursename($category);
|
||||
echo question_category_coursename($category);
|
||||
echo " <input type=\"hidden\" name=\"category\" value=\"$category->id\" />";
|
||||
} else { // no category specified, let user choose
|
||||
choose_from_menu($catmenu, "category", $category->id, "");
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
$quiz->id = 0; // just for safety
|
||||
$quiz->questions = $id;
|
||||
|
||||
if (!$category = get_record("quiz_categories", "id", $questions[$id]->category)) {
|
||||
if (!$category = get_record("question_categories", "id", $questions[$id]->category)) {
|
||||
error("This question doesn't belong to a valid category!");
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
if (!empty($category)) {
|
||||
$question->category = $category;
|
||||
}
|
||||
if (! $category = get_record("quiz_categories", "id", $question->category)) {
|
||||
if (! $category = get_record("question_categories", "id", $question->category)) {
|
||||
error("This question doesn't belong to a valid category!");
|
||||
}
|
||||
if (! $course = get_record("course", "id", $category->course)) {
|
||||
@@ -54,7 +54,7 @@
|
||||
$qtype = $question->qtype;
|
||||
|
||||
} else if ($category) { // only for creating new questions
|
||||
if (! $category = get_record("quiz_categories", "id", $category)) {
|
||||
if (! $category = get_record("question_categories", "id", $category)) {
|
||||
error("This wasn't a valid category!");
|
||||
}
|
||||
if (! $course = get_record("course", "id", $category->course)) {
|
||||
@@ -262,7 +262,7 @@
|
||||
}
|
||||
|
||||
// Now do anything question-type specific that is required to replace the question
|
||||
// For example questions that use the quiz_answers table to hold part of their question will
|
||||
// For example questions that use the question_answers table to hold part of their question will
|
||||
// have to recode the answer ids in the states
|
||||
$QTYPES[$question->qtype]->change_states_question($oldquestionid, $question, $attempts);
|
||||
}
|
||||
@@ -300,7 +300,7 @@
|
||||
arsort($gradeoptions, SORT_NUMERIC);
|
||||
arsort($gradeoptionsfull, SORT_NUMERIC);
|
||||
|
||||
if (!$categories = quiz_get_category_menu($course->id, false)) {
|
||||
if (!$categories = question_category_menu($course->id, false)) {
|
||||
error("No categories!");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
<?php question_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
|
||||
@@ -58,7 +58,7 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
|
||||
if (!$oldanswers = get_records_sql(
|
||||
"SELECT a.*, c.tolerance, c.tolerancetype,
|
||||
c.correctanswerlength, c.id AS calcid
|
||||
FROM {$CFG->prefix}quiz_answers a,
|
||||
FROM {$CFG->prefix}question_answers a,
|
||||
{$CFG->prefix}quiz_calculated c
|
||||
WHERE c.question = $question->id AND a.id = c.answer")) {
|
||||
$oldanswers = array();
|
||||
@@ -89,7 +89,7 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
|
||||
// Reuse old records:
|
||||
$calcrec->answer = $answerrec->id = $oldanswer->id;
|
||||
$calcrec->id = $oldanswer->calcid;
|
||||
if (!update_record('quiz_answers', $answerrec)) {
|
||||
if (!update_record('question_answers', $answerrec)) {
|
||||
error("Unable to update answer for calculated question #{$question->id}!");
|
||||
} else {
|
||||
// notify("Answer updated successfully for calculated question $question->name");
|
||||
@@ -102,7 +102,7 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
|
||||
} else {
|
||||
unset($answerrec->id);
|
||||
unset($calcrec->id);
|
||||
if (!($calcrec->answer = insert_record('quiz_answers',
|
||||
if (!($calcrec->answer = insert_record('question_answers',
|
||||
$answerrec))) {
|
||||
error("Unable to insert answer for calculated question $question->id");
|
||||
} else {
|
||||
@@ -118,7 +118,7 @@ class quiz_calculated_qtype extends quiz_dataset_dependent_questiontype {
|
||||
|
||||
// Delete excessive records:
|
||||
foreach ($oldanswers as $oldanswer) {
|
||||
if (!delete_records('quiz_answers', 'id', $oldanswer->id)) {
|
||||
if (!delete_records('question_answers', 'id', $oldanswer->id)) {
|
||||
error("Unable to delete old answers for calculated question $question->id");
|
||||
} else {
|
||||
// notify("Old answers deleted successfully for calculated question $question->id");
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
$category = required_param('category', PARAM_ALPHANUM);
|
||||
$question = optional_param('question', '', PARAM_INT);
|
||||
|
||||
if (! $category = get_record("quiz_categories", "id", $category)) {
|
||||
if (! $category = get_record("question_categories", "id", $category)) {
|
||||
error("This wasn't a valid category!");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
<?php question_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
}
|
||||
|
||||
if (!empty($options->answer)) {
|
||||
$essayfeedback = get_record("quiz_answers", "id", $options->answer);
|
||||
$essayfeedback = get_record("question_answers", "id", $options->answer);
|
||||
} else {
|
||||
$essayfeedback->feedback = "";
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<b><?php print_string("category", "quiz") ?>:</b>
|
||||
</td>
|
||||
<td>
|
||||
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
<?php question_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
|
||||
@@ -19,7 +19,7 @@ class quiz_essay_qtype extends quiz_default_questiontype {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$question->options->answers = get_records('quiz_answers', 'question',
|
||||
if (!$question->options->answers = get_records('question_answers', 'question',
|
||||
$question->id)) {
|
||||
notify('Error: Missing question answers!');
|
||||
return false;
|
||||
@@ -28,12 +28,12 @@ class quiz_essay_qtype extends quiz_default_questiontype {
|
||||
}
|
||||
|
||||
function save_question_options($question) {
|
||||
if ($answer = get_record("quiz_answers", "question", $question->id)) {
|
||||
if ($answer = get_record("question_answers", "question", $question->id)) {
|
||||
// Existing answer, so reuse it
|
||||
$answer->answer = $question->feedback;
|
||||
$answer->feedback = $question->feedback;
|
||||
$answer->fraction = $question->fraction;
|
||||
if (!update_record("quiz_answers", $answer)) {
|
||||
if (!update_record("question_answers", $answer)) {
|
||||
$result->error = "Could not update quiz answer!";
|
||||
return $result;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class quiz_essay_qtype extends quiz_default_questiontype {
|
||||
$answer->answer = $question->feedback;
|
||||
$answer->feedback = $question->feedback;
|
||||
$answer->fraction = $question->fraction;
|
||||
if (!$answer->id = insert_record("quiz_answers", $answer)) {
|
||||
if (!$answer->id = insert_record("question_answers", $answer)) {
|
||||
$result->error = "Could not insert quiz answer!";
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
<?php question_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
<?php question_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
$options->shuffleanswers = 1;
|
||||
}
|
||||
if (!empty($options->answers)) {
|
||||
$answersraw = get_records_list("quiz_answers", "id", $options->answers);
|
||||
$answersraw = get_records_list("question_answers", "id", $options->answers);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
<?php question_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class quiz_multichoice_qtype extends quiz_default_questiontype {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$question->options->answers = get_records_select('quiz_answers', 'id IN ('.$question->options->answers.')')) {
|
||||
if (!$question->options->answers = get_records_select('question_answers', 'id IN ('.$question->options->answers.')')) {
|
||||
notify('Error: Missing question answers!');
|
||||
return false;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class quiz_multichoice_qtype extends quiz_default_questiontype {
|
||||
|
||||
function save_question_options($question) {
|
||||
|
||||
if (!$oldanswers = get_records("quiz_answers", "question",
|
||||
if (!$oldanswers = get_records("question_answers", "question",
|
||||
$question->id, "id ASC")) {
|
||||
$oldanswers = array();
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class quiz_multichoice_qtype extends quiz_default_questiontype {
|
||||
$answer->answer = $dataanswer;
|
||||
$answer->fraction = $question->fraction[$key];
|
||||
$answer->feedback = $question->feedback[$key];
|
||||
if (!update_record("quiz_answers", $answer)) {
|
||||
if (!update_record("question_answers", $answer)) {
|
||||
$result->error = "Could not update quiz answer! (id=$answer->id)";
|
||||
return $result;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class quiz_multichoice_qtype extends quiz_default_questiontype {
|
||||
$answer->question = $question->id;
|
||||
$answer->fraction = $question->fraction[$key];
|
||||
$answer->feedback = $question->feedback[$key];
|
||||
if (!$answer->id = insert_record("quiz_answers", $answer)) {
|
||||
if (!$answer->id = insert_record("question_answers", $answer)) {
|
||||
$result->error = "Could not insert quiz answer! ";
|
||||
return $result;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ class quiz_multichoice_qtype extends quiz_default_questiontype {
|
||||
// delete old answer records
|
||||
if (!empty($oldanswers)) {
|
||||
foreach($oldanswers as $oa) {
|
||||
delete_records('quiz_answers', 'id', $oa->id);
|
||||
delete_records('question_answers', 'id', $oa->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
<?php question_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
|
||||
@@ -30,7 +30,7 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
|
||||
global $CFG;
|
||||
if (!$question->options->answers = get_records_sql(
|
||||
"SELECT a.*, n.tolerance " .
|
||||
"FROM {$CFG->prefix}quiz_answers a, " .
|
||||
"FROM {$CFG->prefix}question_answers a, " .
|
||||
" {$CFG->prefix}quiz_numerical n " .
|
||||
"WHERE a.question = $question->id " .
|
||||
"AND a.id = n.answer;")) {
|
||||
@@ -94,7 +94,7 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
|
||||
// interface, but the GIFT format supports it. The multianswer qtype,
|
||||
// for example can make use of this feature.
|
||||
// Get old versions of the objects
|
||||
if (!$oldanswers = get_records("quiz_answers", "question", $question->id)) {
|
||||
if (!$oldanswers = get_records("question_answers", "question", $question->id)) {
|
||||
$oldanswers = array();
|
||||
}
|
||||
|
||||
@@ -120,12 +120,12 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
|
||||
|
||||
if ($oldanswer = array_shift($oldanswers)) { // Existing answer, so reuse it
|
||||
$answer->id = $oldanswer->id;
|
||||
if (! update_record("quiz_answers", $answer)) {
|
||||
if (! update_record("question_answers", $answer)) {
|
||||
$result->error = "Could not update quiz answer! (id=$answer->id)";
|
||||
return $result;
|
||||
}
|
||||
} else { // This is a completely new answer
|
||||
if (! $answer->id = insert_record("quiz_answers", $answer)) {
|
||||
if (! $answer->id = insert_record("question_answers", $answer)) {
|
||||
$result->error = "Could not insert quiz answer!";
|
||||
return $result;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class quiz_numerical_qtype extends quiz_shortanswer_qtype {
|
||||
// delete old answer records
|
||||
if (!empty($oldanswers)) {
|
||||
foreach($oldanswers as $oa) {
|
||||
delete_records('quiz_answers', 'id', $oa->id);
|
||||
delete_records('question_answers', 'id', $oa->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ class quiz_default_questiontype {
|
||||
$question->options = new object;
|
||||
}
|
||||
// The default implementation attaches all answers for this question
|
||||
if (!$question->options->answers = get_records('quiz_answers', 'question',
|
||||
if (!$question->options->answers = get_records('question_answers', 'question',
|
||||
$question->id)) {
|
||||
//notify('Error: Missing question answers!');
|
||||
return false;
|
||||
@@ -814,8 +814,9 @@ class quiz_default_questiontype {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the editing wizard is finished, false otherwise. The
|
||||
* default implementation returns true, which is suitable for all question-
|
||||
* Returns true if the editing wizard is finished, false otherwise.
|
||||
*
|
||||
* The default implementation returns true, which is suitable for all question-
|
||||
* types that only use one editing form. This function is used in
|
||||
* question.php to decide whether we can regrade any states of the edited
|
||||
* question and redirect to edit.php.
|
||||
@@ -833,13 +834,20 @@ class quiz_default_questiontype {
|
||||
return true;
|
||||
}
|
||||
|
||||
function print_replacement_options($question, $course, $quizid='0') {
|
||||
// This function is used near the end of the question edit forms in all question types
|
||||
// It prints the table of quizzes in which the question is used
|
||||
// containing checkboxes to allow the teacher to replace the old question version
|
||||
/**
|
||||
* Prints a table of course modules in which the question is used
|
||||
*
|
||||
* This function is used near the end of the question edit forms in all question types
|
||||
* It prints the table of quizzes in which the question is used
|
||||
* containing checkboxes to allow the teacher to replace the old question version
|
||||
*
|
||||
* @param object $question
|
||||
* @param object $course
|
||||
* @param integer $cmid optional The id of the course module currently being edited
|
||||
*/
|
||||
function print_replacement_options($question, $course, $cmid='0') {
|
||||
|
||||
// Disable until the versioning code has been fixed
|
||||
// The $quizid argument will become a $cmid
|
||||
return;
|
||||
|
||||
// no need to display replacement options if the question is new
|
||||
@@ -878,7 +886,7 @@ class quiz_default_questiontype {
|
||||
foreach($quizzes as $quiz) {
|
||||
// work out whethere it should be checked by default
|
||||
$checked = '';
|
||||
if((int)$quizid === (int)$quiz->id
|
||||
if((int)$cmid === (int)$quiz->id
|
||||
or empty($quiz->usercount)) {
|
||||
$checked = "checked=\"checked\"";
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class quiz_random_qtype extends quiz_default_questiontype {
|
||||
$excludedtypes = implode(',', $this->excludedtypes);
|
||||
if ($question->questiontext == "1") {
|
||||
// recurse into subcategories
|
||||
$categorylist = quiz_categorylist($question->category);
|
||||
$categorylist = question_categorylist($question->category);
|
||||
} else {
|
||||
$categorylist = $question->category;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
<?php question_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
|
||||
@@ -80,7 +80,7 @@ class quiz_randomsamatch_qtype extends quiz_match_qtype {
|
||||
|
||||
if ($question->options->subcats) {
|
||||
// recurse into subcategories
|
||||
$categorylist = quiz_categorylist($question->category);
|
||||
$categorylist = question_categorylist($question->category);
|
||||
} else {
|
||||
$categorylist = $question->category;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string('category', 'quiz'); ?>:</b></td>
|
||||
<td align="left">
|
||||
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
<?php question_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
$options->usecase = 0;
|
||||
}
|
||||
if (!empty($options->answers)) {
|
||||
$answersraw = get_records_list("quiz_answers", "id", $options->answers);
|
||||
$answersraw = get_records_list("question_answers", "id", $options->answers);
|
||||
}
|
||||
|
||||
$answers = array();
|
||||
|
||||
@@ -25,7 +25,7 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$question->options->answers = get_records('quiz_answers', 'question',
|
||||
if (!$question->options->answers = get_records('question_answers', 'question',
|
||||
$question->id, 'id ASC')) {
|
||||
notify('Error: Missing question answers!');
|
||||
return false;
|
||||
@@ -34,7 +34,7 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype {
|
||||
}
|
||||
|
||||
function save_question_options($question) {
|
||||
if (!$oldanswers = get_records("quiz_answers", "question", $question->id, "id ASC")) {
|
||||
if (!$oldanswers = get_records("question_answers", "question", $question->id, "id ASC")) {
|
||||
$oldanswers = array();
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype {
|
||||
$answer->answer = trim($dataanswer);
|
||||
$answer->fraction = $question->fraction[$key];
|
||||
$answer->feedback = $question->feedback[$key];
|
||||
if (!update_record("quiz_answers", $answer)) {
|
||||
if (!update_record("question_answers", $answer)) {
|
||||
$result->error = "Could not update quiz answer! (id=$answer->id)";
|
||||
return $result;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype {
|
||||
$answer->question = $question->id;
|
||||
$answer->fraction = $question->fraction[$key];
|
||||
$answer->feedback = $question->feedback[$key];
|
||||
if (!$answer->id = insert_record("quiz_answers", $answer)) {
|
||||
if (!$answer->id = insert_record("question_answers", $answer)) {
|
||||
$result->error = "Could not insert quiz answer!";
|
||||
return $result;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype {
|
||||
// delete old answer records
|
||||
if (!empty($oldanswers)) {
|
||||
foreach($oldanswers as $oa) {
|
||||
delete_records('quiz_answers', 'id', $oa->id);
|
||||
delete_records('question_answers', 'id', $oa->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
<?php question_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
$options = get_record("quiz_truefalse", "question", "$question->id");
|
||||
}
|
||||
if (!empty($options->trueanswer)) {
|
||||
$true = get_record("quiz_answers", "id", $options->trueanswer);
|
||||
$true = get_record("question_answers", "id", $options->trueanswer);
|
||||
} else {
|
||||
$true->fraction = 1;
|
||||
$true->feedback = "";
|
||||
}
|
||||
if (!empty($options->falseanswer)) {
|
||||
$false = get_record("quiz_answers", "id", "$options->falseanswer");
|
||||
$false = get_record("question_answers", "id", "$options->falseanswer");
|
||||
} else {
|
||||
$false->fraction = 0;
|
||||
$false->feedback = "";
|
||||
|
||||
@@ -14,7 +14,7 @@ class quiz_truefalse_qtype extends quiz_default_questiontype {
|
||||
function save_question_options($question) {
|
||||
|
||||
// fetch old answer ids so that we can reuse them
|
||||
if (!$oldanswers = get_records("quiz_answers", "question", $question->id, "id ASC")) {
|
||||
if (!$oldanswers = get_records("question_answers", "question", $question->id, "id ASC")) {
|
||||
$oldanswers = array();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class quiz_truefalse_qtype extends quiz_default_questiontype {
|
||||
$true->answer = get_string("true", "quiz");
|
||||
$true->fraction = $question->answer;
|
||||
$true->feedback = $question->feedbacktrue;
|
||||
if (!update_record("quiz_answers", $true)) {
|
||||
if (!update_record("question_answers", $true)) {
|
||||
$result->error = "Could not update quiz answer \"true\")!";
|
||||
return $result;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class quiz_truefalse_qtype extends quiz_default_questiontype {
|
||||
$true->question = $question->id;
|
||||
$true->fraction = $question->answer;
|
||||
$true->feedback = $question->feedbacktrue;
|
||||
if (!$true->id = insert_record("quiz_answers", $true)) {
|
||||
if (!$true->id = insert_record("question_answers", $true)) {
|
||||
$result->error = "Could not insert quiz answer \"true\")!";
|
||||
return $result;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class quiz_truefalse_qtype extends quiz_default_questiontype {
|
||||
$false->answer = get_string("false", "quiz");
|
||||
$false->fraction = 1 - (int)$question->answer;
|
||||
$false->feedback = $question->feedbackfalse;
|
||||
if (!update_record("quiz_answers", $false)) {
|
||||
if (!update_record("question_answers", $false)) {
|
||||
$result->error = "Could not insert quiz answer \"false\")!";
|
||||
return $result;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class quiz_truefalse_qtype extends quiz_default_questiontype {
|
||||
$false->question = $question->id;
|
||||
$false->fraction = 1 - (int)$question->answer;
|
||||
$false->feedback = $question->feedbackfalse;
|
||||
if (!$false->id = insert_record("quiz_answers", $false)) {
|
||||
if (!$false->id = insert_record("question_answers", $false)) {
|
||||
$result->error = "Could not insert quiz answer \"false\")!";
|
||||
return $result;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class quiz_truefalse_qtype extends quiz_default_questiontype {
|
||||
// delete any leftover old answer records (there couldn't really be any, but who knows)
|
||||
if (!empty($oldanswers)) {
|
||||
foreach($oldanswers as $oa) {
|
||||
delete_records('quiz_answers', 'id', $oa->id);
|
||||
delete_records('question_answers', 'id', $oa->id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ class quiz_truefalse_qtype extends quiz_default_questiontype {
|
||||
return false;
|
||||
}
|
||||
// Load the answers
|
||||
if (!$question->options->answers = get_records('quiz_answers', 'question', $question->id)) {
|
||||
if (!$question->options->answers = get_records('question_answers', 'question', $question->id)) {
|
||||
notify('Error: Missing question answers!');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
|
||||
<td align="left">
|
||||
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
<?php question_category_select_menu($course->id, true, true, $question->category); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
/// Now, check for commands on this page and modify variables as necessary
|
||||
|
||||
if (isset($_REQUEST['move']) and confirm_sesskey()) { /// Move selected questions to new category
|
||||
if (!$tocategory = get_record('quiz_categories', 'id', $_REQUEST['category'])) {
|
||||
if (!$tocategory = get_record('question_categories', 'id', $_REQUEST['category'])) {
|
||||
error('Invalid category');
|
||||
}
|
||||
if (!isteacheredit($tocategory->course)) {
|
||||
@@ -130,7 +130,7 @@
|
||||
|
||||
/// all commands have been dealt with, now print the page
|
||||
|
||||
if (empty($SESSION->questioncat) or !record_exists('quiz_categories', 'id', $SESSION->questioncat)) {
|
||||
if (empty($SESSION->questioncat) or !record_exists('question_categories', 'id', $SESSION->questioncat)) {
|
||||
$category = get_default_question_category($course->id);
|
||||
$SESSION->questioncat = $category->id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user