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.iQuestionCondition.php';
8 require_once
'./Modules/TestQuestionPool/classes/class.ilUserQuestionResult.php';
30 require_once
'Modules/TestQuestionPool/classes/feedback/class.ilAssConfigurableMultiOptionQuestionFeedback.php';
32 $this->minAutoComplete = self::MIN_LENGTH_AUTOCOMPLETE;
142 return $this->minAutoComplete ? $this->minAutoComplete : self::MIN_LENGTH_AUTOCOMPLETE;
147 if (strlen($this->title)
150 &&
sizeof($this->answers) > 0
151 &&
sizeof($this->correct_answers) > 0
173 if(
sizeof($correct_answers) == 0 ||
sizeof($hidden_text_files) == 0 )
177 if(
sizeof($correct_answers) !=
sizeof($hidden_text_files))
181 foreach($correct_answers as $key => $correct_answers_row)
187 if( !is_array($correct_answers_row[0]) ||
sizeof($correct_answers_row[0]) == 0)
191 if($correct_answers_row[1] > 0)
193 array_push(
$points, $correct_answers_row[1]);
196 if(
sizeof($correct_answers) !=
sizeof(
$points))
213 foreach($answers[0] as $key => $answer)
215 if(!in_array($answer, $answer_options))
252 ) .
" (question_fi, long_menu_text, feedback_setting, min_auto_complete) VALUES (%s, %s, %s, %s)",
253 array(
"integer",
"text",
"integer",
"integer"),
271 foreach($gap[0] as $position => $answer)
273 if($type_array == null)
279 $type = $type_array[$gap_number];
284 'question_fi' =>
array(
'integer', (
int)$this->
getId()),
285 'gap_number' =>
array(
'integer', (
int)$gap_number),
286 'position' =>
array(
'integer', (
int)$position)
289 'answer_text' =>
array(
'text', $answer),
290 'points' =>
array(
'float', $gap[1]),
291 'type' =>
array(
'integer', (
int) $type)
304 foreach($array as $gap => $values)
307 if(is_array($values))
309 foreach($values as $key => $value)
311 $file_content .= $value .
"\n";
313 $file_content = rtrim($file_content,
"\n");
315 fwrite(
$file, $file_content);
334 $gap = str_replace(
'.txt',
'', basename($file));
335 $answers[(int) $gap] = explode(
"\n", file_get_contents($file));
351 throw new ilException(
'Cannot create export directory');
355 !is_dir($folder_name) ||
356 !is_readable($folder_name) ||
357 !is_writable($folder_name)
360 throw new ilException(
'Cannot create export directory');
373 $this->
setId($question_id);
382 include_once(
"./Services/RTE/classes/class.ilRTE.php");
388 if( isset(
$data[
'feedback_setting']) )
403 parent::loadFromDb($question_id);
408 $res = $this->db->queryF(
409 "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY gap_number, position ASC",
413 $correct_answers =
array();
416 $correct_answers[
$data[
'gap_number']][0][
$data[
'position']] = rtrim($data[
'answer_text']);
417 $correct_answers[$data[
'gap_number']][1] = $data[
'points'];
418 $correct_answers[$data[
'gap_number']][2] = $data[
'type'];
427 $correct_answers =
array();
428 $res = $this->db->queryF(
429 'SELECT gap_number, answer_text FROM ' . $this->
getAnswerTableName() .
' WHERE question_fi = %s',
434 if(array_key_exists(
$data[
'gap_number'], $correct_answers))
436 $correct_answers[
$data[
'gap_number']] .=
' ' . $this->lng->txt(
"or") .
' ';
437 $correct_answers[
$data[
'gap_number']] .= rtrim(
$data[
'answer_text']);
441 $correct_answers[
$data[
'gap_number']] .= rtrim(
$data[
'answer_text']);
449 $correct_answers =
array();
450 $res = $this->db->queryF(
451 'SELECT answer_text FROM ' . $this->
getAnswerTableName() .
' WHERE question_fi = %s AND gap_number = %s',
452 array(
'integer',
'integer'),
array($question_id, $gap_id)
456 $correct_answers[] = rtrim(
$data[
'answer_text']);
464 $res = $this->db->queryF(
465 'SELECT points FROM ' . $this->
getAnswerTableName() .
' WHERE question_fi = %s AND gap_number = %s GROUP BY gap_number, points',
466 array(
'integer',
'integer'),
array($question_id, $gap_id)
497 $this_id = $this->
getId();
501 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
505 if( (
int)$testObjId > 0 )
507 $clone->setObjId($testObjId);
533 $clone->copyPageOfQuestion($this_id);
534 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
535 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
549 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
552 $source_questionpool_id = $this->
getObjId();
553 $clone->setObjId($target_questionpool_id);
563 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
576 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
579 $sourceParentId = $this->
getObjId();
585 $clone->setObjId($targetParentId);
587 if ($targetQuestionTitle)
589 $clone->setTitle($targetQuestionTitle);
593 $clone->copyPageOfQuestion($sourceQuestionId);
594 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
596 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
617 throw new ilTestException(
'return details not implemented for '.__METHOD__);
620 $found_values =
array();
628 $found_values[(int)
$data[
'value1']] =
$data[
'value2'];
639 foreach($found_values as $key => $answer)
644 if(in_array($answer, $correct_answers))
665 include_once
"./Modules/Test/classes/class.ilObjTest.php";
671 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function() use (&$entered_values, $active_id,
$pass, $authorized) {
689 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
697 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
718 'authorized' =>
false,
719 'intermediate' =>
false 723 SELECT authorized, COUNT(*) cnt 725 WHERE active_fi = " . $ilDB->quote($activeId,
'integer') .
" 726 AND question_fi = ". $ilDB->quote($this->
getId(),
'integer') .
" 727 AND pass = " .$ilDB->quote(
$pass,
'integer') .
" 731 if( $this->
getStep() !== NULL )
733 $query .=
" AND step = " . $ilDB->quote((
int)$this->
getStep(),
'integer') .
" ";
744 if (
$row[
'authorized']) {
745 $return[
'authorized'] =
$row[
'cnt'] > 0;
749 $return[
'intermediate'] =
$row[
'cnt'] > 0;
759 $solutionSubmit =
array();
762 foreach($answer as $key => $value)
764 $solutionSubmit[$key] = $value;
767 return $solutionSubmit;
772 if( array_key_exists(
'answer',
$_POST) )
797 return "assLongMenu";
807 return 'qpl_qst_lome';
831 $worksheet->setCell($startrow + $i, 0, $this->lng->txt(
'assLongMenu') .
" $i");
833 foreach ($solution as $solutionvalue)
835 if ($gap_index == $solutionvalue[
"value1"])
839 case self::ANSWER_TYPE_SELECT_VAL:
840 $value = $solutionvalue[
"value2"];
845 $worksheet->setCell($startrow + $i, 1, $value);
847 case self::ANSWER_TYPE_TEXT_VAL:
848 $worksheet->setCell($startrow + $i, 1, $solutionvalue[
"value2"]);
856 return $startrow + $i + 1;
901 array( $question_id )
924 include_once(
"./Services/RTE/classes/class.ilRTE.php");
935 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
936 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
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.
Base class for ILIAS Exception handling.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
getPoints()
Returns the maximum available points for the question.
Abstract basic class which is to be extended by the concrete assessment question type classes...
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
setId($id=-1)
Sets the id of the assQuestion object.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second. ...
migrateToLmContent($content)
Add rich text string
The name of the decorator.
setNrOfTries($a_nr_of_tries)
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.
getShuffle()
Gets the shuffle flag.
Base Exception for all Exceptions relating to Modules/Test.
setParticipantsSolution($participantSolution)
manipulateF($a_query, $a_types, $a_values)
Formatted manupulate (for DELETE, UPDATE, INSERT).
static _getLogLanguage()
retrieve the log language for assessment logging
fetchAssoc($a_set)
Fetch row as associative array from result set.
setAuthor($author="")
Sets the authors name of the assQuestion object.
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
Class ilUserQuestionResult.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
getQuestion()
Gets the question string of the question object.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
queryF($a_query, $a_types, $a_values)
Formatted query (for SELECTS).
setPoints($a_points)
Sets the maximum available points for the question.
saveQuestionDataToDb($original_id="")
static getDataDir()
get data directory (outside webspace)
setQuestion($question="")
Sets the question string of the question object.
const FEEDBACK_SETTING_ALL
Interface ilObjQuestionScoringAdjustable.
removeCurrentSolution($active_id, $pass, $authorized=true)
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.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
setComment($comment="")
Sets the comment string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.