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';
73 $this->answers = array();
74 $this->correctanswers = 0;
89 count($this->answers) >= $this->correctanswers
133 $this->
setId($question_id);
142 include_once(
"./Services/RTE/classes/class.ilRTE.php");
158 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
162 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
171 parent::loadFromDb($question_id);
181 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
182 if (array_key_exists($order, $this->answers))
186 $newchoices = array();
187 for ($i = 0; $i < $order; $i++)
189 array_push($newchoices, $this->answers[$i]);
191 array_push($newchoices, $answer);
192 for ($i = $order; $i < count($this->answers); $i++)
198 $this->answers = $newchoices;
220 $this_id = $this->
getId();
224 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
228 if( (
int)$testObjId > 0 )
230 $clone->setObjId($testObjId);
257 $clone->copyPageOfQuestion($this_id);
259 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
261 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
280 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
283 $source_questionpool_id = $this->
getObjId();
284 $clone->setObjId($target_questionpool_id);
295 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
308 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
311 $sourceParentId = $this->
getObjId();
317 $clone->setObjId($targetParentId);
319 if ($targetQuestionTitle)
321 $clone->setTitle($targetQuestionTitle);
326 $clone->copyPageOfQuestion($sourceQuestionId);
328 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
330 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
344 return count($this->answers);
358 if ($index < 0)
return NULL;
359 if (count($this->answers) < 1)
return NULL;
360 if ($index >= count($this->answers))
return NULL;
362 return $this->answers[$index];
375 if ($index < 0)
return;
376 if (count($this->answers) < 1)
return;
377 if ($index >= count($this->answers))
return;
378 unset($this->answers[$index]);
379 $this->answers = array_values($this->answers);
380 for ($i = 0; $i < count($this->answers); $i++)
382 if ($this->answers[$i]->getOrder() > $index)
384 $this->answers[$i]->setOrder($i);
397 $this->answers = array();
409 foreach ($this->answers as $answer)
411 if ($answer->getPoints() > 0)
413 array_push(
$points, $answer->getPoints());
420 $maxpoints +=
$points[$counter];
433 $available_answers = array();
434 foreach ($this->answers as $answer)
436 array_push($available_answers, $answer->getAnswertext());
438 return $available_answers;
453 include_once
"./Services/Utilities/classes/class.ilStr.php";
456 foreach ($answers as $key => $value)
464 if (strcmp($value, $answer) == 0 && $this->answers[$key]->
getPoints() > 0)
return $key;
467 if (levenshtein($value, $answer) <= 1 && $this->answers[$key]->
getPoints() > 0)
return $key;
470 if (levenshtein($value, $answer) <= 2 && $this->answers[$key]->
getPoints() > 0)
return $key;
473 if (levenshtein($value, $answer) <= 3 && $this->answers[$key]->
getPoints() > 0)
return $key;
476 if (levenshtein($value, $answer) <= 4 && $this->answers[$key]->
getPoints() > 0)
return $key;
479 if (levenshtein($value, $answer) <= 5 && $this->answers[$key]->
getPoints() > 0)
return $key;
507 switch ($a_text_rating)
516 $this->text_rating = $a_text_rating;
538 throw new ilTestException(
'return details not implemented for '.__METHOD__);
550 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
551 array(
'integer',
'integer',
'integer'),
556 $enteredtext =
$data[
"value1"];
558 if ($index !== FALSE)
560 unset($available_answers[$index]);
561 $points += $this->answers[$index]->getPoints();
576 $this->correctanswers = $a_correct_answers;
605 include_once
"./Modules/Test/classes/class.ilObjTest.php";
612 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
613 array(
'integer',
'integer',
'integer'),
616 require_once
'Services/Utilities/classes/class.ilUtil.php';
617 foreach (
$_POST as $key => $value)
619 if (preg_match(
"/^TEXTSUBSET_(\d+)/", $key, $matches))
624 $next_id = $ilDB->nextId(
'tst_solutions');
625 $affectedRows = $ilDB->insert(
"tst_solutions", array(
626 "solution_id" => array(
"integer", $next_id),
627 "active_fi" => array(
"integer", $active_id),
628 "question_fi" => array(
"integer", $this->
getId()),
629 "value1" => array(
"clob", trim($value)),
630 "value2" => array(
"clob", null),
631 "pass" => array(
"integer",
$pass),
632 "tstamp" => array(
"integer", time())
643 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
651 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
669 array( $this->
getId() )
673 ) .
" (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
674 array(
"integer",
"text",
"integer" ),
687 $ilDB->manipulateF(
"DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
689 array( $this->
getId() )
692 foreach ($this->answers as $key => $value)
694 $answer_obj = $this->answers[$key];
695 $next_id = $ilDB->nextId(
'qpl_a_textsubset' );
696 $ilDB->manipulateF(
"INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
697 array(
'integer',
'integer',
'text',
'float',
'integer',
'integer' ),
701 $answer_obj->getAnswertext(),
702 $answer_obj->getPoints(),
703 $answer_obj->getOrder(),
731 return "assTextSubset";
743 foreach ($this->answers as $answer)
745 if (!is_array($join[$answer->getPoints() .
""]))
747 $join[$answer->getPoints() .
""] = array();
749 array_push($join[$answer->getPoints() .
""], $answer->getAnswertext());
763 foreach ($this->answers as $answer)
765 $len = strlen($answer->getAnswertext());
766 if ($len > $maxwidth) $maxwidth = $len;
768 return $maxwidth + 3;
779 return "qpl_qst_textsubset";
790 return "qpl_a_textsubset";
799 return parent::getRTETextWithMediaObjects();
816 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
821 foreach ($solutions as $solution)
826 return $startrow + $i + 1;
839 include_once(
"./Services/RTE/classes/class.ilRTE.php");
848 "onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false),
849 "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true)
853 foreach ($this->
getAnswers() as $key => $answer_obj)
855 array_push($answers, array(
856 "answertext" => (
string) $answer_obj->getAnswertext(),
857 "points" => (float)$answer_obj->getPoints(),
858 "order" => (int)$answer_obj->getOrder()
866 array_push($answers, array(
addAnswer($answertext, $points, $order)
Adds an answer to the question.
getId()
Gets the id of the assQuestion object.
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
getCorrectAnswers()
Returns the number of correct answers needed to solve the question.
const TEXTGAP_RATING_LEVENSHTEIN5
flushAnswers()
Deletes all answers.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
Creates an Excel worksheet for the detailed cumulated results of this question.
getPoints()
Returns the maximum available points for the question.
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
Abstract basic class which is to be extended by the concrete assessment question type classes...
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
Class for answers with a binary state indicator.
_convert_text($a_text, $a_target="has been removed")
copyObject($target_questionpool_id, $title="")
Copies an assTextSubset object.
& joinAnswers()
Returns the answers of the question as a comma separated string.
getTextRating()
Returns the rating option for text comparisons.
setTextRating($a_text_rating)
Sets the rating option for text comparisons.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
toJSON()
Returns a JSON representation of the question.
setId($id=-1)
Sets the id of the assQuestion object.
getAnswerTableName()
Returns the name of the answer table in the database.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Class for TextSubset questions.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question.
static strToLower($a_string)
isComplete()
Returns true, if a TextSubset question is complete for use.
setNrOfTries($a_nr_of_tries)
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
getObjId()
Get the object id of the container object.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
getQuestionType()
Returns the question type of the question.
Base Exception for all Exceptions relating to Modules/Test.
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assTextSubset constructor
fetchAssoc($a_set)
Fetch row as associative array from result set.
setAuthor($author="")
Sets the authors name of the assQuestion object.
saveToDb($original_id="")
Saves a assTextSubset object to a database.
const TEXTGAP_RATING_LEVENSHTEIN3
loadFromDb($question_id)
Loads a assTextSubset object from a database.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
& getAvailableAnswers()
Returns the available answers for the question.
setCorrectAnswers($a_correct_answers)
Sets the number of correct answers needed to solve the question.
const TEXTGAP_RATING_CASESENSITIVE
Interface ilObjAnswerScoringAdjustable.
getQuestion()
Gets the question string of the question object.
getAnswerCount()
Returns the number of answers.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
_getLogLanguage()
retrieve the log language for assessment logging
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
setPoints($a_points)
Sets the maximum available points for the question.
saveQuestionDataToDb($original_id="")
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
calculateReachedPoints($active_id, $pass=NULL, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
getAnswer($index=0)
Returns an answer with a given index.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
setQuestion($question="")
Sets the question string of the question object.
Interface ilObjQuestionScoringAdjustable.
reworkWorkingData($active_id, $pass, $obligationsAnswered)
Reworks the allready saved working data if neccessary.
const TEXTGAP_RATING_LEVENSHTEIN4
setOriginalId($original_id)
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getTitle()
Gets the title string of the assQuestion object.
deleteAnswer($index=0)
Deletes an answer with a given index.
getMaxTextboxWidth()
Returns the maximum width needed for the answer textboxes.
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assTextSubsetQuestion.
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.
isAnswerCorrect($answers, $answer)
Returns the index of the found answer, if the given answer is in the set of correct answers and match...
saveWorkingData($active_id, $pass=NULL)
Saves the learners input of the question to the database.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
const TEXTGAP_RATING_CASEINSENSITIVE