19 require_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
20 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
21 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
22 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjAnswerScoringAdjustable.php';
97 $this->wordCounterEnabled =
false;
98 $this->maxNumOfChars = 0;
100 $this->answers = array();
101 $this->matchcondition = 0;
111 if (strlen($this->title)
144 $ilDB = $DIC[
'ilDB'];
153 $this->
setId($question_id);
162 include_once(
"./Services/RTE/classes/class.ilRTE.php");
168 $this->matchcondition = (strlen($data[
'matchcondition'])) ? $data[
'matchcondition'] : 0;
169 $this->
setEstimatedWorkingTime(substr($data[
"working_time"], 0, 2), substr($data[
"working_time"], 3, 2), substr($data[
"working_time"], 6, 2));
185 "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
187 array($this->
getId())
192 $this->
addAnswer($row[
'answertext'], $row[
'points']);
195 parent::loadFromDb($question_id);
205 if ($this->
id <= 0) {
210 $this_id = $this->
getId();
214 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
218 if ((
int) $testObjId > 0) {
219 $clone->setObjId($testObjId);
240 $clone->copyPageOfQuestion($this_id);
242 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
243 #$clone->duplicateAnswers($this_id); 245 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
257 if ($this->
id <= 0) {
263 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
266 $source_questionpool_id = $this->
getObjId();
267 $clone->setObjId($target_questionpool_id);
277 #$clone->duplicateAnswers($original_id); 279 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
286 if ($this->
id <= 0) {
291 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
294 $sourceParentId = $this->
getObjId();
300 $clone->setObjId($targetParentId);
302 if ($targetQuestionTitle) {
303 $clone->setTitle($targetQuestionTitle);
308 $clone->copyPageOfQuestion($sourceQuestionId);
310 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
312 #$clone->duplicateAnswers($sourceQuestionId); 314 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
328 if (strcmp($this->maxNumOfChars,
"") == 0) {
344 $this->maxNumOfChars = $maxchars;
371 if (in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
372 return parent::getPoints();
377 foreach ($this->answers as $answer) {
378 if ($answer->getPoints() > 0) {
388 if (in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
394 foreach ($this->answers as $answer) {
395 if ($answer->getPoints() < 0) {
414 $ilDB = $DIC[
'ilDB'];
417 if (is_null(
$pass)) {
420 $affectedRows =
$ilDB->manipulateF(
421 "UPDATE tst_test_result SET points = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
422 array(
'float',
'integer',
'integer',
'integer'),
425 self::_updateTestPassResults($active_id,
$pass);
434 switch ($textRating) {
462 include_once
"./Services/Utilities/classes/class.ilStr.php";
464 switch ($textrating) {
478 $answertext = strip_tags($answertext);
479 $answerwords = array();
480 if (preg_match_all(
"/([^\s.]+)/", $answertext, $matches)) {
481 foreach ($matches[1] as $answerword) {
482 array_push($answerwords, trim($answerword));
487 switch ($textrating) {
489 $transformation =
$refinery->string()->levenshtein()->standard($a_keyword, 1);
492 $transformation =
$refinery->string()->levenshtein()->standard($a_keyword, 2);
495 $transformation =
$refinery->string()->levenshtein()->standard($a_keyword, 3);
498 $transformation =
$refinery->string()->levenshtein()->standard($a_keyword, 4);
501 $transformation =
$refinery->string()->levenshtein()->standard($a_keyword, 5);
506 foreach ($answerwords as $a_original) {
507 if (isset($transformation) && $transformation->transform($a_original) >= 0) {
516 $solution = html_entity_decode($solution);
533 $qst_answer = $answer->getAnswertext();
534 $user_answer =
' ' . $solution;
536 $points += $answer->getPoints();
544 $qst_answer = $answer->getAnswertext();
545 $user_answer =
' ' . $solution;
556 $qst_answer = $answer->getAnswertext();
557 $user_answer =
' ' . $solution;
581 if ($returndetails) {
582 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
586 $ilDB = $DIC[
'ilDB'];
589 if (is_null(
$pass)) {
602 if ($row[
"points"] != null) {
603 return $row[
"points"];
620 $ilDB = $DIC[
'ilDB'];
623 include_once
"./Services/Utilities/classes/class.ilStr.php";
624 if (is_null(
$pass)) {
625 include_once
"./Modules/Test/classes/class.ilObjTest.php";
632 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $active_id,
$pass, $authorized, $text) {
641 if ($entered_values) {
642 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
647 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
664 $text = htmlentities(
$_POST[
"TEXT"]);
678 $ilDB = $DIC[
'ilDB'];
682 array( $this->
getId()
687 'question_fi' => array(
'integer', $this->
getId()),
690 'keywords' => array(
'text', null),
692 'matchcondition' => array(
'integer', $this->matchcondition),
703 $ilDB = $DIC[
'ilDB'];
706 "DELETE FROM qpl_a_essay WHERE question_fi = %s",
708 array( $this->
getId() )
711 foreach ($this->answers as $answer) {
713 $nextID =
$ilDB->nextId(
'qpl_a_essay');
715 "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) VALUES (%s, %s, %s, %s)",
716 array(
"integer",
"integer",
"text",
'float' ),
720 $answer->getAnswertext(),
735 return "assTextQuestion";
759 switch ($a_text_rating) {
767 $this->text_rating = $a_text_rating;
783 return "qpl_qst_essay";
792 return parent::getRTETextWithMediaObjects();
800 parent::setExportDetailsXLS($worksheet, $startrow, $active_id,
$pass);
805 $worksheet->setCell($startrow +
$i, 0, $this->lng->txt(
"result"));
806 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow +
$i));
808 require_once
'Modules/Test/classes/class.ilObjAssessmentFolder.php';
811 $string_escaping_org_value = $worksheet->getStringEscaping();
812 if ($assessment_folder->getExportEssayQuestionsWithHtml() == 1) {
813 $worksheet->setStringEscaping(
false);
816 if (strlen($solutions[0][
"value1"])) {
817 $worksheet->setCell($startrow +
$i, 2, html_entity_decode($solutions[0][
"value1"]));
821 $worksheet->setStringEscaping($string_escaping_org_value);
822 return $startrow +
$i + 1;
830 include_once(
"./Services/RTE/classes/class.ilRTE.php");
844 return count($this->answers);
863 $points_unchecked = 0.0,
867 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
871 $this->answers[] = $answer;
893 if (count($this->answers) < 1) {
896 if (
$index >= count($this->answers)) {
900 return $this->answers[
$index];
916 if (count($this->answers) < 1) {
919 if (
$index >= count($this->answers)) {
922 $answer = $this->answers[
$index];
923 if (strlen($answer->getImage())) {
924 $this->deleteImage($answer->getImage());
926 unset($this->answers[
$index]);
927 $this->answers = array_values($this->answers);
928 for (
$i = 0;
$i < count($this->answers);
$i++) {
929 if ($this->answers[
$i]->getOrder() >
$index) {
930 $this->answers[
$i]->setOrder(
$i);
937 return 'qpl_a_essay';
948 $this->answers = array();
963 for (
$i = 0;
$i < $count;
$i++) {
975 $ilDB = $DIC[
'ilDB'];
978 "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
984 $next_id =
$ilDB->nextId(
'qpl_a_essay');
985 $affectedRows =
$ilDB->manipulateF(
986 "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) 987 VALUES (%s, %s, %s, %s)",
988 array(
'integer',
'integer',
'text',
'float'),
989 array($next_id, $this->
getId(), $row[
"answertext"], $row[
"points"])
1006 $this->keyword_relation = $a_relation;
1011 return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
1016 return array(
'non',
'all',
'one');
1021 return array(
'any');
1039 return $numExistingSolutionRecords > 0;
1059 $text = strip_tags($text);
1061 $text = str_replace(
'>',
'>', $text);
1062 $text = str_replace(
'<',
'<', $text);
1063 $text = str_replace(
' ',
' ', $text);
1064 $text = str_replace(
'&',
'&', $text);
1066 $text = str_replace(
"\r\n",
"\n", $text);
1067 $text = str_replace(
"\n",
"", $text);
1074 $text = str_replace(
' ',
' ', $text);
1076 $text = preg_replace(
'/[.,:;!?\-_#\'"+*\\/=()&%§$]/m',
'', $text);
1078 $text = preg_replace(
'/^\s*/m',
'', $text);
1079 $text = preg_replace(
'/\s*$/m',
'', $text);
1080 $text = preg_replace(
'/\s+/m',
' ', $text);
1082 return count(explode(
' ', $text));
1087 $question_fi = $this->
getId();
1090 $cntresult = $this->db->query(
1092 SELECT count(solution_id) cnt 1094 WHERE active_fi = ' . $this->db->quote($active_id,
'int') .
' 1095 AND question_fi = ' . $this->db->quote($this->
getId(),
'int') .
' 1096 AND authorized = ' . $this->db->quote(0,
'int')
1098 $row = $this->db->fetchAssoc($cntresult);
1099 if ($row[
'cnt'] > 0) {
1100 $tresult = $this->db->query(
1104 WHERE active_fi = ' . $this->db->quote($active_id,
'int') .
' 1105 AND question_fi = ' . $this->db->quote($this->
getId(),
'int') .
' 1106 AND authorized = ' . $this->db->quote(0,
'int')
1108 $trow = $this->db->fetchAssoc($tresult);
1109 return $trow[
'value1'];
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assTextQuestion.
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getId()
Gets the id of the assQuestion object.
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{}
static getInstance($identifier)
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
const TEXTGAP_RATING_LEVENSHTEIN5
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static getScoringModesWithPointsByKeyword()
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
static strPos($a_haystack, $a_needle, $a_offset=null)
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
isAnswered($active_id, $pass=null)
returns boolean wether the question is answered during test pass or not
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
getPoints()
Returns the maximum available points for the question.
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
Abstract basic class which is to be extended by the concrete assessment question type classes...
isComplete()
Returns true, if a multiple choice question is complete for use.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file.
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
setId($id=-1)
Sets the id of the assQuestion object.
loadFromDb($question_id)
Loads a assTextQuestion object from a database.
saveToDb($original_id="")
Saves a assTextQuestion object to a database.
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
copyObject($target_questionpool_id, $title="")
Copies an assTextQuestion object.
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 from given hour, minute and second. ...
static strToLower($a_string)
static getValidScoringModes()
toJSON()
Returns a JSON representation of the question.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setShuffle($shuffle=true)
Sets the shuffle flag.
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...
getObjId()
Get the object id of the container object.
setWordCounterEnabled($wordCounterEnabled)
getShuffle()
Gets the shuffle flag.
Base Exception for all Exceptions relating to Modules/Test.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
static _getLogLanguage()
retrieve the log language for assessment logging
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assTextQuestion constructor
setAuthor($author="")
Sets the authors name of the assQuestion object.
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
isValidTextRating($textRating)
const TEXTGAP_RATING_LEVENSHTEIN3
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
calculateReachedPointsForSolution($solution)
duplicateAnswers($original_id)
flushAnswers()
Deletes all answers.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
Class ilObjAssessmentFolder.
static getScoringModesWithPointsByQuestion()
const TEXTGAP_RATING_CASESENSITIVE
setKeywordRelation($a_relation)
This method implements a default behaviour.
Interface ilObjAnswerScoringAdjustable.
setTextRating($a_text_rating)
Sets the rating option for text comparisons.
getQuestion()
Gets the question string of the question object.
setMaxNumOfChars($maxchars=0)
Sets the maximum number of characters for the text solution.
getHtmlUserSolutionPurifier()
getQuestionType()
Returns the question type of the question.
setReachedPoints($active_id, $points, $pass=null)
Sets the points, a learner has reached answering the question.
isKeywordMatching($answertext, $a_keyword)
Checks if one of the keywords matches the answertext.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getAnswer($index=0)
Returns an answer with a given index.
deleteAnswer($index=0)
Deletes an answer with a given index.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
setPoints($a_points)
Sets the maximum available points for the question.
addAnswer( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="")
Adds a possible answer for a multiple choice question.
saveQuestionDataToDb($original_id="")
getMaxNumOfChars()
Gets the maximum number of characters for the text solution.
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
setQuestion($question="")
Sets the question string of the question object.
Interface ilObjQuestionScoringAdjustable.
removeCurrentSolution($active_id, $pass, $authorized=true)
__construct(Container $dic, ilPlugin $plugin)
const TEXTGAP_RATING_LEVENSHTEIN4
setOriginalId($original_id)
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
setLifecycle(ilAssQuestionLifecycle $lifecycle)
getTitle()
Gets the title string of the assQuestion object.
static isHTML($a_text)
Checks if a given string contains HTML or not.
getTextRating()
Returns the rating option for text comparisons.
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setComment($comment="")
Sets the comment string of the assQuestion object.
getLatestAutosaveContent($active_id)
static getDraftInstance()
static isObligationPossible($questionId)
returns boolean wether it is possible to set this question type as obligatory or not considering the ...
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
const TEXTGAP_RATING_CASEINSENSITIVE