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';
8 require_once
'./Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php';
9 require_once
'./Modules/TestQuestionPool/classes/class.ilUserQuestionResult.php';
75 $this->answers =
array();
76 $this->correctanswers = 0;
91 count($this->answers) >= $this->correctanswers
135 $this->
setId($question_id);
144 include_once(
"./Services/RTE/classes/class.ilRTE.php");
160 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
164 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
173 parent::loadFromDb($question_id);
183 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
184 if (array_key_exists($order, $this->answers))
188 $newchoices =
array();
189 for ($i = 0; $i < $order; $i++)
191 array_push($newchoices, $this->answers[$i]);
193 array_push($newchoices, $answer);
194 for ($i = $order; $i < count($this->answers); $i++)
200 $this->answers = $newchoices;
222 $this_id = $this->
getId();
226 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
230 if( (
int)$testObjId > 0 )
232 $clone->setObjId($testObjId);
259 $clone->copyPageOfQuestion($this_id);
261 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
263 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
282 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
285 $source_questionpool_id = $this->
getObjId();
286 $clone->setObjId($target_questionpool_id);
297 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
310 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
313 $sourceParentId = $this->
getObjId();
319 $clone->setObjId($targetParentId);
321 if ($targetQuestionTitle)
323 $clone->setTitle($targetQuestionTitle);
328 $clone->copyPageOfQuestion($sourceQuestionId);
330 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
332 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
346 return count($this->answers);
360 if ($index < 0)
return NULL;
361 if (count($this->answers) < 1)
return NULL;
362 if ($index >= count($this->answers))
return NULL;
364 return $this->answers[$index];
377 if ($index < 0)
return;
378 if (count($this->answers) < 1)
return;
379 if ($index >= count($this->answers))
return;
380 unset($this->answers[$index]);
381 $this->answers = array_values($this->answers);
382 for ($i = 0; $i < count($this->answers); $i++)
384 if ($this->answers[$i]->getOrder() > $index)
386 $this->answers[$i]->setOrder($i);
399 $this->answers =
array();
411 foreach ($this->answers as $answer)
413 if ($answer->getPoints() > 0)
415 array_push(
$points, $answer->getPoints());
435 $available_answers =
array();
436 foreach ($this->answers as $answer)
438 array_push($available_answers, $answer->getAnswertext());
440 return $available_answers;
455 include_once
"./Services/Utilities/classes/class.ilStr.php";
458 foreach ($answers as $key => $value)
466 if (strcmp($value, $answer) == 0 && $this->answers[$key]->
getPoints() > 0)
return $key;
469 if (levenshtein($value, $answer) <= 1 && $this->answers[$key]->
getPoints() > 0)
return $key;
472 if (levenshtein($value, $answer) <= 2 && $this->answers[$key]->
getPoints() > 0)
return $key;
475 if (levenshtein($value, $answer) <= 3 && $this->answers[$key]->
getPoints() > 0)
return $key;
478 if (levenshtein($value, $answer) <= 4 && $this->answers[$key]->
getPoints() > 0)
return $key;
481 if (levenshtein($value, $answer) <= 5 && $this->answers[$key]->
getPoints() > 0)
return $key;
509 switch ($a_text_rating)
518 $this->text_rating = $a_text_rating;
540 throw new ilTestException(
'return details not implemented for '.__METHOD__);
552 $enteredTexts =
array();
555 $enteredTexts[] =
$data[
"value1"];
571 $this->correctanswers = $a_correct_answers;
600 include_once
"./Modules/Test/classes/class.ilObjTest.php";
607 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function() use (&$entered_values, $solutionSubmit, $active_id,
$pass, $authorized) {
611 foreach($solutionSubmit as $value)
624 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
632 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
654 ) .
" (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
655 array(
"integer",
"text",
"integer" ),
668 $ilDB->manipulateF(
"DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
673 foreach ($this->answers as $key => $value)
675 $answer_obj = $this->answers[$key];
676 $next_id = $ilDB->nextId(
'qpl_a_textsubset' );
677 $ilDB->manipulateF(
"INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
678 array(
'integer',
'integer',
'text',
'float',
'integer',
'integer' ),
682 $answer_obj->getAnswertext(),
683 $answer_obj->getPoints(),
684 $answer_obj->getOrder(),
707 return "assTextSubset";
719 foreach ($this->answers as $answer)
721 if (!is_array($join[$answer->getPoints() .
""]))
723 $join[$answer->getPoints() .
""] =
array();
725 array_push($join[$answer->getPoints() .
""], $answer->getAnswertext());
739 foreach ($this->answers as $answer)
741 $len = strlen($answer->getAnswertext());
742 if ($len > $maxwidth) $maxwidth = $len;
744 return $maxwidth + 3;
755 return "qpl_qst_textsubset";
766 return "qpl_a_textsubset";
775 return parent::getRTETextWithMediaObjects();
788 foreach ($solutions as $solution)
790 $worksheet->setCell($startrow + $i, 0, $solution[
"value1"]);
794 return $startrow + $i + 1;
807 include_once(
"./Services/RTE/classes/class.ilRTE.php");
816 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
817 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
821 foreach ($this->
getAnswers() as $key => $answer_obj)
823 array_push($answers,
array(
824 "answertext" => (
string) $answer_obj->getAnswertext(),
825 "points" => (float)$answer_obj->getPoints(),
826 "order" => (int)$answer_obj->getOrder()
834 array_push($answers,
array(
851 $solutionSubmit =
array();
853 foreach(
$_POST as $key => $val)
855 if(preg_match(
"/^TEXTSUBSET_(\d+)/", $key, $matches))
860 $val = $purifier->purify($val);
861 $solutionSubmit[] = $val;
865 return $solutionSubmit;
876 foreach($enteredTexts as $enteredtext)
881 unset($available_answers[$index]);
882 $points += $this->answers[$index]->getPoints();
898 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
930 $maxStep = $this->lookupMaxStep($active_id,
$pass);
932 if( $maxStep !== null )
934 $data = $ilDB->queryF(
935 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s ORDER BY solution_id",
936 array(
"integer",
"integer",
"integer",
"integer"),
942 $data = $ilDB->queryF(
943 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s ORDER BY solution_id",
944 array(
"integer",
"integer",
"integer"),
949 for($index = 1; $index <= $ilDB->numRows(
$data); ++$index)
calculateReachedPointsForSolution($enteredTexts)
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
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
const PercentageResultExpression
Class iQuestionCondition.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
flushAnswers()
Deletes all answers.
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...
Class for answers with a binary state indicator.
getOperators($expression)
Get all available operations for a specific question.
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 from given hour, minute and second. ...
Add rich text string
The name of the decorator.
static strToLower($a_string)
isComplete()
Returns true, if a TextSubset question is complete for use.
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
setNrOfTries($a_nr_of_tries)
const StringResultExpression
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
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.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
getQuestionType()
Returns the question type of the question.
reworkWorkingData($active_id, $pass, $obligationsAnswered, $authorized)
{}
Base Exception for all Exceptions relating to Modules/Test.
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assTextSubset constructor
static _getLogLanguage()
retrieve the log language for assessment logging
setAuthor($author="")
Sets the authors name of the assQuestion object.
saveToDb($original_id="")
Saves a assTextSubset object to a database.
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
const TEXTGAP_RATING_LEVENSHTEIN3
Class ilUserQuestionResult.
loadFromDb($question_id)
Loads a assTextSubset object from a database.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
& getAvailableAnswers()
Returns the available answers for the question.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
const NumericResultExpression
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.
getHtmlUserSolutionPurifier()
getAdditionalTableName()
Returns the name of the additional question data table in the database.
calculateReachedPoints($active_id, $pass=NULL, $authorizedSolution=true, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
Create styles array
The data for the language used.
static getOperatorsByExpression($expression)
getExpressionTypes()
Get all available expression types for a specific question.
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="")
getAnswer($index=0)
Returns an answer with a given index.
setQuestion($question="")
Sets the question string of the question object.
Interface ilObjQuestionScoringAdjustable.
removeCurrentSolution($active_id, $pass, $authorized=true)
const TEXTGAP_RATING_LEVENSHTEIN4
saveWorkingData($active_id, $pass=NULL, $authorized=true)
Saves the learners input of the question to the database.
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...
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
getTitle()
Gets the title string of the assQuestion object.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
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...
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{}
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
const TEXTGAP_RATING_CASEINSENSITIVE
const EmptyAnswerExpression