|
@@ -36,6 +36,7 @@ class Answer
|
|
|
public $new_nbrAnswers;
|
|
|
public $new_destination; // id of the next question if feedback option is set to Directfeedback
|
|
|
public $course; //Course information
|
|
|
+ public $iid;
|
|
|
|
|
|
/**
|
|
|
* constructor of the class
|
|
@@ -128,6 +129,7 @@ class Answer
|
|
|
$this->hotspot_type[$i] = $object->hotspot_type;
|
|
|
$this->destination[$i] = $object->destination;
|
|
|
$this->autoId[$i] = $object->id_auto;
|
|
|
+ $this->iid[$i] = $object->iid;
|
|
|
$i++;
|
|
|
}
|
|
|
$this->nbrAnswers = $i-1;
|
|
@@ -224,7 +226,8 @@ class Answer
|
|
|
hotspot_coordinates,
|
|
|
hotspot_type,
|
|
|
destination,
|
|
|
- id_auto
|
|
|
+ id_auto,
|
|
|
+ iid
|
|
|
FROM $TBL_ANSWER
|
|
|
WHERE
|
|
|
c_id = {$this->course_id} AND
|
|
@@ -249,6 +252,7 @@ class Answer
|
|
|
$this->hotspot_type[$i] = $object->hotspot_type;
|
|
|
$this->destination[$i] = $object->destination;
|
|
|
$this->autoId[$i] = $object->id_auto;
|
|
|
+ $this->iid[$i] = $object->iid;
|
|
|
$i++;
|
|
|
}
|
|
|
|
|
@@ -262,6 +266,7 @@ class Answer
|
|
|
$this->hotspot_type[$i] = $object->hotspot_type;
|
|
|
$this->destination[$i] = $doubt_data->destination;
|
|
|
$this->autoId[$i] = $doubt_data->id_auto;
|
|
|
+ $this->iid[$i] = $doubt_data->iid;
|
|
|
$i++;
|
|
|
}
|
|
|
$this->nbrAnswers = $i-1;
|
|
@@ -545,7 +550,7 @@ class Answer
|
|
|
* Updates an answer
|
|
|
*
|
|
|
* @author Toon Keppens
|
|
|
- *
|
|
|
+ * @param int $iid
|
|
|
* @param string $answer
|
|
|
* @param string $comment
|
|
|
* @param string $correct
|
|
@@ -556,7 +561,7 @@ class Answer
|
|
|
* @param string $hotspot_type
|
|
|
*/
|
|
|
public function updateAnswers(
|
|
|
- $autoId,
|
|
|
+ $iid,
|
|
|
$answer,
|
|
|
$comment,
|
|
|
$correct,
|
|
@@ -567,7 +572,6 @@ class Answer
|
|
|
$hotspot_type
|
|
|
) {
|
|
|
$answerTable = Database :: get_course_table(TABLE_QUIZ_ANSWER);
|
|
|
- $autoId = intval($autoId);
|
|
|
|
|
|
$params = [
|
|
|
'answer' => $answer,
|
|
@@ -578,10 +582,9 @@ class Answer
|
|
|
'destination' => $destination,
|
|
|
'hotspot_coordinates' => $hotspot_coordinates,
|
|
|
'hotspot_type' => $hotspot_type
|
|
|
-
|
|
|
];
|
|
|
|
|
|
- Database::update($answerTable, $params, ['id_auto = ?' => $autoId]);
|
|
|
+ Database::update($answerTable, $params, ['iid = ?' => intval($iid)]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -608,6 +611,7 @@ class Answer
|
|
|
$hotspot_type = $this->new_hotspot_type[$i];
|
|
|
$destination = $this->new_destination[$i];
|
|
|
$autoId = $this->selectAutoId($i);
|
|
|
+ $iid = isset($this->iid[$i]) ? $this->iid[$i] : 0;
|
|
|
|
|
|
if (!isset($this->position[$i])) {
|
|
|
$params = [
|
|
@@ -623,9 +627,9 @@ class Answer
|
|
|
'hotspot_type' => $hotspot_type,
|
|
|
'destination' => $destination
|
|
|
];
|
|
|
- $autoId = Database::insert($answerTable, $params);
|
|
|
- if ($autoId) {
|
|
|
- $sql = "UPDATE $answerTable SET id = iid, id_auto = iid WHERE iid = $autoId";
|
|
|
+ $iid = Database::insert($answerTable, $params);
|
|
|
+ if ($iid) {
|
|
|
+ $sql = "UPDATE $answerTable SET id = iid, id_auto = iid WHERE iid = $iid";
|
|
|
Database::query($sql);
|
|
|
|
|
|
$questionType = $this->getQuestionType();
|
|
@@ -643,7 +647,7 @@ class Answer
|
|
|
Database::update(
|
|
|
$answerTable,
|
|
|
['correct' => $correctAnswerAutoId ? $correctAnswerAutoId : 0],
|
|
|
- ['iid = ?' => $autoId]
|
|
|
+ ['iid = ?' => $iid]
|
|
|
);
|
|
|
}
|
|
|
}
|
|
@@ -653,7 +657,7 @@ class Answer
|
|
|
// Feed function updateAnswers with none escaped strings
|
|
|
|
|
|
$this->updateAnswers(
|
|
|
- $autoId,
|
|
|
+ $iid,
|
|
|
$this->new_answer[$i],
|
|
|
$this->new_comment[$i],
|
|
|
$this->new_correct[$i],
|
|
@@ -665,10 +669,10 @@ class Answer
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- $answerList[$i] = $autoId;
|
|
|
+ $answerList[$i] = $iid;
|
|
|
|
|
|
if ($correct) {
|
|
|
- $correctList[$autoId] = true;
|
|
|
+ $correctList[$iid] = true;
|
|
|
}
|
|
|
}
|
|
|
|