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';
78 $this->maxNumOfChars = 0;
80 $this->answers =
array();
81 $this->matchcondition = 0;
91 if (strlen($this->title)
130 if ($ilDB->numRows(
$result) == 1)
133 $this->
setId($question_id);
142 include_once(
"./Services/RTE/classes/class.ilRTE.php");
147 $this->matchcondition = (strlen($data[
'matchcondition'])) ? $data[
'matchcondition'] : 0;
148 $this->
setEstimatedWorkingTime(substr($data[
"working_time"], 0, 2), substr($data[
"working_time"], 3, 2), substr($data[
"working_time"], 6, 2));
160 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_essay WHERE question_fi = %s",
171 parent::loadFromDb($question_id);
187 $this_id = $this->
getId();
191 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
195 if( (
int)$testObjId > 0 )
197 $clone->setObjId($testObjId);
224 $clone->copyPageOfQuestion($this_id);
226 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
227 #$clone->duplicateAnswers($this_id); 229 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
248 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
251 $source_questionpool_id = $this->
getObjId();
252 $clone->setObjId($target_questionpool_id);
263 #$clone->duplicateAnswers($original_id); 265 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
278 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
281 $sourceParentId = $this->
getObjId();
287 $clone->setObjId($targetParentId);
289 if ($targetQuestionTitle)
291 $clone->setTitle($targetQuestionTitle);
296 $clone->copyPageOfQuestion($sourceQuestionId);
298 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
300 #$clone->duplicateAnswers($sourceQuestionId); 302 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
316 if (strcmp($this->maxNumOfChars,
"") == 0)
335 $this->maxNumOfChars = $maxchars;
346 if( in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion()) )
348 return parent::getPoints();
353 foreach ($this->answers as $answer)
355 if ($answer->getPoints() > 0)
366 if( in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion()) )
373 foreach ($this->answers as $answer)
375 if ($answer->getPoints() < 0)
402 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_result SET points = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
403 array(
'float',
'integer',
'integer',
'integer'),
406 self::_updateTestPassResults($active_id,
$pass);
444 include_once
"./Services/Utilities/classes/class.ilStr.php";
451 if (
ilStr::strPos($answertext, $a_keyword) !==
false)
return TRUE;
456 $answertext = strip_tags($answertext);
458 $answerwords =
array();
459 if (preg_match_all(
"/([^\s.]+)/", $answertext, $matches))
461 foreach ($matches[1] as $answerword)
463 array_push($answerwords, trim($answerword));
466 foreach ($answerwords as $a_original)
471 if (levenshtein($a_original, $a_keyword) <= 1)
return TRUE;
474 if (levenshtein($a_original, $a_keyword) <= 2)
return TRUE;
477 if (levenshtein($a_original, $a_keyword) <= 3)
return TRUE;
480 if (levenshtein($a_original, $a_keyword) <= 4)
return TRUE;
483 if (levenshtein($a_original, $a_keyword) <= 5)
return TRUE;
501 if (count($answers) == 0)
512 foreach ($answers as $answer)
514 $qst_answer = $answer->getAnswertext();
515 $user_answer =
' '.$solution;
519 $points += $answer->getPoints();
529 foreach ($answers as $answer)
531 $qst_answer = $answer->getAnswertext();
532 $user_answer =
' '.$solution;
547 foreach ($answers as $answer)
549 $qst_answer = $answer->getAnswertext();
550 $user_answer =
' '.$solution;
579 throw new ilTestException(
'return details not implemented for '.__METHOD__);
593 if ($ilDB->numRows(
$result) == 0)
600 if (
$row[
"points"] != NULL)
602 return $row[
"points"];
621 include_once
"./Services/Utilities/classes/class.ilStr.php";
624 include_once
"./Modules/Test/classes/class.ilObjTest.php";
631 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function() use (&$entered_values, $active_id,
$pass, $authorized,
$text) {
645 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
653 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
688 $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxnumofchars, keywords, 689 textgap_rating, matchcondition, keyword_relation) VALUES (%s, %s, %s, %s, %s, %s)",
690 array(
"integer",
"integer",
"text",
"text",
'integer',
'text' ),
696 $this->matchcondition,
707 $ilDB->manipulateF(
"DELETE FROM qpl_a_essay WHERE question_fi = %s",
712 foreach ($this->answers as $answer)
715 $nextID = $ilDB->nextId(
'qpl_a_essay' );
716 $ilDB->manipulateF(
"INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) VALUES (%s, %s, %s, %s)",
717 array(
"integer",
"integer",
"text",
'float' ),
721 $answer->getAnswertext(),
748 return "assTextQuestion";
772 switch ($a_text_rating)
781 $this->text_rating = $a_text_rating;
797 return "qpl_qst_essay";
806 return parent::getRTETextWithMediaObjects();
819 $worksheet->setCell($startrow + $i, 0, $this->lng->txt(
"result"));
822 require_once
'Modules/Test/classes/class.ilObjAssessmentFolder.php';
825 $string_escaping_org_value =
$worksheet->getStringEscaping();
826 if($assessment_folder->getExportEssayQuestionsWithHtml() == 1)
831 if (strlen($solutions[0][
"value1"]))
833 $worksheet->setCell($startrow + $i, 1, $solutions[0][
"value1"]);
837 $worksheet->setStringEscaping($string_escaping_org_value);
838 return $startrow + $i + 1;
846 include_once(
"./Services/RTE/classes/class.ilRTE.php");
860 return count($this->answers);
879 $points_unchecked = 0.0,
884 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
888 $this->answers[] = $answer;
907 if ($index < 0)
return NULL;
908 if (count($this->answers) < 1)
return NULL;
909 if ($index >= count($this->answers))
return NULL;
911 return $this->answers[$index];
924 if ($index < 0)
return;
925 if (count($this->answers) < 1)
return;
926 if ($index >= count($this->answers))
return;
927 $answer = $this->answers[$index];
928 if (strlen($answer->getImage())) $this->deleteImage($answer->getImage());
929 unset($this->answers[$index]);
930 $this->answers = array_values($this->answers);
931 for ($i = 0; $i < count($this->answers); $i++)
933 if ($this->answers[$i]->getOrder() > $index)
935 $this->answers[$i]->setOrder($i);
942 return 'qpl_a_essay';
953 $this->answers =
array();
958 if( isset($answers[
'answer']) )
960 $count = count($answers[
'answer']);
965 $count = count($answers);
971 for( $i = 0; $i < $count; $i++ )
975 $this->
addAnswer($answers[
'answer'][$i], $answers[
'points'][$i]);
988 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_essay WHERE question_fi = %s",
996 $next_id = $ilDB->nextId(
'qpl_a_essay');
997 $affectedRows = $ilDB->manipulateF(
998 "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) 999 VALUES (%s, %s, %s, %s)",
1000 array(
'integer',
'integer',
'text',
'float'),
1018 $this->keyword_relation = $a_relation;
1023 return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
1028 return array(
'non',
'all',
'one');
1033 return array(
'any');
1051 return $numExistingSolutionRecords > 0;
1081 require_once
'Services/Utilities/classes/class.ilStr.php';
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 _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...
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="")
static strPos($a_haystack, $a_needle, $a_offset=NULL)
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file.
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.
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. ...
Add rich text string
The name of the decorator.
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.
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.
saveWorkingData($active_id, $pass=NULL, $authorized=true)
Saves the learners input of the question to the database.
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
isAnswered($active_id, $pass=NULL)
returns boolean wether the question is answered during test pass or not
isValidTextRating($textRating)
const TEXTGAP_RATING_LEVENSHTEIN3
Class for text questions.
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.
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.
Create styles array
The data for the language used.
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="")
setReachedPoints($active_id, $points, $pass=NULL)
Sets the points, a learner has reached answering the question.
getMaxNumOfChars()
Gets the maximum number of characters for the text solution.
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)
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...
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
getTitle()
Gets the title string of the assQuestion object.
calculateReachedPoints($active_id, $pass=NULL, $authorizedSolution=true, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
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.
static isObligationPossible($questionId)
returns boolean wether it is possible to set this question type as obligatory or not considering the ...
reworkWorkingData($active_id, $pass, $obligationsAnswered, $authorized)
{}
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
const TEXTGAP_RATING_CASEINSENSITIVE
createRandomSolution($test_id, $user_id)