23 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
87 $this->thumb_size = 150;
89 $this->answers = array();
101 if (($this->title) and ($this->author) and ($this->question) and (count($this->answers)) and ($this->
getMaximumPoints() > 0))
103 foreach ($this->answers as $answer)
105 if ((strlen($answer->getAnswertext()) == 0) && (strlen($answer->getImage()) == 0))
return false;
133 array($this->
getId())
138 $oldthumbsize =
$data[
'thumb_size'];
141 if (!$this->isSingleline)
147 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
149 array($this->
getId())
152 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, shuffle, allow_images, thumb_size) VALUES (%s, %s, %s, %s)",
153 array(
"integer",
"text",
"text",
"integer"),
157 ($this->isSingleline) ?
"0" :
"1",
162 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_a_sc WHERE question_fi = %s",
164 array($this->
getId())
167 foreach ($this->answers as
$key => $value)
169 $answer_obj = $this->answers[
$key];
170 $next_id = $ilDB->nextId(
'qpl_a_sc');
171 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_a_sc (answer_id, question_fi, answertext, points, aorder, imagefile, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
172 array(
'integer',
'integer',
'text',
'float',
'integer',
'text',
'integer'),
177 $answer_obj->getPoints(),
178 $answer_obj->getOrder(),
179 $answer_obj->getImage(),
198 if (strlen($answer->getImage()))
219 switch (strtoupper($path_info[
'extension']))
255 $this->
setId($question_id);
264 include_once(
"./Services/RTE/classes/class.ilRTE.php");
270 $this->isSingleline = (
$data[
'allow_images']) ?
false :
true;
271 $this->lastChange =
$data[
'tstamp'];
274 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_sc WHERE question_fi = %s ORDER BY aorder ASC",
278 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
284 if (!@file_exists($imagefilename))
286 $data[
"imagefile"] =
"";
288 include_once(
"./Services/RTE/classes/class.ilRTE.php");
310 $this_id = $this->
getId();
312 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
338 $clone->copyPageOfQuestion($this_id);
341 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
343 $clone->duplicateImages($this_id);
345 $clone->duplicateFeedbackGeneric($this_id);
347 $clone->duplicateFeedbackAnswer($this_id);
348 $clone->onDuplicate($this_id);
367 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
370 $source_questionpool = $this->
getObjId();
371 $clone->setObjId($target_questionpool);
436 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
437 if (array_key_exists($order, $this->answers))
441 $newchoices = array();
442 for ($i = 0; $i < $order; $i++)
444 array_push($newchoices, $this->answers[$i]);
446 array_push($newchoices, $answer);
447 for ($i = $order; $i < count($this->answers); $i++)
453 $this->answers = $newchoices;
459 array_push($this->answers, $answer);
472 return count($this->answers);
486 if ($index < 0)
return NULL;
487 if (count($this->answers) < 1)
return NULL;
488 if ($index >= count($this->answers))
return NULL;
490 return $this->answers[$index];
503 if ($index < 0)
return;
504 if (count($this->answers) < 1)
return;
505 if ($index >= count($this->answers))
return;
506 $answer = $this->answers[$index];
507 if (strlen($answer->getImage())) $this->
deleteImage($answer->getImage());
508 unset($this->answers[$index]);
509 $this->answers = array_values($this->answers);
510 for ($i = 0; $i < count($this->answers); $i++)
512 if ($this->answers[$i]->getOrder() > $index)
514 $this->answers[$i]->setOrder($i);
527 $this->answers = array();
539 foreach ($this->answers as
$key => $value)
541 if ($value->getPoints() >
$points)
562 $found_values = array();
567 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
568 array(
'integer',
'integer',
'integer'),
573 if (strcmp(
$data[
"value1"],
"") != 0)
575 array_push($found_values,
$data[
"value1"]);
579 foreach ($this->answers as
$key => $answer)
581 if (count($found_values) > 0)
583 if (in_array(
$key, $found_values))
585 $points += $answer->getPoints();
609 include_once
"./Modules/Test/classes/class.ilObjTest.php";
614 $result = $ilDB->queryF(
"SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
615 array(
'integer',
'integer',
'integer'),
619 $update =
$row[
"solution_id"];
623 if (strlen(
$_POST[
"multiple_choice_result"]))
625 $affectedRows = $ilDB->update(
"tst_solutions", array(
626 "value1" => array(
"clob",
$_POST[
"multiple_choice_result"]),
627 "tstamp" => array(
"integer", time())
629 "solution_id" => array(
"integer", $update)
635 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE solution_id = %s",
643 if (strlen(
$_POST[
"multiple_choice_result"]))
645 $next_id = $ilDB->nextId(
'tst_solutions');
646 $affectedRows = $ilDB->insert(
"tst_solutions", array(
647 "solution_id" => array(
"integer", $next_id),
648 "active_fi" => array(
"integer", $active_id),
649 "question_fi" => array(
"integer", $this->
getId()),
650 "value1" => array(
"clob",
$_POST[
'multiple_choice_result']),
651 "value2" => array(
"clob", null),
652 "pass" => array(
"integer",
$pass),
653 "tstamp" => array(
"integer", time())
660 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
668 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
690 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_sc WHERE question_fi = %s",
692 array($this->original_id)
696 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_sc WHERE question_fi = %s",
698 array($this->
getId())
706 $next_id = $ilDB->nextId(
'qpl_fb_sc');
707 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_fb_sc (feedback_id, question_fi, answer, feedback, tstamp) VALUES (%s, %s, %s, %s, %s)",
708 array(
'integer',
'integer',
'integer',
'text',
'integer'),
739 return "assSingleChoice";
775 if (!empty($image_tempfilename))
777 $image_filename = str_replace(
" ",
"_", $image_filename);
779 if (!file_exists($imagepath))
790 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
792 if (!preg_match(
"/^image/", $mimetype))
794 unlink($imagepath . $image_filename);
819 @unlink($imagepath . $image_filename);
820 $thumbpath = $imagepath . $this->
getThumbPrefix() . $image_filename;
828 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
829 foreach ($this->answers as $answer)
834 if (!file_exists($imagepath))
838 if (!@copy($imagepath_original .
$filename, $imagepath . $filename))
840 $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
841 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
843 if (@file_exists($imagepath_original. $this->getThumbPrefix().
$filename))
847 $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
848 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
859 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
860 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
861 foreach ($this->answers as $answer)
866 if (!file_exists($imagepath))
870 if (!@copy($imagepath_original .
$filename, $imagepath . $filename))
872 $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
873 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
875 if (@file_exists($imagepath_original. $this->getThumbPrefix().
$filename))
879 $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
880 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
895 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
897 foreach ($this->answers as $answer)
902 if (!file_exists($imagepath))
906 if (@file_exists($imagepath .
$filename))
908 if (!file_exists($imagepath))
912 if (!file_exists($imagepath_original))
916 if (!@copy($imagepath . $filename, $imagepath_original . $filename))
918 $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
919 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
922 if (@file_exists($imagepath . $this->
getThumbPrefix() . $filename))
926 $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
927 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
945 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_sc WHERE question_fi = %s AND answer = %s",
946 array(
'integer',
'integer'),
947 array($this->
getId(), $answer_index)
949 if (strlen($feedback))
951 include_once(
"./Services/RTE/classes/class.ilRTE.php");
952 $next_id = $ilDB->nextId(
'qpl_fb_sc');
953 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_fb_sc (feedback_id, question_fi, answer, feedback, tstamp) VALUES (%s, %s, %s, %s, %s)",
954 array(
'integer',
'integer',
'integer',
'text',
'integer'),
978 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_sc WHERE question_fi = %s AND answer = %s",
979 array(
'integer',
'integer'),
980 array($this->
getId(), $answer_index)
985 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1002 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_sc WHERE question_fi = %s",
1010 $next_id = $ilDB->nextId(
'qpl_fb_sc');
1011 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_fb_sc (feedback_id, question_fi, answer, feedback, tstamp) VALUES (%s, %s, %s, %s, %s)",
1012 array(
'integer',
'integer',
'integer',
'text',
'integer'),
1032 foreach ($this->answers as $index => $answer)
1035 $answer_obj = $this->answers[$index];
1036 $text .= $answer_obj->getAnswertext();
1063 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
1071 if (
$id == $solution[0][
"value1"])
1073 $worksheet->write($startrow + $i, 1, 1);
1077 $worksheet->write($startrow + $i, 1, 0);
1081 return $startrow + $i + 1;
1091 $this->thumb_size = $a_size;
1099 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1115 "answertext" => (
string) $answer_obj->getAnswertext(),
1116 "points" => (float)$answer_obj->getPoints(),
1117 "order" => (int)$answer_obj->getOrder(),
1118 "image" => $answer_obj->getImage(),
1130 $answer = $this->answers[$index];
1131 if (is_object($answer))
1134 $answer->setImage(
'');
1140 $value = rand(0, count($this->answers)-1);
1141 $_POST[
"multiple_choice_result"] = (strlen($value)) ? (
string)$value :
'0';
1149 $multilineAnswerSetting = $ilUser->getPref(
"tst_multiline_answers");
1150 if ($multilineAnswerSetting != 1)
1152 $multilineAnswerSetting = 0;
1154 return $multilineAnswerSetting;
1160 $ilUser->writePref(
"tst_multiline_answers", $a_setting);