4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
5 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
7 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjAnswerScoringAdjustable.php';
8 require_once
'./Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php';
9 require_once
'./Modules/TestQuestionPool/classes/class.ilUserQuestionResult.php';
84 $this->thumb_size = 150;
86 $this->answers = array();
88 $this->feedback_setting = 2;
99 if (strlen($this->title) and ($this->author) and ($this->question) and (count($this->answers)) and ($this->
getMaximumPoints() > 0))
101 foreach ($this->answers as $answer)
103 if ((strlen($answer->getAnswertext()) == 0) && (strlen($answer->getImage()) == 0))
return false;
133 array($this->
getId())
137 $data = $ilDB->fetchAssoc(
$result);
138 $oldthumbsize = $data[
'thumb_size'];
159 if (strlen($answer->getImage()))
180 switch (strtoupper($path_info[
'extension']))
215 $data = $ilDB->fetchAssoc(
$result);
216 $this->
setId($question_id);
225 include_once(
"./Services/RTE/classes/class.ilRTE.php");
227 $shuffle = (is_null($data[
'shuffle'])) ?
true : $data[
'shuffle'];
229 $this->
setEstimatedWorkingTime(substr($data[
"working_time"], 0, 2), substr($data[
"working_time"], 3, 2), substr($data[
"working_time"], 6, 2));
231 $this->isSingleline = ($data[
'allow_images']) ?
false :
true;
232 $this->lastChange = $data[
'tstamp'];
233 $this->feedback_setting = $data[
'feedback_setting'];
244 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_sc WHERE question_fi = %s ORDER BY aorder ASC",
248 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
251 while ($data = $ilDB->fetchAssoc(
$result))
253 $imagefilename = $this->
getImagePath() . $data[
"imagefile"];
254 if (!@file_exists($imagefilename))
256 $data[
"imagefile"] =
"";
258 include_once(
"./Services/RTE/classes/class.ilRTE.php");
260 array_push($this->answers,
new ASS_AnswerBinaryStateImage($data[
"answertext"], $data[
"points"], $data[
"aorder"], 1, $data[
"imagefile"]));
280 $this_id = $this->
getId();
284 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
288 if( (
int)$testObjId > 0 )
290 $clone->setObjId($testObjId);
316 $clone->copyPageOfQuestion($this_id);
319 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
321 $clone->duplicateImages($this_id, $thisObjId);
323 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
342 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
345 $source_questionpool_id = $this->
getObjId();
346 $clone->setObjId($target_questionpool_id);
357 $clone->copyImages(
$original_id, $source_questionpool_id);
359 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
372 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
375 $sourceParentId = $this->
getObjId();
381 $clone->setObjId($targetParentId);
383 if ($targetQuestionTitle)
385 $clone->setTitle($targetQuestionTitle);
390 $clone->copyPageOfQuestion($sourceQuestionId);
392 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
394 $clone->copyImages($sourceQuestionId, $sourceParentId);
396 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
445 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
446 if (array_key_exists($order, $this->answers))
450 $newchoices = array();
451 for ($i = 0; $i < $order; $i++)
453 array_push($newchoices, $this->answers[$i]);
455 array_push($newchoices, $answer);
456 for ($i = $order; $i < count($this->answers); $i++)
462 $this->answers = $newchoices;
468 array_push($this->answers, $answer);
481 return count($this->answers);
495 if ($index < 0)
return NULL;
496 if (count($this->answers) < 1)
return NULL;
497 if ($index >= count($this->answers))
return NULL;
499 return $this->answers[$index];
512 if ($index < 0)
return;
513 if (count($this->answers) < 1)
return;
514 if ($index >= count($this->answers))
return;
515 $answer = $this->answers[$index];
516 if (strlen($answer->getImage())) $this->
deleteImage($answer->getImage());
517 unset($this->answers[$index]);
518 $this->answers = array_values($this->answers);
519 for ($i = 0; $i < count($this->answers); $i++)
521 if ($this->answers[$i]->getOrder() > $index)
523 $this->answers[$i]->setOrder($i);
536 $this->answers = array();
548 foreach ($this->answers as $key => $value)
550 if ($value->getPoints() >
$points)
572 throw new ilTestException(
'return details not implemented for '.__METHOD__);
577 $found_values = array();
582 $result = $this->getCurrentSolutionResultSet($active_id,
$pass);
583 while ($data = $ilDB->fetchAssoc(
$result))
585 if (strcmp($data[
"value1"],
"") != 0)
587 array_push($found_values, $data[
"value1"]);
591 foreach ($this->answers as $key => $answer)
593 if (count($found_values) > 0)
595 if (in_array($key, $found_values))
597 $points += $answer->getPoints();
607 foreach ($this->answers as $key => $answer)
611 return $answer->getPoints();
633 include_once
"./Modules/Test/classes/class.ilObjTest.php";
640 $result = $this->getCurrentSolutionResultSet($active_id,
$pass);
642 $update =
$row[
"solution_id"];
646 if (strlen(
$_POST[
"multiple_choice_result"]))
648 $affectedRows = $ilDB->update(
"tst_solutions", array(
649 "value1" => array(
"clob",
$_POST[
"multiple_choice_result"]),
650 "tstamp" => array(
"integer", time())
652 "solution_id" => array(
"integer", $update)
658 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE solution_id = %s",
666 if (strlen(
$_POST[
"multiple_choice_result"]))
668 $affectedRows = $this->saveCurrentSolution($active_id,
$pass,
$_POST[
'multiple_choice_result'], null);
677 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
685 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
697 if( strlen(
$_POST[
'multiple_choice_result'.$this->
getId().
'ID']) )
715 array( $this->
getId() )
719 ) .
" (question_fi, shuffle, allow_images, thumb_size) VALUES (%s, %s, %s, %s)",
720 array(
"integer",
"text",
"text",
"integer" ),
724 ($this->isSingleline) ?
"0" :
"1",
734 if (!$this->isSingleline)
738 $ilDB->manipulateF(
"DELETE FROM qpl_a_sc WHERE question_fi = %s",
740 array( $this->
getId() )
743 foreach ($this->answers as $key => $value)
746 $answer_obj = $this->answers[$key];
747 $next_id = $ilDB->nextId(
'qpl_a_sc' );
748 $ilDB->manipulateF(
"INSERT INTO qpl_a_sc (answer_id, question_fi, answertext, points, aorder, imagefile, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
749 array(
'integer',
'integer',
'text',
'float',
'integer',
'text',
'integer' ),
754 $answer_obj->getPoints(),
755 $answer_obj->getOrder(),
756 $answer_obj->getImage(),
794 return "assSingleChoice";
830 if (!empty($image_tempfilename))
832 $image_filename = str_replace(
" ",
"_", $image_filename);
834 if (!file_exists($imagepath))
845 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
847 if (!preg_match(
"/^image/", $mimetype))
849 unlink($imagepath . $image_filename);
874 @unlink($imagepath . $image_filename);
875 $thumbpath = $imagepath . $this->
getThumbPrefix() . $image_filename;
883 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
885 if( (
int)$objectId > 0 )
887 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
890 foreach ($this->answers as $answer)
895 if (!file_exists($imagepath))
899 if (!@copy($imagepath_original .
$filename, $imagepath . $filename))
901 $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
902 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
904 if (@file_exists($imagepath_original. $this->getThumbPrefix().
$filename))
908 $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
909 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
920 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
921 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
922 foreach ($this->answers as $answer)
927 if (!file_exists($imagepath))
931 if (!@copy($imagepath_original .
$filename, $imagepath . $filename))
933 $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
934 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
936 if (@file_exists($imagepath_original. $this->getThumbPrefix().
$filename))
940 $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
941 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
956 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
958 foreach ($this->answers as $answer)
963 if (@file_exists($imagepath .
$filename))
965 if (!file_exists($imagepath))
969 if (!file_exists($imagepath_original))
973 if (!@copy($imagepath . $filename, $imagepath_original . $filename))
975 $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
976 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
979 if (@file_exists($imagepath . $this->
getThumbPrefix() . $filename))
983 $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
984 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
998 foreach ($this->answers as $index => $answer)
1000 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), $index);
1001 $answer_obj = $this->answers[$index];
1002 $text .= $answer_obj->getAnswertext();
1029 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
1037 if (
$id == $solution[0][
"value1"])
1039 $worksheet->write($startrow + $i, 1, 1);
1043 $worksheet->write($startrow + $i, 1, 0);
1047 return $startrow + $i + 1;
1057 $this->thumb_size = $a_size;
1065 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1069 $reilUtilsult[
'title'] = (string) $this->
getTitle();
1075 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
1076 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
1081 foreach ($this->
getAnswers() as $key => $answer_obj)
1083 if((
string) $answer_obj->getImage())
1087 array_push($answers, array(
1088 "answertext" => (
string) $this->
formatSAQuestion($answer_obj->getAnswertext()),
1089 "points" => (
float)$answer_obj->getPoints(),
1090 "order" => (int)$answer_obj->getOrder(),
1091 "image" => (string) $answer_obj->getImage(),
1093 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key), 0
1112 $answer = $this->answers[$index];
1113 if (is_object($answer))
1116 $answer->setImage(
'');
1122 $value = rand(0, count($this->answers)-1);
1123 $_POST[
"multiple_choice_result"] = (strlen($value)) ? (
string)$value :
'0';
1131 $multilineAnswerSetting = $ilUser->getPref(
"tst_multiline_answers");
1132 if ($multilineAnswerSetting != 1)
1134 $multilineAnswerSetting = 0;
1136 return $multilineAnswerSetting;
1142 $ilUser->writePref(
"tst_multiline_answers", $a_setting);
1156 $this->feedback_setting = $a_feedback_setting;
1170 if ($this->feedback_setting)
1194 return $numExistingSolutionRecords > 0;
1222 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1253 $data = $ilDB->queryF(
1254 "SELECT * FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = (
1255 SELECT MAX(step) FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s
1257 array(
"integer",
"integer",
"integer",
"integer",
"integer",
"integer"),
1261 $row = $ilDB->fetchAssoc($data);