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';
77 $this->maxNumOfChars = 0;
79 $this->answers =
array();
80 $this->matchcondition = 0;
90 if (strlen($this->title)
129 if ($ilDB->numRows(
$result) == 1) {
131 $this->
setId($question_id);
140 include_once(
"./Services/RTE/classes/class.ilRTE.php");
145 $this->matchcondition = (strlen($data[
'matchcondition'])) ? $data[
'matchcondition'] : 0;
146 $this->
setEstimatedWorkingTime(substr($data[
"working_time"], 0, 2), substr($data[
"working_time"], 3, 2), substr($data[
"working_time"], 6, 2));
156 "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
166 parent::loadFromDb($question_id);
176 if ($this->
id <= 0) {
181 $this_id = $this->
getId();
185 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
189 if ((
int) $testObjId > 0) {
190 $clone->setObjId($testObjId);
211 $clone->copyPageOfQuestion($this_id);
213 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
214 #$clone->duplicateAnswers($this_id); 216 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
228 if ($this->
id <= 0) {
234 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
237 $source_questionpool_id = $this->
getObjId();
238 $clone->setObjId($target_questionpool_id);
248 #$clone->duplicateAnswers($original_id); 250 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
257 if ($this->
id <= 0) {
262 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
265 $sourceParentId = $this->
getObjId();
271 $clone->setObjId($targetParentId);
273 if ($targetQuestionTitle) {
274 $clone->setTitle($targetQuestionTitle);
279 $clone->copyPageOfQuestion($sourceQuestionId);
281 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
283 #$clone->duplicateAnswers($sourceQuestionId); 285 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
299 if (strcmp($this->maxNumOfChars,
"") == 0) {
315 $this->maxNumOfChars = $maxchars;
326 if (in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
327 return parent::getPoints();
332 foreach ($this->answers as $answer) {
333 if ($answer->getPoints() > 0) {
343 if (in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
349 foreach ($this->answers as $answer) {
350 if ($answer->getPoints() < 0) {
371 if (is_null(
$pass)) {
374 $affectedRows = $ilDB->manipulateF(
375 "UPDATE tst_test_result SET points = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
376 array(
'float',
'integer',
'integer',
'integer'),
379 self::_updateTestPassResults($active_id,
$pass);
388 switch ($textRating) {
414 include_once
"./Services/Utilities/classes/class.ilStr.php";
415 switch ($textrating) {
429 $answertext = strip_tags($answertext);
431 $answerwords =
array();
432 if (preg_match_all(
"/([^\s.]+)/", $answertext, $matches)) {
433 foreach ($matches[1] as $answerword) {
434 array_push($answerwords, trim($answerword));
437 foreach ($answerwords as $a_original) {
438 switch ($textrating) {
440 if (levenshtein($a_original, $a_keyword) <= 1) {
445 if (levenshtein($a_original, $a_keyword) <= 2) {
450 if (levenshtein($a_original, $a_keyword) <= 3) {
455 if (levenshtein($a_original, $a_keyword) <= 4) {
460 if (levenshtein($a_original, $a_keyword) <= 5) {
489 $qst_answer = $answer->getAnswertext();
490 $user_answer =
' ' . $solution;
493 $points += $answer->getPoints();
504 $qst_answer = $answer->getAnswertext();
505 $user_answer =
' ' . $solution;
520 $qst_answer = $answer->getAnswertext();
521 $user_answer =
' ' . $solution;
547 if ($returndetails) {
548 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
554 if (is_null(
$pass)) {
561 if ($ilDB->numRows(
$result) == 0) {
567 if (
$row[
"points"] != null) {
568 return $row[
"points"];
587 include_once
"./Services/Utilities/classes/class.ilStr.php";
588 if (is_null(
$pass)) {
589 include_once
"./Modules/Test/classes/class.ilObjTest.php";
596 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $active_id,
$pass, $authorized,
$text) {
605 if ($entered_values) {
606 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
611 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
647 textgap_rating, matchcondition, keyword_relation) VALUES (%s, %s, %s, %s, %s, %s)",
648 array(
"integer",
"integer",
"text",
"text",
'integer',
'text' ),
654 $this->matchcondition,
666 "DELETE FROM qpl_a_essay WHERE question_fi = %s",
671 foreach ($this->answers as $answer) {
673 $nextID = $ilDB->nextId(
'qpl_a_essay');
675 "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) VALUES (%s, %s, %s, %s)",
676 array(
"integer",
"integer",
"text",
'float' ),
680 $answer->getAnswertext(),
707 return "assTextQuestion";
731 switch ($a_text_rating) {
739 $this->text_rating = $a_text_rating;
755 return "qpl_qst_essay";
764 return parent::getRTETextWithMediaObjects();
777 $worksheet->setCell($startrow +
$i, 0, $this->lng->txt(
"result"));
780 require_once
'Modules/Test/classes/class.ilObjAssessmentFolder.php';
783 $string_escaping_org_value =
$worksheet->getStringEscaping();
784 if ($assessment_folder->getExportEssayQuestionsWithHtml() == 1) {
788 if (strlen($solutions[0][
"value1"])) {
789 $worksheet->setCell($startrow +
$i, 1, $solutions[0][
"value1"]);
793 $worksheet->setStringEscaping($string_escaping_org_value);
794 return $startrow +
$i + 1;
802 include_once(
"./Services/RTE/classes/class.ilRTE.php");
816 return count($this->answers);
835 $points_unchecked = 0.0,
839 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
843 $this->answers[] = $answer;
865 if (count($this->answers) < 1) {
868 if (
$index >= count($this->answers)) {
872 return $this->answers[
$index];
888 if (count($this->answers) < 1) {
891 if (
$index >= count($this->answers)) {
894 $answer = $this->answers[
$index];
895 if (strlen($answer->getImage())) {
896 $this->deleteImage($answer->getImage());
898 unset($this->answers[
$index]);
899 $this->answers = array_values($this->answers);
900 for (
$i = 0;
$i < count($this->answers);
$i++) {
901 if ($this->answers[
$i]->getOrder() >
$index) {
902 $this->answers[
$i]->setOrder(
$i);
909 return 'qpl_a_essay';
920 $this->answers =
array();
935 for (
$i = 0;
$i < $count;
$i++) {
949 "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
955 $next_id = $ilDB->nextId(
'qpl_a_essay');
956 $affectedRows = $ilDB->manipulateF(
957 "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) 958 VALUES (%s, %s, %s, %s)",
959 array(
'integer',
'integer',
'text',
'float'),
977 $this->keyword_relation = $a_relation;
982 return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
987 return array(
'non',
'all',
'one');
1010 return $numExistingSolutionRecords > 0;
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...
static strPos($a_haystack, $a_needle, $a_offset=null)
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.
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
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.
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.
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="")
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)
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...
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.
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)