Fixed matching answer wrong when copy or export to another course - partial CT#493

skala
Cristian Fasanando 15 years ago
parent af1122faad
commit 6007e30ea2
  1. 2
      main/coursecopy/classes/CourseBuilder.class.php
  2. 14
      main/coursecopy/classes/CourseRestorer.class.php
  3. 5
      main/coursecopy/classes/QuizQuestion.class.php

@ -375,7 +375,7 @@ class CourseBuilder
$db_result2 = Database::query($sql, __FILE__, __LINE__);
while ($obj2 = Database::fetch_object($db_result2))
{
$question->add_answer($obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type);
$question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type);
}
$this->course->add_resource($question);
}

@ -880,10 +880,18 @@ class CourseRestorer
$sql = "INSERT INTO ".$table_que." SET question = '".addslashes($question->question)."', description = '".addslashes($question->description)."', ponderation = '".addslashes($question->ponderation)."', position = '".addslashes($question->position)."', type='".addslashes($question->quiz_type)."', picture='".addslashes($question->picture)."', level='".addslashes($question->level)."'";
Database::query($sql, __FILE__, __LINE__);
$new_id = Database::insert_id();
foreach ($question->answers as $index => $answer)
{
$sql = "INSERT INTO ".$table_ans." SET id= '". ($index +1)."',question_id = '".$new_id."', answer = '".Database::escape_string($answer['answer'])."', correct = '".$answer['correct']."', comment = '".Database::escape_string($answer['comment'])."', ponderation='".$answer['ponderation']."', position = '".$answer['position']."', hotspot_coordinates = '".$answer['hotspot_coordinates']."', hotspot_type = '".$answer['hotspot_type']."'";
if ($question->quiz_type == 4) { // for answer type matching
foreach ($question->answers as $index => $answer) {
$sql = "INSERT INTO ".$table_ans." SET id= '".$answer['id']."',question_id = '".$new_id."', answer = '".Database::escape_string($answer['answer'])."', correct = '".$answer['correct']."', comment = '".Database::escape_string($answer['comment'])."', ponderation='".$answer['ponderation']."', position = '".$answer['position']."', hotspot_coordinates = '".$answer['hotspot_coordinates']."', hotspot_type = '".$answer['hotspot_type']."'";
Database::query($sql, __FILE__, __LINE__);
}
} else {
foreach ($question->answers as $index => $answer) {
$sql = "INSERT INTO ".$table_ans." SET id= '". ($index +1)."',question_id = '".$new_id."', answer = '".Database::escape_string($answer['answer'])."', correct = '".$answer['correct']."', comment = '".Database::escape_string($answer['comment'])."', ponderation='".$answer['ponderation']."', position = '".$answer['position']."', hotspot_coordinates = '".$answer['hotspot_coordinates']."', hotspot_type = '".$answer['hotspot_type']."'";
Database::query($sql, __FILE__, __LINE__);
}
}
$this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
}

@ -87,9 +87,10 @@ class QuizQuestion extends Resource
/**
* Add an answer to this QuizQuestion
*/
function add_answer($answer_text,$correct,$comment,$ponderation,$position,$hotspot_coordinates,$hotspot_type)
function add_answer($answer_id, $answer_text,$correct,$comment,$ponderation,$position,$hotspot_coordinates,$hotspot_type)
{
$answer = array();
$answer = array();
$answer['id'] = $answer_id;
$answer['answer'] = $answer_text;
$answer['correct'] = $correct;
$answer['comment'] = $comment;

Loading…
Cancel
Save