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';
74 $this->answers = array();
75 $this->correctanswers = 0;
90 count($this->answers) >= $this->correctanswers
107 $ilDB = $DIC[
'ilDB'];
126 $ilDB = $DIC[
'ilDB'];
135 $this->
setId($question_id);
144 include_once(
"./Services/RTE/classes/class.ilRTE.php");
164 "SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
168 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
175 parent::loadFromDb($question_id);
185 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
186 if (array_key_exists($order, $this->answers)) {
189 $newchoices = array();
190 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++) {
199 $this->answers = $newchoices;
213 if ($this->
id <= 0) {
218 $this_id = $this->
getId();
222 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
226 if ((
int) $testObjId > 0) {
227 $clone->setObjId($testObjId);
248 $clone->copyPageOfQuestion($this_id);
250 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
252 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
264 if ($this->
id <= 0) {
270 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
273 $source_questionpool_id = $this->
getObjId();
274 $clone->setObjId($target_questionpool_id);
284 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
291 if ($this->
id <= 0) {
296 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
299 $sourceParentId = $this->
getObjId();
305 $clone->setObjId($targetParentId);
307 if ($targetQuestionTitle) {
308 $clone->setTitle($targetQuestionTitle);
313 $clone->copyPageOfQuestion($sourceQuestionId);
315 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
317 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
331 return count($this->answers);
348 if (count($this->answers) < 1) {
351 if (
$index >= count($this->answers)) {
355 return $this->answers[
$index];
371 if (count($this->answers) < 1) {
374 if (
$index >= count($this->answers)) {
377 unset($this->answers[
$index]);
378 $this->answers = array_values($this->answers);
379 for (
$i = 0;
$i < count($this->answers);
$i++) {
380 if ($this->answers[
$i]->getOrder() >
$index) {
381 $this->answers[
$i]->setOrder(
$i);
394 $this->answers = array();
406 foreach ($this->answers as $answer) {
407 if ($answer->getPoints() > 0) {
408 array_push(
$points, $answer->getPoints());
414 $maxpoints +=
$points[$counter];
427 $available_answers = array();
428 foreach ($this->answers as $answer) {
429 array_push($available_answers, $answer->getAnswertext());
431 return $available_answers;
446 include_once
"./Services/Utilities/classes/class.ilStr.php";
451 foreach (
$answers as $key => $value) {
452 if ($this->answers[$key]->
getPoints() <= 0) {
455 $value = html_entity_decode($value); #SB
456 switch ($textrating) {
463 if (strcmp($value, $answer) == 0) {
468 $transformation =
$refinery->string()->levenshtein()->standard($answer, 1);
471 $transformation =
$refinery->string()->levenshtein()->standard($answer, 2);
474 $transformation =
$refinery->string()->levenshtein()->standard($answer, 3);
477 $transformation =
$refinery->string()->levenshtein()->standard($answer, 4);
480 $transformation =
$refinery->string()->levenshtein()->standard($answer, 5);
485 if (isset($transformation) && $transformation->transform($value) >= 0) {
513 switch ($a_text_rating) {
521 $this->text_rating = $a_text_rating;
541 if ($returndetails) {
542 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
546 $ilDB = $DIC[
'ilDB'];
549 if (is_null(
$pass)) {
554 $enteredTexts = array();
556 $enteredTexts[] =
$data[
"value1"];
572 $this->correctanswers = $a_correct_answers;
597 $ilDB = $DIC[
'ilDB'];
600 if (is_null(
$pass)) {
601 include_once
"./Modules/Test/classes/class.ilObjTest.php";
608 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $solutionSubmit, $active_id,
$pass, $authorized) {
611 foreach ($solutionSubmit as $value) {
612 if (strlen($value)) {
619 if ($entered_values) {
620 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
625 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
638 $ilDB = $DIC[
'ilDB'];
644 array( $this->
getId() )
649 ) .
" (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
650 array(
"integer",
"text",
"integer" ),
663 $ilDB = $DIC[
'ilDB'];
665 "DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
667 array( $this->
getId() )
670 foreach ($this->answers as $key => $value) {
671 $answer_obj = $this->answers[$key];
672 $next_id =
$ilDB->nextId(
'qpl_a_textsubset');
674 "INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
675 array(
'integer',
'integer',
'text',
'float',
'integer',
'integer' ),
679 $answer_obj->getAnswertext(),
680 $answer_obj->getPoints(),
681 $answer_obj->getOrder(),
696 return "assTextSubset";
708 foreach ($this->answers as $answer) {
709 if (!is_array($join[$answer->getPoints() .
""])) {
710 $join[$answer->getPoints() .
""] = array();
712 array_push($join[$answer->getPoints() .
""], $answer->getAnswertext());
726 foreach ($this->answers as $answer) {
727 $len = strlen($answer->getAnswertext());
728 if ($len > $maxwidth) {
732 return $maxwidth + 3;
743 return "qpl_qst_textsubset";
754 return "qpl_a_textsubset";
763 return parent::getRTETextWithMediaObjects();
771 parent::setExportDetailsXLS($worksheet, $startrow, $active_id,
$pass);
776 foreach ($solutions as $solution) {
777 $worksheet->setCell($startrow +
$i, 2, $solution[
"value1"]);
781 return $startrow +
$i + 1;
794 include_once(
"./Services/RTE/classes/class.ilRTE.php");
803 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
804 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
808 foreach ($this->
getAnswers() as $key => $answer_obj) {
809 array_push($answers, array(
810 "answertext" => (
string) $answer_obj->getAnswertext(),
811 "points" => (float) $answer_obj->getPoints(),
812 "order" => (int) $answer_obj->getOrder()
819 array_push($answers, array(
836 $solutionSubmit = array();
838 foreach (
$_POST as $key => $val) {
839 if (preg_match(
"/^TEXTSUBSET_(\d+)/", $key, $matches)) {
842 $val = $purifier->purify($val);
843 $solutionSubmit[] = $val;
847 return $solutionSubmit;
858 foreach ($enteredTexts as $enteredtext) {
861 unset($available_answers[
$index]);
878 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
908 $ilDB = $DIC[
'ilDB'];
911 $maxStep = $this->lookupMaxStep($active_id,
$pass);
913 if ($maxStep !== null) {
915 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s ORDER BY solution_id",
916 array(
"integer",
"integer",
"integer",
"integer"),
917 array($active_id,
$pass, $this->
getId(), $maxStep)
921 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s ORDER BY solution_id",
922 array(
"integer",
"integer",
"integer"),
962 if ($answerOptionValue !== $item->getAnswerText()) {
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 getInstance($identifier)
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.
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
& 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.
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.
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.
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. ...
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.
Base Exception for all Exceptions relating to Modules/Test.
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assTextSubset constructor
isAddableAnswerOptionValue($qIndex, $answerOptionValue)
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.
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)
__construct(Container $dic, ilPlugin $plugin)
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...
setLifecycle(ilAssQuestionLifecycle $lifecycle)
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...
static getDraftInstance()
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{}
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
const TEXTGAP_RATING_CASEINSENSITIVE
const EmptyAnswerExpression
addAnswerOptionValue($qIndex, $answerOptionValue, $points)