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)
132 $this->
setId($question_id);
141 include_once(
"./Services/RTE/classes/class.ilRTE.php");
146 $this->matchcondition = (strlen(
$data[
'matchcondition'])) ?
$data[
'matchcondition'] : 0;
157 "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
159 array($this->
getId())
167 parent::loadFromDb($question_id);
177 if ($this->
id <= 0) {
182 $this_id = $this->
getId();
186 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
190 if ((
int) $testObjId > 0) {
191 $clone->setObjId($testObjId);
212 $clone->copyPageOfQuestion($this_id);
214 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
215 #$clone->duplicateAnswers($this_id);
217 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
229 if ($this->
id <= 0) {
235 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
238 $source_questionpool_id = $this->
getObjId();
239 $clone->setObjId($target_questionpool_id);
249 #$clone->duplicateAnswers($original_id);
251 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
258 if ($this->
id <= 0) {
263 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
266 $sourceParentId = $this->
getObjId();
272 $clone->setObjId($targetParentId);
274 if ($targetQuestionTitle) {
275 $clone->setTitle($targetQuestionTitle);
280 $clone->copyPageOfQuestion($sourceQuestionId);
282 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
284 #$clone->duplicateAnswers($sourceQuestionId);
286 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
300 if (strcmp($this->maxNumOfChars,
"") == 0) {
316 $this->maxNumOfChars = $maxchars;
327 if (in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
328 return parent::getPoints();
333 foreach ($this->answers as $answer) {
334 if ($answer->getPoints() > 0) {
344 if (in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
350 foreach ($this->answers as $answer) {
351 if ($answer->getPoints() < 0) {
373 if (is_null(
$pass)) {
376 $affectedRows =
$ilDB->manipulateF(
377 "UPDATE tst_test_result SET points = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
378 array(
'float',
'integer',
'integer',
'integer'),
381 self::_updateTestPassResults($active_id,
$pass);
390 switch ($textRating) {
416 include_once
"./Services/Utilities/classes/class.ilStr.php";
417 switch ($textrating) {
431 $answertext = strip_tags($answertext);
433 $answerwords = array();
434 if (preg_match_all(
"/([^\s.]+)/", $answertext, $matches)) {
435 foreach ($matches[1] as $answerword) {
436 array_push($answerwords, trim($answerword));
439 foreach ($answerwords as $a_original) {
440 switch ($textrating) {
442 if (levenshtein($a_original, $a_keyword) <= 1) {
447 if (levenshtein($a_original, $a_keyword) <= 2) {
452 if (levenshtein($a_original, $a_keyword) <= 3) {
457 if (levenshtein($a_original, $a_keyword) <= 4) {
462 if (levenshtein($a_original, $a_keyword) <= 5) {
491 $qst_answer = $answer->getAnswertext();
492 $user_answer =
' ' . $solution;
495 $points += $answer->getPoints();
506 $qst_answer = $answer->getAnswertext();
507 $user_answer =
' ' . $solution;
522 $qst_answer = $answer->getAnswertext();
523 $user_answer =
' ' . $solution;
549 if ($returndetails) {
550 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
557 if (is_null(
$pass)) {
570 if (
$row[
"points"] !=
null) {
571 return $row[
"points"];
591 include_once
"./Services/Utilities/classes/class.ilStr.php";
592 if (is_null(
$pass)) {
593 include_once
"./Modules/Test/classes/class.ilObjTest.php";
600 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $active_id,
$pass, $authorized,
$text) {
609 if ($entered_values) {
610 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
615 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
646 array( $this->
getId()
652 textgap_rating, matchcondition, keyword_relation) VALUES (%s, %s, %s, %s, %s, %s)",
653 array(
"integer",
"integer",
"text",
"text",
'integer',
'text' ),
659 $this->matchcondition,
672 "DELETE FROM qpl_a_essay WHERE question_fi = %s",
674 array( $this->
getId() )
677 foreach ($this->answers as $answer) {
679 $nextID =
$ilDB->nextId(
'qpl_a_essay');
681 "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) VALUES (%s, %s, %s, %s)",
682 array(
"integer",
"integer",
"text",
'float' ),
686 $answer->getAnswertext(),
705 return "assTextQuestion";
729 switch ($a_text_rating) {
737 $this->text_rating = $a_text_rating;
753 return "qpl_qst_essay";
762 return parent::getRTETextWithMediaObjects();
770 parent::setExportDetailsXLS($worksheet, $startrow, $active_id,
$pass);
775 $worksheet->setCell($startrow +
$i, 0, $this->lng->txt(
"result"));
776 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow +
$i));
778 require_once
'Modules/Test/classes/class.ilObjAssessmentFolder.php';
781 $string_escaping_org_value = $worksheet->getStringEscaping();
782 if ($assessment_folder->getExportEssayQuestionsWithHtml() == 1) {
783 $worksheet->setStringEscaping(
false);
786 if (strlen($solutions[0][
"value1"])) {
787 $worksheet->setCell($startrow +
$i, 1, $solutions[0][
"value1"]);
791 $worksheet->setStringEscaping($string_escaping_org_value);
792 return $startrow +
$i + 1;
800 include_once(
"./Services/RTE/classes/class.ilRTE.php");
814 return count($this->answers);
833 $points_unchecked = 0.0,
837 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
841 $this->answers[] = $answer;
863 if (count($this->answers) < 1) {
866 if (
$index >= count($this->answers)) {
870 return $this->answers[
$index];
886 if (count($this->answers) < 1) {
889 if (
$index >= count($this->answers)) {
892 $answer = $this->answers[
$index];
893 if (strlen($answer->getImage())) {
894 $this->deleteImage($answer->getImage());
896 unset($this->answers[
$index]);
897 $this->answers = array_values($this->answers);
898 for (
$i = 0;
$i < count($this->answers);
$i++) {
899 if ($this->answers[
$i]->getOrder() >
$index) {
900 $this->answers[
$i]->setOrder(
$i);
907 return 'qpl_a_essay';
918 $this->answers = array();
933 for (
$i = 0;
$i < $count;
$i++) {
948 "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
954 $next_id =
$ilDB->nextId(
'qpl_a_essay');
955 $affectedRows =
$ilDB->manipulateF(
956 "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points)
957 VALUES (%s, %s, %s, %s)",
958 array(
'integer',
'integer',
'text',
'float'),
959 array($next_id, $this->
getId(),
$row[
"answertext"],
$row[
"points"])
976 $this->keyword_relation = $a_relation;
981 return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
986 return array(
'non',
'all',
'one');
1009 return $numExistingSolutionRecords > 0;
1044 $question_fi = $this->
getId();
1047 $cntresult = $this->db->query(
'
1048 SELECT count(solution_id) cnt
1050 WHERE active_fi = ' . $this->db->quote($active_id,
'int') .
'
1051 AND question_fi = ' . $this->db->quote($this->getId(),
'int') .
'
1052 AND authorized = ' . $this->db->quote(0,
'int')
1054 $row = $this->db->fetchAssoc($cntresult);
1055 if(
$row[
'cnt'] > 0 ) {
1056 $tresult = $this->db->query(
'
1059 WHERE active_fi = ' . $this->db->quote($active_id,
'int') .
'
1060 AND question_fi = ' . $this->db->quote($this->getId(),
'int') .
'
1061 AND authorized = ' . $this->db->quote(0,
'int')
1063 $trow = $this->db->fetchAssoc($tresult);
1064 return $trow[
'value1'];
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 ...
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)
getLatestAutosaveContent($active_id)
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.