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.iQuestionCondition.php';
8require_once
'./Modules/TestQuestionPool/classes/class.ilUserQuestionResult.php';
41 require_once
'Modules/TestQuestionPool/classes/feedback/class.ilAssConfigurableMultiOptionQuestionFeedback.php';
45 $this->ilDB =
$DIC->database();
46 $this->identical_scoring = 1;
156 if (strlen($this->title)
158 && $this->long_menu_text
159 &&
sizeof($this->answers) > 0
160 &&
sizeof($this->correct_answers) > 0
195 if (!is_array($correct_answers_row[0]) ||
sizeof($correct_answers_row[0]) == 0) {
198 if ($correct_answers_row[1] > 0) {
199 array_push(
$points, $correct_answers_row[1]);
222 if (!in_array($answer, $answer_options)) {
251 $this->ilDB->manipulateF(
254 array( $this->
getId() )
256 $this->ilDB->manipulateF(
258 ) .
" (question_fi, long_menu_text, feedback_setting, min_auto_complete, identical_scoring) VALUES (%s, %s, %s, %s, %s)",
259 array(
"integer",
"text",
"integer",
"integer",
"integer"),
278 foreach ($gap[0] as $position => $answer) {
279 if ($type_array ==
null) {
282 $type = $type_array[$gap_number];
287 'question_fi' => array(
'integer', (
int) $this->
getId()),
288 'gap_number' => array(
'integer', (
int) $gap_number),
289 'position' => array(
'integer', (
int) $position)
292 'answer_text' => array(
'text', $answer),
293 'points' => array(
'float', $gap[1]),
294 'type' => array(
'integer', (
int)
$type)
307 foreach ($array as $gap =>
$values) {
311 $file_content .= $value .
"\n";
313 $file_content = rtrim($file_content,
"\n");
315 fwrite($file, $file_content);
331 foreach (
$files as $file) {
332 $gap = str_replace(
'.txt',
'', basename($file));
333 $answers[(int) $gap] = explode(
"\n", file_get_contents($file));
348 throw new ilException(
'Cannot create export directory');
352 !is_dir($folder_name) ||
353 !is_readable($folder_name) ||
354 !is_writable($folder_name)
356 throw new ilException(
'Cannot create export directory');
369 $this->
setId($question_id);
379 include_once(
"./Services/RTE/classes/class.ilRTE.php");
385 if (isset(
$data[
'feedback_setting'])) {
396 parent::loadFromDb($question_id);
401 $res = $this->db->queryF(
402 "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY gap_number, position ASC",
408 while (
$data = $this->ilDB->fetchAssoc(
$res)) {
420 $res = $this->db->queryF(
421 'SELECT gap_number, answer_text FROM ' . $this->
getAnswerTableName() .
' WHERE question_fi = %s',
425 while (
$data = $this->ilDB->fetchAssoc(
$res)) {
439 $res = $this->db->queryF(
440 'SELECT answer_text FROM ' . $this->
getAnswerTableName() .
' WHERE question_fi = %s AND gap_number = %s',
441 array(
'integer',
'integer'),
442 array($question_id, $gap_id)
444 while (
$data = $this->ilDB->fetchAssoc(
$res)) {
453 $res = $this->db->queryF(
454 'SELECT points FROM ' . $this->
getAnswerTableName() .
' WHERE question_fi = %s AND gap_number = %s GROUP BY gap_number, points',
455 array(
'integer',
'integer'),
456 array($question_id, $gap_id)
458 while (
$data = $this->ilDB->fetchAssoc(
$res)) {
478 if ($this->
id <= 0) {
484 $this_id = $this->
getId();
488 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
492 if ((
int) $testObjId > 0) {
493 $clone->setObjId($testObjId);
513 $clone->copyPageOfQuestion($this_id);
514 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
515 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
522 if ($this->
id <= 0) {
528 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
531 $source_questionpool_id = $this->
getObjId();
532 $clone->setObjId($target_questionpool_id);
541 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
548 if ($this->
id <= 0) {
553 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
556 $sourceParentId = $this->
getObjId();
562 $clone->setObjId($targetParentId);
564 if ($targetQuestionTitle) {
565 $clone->setTitle($targetQuestionTitle);
569 $clone->copyPageOfQuestion($sourceQuestionId);
570 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
572 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
591 if ($returndetails) {
592 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
595 $found_values = array();
596 if (is_null(
$pass)) {
601 $found_values[(int)
$data[
'value1']] =
$data[
'value2'];
612 $solution_values_text = array();
613 foreach ($found_values as
$key => $answer) {
620 if ((in_array($answer, $solution_values_text)) && (
$points > 0)) {
625 array_push($solution_values_text, $answer);
642 if (is_null(
$pass)) {
643 include_once
"./Modules/Test/classes/class.ilObjTest.php";
649 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $active_id,
$pass, $authorized) {
654 if (strlen($value)) {
661 if ($entered_values) {
662 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
667 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
688 'authorized' =>
false,
689 'intermediate' =>
false
693 SELECT authorized, COUNT(*) cnt
695 WHERE active_fi = " .
$ilDB->quote($activeId,
'integer') .
"
696 AND question_fi = " .
$ilDB->quote($this->
getId(),
'integer') .
"
697 AND pass = " .
$ilDB->quote(
$pass,
'integer') .
"
701 if ($this->
getStep() !==
null) {
712 if (
$row[
'authorized']) {
713 $return[
'authorized'] =
$row[
'cnt'] > 0;
715 $return[
'intermediate'] =
$row[
'cnt'] > 0;
725 $solutionSubmit = array();
728 foreach ($answer as
$key => $value) {
729 $solutionSubmit[
$key] = $value;
732 return $solutionSubmit;
737 if (array_key_exists(
'answer',
$_POST)) {
751 return "assLongMenu";
761 return 'qpl_qst_lome';
778 parent::setExportDetailsXLS($worksheet, $startrow, $active_id,
$pass);
784 $worksheet->setCell($startrow +
$i, 0, $this->lng->txt(
'assLongMenu') .
" $i");
785 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow +
$i));
786 foreach ($solution as $solutionvalue) {
787 if ($gap_index == $solutionvalue[
"value1"]) {
790 $value = $solutionvalue[
"value2"];
794 $worksheet->setCell($startrow +
$i, 1, $value);
797 $worksheet->setCell($startrow +
$i, 1, $solutionvalue[
"value2"]);
805 return $startrow +
$i + 1;
848 $this->ilDB->manipulateF(
851 array( $question_id )
874 include_once(
"./Services/RTE/classes/class.ilRTE.php");
885 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
886 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
898 return ($this->identical_scoring) ? 1 : 0;
906 $this->identical_scoring = ($a_identical_scoring) ? 1 : 0;
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.
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.
getShuffle()
Gets the shuffle flag.
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.
const FEEDBACK_SETTING_ALL
setParticipantsSolution($participantSolution)
Base class for ILIAS Exception handling.
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 _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...
Base Exception for all Exceptions relating to Modules/Test.
Class ilUserQuestionResult.
static getDataDir()
get data directory (outside webspace)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static makeDirParents($a_dir)
Create a new directory and all parent directories.
migrateToLmContent($content)
Interface ilObjQuestionScoringAdjustable.
if(isset($_POST['submit'])) $form
foreach($_POST as $key=> $value) $res