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
133 $this->
setId($question_id);
142 include_once(
"./Services/RTE/classes/class.ilRTE.php");
156 "SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
160 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
167 parent::loadFromDb($question_id);
177 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
178 if (array_key_exists($order, $this->answers)) {
181 $newchoices =
array();
182 for (
$i = 0;
$i < $order;
$i++) {
183 array_push($newchoices, $this->answers[
$i]);
185 array_push($newchoices, $answer);
186 for (
$i = $order;
$i < count($this->answers);
$i++) {
191 $this->answers = $newchoices;
205 if ($this->
id <= 0) {
210 $this_id = $this->
getId();
214 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
218 if ((
int) $testObjId > 0) {
219 $clone->setObjId($testObjId);
240 $clone->copyPageOfQuestion($this_id);
242 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
244 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
256 if ($this->
id <= 0) {
262 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
265 $source_questionpool_id = $this->
getObjId();
266 $clone->setObjId($target_questionpool_id);
276 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
283 if ($this->
id <= 0) {
288 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
291 $sourceParentId = $this->
getObjId();
297 $clone->setObjId($targetParentId);
299 if ($targetQuestionTitle) {
300 $clone->setTitle($targetQuestionTitle);
305 $clone->copyPageOfQuestion($sourceQuestionId);
307 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
309 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
323 return count($this->answers);
340 if (count($this->answers) < 1) {
343 if (
$index >= count($this->answers)) {
347 return $this->answers[
$index];
363 if (count($this->answers) < 1) {
366 if (
$index >= count($this->answers)) {
369 unset($this->answers[
$index]);
370 $this->answers = array_values($this->answers);
371 for (
$i = 0;
$i < count($this->answers);
$i++) {
372 if ($this->answers[
$i]->getOrder() >
$index) {
373 $this->answers[
$i]->setOrder(
$i);
386 $this->answers =
array();
398 foreach ($this->answers as $answer) {
399 if ($answer->getPoints() > 0) {
400 array_push(
$points, $answer->getPoints());
419 $available_answers =
array();
420 foreach ($this->answers as $answer) {
421 array_push($available_answers, $answer->getAnswertext());
423 return $available_answers;
438 include_once
"./Services/Utilities/classes/class.ilStr.php";
442 switch ($textrating) {
449 if (strcmp($value, $answer) == 0 && $this->answers[
$key]->
getPoints() > 0) {
454 if (levenshtein($value, $answer) <= 1 && $this->answers[
$key]->
getPoints() > 0) {
459 if (levenshtein($value, $answer) <= 2 && $this->answers[
$key]->
getPoints() > 0) {
464 if (levenshtein($value, $answer) <= 3 && $this->answers[
$key]->
getPoints() > 0) {
469 if (levenshtein($value, $answer) <= 4 && $this->answers[
$key]->
getPoints() > 0) {
474 if (levenshtein($value, $answer) <= 5 && $this->answers[
$key]->
getPoints() > 0) {
504 switch ($a_text_rating) {
512 $this->text_rating = $a_text_rating;
532 if ($returndetails) {
533 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
539 if (is_null(
$pass)) {
544 $enteredTexts =
array();
546 $enteredTexts[] =
$data[
"value1"];
562 $this->correctanswers = $a_correct_answers;
589 if (is_null(
$pass)) {
590 include_once
"./Modules/Test/classes/class.ilObjTest.php";
597 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $solutionSubmit, $active_id,
$pass, $authorized) {
600 foreach ($solutionSubmit as $value) {
601 if (strlen($value)) {
608 if ($entered_values) {
609 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
614 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
637 ) .
" (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
638 array(
"integer",
"text",
"integer" ),
652 "DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
657 foreach ($this->answers as
$key => $value) {
658 $answer_obj = $this->answers[
$key];
659 $next_id = $ilDB->nextId(
'qpl_a_textsubset');
661 "INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
662 array(
'integer',
'integer',
'text',
'float',
'integer',
'integer' ),
666 $answer_obj->getAnswertext(),
667 $answer_obj->getPoints(),
668 $answer_obj->getOrder(),
691 return "assTextSubset";
703 foreach ($this->answers as $answer) {
704 if (!is_array($join[$answer->getPoints() .
""])) {
705 $join[$answer->getPoints() .
""] =
array();
707 array_push($join[$answer->getPoints() .
""], $answer->getAnswertext());
721 foreach ($this->answers as $answer) {
722 $len = strlen($answer->getAnswertext());
723 if ($len > $maxwidth) {
727 return $maxwidth + 3;
738 return "qpl_qst_textsubset";
749 return "qpl_a_textsubset";
758 return parent::getRTETextWithMediaObjects();
771 foreach ($solutions as $solution) {
772 $worksheet->setCell($startrow +
$i, 0, $solution[
"value1"]);
776 return $startrow +
$i + 1;
789 include_once(
"./Services/RTE/classes/class.ilRTE.php");
798 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
799 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
804 array_push($answers,
array(
805 "answertext" => (
string) $answer_obj->getAnswertext(),
806 "points" => (float) $answer_obj->getPoints(),
807 "order" => (int) $answer_obj->getOrder()
814 array_push($answers,
array(
831 $solutionSubmit =
array();
834 if (preg_match(
"/^TEXTSUBSET_(\d+)/",
$key, $matches)) {
837 $val = $purifier->purify($val);
838 $solutionSubmit[] = $val;
842 return $solutionSubmit;
853 foreach ($enteredTexts as $enteredtext) {
856 unset($available_answers[
$index]);
873 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
905 $maxStep = $this->lookupMaxStep($active_id,
$pass);
907 if ($maxStep !== null) {
908 $data = $ilDB->queryF(
909 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s ORDER BY solution_id",
910 array(
"integer",
"integer",
"integer",
"integer"),
914 $data = $ilDB->queryF(
915 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s ORDER BY solution_id",
916 array(
"integer",
"integer",
"integer"),
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.
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.
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.
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
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.
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