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';
8require_once
'./Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php';
9require_once
'./Modules/TestQuestionPool/classes/class.ilUserQuestionResult.php';
74 $this->answers = array();
75 $this->correctanswers = 0;
90 count($this->answers) >= $this->correctanswers
135 $this->
setId($question_id);
144 include_once(
"./Services/RTE/classes/class.ilRTE.php");
158 "SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
162 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
169 parent::loadFromDb($question_id);
179 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
180 if (array_key_exists($order, $this->answers)) {
183 $newchoices = array();
184 for (
$i = 0;
$i < $order;
$i++) {
185 array_push($newchoices, $this->answers[
$i]);
187 array_push($newchoices, $answer);
188 for (
$i = $order;
$i < count($this->answers);
$i++) {
193 $this->answers = $newchoices;
207 if ($this->
id <= 0) {
212 $this_id = $this->
getId();
216 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
220 if ((
int) $testObjId > 0) {
221 $clone->setObjId($testObjId);
242 $clone->copyPageOfQuestion($this_id);
244 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
246 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
258 if ($this->
id <= 0) {
264 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
267 $source_questionpool_id = $this->
getObjId();
268 $clone->setObjId($target_questionpool_id);
278 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
285 if ($this->
id <= 0) {
290 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
293 $sourceParentId = $this->
getObjId();
299 $clone->setObjId($targetParentId);
301 if ($targetQuestionTitle) {
302 $clone->setTitle($targetQuestionTitle);
307 $clone->copyPageOfQuestion($sourceQuestionId);
309 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
311 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
325 return count($this->answers);
342 if (count($this->answers) < 1) {
345 if (
$index >= count($this->answers)) {
349 return $this->answers[
$index];
365 if (count($this->answers) < 1) {
368 if (
$index >= count($this->answers)) {
371 unset($this->answers[
$index]);
372 $this->answers = array_values($this->answers);
373 for (
$i = 0;
$i < count($this->answers);
$i++) {
374 if ($this->answers[
$i]->getOrder() >
$index) {
375 $this->answers[
$i]->setOrder(
$i);
388 $this->answers = array();
400 foreach ($this->answers as $answer) {
401 if ($answer->getPoints() > 0) {
402 array_push(
$points, $answer->getPoints());
408 $maxpoints +=
$points[$counter];
421 $available_answers = array();
422 foreach ($this->answers as $answer) {
423 array_push($available_answers, $answer->getAnswertext());
425 return $available_answers;
440 include_once
"./Services/Utilities/classes/class.ilStr.php";
444 switch ($textrating) {
451 if (strcmp($value, $answer) == 0 && $this->answers[
$key]->
getPoints() > 0) {
456 if (levenshtein($value, $answer) <= 1 && $this->answers[
$key]->
getPoints() > 0) {
461 if (levenshtein($value, $answer) <= 2 && $this->answers[
$key]->
getPoints() > 0) {
466 if (levenshtein($value, $answer) <= 3 && $this->answers[
$key]->
getPoints() > 0) {
471 if (levenshtein($value, $answer) <= 4 && $this->answers[
$key]->
getPoints() > 0) {
476 if (levenshtein($value, $answer) <= 5 && $this->answers[
$key]->
getPoints() > 0) {
506 switch ($a_text_rating) {
514 $this->text_rating = $a_text_rating;
534 if ($returndetails) {
535 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
542 if (is_null(
$pass)) {
547 $enteredTexts = array();
549 $enteredTexts[] =
$data[
"value1"];
565 $this->correctanswers = $a_correct_answers;
593 if (is_null(
$pass)) {
594 include_once
"./Modules/Test/classes/class.ilObjTest.php";
601 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $solutionSubmit, $active_id,
$pass, $authorized) {
604 foreach ($solutionSubmit as $value) {
605 if (strlen($value)) {
612 if ($entered_values) {
613 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
618 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
637 array( $this->
getId() )
642 ) .
" (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
643 array(
"integer",
"text",
"integer" ),
658 "DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
660 array( $this->
getId() )
663 foreach ($this->answers as
$key => $value) {
664 $answer_obj = $this->answers[
$key];
665 $next_id =
$ilDB->nextId(
'qpl_a_textsubset');
667 "INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
668 array(
'integer',
'integer',
'text',
'float',
'integer',
'integer' ),
672 $answer_obj->getAnswertext(),
673 $answer_obj->getPoints(),
674 $answer_obj->getOrder(),
689 return "assTextSubset";
701 foreach ($this->answers as $answer) {
702 if (!is_array($join[$answer->getPoints() .
""])) {
703 $join[$answer->getPoints() .
""] = array();
705 array_push($join[$answer->getPoints() .
""], $answer->getAnswertext());
719 foreach ($this->answers as $answer) {
720 $len = strlen($answer->getAnswertext());
721 if ($len > $maxwidth) {
725 return $maxwidth + 3;
736 return "qpl_qst_textsubset";
747 return "qpl_a_textsubset";
756 return parent::getRTETextWithMediaObjects();
764 parent::setExportDetailsXLS($worksheet, $startrow, $active_id,
$pass);
769 foreach ($solutions as $solution) {
770 $worksheet->setCell($startrow +
$i, 0, $solution[
"value1"]);
774 return $startrow +
$i + 1;
787 include_once(
"./Services/RTE/classes/class.ilRTE.php");
796 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
797 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
803 "answertext" => (
string) $answer_obj->getAnswertext(),
804 "points" => (
float) $answer_obj->getPoints(),
805 "order" => (
int) $answer_obj->getOrder()
829 $solutionSubmit = array();
832 if (preg_match(
"/^TEXTSUBSET_(\d+)/",
$key, $matches)) {
835 $val = $purifier->purify($val);
836 $solutionSubmit[] = $val;
840 return $solutionSubmit;
851 foreach ($enteredTexts as $enteredtext) {
854 unset($available_answers[
$index]);
871 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
904 $maxStep = $this->lookupMaxStep($active_id,
$pass);
906 if ($maxStep !==
null) {
908 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s ORDER BY solution_id",
909 array(
"integer",
"integer",
"integer",
"integer"),
910 array($active_id,
$pass, $this->
getId(), $maxStep)
914 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s ORDER BY solution_id",
915 array(
"integer",
"integer",
"integer"),
Class for answers with a binary state indicator.
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.
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)
setAuthor($author="")
Sets the authors name of the assQuestion object.
getPoints()
Returns the maximum available points for the question.
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 TextSubset questions.
getExpressionTypes()
Get all available expression types for a specific question.
getMaxTextboxWidth()
Returns the maximum width needed for the answer textboxes.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
isAnswerCorrect($answers, $answer)
Returns the index of the found answer, if the given answer is in the set of correct answers and match...
& joinAnswers()
Returns the answers of the question as a comma separated string.
toJSON()
Returns a JSON representation of the question.
deleteAnswer($index=0)
Deletes an answer with a given index.
isComplete()
Returns true, if a TextSubset question is complete for use.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
setTextRating($a_text_rating)
Sets the rating option for text comparisons.
saveToDb($original_id="")
Saves a assTextSubset object to a database.
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assTextSubsetQuestion.
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{Creates an Excel worksheet for the detailed cumulated results of this question.object}
calculateReachedPointsForSolution($enteredTexts)
addAnswer($answertext, $points, $order)
Adds an answer to the question.
getAnswerTableName()
Returns the name of the answer table in the database.
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
getOperators($expression)
Get all available operations for a specific question.
copyObject($target_questionpool_id, $title="")
Copies an assTextSubset object.
& getAvailableAnswers()
Returns the available answers for the question.
getTextRating()
Returns the rating option for text comparisons.
loadFromDb($question_id)
Loads a assTextSubset object from a database.
getQuestionType()
Returns the question type of the question.
getCorrectAnswers()
Returns the number of correct answers needed to solve the question.
getAnswerCount()
Returns the number of answers.
flushAnswers()
Deletes all answers.
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assTextSubset constructor
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
setCorrectAnswers($a_correct_answers)
Sets the number of correct answers needed to solve the question.
getAnswer($index=0)
Returns an answer with a given index.
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
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 getOperatorsByExpression($expression)
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 strToLower($a_string)
Base Exception for all Exceptions relating to Modules/Test.
Class ilUserQuestionResult.
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
Class iQuestionCondition.
const PercentageResultExpression
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
const StringResultExpression
const NumericResultExpression
const EmptyAnswerExpression
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.