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]);
221 foreach (
$answers[0] as $key => $answer) {
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) {
309 if (is_array($values)) {
310 foreach ($values as $key => $value) {
311 $file_content .= $value .
"\n";
313 $file_content = rtrim($file_content,
"\n");
315 fwrite($file, $file_content);
325 if ($files ===
false) {
331 foreach ($files as $file) {
332 $gap = str_replace(
'.txt',
'', basename($file));
333 $answers[(int) $gap] = explode(
"\n", file_get_contents($file));
353 throw new ilException(
'Cannot create export directory');
357 !is_dir($folder_name) ||
358 !is_readable($folder_name) ||
359 !is_writable($folder_name)
361 throw new ilException(
'Cannot create export directory');
374 $this->
setId($question_id);
384 include_once(
"./Services/RTE/classes/class.ilRTE.php");
390 if (isset(
$data[
'feedback_setting'])) {
408 parent::loadFromDb($question_id);
413 $res = $this->db->queryF(
414 "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY gap_number, position ASC",
420 while (
$data = $this->ilDB->fetchAssoc(
$res)) {
432 $res = $this->db->queryF(
433 'SELECT gap_number, answer_text FROM ' . $this->
getAnswerTableName() .
' WHERE question_fi = %s',
437 while (
$data = $this->ilDB->fetchAssoc(
$res)) {
451 $res = $this->db->queryF(
452 'SELECT answer_text FROM ' . $this->
getAnswerTableName() .
' WHERE question_fi = %s AND gap_number = %s',
453 array(
'integer',
'integer'),
454 array($question_id, $gap_id)
456 while (
$data = $this->ilDB->fetchAssoc(
$res)) {
465 $res = $this->db->queryF(
466 'SELECT points FROM ' . $this->
getAnswerTableName() .
' WHERE question_fi = %s AND gap_number = %s GROUP BY gap_number, points',
467 array(
'integer',
'integer'),
468 array($question_id, $gap_id)
470 while (
$data = $this->ilDB->fetchAssoc(
$res)) {
490 if ($this->
id <= 0) {
496 $this_id = $this->
getId();
500 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
504 if ((
int) $testObjId > 0) {
505 $clone->setObjId($testObjId);
525 $clone->copyPageOfQuestion($this_id);
526 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
527 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
534 if ($this->
id <= 0) {
540 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
543 $source_questionpool_id = $this->
getObjId();
544 $clone->setObjId($target_questionpool_id);
553 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
560 if ($this->
id <= 0) {
565 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
568 $sourceParentId = $this->
getObjId();
574 $clone->setObjId($targetParentId);
576 if ($targetQuestionTitle) {
577 $clone->setTitle($targetQuestionTitle);
581 $clone->copyPageOfQuestion($sourceQuestionId);
582 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
584 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
603 if ($returndetails) {
604 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
607 $found_values = array();
608 if (is_null(
$pass)) {
613 $found_values[(int)
$data[
'value1']] =
$data[
'value2'];
624 $solution_values_text = array();
625 foreach ($found_values as $key => $answer) {
632 if ((in_array($answer, $solution_values_text)) && (
$points > 0)) {
637 array_push($solution_values_text, $answer);
654 if (is_null(
$pass)) {
655 include_once
"./Modules/Test/classes/class.ilObjTest.php";
661 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $active_id,
$pass, $authorized) {
666 if (strlen($value)) {
673 if ($entered_values) {
674 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
679 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
700 'authorized' =>
false,
701 'intermediate' =>
false
705 SELECT authorized, COUNT(*) cnt
707 WHERE active_fi = " .
$ilDB->quote($activeId,
'integer') .
"
708 AND question_fi = " .
$ilDB->quote($this->
getId(),
'integer') .
"
709 AND pass = " .
$ilDB->quote(
$pass,
'integer') .
"
713 if ($this->
getStep() !==
null) {
724 if ($row[
'authorized']) {
725 $return[
'authorized'] = $row[
'cnt'] > 0;
727 $return[
'intermediate'] = $row[
'cnt'] > 0;
737 $solutionSubmit = array();
740 foreach ($answer as $key => $value) {
741 $solutionSubmit[$key] = $value;
744 return $solutionSubmit;
749 if (array_key_exists(
'answer',
$_POST)) {
765 return "assLongMenu";
775 return 'qpl_qst_lome';
792 parent::setExportDetailsXLS($worksheet, $startrow, $active_id,
$pass);
798 $worksheet->setCell($startrow +
$i, 0, $this->lng->txt(
'assLongMenu') .
" $i");
799 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow +
$i));
800 foreach ($solution as $solutionvalue) {
801 if ($gap_index == $solutionvalue[
"value1"]) {
804 $value = $solutionvalue[
"value2"];
808 $worksheet->setCell($startrow +
$i, 2, $value);
811 $worksheet->setCell($startrow +
$i, 2, $solutionvalue[
"value2"]);
819 return $startrow +
$i + 1;
862 $this->ilDB->manipulateF(
865 array( $question_id )
888 include_once(
"./Services/RTE/classes/class.ilRTE.php");
899 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
900 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
912 return ($this->identical_scoring) ? 1 : 0;
920 $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="")
getHtmlQuestionContentPurifier()
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.
setLifecycle(ilAssQuestionLifecycle $lifecycle)
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
static getDraftInstance()
static getInstance($identifier)
setParticipantsSolution($participantSolution)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
foreach($_POST as $key=> $value) $res