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';
77 $this->maxNumOfChars = 0;
79 $this->answers = array();
80 $this->matchcondition = 0;
90 if (strlen($this->title)
131 $this->
setId($question_id);
140 include_once(
"./Services/RTE/classes/class.ilRTE.php");
145 $this->matchcondition = (strlen(
$data[
'matchcondition'])) ?
$data[
'matchcondition'] : 0;
156 "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
158 array($this->
getId())
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)) {
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");
641 array( $this->
getId()
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",
668 array( $this->
getId() )
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'),
960 array($next_id, $this->
getId(),
$row[
"answertext"],
$row[
"points"])
977 $this->keyword_relation = $a_relation;
982 return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
987 return array(
'non',
'all',
'one');
1010 return $numExistingSolutionRecords > 0;
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked,...
An exception for terminatinating execution or to throw for unit testing.
Abstract basic class which is to be extended by the concrete assessment question type classes.
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.
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.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
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.
getHtmlUserSolutionPurifier()
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
removeCurrentSolution($active_id, $pass, $authorized=true)
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.
getPoints()
Returns the maximum available points for the question.
getShuffle()
Gets the shuffle flag.
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
setQuestion($question="")
Sets the question string of the question object.
Class for text questions.
setMaxNumOfChars($maxchars=0)
Sets the maximum number of characters for the text solution.
static isObligationPossible($questionId)
returns boolean wether it is possible to set this question type as obligatory or not considering the ...
isAnswered($active_id, $pass=null)
returns boolean wether the question is answered during test pass or not
isKeywordMatching($answertext, $a_keyword)
Checks if one of the keywords matches the answertext.
saveToDb($original_id="")
Saves a assTextQuestion object to a database.
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{Creates an Excel worksheet for the detailed cumulated results of this question.object}
loadFromDb($question_id)
Loads a assTextQuestion object from a database.
addAnswer( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="")
Adds a possible answer for a multiple choice question.
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
reworkWorkingData($active_id, $pass, $obligationsAnswered, $authorized)
{Reworks the allready saved working data if neccessary.}
isComplete()
Returns true, if a multiple choice question is complete for use.
setKeywordRelation($a_relation)
This method implements a default behaviour.
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
getAnswer($index=0)
Returns an answer with a given index.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
static getScoringModesWithPointsByKeyword()
toJSON()
Returns a JSON representation of the question.
getAnswerTableName()
Returns the name of the answer table in the database.
flushAnswers()
Deletes all answers.
setTextRating($a_text_rating)
Sets the rating option for text comparisons.
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assTextQuestion.
static getValidScoringModes()
copyObject($target_questionpool_id, $title="")
Copies an assTextQuestion object.
getQuestionType()
Returns the question type of the question.
deleteAnswer($index=0)
Deletes an answer with a given index.
getMaxNumOfChars()
Gets the maximum number of characters for the text solution.
calculateReachedPointsForSolution($solution)
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
createRandomSolution($test_id, $user_id)
isValidTextRating($textRating)
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
setReachedPoints($active_id, $points, $pass=null)
Sets the points, a learner has reached answering the question.
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assTextQuestion constructor
static getScoringModesWithPointsByQuestion()
getTextRating()
Returns the rating option for text comparisons.
duplicateAnswers($original_id)
Class ilObjAssessmentFolder.
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
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...
static strPos($a_haystack, $a_needle, $a_offset=null)
static strToLower($a_string)
Base Exception for all Exceptions relating to Modules/Test.
static isHTML($a_text)
Checks if a given string contains HTML or not.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_CASEINSENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN1
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.