From c6b6c839447f283ca95c60bd223b88fb09a930ff Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 14 Jun 2012 19:46:30 +0200 Subject: [PATCH] Should fix bug with the quiz_answerid_auto when migrating courses --- main/exercice/answer.class.php | 4 ++-- main/inc/lib/add_course.lib.inc.php | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/main/exercice/answer.class.php b/main/exercice/answer.class.php index 0d06e5e142..d23f08472e 100644 --- a/main/exercice/answer.class.php +++ b/main/exercice/answer.class.php @@ -107,7 +107,7 @@ class Answer { $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); $questionId=$this->questionId; - $sql="SELECT id,answer,correct,comment,ponderation, position, hotspot_coordinates, hotspot_type, destination, id_auto FROM + $sql="SELECT id, id_auto, answer,correct,comment,ponderation, position, hotspot_coordinates, hotspot_type, destination FROM $TBL_ANSWER WHERE c_id = {$this->course_id} AND question_id ='".$questionId."' ORDER BY position"; $result=Database::query($sql); @@ -473,7 +473,7 @@ class Answer { $c_id = $this->course['real_id']; // inserts new answers into data base $sql = "INSERT INTO $TBL_REPONSES (c_id, id, question_id, answer,correct,comment, ponderation,position,hotspot_coordinates,hotspot_type,destination) VALUES "; - for ($i=1;$i <= $this->new_nbrAnswers;$i++) { + for ($i=1;$i <= $this->new_nbrAnswers; $i++) { $answer = Database::escape_string($this->new_answer[$i]); $correct = Database::escape_string($this->new_correct[$i]); $comment = Database::escape_string($this->new_comment[$i]); diff --git a/main/inc/lib/add_course.lib.inc.php b/main/inc/lib/add_course.lib.inc.php index ceeeb5e11e..28c1d2076f 100644 --- a/main/inc/lib/add_course.lib.inc.php +++ b/main/inc/lib/add_course.lib.inc.php @@ -753,6 +753,7 @@ function create_course_tables($course_db_name = null) { CREATE TABLE `".$TABLEQUIZANSWERSLIST . "` ( $add_to_all_tables id int unsigned NOT NULL, + id_auto int NOT NULL AUTO_INCREMENT, question_id int unsigned NOT NULL, answer text NOT NULL, correct mediumint unsigned default NULL, @@ -761,11 +762,9 @@ function create_course_tables($course_db_name = null) { position mediumint unsigned NOT NULL default 1, hotspot_coordinates text, hotspot_type enum('square','circle','poly','delineation','oar') default NULL, - destination text NOT NULL, - id_auto int NOT NULL AUTO_INCREMENT, + destination text NOT NULL, answer_code char(10) default '', - PRIMARY KEY (c_id, id, question_id), - UNIQUE KEY id_auto (id_auto) + PRIMARY KEY (c_id, id_auto) )" . $charset_clause; Database::query($sql); @@ -2452,10 +2451,11 @@ function fill_db_course($course_id, $course_repository, $language, $default_docu /* Exercise tool */ - Database::query("INSERT INTO $TABLEQUIZANSWERSLIST VALUES ($course_id, '1', '1', '".lang2db(get_lang('Ridiculise')) . "', '0', '".lang2db(get_lang('NoPsychology')) . "', '-5', '1','','','','')"); - Database::query("INSERT INTO $TABLEQUIZANSWERSLIST VALUES ($course_id, '2', '1', '".lang2db(get_lang('AdmitError')) . "', '0', '".lang2db(get_lang('NoSeduction')) . "', '-5', '2','','','','')"); - Database::query("INSERT INTO $TABLEQUIZANSWERSLIST VALUES ($course_id, '3', '1', '".lang2db(get_lang('Force')) . "', '1', '".lang2db(get_lang('Indeed')) . "', '5', '3','','','','')"); - Database::query("INSERT INTO $TABLEQUIZANSWERSLIST VALUES ($course_id, '4', '1', '".lang2db(get_lang('Contradiction')) . "', '1', '".lang2db(get_lang('NotFalse')) . "', '5', '4','','','','')"); + Database::query("INSERT INTO $TABLEQUIZANSWERSLIST (c_id, id, question_id, answer, correct, comment, ponderation, position) VALUES ($course_id, '1', '1', '".lang2db(get_lang('Ridiculise')) . "', '0', '".lang2db(get_lang('NoPsychology')) . "', '-5', '1')"); + Database::query("INSERT INTO $TABLEQUIZANSWERSLIST (c_id, id, question_id, answer, correct, comment, ponderation, position) VALUES ($course_id, '2', '1', '".lang2db(get_lang('AdmitError')) . "', '0', '".lang2db(get_lang('NoSeduction')) . "', '-5', '2')"); + Database::query("INSERT INTO $TABLEQUIZANSWERSLIST (c_id, id, question_id, answer, correct, comment, ponderation, position) VALUES ($course_id, '3', '1', '".lang2db(get_lang('Force')) . "', '1', '".lang2db(get_lang('Indeed')) . "', '5', '3')"); + Database::query("INSERT INTO $TABLEQUIZANSWERSLIST (c_id, id, question_id, answer, correct, comment, ponderation, position) VALUES ($course_id, '4', '1', '".lang2db(get_lang('Contradiction')) . "', '1', '".lang2db(get_lang('NotFalse')) . "', '5', '4')"); + $html=Database::escape_string('
'.get_lang('Antique').'
'); Database::query('INSERT INTO '.$TABLEQUIZ . ' (c_id, title, description, type, random, random_answers, active, results_disabled )