5 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
6 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
74 $this->answers = array();
75 $this->correctanswers = 0;
86 if (strlen($this->title) and ($this->author) and ($this->question) and (count($this->answers) >= $this->correctanswers) and ($this->
getMaximumPoints() > 0))
109 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
111 array($this->
getId())
114 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
115 array(
"integer",
"text",
"integer"),
123 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
125 array($this->
getId())
128 foreach ($this->answers as $key => $value)
130 $answer_obj = $this->answers[$key];
131 $next_id = $ilDB->nextId(
'qpl_a_textsubset');
132 $query = $ilDB->manipulateF(
"INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
133 array(
'integer',
'integer',
'text',
'float',
'integer',
'integer'),
137 $answer_obj->getAnswertext(),
138 $answer_obj->getPoints(),
139 $answer_obj->getOrder(),
166 $this->
setId($question_id);
175 include_once(
"./Services/RTE/classes/class.ilRTE.php");
183 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
187 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
206 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
207 if (array_key_exists($order, $this->answers))
211 $newchoices = array();
212 for ($i = 0; $i < $order; $i++)
214 array_push($newchoices, $this->answers[$i]);
216 array_push($newchoices, $answer);
217 for ($i = $order; $i < count($this->answers); $i++)
223 $this->answers = $newchoices;
245 $this_id = $this->
getId();
247 if( (
int)$testObjId > 0 )
253 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
257 if( (
int)$testObjId > 0 )
259 $clone->setObjId($testObjId);
286 $clone->copyPageOfQuestion($this_id);
288 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
290 $clone->duplicateGenericFeedback($this_id);
292 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
311 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
314 $source_questionpool = $this->
getObjId();
315 $clone->setObjId($target_questionpool);
342 return count($this->answers);
356 if ($index < 0)
return NULL;
357 if (count($this->answers) < 1)
return NULL;
358 if ($index >= count($this->answers))
return NULL;
360 return $this->answers[$index];
373 if ($index < 0)
return;
374 if (count($this->answers) < 1)
return;
375 if ($index >= count($this->answers))
return;
376 unset($this->answers[$index]);
377 $this->answers = array_values($this->answers);
378 for ($i = 0; $i < count($this->answers); $i++)
380 if ($this->answers[$i]->getOrder() > $index)
382 $this->answers[$i]->setOrder($i);
395 $this->answers = array();
407 foreach ($this->answers as $answer)
409 if ($answer->getPoints() > 0)
411 array_push(
$points, $answer->getPoints());
418 $maxpoints +=
$points[$counter];
431 $available_answers = array();
432 foreach ($this->answers as $answer)
434 array_push($available_answers, $answer->getAnswertext());
436 return $available_answers;
451 include_once
"./Services/Utilities/classes/class.ilStr.php";
454 foreach (
$answers as $key => $value)
462 if (strcmp($value, $answer) == 0 && $this->answers[$key]->
getPoints() > 0)
return $key;
465 if (levenshtein($value, $answer) <= 1 && $this->answers[$key]->
getPoints() > 0)
return $key;
468 if (levenshtein($value, $answer) <= 2 && $this->answers[$key]->
getPoints() > 0)
return $key;
471 if (levenshtein($value, $answer) <= 3 && $this->answers[$key]->
getPoints() > 0)
return $key;
474 if (levenshtein($value, $answer) <= 4 && $this->answers[$key]->
getPoints() > 0)
return $key;
477 if (levenshtein($value, $answer) <= 5 && $this->answers[$key]->
getPoints() > 0)
return $key;
505 switch ($a_text_rating)
514 $this->text_rating = $a_text_rating;
536 throw new ilTestException(
'return details not implemented for '.__METHOD__);
548 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
549 array(
'integer',
'integer',
'integer'),
554 $enteredtext =
$data[
"value1"];
556 if ($index !== FALSE)
558 unset($available_answers[$index]);
559 $points += $this->answers[$index]->getPoints();
574 $this->correctanswers = $a_correct_answers;
603 include_once
"./Modules/Test/classes/class.ilObjTest.php";
608 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
609 array(
'integer',
'integer',
'integer'),
612 foreach (
$_POST as $key => $value)
614 if (preg_match(
"/^TEXTSUBSET_(\d+)/", $key, $matches))
618 $next_id = $ilDB->nextId(
'tst_solutions');
619 $affectedRows = $ilDB->insert(
"tst_solutions", array(
620 "solution_id" => array(
"integer", $next_id),
621 "active_fi" => array(
"integer", $active_id),
622 "question_fi" => array(
"integer", $this->
getId()),
623 "value1" => array(
"clob", trim($value)),
624 "value2" => array(
"clob", null),
625 "pass" => array(
"integer",
$pass),
626 "tstamp" => array(
"integer", time())
634 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
642 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
673 return "assTextSubset";
685 foreach ($this->answers as $answer)
687 if (!is_array($join[$answer->getPoints() .
""]))
689 $join[$answer->getPoints() .
""] = array();
691 array_push($join[$answer->getPoints() .
""], $answer->getAnswertext());
705 foreach ($this->answers as $answer)
707 $len = strlen($answer->getAnswertext());
708 if ($len > $maxwidth) $maxwidth = $len;
710 return $maxwidth + 3;
721 return "qpl_qst_textsubset";
732 return "qpl_a_textsubset";
758 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
763 foreach ($solutions as $solution)
768 return $startrow + $i + 1;
781 include_once(
"./Services/RTE/classes/class.ilRTE.php");
795 foreach ($this->
getAnswers() as $key => $answer_obj)
798 "answertext" => (
string) $answer_obj->getAnswertext(),
799 "points" => (float)$answer_obj->getPoints(),
800 "order" => (int)$answer_obj->getOrder()