4require_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
5require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
6require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
7require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjAnswerScoringAdjustable.php';
8require_once
'./Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php';
9require_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())
138 $oldthumbsize =
$data[
'thumb_size'];
159 if (strlen($answer->getImage()))
180 switch (strtoupper($path_info[
'extension']))
216 $this->
setId($question_id);
225 include_once(
"./Services/RTE/classes/class.ilRTE.php");
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";
254 if (!@file_exists($imagefilename))
256 $data[
"imagefile"] =
"";
258 include_once(
"./Services/RTE/classes/class.ilRTE.php");
264 parent::loadFromDb($question_id);
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);
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(),
785 return "assSingleChoice";
821 if (!empty($image_tempfilename))
823 $image_filename = str_replace(
" ",
"_", $image_filename);
825 if (!file_exists($imagepath))
836 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
838 if (!preg_match(
"/^image/", $mimetype))
840 unlink($imagepath . $image_filename);
865 @unlink($imagepath . $image_filename);
866 $thumbpath = $imagepath . $this->
getThumbPrefix() . $image_filename;
874 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
876 if( (
int)$objectId > 0 )
878 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
881 foreach ($this->answers as $answer)
886 if (!file_exists($imagepath))
892 $ilLog->write(
"image could not be duplicated!!!!",
$ilLog->ERROR);
893 $ilLog->write(
"object: " . print_r($this, TRUE),
$ilLog->ERROR);
895 if (@file_exists($imagepath_original. $this->getThumbPrefix().
$filename))
899 $ilLog->write(
"image thumbnail could not be duplicated!!!!",
$ilLog->ERROR);
900 $ilLog->write(
"object: " . print_r($this, TRUE),
$ilLog->ERROR);
911 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
912 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
913 foreach ($this->answers as $answer)
918 if (!file_exists($imagepath))
924 $ilLog->write(
"image could not be duplicated!!!!",
$ilLog->ERROR);
925 $ilLog->write(
"object: " . print_r($this, TRUE),
$ilLog->ERROR);
927 if (@file_exists($imagepath_original. $this->getThumbPrefix().
$filename))
931 $ilLog->write(
"image thumbnail could not be duplicated!!!!",
$ilLog->ERROR);
932 $ilLog->write(
"object: " . print_r($this, TRUE),
$ilLog->ERROR);
947 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
949 foreach ($this->answers as $answer)
954 if (@file_exists($imagepath .
$filename))
956 if (!file_exists($imagepath))
960 if (!file_exists($imagepath_original))
966 $ilLog->write(
"image could not be duplicated!!!!",
$ilLog->ERROR);
967 $ilLog->write(
"object: " . print_r($this, TRUE),
$ilLog->ERROR);
970 if (@file_exists($imagepath . $this->
getThumbPrefix() . $filename))
974 $ilLog->write(
"image thumbnail could not be duplicated!!!!",
$ilLog->ERROR);
975 $ilLog->write(
"object: " . print_r($this, TRUE),
$ilLog->ERROR);
988 $text = parent::getRTETextWithMediaObjects();
989 foreach ($this->answers as $index => $answer)
991 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), $index);
992 $answer_obj = $this->answers[$index];
993 $text .= $answer_obj->getAnswertext();
1020 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
1029 count($solution) > 0 &&
1030 isset($solution[0]) &&
1031 is_array($solution[0]) &&
1032 strlen($solution[0][
'value1']) > 0 &&
$id == $solution[0][
'value1'])
1034 $worksheet->write($startrow + $i, 1, 1);
1038 $worksheet->write($startrow + $i, 1, 0);
1042 return $startrow + $i + 1;
1052 $this->thumb_size = $a_size;
1060 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1064 $reilUtilsult[
'title'] = (string) $this->
getTitle();
1070 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
1071 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
1076 foreach ($this->
getAnswers() as $key => $answer_obj)
1078 if((
string) $answer_obj->getImage())
1083 "answertext" => (
string) $this->
formatSAQuestion($answer_obj->getAnswertext()),
1084 "points" => (
float)$answer_obj->getPoints(),
1085 "order" => (
int)$answer_obj->getOrder(),
1086 "image" => (
string) $answer_obj->getImage(),
1087 "feedback" => $this->formatSAQuestion(
1088 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key)
1107 $answer = $this->answers[$index];
1108 if (is_object($answer))
1111 $answer->setImage(
'');
1117 $value = rand(0, count($this->answers)-1);
1118 $_POST[
"multiple_choice_result"] = (strlen($value)) ? (
string)$value :
'0';
1126 $multilineAnswerSetting =
$ilUser->getPref(
"tst_multiline_answers");
1127 if ($multilineAnswerSetting != 1)
1129 $multilineAnswerSetting = 0;
1131 return $multilineAnswerSetting;
1137 $ilUser->writePref(
"tst_multiline_answers", $a_setting);
1151 $this->feedback_setting = $a_feedback_setting;
1165 if ($this->feedback_setting)
1189 return $numExistingSolutionRecords > 0;
1217 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1249 "SELECT * FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = (
1250 SELECT MAX(step) FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s
1252 array(
"integer",
"integer",
"integer",
"integer",
"integer",
"integer"),
1297 parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
1299 $origImagePath = $this->
buildImagePath($origQuestionId, $origParentObjId);
1300 $dupImagePath = $this->
buildImagePath($dupQuestionId, $dupParentObjId);
1303 if(is_dir($dupImagePath))
Class for answers with a binary state indicator.
Abstract basic class which is to be extended by the concrete assessment question type classes.
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
setShuffle($shuffle=true)
Sets the shuffle flag.
setId($id=-1)
Sets the id of the assQuestion object.
setOriginalId($original_id)
setObjId($obj_id=0)
Set the object id of the container object.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
saveQuestionDataToDb($original_id="")
getId()
Gets the id of the assQuestion object.
getObjId()
Get the object id of the container object.
setTitle($title="")
Sets the title string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second.
buildImagePath($questionId, $parentObjectId)
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
setAuthor($author="")
Sets the authors name of the assQuestion object.
getShuffle()
Gets the shuffle flag.
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getTitle()
Gets the title string of the assQuestion object.
setPoints($a_points)
Sets the maximum available points for the question.
setComment($comment="")
Sets the comment string of the assQuestion object.
setNrOfTries($a_nr_of_tries)
getQuestion()
Gets the question string of the question object.
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
saveToDb($original_id="")
Saves the question to the database.
setQuestion($question="")
Sets the question string of the question object.
getImagePathWeb()
Returns the web image path for web accessable images of a question.
Class for single choice questions.
copyImages($question_id, $source_questionpool)
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
saveWorkingData($active_id, $pass=NULL)
Saves the learners input of the question to the database.
loadFromDb($question_id)
Loads a assSingleChoice object from a database.
deleteImage($image_filename)
Deletes an image file.
setOutputType($output_type=OUTPUT_ORDER)
Sets the output type of the assSingleChoice object.
calculateReachedPoints($active_id, $pass=NULL, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
getQuestionType()
Returns the question type of the question.
getAnswerCount()
Returns the number of answers.
reworkWorkingData($active_id, $pass, $obligationsAnswered)
Reworks the allready saved working data if neccessary.
toJSON()
Returns a JSON representation of the question.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
generateThumbForFile($path, $file)
syncImages()
Sync images of a MC question on synchronisation with the original question.
createRandomSolution($active_id, $pass)
setSpecificFeedbackSetting($a_feedback_setting)
Sets the feedback settings in effect for the question.
removeAnswerImage($index)
getOutputType()
Gets the single choice output type which is either OUTPUT_ORDER (=0) or OUTPUT_RANDOM (=1).
addAnswer( $answertext="", $points=0.0, $order=0, $answerimage="")
Adds a possible answer for a single choice question.
getSpecificFeedbackSetting()
Gets the current feedback settings in effect for the question.
getOperators($expression)
Get all available operations for a specific question.
setMultilineAnswerSetting($a_setting=0)
setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
Creates an Excel worksheet for the detailed cumulated results of this question.
getExpressionTypes()
Get all available expression types for a specific question.
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
{}
& getAnswers()
Returns a reference to the answers array.
isComplete()
Returns true, if a single choice question is complete for use.
deleteAnswer($index=0)
Deletes an answer with a given index.
savePreviewData(ilAssQuestionPreviewSession $previewSession)
isAnswered($active_id, $pass)
returns boolean wether the question is answered during test pass or not
static isObligationPossible($questionId)
returns boolean wether it is possible to set this question type as obligatory or not considering the ...
setImageFile($image_filename, $image_tempfilename="")
Sets the image file and uploads the image to the object's image directory.
copyObject($target_questionpool_id, $title="")
Copies an assSingleChoice object.
__construct( $title="", $comment="", $author="", $owner=-1, $question="", $output_type=OUTPUT_ORDER)
assSingleChoice constructor
flushAnswers()
Deletes all answers.
getMultilineAnswerSetting()
getAnswer($index=0)
Returns an answer with a given index.
calculateReachedPointsFromPreviewSession(ilAssQuestionPreviewSession $previewSession)
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
duplicateImages($question_id, $objectId=null)
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assSingleChoiceQuestion.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getAnswerTableName()
Returns the name of the answer table in the database.
getParticipantsSolution()
setParticipantsSolution($participantSolution)
_convert_text($a_text, $a_target="has been removed")
_getLogLanguage()
retrieve the log language for assessment logging
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static getOperatorsByExpression($expression)
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
Base Exception for all Exceptions relating to Modules/Test.
Class ilUserQuestionResult.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
static makeDirParents($a_dir)
Create a new directory and all parent directories.
Class iQuestionCondition.
const PercentageResultExpression
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
const EmptyAnswerExpression
const NumberOfResultExpression
Interface ilObjAnswerScoringAdjustable.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
Interface ilObjQuestionScoringAdjustable.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.