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';
39 require_once
'Modules/TestQuestionPool/classes/feedback/class.ilAssConfigurableMultiOptionQuestionFeedback.php';
153 if (strlen($this->title)
156 &&
sizeof($this->answers) > 0
157 &&
sizeof($this->correct_answers) > 0
188 if (!is_array($correct_answers_row[0]) ||
sizeof($correct_answers_row[0]) == 0) {
191 if ($correct_answers_row[1] > 0) {
192 array_push(
$points, $correct_answers_row[1]);
210 if (!in_array($answer, $answer_options)) {
242 array( $this->
getId() )
246 ) .
" (question_fi, long_menu_text, feedback_setting, min_auto_complete) VALUES (%s, %s, %s, %s)",
247 array(
"integer",
"text",
"integer",
"integer"),
264 foreach ($gap[0] as $position => $answer) {
265 if ($type_array ==
null) {
268 $type = $type_array[$gap_number];
273 'question_fi' => array(
'integer', (
int) $this->
getId()),
274 'gap_number' => array(
'integer', (
int) $gap_number),
275 'position' => array(
'integer', (
int) $position)
278 'answer_text' => array(
'text', $answer),
279 'points' => array(
'float', $gap[1]),
280 'type' => array(
'integer', (
int)
$type)
293 foreach ($array as $gap => $values) {
295 if (is_array($values)) {
296 foreach ($values as
$key => $value) {
297 $file_content .= $value .
"\n";
299 $file_content = rtrim($file_content,
"\n");
301 fwrite(
$file, $file_content);
318 $gap = str_replace(
'.txt',
'', basename(
$file));
319 $answers[(int) $gap] = explode(
"\n", file_get_contents(
$file));
334 throw new ilException(
'Cannot create export directory');
338 !is_dir($folder_name) ||
339 !is_readable($folder_name) ||
340 !is_writable($folder_name)
342 throw new ilException(
'Cannot create export directory');
355 $this->
setId($question_id);
364 include_once(
"./Services/RTE/classes/class.ilRTE.php");
370 if (isset(
$data[
'feedback_setting'])) {
381 parent::loadFromDb($question_id);
386 $res = $this->db->queryF(
387 "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY gap_number, position ASC",
405 $res = $this->db->queryF(
406 'SELECT gap_number, answer_text FROM ' . $this->
getAnswerTableName() .
' WHERE question_fi = %s',
424 $res = $this->db->queryF(
425 'SELECT answer_text FROM ' . $this->
getAnswerTableName() .
' WHERE question_fi = %s AND gap_number = %s',
426 array(
'integer',
'integer'),
427 array($question_id, $gap_id)
438 $res = $this->db->queryF(
439 'SELECT points FROM ' . $this->
getAnswerTableName() .
' WHERE question_fi = %s AND gap_number = %s GROUP BY gap_number, points',
440 array(
'integer',
'integer'),
441 array($question_id, $gap_id)
463 if ($this->
id <= 0) {
469 $this_id = $this->
getId();
473 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
477 if ((
int) $testObjId > 0) {
478 $clone->setObjId($testObjId);
498 $clone->copyPageOfQuestion($this_id);
499 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
500 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
507 if ($this->
id <= 0) {
513 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
516 $source_questionpool_id = $this->
getObjId();
517 $clone->setObjId($target_questionpool_id);
526 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
533 if ($this->
id <= 0) {
538 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
541 $sourceParentId = $this->
getObjId();
547 $clone->setObjId($targetParentId);
549 if ($targetQuestionTitle) {
550 $clone->setTitle($targetQuestionTitle);
554 $clone->copyPageOfQuestion($sourceQuestionId);
555 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
557 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
576 if ($returndetails) {
577 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
580 $found_values = array();
581 if (is_null(
$pass)) {
586 $found_values[(int)
$data[
'value1']] =
$data[
'value2'];
597 foreach ($found_values as
$key => $answer) {
618 if (is_null(
$pass)) {
619 include_once
"./Modules/Test/classes/class.ilObjTest.php";
625 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $active_id,
$pass, $authorized) {
630 if (strlen($value)) {
637 if ($entered_values) {
638 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
643 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
663 'authorized' =>
false,
664 'intermediate' =>
false
668 SELECT authorized, COUNT(*) cnt
670 WHERE active_fi = " .
$ilDB->quote($activeId,
'integer') .
"
671 AND question_fi = " .
$ilDB->quote($this->
getId(),
'integer') .
"
672 AND pass = " . $ilDB->quote(
$pass,
'integer') .
"
676 if ($this->
getStep() !==
null) {
677 $query .=
" AND step = " . $ilDB->quote((
int) $this->
getStep(),
'integer') .
" ";
687 if (
$row[
'authorized']) {
688 $return[
'authorized'] =
$row[
'cnt'] > 0;
690 $return[
'intermediate'] =
$row[
'cnt'] > 0;
700 $solutionSubmit = array();
703 foreach ($answer as
$key => $value) {
704 $solutionSubmit[
$key] = $value;
707 return $solutionSubmit;
712 if (array_key_exists(
'answer',
$_POST)) {
734 return "assLongMenu";
744 return 'qpl_qst_lome';
767 $worksheet->setCell($startrow +
$i, 0, $this->lng->txt(
'assLongMenu') .
" $i");
769 foreach ($solution as $solutionvalue) {
770 if ($gap_index == $solutionvalue[
"value1"]) {
773 $value = $solutionvalue[
"value2"];
780 $worksheet->setCell($startrow +
$i, 1, $solutionvalue[
"value2"]);
788 return $startrow +
$i + 1;
834 array( $question_id )
857 include_once(
"./Services/RTE/classes/class.ilRTE.php");
868 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
869 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
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)
queryF($a_query, $a_types, $a_values)
Formatted query (for SELECTS).
manipulateF($a_query, $a_types, $a_values)
Formatted manupulate (for DELETE, UPDATE, INSERT).
fetchAssoc($a_set)
Fetch row as associative array from result set.
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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
migrateToLmContent($content)
Interface ilObjQuestionScoringAdjustable.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
foreach($_POST as $key=> $value) $res