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())
136 $oldthumbsize =
$data[
'thumb_size'];
157 if (strlen($answer->getImage()))
178 switch (strtoupper($path_info[
'extension']))
214 $this->
setId($question_id);
223 include_once(
"./Services/RTE/classes/class.ilRTE.php");
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";
252 if (!@file_exists($imagefilename))
254 $data[
"imagefile"] =
"";
256 include_once(
"./Services/RTE/classes/class.ilRTE.php");
262 parent::loadFromDb($question_id);
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'),
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(),
770 parent::syncWithOriginal();
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);
985 $text = parent::getRTETextWithMediaObjects();
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())
1075 array_push($answers, array(
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)
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getOutputType()
Gets the single choice output type which is either OUTPUT_ORDER (=0) or OUTPUT_RANDOM (=1)...
getId()
Gets the id of the assQuestion object.
saveToDb($original_id="")
Saves the question to the database.
generateThumbForFile($path, $file)
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
removeAnswerImage($index)
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
static doesSolutionRecordsExist($activeId, $pass, $questionId)
checks wether there are existing solution records for the given test active / pass and given question...
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
Abstract basic class which is to be extended by the concrete assessment question type classes...
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
Class for answers with a binary state indicator.
_convert_text($a_text, $a_target="has been removed")
setOutputType($output_type=OUTPUT_ORDER)
Sets the output type of the assSingleChoice object.
setMultilineAnswerSetting($a_setting=0)
& getAnswers()
Returns a reference to the answers array.
getAnswerCount()
Returns the number of answers.
isComplete()
Returns true, if a single choice question is complete for use.
setId($id=-1)
Sets the id of the assQuestion object.
copyObject($target_questionpool_id, $title="")
Copies an assSingleChoice object.
getQuestionType()
Returns the question type of the question.
getAnswerTableName()
Returns the name of the answer table in the database.
getImagePathWeb()
Returns the web image path for web accessable images of a question.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question.
loadFromDb($question_id)
Loads a assSingleChoice object from a database.
setNrOfTries($a_nr_of_tries)
setSpecificFeedbackSetting($a_feedback_setting)
Sets the feedback settings in effect for the question.
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
copyImages($question_id, $source_questionpool)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assSingleChoiceQuestion.
getAnswer($index=0)
Returns an answer with a given index.
setShuffle($shuffle=true)
Sets the shuffle flag.
getObjId()
Get the object id of the container object.
getShuffle()
Gets the shuffle flag.
Base Exception for all Exceptions relating to Modules/Test.
getMultilineAnswerSetting()
getSpecificFeedbackSetting()
Gets the current feedback settings in effect for the question.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
deleteImage($image_filename)
Deletes an image file.
fetchAssoc($a_set)
Fetch row as associative array from result set.
setAuthor($author="")
Sets the authors name of the assQuestion object.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
createRandomSolution($active_id, $pass)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
Class for single choice questions.
deleteAnswer($index=0)
Deletes an answer with a given index.
Interface ilObjAnswerScoringAdjustable.
toJSON()
Returns a JSON representation of the question.
addAnswer( $answertext="", $points=0.0, $order=0, $answerimage="")
Adds a possible answer for a single choice question.
__construct( $title="", $comment="", $author="", $owner=-1, $question="", $output_type=OUTPUT_ORDER)
assSingleChoice constructor
getQuestion()
Gets the question string of the question object.
syncImages()
Sync images of a MC question on synchronisation with the original question.
calculateReachedPoints($active_id, $pass=NULL, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
flushAnswers()
Deletes all answers.
reworkWorkingData($active_id, $pass, $obligationsAnswered)
Reworks the allready saved working data if neccessary.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
_getLogLanguage()
retrieve the log language for assessment logging
setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
Creates an Excel worksheet for the detailed cumulated results of this question.
isAnswered($active_id, $pass)
returns boolean wether the question is answered during test pass or not
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
setPoints($a_points)
Sets the maximum available points for the question.
saveQuestionDataToDb($original_id="")
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
saveWorkingData($active_id, $pass=NULL)
Saves the learners input of the question to the database.
setImageFile($image_filename, $image_tempfilename="")
Sets the image file and uploads the image to the object's image directory.
setQuestion($question="")
Sets the question string of the question object.
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
duplicateImages($question_id, $objectId=null)
Interface ilObjQuestionScoringAdjustable.
setOriginalId($original_id)
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getTitle()
Gets the title string of the assQuestion object.
static isObligationPossible($questionId)
returns boolean wether it is possible to set this question type as obligatory or not considering the ...
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
setComment($comment="")
Sets the comment string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.