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';
82 $this->thumb_size = 150;
84 $this->answers = array();
86 $this->feedback_setting = 2;
97 if (strlen($this->title) and ($this->author) and ($this->question) and (count($this->answers)) and ($this->
getMaximumPoints() > 0))
99 foreach ($this->answers as $answer)
101 if ((strlen($answer->getAnswertext()) == 0) && (strlen($answer->getImage()) == 0))
return false;
131 array($this->
getId())
135 $data = $ilDB->fetchAssoc(
$result);
136 $oldthumbsize = $data[
'thumb_size'];
157 if (strlen($answer->getImage()))
178 switch (strtoupper($path_info[
'extension']))
213 $data = $ilDB->fetchAssoc(
$result);
214 $this->
setId($question_id);
223 include_once(
"./Services/RTE/classes/class.ilRTE.php");
225 $shuffle = (is_null($data[
'shuffle'])) ?
true : $data[
'shuffle'];
227 $this->
setEstimatedWorkingTime(substr($data[
"working_time"], 0, 2), substr($data[
"working_time"], 3, 2), substr($data[
"working_time"], 6, 2));
229 $this->isSingleline = ($data[
'allow_images']) ?
false :
true;
230 $this->lastChange = $data[
'tstamp'];
231 $this->feedback_setting = $data[
'feedback_setting'];
242 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_sc WHERE question_fi = %s ORDER BY aorder ASC",
246 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
249 while ($data = $ilDB->fetchAssoc(
$result))
251 $imagefilename = $this->
getImagePath() . $data[
"imagefile"];
252 if (!@file_exists($imagefilename))
254 $data[
"imagefile"] =
"";
256 include_once(
"./Services/RTE/classes/class.ilRTE.php");
258 array_push($this->answers,
new ASS_AnswerBinaryStateImage($data[
"answertext"], $data[
"points"], $data[
"aorder"], 1, $data[
"imagefile"]));
278 $this_id = $this->
getId();
282 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
286 if( (
int)$testObjId > 0 )
288 $clone->setObjId($testObjId);
314 $clone->copyPageOfQuestion($this_id);
317 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
319 $clone->duplicateImages($this_id, $thisObjId);
321 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
340 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
343 $source_questionpool_id = $this->
getObjId();
344 $clone->setObjId($target_questionpool_id);
355 $clone->copyImages(
$original_id, $source_questionpool_id);
357 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
370 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
373 $sourceParentId = $this->
getObjId();
379 $clone->setObjId($targetParentId);
381 if ($targetQuestionTitle)
383 $clone->setTitle($targetQuestionTitle);
388 $clone->copyPageOfQuestion($sourceQuestionId);
390 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
392 $clone->copyImages($sourceQuestionId, $sourceParentId);
394 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
443 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
444 if (array_key_exists($order, $this->answers))
448 $newchoices = array();
449 for ($i = 0; $i < $order; $i++)
451 array_push($newchoices, $this->answers[$i]);
453 array_push($newchoices, $answer);
454 for ($i = $order; $i < count($this->answers); $i++)
460 $this->answers = $newchoices;
466 array_push($this->answers, $answer);
479 return count($this->answers);
493 if ($index < 0)
return NULL;
494 if (count($this->answers) < 1)
return NULL;
495 if ($index >= count($this->answers))
return NULL;
497 return $this->answers[$index];
510 if ($index < 0)
return;
511 if (count($this->answers) < 1)
return;
512 if ($index >= count($this->answers))
return;
513 $answer = $this->answers[$index];
514 if (strlen($answer->getImage())) $this->
deleteImage($answer->getImage());
515 unset($this->answers[$index]);
516 $this->answers = array_values($this->answers);
517 for ($i = 0; $i < count($this->answers); $i++)
519 if ($this->answers[$i]->getOrder() > $index)
521 $this->answers[$i]->setOrder($i);
534 $this->answers = array();
546 foreach ($this->answers as $key => $value)
548 if ($value->getPoints() >
$points)
570 throw new ilTestException(
'return details not implemented for '.__METHOD__);
575 $found_values = array();
580 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
581 array(
'integer',
'integer',
'integer'),
584 while ($data = $ilDB->fetchAssoc(
$result))
586 if (strcmp($data[
"value1"],
"") != 0)
588 array_push($found_values, $data[
"value1"]);
592 foreach ($this->answers as $key => $answer)
594 if (count($found_values) > 0)
596 if (in_array($key, $found_values))
598 $points += $answer->getPoints();
621 include_once
"./Modules/Test/classes/class.ilObjTest.php";
628 $result = $ilDB->queryF(
"SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
629 array(
'integer',
'integer',
'integer'),
633 $update =
$row[
"solution_id"];
637 if (strlen(
$_POST[
"multiple_choice_result"]))
639 $affectedRows = $ilDB->update(
"tst_solutions", array(
640 "value1" => array(
"clob",
$_POST[
"multiple_choice_result"]),
641 "tstamp" => array(
"integer", time())
643 "solution_id" => array(
"integer", $update)
649 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE solution_id = %s",
657 if (strlen(
$_POST[
"multiple_choice_result"]))
659 $next_id = $ilDB->nextId(
'tst_solutions');
660 $affectedRows = $ilDB->insert(
"tst_solutions", array(
661 "solution_id" => array(
"integer", $next_id),
662 "active_fi" => array(
"integer", $active_id),
663 "question_fi" => array(
"integer", $this->
getId()),
664 "value1" => array(
"clob",
$_POST[
'multiple_choice_result']),
665 "value2" => array(
"clob", null),
666 "pass" => array(
"integer",
$pass),
667 "tstamp" => array(
"integer", time())
677 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
685 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
703 array( $this->
getId() )
707 ) .
" (question_fi, shuffle, allow_images, thumb_size) VALUES (%s, %s, %s, %s)",
708 array(
"integer",
"text",
"text",
"integer" ),
712 ($this->isSingleline) ?
"0" :
"1",
722 if (!$this->isSingleline)
726 $ilDB->manipulateF(
"DELETE FROM qpl_a_sc WHERE question_fi = %s",
728 array( $this->
getId() )
731 foreach ($this->answers as $key => $value)
734 $answer_obj = $this->answers[$key];
735 $next_id = $ilDB->nextId(
'qpl_a_sc' );
736 $ilDB->manipulateF(
"INSERT INTO qpl_a_sc (answer_id, question_fi, answertext, points, aorder, imagefile, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
737 array(
'integer',
'integer',
'text',
'float',
'integer',
'text',
'integer' ),
742 $answer_obj->getPoints(),
743 $answer_obj->getOrder(),
744 $answer_obj->getImage(),
782 return "assSingleChoice";
818 if (!empty($image_tempfilename))
820 $image_filename = str_replace(
" ",
"_", $image_filename);
822 if (!file_exists($imagepath))
833 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
835 if (!preg_match(
"/^image/", $mimetype))
837 unlink($imagepath . $image_filename);
862 @unlink($imagepath . $image_filename);
863 $thumbpath = $imagepath . $this->
getThumbPrefix() . $image_filename;
871 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
873 if( (
int)$objectId > 0 )
875 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
878 foreach ($this->answers as $answer)
883 if (!file_exists($imagepath))
887 if (!@copy($imagepath_original .
$filename, $imagepath . $filename))
889 $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
890 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
892 if (@file_exists($imagepath_original. $this->getThumbPrefix().
$filename))
896 $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
897 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
908 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
909 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
910 foreach ($this->answers as $answer)
915 if (!file_exists($imagepath))
919 if (!@copy($imagepath_original .
$filename, $imagepath . $filename))
921 $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
922 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
924 if (@file_exists($imagepath_original. $this->getThumbPrefix().
$filename))
928 $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
929 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
944 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
946 foreach ($this->answers as $answer)
951 if (@file_exists($imagepath .
$filename))
953 if (!file_exists($imagepath))
957 if (!file_exists($imagepath_original))
961 if (!@copy($imagepath . $filename, $imagepath_original . $filename))
963 $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
964 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
967 if (@file_exists($imagepath . $this->
getThumbPrefix() . $filename))
971 $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
972 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
986 foreach ($this->answers as $index => $answer)
988 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), $index);
989 $answer_obj = $this->answers[$index];
990 $text .= $answer_obj->getAnswertext();
1017 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
1025 if (
$id == $solution[0][
"value1"])
1027 $worksheet->write($startrow + $i, 1, 1);
1031 $worksheet->write($startrow + $i, 1, 0);
1035 return $startrow + $i + 1;
1045 $this->thumb_size = $a_size;
1053 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1057 $reilUtilsult[
'title'] = (string) $this->
getTitle();
1063 "onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false),
1064 "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true)
1069 foreach ($this->
getAnswers() as $key => $answer_obj)
1071 if((
string) $answer_obj->getImage())
1076 "answertext" => (
string) $this->
formatSAQuestion($answer_obj->getAnswertext()),
1077 "points" => (
float)$answer_obj->getPoints(),
1078 "order" => (int)$answer_obj->getOrder(),
1079 "image" => (string) $answer_obj->getImage(),
1081 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key), 0
1100 $answer = $this->answers[$index];
1101 if (is_object($answer))
1104 $answer->setImage(
'');
1110 $value = rand(0, count($this->answers)-1);
1111 $_POST[
"multiple_choice_result"] = (strlen($value)) ? (
string)$value :
'0';
1119 $multilineAnswerSetting = $ilUser->getPref(
"tst_multiline_answers");
1120 if ($multilineAnswerSetting != 1)
1122 $multilineAnswerSetting = 0;
1124 return $multilineAnswerSetting;
1130 $ilUser->writePref(
"tst_multiline_answers", $a_setting);
1144 $this->feedback_setting = $a_feedback_setting;
1158 if ($this->feedback_setting)