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)
123 $ilDB = $DIC[
'ilDB'];
132 $this->
setId($question_id);
141 include_once(
"./Services/RTE/classes/class.ilRTE.php");
146 $this->matchcondition = (strlen($data[
'matchcondition'])) ? $data[
'matchcondition'] : 0;
147 $this->
setEstimatedWorkingTime(substr($data[
"working_time"], 0, 2), substr($data[
"working_time"], 3, 2), substr($data[
"working_time"], 6, 2));
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) {
370 $ilDB = $DIC[
'ilDB'];
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__);
554 $ilDB = $DIC[
'ilDB'];
557 if (is_null(
$pass)) {
570 if (
$row[
"points"] != null) {
571 return $row[
"points"];
588 $ilDB = $DIC[
'ilDB'];
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");
642 $ilDB = $DIC[
'ilDB'];
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,
669 $ilDB = $DIC[
'ilDB'];
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++) {
945 $ilDB = $DIC[
'ilDB'];
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'];
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.
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.
getLatestAutosaveContent($active_id)
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
createRandomSolution($test_id, $user_id)