Should fix bug with the quiz_answerid_auto when migrating courses

skala
Julio Montoya 13 years ago
parent cd9fdde53a
commit c6b6c83944
  1. 4
      main/exercice/answer.class.php
  2. 16
      main/inc/lib/add_course.lib.inc.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]);

@ -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('<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="110" valign="top" align="left"><img src="'.api_get_path(WEB_CODE_PATH).'default_course_document/images/mr_dokeos/thinking.jpg"></td><td valign="top" align="left">'.get_lang('Antique').'</td></tr></table>');
Database::query('INSERT INTO '.$TABLEQUIZ . ' (c_id, title, description, type, random, random_answers, active, results_disabled )

Loading…
Cancel
Save