diff --git a/README.md b/README.md index d0463d6d847596d520913c6582519d263e7e6550..13f12a82806c24fd5fc2c3660238664e201560da 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ILIAS FormATest -* For ILIAS versions: 5.3.0 - 5.4.999 +* For ILIAS versions: 6.0 - 6.999 ## Installation Instructions 1. Clone this repository to /Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest diff --git a/classes/adapter/class.ilFatImageMapQuestionAdapter.php b/classes/adapter/class.ilFatImageMapQuestionAdapter.php index 2cc52620478ad56b5bbe822bc59e88b6b5239f3d..a7151fb93bf545af4636c8aca28bffcc758aa4f8 100644 --- a/classes/adapter/class.ilFatImageMapQuestionAdapter.php +++ b/classes/adapter/class.ilFatImageMapQuestionAdapter.php @@ -1,5 +1,4 @@ database(); - - if (is_null($pass)) - { - include_once "./Modules/Test/classes/class.ilObjTest.php"; - $pass = ilObjTest::_getPass($active_id); - } - - $solutionSelectionChanged = false; - - $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function() use (&$solutionSelectionChanged, $ilDB, $active_id, $pass, $authorized) { - if ($this->isRemoveSolutionSelectionRequest()) { - $selection = $this->getRemoveSolutionSelectionParameter(); - if (strlen($selection) > 0) { - $this->deleteSolutionRecordByValues($active_id, $pass, !$authorized, array( - 'value1' => (int)$selection - )); - $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, array( - 'value1' => (int)$selection - )); - - $solutionSelectionChanged = true; - } - } else if ($this->isAddSolutionSelectionRequest()) { - $selection = $this->getAddSolutionSelectionParameter(); - if (strlen($selection) > 0) { - if ($this->is_multiple_choice) { - $this->deleteSolutionRecordByValues($active_id, $pass, !$authorized, array( - 'value1' => (int)$selection - )); - $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, array( - 'value1' => (int)$selection - )); - } else { - $this->removeCurrentSolution($active_id, $pass, !$authorized); - $this->removeCurrentSolution($active_id, $pass, $authorized); - } + public function saveWorkingData($active_id, $pass = null, $authorized = true) + { + global $DIC; + $ilDB = $DIC->database(); + + if (is_null($pass)) { + $pass = ilObjTest::_getPass($active_id); + } + + $solutionSelectionChanged = false; + + $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$solutionSelectionChanged, $ilDB, $active_id, $pass, $authorized) { + if ($this->isRemoveSolutionSelectionRequest()) { + $selection = $this->getRemoveSolutionSelectionParameter(); + if (strlen($selection) > 0) { + $this->deleteSolutionRecordByValues($active_id, $pass, !$authorized, array( + 'value1' => (int) $selection + )); + $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, array( + 'value1' => (int) $selection + )); + + $solutionSelectionChanged = true; + } + } elseif ($this->isAddSolutionSelectionRequest()) { + $selection = $this->getAddSolutionSelectionParameter(); + if (strlen($selection) > 0) { + if ($this->is_multiple_choice) { + $this->deleteSolutionRecordByValues($active_id, $pass, !$authorized, array( + 'value1' => (int) $selection + )); + $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, array( + 'value1' => (int) $selection + )); + } else { + $this->removeCurrentSolution($active_id, $pass, !$authorized); + $this->removeCurrentSolution($active_id, $pass, $authorized); + } - $this->saveCurrentSolution($active_id, $pass, (int)$selection, null, !$authorized); - $this->saveCurrentSolution($active_id, $pass, (int)$selection, null, $authorized); + $this->saveCurrentSolution($active_id, $pass, (int) $selection, null, !$authorized); + $this->saveCurrentSolution($active_id, $pass, (int) $selection, null, $authorized); - $solutionSelectionChanged = true; - } - } - }); - - require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php'; - if( ilObjAssessmentFolder::_enabledAssessmentLogging() ) - { - if( $solutionSelectionChanged ) - { - assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId()); - } - else - { - assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId()); - } - } - - return true; - } - - public function removeIntermediateSolution($active_id, $pass) - { - } -} \ No newline at end of file + $solutionSelectionChanged = true; + } + } + }); + + if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { + if ($solutionSelectionChanged) { + assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId()); + } else { + assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId()); + } + } + + return true; + } + + public function removeIntermediateSolution($active_id, $pass) + { + } +} diff --git a/classes/class.ilFatQuestionFactory.php b/classes/class.ilFatQuestionFactory.php index 4685c7e63e0bbc259cbdb168b177c92fba8a07eb..c130659f34f4c3000e8cc0da2432ed5b3eeac7fe 100644 --- a/classes/class.ilFatQuestionFactory.php +++ b/classes/class.ilFatQuestionFactory.php @@ -1,32 +1,28 @@ */ class ilFatQuestionFactory { - private function __construct() - { - } - - public static function instantiateQuestionGUI($obj_id) - { - $gui = assQuestion::instantiateQuestionGUI($obj_id); - if ($gui->object instanceof assImagemapQuestion) { - require_once 'Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/classes/adapter/class.ilFatImageMapQuestionAdapter.php'; - $object = new ilFatImageMapQuestionAdapter(); - $object->loadFromDb($obj_id); - - $object->setProcessLocker($gui->object->getProcessLocker()); - $object->feedbackOBJ = $gui->object->feedbackOBJ; + private function __construct() + { + } + + public static function instantiateQuestionGUI($obj_id) + { + $gui = assQuestion::instantiateQuestionGUI($obj_id); + if ($gui->object instanceof assImagemapQuestion) { + require_once 'Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/classes/adapter/class.ilFatImageMapQuestionAdapter.php'; + $object = new ilFatImageMapQuestionAdapter(); + $object->loadFromDb($obj_id); + + $object->setProcessLocker($gui->object->getProcessLocker()); + $object->feedbackOBJ = $gui->object->feedbackOBJ; - $gui->object = $object; - } + $gui->object = $object; + } - return $gui; - } - - - -} \ No newline at end of file + return $gui; + } +} diff --git a/classes/class.ilFormATestExportGUI.php b/classes/class.ilFormATestExportGUI.php index 2f9fc159b91c567439244957c207e02849847f7f..ecf6c4fd2ed01138104792307402b67cacb34f1e 100755 --- a/classes/class.ilFormATestExportGUI.php +++ b/classes/class.ilFormATestExportGUI.php @@ -1,33 +1,30 @@ */ class ilFormATestExportGUI extends ilExportGUI { - /** - * {@inheritdoc} - */ - protected function buildExportTableGUI() - { - require_once 'tables/class.ilFormATestExportTableGUI.php'; - $table = new ilFormATestExportTableGUI($this, 'listExportFiles', $this->obj); - return $table; - } - - /** - * Download file - */ - public function download() - { - if(isset($_GET['file']) && $_GET['file']) - { - $_POST['file'] = array($_GET['file']); - } - parent::download(); - } -} \ No newline at end of file + /** + * {@inheritdoc} + */ + protected function buildExportTableGUI() + { + require_once 'tables/class.ilFormATestExportTableGUI.php'; + $table = new ilFormATestExportTableGUI($this, 'listExportFiles', $this->obj); + return $table; + } + + /** + * Download file + */ + public function download() + { + if (isset($_GET['file']) && $_GET['file']) { + $_POST['file'] = array($_GET['file']); + } + parent::download(); + } +} diff --git a/classes/class.ilFormATestExporter.php b/classes/class.ilFormATestExporter.php index aee500ed64605ea7e394deb6eda32a6c06995ca6..69c65a401d57ec6bc1c68bf1540661d7288b348a 100755 --- a/classes/class.ilFormATestExporter.php +++ b/classes/class.ilFormATestExporter.php @@ -1,9 +1,6 @@ plugin_object = ilPlugin::getPluginObject('Services', 'Repository', 'robj', 'FormATest'); - } - - /** - * - */ - public function initLogFile() - { - include_once "./Services/Logging/classes/class.ilLog.php"; - $this->expLog = new ilLog($this->getExportDirectory(), "export.log"); - $this->expLog->delete(); - $this->expLog->setLogFormat(""); - $this->expLog->write(date("[y-m-d H:i:s] ") . "Start Export"); - } - - /** - * get export directory of questionsetpool - * @param string $type - * @return string - */ - function getExportDirectory($type = "") - { - include_once "./Services/Utilities/classes/class.ilUtil.php"; - switch($type) - { - case 'xml': - include_once("./Services/Export/classes/class.ilExport.php"); - $export_dir = ilExport::_getExportDirectory($this->object->getId(), $type, $this->object->getType()); - break; - // case 'xls': - case 'zip': - $export_dir = ilUtil::getDataDir() . "/xtsf_data" . "/xtsf_" . $this->object->getId() . "/export_$type"; - break; - - default: - $export_dir = ilUtil::getDataDir() . "/xtsf_data" . "/xtsf_" . $this->object->getId() . "/export"; - break; - } - return $export_dir; - } - - /** - * - */ - public function exportPagesXML() - { - global $DIC; - $ilBench = $DIC['ilBench']; - - $this->mob_ids = array(); - $this->file_ids = array(); - - $attrs = array(); - $attrs["Type"] = "Test_FormATest"; - $this->xml_writer->xmlStartTag("ContentObject", $attrs); - - // MetaData - $this->exportXMLMetaData(); - - // Settings - $this->exportXMLSettings(); - - $this->exportMarkSchema(); - - // Question Sets - $this->exportQuestionSets(); - - // PageObjects - $this->expLog->write(date("[y-m-d H:i:s] ") . "Start Export Page Objects"); - $ilBench->start("ContentObjectExport", "exportPageObjects"); - $this->qpl_obj->exportXMLPageObjects($this->xml_writer, IL_INST_ID, $this->expLog, $this->questions); - $ilBench->stop("ContentObjectExport", "exportPageObjects"); - $this->expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Page Objects"); - - // add media objects which were added with tiny mce - $this->expLog->write(date("[y-m-d H:i:s] ") . "Start Export Media Objects"); - $export_dir = $this->exp->export_run_dir; - $ilBench->start("ContentObjectExport", "exportMediaObjects"); - - $this->exportXHTMLMediaObjects($export_dir); - $ilBench->stop("ContentObjectExport", "exportMediaObjects"); - $this->expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Media Objects"); - - if(is_array($this->qpl_obj->file_ids) && count($this->qpl_obj->file_ids) > 0) - { - // FileItems - $this->expLog->write(date("[y-m-d H:i:s] ") . "Start Export File Items"); - $ilBench->start("ContentObjectExport", "exportFileItems"); - $this->exportFileItems($this->export_dir . "/" . $this->subdir, $this->expLog); - $ilBench->stop("ContentObjectExport", "exportFileItems"); - $this->expLog->write(date("[y-m-d H:i:s] ") . "Finished Export File Items"); - } - $this->xml_writer->xmlEndTag("ContentObject"); - } - - /** - * export content objects meta data to xml (see ilias_co.dtd) - */ - function exportXMLMetaData() - { - include_once("Services/MetaData/classes/class.ilMD2XML.php"); - $md2xml = new ilMD2XML($this->object->getId(), 0, $this->object->getType()); - $md2xml->setExportMode(true); - $md2xml->startExport(); - $this->xml_writer->appendXML($md2xml->getXML()); - } - - /** - * - */ - private function exportXMLSettings() - { - $this->xml_writer->xmlStartTag('Settings'); - - // general - $this->xml_writer->xmlElement('Title', null, (string)$this->object->getTitle()); - $this->xml_writer->xmlElement('Description', null, (string)$this->object->getDescription()); - - // Availability - $this->xml_writer->xmlElement('Online', null, (int)$this->object->isOnline()); - - // Information at Beginning and End of Test - $this->xml_writer->xmlElement('ShowIntroStatement', null, (int)$this->object->getShowIntroStatement()); - $this->xml_writer->xmlElement('IntroStatement', null, (string)$this->object->getIntroStatement()); - $this->xml_writer->xmlElement('ShowFinalStatement', null, (int)$this->object->getShowFinalStatement()); - $this->xml_writer->xmlElement('FinalStatement', null, (string)$this->object->getFinalStatement()); - - // Session Settings - $this->xml_writer->xmlElement('MaxPasses', null, (int)$this->object->getMaxPasses()); - $this->xml_writer->xmlElement('StartTime', null,$this->object->getStartTime()); - $this->xml_writer->xmlElement('EndTime', null, $this->object->getEndTime()); - $this->xml_writer->xmlElement('StartTimeEnabled', null, (int)$this->object->isStartTimeEnabled()); - $this->xml_writer->xmlElement('EndTimeEnabled', null, (int)$this->object->isEndTimeEnabled()); - $this->xml_writer->xmlElement('AllowWalkBack', null, $this->object->isAllowWalkBack()); - $this->xml_writer->xmlElement('ShowCurrentTrack', null, $this->object->getShowCurrentTrack()); - $this->xml_writer->xmlElement('ShowQuestionsOverview', null, $this->object->getShowQuestionsOverview()); - $this->xml_writer->xmlElement('AllowInterruption', null, $this->object->isAllowInterruption()); - $this->xml_writer->xmlElement('SkillServiceEnabled', null, (int)$this->object->isSkillServiceEnabled()); - - // Behavior of the Question - $this->xml_writer->xmlElement('AnswerFeedbackPoints', null, $this->object->getAnswerFeedbackPoints()); - $this->xml_writer->xmlElement('GenericAnswerFeedback', null, $this->object->getGenericAnswerFeedback()); - $this->xml_writer->xmlElement('SpecificAnswerFeedback', null, $this->object->getSpecificAnswerFeedback()); - $this->xml_writer->xmlElement('InstantFeedbackSolution', null, $this->object->getInstantFeedbackSolution()); - - $this->xml_writer->xmlElement('NodeFeedbackAuthor', null, $this->object->getNodeFeedbackAuthor()); - $this->xml_writer->xmlElement('NodeFeedbackParticipant', null, $this->object->getNodeFeedbackParticipant()); - $this->xml_writer->xmlElement('NodeFeedbackParticipantRes', null, $this->object->getNodeFeedbackParticipantRes()); - - // sonstiges - $this->xml_writer->xmlElement('ProcessTime', null, $this->object->getProcessTime()); - - $this->xml_writer->xmlElement('CharSelectorAvailability', null, $this->object->getCharSelectorAvailability()); - $this->xml_writer->xmlElement('CharSelectorDefinition', null, $this->object->getCharSelectorDefinition()); - - // scoring and results - $this->xml_writer->xmlElement('ScoreReporting', null, $this->object->getScoreReporting()); - $this->xml_writer->xmlElement('ReportingDate', null, $this->object->getReportingDate()); - - $this->xml_writer->xmlEndTag('Settings'); - } - - private function exportMarkSchema() - { - foreach($this->object->getMarkSchema()->getMarkSteps() as $index => $mark) - { - // mark steps - $this->xml_writer->xmlStartTag("qtimetadatafield"); - $this->xml_writer->xmlElement("fieldlabel", NULL, "mark_step_$index"); - $this->xml_writer->xmlElement("fieldentry", NULL, sprintf( - "%s%s%.2f%d", - $mark->getShortName(), $mark->getOfficialName(), $mark->getMinimumLevel(), $mark->getPassed() - )); - $this->xml_writer->xmlEndTag("qtimetadatafield"); - } - } - - /** - * - */ - protected function exportQuestionSets() - { - $this->xqsp_object = ilQuestionSetPoolPlugin::getInstance(); - $this->xqsp_object->includeClass('models/class.ilQuestionSetPoolSet.php'); - $this->xqsp_object->includeClass('models/class.ilQuestionSetPoolPath.php'); - $this->xqsp_object->includeClass('models/class.ilQuestionSetPoolNode.php'); - $this->xqsp_object->includeClass('models/class.ilQuestionSetPoolJumpCondition.php'); - - $setlist = $this->object->getSetList(); - $sets = array(); - $sets = $setlist->loadData(); - - $this->xml_writer->xmlStartTag('QuestionSets'); - foreach($sets as $set_index => $set_data) - { - $set = new ilQuestionSetPoolSet((int)$set_data['id']); - $set->read(); - - $this->xml_writer->xmlStartTag('Set'); - $this->xml_writer->xmlElement('SetId', null, (int)$set->getId()); - $this->xml_writer->xmlElement('SetTitle', null, (string)$set->getTitle()); - $this->xml_writer->xmlElement('SetDescription', null, (string)$set->getDescription()); - - $this->xml_writer->xmlElement('OriginalId', null, (int)$set->getOriginalId()); - - // Export QuestionList - $this->exportQuestionList($set->getQuestionList()); - - // Export Paths - $this->exportPathList($set->getPathList()); - - $this->xml_writer->xmlEndTag('Set'); - } - - $this->xml_writer->xmlEndTag('QuestionSets'); - } - - /** - * @param ilQuestionSetPoolSetQuestionList $questionList - */ - protected function exportQuestionList(ilQuestionSetPoolSetQuestionList $questionList) - { - $questions = array(); - $questions = $questionList->loadData(); - $this->xml_writer->xmlStartTag('Questions'); - foreach($questions as $question_index => $question) - { - $this->xml_writer->xmlStartTag('Question'); - $this->xml_writer->xmlElement('QuestionId', null, $question['question_id']); - $this->xml_writer->xmlElement('QuestionIndex', null, $question['question_index']); - $this->xml_writer->xmlElement('QuestionOriginalId', null, $question['original_id']); - $this->xml_writer->xmlEndTag('Question'); - $this->questions[$question['question_id']] = $question['question_id']; - } - $this->xml_writer->xmlEndTag('Questions'); - if(is_array($this->questions) && count($this->questions) > 0) - { - $this->exportQuestions(); - } - } - - /** - * @param ilQuestionSetPoolPathList $pathlist - */ - protected function exportPathList(ilQuestionSetPoolPathList $pathList) - { - $paths = array(); - $paths = $pathList->loadData(); - - $this->xml_writer->xmlStartTag('Paths'); - foreach($paths as $path_index => $path_data) - { - $path = new ilQuestionSetPoolPath(); - $path->setId($path_data['id']); - $path->read(); - $this->xml_writer->xmlStartTag('Path'); - $this->xml_writer->xmlElement('PathId', null, (int)$path->getId()); - $this->xml_writer->xmlElement('PathTitle', null, (string)$path->getTitle()); - $this->xml_writer->xmlElement('PathQuestionSetId', null, (int)$path_data['questionset_fi']); - $this->xml_writer->xmlElement('PathIndex', null, $path->getIndex()); - - // Nodes - $this->exportNodeList($path->getNodes()); - - $this->xml_writer->xmlEndTag('Path'); - } - $this->xml_writer->xmlEndTag('Paths'); - } - - /** - * @param ilQuestionSetPoolNodeList $nodelist - */ - protected function exportNodeList(ilQuestionSetPoolNodeList $nodeList) - { - $nodes = array(); - $nodes = $nodeList->loadData(); - - $this->xml_writer->xmlStartTag('Nodes'); - foreach($nodes as $node_index => $node_data) - { - $node = new ilQuestionSetPoolNode((int)$node_data['id']); - $node->read(); - $this->xml_writer->xmlStartTag('Node'); - - $this->xml_writer->xmlElement('NodeId', null, (int)$node->getId()); - $this->xml_writer->xmlElement('NodeQuestionId', null, (int)$node_data['question_fi']); - $this->xml_writer->xmlElement('NodePathId', null, (int)$node_data['path_fi']); - $this->xml_writer->xmlElement('NodeIndex', null, (int)$node->getIndex()); - - $this->xml_writer->xmlElement('NodeInitialCondition', null, $node->getInitialCondition()); - $this->xml_writer->xmlElement('NodeDominantScoring', null, $node->getDominantScoring()); - - $this->xml_writer->xmlElement('NodeTrueFeedback', null, $node->getTrueFeedback()); - $this->xml_writer->xmlElement('NodeFalseFeedback', null, $node->getFalseFeedback()); - - // Jump Conditions - $this->exportJumpConditions($node->getJumpConditionList()); - - $this->xml_writer->xmlEndTag('Node'); - } - $this->xml_writer->xmlEndTag('Nodes'); - } - - /** - * @param ilQuestionSetPoolJumpConditionList $jumpConditionList - */ - protected function exportJumpConditions(ilQuestionSetPoolJumpConditionList $jumpConditionList) - { - $jumpConditions = array(); - $jumpConditions = $jumpConditionList->getData(); - - $this->xml_writer->xmlStartTag('JumpConditions'); - - foreach($jumpConditions as $jmp_con_index => $jumpCondition_data) - { - $jumpCondition = new ilQuestionSetPoolJumpCondition(); - $jumpCondition->setId($jumpCondition_data['id']); - $jumpCondition->read(); - - $this->xml_writer->xmlStartTag('JumpCondition'); - $this->xml_writer->xmlElement('JumpConditionId', null, (int)$jumpCondition->getId()); - $this->xml_writer->xmlElement('JumpConditionText', null, (string)$jumpCondition->getJumpCondition()); - - $this->xml_writer->xmlElement('JumpConditionNodeId', null, (int)$jumpCondition_data['node_fi']); - $this->xml_writer->xmlElement('JumpConditionQuestionId', null, $jumpCondition_data['question_fi']); - - $this->xml_writer->xmlElement('JumpConditionRepetitions', null, $jumpCondition->getRepititions()); - $this->xml_writer->xmlElement('JumpConditionSorting', null, $jumpCondition->getSorting()); - $this->xml_writer->xmlElement('JumpConditionTrueFeedback', null, $jumpCondition->getTrueFeedback()); - $this->xml_writer->xmlElement('JumpConditionTrueJumpFeedback', null, $jumpCondition->getTrueJumpFeedback()); - $this->xml_writer->xmlElement('JumpConditionFalseFeedback', null, $jumpCondition->getFalseFeedback()); - - $this->xml_writer->xmlEndTag('JumpCondition'); - } - - $this->xml_writer->xmlEndTag('JumpConditions'); - } - - /** - * Default ilias questionpool export - */ - protected function exportQuestions() - { - // write qti file - ilUtil::makeDirParents($this->export_dir); - $qti_file = fopen($this->export_dir . "/" . $this->qti_filename, "w"); - fwrite($qti_file, $this->qpl_obj->questionsToXML($this->questions)); - fclose($qti_file); - } - - /** - * @param $a_export_dir - */ - function exportXHTMLMediaObjects($a_export_dir) - { - include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php"); - ilUtil::makeDirParents($a_export_dir . "/objects/"); - - foreach($this->questions as $question_id) - { - $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id); - foreach($mobs as $mob) - { - if(ilObjMediaObject::_exists($mob)) - { - $mob_obj = new ilObjMediaObject($mob); - $mob_obj->exportFiles($a_export_dir); - unset($mob_obj); - } - } - } - } - - /** - * @param $a_entity - * @param $a_schema_version - * @param $a_id - * @return string - */ - public function getXmlRepresentation($a_entity, $a_schema_version, $a_id) - { - $ref_id = current(ilObject::_getAllReferences($a_id)); - - $date = time(); - $this->export_dir = $this->getAbsoluteExportDirectory(); - $this->subdir = $date . "__" . IL_INST_ID . "__" . "xtsf" . "_" . $a_id; - $this->filename = $this->subdir . ".xml"; - $this->qti_filename = "xtsf_qti.xml"; - - $this->plugin_object->includeClass('class.ilObjFormATest.php'); - - $this->object = new ilObjFormATest($ref_id); - $this->xml_writer = new ilXmlWriter(); - - $this->qpl_obj = new ilObjQuestionPool(); - // get Log File - ilUtil::makeDirParents($this->getExportDirectory()); - $this->initLogFile(); - $this->exportPagesXML(); - - return $this->xml_writer->xmlDumpMem(); - } - - /** - * @param $a_entity - * @return array - */ - public function getValidSchemaVersions($a_entity) - { - return array( - '5.1.0' => array( - 'namespace' => 'http://www.ilias.de/', - 'xsd_file' => 'xtsf_5_1.xsd', - 'uses_dataset' => false, - 'min' => '5.1.0', - 'max' => '5.1.999' - ) - ); - } - - /** - * @param $a_entity - * @param $a_target_release - * @param array $a_ids - * @return array - */ - public function getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids) - { - return parent::getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids); - } + /** + * @var ilXmlWriter + */ + protected $xml_writer = null; + + /** + * @var string + */ + protected $export_dir = ''; + + /** + * @var string + */ + protected $subdir = ''; + + /** + * @var string + */ + protected $filename = ''; + + /** + * @var string + */ + protected $qti_filename = ''; + + /** + * @var string + */ + protected $zipfilename = ''; + + /** + * @var array with question ids to export + */ + protected $questions = array(); + + /** + * @var ilLog + */ + protected $expLog = null; + + /** + * Initialisation + */ + public function init() + { + } + + /** + * ilFormATestExporter constructor. + */ + public function __construct() + { + $this->plugin_object = ilPlugin::getPluginObject('Services', 'Repository', 'robj', 'FormATest'); + } + + /** + * + */ + public function initLogFile() + { + $this->expLog = new ilLog($this->getExportDirectory(), "export.log"); + $this->expLog->delete(); + $this->expLog->setLogFormat(""); + $this->expLog->write(date("[y-m-d H:i:s] ") . "Start Export"); + } + + /** + * get export directory of questionsetpool + * @param string $type + * @return string + */ + public function getExportDirectory($type = "") + { + switch ($type) { + case 'xml': + $export_dir = ilExport::_getExportDirectory($this->object->getId(), $type, $this->object->getType()); + break; + // case 'xls': + case 'zip': + $export_dir = ilUtil::getDataDir() . "/xtsf_data" . "/xtsf_" . $this->object->getId() . "/export_$type"; + break; + + default: + $export_dir = ilUtil::getDataDir() . "/xtsf_data" . "/xtsf_" . $this->object->getId() . "/export"; + break; + } + return $export_dir; + } + + /** + * + */ + public function exportPagesXML() + { + global $DIC; + $ilBench = $DIC['ilBench']; + + $this->mob_ids = array(); + $this->file_ids = array(); + + $attrs = array(); + $attrs["Type"] = "Test_FormATest"; + $this->xml_writer->xmlStartTag("ContentObject", $attrs); + + // MetaData + $this->exportXMLMetaData(); + + // Settings + $this->exportXMLSettings(); + + $this->exportMarkSchema(); + + // Question Sets + $this->exportQuestionSets(); + + // PageObjects + $this->expLog->write(date("[y-m-d H:i:s] ") . "Start Export Page Objects"); + $ilBench->start("ContentObjectExport", "exportPageObjects"); + $this->qpl_obj->exportXMLPageObjects($this->xml_writer, IL_INST_ID, $this->expLog, $this->questions); + $ilBench->stop("ContentObjectExport", "exportPageObjects"); + $this->expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Page Objects"); + + // add media objects which were added with tiny mce + $this->expLog->write(date("[y-m-d H:i:s] ") . "Start Export Media Objects"); + $export_dir = $this->exp->export_run_dir; + $ilBench->start("ContentObjectExport", "exportMediaObjects"); + + $this->exportXHTMLMediaObjects($export_dir); + $ilBench->stop("ContentObjectExport", "exportMediaObjects"); + $this->expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Media Objects"); + + if (is_array($this->qpl_obj->file_ids) && count($this->qpl_obj->file_ids) > 0) { + // FileItems + $this->expLog->write(date("[y-m-d H:i:s] ") . "Start Export File Items"); + $ilBench->start("ContentObjectExport", "exportFileItems"); + $this->exportFileItems($this->export_dir . "/" . $this->subdir, $this->expLog); + $ilBench->stop("ContentObjectExport", "exportFileItems"); + $this->expLog->write(date("[y-m-d H:i:s] ") . "Finished Export File Items"); + } + $this->xml_writer->xmlEndTag("ContentObject"); + } + + /** + * export content objects meta data to xml (see ilias_co.dtd) + */ + public function exportXMLMetaData() + { + $md2xml = new ilMD2XML($this->object->getId(), 0, $this->object->getType()); + $md2xml->setExportMode(true); + $md2xml->startExport(); + $this->xml_writer->appendXML($md2xml->getXML()); + } + + /** + * + */ + private function exportXMLSettings() + { + $this->xml_writer->xmlStartTag('Settings'); + + // general + $this->xml_writer->xmlElement('Title', null, (string) $this->object->getTitle()); + $this->xml_writer->xmlElement('Description', null, (string) $this->object->getDescription()); + + // Availability + $this->xml_writer->xmlElement('Online', null, (int) $this->object->isOnline()); + + // Information at Beginning and End of Test + $this->xml_writer->xmlElement('ShowIntroStatement', null, (int) $this->object->getShowIntroStatement()); + $this->xml_writer->xmlElement('IntroStatement', null, (string) $this->object->getIntroStatement()); + $this->xml_writer->xmlElement('ShowFinalStatement', null, (int) $this->object->getShowFinalStatement()); + $this->xml_writer->xmlElement('FinalStatement', null, (string) $this->object->getFinalStatement()); + + // Session Settings + $this->xml_writer->xmlElement('MaxPasses', null, (int) $this->object->getMaxPasses()); + $this->xml_writer->xmlElement('StartTime', null, $this->object->getStartTime()); + $this->xml_writer->xmlElement('EndTime', null, $this->object->getEndTime()); + $this->xml_writer->xmlElement('StartTimeEnabled', null, (int) $this->object->isStartTimeEnabled()); + $this->xml_writer->xmlElement('EndTimeEnabled', null, (int) $this->object->isEndTimeEnabled()); + $this->xml_writer->xmlElement('AllowWalkBack', null, $this->object->isAllowWalkBack()); + $this->xml_writer->xmlElement('ShowCurrentTrack', null, $this->object->getShowCurrentTrack()); + $this->xml_writer->xmlElement('ShowQuestionsOverview', null, $this->object->getShowQuestionsOverview()); + $this->xml_writer->xmlElement('AllowInterruption', null, $this->object->isAllowInterruption()); + $this->xml_writer->xmlElement('SkillServiceEnabled', null, (int) $this->object->isSkillServiceEnabled()); + + // Behavior of the Question + $this->xml_writer->xmlElement('AnswerFeedbackPoints', null, $this->object->getAnswerFeedbackPoints()); + $this->xml_writer->xmlElement('GenericAnswerFeedback', null, $this->object->getGenericAnswerFeedback()); + $this->xml_writer->xmlElement('SpecificAnswerFeedback', null, $this->object->getSpecificAnswerFeedback()); + $this->xml_writer->xmlElement('InstantFeedbackSolution', null, $this->object->getInstantFeedbackSolution()); + + $this->xml_writer->xmlElement('NodeFeedbackAuthor', null, $this->object->getNodeFeedbackAuthor()); + $this->xml_writer->xmlElement('NodeFeedbackParticipant', null, $this->object->getNodeFeedbackParticipant()); + $this->xml_writer->xmlElement('NodeFeedbackParticipantRes', null, $this->object->getNodeFeedbackParticipantRes()); + + // sonstiges + $this->xml_writer->xmlElement('ProcessTime', null, $this->object->getProcessTime()); + + $this->xml_writer->xmlElement('CharSelectorAvailability', null, $this->object->getCharSelectorAvailability()); + $this->xml_writer->xmlElement('CharSelectorDefinition', null, $this->object->getCharSelectorDefinition()); + + // scoring and results + $this->xml_writer->xmlElement('ScoreReporting', null, $this->object->getScoreReporting()); + $this->xml_writer->xmlElement('ReportingDate', null, $this->object->getReportingDate()); + + $this->xml_writer->xmlEndTag('Settings'); + } + + private function exportMarkSchema() + { + foreach ($this->object->getMarkSchema()->getMarkSteps() as $index => $mark) { + // mark steps + $this->xml_writer->xmlStartTag("qtimetadatafield"); + $this->xml_writer->xmlElement("fieldlabel", null, "mark_step_$index"); + $this->xml_writer->xmlElement("fieldentry", null, sprintf( + "%s%s%.2f%d", + $mark->getShortName(), + $mark->getOfficialName(), + $mark->getMinimumLevel(), + $mark->getPassed() + )); + $this->xml_writer->xmlEndTag("qtimetadatafield"); + } + } + + /** + * + */ + protected function exportQuestionSets() + { + $this->xqsp_object = ilQuestionSetPoolPlugin::getInstance(); + $this->xqsp_object->includeClass('models/class.ilQuestionSetPoolSet.php'); + $this->xqsp_object->includeClass('models/class.ilQuestionSetPoolPath.php'); + $this->xqsp_object->includeClass('models/class.ilQuestionSetPoolNode.php'); + $this->xqsp_object->includeClass('models/class.ilQuestionSetPoolJumpCondition.php'); + + $setlist = $this->object->getSetList(); + $sets = array(); + $sets = $setlist->loadData(); + + $this->xml_writer->xmlStartTag('QuestionSets'); + foreach ($sets as $set_index => $set_data) { + $set = new ilQuestionSetPoolSet((int) $set_data['id']); + $set->read(); + + $this->xml_writer->xmlStartTag('Set'); + $this->xml_writer->xmlElement('SetId', null, (int) $set->getId()); + $this->xml_writer->xmlElement('SetTitle', null, (string) $set->getTitle()); + $this->xml_writer->xmlElement('SetDescription', null, (string) $set->getDescription()); + + $this->xml_writer->xmlElement('OriginalId', null, (int) $set->getOriginalId()); + + // Export QuestionList + $this->exportQuestionList($set->getQuestionList()); + + // Export Paths + $this->exportPathList($set->getPathList()); + + $this->xml_writer->xmlEndTag('Set'); + } + + $this->xml_writer->xmlEndTag('QuestionSets'); + } + + /** + * @param ilQuestionSetPoolSetQuestionList $questionList + */ + protected function exportQuestionList(ilQuestionSetPoolSetQuestionList $questionList) + { + $questions = array(); + $questions = $questionList->loadData(); + $this->xml_writer->xmlStartTag('Questions'); + foreach ($questions as $question_index => $question) { + $this->xml_writer->xmlStartTag('Question'); + $this->xml_writer->xmlElement('QuestionId', null, $question['question_id']); + $this->xml_writer->xmlElement('QuestionIndex', null, $question['question_index']); + $this->xml_writer->xmlElement('QuestionOriginalId', null, $question['original_id']); + $this->xml_writer->xmlEndTag('Question'); + $this->questions[$question['question_id']] = $question['question_id']; + } + $this->xml_writer->xmlEndTag('Questions'); + if (is_array($this->questions) && count($this->questions) > 0) { + $this->exportQuestions(); + } + } + + /** + * @param ilQuestionSetPoolPathList $pathlist + */ + protected function exportPathList(ilQuestionSetPoolPathList $pathList) + { + $paths = array(); + $paths = $pathList->loadData(); + + $this->xml_writer->xmlStartTag('Paths'); + foreach ($paths as $path_index => $path_data) { + $path = new ilQuestionSetPoolPath(); + $path->setId($path_data['id']); + $path->read(); + $this->xml_writer->xmlStartTag('Path'); + $this->xml_writer->xmlElement('PathId', null, (int) $path->getId()); + $this->xml_writer->xmlElement('PathTitle', null, (string) $path->getTitle()); + $this->xml_writer->xmlElement('PathQuestionSetId', null, (int) $path_data['questionset_fi']); + $this->xml_writer->xmlElement('PathIndex', null, $path->getIndex()); + + // Nodes + $this->exportNodeList($path->getNodes()); + + $this->xml_writer->xmlEndTag('Path'); + } + $this->xml_writer->xmlEndTag('Paths'); + } + + /** + * @param ilQuestionSetPoolNodeList $nodelist + */ + protected function exportNodeList(ilQuestionSetPoolNodeList $nodeList) + { + $nodes = array(); + $nodes = $nodeList->loadData(); + + $this->xml_writer->xmlStartTag('Nodes'); + foreach ($nodes as $node_index => $node_data) { + $node = new ilQuestionSetPoolNode((int) $node_data['id']); + $node->read(); + $this->xml_writer->xmlStartTag('Node'); + + $this->xml_writer->xmlElement('NodeId', null, (int) $node->getId()); + $this->xml_writer->xmlElement('NodeQuestionId', null, (int) $node_data['question_fi']); + $this->xml_writer->xmlElement('NodePathId', null, (int) $node_data['path_fi']); + $this->xml_writer->xmlElement('NodeIndex', null, (int) $node->getIndex()); + + $this->xml_writer->xmlElement('NodeInitialCondition', null, $node->getInitialCondition()); + $this->xml_writer->xmlElement('NodeDominantScoring', null, $node->getDominantScoring()); + + $this->xml_writer->xmlElement('NodeTrueFeedback', null, $node->getTrueFeedback()); + $this->xml_writer->xmlElement('NodeFalseFeedback', null, $node->getFalseFeedback()); + + // Jump Conditions + $this->exportJumpConditions($node->getJumpConditionList()); + + $this->xml_writer->xmlEndTag('Node'); + } + $this->xml_writer->xmlEndTag('Nodes'); + } + + /** + * @param ilQuestionSetPoolJumpConditionList $jumpConditionList + */ + protected function exportJumpConditions(ilQuestionSetPoolJumpConditionList $jumpConditionList) + { + $jumpConditions = array(); + $jumpConditions = $jumpConditionList->getData(); + + $this->xml_writer->xmlStartTag('JumpConditions'); + + foreach ($jumpConditions as $jmp_con_index => $jumpCondition_data) { + $jumpCondition = new ilQuestionSetPoolJumpCondition(); + $jumpCondition->setId($jumpCondition_data['id']); + $jumpCondition->read(); + + $this->xml_writer->xmlStartTag('JumpCondition'); + $this->xml_writer->xmlElement('JumpConditionId', null, (int) $jumpCondition->getId()); + $this->xml_writer->xmlElement('JumpConditionText', null, (string) $jumpCondition->getJumpCondition()); + + $this->xml_writer->xmlElement('JumpConditionNodeId', null, (int) $jumpCondition_data['node_fi']); + $this->xml_writer->xmlElement('JumpConditionQuestionId', null, $jumpCondition_data['question_fi']); + + $this->xml_writer->xmlElement('JumpConditionRepetitions', null, $jumpCondition->getRepititions()); + $this->xml_writer->xmlElement('JumpConditionSorting', null, $jumpCondition->getSorting()); + $this->xml_writer->xmlElement('JumpConditionTrueFeedback', null, $jumpCondition->getTrueFeedback()); + $this->xml_writer->xmlElement('JumpConditionTrueJumpFeedback', null, $jumpCondition->getTrueJumpFeedback()); + $this->xml_writer->xmlElement('JumpConditionFalseFeedback', null, $jumpCondition->getFalseFeedback()); + + $this->xml_writer->xmlEndTag('JumpCondition'); + } + + $this->xml_writer->xmlEndTag('JumpConditions'); + } + + /** + * Default ilias questionpool export + */ + protected function exportQuestions() + { + // write qti file + ilUtil::makeDirParents($this->export_dir); + $qti_file = fopen($this->export_dir . "/" . $this->qti_filename, "w"); + fwrite($qti_file, $this->qpl_obj->questionsToXML($this->questions)); + fclose($qti_file); + } + + /** + * @param $a_export_dir + */ + public function exportXHTMLMediaObjects($a_export_dir) + { + ilUtil::makeDirParents($a_export_dir . "/objects/"); + + foreach ($this->questions as $question_id) { + $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id); + foreach ($mobs as $mob) { + if (ilObjMediaObject::_exists($mob)) { + $mob_obj = new ilObjMediaObject($mob); + $mob_obj->exportFiles($a_export_dir); + unset($mob_obj); + } + } + } + } + + /** + * @param $a_entity + * @param $a_schema_version + * @param $a_id + * @return string + */ + public function getXmlRepresentation($a_entity, $a_schema_version, $a_id) + { + $ref_id = current(ilObject::_getAllReferences($a_id)); + + $date = time(); + $this->export_dir = $this->getAbsoluteExportDirectory(); + $this->subdir = $date . "__" . IL_INST_ID . "__" . "xtsf" . "_" . $a_id; + $this->filename = $this->subdir . ".xml"; + $this->qti_filename = "xtsf_qti.xml"; + + $this->plugin_object->includeClass('class.ilObjFormATest.php'); + + $this->object = new ilObjFormATest($ref_id); + $this->xml_writer = new ilXmlWriter(); + + $this->qpl_obj = new ilObjQuestionPool(); + // get Log File + ilUtil::makeDirParents($this->getExportDirectory()); + $this->initLogFile(); + $this->exportPagesXML(); + + return $this->xml_writer->xmlDumpMem(); + } + + /** + * @param $a_entity + * @return array + */ + public function getValidSchemaVersions($a_entity) + { + return array( + '5.1.0' => array( + 'namespace' => 'http://www.ilias.de/', + 'xsd_file' => 'xtsf_5_1.xsd', + 'uses_dataset' => false, + 'min' => '5.1.0', + 'max' => '5.1.999' + ) + ); + } + + /** + * @param $a_entity + * @param $a_target_release + * @param array $a_ids + * @return array + */ + public function getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids) + { + return parent::getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids); + } } diff --git a/classes/class.ilFormATestImporter.php b/classes/class.ilFormATestImporter.php index 4f85b953e4fddb1752269864feb66db0f8b90c67..e263f7620861cd5b4e09e97b5a13fef1879256d7 100644 --- a/classes/class.ilFormATestImporter.php +++ b/classes/class.ilFormATestImporter.php @@ -1,8 +1,6 @@ xml_file = $xml_file; - } - - public function getXmlFile() - { - return $this->xml_file; - } - - /** - * @param $qti_file - */ - public function setQtiFile($qti_file) - { - $this->qti_file = $qti_file; - } - - public function getQtiFile() - { - return $this->qti_file; - } - - /** - * ilQuestionSetPoolImporter constructor. - */ - public function __construct() - { - $this->plugin_object = ilFormATestPlugin::getInstance(); - - $this->xqsp_plugin_object = ilQuestionSetPoolPlugin::getInstance(); - $this->xqsp_plugin_object->includeClass('models/class.ilQuestionSetPoolSet.php'); - $this->xqsp_plugin_object->includeClass('models/class.ilQuestionSetPoolPath.php'); - $this->xqsp_plugin_object->includeClass('models/class.ilQuestionSetPoolNode.php'); - $this->xqsp_plugin_object->includeClass('models/class.ilQuestionSetPoolJumpCondition.php'); - $this->xqsp_plugin_object->includeClass('class.ilQuestionSetPoolImporter.php'); - } - - public function init() - { - $qti_path = $this->getImportDirectory().'/Plugins/xtsf/set_1/expDir_1'; - $qti_file = $qti_path.'/xtsf_qti.xml'; - $xml_file = $this->getImportDirectory().'/Plugins/xtsf/set_1/export.xml'; - - $this->validateXmlFile($xml_file); - $this->setQtiFile($qti_file); - } - - /** - * @param $xml_file - */ - public function validateXmlFile($xml_file) - { - $this->plugin_object->includeClass('class.ilFormATestXmlValidator.php'); - $validator = new ilFormATestXmlValidator(); - $validator->setXsdFile('/xml/xtsf_5_1.xsd'); - $validator->setXmlFile($xml_file); - $validator->validate(); - $this->setXmlFile($xml_file); - return true; - } - - /** - * - */ - public function createImportDirectory() - { - global $DIC; - $ilErr = $DIC['ilErr']; - - include_once "./Services/Utilities/classes/class.ilUtil.php"; - - $xtsf_data_dir = ilUtil::getDataDir()."/xtsf_data"; - ilUtil::makeDir($xtsf_data_dir); - if(!is_writable($xtsf_data_dir)) - { - $ilErr->raiseError("QuestionSetPool Data Directory (".$xtsf_data_dir.") not writeable.", $ilErr->error_obj->FATAL); - } - - // create QuestionSetPool directory (data_dir/xtsf_data/xtsf_import) - $import_dir = $xtsf_data_dir."/xtsf_import"; - ilUtil::makeDir($import_dir); - if(!@is_dir($import_dir)) - { - $ilErr->raiseError("Creation of QuestionSetPool import directory failed.", $ilErr->error_obj->FATAL); - } - - $this->setImportDirectory($import_dir); - } - - public function initializeQplObject($obj_id) - { - if($obj_id <= 0) - { - $this->qpl_obj = $this->createQplObject(); - } - else - { - $this->qpl_obj = new ilObjQuestionPool($obj_id, false); - $this->qpl_obj->read(true); - } - } - - /** - * @param $obj_id - */ - public function initializeXqspObject($obj_id) - { - if($obj_id <= 0) - { - $this->xqsp_obj = $this->createXqspObject(); - } - else - { - $ref_ids = ilObject::_getAllReferences($obj_id); - $this->xqsp_obj = new ilObjQuestionSetPool(current($ref_ids)); - $this->xqsp_obj->read(true); - } - } - - /** - * Creates a new questionpool object - * - * copied from ilObjQuestionPoolGUI->importVerifiedFileObject() - */ - public function createQplObject() - { - // create new questionpool object - $qpl_obj = new ilObjQuestionPool(0, true); - // set type of questionpool object - $qpl_obj->setType('qpl'); - // set title of questionpool object to "dummy" - $qpl_obj->setTitle("dummy"); - // set description of questionpool object - $qpl_obj->setDescription("questionpool creation"); - // set online - $qpl_obj->setOnline(true); - // create the questionpool class in the ILIAS database (object_data table) - $qpl_obj->create(true); - - $qpl_obj->update(); - $qpl_obj->saveToDb(); - return $qpl_obj; - } - - /** - * @return ilObjQuestionSetPool - */ - public function createXqspObject() - { - // create new questionsetpool object - $xqsp_obj = new ilObjQuestionSetPool(); - // set type of questionsetpool object - $xqsp_obj->setType('xqsp'); - // set title of questionsetpool object to "dummy" - $xqsp_obj->setTitle("dummy"); - // set description of questionsetpool object - $xqsp_obj->setDescription("questionsetpool creation"); - // set online - $xqsp_obj->setOnline(true); - // create the questionsetpool class in the ILIAS database (object_data table) - $xqsp_obj->create(true); - - $xqsp_obj->update(); - return $xqsp_obj; - } - - - /** - * Import questions to QPL questionpool - */ - protected function parseQtiFile() - { - include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php"; - $tmp_dir = ilObjQuestionPool::_getImportDirectory(); - ilObjQuestionPool::_setImportDirectory($this->getImportDirectoryBase()); + protected $is_single_import = true; + + protected $import_into_xqsp = false; + protected $import_into_qpl = false; + + /** + * @var int[] + */ + protected static $pool_by_parent_id = array(); + + protected $current_parent_ref_id = 0; + + /** + * @var null + */ + protected $xml_file = null; + /** + * @var null + */ + protected $qti_file = null; + + /** + * @var array + */ + protected $fat_qst_mapping = array(); + + protected $xqsp_qst_mapping = array(); + + /** + * @param $xml_file + */ + private function setXmlFile($xml_file) + { + $this->xml_file = $xml_file; + } + + public function getXmlFile() + { + return $this->xml_file; + } + + /** + * @param $qti_file + */ + public function setQtiFile($qti_file) + { + $this->qti_file = $qti_file; + } + + public function getQtiFile() + { + return $this->qti_file; + } + + /** + * ilQuestionSetPoolImporter constructor. + */ + public function __construct() + { + $this->plugin_object = ilFormATestPlugin::getInstance(); + + $this->xqsp_plugin_object = ilQuestionSetPoolPlugin::getInstance(); + $this->xqsp_plugin_object->includeClass('models/class.ilQuestionSetPoolSet.php'); + $this->xqsp_plugin_object->includeClass('models/class.ilQuestionSetPoolPath.php'); + $this->xqsp_plugin_object->includeClass('models/class.ilQuestionSetPoolNode.php'); + $this->xqsp_plugin_object->includeClass('models/class.ilQuestionSetPoolJumpCondition.php'); + $this->xqsp_plugin_object->includeClass('class.ilQuestionSetPoolImporter.php'); + } + + public function init() + { + $qti_path = $this->getImportDirectory() . '/Plugins/xtsf/set_1/expDir_1'; + $qti_file = $qti_path . '/xtsf_qti.xml'; + $xml_file = $this->getImportDirectory() . '/Plugins/xtsf/set_1/export.xml'; + + $this->validateXmlFile($xml_file); + $this->setQtiFile($qti_file); + } + + /** + * @param $xml_file + */ + public function validateXmlFile($xml_file) + { + $this->plugin_object->includeClass('class.ilFormATestXmlValidator.php'); + $validator = new ilFormATestXmlValidator(); + $validator->setXsdFile('/xml/xtsf_5_1.xsd'); + $validator->setXmlFile($xml_file); + $validator->validate(); + $this->setXmlFile($xml_file); + return true; + } + + /** + * + */ + public function createImportDirectory() + { + global $DIC; + $ilErr = $DIC['ilErr']; + + $xtsf_data_dir = ilUtil::getDataDir() . "/xtsf_data"; + ilUtil::makeDir($xtsf_data_dir); + if (!is_writable($xtsf_data_dir)) { + $ilErr->raiseError("QuestionSetPool Data Directory (" . $xtsf_data_dir . ") not writeable.", $ilErr->error_obj->FATAL); + } + + // create QuestionSetPool directory (data_dir/xtsf_data/xtsf_import) + $import_dir = $xtsf_data_dir . "/xtsf_import"; + ilUtil::makeDir($import_dir); + if (!@is_dir($import_dir)) { + $ilErr->raiseError("Creation of QuestionSetPool import directory failed.", $ilErr->error_obj->FATAL); + } + + $this->setImportDirectory($import_dir); + } + + public function initializeQplObject($obj_id) + { + if ($obj_id <= 0) { + $this->qpl_obj = $this->createQplObject(); + } else { + $this->qpl_obj = new ilObjQuestionPool($obj_id, false); + $this->qpl_obj->read(true); + } + } + + /** + * @param $obj_id + */ + public function initializeXqspObject($obj_id) + { + if ($obj_id <= 0) { + $this->xqsp_obj = $this->createXqspObject(); + } else { + $ref_ids = ilObject::_getAllReferences($obj_id); + $this->xqsp_obj = new ilObjQuestionSetPool(current($ref_ids)); + $this->xqsp_obj->read(true); + } + } + + /** + * Creates a new questionpool object + * + * copied from ilObjQuestionPoolGUI->importVerifiedFileObject() + */ + public function createQplObject() + { + // create new questionpool object + $qpl_obj = new ilObjQuestionPool(0, true); + // set type of questionpool object + $qpl_obj->setType('qpl'); + // set title of questionpool object to "dummy" + $qpl_obj->setTitle("dummy"); + // set description of questionpool object + $qpl_obj->setDescription("questionpool creation"); + // set online + $qpl_obj->setOnline(true); + // create the questionpool class in the ILIAS database (object_data table) + $qpl_obj->create(true); + + $qpl_obj->update(); + $qpl_obj->saveToDb(); + return $qpl_obj; + } + + /** + * @return ilObjQuestionSetPool + */ + public function createXqspObject() + { + // create new questionsetpool object + $xqsp_obj = new ilObjQuestionSetPool(); + // set type of questionsetpool object + $xqsp_obj->setType('xqsp'); + // set title of questionsetpool object to "dummy" + $xqsp_obj->setTitle("dummy"); + // set description of questionsetpool object + $xqsp_obj->setDescription("questionsetpool creation"); + // set online + $xqsp_obj->setOnline(true); + // create the questionsetpool class in the ILIAS database (object_data table) + $xqsp_obj->create(true); + + $xqsp_obj->update(); + return $xqsp_obj; + } + + + /** + * Import questions to QPL questionpool + */ + protected function parseQtiFile() + { + $tmp_dir = ilObjQuestionPool::_getImportDirectory(); + ilObjQuestionPool::_setImportDirectory($this->getImportDirectoryBase()); - $tmp_subdir = $_SESSION["qpl_import_subdir"]; - $_SESSION["qpl_import_subdir"] = basename($this->getImportDirectory()); + $tmp_subdir = $_SESSION["qpl_import_subdir"]; + $_SESSION["qpl_import_subdir"] = basename($this->getImportDirectory()); - // start parsing of QTI files - include_once "./Services/QTI/classes/class.ilQTIParser.php"; - $qtiParser = new ilQTIParser($this->getQtiFile(), IL_MO_PARSE_QTI, $this->xtsf_obj->getId()); - $result = $qtiParser->startParsing(); - $this->addQuestionMapping($qtiParser->getImportMapping()); + // start parsing of QTI files + $qtiParser = new ilQTIParser($this->getQtiFile(), IL_MO_PARSE_QTI, $this->xtsf_obj->getId()); + $result = $qtiParser->startParsing(); + $this->addQuestionMapping($qtiParser->getImportMapping()); - ilObjQuestionPool::_setImportDirectory($tmp_dir); - $_SESSION["qpl_import_subdir"] = $tmp_subdir; - } - - protected function addQuestionMapping($qtiParser_import_mapping) - { - foreach($qtiParser_import_mapping as $question_ident => $pool_qst_ident) - { - $exp_ident = explode('_qst_', $question_ident); - $old_qst_id = end($exp_ident); - $new_qst_id = $pool_qst_ident['pool']; - $this->fat_qst_mapping[$old_qst_id] = $new_qst_id; - } - } + ilObjQuestionPool::_setImportDirectory($tmp_dir); + $_SESSION["qpl_import_subdir"] = $tmp_subdir; + } + + protected function addQuestionMapping($qtiParser_import_mapping) + { + foreach ($qtiParser_import_mapping as $question_ident => $pool_qst_ident) { + $exp_ident = explode('_qst_', $question_ident); + $old_qst_id = end($exp_ident); + $new_qst_id = $pool_qst_ident['pool']; + $this->fat_qst_mapping[$old_qst_id] = $new_qst_id; + } + } - /** - * @param $set_data - * @param $set_questions - * @param $set_paths - * @param $a_mapping - * @param $container_id FormATest | QuestionSetPool - */ - public function importQuestionSet($set_data, $set_questions, $set_paths, $a_mapping, $container_id) - { - $container_obj_type = ilObject::_lookupType($container_id); - - $set = new ilQuestionSetPoolSet(); - $set->setContainerObjId($container_id); - $set->setTitle($set_data['SetTitle']); - $set->setDescription($set_data['SetDescription']); - $set->setOriginalId($set_data['OriginalSetId']); - $set->update(); + /** + * @param $set_data + * @param $set_questions + * @param $set_paths + * @param $a_mapping + * @param $container_id FormATest | QuestionSetPool + */ + public function importQuestionSet($set_data, $set_questions, $set_paths, $a_mapping, $container_id) + { + $container_obj_type = ilObject::_lookupType($container_id); + + $set = new ilQuestionSetPoolSet(); + $set->setContainerObjId($container_id); + $set->setTitle($set_data['SetTitle']); + $set->setDescription($set_data['SetDescription']); + $set->setOriginalId($set_data['OriginalSetId']); + $set->update(); - $this->addSetMapping($set_data['SetId'], $set->getId()); + $this->addSetMapping($set_data['SetId'], $set->getId()); - foreach($set_questions as $set_question) - { - if($container_obj_type == 'xqsp') - { - $original_question_id = $a_mapping->getMapping('Modules/TestQuestionPool', 'quest', $set_question['QuestionOriginalId']); - - if($original_question_id) - { - if(!assQuestion::_questionExistsInPool($original_question_id) ) - { - $original_question_id = NULL; - } - } - - $copy_id = $set->getQuestionList()->import($this->fat_qst_mapping[$set_question['QuestionId']], $original_question_id); - if($original_question_id == 0 || $this->is_single_import ) - { - $this->fat_qst_mapping['new_fat'][$set_question['QuestionId']] = $copy_id; - if($set_question['QuestionOriginalId']) - { - $a_mapping->addMapping('Plugins/xtsf', 'org_qst_id', $set_question['QuestionOriginalId'], $copy_id); - } - } - else - { - $this->fat_qst_mapping['new_fat'][$set_question['QuestionId']] = $original_question_id; - } - } - else if($container_obj_type == 'xtsf') - { - $original_question_id = $a_mapping->getMapping('Plugins/xtsf', 'org_qst_id', $set_question['QuestionOriginalId']); - $copy_id = $set->getQuestionList()->import($this->fat_qst_mapping[$set_question['QuestionId']], $original_question_id); - - if($original_question_id == 0 || $this->is_single_import ) - { - $this->fat_qst_mapping['new_fat'][$set_question['QuestionId']] = $copy_id; - if($set_question['QuestionOriginalId']) - { - $a_mapping->addMapping('Plugins/xtsf', 'org_qst_id', $set_question['QuestionOriginalId'], $copy_id); - } - } - else - { - $this->fat_qst_mapping['new_fat'][$set_question['QuestionId']] = $original_question_id; - } - } - $this->fat_qst_mapping[$set_question['QuestionId']] = $copy_id; - } + foreach ($set_questions as $set_question) { + if ($container_obj_type == 'xqsp') { + $original_question_id = $a_mapping->getMapping('Modules/TestQuestionPool', 'quest', $set_question['QuestionOriginalId']); + + if ($original_question_id) { + if (!assQuestion::_questionExistsInPool($original_question_id)) { + $original_question_id = null; + } + } + + $copy_id = $set->getQuestionList()->import($this->fat_qst_mapping[$set_question['QuestionId']], $original_question_id); + if ($original_question_id == 0 || $this->is_single_import) { + $this->fat_qst_mapping['new_fat'][$set_question['QuestionId']] = $copy_id; + if ($set_question['QuestionOriginalId']) { + $a_mapping->addMapping('Plugins/xtsf', 'org_qst_id', $set_question['QuestionOriginalId'], $copy_id); + } + } else { + $this->fat_qst_mapping['new_fat'][$set_question['QuestionId']] = $original_question_id; + } + } elseif ($container_obj_type == 'xtsf') { + $original_question_id = $a_mapping->getMapping('Plugins/xtsf', 'org_qst_id', $set_question['QuestionOriginalId']); + $copy_id = $set->getQuestionList()->import($this->fat_qst_mapping[$set_question['QuestionId']], $original_question_id); + + if ($original_question_id == 0 || $this->is_single_import) { + $this->fat_qst_mapping['new_fat'][$set_question['QuestionId']] = $copy_id; + if ($set_question['QuestionOriginalId']) { + $a_mapping->addMapping('Plugins/xtsf', 'org_qst_id', $set_question['QuestionOriginalId'], $copy_id); + } + } else { + $this->fat_qst_mapping['new_fat'][$set_question['QuestionId']] = $original_question_id; + } + } + $this->fat_qst_mapping[$set_question['QuestionId']] = $copy_id; + } - foreach($set_paths as $set_path) - { - $path = new ilQuestionSetPoolPath(); - $path->setSet($set); - $path->setTitle($set_path[0]['PathTitle']); - $path->import(); + foreach ($set_paths as $set_path) { + $path = new ilQuestionSetPoolPath(); + $path->setSet($set); + $path->setTitle($set_path[0]['PathTitle']); + $path->import(); - $this->addPathMapping($set_data[0]['PathId'], $path->getId()); + $this->addPathMapping($set_data[0]['PathId'], $path->getId()); - $nodes = $set_path['nodes']; - $this->importNodes($nodes, $path); - } - } - - /** - * @param array $nodes - * @param ilQuestionSetPoolPath $path - */ - protected function importNodes($nodes, ilQuestionSetPoolPath $path) - { - foreach($nodes as $node_data) - { - $node = new ilQuestionSetPoolNode(); - $node->setQuestion(assQuestion::_instantiateQuestion($this->fat_qst_mapping[$node_data[0]['NodeQuestionId']])); - $node->setPath($path); - $node->setInitialCondition($node_data[0]['NodeInitialCondition']); - if(strlen($node_data[0]['NodeDominantScoring'])) - { - $node->setDominantScoring($node_data[0]['NodeDominantScoring']); - } - $node->setTrueFeedback($node_data[0]['NodeTrueFeedback']); - $node->setFalseFeedback($node_data[0]['NodeFalseFeedback']); - - $node->import(); - - $this->addNodeMapping($node_data[0]['NodeId'], $node->getId()); - - $jump_conditions = $node_data['jump_conditions']; - if(is_array($jump_conditions) && count($jump_conditions) == 0) - { - continue 1; - } - $this->importJumpConditions($jump_conditions, $node); - } - } - - /** - * @param array $jump_conditions - * @param ilQuestionSetPoolNode $node - */ - protected function importJumpConditions($jump_conditions, ilQuestionSetPoolNode $node) - { - foreach($jump_conditions as $jump_condition_data) - { - $jump_con = new ilQuestionSetPoolJumpCondition(); - $jump_con->setNode($node); - $jump_con->setQuestion( - $this->fat_qst_mapping[$jump_condition_data['JumpConditionQuestionId']] ? - assQuestion::_instantiateQuestion($this->fat_qst_mapping[$jump_condition_data['JumpConditionQuestionId']]): - NULL - ); - $jump_con->setJumpCondition($jump_condition_data['JumpConditionText']); - if(strlen($jump_condition_data['JumpConditionRepetitions'])) - { - $jump_con->setRepititions($jump_condition_data['JumpConditionRepetitions']); - } + $nodes = $set_path['nodes']; + $this->importNodes($nodes, $path); + } + } + + /** + * @param array $nodes + * @param ilQuestionSetPoolPath $path + */ + protected function importNodes($nodes, ilQuestionSetPoolPath $path) + { + foreach ($nodes as $node_data) { + $node = new ilQuestionSetPoolNode(); + $node->setQuestion(assQuestion::_instantiateQuestion($this->fat_qst_mapping[$node_data[0]['NodeQuestionId']])); + $node->setPath($path); + $node->setInitialCondition($node_data[0]['NodeInitialCondition']); + if (strlen($node_data[0]['NodeDominantScoring'])) { + $node->setDominantScoring($node_data[0]['NodeDominantScoring']); + } + $node->setTrueFeedback($node_data[0]['NodeTrueFeedback']); + $node->setFalseFeedback($node_data[0]['NodeFalseFeedback']); + + $node->import(); + + $this->addNodeMapping($node_data[0]['NodeId'], $node->getId()); + + $jump_conditions = $node_data['jump_conditions']; + if (is_array($jump_conditions) && count($jump_conditions) == 0) { + continue 1; + } + $this->importJumpConditions($jump_conditions, $node); + } + } + + /** + * @param array $jump_conditions + * @param ilQuestionSetPoolNode $node + */ + protected function importJumpConditions($jump_conditions, ilQuestionSetPoolNode $node) + { + foreach ($jump_conditions as $jump_condition_data) { + $jump_con = new ilQuestionSetPoolJumpCondition(); + $jump_con->setNode($node); + $jump_con->setQuestion( + $this->fat_qst_mapping[$jump_condition_data['JumpConditionQuestionId']] ? + assQuestion::_instantiateQuestion($this->fat_qst_mapping[$jump_condition_data['JumpConditionQuestionId']]): + null + ); + $jump_con->setJumpCondition($jump_condition_data['JumpConditionText']); + if (strlen($jump_condition_data['JumpConditionRepetitions'])) { + $jump_con->setRepititions($jump_condition_data['JumpConditionRepetitions']); + } - $jump_con->setTrueFeedback($jump_condition_data['JumpConditionTrueFeedback']); - $jump_con->setTrueJumpFeedback($jump_condition_data['JumpConditionTrueJumpFeedback']); - $jump_con->setFalseFeedback($jump_condition_data['JumpConditionFalseFeedback']); - - $jump_con->import(); - } - } - - /** - * @param $old_set_id - * @param $new_set_id - */ - protected function addSetMapping($old_set_id, $new_set_id) - { - if(!isset($this->set_mapping[$old_set_id])) - { - $this->set_mapping[$old_set_id] = $new_set_id; - } - } - - public function getSetMapping() - { - return $this->set_mapping; - } - - /** - * @param $old_path_id - * @param $new_path_id - */ - protected function addPathMapping($old_path_id, $new_path_id) - { - $this->path_mapping[$old_path_id] = $new_path_id; - } - - /** - * @param $old_node_id - * @param $new_node_id - */ - protected function addNodeMapping($old_node_id, $new_node_id) - { - $this->node_mapping[$old_node_id] = $new_node_id; - } - - /** - * Import XML - * @param $a_entity - * @param $a_id - * @param $a_xml - * @param $a_mapping - * @return bool - */ - function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping) - { - global $DIC; - $tree = $DIC->repositoryTree(); + $jump_con->setTrueFeedback($jump_condition_data['JumpConditionTrueFeedback']); + $jump_con->setTrueJumpFeedback($jump_condition_data['JumpConditionTrueJumpFeedback']); + $jump_con->setFalseFeedback($jump_condition_data['JumpConditionFalseFeedback']); + + $jump_con->import(); + } + } + + /** + * @param $old_set_id + * @param $new_set_id + */ + protected function addSetMapping($old_set_id, $new_set_id) + { + if (!isset($this->set_mapping[$old_set_id])) { + $this->set_mapping[$old_set_id] = $new_set_id; + } + } + + public function getSetMapping() + { + return $this->set_mapping; + } + + /** + * @param $old_path_id + * @param $new_path_id + */ + protected function addPathMapping($old_path_id, $new_path_id) + { + $this->path_mapping[$old_path_id] = $new_path_id; + } + + /** + * @param $old_node_id + * @param $new_node_id + */ + protected function addNodeMapping($old_node_id, $new_node_id) + { + $this->node_mapping[$old_node_id] = $new_node_id; + } + + /** + * Import XML + * @param $a_entity + * @param $a_id + * @param $a_xml + * @param $a_mapping + * @return bool + */ + public function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping) + { + global $DIC; + $tree = $DIC->repositoryTree(); - $this->plugin_object->includeClass('class.ilObjFormATest.php'); - $this->plugin_object->includeClass('class.ilObjFormATestXMLParser.php'); - - $parent_ref_id = 0; + $this->plugin_object->includeClass('class.ilObjFormATest.php'); + $this->plugin_object->includeClass('class.ilObjFormATestXMLParser.php'); + + $parent_ref_id = 0; - if($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) - { - $ref_ids = ilObject::_getAllReferences($new_id); - $ref_id = current($ref_ids); - - $parent_ref_id = $tree->getParentId($ref_id); - - $this->xtsf_obj = ilObjectFactory::getInstanceByObjId($new_id, false); - $this->xtsf_obj->setRefId($ref_id); - $this->is_single_import = false; - } - else - { - // das ist eigentlich immer der Fall ...? - - $this->xtsf_obj = new ilObjFormaTest(); - $this->xtsf_obj->create(true); + if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) { + $ref_ids = ilObject::_getAllReferences($new_id); + $ref_id = current($ref_ids); + + $parent_ref_id = $tree->getParentId($ref_id); + + $this->xtsf_obj = ilObjectFactory::getInstanceByObjId($new_id, false); + $this->xtsf_obj->setRefId($ref_id); + $this->is_single_import = false; + } else { + // das ist eigentlich immer der Fall ...? + + $this->xtsf_obj = new ilObjFormaTest(); + $this->xtsf_obj->create(true); - $this->is_single_import = true; - } - - $this->current_parent_ref_id = $parent_ref_id; - - if(isset($_POST['xqsp_selection'])) - { - // container_id ermittle Basis-Container für questionsets - if($_POST['xqsp_selection'] == self::IMPORT_FAT_NO_POOLS) - { - - } - else if($_POST['xqsp_selection'] == self::IMPORT_INTO_SELECTED_POOLS) - { - $this->import_into_xqsp = true; - if((int)$_POST['xqsp'] > 0) - { - // verwende existierenden QuestionSetPool - $this->initializeXqspObject((int)$_POST['xqsp']); - } - else - { - // erstelle neuen QuestionSetPool - $this->initializeXqspObject(-1); - $this->xqsp_obj->createReference(); - $this->xqsp_obj->putInTree($a_mapping->getTargetId()); - $this->xqsp_obj->setPermissions($a_mapping->getTargetId()); - } - - if((int)$_POST['qpl'] == self::SINGLE_IMPORT_NO_POOL) - { - // kein QuestionPool verwenden - $this->import_into_qpl = false; - } - else if((int)$_POST['qpl'] > 0) - { - $this->import_into_qpl = true; - // verwende existierenden QuestionPool - $this->initializeQplObject((int)$_POST['qpl']); - } - else - { - $this->import_into_qpl = true; - // erstelle neuen QuestionPool - $this->initializeQplObject(self::SINGLE_IMPORT_NEW_POOL); - $this->qpl_obj->createReference(); - $this->qpl_obj->putInTree($a_mapping->getTargetId()); - $this->qpl_obj->setPermissions($a_mapping->getTargetId()); - } - } - } - - // import questions into selected main container - $this->parseQtiFile(); + $this->is_single_import = true; + } + + $this->current_parent_ref_id = $parent_ref_id; + + if (isset($_POST['xqsp_selection'])) { + // container_id ermittle Basis-Container für questionsets + if ($_POST['xqsp_selection'] == self::IMPORT_FAT_NO_POOLS) { + } elseif ($_POST['xqsp_selection'] == self::IMPORT_INTO_SELECTED_POOLS) { + $this->import_into_xqsp = true; + if ((int) $_POST['xqsp'] > 0) { + // verwende existierenden QuestionSetPool + $this->initializeXqspObject((int) $_POST['xqsp']); + } else { + // erstelle neuen QuestionSetPool + $this->initializeXqspObject(-1); + $this->xqsp_obj->createReference(); + $this->xqsp_obj->putInTree($a_mapping->getTargetId()); + $this->xqsp_obj->setPermissions($a_mapping->getTargetId()); + } + + if ((int) $_POST['qpl'] == self::SINGLE_IMPORT_NO_POOL) { + // kein QuestionPool verwenden + $this->import_into_qpl = false; + } elseif ((int) $_POST['qpl'] > 0) { + $this->import_into_qpl = true; + // verwende existierenden QuestionPool + $this->initializeQplObject((int) $_POST['qpl']); + } else { + $this->import_into_qpl = true; + // erstelle neuen QuestionPool + $this->initializeQplObject(self::SINGLE_IMPORT_NEW_POOL); + $this->qpl_obj->createReference(); + $this->qpl_obj->putInTree($a_mapping->getTargetId()); + $this->qpl_obj->setPermissions($a_mapping->getTargetId()); + } + } + } + + // import questions into selected main container + $this->parseQtiFile(); - $parser = new ilObjFormATestXMLParser($this->xtsf_obj, $this->getXmlFile()); - $parser->setImportDirectory($this->getImportDirectory()); - $parser->startParsing(); - $this->xtsf_obj = $parser->getFormATestObject(); - $this->xtsf_obj->update(); - - // create sets - $sets = $parser->getSetsArray(); - - //BUGFIX: first of all! import into formatest! IMMER!! - foreach($sets as $set_data) - { - $this->importQuestionSet($set_data[0], $set_data['questions'], $set_data['paths'], $a_mapping, $this->xtsf_obj->getId()); - } - $this->xtsf_obj->getSetList()->insert($this->getSetMapping(), false); - - //BUGFIX: import into xqsp - if($this->import_into_xqsp) - { - $xtsf_setlist = $this->xtsf_obj->getSetList(); - $xtsf_set_data = $xtsf_setlist->getData(); - foreach($xtsf_set_data as $item) - { - $this->xqsp_obj->getSetList()->insert(array($item['id']), true); - $set_mapping[$item['id']] = $this->xqsp_obj->getSetList()->getSetMapping(); - $this->xqsp_qst_mapping[$item['id']]['xqsp_questions'] = $this->xqsp_obj->getSetList()->getQuestionMapping(); - $this->setNewOriginalSetIds($set_mapping); - } - } - $a_mapping->addMapping('Plugins/xtsf', 'xtsf', $a_id, $this->xtsf_obj->getId()); - } - - /** - * update original_ids: xqsp_set_id = NULL & xtsf_set_id = xqsp_set_id - * @param array $set_mapping $set_mapping[xtsf_set_id] = xqsp_set_id - */ - protected function setNewOriginalSetIds($set_mapping = array()) - { - global $DIC; - $ilDB = $DIC->database(); - - foreach($set_mapping as $xtsf_set_id => $xqsp_set_id) - { - $ilDB->update('rep_robj_xqsp_qs', - array('original_id' => array('integer', $xqsp_set_id)), - array('id' => array('integer', $xtsf_set_id))); - - $ilDB->update('rep_robj_xqsp_qs', - array('original_id' => array('integer', NULL)), - array('id' => array('integer', $xqsp_set_id), - 'original_id' => array('integer', $xtsf_set_id))); - } - } - - /** - * @param $a_mapping - */ - function finalProcessing($a_mapping) - { - if($this->import_into_xqsp) - { - foreach($this->xqsp_qst_mapping as $set_id) - { - $xqsp_qst_mapping = $set_id['xqsp_questions']; - foreach($xqsp_qst_mapping as $fat_qst_id => $xqsp_qst_id) - { - //****************************************************// - // BUGFIX: Get fat_question; update original_id - $source_qst = assQuestion::_instantiateQuestion($fat_qst_id); - $source_qst->setNewOriginalId($xqsp_qst_id); - $source_qst->saveToDb(); - - //****************************************************// - // BUGFIX: get xqsp_question; update Original-Id = NULL!! Needed for question_types with image-files i.e. assimagemapquestion otherwise files will not be copied into questionpool! - $xqsp_source_qst = assQuestion::_instantiateQuestion($xqsp_qst_id); - $xqsp_source_qst->setNewOriginalId(NULL); - $xqsp_source_qst->saveToDb(); - // BUGFIX: reload updated question from db! - $xqsp_source_qst = assQuestion::_instantiateQuestion($xqsp_qst_id); - //****************************************************// - - if($this->import_into_qpl) - { - // jetzt müssen sie in den neu angelegten dummy pool (QPL) kopiert werden und die org_id im xqsp-pool angepasst werden. - $this->qpl_obj->read(true); - $qpl_clone_id = $xqsp_source_qst->copyObject($this->qpl_obj->getId()); - - //****************************************************// - // BUGFIX: After copying the question update xqsp_question original_id to qpl_clone_id! - $xqsp_source_qst = assQuestion::_instantiateQuestion($xqsp_qst_id); - $xqsp_source_qst->setNewOriginalId($qpl_clone_id); - $xqsp_source_qst->saveToDb(); - //****************************************************// - } - } - } - } - - return parent::finalProcessing($a_mapping); - } - - /** - * Create qti and xml file name - * @return array - */ - protected function parseXmlFileNames() - { - $GLOBALS['ilLog']->write(__METHOD__.': '.$this->getImportDirectory()); - - $basename = basename($this->getImportDirectory()); + $parser = new ilObjFormATestXMLParser($this->xtsf_obj, $this->getXmlFile()); + $parser->setImportDirectory($this->getImportDirectory()); + $parser->startParsing(); + $this->xtsf_obj = $parser->getFormATestObject(); + $this->xtsf_obj->update(); + + // create sets + $sets = $parser->getSetsArray(); + + //BUGFIX: first of all! import into formatest! IMMER!! + foreach ($sets as $set_data) { + $this->importQuestionSet($set_data[0], $set_data['questions'], $set_data['paths'], $a_mapping, $this->xtsf_obj->getId()); + } + $this->xtsf_obj->getSetList()->insert($this->getSetMapping(), false); + + //BUGFIX: import into xqsp + if ($this->import_into_xqsp) { + $xtsf_setlist = $this->xtsf_obj->getSetList(); + $xtsf_set_data = $xtsf_setlist->getData(); + foreach ($xtsf_set_data as $item) { + $this->xqsp_obj->getSetList()->insert(array($item['id']), true); + $set_mapping[$item['id']] = $this->xqsp_obj->getSetList()->getSetMapping(); + $this->xqsp_qst_mapping[$item['id']]['xqsp_questions'] = $this->xqsp_obj->getSetList()->getQuestionMapping(); + $this->setNewOriginalSetIds($set_mapping); + } + } + $a_mapping->addMapping('Plugins/xtsf', 'xtsf', $a_id, $this->xtsf_obj->getId()); + } + + /** + * update original_ids: xqsp_set_id = NULL & xtsf_set_id = xqsp_set_id + * @param array $set_mapping $set_mapping[xtsf_set_id] = xqsp_set_id + */ + protected function setNewOriginalSetIds($set_mapping = array()) + { + global $DIC; + $ilDB = $DIC->database(); + + foreach ($set_mapping as $xtsf_set_id => $xqsp_set_id) { + $ilDB->update( + 'rep_robj_xqsp_qs', + array('original_id' => array('integer', $xqsp_set_id)), + array('id' => array('integer', $xtsf_set_id)) + ); + + $ilDB->update( + 'rep_robj_xqsp_qs', + array('original_id' => array('integer', null)), + array('id' => array('integer', $xqsp_set_id), + 'original_id' => array('integer', $xtsf_set_id)) + ); + } + } + + /** + * @param $a_mapping + */ + public function finalProcessing($a_mapping) + { + if ($this->import_into_xqsp) { + foreach ($this->xqsp_qst_mapping as $set_id) { + $xqsp_qst_mapping = $set_id['xqsp_questions']; + foreach ($xqsp_qst_mapping as $fat_qst_id => $xqsp_qst_id) { + //****************************************************// + // BUGFIX: Get fat_question; update original_id + $source_qst = assQuestion::_instantiateQuestion($fat_qst_id); + $source_qst->setNewOriginalId($xqsp_qst_id); + $source_qst->saveToDb(); + + //****************************************************// + // BUGFIX: get xqsp_question; update Original-Id = NULL!! Needed for question_types with image-files i.e. assimagemapquestion otherwise files will not be copied into questionpool! + $xqsp_source_qst = assQuestion::_instantiateQuestion($xqsp_qst_id); + $xqsp_source_qst->setNewOriginalId(null); + $xqsp_source_qst->saveToDb(); + // BUGFIX: reload updated question from db! + $xqsp_source_qst = assQuestion::_instantiateQuestion($xqsp_qst_id); + //****************************************************// + + if ($this->import_into_qpl) { + // jetzt müssen sie in den neu angelegten dummy pool (QPL) kopiert werden und die org_id im xqsp-pool angepasst werden. + $this->qpl_obj->read(true); + $qpl_clone_id = $xqsp_source_qst->copyObject($this->qpl_obj->getId()); + + //****************************************************// + // BUGFIX: After copying the question update xqsp_question original_id to qpl_clone_id! + $xqsp_source_qst = assQuestion::_instantiateQuestion($xqsp_qst_id); + $xqsp_source_qst->setNewOriginalId($qpl_clone_id); + $xqsp_source_qst->saveToDb(); + //****************************************************// + } + } + } + } + + return parent::finalProcessing($a_mapping); + } + + /** + * Create qti and xml file name + * @return array + */ + protected function parseXmlFileNames() + { + $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $this->getImportDirectory()); + + $basename = basename($this->getImportDirectory()); - $xml = $this->getImportDirectory().'/'.$basename.'.xml'; - $qti = $this->getImportDirectory().'/'.preg_replace('/xqsp/', 'qti', $basename).'.xml'; - - return array($xml,$qti); - } + $xml = $this->getImportDirectory() . '/' . $basename . '.xml'; + $qti = $this->getImportDirectory() . '/' . preg_replace('/xqsp/', 'qti', $basename) . '.xml'; + + return array($xml,$qti); + } - private function getImportDirectoryBase() - { - $dir = $this->getImportDirectory(); - $dir = dirname($dir); - return $dir; - } + private function getImportDirectoryBase() + { + $dir = $this->getImportDirectory(); + $dir = dirname($dir); + return $dir; + } } diff --git a/classes/class.ilFormATestLPSummaryTableGUI.php b/classes/class.ilFormATestLPSummaryTableGUI.php index de5f9e9d3220c551cf1b78dc324e681a080a2ca5..b749932df43a6050cc8b27ddf2067d06345985e9 100644 --- a/classes/class.ilFormATestLPSummaryTableGUI.php +++ b/classes/class.ilFormATestLPSummaryTableGUI.php @@ -1,186 +1,169 @@ language(); - $ilObjDataCache = $DIC['ilObjDataCache']; - $ilUser = $DIC->user(); - - $user = ''; - if($a_user_id) - { - if($a_user_id != $ilUser->getId()) - { - $a_user = ilObjectFactory::getInstanceByObjId($a_user_id); - } - else - { - $a_user = $ilUser; - } - $user .= ', '.$a_user->getFullname(); - } - - $this->setTitle($lng->txt($action).': '.$ilObjDataCache->lookupTitle($a_obj_id).$user); - $olp = ilObjectLP::getInstance($a_obj_id); - $this->setDescription($this->lng->txt('trac_mode').': '.$olp->getModeText($this->parent_obj->object->getLearningProgressMode())); - } - - /** - * {@inheritdoc} - */ - protected function isPercentageAvailable($a_obj_id) - { - if($this->isLearningProgressDeactivated()) - { - return false; - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function searchFilterListener($a_ref_id, $a_data) - { - $status = parent::searchFilterListener($a_ref_id, $a_data); - - if( - $status && - $this->isLearningProgressDeactivated() - ) - { - $status = false; - } - - return $status; - } - - /** - * {@inheritdoc} - */ - protected function getSelectableUserColumns($a_in_course = false, $a_in_group = false) - { - $columns = parent::getSelectableUserColumns($a_in_course, $a_in_group); - - if($this->isLearningProgressDeactivated()) - { - unset($columns['status']); - unset($columns['status_changed']); - } - - return $columns; - } - - /** - * {@inheritdoc} - */ - function getSelectableColumns() - { - $columns = parent::getSelectableColumns(); - - if($this->isLearningProgressDeactivated()) - { - unset($columns['status']); - unset($columns['status_changed']); - } - - return $columns; - } - - /** - * @return bool - */ - protected function isLearningProgressDeactivated() - { - return in_array($this->parent_obj->object->getLearningProgressMode(), array(ilObjFormATest::LP_MODE_DEACTIVATED)); - } - - /** - * {@inheritdoc} - */ - protected function fillRow($a_set) - { - global $DIC; - $lng = $DIC->language(); - - $this->tpl->setVariable("ICON", ilObject::_getIcon("", "tiny", $a_set["type"])); - $this->tpl->setVariable("ICON_ALT", $lng->txt($a_set["type"])); - $this->tpl->setVariable("TITLE", $a_set["title"]); - - if($a_set["offline"]) - { - $this->tpl->setCurrentBlock("offline"); - $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("status")); - $this->tpl->setVariable("TEXT_OFFLINE", $this->lng->txt("offline")); - $this->tpl->parseCurrentBlock(); - } - - foreach ($this->getSelectedColumns() as $c) - { - switch($c) - { - case "country": - case "gender": - case "city": - case "language": - case "status": - case "mark": - case "sel_country": - $this->renderPercentages($c, $a_set[$c]); - break; - - case "percentage_avg": - if((int)$a_set[$c] === 0 || !$this->isPercentageAvailable($a_set["obj_id"])) - { - $this->tpl->setVariable(strtoupper($c), ""); - } - break; - - default: - $value = $this->parseValue($c, $a_set[$c], $a_set["type"]); - $this->tpl->setVariable(strtoupper($c), $value); - break; - } - } - - if($this->is_root) - { - $path = $this->buildPath($a_set["ref_ids"]); - if($path) - { - $this->tpl->setCurrentBlock("item_path"); - foreach($path as $ref_id => $path_item) - { - $this->tpl->setVariable("PATH_ITEM", $path_item); - - - - $this->tpl->parseCurrentBlock(); - } - } - - $this->tpl->touchBlock("path_action"); - } - } - - /** - * {@inheritdoc} - */ - function initFilter() - { - $this->filter = array(); - } -} \ No newline at end of file + /** + * {@inheritdoc} + */ + protected function parseTitle($a_obj_id, $action, $a_user_id = false) + { + global $DIC; + $lng = $DIC->language(); + $ilObjDataCache = $DIC['ilObjDataCache']; + $ilUser = $DIC->user(); + + $user = ''; + if ($a_user_id) { + if ($a_user_id != $ilUser->getId()) { + $a_user = ilObjectFactory::getInstanceByObjId($a_user_id); + } else { + $a_user = $ilUser; + } + $user .= ', ' . $a_user->getFullname(); + } + + $this->setTitle($lng->txt($action) . ': ' . $ilObjDataCache->lookupTitle($a_obj_id) . $user); + $olp = ilObjectLP::getInstance($a_obj_id); + $this->setDescription($this->lng->txt('trac_mode') . ': ' . $olp->getModeText($this->parent_obj->object->getLearningProgressMode())); + } + + /** + * {@inheritdoc} + */ + protected function isPercentageAvailable($a_obj_id) + { + if ($this->isLearningProgressDeactivated()) { + return false; + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function searchFilterListener($a_ref_id, $a_data) + { + $status = parent::searchFilterListener($a_ref_id, $a_data); + + if ( + $status && + $this->isLearningProgressDeactivated() + ) { + $status = false; + } + + return $status; + } + + /** + * {@inheritdoc} + */ + protected function getSelectableUserColumns($a_in_course = false, $a_in_group = false) + { + $columns = parent::getSelectableUserColumns($a_in_course, $a_in_group); + + if ($this->isLearningProgressDeactivated()) { + unset($columns['status']); + unset($columns['status_changed']); + } + + return $columns; + } + + /** + * {@inheritdoc} + */ + public function getSelectableColumns() + { + $columns = parent::getSelectableColumns(); + + if ($this->isLearningProgressDeactivated()) { + unset($columns['status']); + unset($columns['status_changed']); + } + + return $columns; + } + + /** + * @return bool + */ + protected function isLearningProgressDeactivated() + { + return in_array($this->parent_obj->object->getLearningProgressMode(), array(ilObjFormATest::LP_MODE_DEACTIVATED)); + } + + /** + * {@inheritdoc} + */ + protected function fillRow($a_set) + { + global $DIC; + $lng = $DIC->language(); + + $this->tpl->setVariable("ICON", ilObject::_getIcon("", "tiny", $a_set["type"])); + $this->tpl->setVariable("ICON_ALT", $lng->txt($a_set["type"])); + $this->tpl->setVariable("TITLE", $a_set["title"]); + + if ($a_set["offline"]) { + $this->tpl->setCurrentBlock("offline"); + $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("status")); + $this->tpl->setVariable("TEXT_OFFLINE", $this->lng->txt("offline")); + $this->tpl->parseCurrentBlock(); + } + + foreach ($this->getSelectedColumns() as $c) { + switch ($c) { + case "country": + case "gender": + case "city": + case "language": + case "status": + case "mark": + case "sel_country": + $this->renderPercentages($c, $a_set[$c]); + break; + + case "percentage_avg": + if ((int) $a_set[$c] === 0 || !$this->isPercentageAvailable($a_set["obj_id"])) { + $this->tpl->setVariable(strtoupper($c), ""); + } + break; + + default: + $value = $this->parseValue($c, $a_set[$c], $a_set["type"]); + $this->tpl->setVariable(strtoupper($c), $value); + break; + } + } + + if ($this->is_root) { + $path = $this->buildPath($a_set["ref_ids"]); + if ($path) { + $this->tpl->setCurrentBlock("item_path"); + foreach ($path as $ref_id => $path_item) { + $this->tpl->setVariable("PATH_ITEM", $path_item); + + + + $this->tpl->parseCurrentBlock(); + } + } + + $this->tpl->touchBlock("path_action"); + } + } + + /** + * {@inheritdoc} + */ + public function initFilter() + { + $this->filter = array(); + } +} diff --git a/classes/class.ilFormATestLPUsersTableGUI.php b/classes/class.ilFormATestLPUsersTableGUI.php index 0b40fb0f48637b3d4bbd3b2a2785cd433440f786..e39c560cc5513982e27a75ee8c29b63c62138639 100644 --- a/classes/class.ilFormATestLPUsersTableGUI.php +++ b/classes/class.ilFormATestLPUsersTableGUI.php @@ -1,185 +1,165 @@ setPrintMode($a_print_view); - $this->setRowTemplate("tpl.object_users_props_row.html", $this->parent_obj->plugin->getDirectory()); - if(!$a_print_view) - { - $this->addColumn($this->lng->txt("actions"), ""); - } - } - - /** - * {@inheritdoc} - */ - protected function parseTitle($a_obj_id, $action, $a_user_id = false) - { - global $DIC; - $lng = $DIC->language(); - $ilObjDataCache = $DIC['ilObjDataCache']; - $ilUser = $DIC->user(); - - $user = ''; - if($a_user_id) - { - if($a_user_id != $ilUser->getId()) - { - $a_user = ilObjectFactory::getInstanceByObjId($a_user_id); - } - else - { - $a_user = $ilUser; - } - $user .= ', '.$a_user->getFullname(); - } - - $this->setTitle($lng->txt($action).': '.$ilObjDataCache->lookupTitle($a_obj_id).$user); - $olp = ilObjectLP::getInstance($a_obj_id); - $this->setDescription($this->lng->txt('trac_mode').': '.$olp->getModeText($this->parent_obj->object->getLearningProgressMode())); - } - - /** - * {@inheritdoc} - */ - protected function isPercentageAvailable($a_obj_id) - { - if($this->isLearningProgressDeactivated()) - { - return false; - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function searchFilterListener($a_ref_id, $a_data) - { - $status = parent::searchFilterListener($a_ref_id, $a_data); - - if( - $status && - $this->isLearningProgressDeactivated() - ) - { - $status = false; - } - - return $status; - } - - /** - * {@inheritdoc} - */ - protected function getSelectableUserColumns($a_in_course = false, $a_in_group = false) - { - $columns = parent::getSelectableUserColumns($a_in_course, $a_in_group); - - if($this->isLearningProgressDeactivated()) - { - unset($columns['status']); - unset($columns['status_changed']); - } - - return $columns; - } - - /** - * {@inheritdoc} - */ - function getSelectableColumns() - { - $columns = parent::getSelectableColumns(); - - if($this->isLearningProgressDeactivated()) - { - unset($columns['status']); - unset($columns['status_changed']); - } - - return $columns; - } - - /** - * @return bool - */ - protected function isLearningProgressDeactivated() - { - return in_array($this->parent_obj->object->getLearningProgressMode(), array(ilObjFormATest::LP_MODE_DEACTIVATED)); - } - - /** - * {@inheritdoc} - */ - function initFilter() - { - $this->filter = array(); - } - - /** - * {@inheritdoc} - */ - protected function fillRow($data) - { - global $DIC; - $lng = $DIC->language(); - - foreach ($this->getSelectedColumns() as $c) - { - if($c == 'status' && $data[$c] != ilLPStatus::LP_STATUS_COMPLETED_NUM) - { - $timing = $this->showTimingsWarning($this->ref_id, $data["usr_id"]); - if($timing) - { - if($timing !== true) - { - $timing = ": ".ilDatePresentation::formatDate(new ilDate($timing, IL_CAL_UNIX)); - } - else - { - $timing = ""; - } - $this->tpl->setCurrentBlock('warning_img'); - $this->tpl->setVariable('WARNING_IMG', ilUtil::getImagePath('time_warn.svg')); - $this->tpl->setVariable('WARNING_ALT', $this->lng->txt('trac_time_passed').$timing); - $this->tpl->parseCurrentBlock(); - } - } - - // #7694 - if($c == 'login' && !$data["active"]) - { - $this->tpl->setCurrentBlock('inactive_bl'); - $this->tpl->setVariable('TXT_INACTIVE', $lng->txt("inactive")); - $this->tpl->parseCurrentBlock(); - } - - $this->tpl->setCurrentBlock("user_field"); - $val = $this->parseValue($c, $data[$c], "user"); - $this->tpl->setVariable("VAL_UF", $val); - $this->tpl->parseCurrentBlock(); - } - - $this->getParentObject()->ctrl->setParameter($this->getParentObject(), "user_id", $data["usr_id"]); - if(!$this->getPrintMode()) - { - $this->tpl->setCurrentBlock("item_command"); - $this->tpl->setVariable("HREF_COMMAND", $this->getParentObject()->ctrl->getLinkTarget($this->getParentObject(), "ilFormATestLearningProgressGUI.editUser")); - $this->tpl->setVariable("TXT_COMMAND", $lng->txt('edit')); - $this->tpl->parseCurrentBlock(); - } - $this->getParentObject()->ctrl->setParameter($this->getParentObject(), "user_id", ''); - } -} \ No newline at end of file + public function __construct($a_parent_obj, $a_parent_cmd, $a_obj_id, $a_ref_id, $a_print_view = false) + { + parent::__construct($a_parent_obj, $a_parent_cmd, $a_obj_id, $a_ref_id, true); + $this->setPrintMode($a_print_view); + $this->setRowTemplate("tpl.object_users_props_row.html", $this->parent_obj->plugin->getDirectory()); + if (!$a_print_view) { + $this->addColumn($this->lng->txt("actions"), ""); + } + } + + /** + * {@inheritdoc} + */ + protected function parseTitle($a_obj_id, $action, $a_user_id = false) + { + global $DIC; + $lng = $DIC->language(); + $ilObjDataCache = $DIC['ilObjDataCache']; + $ilUser = $DIC->user(); + + $user = ''; + if ($a_user_id) { + if ($a_user_id != $ilUser->getId()) { + $a_user = ilObjectFactory::getInstanceByObjId($a_user_id); + } else { + $a_user = $ilUser; + } + $user .= ', ' . $a_user->getFullname(); + } + + $this->setTitle($lng->txt($action) . ': ' . $ilObjDataCache->lookupTitle($a_obj_id) . $user); + $olp = ilObjectLP::getInstance($a_obj_id); + $this->setDescription($this->lng->txt('trac_mode') . ': ' . $olp->getModeText($this->parent_obj->object->getLearningProgressMode())); + } + + /** + * {@inheritdoc} + */ + protected function isPercentageAvailable($a_obj_id) + { + if ($this->isLearningProgressDeactivated()) { + return false; + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function searchFilterListener($a_ref_id, $a_data) + { + $status = parent::searchFilterListener($a_ref_id, $a_data); + + if ( + $status && + $this->isLearningProgressDeactivated() + ) { + $status = false; + } + + return $status; + } + + /** + * {@inheritdoc} + */ + protected function getSelectableUserColumns($a_in_course = false, $a_in_group = false) + { + $columns = parent::getSelectableUserColumns($a_in_course, $a_in_group); + + if ($this->isLearningProgressDeactivated()) { + unset($columns['status']); + unset($columns['status_changed']); + } + + return $columns; + } + + /** + * {@inheritdoc} + */ + public function getSelectableColumns() + { + $columns = parent::getSelectableColumns(); + + if ($this->isLearningProgressDeactivated()) { + unset($columns['status']); + unset($columns['status_changed']); + } + + return $columns; + } + + /** + * @return bool + */ + protected function isLearningProgressDeactivated() + { + return in_array($this->parent_obj->object->getLearningProgressMode(), array(ilObjFormATest::LP_MODE_DEACTIVATED)); + } + + /** + * {@inheritdoc} + */ + public function initFilter() + { + $this->filter = array(); + } + + /** + * {@inheritdoc} + */ + protected function fillRow($data) + { + global $DIC; + $lng = $DIC->language(); + + foreach ($this->getSelectedColumns() as $c) { + if ($c == 'status' && $data[$c] != ilLPStatus::LP_STATUS_COMPLETED_NUM) { + $timing = $this->showTimingsWarning($this->ref_id, $data["usr_id"]); + if ($timing) { + if ($timing !== true) { + $timing = ": " . ilDatePresentation::formatDate(new ilDate($timing, IL_CAL_UNIX)); + } else { + $timing = ""; + } + $this->tpl->setCurrentBlock('warning_img'); + $this->tpl->setVariable('WARNING_IMG', ilUtil::getImagePath('time_warn.svg')); + $this->tpl->setVariable('WARNING_ALT', $this->lng->txt('trac_time_passed') . $timing); + $this->tpl->parseCurrentBlock(); + } + } + + // #7694 + if ($c == 'login' && !$data["active"]) { + $this->tpl->setCurrentBlock('inactive_bl'); + $this->tpl->setVariable('TXT_INACTIVE', $lng->txt("inactive")); + $this->tpl->parseCurrentBlock(); + } + + $this->tpl->setCurrentBlock("user_field"); + $val = $this->parseValue($c, $data[$c], "user"); + $this->tpl->setVariable("VAL_UF", $val); + $this->tpl->parseCurrentBlock(); + } + + $DIC->ctrl()->setParameter($this->getParentObject(), "user_id", $data["usr_id"]); + if (!$this->getPrintMode()) { + $this->tpl->setCurrentBlock("item_command"); + $this->tpl->setVariable("HREF_COMMAND", $DIC->ctrl()->getLinkTarget($this->getParentObject(), "ilFormATestLearningProgressGUI.editUser")); + $this->tpl->setVariable("TXT_COMMAND", $lng->txt('edit')); + $this->tpl->parseCurrentBlock(); + } + $DIC->ctrl()->setParameter($this->getParentObject(), "user_id", ''); + } +} diff --git a/classes/class.ilFormATestPlugin.php b/classes/class.ilFormATestPlugin.php index 5537a93976e6a558459111ef674934cc7f07b858..e82ce3a235fc07c66c7a346b6d55c3c7bdc905fe 100644 --- a/classes/class.ilFormATestPlugin.php +++ b/classes/class.ilFormATestPlugin.php @@ -1,130 +1,129 @@ provider_collection->setToolProvider(new FormATestGlobalScreenToolsProvider($DIC, $this)); + } + } - /** - * @return string - */ - public function getPluginName() - { - return self::PNAME; - } + /** + * @return string + */ + public function getPluginName() + { + return self::PNAME; + } - /** - * @param string $a_type - * @param string $a_size - * @return string - */ - public static function _getIcon($a_type, $a_size) - { - return ilPlugin::_getImagePath( - IL_COMP_SERVICE, 'Repository', 'robj', - ilPlugin::lookupNameForId(IL_COMP_SERVICE, 'Repository', 'robj', $a_type), - 'icon_' . $a_type . '.svg' - ); - } + /** + * @param string $a_type + * @param string $a_size + * @return string + */ + public static function _getIcon($a_type, $a_size) + { + return ilPlugin::_getImagePath( + IL_COMP_SERVICE, + 'Repository', + 'robj', + ilPlugin::lookupNameForId(IL_COMP_SERVICE, 'Repository', 'robj', $a_type), + 'icon_' . $a_type . '.svg' + ); + } - protected function uninstallCustom() - { - global $DIC; - $ilDB = $DIC->database(); - - if($ilDB->tableExists('rep_robj_xtsf_data')) - { - $ilDB->dropTable('rep_robj_xtsf_data'); - } - - if($ilDB->tableExists('rep_robj_xtsf_fbt')) - { - $ilDB->dropTable('rep_robj_xtsf_fbt'); - } - if($ilDB->sequenceExists('rep_robj_xtsf_fbt')) - { - $ilDB->dropSequence('rep_robj_xtsf_fbt'); - } - - if($ilDB->tableExists('rep_robj_xtsf_qs')) - { - $ilDB->dropTable('rep_robj_xtsf_qs'); - } - - if($ilDB->tableExists('rep_robj_xtsf_session')) - { - $ilDB->dropTable('rep_robj_xtsf_session'); - } - if($ilDB->sequenceExists('rep_robj_xtsf_session')) - { - $ilDB->dropSequence('rep_robj_xtsf_session'); - } - - if($ilDB->tableExists('rep_robj_xtsf_set_trck')) - { - $ilDB->dropTable('rep_robj_xtsf_set_trck'); - } - - if($ilDB->tableExists('rep_robj_xtsf_solut')) - { - $ilDB->dropTable('rep_robj_xtsf_solut'); - } - - if($ilDB->tableExists('rep_robj_xtsf_tracking')) - { - $ilDB->dropTable('rep_robj_xtsf_tracking'); - } - - if($ilDB->tableExists('rep_robj_xtsf_trck_his')) - { - $ilDB->dropTable('rep_robj_xtsf_trck_his'); - } - } -} \ No newline at end of file + protected function uninstallCustom() + { + global $DIC; + $ilDB = $DIC->database(); + + if ($ilDB->tableExists('rep_robj_xtsf_data')) { + $ilDB->dropTable('rep_robj_xtsf_data'); + } + + if ($ilDB->tableExists('rep_robj_xtsf_fbt')) { + $ilDB->dropTable('rep_robj_xtsf_fbt'); + } + if ($ilDB->sequenceExists('rep_robj_xtsf_fbt')) { + $ilDB->dropSequence('rep_robj_xtsf_fbt'); + } + + if ($ilDB->tableExists('rep_robj_xtsf_qs')) { + $ilDB->dropTable('rep_robj_xtsf_qs'); + } + + if ($ilDB->tableExists('rep_robj_xtsf_session')) { + $ilDB->dropTable('rep_robj_xtsf_session'); + } + if ($ilDB->sequenceExists('rep_robj_xtsf_session')) { + $ilDB->dropSequence('rep_robj_xtsf_session'); + } + + if ($ilDB->tableExists('rep_robj_xtsf_set_trck')) { + $ilDB->dropTable('rep_robj_xtsf_set_trck'); + } + + if ($ilDB->tableExists('rep_robj_xtsf_solut')) { + $ilDB->dropTable('rep_robj_xtsf_solut'); + } + + if ($ilDB->tableExists('rep_robj_xtsf_tracking')) { + $ilDB->dropTable('rep_robj_xtsf_tracking'); + } + + if ($ilDB->tableExists('rep_robj_xtsf_trck_his')) { + $ilDB->dropTable('rep_robj_xtsf_trck_his'); + } + } +} diff --git a/classes/class.ilFormATestSkillEvaluationGUI.php b/classes/class.ilFormATestSkillEvaluationGUI.php new file mode 100644 index 0000000000000000000000000000000000000000..36fff097ff69e521727ae7f2173dba46da44018c --- /dev/null +++ b/classes/class.ilFormATestSkillEvaluationGUI.php @@ -0,0 +1,313 @@ +ctrl = $ctrl; + $this->tabs = $tabs; + $this->tpl = $tpl; + $this->lng = $lng; + $this->db = $db; + $this->testOBJ = $testOBJ; + } + + public function executeCommand() : void + { + $cmd = $this->ctrl->getCmd(self::CMD_SHOW) . 'Cmd'; + + $this->$cmd(); + } + + /** + * @param array $testResults + */ + public function setTestResults(array $testResults) + { + $this->testResults = $testResults; + } + + /** + * @return array + */ + public function getTestResults() : array + { + return $this->testResults; + } + + /** + * @param ilTestSession $testSession + */ + public function setTestSession($testSession) + { + $this->testSession = $testSession; + } + + /** + * @return ilAssQuestionList + */ + public function getQuestionList() + { + return $this->questionList; + } + + /** + * @param ilAssQuestionList $questionList + */ + public function setQuestionList($questionList) + { + $this->questionList = $questionList; + } + + /** + * @return ilTestObjectiveOrientedContainer + */ + public function getObjectiveOrientedContainer() + { + return $this->objectiveOrientedContainer; + } + + /** + * @param ilTestObjectiveOrientedContainer $objectiveOrientedContainer + */ + public function setObjectiveOrientedContainer($objectiveOrientedContainer) + { + $this->objectiveOrientedContainer = $objectiveOrientedContainer; + } + + /** + * @return boolean + */ + public function isNoSkillProfileOptionEnabled() + { + return $this->noSkillProfileOptionEnabled; + } + + /** + * @param boolean $noSkillProfileOptionEnabled + */ + public function setNoSkillProfileOptionEnabled($noSkillProfileOptionEnabled) + { + $this->noSkillProfileOptionEnabled = $noSkillProfileOptionEnabled; + } + + /** + * @return array + */ + public function getAvailableSkillProfiles() + { + return $this->availableSkillProfiles; + } + + /** + * @param array $availableSkillProfiles + */ + public function setAvailableSkillProfiles($availableSkillProfiles) + { + $this->availableSkillProfiles = $availableSkillProfiles; + } + + /** + * @return array + */ + public function getAvailableSkills() + { + return $this->availableSkills; + } + + /** + * @param array $availableSkills + */ + public function setAvailableSkills($availableSkills) + { + $this->availableSkills = $availableSkills; + } + + /** + * @return ilTestSession + */ + public function getTestSession() + { + return $this->testSession; + } + + protected function init($skillProfileEnabled) + { + $testFake = new ilObjTest(0, true); + $testFake->setTestId($this->testOBJ->getTestId()); + $testFake->setRefId($this->testOBJ->getRefId()); + $testFake->setId($this->testOBJ->getId()); + $testFake->setScoreReporting($this->testOBJ->getScoreReporting()); + + $this->testPassesSelector = new ilTestPassesSelector($this->db, $testFake); + $this->testPassesSelector->setActiveId($this->testSession->getActiveId()); + $this->testPassesSelector->setLastFinishedPass($this->testSession->getPass()); + + $assSettings = new ilSetting('assessment'); + $skillEvaluation = new ilTestSkillEvaluation( + $this->db, + $this->testOBJ->getTestId(), + $this->testOBJ->getRefId() + ); + + $skillEvaluation->setUserId($this->getTestSession()->getUserId()); + $skillEvaluation->setActiveId($this->getTestSession()->getActiveId()); + $skillEvaluation->setNumRequiredBookingsForSkillTriggering($assSettings->get( + 'ass_skl_trig_num_answ_barrier', + ilObjAssessmentFolder::DEFAULT_SKL_TRIG_NUM_ANSWERS_BARRIER + )); + + $skillEvaluation->init($this->getQuestionList()); + + $availableSkillProfiles = $skillEvaluation->getAssignedSkillMatchingSkillProfiles(); + $this->setNoSkillProfileOptionEnabled( + $skillEvaluation->noProfileMatchingAssignedSkillExists($availableSkillProfiles) + ); + $this->setAvailableSkillProfiles($availableSkillProfiles); + + $availableSkills = []; + + $skillEvaluation->setPass($this->testSession->getPass()); + $skillEvaluation->evaluate($this->testResults); + + $availableSkills = array_merge($availableSkills, $skillEvaluation->getSkillsMatchingNumAnswersBarrier()); + + $this->setAvailableSkills(array_values($availableSkills)); + } + + private function showCmd() + { + $selectedSkillProfile = ilTestSkillEvaluationToolbarGUI::fetchSkillProfileParam($_POST); + + $this->init($selectedSkillProfile); + + $evaluationToolbarGUI = $this->buildEvaluationToolbarGUI($selectedSkillProfile); + + $personalSkillsGUI = $this->buildPersonalSkillsGUI( + $this->getTestSession()->getUserId(), + $evaluationToolbarGUI->getSelectedEvaluationMode(), + $this->getAvailableSkills() + ); + + $this->tpl->setContent( + $this->ctrl->getHTML($evaluationToolbarGUI) . $this->ctrl->getHTML($personalSkillsGUI) + ); + } + + private function buildEvaluationToolbarGUI($selectedSkillProfileId) : ilTestSkillEvaluationToolbarGUI + { + if (!$this->isNoSkillProfileOptionEnabled() && !$selectedSkillProfileId) { + $selectedSkillProfileId = key($this->getAvailableSkillProfiles()); + } + + $gui = new ilTestSkillEvaluationToolbarGUI($this->ctrl, $this->lng, $this, self::CMD_SHOW); + + $gui->setAvailableSkillProfiles($this->getAvailableSkillProfiles()); + $gui->setNoSkillProfileOptionEnabled($this->isNoSkillProfileOptionEnabled()); + $gui->setSelectedEvaluationMode($selectedSkillProfileId); + + $gui->build(); + + return $gui; + } + + private function buildPersonalSkillsGUI($usrId, $selectedSkillProfileId, $availableSkills) : ilTestPersonalSkillsGUI + { + $gui = new ilTestPersonalSkillsGUI($this->lng, $this->testOBJ->getId()); + + $gui->setAvailableSkills($availableSkills); + $gui->setSelectedSkillProfile($selectedSkillProfileId); + + $gui->setUsrId($usrId); + + return $gui; + } +} diff --git a/classes/class.ilFormATestXmlValidator.php b/classes/class.ilFormATestXmlValidator.php index 1abe6db87d3ae375683788d4a61fe1923cb1799a..bd8c016ef2845a8f6337f66472c2b9fe0e7804b1 100644 --- a/classes/class.ilFormATestXmlValidator.php +++ b/classes/class.ilFormATestXmlValidator.php @@ -6,280 +6,271 @@ */ class ilFormATestXmlValidator { - /** - * - */ - const MODE_VALIDATION = 1; - /** - * - */ - const XSD_FILE = './Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/xml/xtsf_5_1.xsd'; - /** - * - */ - const NAME_SPACE_URI = 'http://www.ilias.de/Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest'; - /** - * - */ - const DOM_MISSING_NS_CODE = 1845; - - /** - * @var - */ - private $mode; - /** - * @var string - */ - private $schema; - /** - * @var - */ - private $xml; - - /** - * @var array - */ - private $assignments = array(); - /** - * @var array - */ - private $errors = array(); - /** - * @var bool - */ - private $has_errors = false; - - /** - * @var null - */ - protected $xml_file = NULL; - - /** - * @var null - */ - protected $xsd_file = NULL; - - /** - * @var string - */ - protected $error_message = ''; - - /** - * ilQuestionSetPoolXmlValidator constructor. - */ - public function __construct() - { - $this->schema = self::XSD_FILE; - } - - /** - * @return mixed - */ - public function getMode() - { - return $this->mode; - } - - /** - * @param mixed $mode - */ - public function setMode($mode) - { - $this->mode = $mode; - } - - /** - * @return string - */ - public function getSchema() - { - return $this->schema; - } - - /** - * @param string $schema - */ - public function setSchema($schema) - { - $this->schema = $schema; - } - - /** - * @return mixed - */ - public function getXml() - { - return $this->xml; - } - - /** - * @param mixed $xml - */ - public function setXml($xml) - { - $this->xml = $xml; - } - - /** - * @return array - */ - public function getAssignments() - { - return $this->assignments; - } - - /** - * @param array $assignments - */ - public function setAssignments($assignments) - { - $this->assignments = $assignments; - } - - /** - * @return array - */ - public function getErrors() - { - return $this->errors; - } - - /** - * @param array $errors - */ - public function setErrors($errors) - { - $this->errors = $errors; - } - - /** - * @return boolean - */ - public function isHasErrors() - { - return $this->has_errors; - } - - /** - * @param boolean $has_errors - */ - public function setHasErrors($has_errors) - { - $this->has_errors = $has_errors; - } - - /** - * @return null - */ - public function getXmlFile() - { - return $this->xml_file; - } - - /** - * @param null $xml_file - */ - public function setXmlFile($xml_file) - { - $this->xml_file = $xml_file; - } - - /** - * @return null - */ - public function getXsdFile() - { - return $this->xsd_file; - } - - /** - * @param null $xsd_file - */ - public function setXsdFile($xsd_file) - { - $this->xsd_file = $xsd_file; - } - - /** - * @return string - */ - public function getErrorMessage() - { - return $this->error_message; - } - - /** - * @param string $error_message - */ - public function setErrorMessage($error_message) - { - $this->error_message = $error_message; - } - - /** - * @return bool - */ - public function validate() - { - // validate against schema - $this->setXml(@file_get_contents($this->getXmlFile())); - - if(!$this->validateXml($this->getXml(), false)) - { - return true; - } - - if(is_array($this->errors) && count($this->errors)) - { - return false; - } - return true; - } - - /** - * validate xml string - * @param string $a_xml - * @param bool|false $a_add_default_namespace - * @return bool - */ - protected function validateXml($a_xml, $a_add_default_namespace = false) - { - ilLoggerFactory::getLogger('xtsf')->debug($a_xml); - - libxml_use_internal_errors(true); - $dom = new DOMDocument(); - $dom->loadXML($a_xml); - $dom->schemaValidate($this->getSchema()); - - foreach(libxml_get_errors() as $error) - { - ilLoggerFactory::getLogger('xtsf')->warning('XML schema validation failed: ' . $error->line.': '. $error->message); - - /* @var $error LibXMLError */ - if($error->code == self::DOM_MISSING_NS_CODE) - { - if(!$a_add_default_namespace) - { - // add default namespace to xml - $xml = simplexml_load_string($a_xml); - $xml->addAttribute('xmlns', self::NAME_SPACE_URI); - $xml->saveXml(); - ilLoggerFactory::getLogger('xtsf')->debug('Starting second validation with default namespace'); - libxml_clear_errors(); - return $this->validateXml($xml->asXML(), true); - } - } - else - { - $this->errors[] = $error->line.': '.$error->message; - } - } - libxml_clear_errors(); - if(is_array($this->errors) && count($this->errors)) - { - return false; - } - return true; - - } -} \ No newline at end of file + /** + * + */ + const MODE_VALIDATION = 1; + /** + * + */ + const XSD_FILE = './Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/xml/xtsf_5_1.xsd'; + /** + * + */ + const NAME_SPACE_URI = 'http://www.ilias.de/Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest'; + /** + * + */ + const DOM_MISSING_NS_CODE = 1845; + + /** + * @var + */ + private $mode; + /** + * @var string + */ + private $schema; + /** + * @var + */ + private $xml; + + /** + * @var array + */ + private $assignments = array(); + /** + * @var array + */ + private $errors = array(); + /** + * @var bool + */ + private $has_errors = false; + + /** + * @var null + */ + protected $xml_file = null; + + /** + * @var null + */ + protected $xsd_file = null; + + /** + * @var string + */ + protected $error_message = ''; + + /** + * ilQuestionSetPoolXmlValidator constructor. + */ + public function __construct() + { + $this->schema = self::XSD_FILE; + } + + /** + * @return mixed + */ + public function getMode() + { + return $this->mode; + } + + /** + * @param mixed $mode + */ + public function setMode($mode) + { + $this->mode = $mode; + } + + /** + * @return string + */ + public function getSchema() + { + return $this->schema; + } + + /** + * @param string $schema + */ + public function setSchema($schema) + { + $this->schema = $schema; + } + + /** + * @return mixed + */ + public function getXml() + { + return $this->xml; + } + + /** + * @param mixed $xml + */ + public function setXml($xml) + { + $this->xml = $xml; + } + + /** + * @return array + */ + public function getAssignments() + { + return $this->assignments; + } + + /** + * @param array $assignments + */ + public function setAssignments($assignments) + { + $this->assignments = $assignments; + } + + /** + * @return array + */ + public function getErrors() + { + return $this->errors; + } + + /** + * @param array $errors + */ + public function setErrors($errors) + { + $this->errors = $errors; + } + + /** + * @return boolean + */ + public function isHasErrors() + { + return $this->has_errors; + } + + /** + * @param boolean $has_errors + */ + public function setHasErrors($has_errors) + { + $this->has_errors = $has_errors; + } + + /** + * @return null + */ + public function getXmlFile() + { + return $this->xml_file; + } + + /** + * @param null $xml_file + */ + public function setXmlFile($xml_file) + { + $this->xml_file = $xml_file; + } + + /** + * @return null + */ + public function getXsdFile() + { + return $this->xsd_file; + } + + /** + * @param null $xsd_file + */ + public function setXsdFile($xsd_file) + { + $this->xsd_file = $xsd_file; + } + + /** + * @return string + */ + public function getErrorMessage() + { + return $this->error_message; + } + + /** + * @param string $error_message + */ + public function setErrorMessage($error_message) + { + $this->error_message = $error_message; + } + + /** + * @return bool + */ + public function validate() + { + // validate against schema + $this->setXml(@file_get_contents($this->getXmlFile())); + + if (!$this->validateXml($this->getXml(), false)) { + return true; + } + + if (is_array($this->errors) && count($this->errors)) { + return false; + } + return true; + } + + /** + * validate xml string + * @param string $a_xml + * @param bool|false $a_add_default_namespace + * @return bool + */ + protected function validateXml($a_xml, $a_add_default_namespace = false) + { + ilLoggerFactory::getLogger('xtsf')->debug($a_xml); + + libxml_use_internal_errors(true); + $dom = new DOMDocument(); + $dom->loadXML($a_xml); + $dom->schemaValidate($this->getSchema()); + + foreach (libxml_get_errors() as $error) { + ilLoggerFactory::getLogger('xtsf')->warning('XML schema validation failed: ' . $error->line . ': ' . $error->message); + + /* @var $error LibXMLError */ + if ($error->code == self::DOM_MISSING_NS_CODE) { + if (!$a_add_default_namespace) { + // add default namespace to xml + $xml = simplexml_load_string($a_xml); + $xml->addAttribute('xmlns', self::NAME_SPACE_URI); + $xml->saveXml(); + ilLoggerFactory::getLogger('xtsf')->debug('Starting second validation with default namespace'); + libxml_clear_errors(); + return $this->validateXml($xml->asXML(), true); + } + } else { + $this->errors[] = $error->line . ': ' . $error->message; + } + } + libxml_clear_errors(); + if (is_array($this->errors) && count($this->errors)) { + return false; + } + return true; + } +} diff --git a/classes/class.ilObjFormATest.php b/classes/class.ilObjFormATest.php index 5d85dbd51316d06dbf54fade77ec809685f29a7c..722795245d620722d527823221332020f33cc6c5 100644 --- a/classes/class.ilObjFormATest.php +++ b/classes/class.ilObjFormATest.php @@ -1,20 +1,10 @@ db = $DIC->database(); + $this->log = $DIC->logger()->root(); + $this->user = $DIC->user(); + $lng = $DIC->language(); + $this->score_reporting = self::SCORE_REPORTING_ALWAYS; + $this->max_passes = 0; + + $lng->loadLanguageModule('assessment'); + $this->mark_schema = new ASS_MarkSchema(); + $this->mark_schema->createSimpleSchema( + $lng->txt("failed_short"), + $lng->txt("failed_official"), + 0, + 0, + $lng->txt("passed_short"), + $lng->txt("passed_official"), + 50, + 1 + ); + parent::__construct($ref_id); + + $this->plugin = $this->getPlugin(); + } + + /** + * @return string + */ + public function getQuestionEditingFormBackTargetLabel() + { + return $this->plugin->txt('back_to_question_set_qlist'); + } + + /** + * @param $context + * @return string + */ + public function getQuestionEditingFormBackTarget($context) + { + global $DIC; + $ilCtrl = $DIC->ctrl(); + $params = @json_decode(base64_decode($context), true); + + $ilCtrl->setParameterByClass('ilObjPluginDispatchGUI', 'ref_id', $this->getRefId()); + $ilCtrl->setParameterByClass('ilObjPluginDispatchGUI', 'set_id', $_GET['set_id']); + $url = $ilCtrl->getLinkTargetByClass(array('ilObjPluginDispatchGUI', 'ilObjFormATestGUI', 'ilObjFormATestQuestionSetPoolGUI'), '', '', false, false); + foreach ((array) $params as $key => $value) { + $url = ilUtil::appendUrlParameterString($url, $key . '=' . $value); + } + + return $url; + } + + /** + * @return ilFormATestSetList + */ + public function getSetList() + { + return $this->set_list; + } + + /** + * @return int + */ + public function getTestId() + { + return $this->test_id; + } + + /** + * Returns the full name of a test user according to the anonymity status + * @param int $user_id The database ID of the user + * @param boolean $overwrite_anonymity Indicates if the anonymity status should be ignored + * @return string The full name of the user or UNKNOWN if the anonymity status is affected + * @access public + */ + public function userLookupFullName($user_id, $overwrite_anonymity = false, $sorted_order = false, $suffix = "") + { + $uname = ilObjUser::_lookupName($user_id); + if (strlen($uname["firstname"] . $uname["lastname"]) == 0) { + $uname["firstname"] = $this->lng->txt("deleted_user"); + } + if ($sorted_order) { + return trim($uname["lastname"] . ", " . $uname["firstname"]) . $suffix; + } else { + return trim($uname["firstname"] . " " . $uname["lastname"]) . $suffix; + } + } + + /** + * + */ + protected function initType() + { + $this->setType('xtsf'); + } + + /** + * @throws ilException + */ + public function doCreate() + { + $this->set_list = new ilFormATestSetList($this); + $this->participants = new ilFormATestParticipantsList($this); + + try { + $this->db->insert( + 'rep_robj_xtsf_data', + array( + 'id' => array('integer', $this->getId()), + "max_passes" => array("integer", $this->getMaxPasses()) + ) + ); + + $testId = $this->db->nextId('tst_tests'); + $this->db->insert( + 'tst_tests', + array( + 'test_id' => array('integer', $testId), + 'obj_fi' => array('integer', $this->getId()), + 'author' => array('integer', $this->user->getFirstname() . ' ' . $this->user->getLastname()), + "score_reporting" => array("integer", self::SCORE_REPORTING_ALWAYS) + ) + ); + + $this->mark_schema->saveToDb($testId); + + $this->createMetaData(); + $this->logAction($this->plugin->txt("log_create_new_test")); + } catch (Exception $e) { + $this->log->write($e->getMessage()); + $this->log->logStack(); + + $this->delete(); + + // If you throw an exception here, ILIAS does not create an entry in object_data / object_reference / tree ... + throw new ilException(''); + } + } + + /** + * Read data from db + */ + public function doRead() + { + $this->set_list = new ilFormATestSetList($this); + $this->participants = new ilFormATestParticipantsList($this); + + $res = $this->db->query('SELECT rep_robj_xtsf_data.*, tst_tests.* FROM rep_robj_xtsf_data INNER JOIN tst_tests ON obj_fi = id WHERE id = ' . $this->db->quote($this->getId(), 'integer')); + $row = $this->db->fetchAssoc($res); + + $this->setLearningProgressMode($row['lp_mode']); + $this->test_id = $row["test_id"]; + $this->setOnline($row["is_online"]); + $this->setAllowInterruption($row["allow_interruption"]); + $this->setAllowWalkBack($row["allow_walk_back"]); + $this->setMaxPasses($row["max_passes"]); + $this->setProcessTime($row["process_time"]); + $this->setShowCurrentTrack($row["show_current_track"]); + $this->setIntroStatement($row["intro_statement"]); + $this->setFinalStatement($row["final_statement"]); + $this->setShowIntroStatement($row["show_intro_statement"]); + $this->setShowFinalStatement($row["show_final_statement"]); + $this->setShowQuestionsOverview($row["show_questions_overview"]); + $this->setScoreReporting($row["score_reporting"]); + $this->setCharSelectorAvailability((int) $row['char_selector_availability']); + $this->setCharSelectorDefinition($row['char_selector_definition']); + $this->setSkillServiceEnabled($row['skill_service']); + + $this->setSpecificAnswerFeedback($row['specific_feedback']); + $this->setGenericAnswerFeedback($row['answer_feedback']); + $this->setAnswerFeedbackPoints($row['answer_feedback_points']); + $this->setInstantFeedbackSolution($row['instant_verification']); + + $this->setNodeFeedbackAuthor($row['node_fb_author']); + $this->setNodeFeedbackParticipant($row['node_fb_part']); + $this->setNodeFeedbackParticipantRes($row['node_fb_part_res']); + + if ($row["starting_time"]) { + $this->setStartTime(new ilDateTime($row["starting_time"], IL_CAL_UNIX)); + $this->setStartTimeEnabled(true); + } else { + $this->setStartTime(null); + $this->setStartTimeEnabled(false); + } + if ($row["ending_time"]) { + $this->setEndTime(new ilDateTime($row["ending_time"], IL_CAL_UNIX)); + $this->setEndTimeEnabled(true); + } else { + $this->setEndTime(null); + $this->setEndTimeEnabled(false); + } + if ($row["reporting_date"]) { + $this->setReportingDate(new ilDateTime($row["reporting_date"], IL_CAL_UNIX)); + } else { + $this->setReportingDate(null); + } + + $this->mark_schema->flush(); + $this->mark_schema->loadFromDb($this->test_id); + } + + /** + * Update data + */ + public function doUpdate() + { + $unix_start_time = $this->getStartTime() instanceof ilDateTime ? $this->getStartTime()->getUnixTime() : null; + $unix_end_time = $this->getEndTime() instanceof ilDateTime ? $this->getEndTime()->getUnixTime() : null; + $unix_reporting_date = $this->getReportingDate() instanceof ilDateTime ? $this->getReportingDate()->getUnixTime() : null; + + $this->db->update( + "tst_tests", + array( + "starting_time" => array("text", $unix_start_time), + "ending_time" => array("text", $unix_end_time), + "reporting_date" => array("text", $unix_reporting_date), + "score_reporting" => array("integer", $this->getScoreReporting()), + 'char_selector_availability' => array('integer', (int) $this->getCharSelectorAvailability()), + 'char_selector_definition' => array('text', (string) $this->getCharSelectorDefinition()), + 'specific_feedback' => array('integer', (int) $this->getSpecificAnswerFeedback()), + 'answer_feedback' => array('text', $this->getGenericAnswerFeedback()), + 'answer_feedback_points' => array('text', $this->getAnswerFeedbackPoints()), + 'instant_verification' => array('text', $this->getInstantFeedbackSolution()), + 'skill_service' => array('integer', $this->isSkillServiceEnabled()) + ), + array('obj_fi' => array('integer', $this->getId())) + ); + + unset($tmp_obj); + + $this->db->update( + 'rep_robj_xtsf_data', + array( + 'lp_mode' => array('integer', $this->getLearningProgressMode()), + "is_online" => array("integer", $this->isOnline()), + "allow_walk_back" => array("integer", $this->isAllowWalkBack()), + "allow_interruption" => array("integer", $this->isAllowInterruption()), + "show_current_track" => array("integer", $this->getShowCurrentTrack()), + "max_passes" => array("integer", $this->getMaxPasses()), + "process_time" => array("integer", $this->getProcessTime()), + "intro_statement" => array("text", $this->getIntroStatement()), + "final_statement" => array("text", $this->getFinalStatement()), + "show_intro_statement" => array("integer", $this->getShowIntroStatement()), + "show_final_statement" => array("integer", $this->getShowFinalStatement()), + "show_questions_overview" => array("integer", $this->getShowQuestionsOverview()), + "node_fb_author" => array("integer", $this->getNodeFeedbackAuthor()), + "node_fb_part" => array("integer", $this->getNodeFeedbackParticipant()), + "node_fb_part_res" => array("integer", $this->getNodeFeedbackParticipantRes()) + ), + array( + 'id' => array('integer', $this->getId()) + ) + ); + + $this->updateMetaData(); + $this->logAction($this->plugin->txt("log_modified_test")); + } + + /** + * @return bool + */ + public function beforeDelete() + { + $this->getParticipants()->removeAll(); + $this->getSetList()->removeAll(); + + return true; + } + + /** + * Delete data from database + */ + public function doDelete() + { + try { + $this->db->manipulate('DELETE FROM rep_robj_xtsf_data WHERE id = ' . $this->db->quote($this->getId(), 'integer')); + $this->db->manipulate('DELETE FROM tst_tests WHERE obj_fi = ' . $this->db->quote($this->getId(), 'integer')); + $this->mark_schema->flush(); + $this->mark_schema->saveToDb($this->getTestId()); + } catch (Exception $e) { + $this->log->write($e->getMessage()); + $this->log->logStack(); + } + } + + /** + * @param ilObjFormATest $new_obj + * @param int $a_target_id + * @param int $a_copy_id + */ + public function doCloneObject($new_obj, $a_target_id, $a_copy_id = null) + { + $res = $this->db->queryF( + 'SELECT * FROM rep_robj_xtsf_data WHERE id = %s', + array('integer'), + array($this->getId()) + ); + $row = $this->db->fetchAssoc($res); + + try { + $res_tmp = $this->db->queryF( + 'SELECT * FROM rep_robj_xtsf_data WHERE id = %s', + array('integer'), + array($new_obj->getId()) + ); + + $numrows = $this->db->numRows($res_tmp); + if ($numrows == 1) { + $this->db->update( + 'rep_robj_xtsf_data', + array( + 'lp_mode' => array('integer', $this->getLearningProgressMode()), + "is_online" => array("integer", $this->isOnline()), + "allow_walk_back" => array("integer", $this->isAllowWalkBack()), + "allow_interruption" => array("integer", $this->isAllowInterruption()), + "show_current_track" => array("integer", $this->getShowCurrentTrack()), + "max_passes" => array("integer", $this->getMaxPasses()), + "process_time" => array("integer", $this->getProcessTime()), + "intro_statement" => array("text", $this->getIntroStatement()), + "final_statement" => array("text", $this->getFinalStatement()), + "show_intro_statement" => array("integer", $this->getShowIntroStatement()), + "show_final_statement" => array("integer", $this->getShowFinalStatement()), + "show_questions_overview" => array("integer", $this->getShowQuestionsOverview()), + "node_fb_author" => array("integer", $this->getNodeFeedbackAuthor()), + "node_fb_part" => array("integer", $this->getNodeFeedbackParticipant()), + "node_fb_part_res" => array("integer", $this->getNodeFeedbackParticipantRes()) + ), + array('id' => array('integer', $new_obj->getId())) + ); + } elseif ($numrows == 0) { + $this->db->insert( + 'rep_robj_xtsf_data', + array( + 'id' => array('integer', $new_obj->getId()), + 'lp_mode' => array('integer', $row['lp_mode']), + "is_online" => array("integer", $row['is_online']), + "allow_walk_back" => array("integer", $row['allow_walk_back']), + "allow_interruption" => array("integer", $row['allow_interruption']), + "show_current_track" => array("integer", $row['show_current_track']), + "max_passes" => array("integer", $row['max_passes']), + "process_time" => array("integer", $row['process_time']), + "intro_statement" => array("text", $row['intro_statement']), + "final_statement" => array("text", $row['final_statement']), + "show_intro_statement" => array("integer", $row['show_intro_statement']), + "show_final_statement" => array("integer", $row['show_final_statement']), + "show_questions_overview" => array("integer", $this->getShowQuestionsOverview()) + ) + ); + } + + $res = $this->db->queryF( + 'SELECT * FROM tst_tests WHERE obj_fi = %s', + array('integer'), + array($this->getId()) + ); + $row = $this->db->fetchAssoc($res); + + $testId = $this->db->nextId('tst_tests'); + $this->db->insert( + 'tst_tests', + array( + 'test_id' => array('integer', $testId), + 'obj_fi' => array('integer', $new_obj->getId()), + 'author' => array('integer', $this->user->getFirstname() . ' ' . $this->user->getLastname()), + "starting_time" => array("text", $row['starting_time']), + "ending_time" => array("text", $row['ending_time']), + "reporting_date " => array("text", $row['reporting_date']), + "score_reporting" => array("text", $row['score_reporting']), + 'char_selector_availability' => array('integer', (int) $this->getCharSelectorAvailability()), + 'char_selector_definition' => array('text', (string) $this->getCharSelectorDefinition()), + + 'specific_feedback' => array('integer', (int) $this->getSpecificAnswerFeedback()), + 'answer_feedback' => array('text', $this->getGenericAnswerFeedback()), + 'answer_feedback_points' => array('text', $this->getAnswerFeedbackPoints()), + 'instant_verification' => array('text', $this->getInstantFeedbackSolution()), + 'skill_service' => array('integer', $this->isSkillServiceEnabled()) + ) + ); + + $set_data = $this->getSetList()->getData(); + + foreach ($set_data as $item) { + $new_obj->getSetList()->insert(array($item["id"])); + } + + // @todo: Clone mark schema + $this->cloneMetaData($new_obj); + } catch (Exception $e) { + //@todo: Handle Exception + $this->log->write($e->getMessage()); + $this->log->logStack(); + } + } - const SCORE_REPORTING_FINISHED = 1; - const SCORE_REPORTING_ALWAYS = 2; - const SCORE_REPORTING_DATE = 3; - const SCORE_REPORTING_NEVER = 4; - - /** - * @var int - */ - const LP_MODE_DEACTIVATED = 0; - - /** - * @var int - */ - const LP_MODE_TEST_PASSED = 8; - - /** - * @var ilFormATestSetList - */ - protected $set_list; - - /** - * @var ilFormATestParticipantsList - */ - protected $participants; - - /** - * @var int - */ - protected $test_id; - - /** - * @var int - */ - protected $learning_progress_mode = self::LP_MODE_DEACTIVATED; - - /** - * @var ilDB - */ - protected $db; - - /** - * @var ilObjUser - */ - protected $user; - - /** - * @var ilLog - */ - protected $log; - - /** - * @var boolean - */ - protected $online; - - /** - * @var integer - */ - protected $max_passes; - - /** - * @var integer - */ - protected $process_time; - - /** - * @var boolean - */ - protected $allow_walk_back; - - /** - * @var boolean - */ - protected $show_current_track; - - /** - * @var boolean - */ - protected $show_questions_overview; - - /** - * @var boolean - */ - protected $allow_interruption; - - /** - * @var string - */ - protected $intro_statement; - - /** - * @var string - */ - protected $final_statement; - - /** - * @var boolean - */ - protected $show_final_statement; - - /** - * @var boolean - */ - protected $show_intro_statement; - - /** - * @var boolean - */ - protected $start_time_enabled; - - /** - * @var boolean - */ - protected $end_time_enabled; - - /** - * @var ilDateTime - */ - protected $start_time; - - /** - * @var ilDateTime - */ - protected $end_time; - - /** - * @var ilDateTime - */ - protected $reporting_date; - - /** - * @var int - */ - protected $score_reporting; - - /** - * @var array - */ - protected static $online_status_map = array(); - - /** - * @var ASS_MarkSchema - */ - public $mark_schema; - - /** @var mixed availability of selector for special characters */ - protected $char_selector_availability; - - /** @var string definition of selector for special characters */ - protected $char_selector_definition; - - /** - * @var integer $answer_feedback_points - */ - private $answer_feedback_points; - /** - * @var integer $instant_verification - */ - private $instant_verification; - /** - * @var integer $answer_feedback - */ - private $answer_feedback; - /** - * @var integer $specific_answer_feedback - */ - private $specific_answer_feedback; - - /** - * @var integer $node_feedback_author - */ - private $node_feedback_author = 0; - - /**# - * @var integer $node_feedback_participant - */ - private $node_feedback_participant = 0; - /** - * @var integer $node_feedback_participant_res - */ - private $node_feedback_participant_res = 0; - - /** - * @var bool - */ - private $skillServiceEnabled = false; - - /** - * @var null|bool - */ - private static $isSkillManagementGloballyActivated = null; - - /** - * @param int $ref_id - */ - public function __construct($ref_id = 0) - { - global $DIC; - - $this->db = $DIC->database(); - $this->log = $DIC->logger()->root(); - $this->user = $DIC->user(); - $lng = $DIC->language(); - $this->score_reporting = self::SCORE_REPORTING_ALWAYS; - $this->max_passes = 0; - - require_once "./Modules/Test/classes/class.assMarkSchema.php"; - $lng->loadLanguageModule('assessment'); - $this->mark_schema = new ASS_MarkSchema(); - $this->mark_schema->createSimpleSchema( - $lng->txt("failed_short"), - $lng->txt("failed_official"), - 0, - 0, - $lng->txt("passed_short"), - $lng->txt("passed_official"), - 50, - 1 - ); - parent::__construct($ref_id); - - $this->plugin = $this->getPlugin(); - } - - /** - * @return string - */ - public function getQuestionEditingFormBackTargetLabel() - { - return $this->plugin->txt('back_to_question_set_qlist'); - } - - /** - * @param $context - * @return string - */ - public function getQuestionEditingFormBackTarget($context) - { - global $DIC; - $ilCtrl = $DIC->ctrl(); - $params = @json_decode(base64_decode($context), true); - - $ilCtrl->setParameterByClass('ilObjPluginDispatchGUI', 'ref_id', $this->getRefId()); - $ilCtrl->setParameterByClass('ilObjPluginDispatchGUI', 'set_id', $_GET['set_id']); - $url = $ilCtrl->getLinkTargetByClass(array('ilObjPluginDispatchGUI', 'ilObjFormATestGUI', 'ilObjFormATestQuestionSetPoolGUI'), '', '', false, false); - foreach((array)$params as $key => $value) - { - $url = ilUtil::appendUrlParameterString($url, $key . '=' . $value); - } - - return $url; - } - - /** - * @return ilFormATestSetList - */ - public function getSetList() - { - return $this->set_list; - } - - /** - * @return int - */ - public function getTestId() - { - return $this->test_id; - } - - /** - * Returns the full name of a test user according to the anonymity status - * @param int $user_id The database ID of the user - * @param boolean $overwrite_anonymity Indicates if the anonymity status should be ignored - * @return string The full name of the user or UNKNOWN if the anonymity status is affected - * @access public - */ - public function userLookupFullName($user_id, $overwrite_anonymity = FALSE, $sorted_order = FALSE, $suffix = "") - { - $uname = ilObjUser::_lookupName($user_id); - if(strlen($uname["firstname"] . $uname["lastname"]) == 0) $uname["firstname"] = $this->lng->txt("deleted_user"); - if($sorted_order) - { - return trim($uname["lastname"] . ", " . $uname["firstname"]) . $suffix; - } - else - { - return trim($uname["firstname"] . " " . $uname["lastname"]) . $suffix; - } - } - - /** - * - */ - protected function initType() - { - $this->setType('xtsf'); - } - - /** - * @throws ilException - */ - public function doCreate() - { - $this->set_list = new ilFormATestSetList($this); - $this->participants = new ilFormATestParticipantsList($this); - - try - { - $this->db->insert( - 'rep_robj_xtsf_data', - array( - 'id' => array('integer', $this->getId()), - "max_passes" => array("integer", $this->getMaxPasses()) - ) - ); - - $testId = $this->db->nextId('tst_tests'); - $this->db->insert( - 'tst_tests', - array( - 'test_id' => array('integer', $testId), - 'obj_fi' => array('integer', $this->getId()), - 'author' => array('integer', $this->user->getFirstname() . ' ' . $this->user->getLastname()), - "score_reporting" => array("integer", self::SCORE_REPORTING_ALWAYS) - ) - ); - - $this->mark_schema->saveToDb($testId); - - $this->createMetaData(); - $this->logAction($this->plugin->txt("log_create_new_test")); - } - catch(Exception $e) - { - $this->log->write($e->getMessage()); - $this->log->logStack(); - - $this->delete(); - - // If you throw an exception here, ILIAS does not create an entry in object_data / object_reference / tree ... - throw new ilException(''); - } - } - - /** - * Read data from db - */ - public function doRead() - { - $this->set_list = new ilFormATestSetList($this); - $this->participants = new ilFormATestParticipantsList($this); - - $res = $this->db->query('SELECT rep_robj_xtsf_data.*, tst_tests.* FROM rep_robj_xtsf_data INNER JOIN tst_tests ON obj_fi = id WHERE id = ' . $this->db->quote($this->getId(), 'integer')); - $row = $this->db->fetchAssoc($res); - - $this->setLearningProgressMode($row['lp_mode']); - $this->test_id = $row["test_id"]; - $this->setOnline($row["is_online"]); - $this->setAllowInterruption($row["allow_interruption"]); - $this->setAllowWalkBack($row["allow_walk_back"]); - $this->setMaxPasses($row["max_passes"]); - $this->setProcessTime($row["process_time"]); - $this->setShowCurrentTrack($row["show_current_track"]); - $this->setIntroStatement($row["intro_statement"]); - $this->setFinalStatement($row["final_statement"]); - $this->setShowIntroStatement($row["show_intro_statement"]); - $this->setShowFinalStatement($row["show_final_statement"]); - $this->setShowQuestionsOverview($row["show_questions_overview"]); - $this->setScoreReporting($row["score_reporting"]); - $this->setCharSelectorAvailability((int)$row['char_selector_availability']); - $this->setCharSelectorDefinition($row['char_selector_definition']); - $this->setSkillServiceEnabled($row['skill_service']); - - $this->setSpecificAnswerFeedback($row['specific_feedback']); - $this->setGenericAnswerFeedback($row['answer_feedback']); - $this->setAnswerFeedbackPoints($row['answer_feedback_points']); - $this->setInstantFeedbackSolution($row['instant_verification']); - - $this->setNodeFeedbackAuthor($row['node_fb_author']); - $this->setNodeFeedbackParticipant($row['node_fb_part']); - $this->setNodeFeedbackParticipantRes($row['node_fb_part_res']); - - if($row["starting_time"]) - { - $this->setStartTime(new ilDateTime($row["starting_time"], IL_CAL_UNIX)); - $this->setStartTimeEnabled(true); - } - else - { - $this->setStartTime(null); - $this->setStartTimeEnabled(false); - } - if($row["ending_time"]) - { - $this->setEndTime(new ilDateTime($row["ending_time"], IL_CAL_UNIX)); - $this->setEndTimeEnabled(true); - } - else - { - $this->setEndTime(null); - $this->setEndTimeEnabled(false); - } - if($row["reporting_date"]) - { - $this->setReportingDate(new ilDateTime($row["reporting_date"], IL_CAL_UNIX)); - } - else - { - $this->setReportingDate(null); - } - - $this->mark_schema->flush(); - $this->mark_schema->loadFromDb($this->test_id); - } - - /** - * Update data - */ - public function doUpdate() - { - $unix_start_time = $this->getStartTime() instanceof ilDateTime ? $this->getStartTime()->getUnixTime() : NULL; - $unix_end_time = $this->getEndTime() instanceof ilDateTime ? $this->getEndTime()->getUnixTime() : NULL; - $unix_reporting_date = $this->getReportingDate() instanceof ilDateTime ? $this->getReportingDate()->getUnixTime() : NULL; - - $this->db->update( - "tst_tests", - array( - "starting_time" => array("text", $unix_start_time), - "ending_time" => array("text", $unix_end_time), - "reporting_date" => array("text", $unix_reporting_date), - "score_reporting" => array("integer", $this->getScoreReporting()), - 'char_selector_availability' => array('integer', (int)$this->getCharSelectorAvailability()), - 'char_selector_definition' => array('text', (string)$this->getCharSelectorDefinition()), - 'specific_feedback' => array('integer', (int)$this->getSpecificAnswerFeedback()), - 'answer_feedback' => array('text', $this->getGenericAnswerFeedback()), - 'answer_feedback_points' => array('text', $this->getAnswerFeedbackPoints()), - 'instant_verification' => array('text', $this->getInstantFeedbackSolution()), - 'skill_service' => array('integer', $this->isSkillServiceEnabled()) - ), - array('obj_fi' => array('integer', $this->getId())) - ); - - unset($tmp_obj); - - $this->db->update( - 'rep_robj_xtsf_data', - array( - 'lp_mode' => array('integer', $this->getLearningProgressMode()), - "is_online" => array("integer", $this->isOnline()), - "allow_walk_back" => array("integer", $this->isAllowWalkBack()), - "allow_interruption" => array("integer", $this->isAllowInterruption()), - "show_current_track" => array("integer", $this->getShowCurrentTrack()), - "max_passes" => array("integer", $this->getMaxPasses()), - "process_time" => array("integer", $this->getProcessTime()), - "intro_statement" => array("text", $this->getIntroStatement()), - "final_statement" => array("text", $this->getFinalStatement()), - "show_intro_statement" => array("integer", $this->getShowIntroStatement()), - "show_final_statement" => array("integer", $this->getShowFinalStatement()), - "show_questions_overview" => array("integer", $this->getShowQuestionsOverview()), - "node_fb_author" => array("integer", $this->getNodeFeedbackAuthor()), - "node_fb_part" => array("integer", $this->getNodeFeedbackParticipant()), - "node_fb_part_res" => array("integer", $this->getNodeFeedbackParticipantRes()) - ), - array( - 'id' => array('integer', $this->getId()) - ) - ); - - $this->updateMetaData(); - $this->logAction($this->plugin->txt("log_modified_test")); - } - - /** - * @return bool - */ - public function beforeDelete() - { - $this->getParticipants()->removeAll(); - $this->getSetList()->removeAll(); - - return true; - } - - /** - * Delete data from database - */ - public function doDelete() - { - try - { - $this->db->manipulate('DELETE FROM rep_robj_xtsf_data WHERE id = ' . $this->db->quote($this->getId(), 'integer')); - $this->db->manipulate('DELETE FROM tst_tests WHERE obj_fi = ' . $this->db->quote($this->getId(), 'integer')); - $this->mark_schema->flush(); - $this->mark_schema->saveToDb($this->getTestId()); - } - catch(Exception $e) - { - $this->log->write($e->getMessage()); - $this->log->logStack(); - } - } - - /** - * @param ilObjFormATest $new_obj - * @param int $a_target_id - * @param int $a_copy_id - */ - public function doCloneObject($new_obj, $a_target_id, $a_copy_id = NULL) - { - $res = $this->db->queryF( - 'SELECT * FROM rep_robj_xtsf_data WHERE id = %s', - array('integer'), - array($this->getId()) - ); - $row = $this->db->fetchAssoc($res); - - try - { - $res_tmp = $this->db->queryF('SELECT * FROM rep_robj_xtsf_data WHERE id = %s', - array('integer'), array($new_obj->getId())); - - $numrows = $this->db->numRows($res_tmp); - if($numrows == 1) - { - $this->db->update( - 'rep_robj_xtsf_data', - array( - 'lp_mode' => array('integer', $this->getLearningProgressMode()), - "is_online" => array("integer", $this->isOnline()), - "allow_walk_back" => array("integer", $this->isAllowWalkBack()), - "allow_interruption" => array("integer", $this->isAllowInterruption()), - "show_current_track" => array("integer", $this->getShowCurrentTrack()), - "max_passes" => array("integer", $this->getMaxPasses()), - "process_time" => array("integer", $this->getProcessTime()), - "intro_statement" => array("text", $this->getIntroStatement()), - "final_statement" => array("text", $this->getFinalStatement()), - "show_intro_statement" => array("integer", $this->getShowIntroStatement()), - "show_final_statement" => array("integer", $this->getShowFinalStatement()), - "show_questions_overview" => array("integer", $this->getShowQuestionsOverview()), - "node_fb_author" => array("integer", $this->getNodeFeedbackAuthor()), - "node_fb_part" => array("integer", $this->getNodeFeedbackParticipant()), - "node_fb_part_res" => array("integer", $this->getNodeFeedbackParticipantRes()) - ), - array('id' => array('integer', $new_obj->getId())) - ); - } - else if($numrows == 0) - { - $this->db->insert( - 'rep_robj_xtsf_data', - array( - 'id' => array('integer', $new_obj->getId()), - 'lp_mode' => array('integer', $row['lp_mode']), - "is_online" => array("integer", $row['is_online']), - "allow_walk_back" => array("integer", $row['allow_walk_back']), - "allow_interruption" => array("integer", $row['allow_interruption']), - "show_current_track" => array("integer", $row['show_current_track']), - "max_passes" => array("integer", $row['max_passes']), - "process_time" => array("integer", $row['process_time']), - "intro_statement" => array("text", $row['intro_statement']), - "final_statement" => array("text", $row['final_statement']), - "show_intro_statement" => array("integer", $row['show_intro_statement']), - "show_final_statement" => array("integer", $row['show_final_statement']), - "show_questions_overview" => array("integer", $this->getShowQuestionsOverview()) - ) - ); - } - - $res = $this->db->queryF( - 'SELECT * FROM tst_tests WHERE obj_fi = %s', - array('integer'), - array($this->getId()) - ); - $row = $this->db->fetchAssoc($res); - - $testId = $this->db->nextId('tst_tests'); - $this->db->insert( - 'tst_tests', - array( - 'test_id' => array('integer', $testId), - 'obj_fi' => array('integer', $new_obj->getId()), - 'author' => array('integer', $this->user->getFirstname() . ' ' . $this->user->getLastname()), - "starting_time" => array("text", $row['starting_time']), - "ending_time" => array("text", $row['ending_time']), - "reporting_date " => array("text", $row['reporting_date']), - "score_reporting" => array("text", $row['score_reporting']), - 'char_selector_availability' => array('integer', (int)$this->getCharSelectorAvailability()), - 'char_selector_definition' => array('text', (string)$this->getCharSelectorDefinition()), - - 'specific_feedback' => array('integer', (int)$this->getSpecificAnswerFeedback()), - 'answer_feedback' => array('text', $this->getGenericAnswerFeedback()), - 'answer_feedback_points' => array('text', $this->getAnswerFeedbackPoints()), - 'instant_verification' => array('text', $this->getInstantFeedbackSolution()), - 'skill_service' => array('integer', $this->isSkillServiceEnabled()) - ) - ); - - $set_data = $this->getSetList()->getData(); - - foreach($set_data as $item) - { - $new_obj->getSetList()->insert(array($item["id"])); - } - - // @todo: Clone mark schema - $this->cloneMetaData($new_obj); - } - catch(Exception $e) - { - //@todo: Handle Exception - $this->log->write($e->getMessage()); - $this->log->logStack(); - } - } - - /** - * Get all user ids with LP status completed - * @return array - */ - public function getLPCompleted() - { - if(in_array($this->getLearningProgressMode(), array(self::LP_MODE_DEACTIVATED))) - { - return array(); - } - - $user_ids = array(); - $passed_users = ilObjTestAccess::_getPassedUsers($this->getId()); - foreach((array)$passed_users as $user_data) - { - if($user_data['passed']) - { - $user_ids[] = $user_data['user_id']; - } - } - return $user_ids; - } - - /** - * Get all user ids with LP status not attempted - * @return array - */ - public function getLPNotAttempted() - { - return array(); - } - - /** - * Get all user ids with LP status failed - * @return array - */ - public function getLPFailed() - { - if(in_array($this->getLearningProgressMode(), array(self::LP_MODE_DEACTIVATED))) - { - return array(); - } - - $user_ids = array(); - $passed_users = ilObjTestAccess::_getPassedUsers($this->getId()); - foreach((array)$passed_users as $user_data) - { - if($user_data['failed']) - { - $user_ids[] = $user_data['user_id']; - } - } - return $user_ids; - } - - /** - * Get all user ids with LP status in progress - * @return array - */ - public function getLPInProgress() - { - if(in_array($this->getLearningProgressMode(), array(self::LP_MODE_DEACTIVATED))) - { - return array(); - } - - require_once 'Modules/Test/classes/class.ilObjTestAccess.php'; - $test_fi = ilObjTestAccess::_getTestIDFromObjectID($this->getId()); - $query = 'SELECT DISTINCT(user_fi) FROM tst_active WHERE test_fi = ' . $this->db->quote($test_fi, 'integer'); - - $user_ids = array(); - $res = $this->db->query($query); - while($row = $this->db->fetchAssoc($res)) - { - $user_ids[] = $row['user_fi']; - } - - $users = array_diff((array)$user_ids, $this->getLPCompleted()); - $users = array_diff((array)$users, $this->getLPFailed()); - return $users ? $users : array(); - } - - /** - * Get current status for given user - * @param int $a_user_id - * @return int - */ - public function getLPStatusForUser($a_user_id) - { - $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM; - - $res = $this->db->query( - 'SELECT tries + /** + * Get all user ids with LP status completed + * @return array + */ + public function getLPCompleted() + { + if (in_array($this->getLearningProgressMode(), array(self::LP_MODE_DEACTIVATED))) { + return array(); + } + + $user_ids = array(); + $passed_users = ilObjTestAccess::_getPassedUsers($this->getId()); + foreach ((array) $passed_users as $user_data) { + if ($user_data['passed']) { + $user_ids[] = $user_data['user_id']; + } + } + return $user_ids; + } + + /** + * Get all user ids with LP status not attempted + * @return array + */ + public function getLPNotAttempted() + { + return array(); + } + + /** + * Get all user ids with LP status failed + * @return array + */ + public function getLPFailed() + { + if (in_array($this->getLearningProgressMode(), array(self::LP_MODE_DEACTIVATED))) { + return array(); + } + + $user_ids = array(); + $passed_users = ilObjTestAccess::_getPassedUsers($this->getId()); + foreach ((array) $passed_users as $user_data) { + if ($user_data['failed']) { + $user_ids[] = $user_data['user_id']; + } + } + return $user_ids; + } + + /** + * Get all user ids with LP status in progress + * @return array + */ + public function getLPInProgress() + { + if (in_array($this->getLearningProgressMode(), array(self::LP_MODE_DEACTIVATED))) { + return array(); + } + + $test_fi = ilObjTestAccess::_getTestIDFromObjectID($this->getId()); + $query = 'SELECT DISTINCT(user_fi) FROM tst_active WHERE test_fi = ' . $this->db->quote($test_fi, 'integer'); + + $user_ids = array(); + $res = $this->db->query($query); + while ($row = $this->db->fetchAssoc($res)) { + $user_ids[] = $row['user_fi']; + } + + $users = array_diff((array) $user_ids, $this->getLPCompleted()); + $users = array_diff((array) $users, $this->getLPFailed()); + return $users ? $users : array(); + } + + /** + * Get current status for given user + * @param int $a_user_id + * @return int + */ + public function getLPStatusForUser($a_user_id) + { + $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM; + + $res = $this->db->query( + 'SELECT tries FROM tst_active WHERE user_fi = ' . $this->db->quote($a_user_id, 'integer') . ' AND test_fi = ' . $this->db->quote(ilObjTestAccess::_getTestIDFromObjectID($this->getId()), 'integer') - ); - - assQuestion::setResultGateway(new ilObjTestGateway()); - if($row = $this->db->fetchAssoc($res)) - { - if(ilObjTestAccess::_isPassed($a_user_id, $this->getId())) - { - $status = ilLPStatus::LP_STATUS_COMPLETED_NUM; - } - else - { - $status = ilLPStatus::LP_STATUS_FAILED_NUM; - } - } - assQuestion::setResultGateway(null); - return $status; - } - - /** - * @param int $a_user_id - * @return int - */ - public function getPercentageForUser($a_user_id) - { - $ilDB = $this->db; - - $set = $ilDB->query( - "SELECT tst_result_cache.*, tst_active.user_fi FROM " . - "tst_result_cache JOIN tst_active ON (tst_active.active_id = tst_result_cache.active_fi)" . - " JOIN tst_tests ON (tst_tests.test_id = tst_active.test_fi) " . - " WHERE tst_tests.obj_fi = " . $ilDB->quote($this->getId(), "integer") . - " AND tst_active.user_fi = " . $ilDB->quote($a_user_id, "integer")); - $per = 0; - if($rec = $ilDB->fetchAssoc($set)) - { - if($rec["max_points"] > 0) - { - $per = min(100, 100 / $rec["max_points"] * $rec["reached_points"]); - } - else - { - // According to mantis #12305 - $per = 0; - } - } - return (int)$per; - } - - /** - * @param int $learning_progress_mode - */ - public function setLearningProgressMode($learning_progress_mode) - { - $this->learning_progress_mode = $learning_progress_mode; - } - - /** - * @return int - */ - public function getLearningProgressMode() - { - return $this->learning_progress_mode; - } - - /** - * @return array - */ - public function getLPValidModes() - { - return array( - self::LP_MODE_DEACTIVATED, - self::LP_MODE_TEST_PASSED - ); - } - - /** - * @return int - */ - public function getDefaultMode() - { - return self::LP_MODE_DEACTIVATED; - } - - /** - * @param boolean $allow_interruption - */ - public function setAllowInterruption($allow_interruption) - { - $this->allow_interruption = $allow_interruption; - } - - /** - * @return boolean - */ - public function isAllowInterruption() - { - return $this->allow_interruption; - } - - /** - * @param boolean $allow_walk_back - */ - public function setAllowWalkBack($allow_walk_back) - { - $this->allow_walk_back = $allow_walk_back; - } - - /** - * @return boolean - */ - public function isAllowWalkBack() - { - return $this->allow_walk_back; - } - - /** - * @param int $max_passes - */ - public function setMaxPasses($max_passes) - { - $this->max_passes = $max_passes; - } - - /** - * @return int - */ - public function getMaxPasses() - { - return $this->max_passes; - } - - /** - * @param boolean $online - */ - public function setOnline($online) - { - $this->online = $online; - } - - /** - * @return boolean - */ - public function isOnline() - { - return $this->online; - } - - /** - * @param int $process_time - */ - public function setProcessTime($process_time) - { - $this->process_time = $process_time; - } - - /** - * @return int - */ - public function getProcessTime() - { - return $this->process_time; - } - - /** - * @param boolean $show_current_track - */ - public function setShowCurrentTrack($show_current_track) - { - $this->show_current_track = $show_current_track; - } - - /** - * @return boolean - */ - public function getShowCurrentTrack() - { - return $this->show_current_track; - } - - /** - * @param string $final_statement - */ - public function setFinalStatement($final_statement) - { - $this->final_statement = $final_statement; - } - - /** - * @return string - */ - public function getFinalStatement() - { - return $this->final_statement; - } - - /** - * @param string $intro_statement - */ - public function setIntroStatement($intro_statement) - { - $this->intro_statement = $intro_statement; - } - - /** - * @return string - */ - public function getIntroStatement() - { - return $this->intro_statement; - } - - /** - * @param boolean $show_final_statement - */ - public function setShowFinalStatement($show_final_statement) - { - $this->show_final_statement = $show_final_statement; - } - - /** - * @return boolean - */ - public function getShowFinalStatement() - { - return $this->show_final_statement; - } - - /** - * @param boolean $show_intro_statement - */ - public function setShowIntroStatement($show_intro_statement) - { - $this->show_intro_statement = $show_intro_statement; - } - - /** - * @return boolean - */ - public function getShowIntroStatement() - { - return $this->show_intro_statement; - } - - /** - * @param ilDateTime $end_time - */ - public function setEndTime($end_time) - { - $this->end_time = $end_time; - } - - /** - * @return ilDateTime - */ - public function getEndTime() - { - return $this->end_time; - } - - /** - * @param boolean $end_time_enabled - */ - public function setEndTimeEnabled($end_time_enabled) - { - $this->end_time_enabled = $end_time_enabled; - } - - /** - * @return boolean - */ - public function isEndTimeEnabled() - { - return $this->end_time_enabled; - } - - /** - * @param ilDateTime $start_time - */ - public function setStartTime($start_time) - { - $this->start_time = $start_time; - } - - /** - * @return ilDateTime - */ - public function getStartTime() - { - return $this->start_time; - } - - /** - * @param boolean $start_time_enabled - */ - public function setStartTimeEnabled($start_time_enabled) - { - $this->start_time_enabled = $start_time_enabled; - } - - /** - * @return boolean - */ - public function isStartTimeEnabled() - { - return $this->start_time_enabled; - } - - /** - * @return \ilFormATestParticipantsList - */ - public function getParticipants() - { - return $this->participants; - } - - /** - * @param boolean $show_questions_overview - */ - public function setShowQuestionsOverview($show_questions_overview) - { - $this->show_questions_overview = $show_questions_overview; - } - - /** - * @return boolean - */ - public function getShowQuestionsOverview() - { - return $this->show_questions_overview; - } - - /** - * @param int $score_reporting - */ - public function setScoreReporting($score_reporting) - { - $this->score_reporting = $score_reporting; - } - - /** - * @return int - */ - public function getScoreReporting() - { - return $this->score_reporting; - } - - /** - * @param \ilDateTime $reporting_date - */ - public function setReportingDate($reporting_date) - { - $this->reporting_date = $reporting_date; - } - - /** - * @return \ilDateTime - */ - public function getReportingDate() - { - return $this->reporting_date; - } - - /** - * @param int availability of the special character selector - */ - public function setCharSelectorAvailability($availability) - { - $this->char_selector_availability = (int)$availability; - } - - /** - * @return int availability of the special character selector - */ - public function getCharSelectorAvailability() - { - return (int)$this->char_selector_availability; - } - - /** - * @param string definition of the special character selector - */ - public function setCharSelectorDefinition($definition = '') - { - $this->char_selector_definition = $definition; - } - - /** - * @return string definition of the special character selector - */ - public function getCharSelectorDefinition() - { - return $this->char_selector_definition; - } - - /** - * @return array - */ - public function toArray() - { - require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php'; - $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_TEST); - $char_selector->getConfig()->setDefinition($this->getCharSelectorDefinition()); - $values = array( - "title" => $this->getTitle(), - "description" => $this->getDescription(), - "online" => $this->isOnline(), - "allow_walk_back" => $this->isAllowWalkBack(), - "allow_interruption" => $this->isAllowInterruption(), - "max_passes" => $this->getMaxPasses(), - "process_time" => $this->getProcessTime(), - "show_current_track" => $this->getShowCurrentTrack(), - "intro_statement" => $this->getIntroStatement(), - "final_statement" => $this->getFinalStatement(), - "show_intro_statement" => $this->getShowIntroStatement(), - "show_final_statement" => $this->getShowFinalStatement(), - "enable_start_time" => $this->isStartTimeEnabled(), - "enable_end_time" => $this->isEndTimeEnabled(), - "show_questions_overview" => $this->getShowQuestionsOverview(), - "score_reporting" => $this->getScoreReporting(), - 'char_selector_availability' => (int)$this->getCharSelectorAvailability(), - 'char_selector_blocks' => $char_selector->getConfig()->getAddedBlocks(), - 'char_selector_custom_items' => $char_selector->getConfig()->getCustomItems(), - 'skill_service' => $this->isSkillServiceEnabled(), - ); - - if($this->getAnswerFeedbackPoints()) - { - $values['instant_feedback'][] = 'instant_feedback_points'; - } - if($this->getGenericAnswerFeedback()) - { - $values['instant_feedback'][] = 'instant_feedback_generic' ; - } - if($this->getInstantFeedbackSolution()) - { - $values['instant_feedback'][] = 'instant_feedback_solution'; - } - if($this->getSpecificAnswerFeedback()) - { - $values['instant_feedback'][] = 'instant_feedback_specific'; - } - - if($this->getNodeFeedbackAuthor()) - { - $values['node_feedback'][] ='node_feedback_author'; - } - if($this->getNodeFeedbackParticipant()) - { - $values['node_feedback'][] ='node_feedback_part'; - } - - if($this->getNodeFeedbackParticipantRes()) - { - $values['node_feedback'][] ='node_feedback_part_res'; - } - - if($this->getStartTime() != null) - { - $values["start_time"] = $this->getStartTime(); - } - if($this->getEndTime() != null) - { - $values["end_time"] = $this->getEndTime(); - } - if($this->getReportingDate() != null) - { - $values["reporting_date"] = $this->getReportingDate(); - } - - return $values; - } - - /** - * @param ilPropertyFormGUI $form - */ - public function bindForm(ilPropertyFormGUI $form) - { - global $DIC; - $ilSetting = $DIC->settings(); - - if($form->getItemByPostVar("title")) - { - $this->setTitle($form->getInput('title')); - $this->setDescription($form->getInput('description')); - $this->setOnline($form->getInput('online')); - $this->setMaxPasses($form->getInput('max_passes')); - $this->setProcessTime($form->getInput('process_time')); - $this->setAllowInterruption($form->getInput('allow_interruption')); - $this->setAllowWalkBack($form->getInput('allow_walk_back')); - $this->setIntroStatement($form->getInput('intro_statement')); - $this->setFinalStatement($form->getInput('final_statement')); - $this->setShowFinalStatement((bool)$form->getInput('show_final_statement')); - $this->setShowIntroStatement((bool)$form->getInput('show_intro_statement')); - $this->setSkillServiceEnabled((bool)$form->getInput('skill_service')); - - // Selector for uicode characters - if($ilSetting->get('char_selector_availability') > 0) - { - require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php'; - $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_TEST); - $char_selector->addFormProperties($form); - $char_selector->getFormValues($form); - $this->setCharSelectorAvailability($char_selector->getConfig()->getAvailability()); - $this->setCharSelectorDefinition($char_selector->getConfig()->getDefinition()); - } - } - - $options = array(); - if(is_array( $form->getInput('instant_feedback'))) - { - $options = $form->getInput('instant_feedback'); - } - $this->setScoringFeedbackOptionsByArray($options); - - $node_options = array(); - if(is_array($form->getInput('node_feedback'))) - { - $node_options = $form->getInput('node_feedback'); - } - $this->setNodeFeedbackOptionsByArray($node_options); - - if($form->getItemByPostVar("show_current_track")) - { - $this->setShowCurrentTrack($form->getInput('show_current_track')); - } - if($form->getItemByPostVar("show_questions_overview")) - { - $this->setShowQuestionsOverview($form->getInput('show_questions_overview')); - } - - if($form->getItemByPostVar("enable_start_time")) - { - $this->setStartTimeEnabled($form->getInput("enable_start_time")); - if($form->getInput("enable_start_time")) - { - $this->setStartTime($form->getItemByPostVar('start_time')->getDate()); - } - else - { - $this->setStartTime(null); - } - } - - if($form->getItemByPostVar("enable_end_time")) - { - $this->setEndTimeEnabled($form->getInput("enable_end_time")); - if($form->getInput("enable_end_time")) - { - $this->setEndTime($form->getItemByPostVar('end_time')->getDate()); - } - else - { - $this->setEndTime(null); - } - } - - if($form->getItemByPostVar("reporting_date")) - { - if($form->getInput("reporting_date")) - { - $this->setReportingDate($form->getItemByPostVar('reporting_date')->getDate()); - } - else - { - $this->setReportingDate(null); - } - } - - if($form->getItemByPostVar("score_reporting")) - { - $this->setScoreReporting($form->getInput("score_reporting")); - } - } - - /** - * @param int $obj_id - * @return bool - */ - public static function getOnlineStatusByObjId($obj_id) - { - if(!isset(self::$online_status_map[$obj_id])) - { - self::preloadDataForLists(array($obj_id)); - } - - return (bool)self::$online_status_map[$obj_id]; - - } - - /** - * @param array $obj_ids - * @param array $ref_ids - */ - public static function preloadDataForLists(array $obj_ids, array $ref_ids = array()) - { - global $DIC; - $ilDB = $DIC->database(); - - if(is_array($obj_ids) && count($obj_ids) == 1) - { - $in = ' id = ' . $ilDB->quote(current($obj_ids), 'integer') . ' '; - } - else - { - $in = $ilDB->in('id', $obj_ids, false, 'integer'); - } - - $query = 'SELECT id, is_online FROM rep_robj_xtsf_data WHERE ' . $in; - $res = $ilDB->query($query); - - while($row = $ilDB->fetchAssoc($res)) - { - self::$online_status_map[$row['id']] = $row['is_online']; - } - } - - /** - * @param string $logtext - * @param string|int $set_id - */ - public function logAction($logtext = "", $set_id = "") - { - if(ilObjAssessmentFolder::_enabledAssessmentLogging()) - { - $ilUser = $this->user; - - $original_id = ""; - if(strcmp($set_id, "") != 0) - { - include_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/models/class.ilQuestionSetPoolSet.php"; - $set = new ilQuestionSetPoolSet($set_id); - $set->read(); - $original_id = $set->getOriginalId(); - } - ilObjAssessmentFolder::_addLog($ilUser->getId(), $this->getId(), $logtext, $set_id, $original_id, TRUE, $this->getRefId()); - } - } - - /** - * @return bool - */ - final public function isComplete() - { - if(is_array($this->mark_schema->mark_steps) && !count($this->mark_schema->mark_steps)) - { - return false; - } - - if(is_array($this->getSetList()->getData())) - return count((array)$this->getSetList()->getData()) > 0; - } - - public function setSpecificAnswerFeedback($specific_answer_feedback) - { - switch($specific_answer_feedback) - { - case 1: - $this->specific_answer_feedback = 1; - break; - default: - $this->specific_answer_feedback = 0; - break; - } - } - - public function getSpecificAnswerFeedback() - { - switch($this->specific_answer_feedback) - { - case 1: - return 1; - default: - return 0; - } - } - - function setGenericAnswerFeedback($generic_answer_feedback = 0) - { - switch($generic_answer_feedback) - { - case 1: - $this->answer_feedback = 1; - break; - default: - $this->answer_feedback = 0; - break; - } - } - - public function getGenericAnswerFeedback() - { - return ($this->answer_feedback) ? $this->answer_feedback : 0; - } - - function setAnswerFeedbackPoints($answer_feedback_points = 0) - { - switch($answer_feedback_points) - { - case 1: - $this->answer_feedback_points = 1; - break; - default: - $this->answer_feedback_points = 0; - break; - } - } - - function getAnswerFeedbackPoints() - { - return ($this->answer_feedback_points) ? $this->answer_feedback_points : 0; - } - - function setInstantFeedbackSolution($instant_feedback = 0) - { - switch($instant_feedback) - { - case 1: - $this->instant_verification = 1; - break; - default: - $this->instant_verification = 0; - break; - } - } - - function getInstantFeedbackSolution() - { - return ($this->instant_verification) ? $this->instant_verification : 0; - } - - public function setScoringFeedbackOptionsByArray($options) - { - if (is_array($options)) - { - $this->setGenericAnswerFeedback( in_array('instant_feedback_generic', $options) ? 1 : 0); - $this->setSpecificAnswerFeedback( in_array('instant_feedback_specific', $options) ? 1 : 0); - $this->setAnswerFeedbackPoints( in_array('instant_feedback_points', $options) ? 1 : 0); - $this->setInstantFeedbackSolution( in_array('instant_feedback_solution', $options) ? 1 : 0); - } - else - { - $this->setGenericAnswerFeedback(0); - $this->setSpecificAnswerFeedback(0); - $this->setAnswerFeedbackPoints(0); - $this->setInstantFeedbackSolution(0); - } - } - - public function getInstantFeedbackSessionKey() - { - return 'xtsf_' . $this->getId() . '_is_instant_fb_requested'; - } - - /** - * @return ASS_MarkSchema - */ - public function getMarkSchema() - { - return $this->mark_schema; - } - - /** - * @return boolean|string True or an error string which can be used for display purposes - */ - public function checkMarks() - { - return $this->mark_schema->checkMarks(); - } - - /** - * @return boolean - */ - public function canEditMarks() - { - return !$this->getParticipants()->hasParticipants(); - } - - /** - * @return int - */ - public function getMarkSchemaForeignId() - { - return $this->getTestId(); - } - - /** - * - */ - public function onMarkSchemaSaved() - { - } - - /** - * @return int - */ - public function getNodeFeedbackAuthor() - { - return (int)$this->node_feedback_author; - } - - /** - * @param int $node_feedback_author - */ - public function setNodeFeedbackAuthor($node_feedback_author) - { - $this->node_feedback_author = $node_feedback_author; - } - - /** - * @return int - */ - public function getNodeFeedbackParticipant() - { - return (int)$this->node_feedback_participant; - } - - /** - * @param int $node_feedback_participants - */ - public function setNodeFeedbackParticipant($node_feedback_participant) - { - $this->node_feedback_participant = (int)$node_feedback_participant; - } - - /** - * @return int - */ - public function getNodeFeedbackParticipantRes() - { - return $this->node_feedback_participant_res; - } - - /** - * @param int $node_feedback_participant_res - */ - public function setNodeFeedbackParticipantRes($node_feedback_participant_res) - { - $this->node_feedback_participant_res = $node_feedback_participant_res; - } - - /** - * @param $node_options - */ - protected function setNodeFeedbackOptionsByArray($node_options) - { - if (is_array($node_options)) - { - $this->setNodeFeedbackAuthor( in_array('node_feedback_author', $node_options) ? 1 : 0); - $this->setNodeFeedbackParticipant( in_array('node_feedback_part', $node_options) ? 1 : 0); - $this->setNodeFeedbackParticipantRes( in_array('node_feedback_part_res', $node_options) ? 1 : 0); - } - else - { - $this->setNodeFeedbackAuthor(0); - $this->setNodeFeedbackParticipant(0); - $this->setNodeFeedbackParticipantRes(0); - } - } - - public static function deleteFeedback($node_index, $set_id, $session_id) - { - global $DIC; - $ilDB = $DIC->database(); - - $ilDB->manipulateF('DELETE FROM rep_robj_xtsf_fbt + ); + + assQuestion::setResultGateway(new ilObjTestGateway()); + if ($row = $this->db->fetchAssoc($res)) { + if (ilObjTestAccess::_isPassed($a_user_id, $this->getId())) { + $status = ilLPStatus::LP_STATUS_COMPLETED_NUM; + } else { + $status = ilLPStatus::LP_STATUS_FAILED_NUM; + } + } + assQuestion::setResultGateway(null); + return $status; + } + + /** + * @param int $a_user_id + * @return int + */ + public function getPercentageForUser($a_user_id) + { + $ilDB = $this->db; + + $set = $ilDB->query( + "SELECT tst_result_cache.*, tst_active.user_fi FROM " . + "tst_result_cache JOIN tst_active ON (tst_active.active_id = tst_result_cache.active_fi)" . + " JOIN tst_tests ON (tst_tests.test_id = tst_active.test_fi) " . + " WHERE tst_tests.obj_fi = " . $ilDB->quote($this->getId(), "integer") . + " AND tst_active.user_fi = " . $ilDB->quote($a_user_id, "integer") + ); + $per = 0; + if ($rec = $ilDB->fetchAssoc($set)) { + if ($rec["max_points"] > 0) { + $per = min(100, 100 / $rec["max_points"] * $rec["reached_points"]); + } else { + // According to mantis #12305 + $per = 0; + } + } + return (int) $per; + } + + /** + * @param int $learning_progress_mode + */ + public function setLearningProgressMode($learning_progress_mode) + { + $this->learning_progress_mode = $learning_progress_mode; + } + + /** + * @return int + */ + public function getLearningProgressMode() + { + return $this->learning_progress_mode; + } + + /** + * @return array + */ + public function getLPValidModes() + { + return array( + self::LP_MODE_DEACTIVATED, + self::LP_MODE_TEST_PASSED + ); + } + + /** + * @return int + */ + public function getDefaultMode() + { + return self::LP_MODE_DEACTIVATED; + } + + /** + * @param boolean $allow_interruption + */ + public function setAllowInterruption($allow_interruption) + { + $this->allow_interruption = $allow_interruption; + } + + /** + * @return boolean + */ + public function isAllowInterruption() + { + return $this->allow_interruption; + } + + /** + * @param boolean $allow_walk_back + */ + public function setAllowWalkBack($allow_walk_back) + { + $this->allow_walk_back = $allow_walk_back; + } + + /** + * @return boolean + */ + public function isAllowWalkBack() + { + return $this->allow_walk_back; + } + + /** + * @param int $max_passes + */ + public function setMaxPasses($max_passes) + { + $this->max_passes = $max_passes; + } + + /** + * @return int + */ + public function getMaxPasses() + { + return $this->max_passes; + } + + /** + * @param boolean $online + */ + public function setOnline($online) + { + $this->online = $online; + } + + /** + * @return boolean + */ + public function isOnline() + { + return $this->online; + } + + /** + * @param int $process_time + */ + public function setProcessTime($process_time) + { + $this->process_time = $process_time; + } + + /** + * @return int + */ + public function getProcessTime() + { + return $this->process_time; + } + + /** + * @param boolean $show_current_track + */ + public function setShowCurrentTrack($show_current_track) + { + $this->show_current_track = $show_current_track; + } + + /** + * @return boolean + */ + public function getShowCurrentTrack() + { + return $this->show_current_track; + } + + /** + * @param string $final_statement + */ + public function setFinalStatement($final_statement) + { + $this->final_statement = $final_statement; + } + + /** + * @return string + */ + public function getFinalStatement() + { + return $this->final_statement; + } + + /** + * @param string $intro_statement + */ + public function setIntroStatement($intro_statement) + { + $this->intro_statement = $intro_statement; + } + + /** + * @return string + */ + public function getIntroStatement() + { + return $this->intro_statement; + } + + /** + * @param boolean $show_final_statement + */ + public function setShowFinalStatement($show_final_statement) + { + $this->show_final_statement = $show_final_statement; + } + + /** + * @return boolean + */ + public function getShowFinalStatement() + { + return $this->show_final_statement; + } + + /** + * @param boolean $show_intro_statement + */ + public function setShowIntroStatement($show_intro_statement) + { + $this->show_intro_statement = $show_intro_statement; + } + + /** + * @return boolean + */ + public function getShowIntroStatement() + { + return $this->show_intro_statement; + } + + /** + * @param ilDateTime $end_time + */ + public function setEndTime($end_time) + { + $this->end_time = $end_time; + } + + /** + * @return ilDateTime + */ + public function getEndTime() + { + return $this->end_time; + } + + /** + * @param boolean $end_time_enabled + */ + public function setEndTimeEnabled($end_time_enabled) + { + $this->end_time_enabled = $end_time_enabled; + } + + /** + * @return boolean + */ + public function isEndTimeEnabled() + { + return $this->end_time_enabled; + } + + /** + * @param ilDateTime $start_time + */ + public function setStartTime($start_time) + { + $this->start_time = $start_time; + } + + /** + * @return ilDateTime + */ + public function getStartTime() + { + return $this->start_time; + } + + /** + * @param boolean $start_time_enabled + */ + public function setStartTimeEnabled($start_time_enabled) + { + $this->start_time_enabled = $start_time_enabled; + } + + /** + * @return boolean + */ + public function isStartTimeEnabled() + { + return $this->start_time_enabled; + } + + /** + * @return \ilFormATestParticipantsList + */ + public function getParticipants() + { + return $this->participants; + } + + /** + * @param boolean $show_questions_overview + */ + public function setShowQuestionsOverview($show_questions_overview) + { + $this->show_questions_overview = $show_questions_overview; + } + + /** + * @return boolean + */ + public function getShowQuestionsOverview() + { + return $this->show_questions_overview; + } + + /** + * @param int $score_reporting + */ + public function setScoreReporting($score_reporting) + { + $this->score_reporting = $score_reporting; + } + + /** + * @return int + */ + public function getScoreReporting() + { + return $this->score_reporting; + } + + /** + * @param \ilDateTime $reporting_date + */ + public function setReportingDate($reporting_date) + { + $this->reporting_date = $reporting_date; + } + + /** + * @return \ilDateTime + */ + public function getReportingDate() + { + return $this->reporting_date; + } + + /** + * @param int availability of the special character selector + */ + public function setCharSelectorAvailability($availability) + { + $this->char_selector_availability = (int) $availability; + } + + /** + * @return int availability of the special character selector + */ + public function getCharSelectorAvailability() + { + return (int) $this->char_selector_availability; + } + + /** + * @param string definition of the special character selector + */ + public function setCharSelectorDefinition($definition = '') + { + $this->char_selector_definition = $definition; + } + + /** + * @return string definition of the special character selector + */ + public function getCharSelectorDefinition() + { + return $this->char_selector_definition; + } + + /** + * @return array + */ + public function toArray() + { + $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_TEST); + $char_selector->getConfig()->setDefinition($this->getCharSelectorDefinition()); + $values = array( + "title" => $this->getTitle(), + "description" => $this->getDescription(), + "online" => $this->isOnline(), + "allow_walk_back" => $this->isAllowWalkBack(), + "allow_interruption" => $this->isAllowInterruption(), + "max_passes" => $this->getMaxPasses(), + "process_time" => $this->getProcessTime(), + "show_current_track" => $this->getShowCurrentTrack(), + "intro_statement" => $this->getIntroStatement(), + "final_statement" => $this->getFinalStatement(), + "show_intro_statement" => $this->getShowIntroStatement(), + "show_final_statement" => $this->getShowFinalStatement(), + "enable_start_time" => $this->isStartTimeEnabled(), + "enable_end_time" => $this->isEndTimeEnabled(), + "show_questions_overview" => $this->getShowQuestionsOverview(), + "score_reporting" => $this->getScoreReporting(), + 'char_selector_availability' => (int) $this->getCharSelectorAvailability(), + 'char_selector_blocks' => $char_selector->getConfig()->getAddedBlocks(), + 'char_selector_custom_items' => $char_selector->getConfig()->getCustomItems(), + 'skill_service' => $this->isSkillServiceEnabled(), + ); + + if ($this->getAnswerFeedbackPoints()) { + $values['instant_feedback'][] = 'instant_feedback_points'; + } + if ($this->getGenericAnswerFeedback()) { + $values['instant_feedback'][] = 'instant_feedback_generic' ; + } + if ($this->getInstantFeedbackSolution()) { + $values['instant_feedback'][] = 'instant_feedback_solution'; + } + if ($this->getSpecificAnswerFeedback()) { + $values['instant_feedback'][] = 'instant_feedback_specific'; + } + + if ($this->getNodeFeedbackAuthor()) { + $values['node_feedback'][] = 'node_feedback_author'; + } + if ($this->getNodeFeedbackParticipant()) { + $values['node_feedback'][] = 'node_feedback_part'; + } + + if ($this->getNodeFeedbackParticipantRes()) { + $values['node_feedback'][] = 'node_feedback_part_res'; + } + + if ($this->getStartTime() != null) { + $values["start_time"] = $this->getStartTime(); + } + if ($this->getEndTime() != null) { + $values["end_time"] = $this->getEndTime(); + } + if ($this->getReportingDate() != null) { + $values["reporting_date"] = $this->getReportingDate(); + } + + return $values; + } + + /** + * @param ilPropertyFormGUI $form + */ + public function bindForm(ilPropertyFormGUI $form) + { + global $DIC; + $ilSetting = $DIC->settings(); + + if ($form->getItemByPostVar("title")) { + $this->setTitle($form->getInput('title')); + $this->setDescription($form->getInput('description')); + $this->setOnline($form->getInput('online')); + $this->setMaxPasses($form->getInput('max_passes')); + $this->setProcessTime($form->getInput('process_time')); + $this->setAllowInterruption($form->getInput('allow_interruption')); + $this->setAllowWalkBack($form->getInput('allow_walk_back')); + $this->setIntroStatement($form->getInput('intro_statement')); + $this->setFinalStatement($form->getInput('final_statement')); + $this->setShowFinalStatement((bool) $form->getInput('show_final_statement')); + $this->setShowIntroStatement((bool) $form->getInput('show_intro_statement')); + $this->setSkillServiceEnabled((bool) $form->getInput('skill_service')); + + // Selector for uicode characters + if ($ilSetting->get('char_selector_availability') > 0) { + $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_TEST); + $char_selector->addFormProperties($form); + $char_selector->getFormValues($form); + $this->setCharSelectorAvailability($char_selector->getConfig()->getAvailability()); + $this->setCharSelectorDefinition($char_selector->getConfig()->getDefinition()); + } + } + + $options = array(); + if (is_array($form->getInput('instant_feedback'))) { + $options = $form->getInput('instant_feedback'); + } + $this->setScoringFeedbackOptionsByArray($options); + + $node_options = array(); + if (is_array($form->getInput('node_feedback'))) { + $node_options = $form->getInput('node_feedback'); + } + $this->setNodeFeedbackOptionsByArray($node_options); + + if ($form->getItemByPostVar("show_current_track")) { + $this->setShowCurrentTrack($form->getInput('show_current_track')); + } + if ($form->getItemByPostVar("show_questions_overview")) { + $this->setShowQuestionsOverview($form->getInput('show_questions_overview')); + } + + if ($form->getItemByPostVar("enable_start_time")) { + $this->setStartTimeEnabled($form->getInput("enable_start_time")); + if ($form->getInput("enable_start_time")) { + $this->setStartTime($form->getItemByPostVar('start_time')->getDate()); + } else { + $this->setStartTime(null); + } + } + + if ($form->getItemByPostVar("enable_end_time")) { + $this->setEndTimeEnabled($form->getInput("enable_end_time")); + if ($form->getInput("enable_end_time")) { + $this->setEndTime($form->getItemByPostVar('end_time')->getDate()); + } else { + $this->setEndTime(null); + } + } + + if ($form->getItemByPostVar("reporting_date")) { + if ($form->getInput("reporting_date")) { + $this->setReportingDate($form->getItemByPostVar('reporting_date')->getDate()); + } else { + $this->setReportingDate(null); + } + } + + if ($form->getItemByPostVar("score_reporting")) { + $this->setScoreReporting($form->getInput("score_reporting")); + } + } + + /** + * @param int $obj_id + * @return bool + */ + public static function getOnlineStatusByObjId($obj_id) + { + if (!isset(self::$online_status_map[$obj_id])) { + self::preloadDataForLists(array($obj_id)); + } + + return (bool) self::$online_status_map[$obj_id]; + } + + /** + * @param array $obj_ids + * @param array $ref_ids + */ + public static function preloadDataForLists(array $obj_ids, array $ref_ids = array()) + { + global $DIC; + $ilDB = $DIC->database(); + + if (is_array($obj_ids) && count($obj_ids) == 1) { + $in = ' id = ' . $ilDB->quote(current($obj_ids), 'integer') . ' '; + } else { + $in = $ilDB->in('id', $obj_ids, false, 'integer'); + } + + $query = 'SELECT id, is_online FROM rep_robj_xtsf_data WHERE ' . $in; + $res = $ilDB->query($query); + + while ($row = $ilDB->fetchAssoc($res)) { + self::$online_status_map[$row['id']] = $row['is_online']; + } + } + + /** + * @param string $logtext + * @param string|int $set_id + */ + public function logAction($logtext = "", $set_id = "") + { + if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { + $ilUser = $this->user; + + $original_id = ""; + if (strcmp($set_id, "") != 0) { + include_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/models/class.ilQuestionSetPoolSet.php"; + $set = new ilQuestionSetPoolSet($set_id); + $set->read(); + $original_id = $set->getOriginalId(); + } + ilObjAssessmentFolder::_addLog($ilUser->getId(), $this->getId(), $logtext, $set_id, $original_id, true, $this->getRefId()); + } + } + + /** + * @return bool + */ + final public function isComplete() + { + if (is_array($this->mark_schema->mark_steps) && !count($this->mark_schema->mark_steps)) { + return false; + } + + if (is_array($this->getSetList()->getData())) { + return count((array) $this->getSetList()->getData()) > 0; + } + } + + public function setSpecificAnswerFeedback($specific_answer_feedback) + { + switch ($specific_answer_feedback) { + case 1: + $this->specific_answer_feedback = 1; + break; + default: + $this->specific_answer_feedback = 0; + break; + } + } + + public function getSpecificAnswerFeedback() + { + switch ($this->specific_answer_feedback) { + case 1: + return 1; + default: + return 0; + } + } + + public function setGenericAnswerFeedback($generic_answer_feedback = 0) + { + switch ($generic_answer_feedback) { + case 1: + $this->answer_feedback = 1; + break; + default: + $this->answer_feedback = 0; + break; + } + } + + public function getGenericAnswerFeedback() + { + return ($this->answer_feedback) ? $this->answer_feedback : 0; + } + + public function setAnswerFeedbackPoints($answer_feedback_points = 0) + { + switch ($answer_feedback_points) { + case 1: + $this->answer_feedback_points = 1; + break; + default: + $this->answer_feedback_points = 0; + break; + } + } + + public function getAnswerFeedbackPoints() + { + return ($this->answer_feedback_points) ? $this->answer_feedback_points : 0; + } + + public function setInstantFeedbackSolution($instant_feedback = 0) + { + switch ($instant_feedback) { + case 1: + $this->instant_verification = 1; + break; + default: + $this->instant_verification = 0; + break; + } + } + + public function getInstantFeedbackSolution() + { + return ($this->instant_verification) ? $this->instant_verification : 0; + } + + public function setScoringFeedbackOptionsByArray($options) + { + if (is_array($options)) { + $this->setGenericAnswerFeedback(in_array('instant_feedback_generic', $options) ? 1 : 0); + $this->setSpecificAnswerFeedback(in_array('instant_feedback_specific', $options) ? 1 : 0); + $this->setAnswerFeedbackPoints(in_array('instant_feedback_points', $options) ? 1 : 0); + $this->setInstantFeedbackSolution(in_array('instant_feedback_solution', $options) ? 1 : 0); + } else { + $this->setGenericAnswerFeedback(0); + $this->setSpecificAnswerFeedback(0); + $this->setAnswerFeedbackPoints(0); + $this->setInstantFeedbackSolution(0); + } + } + + public function getInstantFeedbackSessionKey() + { + return 'xtsf_' . $this->getId() . '_is_instant_fb_requested'; + } + + /** + * @return ASS_MarkSchema + */ + public function getMarkSchema() + { + return $this->mark_schema; + } + + /** + * @return boolean|string True or an error string which can be used for display purposes + */ + public function checkMarks() + { + return $this->mark_schema->checkMarks(); + } + + /** + * @return boolean + */ + public function canEditMarks() + { + return !$this->getParticipants()->hasParticipants(); + } + + /** + * @return int + */ + public function getMarkSchemaForeignId() + { + return $this->getTestId(); + } + + /** + * + */ + public function onMarkSchemaSaved() + { + } + + /** + * @return int + */ + public function getNodeFeedbackAuthor() + { + return (int) $this->node_feedback_author; + } + + /** + * @param int $node_feedback_author + */ + public function setNodeFeedbackAuthor($node_feedback_author) + { + $this->node_feedback_author = $node_feedback_author; + } + + /** + * @return int + */ + public function getNodeFeedbackParticipant() + { + return (int) $this->node_feedback_participant; + } + + /** + * @param int $node_feedback_participants + */ + public function setNodeFeedbackParticipant($node_feedback_participant) + { + $this->node_feedback_participant = (int) $node_feedback_participant; + } + + /** + * @return int + */ + public function getNodeFeedbackParticipantRes() + { + return $this->node_feedback_participant_res; + } + + /** + * @param int $node_feedback_participant_res + */ + public function setNodeFeedbackParticipantRes($node_feedback_participant_res) + { + $this->node_feedback_participant_res = $node_feedback_participant_res; + } + + /** + * @param $node_options + */ + protected function setNodeFeedbackOptionsByArray($node_options) + { + if (is_array($node_options)) { + $this->setNodeFeedbackAuthor(in_array('node_feedback_author', $node_options) ? 1 : 0); + $this->setNodeFeedbackParticipant(in_array('node_feedback_part', $node_options) ? 1 : 0); + $this->setNodeFeedbackParticipantRes(in_array('node_feedback_part_res', $node_options) ? 1 : 0); + } else { + $this->setNodeFeedbackAuthor(0); + $this->setNodeFeedbackParticipant(0); + $this->setNodeFeedbackParticipantRes(0); + } + } + + public static function deleteFeedback($node_index, $set_id, $session_id) + { + global $DIC; + $ilDB = $DIC->database(); + + $ilDB->manipulateF( + 'DELETE FROM rep_robj_xtsf_fbt WHERE step >= %s AND set_id = %s AND session_id = %s', - array('integer', 'integer', 'integer'), array($node_index, $set_id, $session_id)); - } - - /** - * @param array $data - */ - public static function updateConditionEvaluation(array $data) - { - global $DIC; - $ilDB = $DIC->database(); - - $node = $data['node']; - $node_index = $data['node_index']; - - $session = $data['session']; - $feedback_type = $data['feedback_type']; - $condition_id = $data['condition_id']; - $set_id = $session->getSetId(); - - if($condition_id > 0) - { - // jump == true - $res = $ilDB->queryF(' + array('integer', 'integer', 'integer'), + array($node_index, $set_id, $session_id) + ); + } + + /** + * @param array $data + */ + public static function updateConditionEvaluation(array $data) + { + global $DIC; + $ilDB = $DIC->database(); + + $node = $data['node']; + $node_index = $data['node_index']; + + $session = $data['session']; + $feedback_type = $data['feedback_type']; + $condition_id = $data['condition_id']; + $set_id = $session->getSetId(); + + if ($condition_id > 0) { + // jump == true + $res = $ilDB->queryF( + ' SELECT * FROM rep_robj_xtsf_fbt WHERE session_id = %s AND step = %s AND feedback_type = %s AND condition_id = %s', - array('integer', 'integer', 'integer', 'integer'), - array($session->getSessionId(), $node_index, $feedback_type, $condition_id) - ); - } - else - { - $res = $ilDB->queryF(' + array('integer', 'integer', 'integer', 'integer'), + array($session->getSessionId(), $node_index, $feedback_type, $condition_id) + ); + } else { + $res = $ilDB->queryF( + ' SELECT * FROM rep_robj_xtsf_fbt WHERE session_id = %s AND step = %s AND node_id = %s AND feedback_type = %s', - array('integer', 'integer', 'integer', 'integer'), - array($session->getSessionId(), $node_index, $node->getId(), $feedback_type) - ); - } - - $numrows = $ilDB->numRows($res); - - if(!$numrows) - { - $fbt_time = time(); - - $next_id = $ilDB->nextId('rep_robj_xtsf_fbt'); - $ilDB->insert('rep_robj_xtsf_fbt', - array( - 'fbt_id' => array('integer', $next_id), - 'session_id' => array('integer', $session->getSessionId()), - 'step' => array('integer', $node_index), - 'node_id' => array('integer', $node->getId()), - 'set_id' => array('integer', $set_id), - 'condition_id' => array('integer', $condition_id), - 'feedback_type' => array('integer', $feedback_type), - 'fbt_time' => array('integer', $fbt_time) - )); - } -// // lösche feebacks die wegen einer Sprungcondition nicht mehr benötigt werden. - /*$ilDB->manipulateF('DELETE FROM rep_robj_xtsf_fbt - WHERE step >= %s - AND node_id <> %s - AND session_id = %s', - array('integer', 'integer', 'integer'), array($node_index, $node->getId(), $session->getSessionId()));*/ - } - - /** - * @param integer $session_id - * @param integer $set_id - * @param integer $node_id - * @return array with strings - */ - public function getNodeFeedbacks($session_id, $set_id, $node_id, $step) - { - global $DIC; - $ilDB = $DIC->database(); - - $feedbacks = array(); - - $res = $ilDB->queryF(" + array('integer', 'integer', 'integer', 'integer'), + array($session->getSessionId(), $node_index, $node->getId(), $feedback_type) + ); + } + + $numrows = $ilDB->numRows($res); + + if (!$numrows) { + $fbt_time = time(); + + $next_id = $ilDB->nextId('rep_robj_xtsf_fbt'); + $ilDB->insert( + 'rep_robj_xtsf_fbt', + array( + 'fbt_id' => array('integer', $next_id), + 'session_id' => array('integer', $session->getSessionId()), + 'step' => array('integer', $node_index), + 'node_id' => array('integer', $node->getId()), + 'set_id' => array('integer', $set_id), + 'condition_id' => array('integer', $condition_id), + 'feedback_type' => array('integer', $feedback_type), + 'fbt_time' => array('integer', $fbt_time) + ) + ); + } + // // lösche feebacks die wegen einer Sprungcondition nicht mehr benötigt werden. + /*$ilDB->manipulateF('DELETE FROM rep_robj_xtsf_fbt + WHERE step >= %s + AND node_id <> %s + AND session_id = %s', + array('integer', 'integer', 'integer'), array($node_index, $node->getId(), $session->getSessionId()));*/ + } + + /** + * @param integer $session_id + * @param integer $set_id + * @param integer $node_id + * @return array with strings + */ + public function getNodeFeedbacks($session_id, $set_id, $node_id, $step) + { + global $DIC; + $ilDB = $DIC->database(); + + $feedbacks = array(); + + $res = $ilDB->queryF( + " (SELECT fbt.fbt_id, fbt.step, fbt.feedback_type, @@ -1725,124 +1630,122 @@ class ilObjFormATest extends ilObjectPlugin implements ilLPStatusPluginInterface AND step = %s ) ORDER BY fbt_time, fbt_id ASC", - array('integer', 'integer', 'integer', 'integer', 'integer', 'integer'), - array($session_id, $set_id, $step, $session_id, $set_id, $step) - ); - - while($row = $ilDB->fetchAssoc($res)) - { - $feedbacks[] = ilRTE::_replaceMediaObjectImageSrc($row['fb_'.$row['feedback_type']], 1); - } - - return $feedbacks; - } - - /** - * @return bool - */ - public function isFeedbackEnabled() - { - global $DIC; - $ilDB = $DIC->database(); - $ilUser = $DIC->user(); - $ilAccess = $DIC->access(); - - $res = $ilDB->queryF('SELECT node_fb_part FROM rep_robj_xtsf_data WHERE id = %s', - array('integer'), array($this->getId())); - - $row = $ilDB->fetchAssoc($res); - - $fb_part = (bool)$row['node_fb_part']; - - if($ilAccess->checkAccessOfUser($ilUser->getId(), 'read', '', $this->getRefId()) - && $fb_part) - { - return true; - } - - return false; - } - - /** - * @return bool - */ - public function isResultFeedbackEnabled() - { - global $DIC; - $ilDB = $DIC->database(); - $ilUser = $DIC->user(); - $ilAccess = $DIC->access(); - - $res = $ilDB->queryF('SELECT node_fb_author, node_fb_part, node_fb_part_res FROM rep_robj_xtsf_data WHERE id = %s', - array('integer'), array($this->getId())); - - $row = $ilDB->fetchAssoc($res); - $fb_author = (bool)$row['node_fb_author']; - $fb_part = (bool)$row['node_fb_part']; - $fb_part_res = (bool)$row['node_fb_part_res']; - - if($ilAccess->checkAccessOfUser($ilUser->getId(), 'write', '', $this->getRefId()) - && $fb_author) - { - return true; - } - else if($ilAccess->checkAccessOfUser($ilUser->getId(), 'read', '', $this->getRefId()) - && $fb_part_res) - { - return true; - } - - return false; - } - - /** - * @param bool $skillServiceEnabled - */ - public function setSkillServiceEnabled($skillServiceEnabled) - { - $this->skillServiceEnabled = $skillServiceEnabled; - } - - /** - * @return bool - */ - public function isSkillServiceEnabled() - { - if(!self::isSkillManagementGloballyActivated()) - { - return false; - } - - return $this->skillServiceEnabled; - } - - /** - * @return bool - */ - public static function isSkillManagementGloballyActivated() - { - if( self::$isSkillManagementGloballyActivated === null ) - { - include_once './Services/Skill/classes/class.ilSkillManagementSettings.php'; - $skmgSet = new ilSkillManagementSettings(); - - self::$isSkillManagementGloballyActivated = $skmgSet->isActivated(); - } - - return self::$isSkillManagementGloballyActivated; - } - - /** - * Adapter for ilObjTest::canShowTestResults - * - * @param ilFormATestSession $testSession - * - * @return boolean - */ - public function canShowTestResults($testSession) - { - return false; - } + array('integer', 'integer', 'integer', 'integer', 'integer', 'integer'), + array($session_id, $set_id, $step, $session_id, $set_id, $step) + ); + + while ($row = $ilDB->fetchAssoc($res)) { + $feedbacks[] = ilRTE::_replaceMediaObjectImageSrc($row['fb_' . $row['feedback_type']], 1); + } + + return $feedbacks; + } + + /** + * @return bool + */ + public function isFeedbackEnabled() + { + global $DIC; + $ilDB = $DIC->database(); + $ilUser = $DIC->user(); + $ilAccess = $DIC->access(); + + $res = $ilDB->queryF( + 'SELECT node_fb_part FROM rep_robj_xtsf_data WHERE id = %s', + array('integer'), + array($this->getId()) + ); + + $row = $ilDB->fetchAssoc($res); + + $fb_part = (bool) $row['node_fb_part']; + + if ($ilAccess->checkAccessOfUser($ilUser->getId(), 'read', '', $this->getRefId()) + && $fb_part) { + return true; + } + + return false; + } + + /** + * @return bool + */ + public function isResultFeedbackEnabled() + { + global $DIC; + $ilDB = $DIC->database(); + $ilUser = $DIC->user(); + $ilAccess = $DIC->access(); + + $res = $ilDB->queryF( + 'SELECT node_fb_author, node_fb_part, node_fb_part_res FROM rep_robj_xtsf_data WHERE id = %s', + array('integer'), + array($this->getId()) + ); + + $row = $ilDB->fetchAssoc($res); + $fb_author = (bool) $row['node_fb_author']; + $fb_part = (bool) $row['node_fb_part']; + $fb_part_res = (bool) $row['node_fb_part_res']; + + if ($ilAccess->checkAccessOfUser($ilUser->getId(), 'write', '', $this->getRefId()) + && $fb_author) { + return true; + } elseif ($ilAccess->checkAccessOfUser($ilUser->getId(), 'read', '', $this->getRefId()) + && $fb_part_res) { + return true; + } + + return false; + } + + /** + * @param bool $skillServiceEnabled + */ + public function setSkillServiceEnabled($skillServiceEnabled) + { + $this->skillServiceEnabled = $skillServiceEnabled; + } + + /** + * @return bool + */ + public function isSkillServiceEnabled() + { + if (!self::isSkillManagementGloballyActivated()) { + return false; + } + + return $this->skillServiceEnabled; + } + + /** + * @return bool + */ + public static function isSkillManagementGloballyActivated() + { + if (self::$isSkillManagementGloballyActivated === null) { + $skmgSet = new ilSkillManagementSettings(); + + self::$isSkillManagementGloballyActivated = $skmgSet->isActivated(); + } + + return self::$isSkillManagementGloballyActivated; + } + + /** + * Adapter for ilObjTest::canShowTestResults + * + * @param ilFormATestSession $testSession + * + * @return boolean + */ + public function canShowTestResults($testSession) + { + return false; + } public function checkQuestionParent($questionId) { @@ -1857,4 +1760,3 @@ class ilObjFormATest extends ilObjectPlugin implements ilLPStatusPluginInterface return (bool) $row['cnt']; } } - diff --git a/classes/class.ilObjFormATestAccess.php b/classes/class.ilObjFormATestAccess.php index 07063a02a8ee1edcf5207c179cd38fd5c49d7eea..9ef7de5f5f25411f9f590bcb845fe9104f3eb0ac 100644 --- a/classes/class.ilObjFormATestAccess.php +++ b/classes/class.ilObjFormATestAccess.php @@ -1,7 +1,6 @@ user(); - $ilAccess = $DIC->access(); + /** + * @param string $a_cmd + * @param string $a_permission + * @param int $a_ref_id + * @param int $a_obj_id + * @param string $a_user_id + * @return bool + */ + public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = '') + { + global $DIC; + $ilUser = $DIC->user(); + $ilAccess = $DIC->access(); - if(!$a_user_id) - { - $a_user_id = $ilUser->getId(); - } + if (!$a_user_id) { + $a_user_id = $ilUser->getId(); + } - switch($a_permission) - { - case 'read': - if( - !ilObjFormATestAccess::checkOnline($a_obj_id) && - !$ilAccess->checkAccessOfUser($a_user_id, 'write', '', $a_ref_id) - ) - { - return false; - } - return true; - } + switch ($a_permission) { + case 'read': + if ( + !ilObjFormATestAccess::checkOnline($a_obj_id) && + !$ilAccess->checkAccessOfUser($a_user_id, 'write', '', $a_ref_id) + ) { + return false; + } + return true; + } - return true; - } + return true; + } - /** - * @param int $a_obj_id - * - * @return bool - */ - public static function checkOnline($a_obj_id) - { - return ilObjFormATest::getOnlineStatusByObjId($a_obj_id); - } + /** + * @param int $a_obj_id + * + * @return bool + */ + public static function checkOnline($a_obj_id) + { + return ilObjFormATest::getOnlineStatusByObjId($a_obj_id); + } - /** - * @param array $a_obj_ids - * @param array $a_ref_ids - */ - public static function _preloadData($a_obj_ids, $a_ref_ids) - { - ilObjFormATest::preloadDataForLists($a_obj_ids, $a_ref_ids); - } + /** + * @param array $a_obj_ids + * @param array $a_ref_ids + */ + public static function _preloadData($a_obj_ids, $a_ref_ids) + { + ilObjFormATest::preloadDataForLists($a_obj_ids, $a_ref_ids); + } } diff --git a/classes/class.ilObjFormATestGUI.php b/classes/class.ilObjFormATestGUI.php index c120bc5547246f6036eea1607d2b2f9b1098b56b..cc86411bbbe9ace12486de90c4bb3ce3f46456c4 100644 --- a/classes/class.ilObjFormATestGUI.php +++ b/classes/class.ilObjFormATestGUI.php @@ -1,11 +1,7 @@ hasPermission('write')) - { - return 'ilFormATestSetsGUI.listSets'; - } - - return 'ilFormATestInfoScreenControllerGUI.show'; - } - - /** - * Public wrapper for permission checks - * @param string $permission - * @return bool - */ - public function hasPermission($permission) - { - return $this->checkPermissionBool($permission); - } - - /** - * Public wrapper for permission assumption - * @param string $permission - * @return bool - */ - public function ensurePermission($permission) - { - return $this->checkPermission($permission); - } - - /** - * @param string $cmd - */ - public function performCommand($cmd) - { - global $DIC; - $ilTabs = $DIC->tabs(); - $tpl = $DIC->ui()->mainTemplate(); - $lng = $DIC->language(); - $ilDB = $DIC->database(); - $ilPluginAdmin = $DIC['ilPluginAdmin']; - - require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/classes/dispatcher/class.ilXTSFPluginDispatcher.php"; - - $this->lng->loadLanguageModule('assessment'); - $tpl->addCss('./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/templates/default/xtsf.css'); - - $tpl->setDescription($this->object->getDescription()); - - $next_class = $this->ctrl->getNextClass($this); - switch($next_class) - { - - case 'ilmarkschemagui': - $this->checkPermission('write'); - $ilTabs->activateTab('settings'); - $this->setSubTabs($ilTabs, 'ilmarkschemagui'); - require_once 'Modules/Test/classes/class.ilMarkSchemaGUI.php'; - $mark_schema_gui = new ilMarkSchemaGUI($this->object); - $this->ctrl->forwardCommand($mark_schema_gui); - break; - case 'ilformatestskilladministrationgui': - require_once 'controllers/class.ilFormATestSkillAdministrationGUI.php'; - $this->prepareOutput(); - $this->addHeaderAction(); - - $gui = new ilFormATestSkillAdministrationGUI($this); - $this->ctrl->forwardCommand($gui); - break; - case 'iltestskillevaluationgui': - $this->prepareOutput(); - $this->addHeaderAction(); - - require_once 'utils/class.ilFormATestSkillLevelHelper.php'; - require_once 'models/class.ilFormATestSession.php'; - - - $session = new ilFormATestSession($this->object); - $session->read($this->object->getSetList()->getData()); - - $helper = new ilFormATestSkillLevelHelper(); - $helper->setSession($session); - - $questionList = $helper->loadQuestionList($this->object); - $testResults = $helper->getTestResults($this->object); - - require_once 'Modules/Test/classes/class.ilTestObjectiveOrientedContainer.php'; - $objectiveOrientedContainer = new ilTestObjectiveOrientedContainer(); - $objectiveOrientedContainer->setObjId($this->object->getId()); - $objectiveOrientedContainer->setRefId($this->object->getRefId()); - - require_once 'Modules/Test/classes/class.ilTestSkillEvaluationGUI.php'; - $gui = new ilTestSkillEvaluationGUI($this->ctrl, $ilTabs, $this->tpl, $this->lng, $ilDB, $this->object->getTestId(), $this->object->getRefId(), $this->object->getId()); - $gui->setQuestionList($questionList); - $gui->setTestSession($session); - $gui->setTestResults($testResults); - $gui->setObjectiveOrientedContainer($objectiveOrientedContainer); - $this->ctrl->forwardCommand($gui); - $ilTabs->clearTargets(); - $ilTabs->setBackTarget( - $this->lng->txt('tst_results_back_introduction'), - $this->ctrl->getLinkTarget($this, 'ilFormATestInfoScreenControllerGUI.show') - ); - break; - - case 'ilmdeditorgui': - $this->checkPermission('write'); - require_once 'Services/MetaData/classes/class.ilMDEditorGUI.php'; - $md_gui = new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType()); - $md_gui->addObserver($this->object,'MDUpdateListener','General'); - $ilTabs->activateSubTab('meta_data'); - $this->ctrl->forwardCommand($md_gui); - break; - - case 'ilpublicuserprofilegui': - require_once 'Services/User/classes/class.ilPublicUserProfileGUI.php'; - $profile_gui = new ilPublicUserProfileGUI($_GET['user']); - $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, 'ilFormATestInfoScreenControllerGUI.show')); - $this->tpl->setContent($this->ctrl->forwardCommand($profile_gui)); - break; - case "ilassquestionpagegui": - require_once "Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php"; - $gui = new ilAssQuestionPageGUI(); - $this->tpl->setContent($this->ctrl->forwardCommand($gui)); - break; - case 'ilcommonactiondispatchergui': - require_once 'Services/Object/classes/class.ilCommonActionDispatcherGUI.php'; - $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall(); - $this->ctrl->forwardCommand($gui); - break; - case 'ilobjformatestquestionsetpoolgui': - require_once 'class.ilObjFormATestQuestionSetPoolGUI.php'; - $gui = new ilObjFormATestQuestionSetPoolGUI((int)$_GET['ref_id']); - $this->ctrl->forwardCommand($gui); - break; - case "ilformatestexportgui": - $this->checkPermission('write'); - $ilTabs->setTabActive('export'); - $this->plugin->includeClass('class.ilFormATestExportGUI.php'); - $exp_gui = new ilFormATestExportGUI($this); - $exp_gui->addFormat('xml', $this->lng->txt('qpl_export_xml')); - $this->ctrl->forwardCommand($exp_gui); - break; - default: - switch($cmd) - { - case 'updateProperties': - case 'editProperties': - case 'showHistory': - $this->checkPermission('write'); - $this->$cmd(); - break; - - case 'addToDesk': - case 'removeFromDesk': - case 'redrawHeaderAction': - if(in_array($cmd, array('addToDesk', 'removeFromDesk'))) - { - $cmd .= 'Object'; - } - $this->checkPermission('read'); - $this->$cmd(); - break; - case "handleQuestionAction": - case "showInstantResponse": - $cmd = "ilFormATestPlayerControllerGUI." . $cmd; - default: - $dispatcher = ilXTSFPluginDispatcher::getInstance($this); - $this->setSubTabs($ilTabs, $dispatcher->getController($cmd)); - $dispatcher->dispatch($cmd); - break; - } - break; - } - - if(strpos($cmd, 'ilFormATestPlayerControllerGUI') === false) - { - $this->addHeaderAction(); - } - } - - /** - * Copied from: ilInfoScreenGUI - */ - public function saveTags() - { - require_once 'Services/Tagging/classes/class.ilTaggingGUI.php'; - $tagging_gui = new ilTaggingGUI(); - $tagging_gui->setObject($this->object->getId(), $this->object->getType()); - $tagging_gui->saveInput(); - - $this->ctrl->redirect($this, 'ilFormATestInfoScreenControllerGUI.show'); - } - - /** - * - */ - protected function setTabs() - { - global $DIC; - $ilTabs = $DIC->tabs(); - $ilCtrl = $DIC->ctrl(); - $lng = $DIC->language(); - - $ilTabs->clearTargets(); - - if($this->checkPermissionBool('write')) - { - $ilTabs->addTab('sets', $this->txt('sets'), $ilCtrl->getLinkTarget($this, 'ilFormATestSetsGUI.listSets')); - - } - - if($this->checkPermissionBool("read")) - { - $ilTabs->addTab("info_short", $lng->txt("info_short"), $ilCtrl->getLinkTarget($this, "ilFormATestInfoScreenControllerGUI.show")); - } - -// $this->addInfoTab(); - - if($this->checkPermissionBool('write')) - { - $ilTabs->addTab('properties', $this->txt('properties'), $ilCtrl->getLinkTarget($this, 'ilFormATestPropertiesGUI.edit')); - } - - if($this->checkPermissionBool('read') && $this->object->isSkillServiceEnabled() && ilObjFormATest::isSkillManagementGloballyActivated()) - { - $link = $this->ctrl->getLinkTargetByClass( - array('ilFormATestSkillAdministrationGUI', 'ilFormATestAssQuestionSkillAssignmentsGUI'), - ilFormATestAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_QUEST_ASSIGNS - ); - - $ilTabs->addTarget('tst_tab_competences', $link); - } - - if($this->checkPermissionBool('write')) - { - $ilTabs->addTab('participants', $this->txt('participants'), $ilCtrl->getLinkTarget($this, 'ilFormATestParticipantsGUI.show')); - } - - require_once 'Services/Tracking/classes/class.ilLearningProgressAccess.php'; - if(ilLearningProgressAccess::checkAccess($this->object->getRefId(), true)) - { - if($this->checkPermissionBool('write')) - { - if($this->object->getLearningProgressMode() != ilObjFormATest::LP_MODE_DEACTIVATED) - { - $ilTabs->addTab('learning_progress', $lng->txt('learning_progress'), $ilCtrl->getLinkTarget($this, 'ilFormATestLearningProgressGUI.showLpUsers')); - } - else - { - $ilTabs->addTab('learning_progress', $lng->txt('learning_progress'), $ilCtrl->getLinkTarget($this, 'ilFormATestLearningProgressGUI.showLPSettings')); - } - } - else if($this->checkPermissionBool('read') && $this->object->getLearningProgressMode() != ilObjFormATest::LP_MODE_DEACTIVATED) - { - $ilTabs->addTab('learning_progress', $lng->txt('learning_progress'), $ilCtrl->getLinkTarget($this, 'ilFormATestLearningProgressGUI.showLPUserDetails')); - } - } - - if($this->checkPermissionBool('write')) - { - $ilTabs->addTab('history', $lng->txt('history'), $ilCtrl->getLinkTarget($this, 'ilFormATestHistoryGUI.showHistory')); - $ilTabs->addTarget('meta_data', $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''), '', 'ilmdeditorgui'); - $ilTabs->addTarget("export", $this->ctrl->getLinkTargetByClass("ilformatestexportgui", ""), "", "ilformatestexportgui"); - } - - $this->addPermissionTab(); - } - - private function setSubTabs(ilTabsGUI $tabsGUI, $controllerClass) - { - switch($controllerClass) - { - case 'ilFormATestPropertiesGUI': - case 'ilFormATestScoringAndResultPropertiesGUI': - case 'ilmarkschemagui': - - $this->setPropertiesSubTabs($tabsGUI, $controllerClass); - break; - } - } - - private function setPropertiesSubTabs(ilTabsGUI $tabsGUI, $controllerClass) - { - $tabsGUI->addSubTab( - 'xtsf_properties', $this->txt('st_general_properties'), - $this->ctrl->getLinkTarget($this, 'ilFormATestPropertiesGUI.edit') - ); - - $tabsGUI->addSubTab( - 'xtsf_markschema', $this->txt('st_mark_schema'), - $this->ctrl->getLinkTargetByClass('ilMarkSchemaGUI', 'showMarkSchema') - ); - - $tabsGUI->addSubTab( - 'xtsf_scoringresult', $this->txt('st_scoring_result'), - $this->ctrl->getLinkTarget($this, 'ilFormATestScoringAndResultPropertiesGUI.edit') - ); - - switch($controllerClass) - { - case 'ilFormATestScoringAndResultPropertiesGUI': - - $tabsGUI->activateSubTab('xtsf_scoringresult'); - break; - - case 'ilFormATestPropertiesGUI': - - $tabsGUI->activateSubTab('xtsf_properties'); - break; - - case 'ilmarkschemagui': - - $tabsGUI->activateSubTab('xtsf_markschema'); - break; - } - } - - /** - * - */ - public function getObjId() - { - return $this->object->getId(); - } - - /** - * @param string $a_sub_type - * @param int $a_sub_id - * @return ilObjectListGUI|ilObjFormATestListGUI - */ - protected function initHeaderAction($a_sub_type = null, $a_sub_id = null) - { - global $DIC; - $ilUser = $DIC->user(); - - $lg = parent::initHeaderAction(); - if($lg instanceof ilObjFormATestListGUI) - { - if($ilUser->getId() != ANONYMOUS_USER_ID) - { - // Maybe handle notifications in future ... - } - } - - return $lg; - } - - /** - * @see ilDesktopItemHandling::addToDesk() - */ - public function addToDeskObject() - { - global $DIC; - $ilSetting = $DIC->settings(); - $lng = $DIC->language(); - - if((int)$ilSetting->get('disable_my_offers')) - { - $this->ctrl->redirect($this, 'ilFormATestInfoScreenControllerGUI.show'); - return; - } - - include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php'; - ilDesktopItemGUI::addToDesktop(); - ilUtil::sendSuccess($lng->txt('added_to_desktop'), true); - $this->ctrl->redirect($this, 'ilFormATestInfoScreenControllerGUI.show'); - } - - /** - * @see ilDesktopItemHandling::removeFromDesk() - */ - public function removeFromDeskObject() - { - global $DIC; - $ilSetting = $DIC->settings(); - $lng = $DIC->language(); - - if((int)$ilSetting->get('disable_my_offers')) - { - $this->ctrl->redirect($this, 'ilFormATestInfoScreenControllerGUI.show'); - return; - } - - include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php'; - ilDesktopItemGUI::removeFromDesktop(); - ilUtil::sendSuccess($lng->txt('removed_from_desktop'), true); - $this->ctrl->redirect($this, 'ilFormATestInfoScreenControllerGUI.show'); - } - - /** - * @param string $type - * @return array - */ - protected function initCreationForms($type) - { - return array( - self::CFORM_NEW => $this->initCreateForm($type), - self::CFORM_IMPORT => $this->initImportForm($type) - ); - } - - /** - * @param string $type - * @return ilPropertyFormGUI - */ - public function initCreateForm($type) - { - $form = parent::initCreateForm($type); - - // Add additional form elements for creation form (e.g. clone, import) - - return $form; - } - - /** - * @return array - */ - private function getXqspFormOptionValues() - { - $xqsp_available_pools = ilObjQuestionSetPool::getAvailableQuestionSetPools(TRUE); - $options_1 = array(ilFormATestImporter::SINGLE_IMPORT_NEW_POOL => $this->plugin->txt("new_xqsp_pool")); - - if (is_array($xqsp_available_pools) && count($xqsp_available_pools)) - { - foreach ($xqsp_available_pools as $key => $xqsp_obj) - { - $options_1[$key] = $xqsp_obj->getTitle(); - } - } - return $options_1; - } - - /** - * @return array - */ - private function getQplFormOptionValues() - { - include_once("./Modules/Test/classes/class.ilObjTest.php"); - $tst = new ilObjTest(); - $questionpools = $tst->getAvailableQuestionpools(TRUE, FALSE, TRUE, TRUE); - $this->plugin->includeClass('class.ilFormATestImporter.php'); - $options = array( - ilFormATestImporter::SINGLE_IMPORT_NEW_POOL => $this->lng->txt("assessment_new_pool"), - ilFormATestImporter::SINGLE_IMPORT_NO_POOL => $this->lng->txt('assessment_no_pool') - ); - - if (is_array($questionpools) && count($questionpools)) - { - foreach ($questionpools as $key => $value) - { - $options[$key] = $value["title"]; - } - } - return $options; - } - - /** - * @param $a_new_type - * @return ilPropertyFormGUI - */ - public function initImportForm($a_new_type) - { - $form = parent::initImportForm($a_new_type); - $this->plugin->includeClass('class.ilFormATestImporter.php'); - - // select QuestionSetPool - $radio_grp = new ilRadioGroupInputGUI($this->plugin->txt('xqsp_selection'), 'xqsp_selection'); - - // no QuestionSetPool - $no_xqsp = new ilRadioOption($this->plugin->txt('no_xqsp_pool'), 'xqsp_sel_0', $this->plugin->txt('no_xqsp_pool_info')); - - $radio_grp->addOption($no_xqsp); - - // new/existing QuestionSetPool - $xqsp_pool = new ilSelectInputGUI($this->plugin->txt("select_xqsp_pool"), "xqsp"); - $xqsp_pool->setOptions($this->getXqspFormOptionValues()); - - // select question pool - $qpl_pool = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "qpl"); - $qpl_pool->setOptions($this->getQplFormOptionValues()); - - $existing_xqsp = new ilRadioOption($this->plugin->txt('existing_xqsp_pool'), 'xqsp_sel_1', $this->plugin->txt('existing_xqsp_pool_info')); - $existing_xqsp->addSubItem($xqsp_pool); - $existing_xqsp->addSubItem($qpl_pool); - - $radio_grp->setValue('xqsp_sel_0'); - $radio_grp->addOption($existing_xqsp); - $form->addItem($radio_grp); - - return $form; - } - - /** - * - */ - protected function editProperties() - { - global $DIC; - - $this->initPropertiesForm(); - $this->getPropertiesValues(); - - $DIC->ui()->mainTemplate()->setContent($this->form->getHTML()); - } - - /** - * - */ - protected function initPropertiesForm() - { - global $DIC; - $ilCtrl = $DIC->ctrl(); - - $this->form = new ilPropertyFormGUI(); - $this->form->setTitle($this->txt('edit_properties')); - $this->form->setFormAction($ilCtrl->getFormAction($this, 'updateProperties')); - - $ti = new ilTextInputGUI($this->txt('title'), 'title'); - $ti->setRequired(true); - $this->form->addItem($ti); - - $ta = new ilTextAreaInputGUI($this->txt('description'), 'desc'); - $this->form->addItem($ta); - - // Add your form elements here - - $this->form->addCommandButton('updateProperties', $this->txt('save')); - } - - /** - * - */ - protected function getPropertiesValues() - { - $values['title'] = $this->object->getTitle(); - $values['desc'] = $this->object->getDescription(); - - // Add other settings here - - $this->form->setValuesByArray($values); - } - - /** - * - */ - protected function updateProperties() - { - global $DIC; - $tpl = $DIC->ui()->mainTemplate(); - $lng = $DIC->language(); - $ilCtrl = $DIC->ctrl(); - - $this->initPropertiesForm(); - if($this->form->checkInput()) - { - $this->object->setTitle($this->form->getInput('title')); - $this->object->setDescription($this->form->getInput('desc')); - - // Set settings from request to object here - - $this->object->update(); - ilUtil::sendSuccess($lng->txt('msg_obj_modified'), true); - $ilCtrl->redirect($this, 'editProperties'); - } - - $this->form->setValuesByPost(); - $tpl->setContent($this->form->getHTML()); - } - - /** - * Overwriting this method is necessary to handle creation problems with the api - */ - public function save() - { - $this->saveObject(); - } - - /** - * Overwriting this method is necessary to handle creation problems with the api - */ - public function saveObject() - { - global $DIC; - $ilCtrl = $DIC->ctrl(); - - try - { - parent::saveObject(); - } - catch(Exception $e) - { - ilUtil::sendFailure($this->plugin->txt($e->getMessage()), true); - $ilCtrl->setParameterByClass('ilrepositorygui', 'ref_id', (int)$_GET['ref_id']); - $ilCtrl->redirectByClass('ilrepositorygui'); - } - } - - /** - * @param ilObjFormATest $newObj - */ - public function afterSave(ilObject $newObj) - { - // Do something on save-request, e.g. add members to your object automatically etc. - parent::afterSave($newObj); - } - - public static function _goto($a_target, $a_thread = 0, $a_posting = 0) - { - global $DIC; - $ilCtrl = $DIC->ctrl(); - $ilAccess = $DIC->access(); - $lng = $DIC->language(); - - $t = explode("_", $a_target[0]); - $ref_id = (int) $t[0]; - $class_name = $a_target[1]; - - if ($ilAccess->checkAccess("write", "", $ref_id)) - { - $ilCtrl->initBaseClass("ilObjPluginDispatchGUI"); - $ilCtrl->setTargetScript("ilias.php"); - $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI")); - $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id); - $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "ilFormATestSetsGUI.listSets"); - } - else if ($ilAccess->checkAccess("read", "", $ref_id)) - { - $ilCtrl->initBaseClass("ilObjPluginDispatchGUI"); - $ilCtrl->setTargetScript("ilias.php"); - $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI")); - $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id); - $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "ilFormATestInfoScreenControllerGUI.show"); - } - else if($ilAccess->checkAccess("visible", "", $ref_id)) - { - $ilCtrl->initBaseClass("ilObjPluginDispatchGUI"); - $ilCtrl->setTargetScript("ilias.php"); - $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI")); - $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id); - $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "infoScreen"); - } - else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) - { - ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"), - ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)))); - include_once("./Services/Object/classes/class.ilObjectGUI.php"); - ilObjectGUI::_gotoRepositoryRoot(); - } - } - -} \ No newline at end of file + /** + * @var ilObjFormATest + */ + public $object = null; + + + /** + * @var ilPropertyFormGUI + */ + protected $form; + + public $plugin; + + /** + * @return string + */ + public function getType() + { + return 'xtsf'; + } + + /** + * @return string + */ + public function getAfterCreationCmd() + { + return 'ilFormATestPropertiesGUI.edit'; + } + + /** + * @return string + */ + public function getStandardCmd() + { + if ($this->hasPermission('write')) { + return 'ilFormATestSetsGUI.listSets'; + } + + return 'ilFormATestInfoScreenControllerGUI.show'; + } + + /** + * Public wrapper for permission checks + * @param string $permission + * @return bool + */ + public function hasPermission($permission) + { + return $this->checkPermissionBool($permission); + } + + /** + * Public wrapper for permission assumption + * @param string $permission + * @return bool + */ + public function ensurePermission($permission) + { + return $this->checkPermission($permission); + } + + /** + * @param string $cmd + */ + public function performCommand($cmd) + { + global $DIC; + $ilTabs = $DIC->tabs(); + $tpl = $DIC->ui()->mainTemplate(); + $ilDB = $DIC->database(); + + require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/classes/dispatcher/class.ilXTSFPluginDispatcher.php"; + + $this->lng->loadLanguageModule('assessment'); + $tpl->addCss('./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/templates/default/xtsf.css'); + + $tpl->setDescription($this->object->getDescription()); + + $next_class = $this->ctrl->getNextClass($this); + switch ($next_class) { + + case 'ilmarkschemagui': + $this->checkPermission('write'); + $this->setSubTabs($ilTabs, 'ilmarkschemagui'); + $mark_schema_gui = new ilMarkSchemaGUI($this->object); + $this->ctrl->forwardCommand($mark_schema_gui); + $ilTabs->activateTab('properties'); // Has to be called at last, because ilMarkSchemaGUI sets the active tab to `settings` + break; + case 'ilformatestskilladministrationgui': + require_once 'controllers/class.ilFormATestSkillAdministrationGUI.php'; + $this->prepareOutput(); + $this->addHeaderAction(); + + $gui = new ilFormATestSkillAdministrationGUI($this); + $this->ctrl->forwardCommand($gui); + break; + case 'ilformatestskillevaluationgui': + $this->prepareOutput(); + $this->addHeaderAction(); + + require_once 'utils/class.ilFormATestSkillLevelHelper.php'; + require_once 'models/class.ilFormATestSession.php'; + require_once __DIR__ . '/class.ilFormATestSkillEvaluationGUI.php'; + + $session = new ilFormATestSession($this->object); + $session->read($this->object->getSetList()->getData()); + + $helper = new ilFormATestSkillLevelHelper(); + $helper->setSession($session); + + $questionList = $helper->loadQuestionList($this->object); + $testResults = $helper->getTestResults($this->object); + + $objectiveOrientedContainer = new ilTestObjectiveOrientedContainer(); + $objectiveOrientedContainer->setObjId($this->object->getId()); + $objectiveOrientedContainer->setRefId($this->object->getRefId()); + + $gui = new ilFormATestSkillEvaluationGUI( + $this->ctrl, + $ilTabs, + $this->tpl, + $this->lng, + $ilDB, + $this->object + ); + $gui->setQuestionList($questionList); + $gui->setTestSession($session); + $gui->setTestResults($testResults); + $gui->setObjectiveOrientedContainer($objectiveOrientedContainer); + $this->ctrl->forwardCommand($gui); + $ilTabs->clearTargets(); + $ilTabs->setBackTarget( + $this->lng->txt('tst_results_back_introduction'), + $this->ctrl->getLinkTarget($this, 'ilFormATestInfoScreenControllerGUI.show') + ); + break; + + case 'ilmdeditorgui': + $this->checkPermission('write'); + $ilTabs->activateTab('meta_data'); + $md_gui = new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType()); + $md_gui->addObserver($this->object, 'MDUpdateListener', 'General'); + $ilTabs->activateSubTab('meta_data'); + $this->ctrl->forwardCommand($md_gui); + break; + + case 'ilpublicuserprofilegui': + $profile_gui = new ilPublicUserProfileGUI($_GET['user']); + $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, 'ilFormATestInfoScreenControllerGUI.show')); + $this->tpl->setContent($this->ctrl->forwardCommand($profile_gui)); + break; + case "ilassquestionpagegui": + $gui = new ilAssQuestionPageGUI(); + $this->tpl->setContent($this->ctrl->forwardCommand($gui)); + break; + case 'ilcommonactiondispatchergui': + $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall(); + $this->ctrl->forwardCommand($gui); + break; + case 'ilobjformatestquestionsetpoolgui': + require_once 'class.ilObjFormATestQuestionSetPoolGUI.php'; + $gui = new ilObjFormATestQuestionSetPoolGUI((int) $_GET['ref_id']); + $this->ctrl->forwardCommand($gui); + break; + case "ilformatestexportgui": + $this->checkPermission('write'); + $ilTabs->setTabActive('export'); + $this->plugin->includeClass('class.ilFormATestExportGUI.php'); + $exp_gui = new ilFormATestExportGUI($this); + $exp_gui->addFormat('xml', $this->lng->txt('qpl_export_xml')); + $this->ctrl->forwardCommand($exp_gui); + break; + default: + switch ($cmd) { + case 'updateProperties': + case 'editProperties': + case 'showHistory': + $this->checkPermission('write'); + $this->$cmd(); + break; + + case 'addToDesk': + case 'removeFromDesk': + case 'redrawHeaderAction': + if (in_array($cmd, array('addToDesk', 'removeFromDesk'))) { + $cmd .= 'Object'; + } + $this->checkPermission('read'); + $this->$cmd(); + break; + case "handleQuestionAction": + case "showInstantResponse": + $cmd = "ilFormATestPlayerControllerGUI." . $cmd; + // no break + default: + $dispatcher = ilXTSFPluginDispatcher::getInstance($this); + $this->setSubTabs($ilTabs, $dispatcher->getController($cmd)); + $dispatcher->dispatch($cmd); + break; + } + break; + } + + if (strpos($cmd, 'ilFormATestPlayerControllerGUI') === false) { + $this->addHeaderAction(); + } + } + + /** + * Copied from: ilInfoScreenGUI + */ + public function saveTags() + { + $tagging_gui = new ilTaggingGUI(); + $tagging_gui->setObject($this->object->getId(), $this->object->getType()); + $tagging_gui->saveInput(); + + $this->ctrl->redirect($this, 'ilFormATestInfoScreenControllerGUI.show'); + } + + /** + * + */ + protected function setTabs() + { + global $DIC; + $ilTabs = $DIC->tabs(); + $ilCtrl = $DIC->ctrl(); + $lng = $DIC->language(); + + $ilTabs->clearTargets(); + + if ($this->checkPermissionBool('write')) { + $ilTabs->addTab('sets', $this->txt('sets'), $ilCtrl->getLinkTarget($this, 'ilFormATestSetsGUI.listSets')); + } + + if ($this->checkPermissionBool("read")) { + $ilTabs->addTab("info_short", $lng->txt("info_short"), $ilCtrl->getLinkTarget($this, "ilFormATestInfoScreenControllerGUI.show")); + } + + // $this->addInfoTab(); + + if ($this->checkPermissionBool('write')) { + $ilTabs->addTab('properties', $this->txt('properties'), $ilCtrl->getLinkTarget($this, 'ilFormATestPropertiesGUI.edit')); + } + + if ($this->checkPermissionBool('read') && $this->object->isSkillServiceEnabled() && ilObjFormATest::isSkillManagementGloballyActivated()) { + $link = $this->ctrl->getLinkTargetByClass( + array('ilFormATestSkillAdministrationGUI', 'ilFormATestAssQuestionSkillAssignmentsGUI'), + ilFormATestAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_QUEST_ASSIGNS + ); + + $ilTabs->addTarget('tst_tab_competences', $link); + } + + if ($this->checkPermissionBool('write')) { + $ilTabs->addTab('participants', $this->txt('participants'), $ilCtrl->getLinkTarget($this, 'ilFormATestParticipantsGUI.show')); + } + + if (ilLearningProgressAccess::checkAccess($this->object->getRefId(), true)) { + if ($this->checkPermissionBool('write')) { + if ($this->object->getLearningProgressMode() != ilObjFormATest::LP_MODE_DEACTIVATED) { + $ilTabs->addTab('learning_progress', $lng->txt('learning_progress'), $ilCtrl->getLinkTarget($this, 'ilFormATestLearningProgressGUI.showLpUsers')); + } else { + $ilTabs->addTab('learning_progress', $lng->txt('learning_progress'), $ilCtrl->getLinkTarget($this, 'ilFormATestLearningProgressGUI.showLPSettings')); + } + } elseif ($this->checkPermissionBool('read') && $this->object->getLearningProgressMode() != ilObjFormATest::LP_MODE_DEACTIVATED) { + $ilTabs->addTab('learning_progress', $lng->txt('learning_progress'), $ilCtrl->getLinkTarget($this, 'ilFormATestLearningProgressGUI.showLPUserDetails')); + } + } + + if ($this->checkPermissionBool('write')) { + $ilTabs->addTab('history', $lng->txt('history'), $ilCtrl->getLinkTarget($this, 'ilFormATestHistoryGUI.showHistory')); + $ilTabs->addTarget('meta_data', $this->ctrl->getLinkTargetByClass('ilmdeditorgui', ''), '', 'ilmdeditorgui'); + $ilTabs->addTarget("export", $this->ctrl->getLinkTargetByClass("ilformatestexportgui", ""), "", "ilformatestexportgui"); + } + + $this->addPermissionTab(); + } + + private function setSubTabs(ilTabsGUI $tabsGUI, $controllerClass) + { + switch ($controllerClass) { + case 'ilFormATestPropertiesGUI': + case 'ilFormATestScoringAndResultPropertiesGUI': + case 'ilmarkschemagui': + + $this->setPropertiesSubTabs($tabsGUI, $controllerClass); + break; + } + } + + private function setPropertiesSubTabs(ilTabsGUI $tabsGUI, $controllerClass) + { + $tabsGUI->addSubTab( + 'xtsf_properties', + $this->txt('st_general_properties'), + $this->ctrl->getLinkTarget($this, 'ilFormATestPropertiesGUI.edit') + ); + + $tabsGUI->addSubTab( + 'xtsf_markschema', + $this->txt('st_mark_schema'), + $this->ctrl->getLinkTargetByClass('ilMarkSchemaGUI', 'showMarkSchema') + ); + + $tabsGUI->addSubTab( + 'xtsf_scoringresult', + $this->txt('st_scoring_result'), + $this->ctrl->getLinkTarget($this, 'ilFormATestScoringAndResultPropertiesGUI.edit') + ); + + switch ($controllerClass) { + case 'ilFormATestScoringAndResultPropertiesGUI': + + $tabsGUI->activateSubTab('xtsf_scoringresult'); + break; + + case 'ilFormATestPropertiesGUI': + + $tabsGUI->activateSubTab('xtsf_properties'); + break; + + case 'ilmarkschemagui': + + $tabsGUI->activateSubTab('xtsf_markschema'); + break; + } + } + + /** + * + */ + public function getObjId() + { + return $this->object->getId(); + } + + /** + * @param string $a_sub_type + * @param int $a_sub_id + * @return ilObjectListGUI|ilObjFormATestListGUI + */ + protected function initHeaderAction($a_sub_type = null, $a_sub_id = null) + { + global $DIC; + $ilUser = $DIC->user(); + + $lg = parent::initHeaderAction(); + if ($lg instanceof ilObjFormATestListGUI) { + if ($ilUser->getId() != ANONYMOUS_USER_ID) { + // Maybe handle notifications in future ... + } + } + + return $lg; + } + + /** + * @param string $type + * @return array + */ + protected function initCreationForms($type) + { + return array( + self::CFORM_NEW => $this->initCreateForm($type), + self::CFORM_IMPORT => $this->initImportForm($type) + ); + } + + /** + * @param string $type + * @return ilPropertyFormGUI + */ + public function initCreateForm($type) + { + $form = parent::initCreateForm($type); + + // Add additional form elements for creation form (e.g. clone, import) + + return $form; + } + + /** + * @return array + */ + private function getXqspFormOptionValues() + { + $xqsp_available_pools = ilObjQuestionSetPool::getAvailableQuestionSetPools(true); + $options_1 = array(ilFormATestImporter::SINGLE_IMPORT_NEW_POOL => $this->plugin->txt("new_xqsp_pool")); + + if (is_array($xqsp_available_pools) && count($xqsp_available_pools)) { + foreach ($xqsp_available_pools as $key => $xqsp_obj) { + $options_1[$key] = $xqsp_obj->getTitle(); + } + } + return $options_1; + } + + /** + * @return array + */ + private function getQplFormOptionValues() + { + $tst = new ilObjTest(); + $questionpools = $tst->getAvailableQuestionpools(true, false, true, true); + $this->plugin->includeClass('class.ilFormATestImporter.php'); + $options = array( + ilFormATestImporter::SINGLE_IMPORT_NEW_POOL => $this->lng->txt("assessment_new_pool"), + ilFormATestImporter::SINGLE_IMPORT_NO_POOL => $this->lng->txt('assessment_no_pool') + ); + + if (is_array($questionpools) && count($questionpools)) { + foreach ($questionpools as $key => $value) { + $options[$key] = $value["title"]; + } + } + return $options; + } + + /** + * @param $a_new_type + * @return ilPropertyFormGUI + */ + public function initImportForm($a_new_type) + { + $form = parent::initImportForm($a_new_type); + $this->plugin->includeClass('class.ilFormATestImporter.php'); + + // select QuestionSetPool + $radio_grp = new ilRadioGroupInputGUI($this->plugin->txt('xqsp_selection'), 'xqsp_selection'); + + // no QuestionSetPool + $no_xqsp = new ilRadioOption($this->plugin->txt('no_xqsp_pool'), 'xqsp_sel_0', $this->plugin->txt('no_xqsp_pool_info')); + + $radio_grp->addOption($no_xqsp); + + // new/existing QuestionSetPool + $xqsp_pool = new ilSelectInputGUI($this->plugin->txt("select_xqsp_pool"), "xqsp"); + $xqsp_pool->setOptions($this->getXqspFormOptionValues()); + + // select question pool + $qpl_pool = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "qpl"); + $qpl_pool->setOptions($this->getQplFormOptionValues()); + + $existing_xqsp = new ilRadioOption($this->plugin->txt('existing_xqsp_pool'), 'xqsp_sel_1', $this->plugin->txt('existing_xqsp_pool_info')); + $existing_xqsp->addSubItem($xqsp_pool); + $existing_xqsp->addSubItem($qpl_pool); + + $radio_grp->setValue('xqsp_sel_0'); + $radio_grp->addOption($existing_xqsp); + $form->addItem($radio_grp); + + return $form; + } + + /** + * + */ + protected function editProperties() + { + global $DIC; + + $this->initPropertiesForm(); + $this->getPropertiesValues(); + + $DIC->ui()->mainTemplate()->setContent($this->form->getHTML()); + } + + /** + * + */ + protected function initPropertiesForm() + { + global $DIC; + $ilCtrl = $DIC->ctrl(); + + $this->form = new ilPropertyFormGUI(); + $this->form->setTitle($this->txt('edit_properties')); + $this->form->setFormAction($ilCtrl->getFormAction($this, 'updateProperties')); + + $ti = new ilTextInputGUI($this->txt('title'), 'title'); + $ti->setRequired(true); + $this->form->addItem($ti); + + $ta = new ilTextAreaInputGUI($this->txt('description'), 'desc'); + $this->form->addItem($ta); + + // Add your form elements here + + $this->form->addCommandButton('updateProperties', $this->txt('save')); + } + + /** + * + */ + protected function getPropertiesValues() + { + $values['title'] = $this->object->getTitle(); + $values['desc'] = $this->object->getDescription(); + + // Add other settings here + + $this->form->setValuesByArray($values); + } + + /** + * + */ + protected function updateProperties() + { + global $DIC; + $tpl = $DIC->ui()->mainTemplate(); + $lng = $DIC->language(); + $ilCtrl = $DIC->ctrl(); + + $this->initPropertiesForm(); + if ($this->form->checkInput()) { + $this->object->setTitle($this->form->getInput('title')); + $this->object->setDescription($this->form->getInput('desc')); + + // Set settings from request to object here + + $this->object->update(); + ilUtil::sendSuccess($lng->txt('msg_obj_modified'), true); + $ilCtrl->redirect($this, 'editProperties'); + } + + $this->form->setValuesByPost(); + $tpl->setContent($this->form->getHTML()); + } + + /** + * Overwriting this method is necessary to handle creation problems with the api + */ + public function save() + { + $this->saveObject(); + } + + /** + * Overwriting this method is necessary to handle creation problems with the api + */ + public function saveObject() + { + global $DIC; + $ilCtrl = $DIC->ctrl(); + + try { + parent::saveObject(); + } catch (Exception $e) { + ilUtil::sendFailure($this->plugin->txt($e->getMessage()), true); + $ilCtrl->setParameterByClass('ilrepositorygui', 'ref_id', (int) $_GET['ref_id']); + $ilCtrl->redirectByClass('ilrepositorygui'); + } + } + + /** + * @param ilObjFormATest $newObj + */ + public function afterSave(ilObject $newObj) + { + // Do something on save-request, e.g. add members to your object automatically etc. + parent::afterSave($newObj); + } + + public static function _goto($a_target, $a_thread = 0, $a_posting = 0) + { + global $DIC; + $ilCtrl = $DIC->ctrl(); + $ilAccess = $DIC->access(); + $lng = $DIC->language(); + + $t = explode("_", $a_target[0]); + $ref_id = (int) $t[0]; + $class_name = $a_target[1]; + + if ($ilAccess->checkAccess("write", "", $ref_id)) { + $ilCtrl->initBaseClass("ilObjPluginDispatchGUI"); + $ilCtrl->setTargetScript("ilias.php"); + $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI")); + $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id); + $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "ilFormATestSetsGUI.listSets"); + } elseif ($ilAccess->checkAccess("read", "", $ref_id)) { + $ilCtrl->initBaseClass("ilObjPluginDispatchGUI"); + $ilCtrl->setTargetScript("ilias.php"); + $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI")); + $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id); + $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "ilFormATestInfoScreenControllerGUI.show"); + } elseif ($ilAccess->checkAccess("visible", "", $ref_id)) { + $ilCtrl->initBaseClass("ilObjPluginDispatchGUI"); + $ilCtrl->setTargetScript("ilias.php"); + $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI")); + $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id); + $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "infoScreen"); + } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) { + ilUtil::sendFailure(sprintf( + $lng->txt("msg_no_perm_read_item"), + ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)) + )); + ilObjectGUI::_gotoRepositoryRoot(); + } + } +} diff --git a/classes/class.ilObjFormATestListGUI.php b/classes/class.ilObjFormATestListGUI.php index f5c5fb8c46f81fd900d9e047fa6aa50add1cfd5a..8a75214e4b6054ddd7d2cb42d88ccf6d60db0577 100644 --- a/classes/class.ilObjFormATestListGUI.php +++ b/classes/class.ilObjFormATestListGUI.php @@ -1,83 +1,78 @@ copy_enabled = false; + /** + * @return array + */ + public function initCommands() + { + $this->copy_enabled = false; - return array - ( - array( - 'permission' => 'visible', - 'cmd' => 'ilFormATestInfoScreenControllerGUI.show', - 'default' => true - ), - array( - 'permission' => 'write', - 'cmd' => 'ilFormATestPropertiesGUI.edit', - 'txt' => $this->lng->txt('edit'), - 'default' => false - ), - ); - } + return array( + array( + 'permission' => 'visible', + 'cmd' => 'ilFormATestInfoScreenControllerGUI.show', + 'default' => true + ), + array( + 'permission' => 'write', + 'cmd' => 'ilFormATestPropertiesGUI.edit', + 'txt' => $this->lng->txt('edit'), + 'default' => false + ), + ); + } - /** - * {@inheritdoc} - */ - function insertInfoScreenCommand() - { - if($this->std_cmd_only) - { - return; - } - $cmd_link = $this->getCommandLink('ilFormATestInfoScreenControllerGUI.show'); - $cmd_frame = $this->getCommandFrame('infoScreen'); - $this->insertCommand($cmd_link, $this->lng->txt('info_short'), $cmd_frame); - } + /** + * {@inheritdoc} + */ + public function insertInfoScreenCommand() + { + if ($this->std_cmd_only) { + return; + } + $cmd_link = $this->getCommandLink('ilFormATestInfoScreenControllerGUI.show'); + $cmd_frame = $this->getCommandFrame('infoScreen'); + $this->insertCommand($cmd_link, $this->lng->txt('info_short'), $cmd_frame); + } - /** - * - */ - public function initType() - { - $this->setType('xtsf'); - } + /** + * + */ + public function initType() + { + $this->setType('xtsf'); + } - /** - * @return array - */ - public function getProperties() - { - global $DIC; - $lng = $DIC->language(); + /** + * @return array + */ + public function getProperties() + { + global $DIC; + $lng = $DIC->language(); - $props = array(); - include_once "class.ilObjFormATestAccess.php"; + $props = array(); + include_once "class.ilObjFormATestAccess.php"; - if (!ilObjFormATestAccess::checkOnline($this->obj_id)) - { - $props[] = array("alert" => true, "property" => $lng->txt("status"), - "value" => $lng->txt("offline")); - } + if (!ilObjFormATestAccess::checkOnline($this->obj_id)) { + $props[] = array("alert" => true, "property" => $lng->txt("status"), + "value" => $lng->txt("offline")); + } - return $props; - } + return $props; + } } diff --git a/classes/class.ilObjFormATestQuestionSetPoolGUI.php b/classes/class.ilObjFormATestQuestionSetPoolGUI.php index d45e4255ed0c552c947773668d4a70114ca2dd6d..499fcb388ebe3e2b1020a2aea2b70476eaf996e5 100644 --- a/classes/class.ilObjFormATestQuestionSetPoolGUI.php +++ b/classes/class.ilObjFormATestQuestionSetPoolGUI.php @@ -9,171 +9,167 @@ require_once "Customizing/global/plugins/Services/Repository/RepositoryObject/Qu * Date: 14.02.14 * Time: 14:01 * @author Thomas Joußen - */ + */ class ilObjFormATestQuestionSetPoolGUI extends ilObjQuestionSetPoolGUI { - /** - * execute command - */ - function &executeCommand() - { - global $DIC; - $ilCtrl = $DIC->ctrl(); - $tpl = $DIC->ui()->mainTemplate(); - $lng = $DIC->language(); - $ilTabs = $DIC->tabs(); - $ilLocator = $DIC['ilLocator']; - $ilToolbar = $DIC->toolbar(); - - $available_pools = array_keys(ilObjQuestionSetPool::getAvailableQuestionSetPools()); - - $set = new ilQuestionSetPoolSet((int)$_GET["set_id"]); - $set->read(); - - // get standard template (includes main menu and general layout) - $tpl->getStandardTemplate(); - - $ilLocator->clearItems(); - - $plugin = $this->initFormATestPlugin(); - - $tpl->setTitle($this->object->getTitle()); - $tpl->setTitleIcon($plugin->getImagePath("icon_".$this->object->getType() . ".svg"), - $lng->txt("icon")." ".$this->txt("obj_".$this->object->getType())); - - $this->setTabs(); - $this->setLocator(); - - $next_class = $this->ctrl->getNextClass($this); - $cmd = $this->ctrl->getCmd(); - - switch($next_class) - { - case "ilinfoscreengui": - $this->checkPermission("visible"); - $this->infoScreen(); // forwards command - break; - - case 'ilpermissiongui': - include_once("Services/AccessControl/classes/class.ilPermissionGUI.php"); - $perm_gui = new ilPermissionGUI($this); - $ilTabs->setTabActive("perm_settings"); - $ret = $ilCtrl->forwardCommand($perm_gui); - break; - - case 'ilobjectcopygui': - include_once './Services/Object/classes/class.ilObjectCopyGUI.php'; - $cp = new ilObjectCopyGUI($this); - $cp->setType($this->getType()); - $this->ctrl->forwardCommand($cp); - break; - - default: - if (strtolower($_GET["baseClass"]) == "iladministrationgui") - { - $this->viewObject(); - return; - } - if(!$cmd) - { - $cmd = $this->getStandardCmd(); - } - if ($cmd == "infoScreen") - { - $ilCtrl->setCmd("showSummary"); - $ilCtrl->setCmdClass("ilinfoscreengui"); - $this->infoScreen(); - } - else - { - $this->performCommand($cmd); - - $reflection = new ReflectionClass(get_class($this->tpl)); - $property = $reflection->getProperty('message'); - $property->setAccessible(true); - $values = $property->getValue($this->tpl); - $values = (array)$values; - - if(is_array($values['failure'])) - { - if(ilObjQuestionSetPool::canSynchronizeSet($set->getOriginalId())) - { - if(!strlen($_SESSION['failure']) && !count($values['failure'])) - { - $ilCtrl->setParameter($this, "set_id", $set->getId()); - $ilToolbar->setFormAction($ilCtrl->getFormAction($this)); - $ilCtrl->setParameter($this, "set_id", ""); - $ilToolbar->addFormButton($this->plugin->txt("synchronize_set"), "ilQuestionSetPoolSetsGUI.synchronize", "", true); - } - } - else - { - if(!strlen($_SESSION['failure']) && !count($values['failure'])) - { - ilUtil::sendInfo($this->plugin->txt("not_in_test")); - } - } - } - } - break; - } - } - - protected function redirectToDefaultPage() - { - $this->ctrl->redirectByClass("ilObjFormATestGUI", "ilFormATestSetsGUI.listSets"); - } - - public function initFormATestPlugin() - { - return ilPlugin::getPluginObject(IL_COMP_SERVICE, "Repository", "robj", - ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", "xtsf")); - } - - public function setTabs() - { - global $DIC; - $ilTabs = $DIC->tabs(); - - $ilTabs->clearTargets(); - - $ilTabs->setBackTarget($this->txt('back_to_test'), $this->ctrl->getLinkTargetByClass("ilObjFormATestGUI", "ilFormATestSetsGUI.listSets")); - } - - protected function addHeaderAction() - { - - } - - /** - * Add object to locator - */ - function addLocatorItems() - { - global $DIC; - $ilLocator = $DIC['ilLocator']; - - if (!$this->getCreationMode()) - { - $ilLocator->addItem($this->object->getTitle(), - $this->ctrl->getLinkTargetByClass('ilObjFormATestGUI', $this->getStandardCmd()), "", $_GET["ref_id"]); - } - } - - public function getStandardCmd() - { - return "ilFormATestSetsGUI.listSets"; - } - - - - /** - * Functions that must be overwritten - */ - /*public function getType() - { - return "xtsf"; - }*/ + /** + * execute command + */ + public function &executeCommand() + { + global $DIC; + $ilCtrl = $DIC->ctrl(); + $tpl = $DIC->ui()->mainTemplate(); + $lng = $DIC->language(); + $ilTabs = $DIC->tabs(); + $ilLocator = $DIC['ilLocator']; + $ilToolbar = $DIC->toolbar(); + + $available_pools = array_keys(ilObjQuestionSetPool::getAvailableQuestionSetPools()); + + $set = new ilQuestionSetPoolSet((int) $_GET["set_id"]); + $set->read(); + + // get standard template (includes main menu and general layout) + $tpl->loadStandardTemplate(); + + $ilLocator->clearItems(); + + $plugin = $this->initFormATestPlugin(); + + $tpl->setTitle($this->object->getTitle()); + $tpl->setTitleIcon( + $plugin->getImagePath("icon_" . $this->object->getType() . ".svg"), + $lng->txt("icon") . " " . $this->txt("obj_" . $this->object->getType()) + ); + + $this->setTabs(); + $this->setLocator(); + + $next_class = $this->ctrl->getNextClass($this); + $cmd = $this->ctrl->getCmd(); + + switch ($next_class) { + case "ilinfoscreengui": + $this->checkPermission("visible"); + $this->infoScreen(); // forwards command + break; + + case 'ilpermissiongui': + $perm_gui = new ilPermissionGUI($this); + $ilTabs->setTabActive("perm_settings"); + $ret = $ilCtrl->forwardCommand($perm_gui); + break; + + case 'ilobjectcopygui': + $cp = new ilObjectCopyGUI($this); + $cp->setType($this->getType()); + $this->ctrl->forwardCommand($cp); + break; + + default: + if (strtolower($_GET["baseClass"]) == "iladministrationgui") { + $this->viewObject(); + return; + } + if (!$cmd) { + $cmd = $this->getStandardCmd(); + } + if ($cmd == "infoScreen") { + $ilCtrl->setCmd("showSummary"); + $ilCtrl->setCmdClass("ilinfoscreengui"); + $this->infoScreen(); + } else { + $this->performCommand($cmd); + + $reflection = new ReflectionObject($this->tpl); + $contentTemplateProp = $reflection->getProperty('legacy_content_template'); + $contentTemplateProp->setAccessible(true); + $contentTemplate = $contentTemplateProp->getValue($this->tpl); + + $contentTemplateReflection = new ReflectionObject($contentTemplate); + $property = $contentTemplateReflection->getProperty('message'); + $property->setAccessible(true); + $messages = $property->getValue($contentTemplate); + $messages = (array) $messages; + + $hasFailure = ( + ( + isset($messages['failure']) + && is_string($messages['failure']) && + 0 !== strlen($messages['failure']) + ) || + ( + is_string(ilSession::get('failure')) && + 0 !== ilSession::get('failure') + ) + ); + + if (ilObjQuestionSetPool::canSynchronizeSet($set->getOriginalId())) { + if (!$hasFailure) { + $ilCtrl->setParameter($this, "set_id", $set->getId()); + $ilToolbar->setFormAction($ilCtrl->getFormAction($this)); + $ilCtrl->setParameter($this, "set_id", ""); + $ilToolbar->addFormButton($this->plugin->txt("synchronize_set"), "ilQuestionSetPoolSetsGUI.synchronize", "", true); + } + } elseif (!$hasFailure) { + ilUtil::sendInfo($this->plugin->txt("not_in_test")); + } + } + break; + } + } + + protected function redirectToDefaultPage() + { + $this->ctrl->redirectByClass("ilObjFormATestGUI", "ilFormATestSetsGUI.listSets"); + } + + public function initFormATestPlugin() + { + return ilPlugin::getPluginObject( + IL_COMP_SERVICE, + "Repository", + "robj", + ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", "xtsf") + ); + } + + public function setTabs() + { + global $DIC; + $ilTabs = $DIC->tabs(); + + $ilTabs->clearTargets(); + + $ilTabs->setBackTarget($this->txt('back_to_test'), $this->ctrl->getLinkTargetByClass("ilObjFormATestGUI", "ilFormATestSetsGUI.listSets")); + } + + protected function addHeaderAction() + { + } + + /** + * Add object to locator + */ + public function addLocatorItems() + { + global $DIC; + $ilLocator = $DIC['ilLocator']; + + if (!$this->getCreationMode()) { + $ilLocator->addItem( + $this->object->getTitle(), + $this->ctrl->getLinkTargetByClass('ilObjFormATestGUI', $this->getStandardCmd()), + "", + $_GET["ref_id"] + ); + } + } + + public function getStandardCmd() + { + return "ilFormATestSetsGUI.listSets"; + } } - \ No newline at end of file diff --git a/classes/class.ilObjFormATestXMLParser.php b/classes/class.ilObjFormATestXMLParser.php index 37acec32c91b0c1ce753d7e89377ac3382b635b9..ae44f9fe247d9e7de07769f388899ed21dd54b20 100644 --- a/classes/class.ilObjFormATestXMLParser.php +++ b/classes/class.ilObjFormATestXMLParser.php @@ -1,410 +1,399 @@ */ class ilObjFormATestXMLParser extends ilSaxParser { - /** - * @var ilObjFormATest - */ - private $xtsf_obj; - - private $inSettingsTag; - - private $inMetaDataTag; - private $inMdGeneralTag; - - public $sets = array(); - - private $questions = array(); - private $paths = array(); - private $nodes = array(); - private $jump_conditions = array(); - protected $importDirectory = ''; - - /** - * @param ilObjFormATest $xtsf_obj - * @param $xmlFile - */ - public function __construct($xtsf_obj, $xmlFile) - { - $this->xtsf_obj = $xtsf_obj; - - $this->inSettingsTag = false; - $this->inMetaDataTag = false; - $this->inMdGeneralTag = false; - - parent::__construct($xmlFile); - } - - /** - * Set import directory - * - * @param string import directory - */ - public function setImportDirectory($a_val) - { - $this->importDirectory = $a_val; - } - - /** - * Get import directory - * - * @return string import directory - */ - public function getImportDirectory() - { - return $this->importDirectory; - } - - /** - * @param $xmlParser - */ - public function setHandlers($xmlParser) - { - xml_set_object($xmlParser, $this); - xml_set_element_handler($xmlParser, 'handlerBeginTag', 'handlerEndTag'); - xml_set_character_data_handler($xmlParser, 'handlerCharacterData'); - } - - /** - * @param $xmlParser - * @param $tagName - * @param $tagAttributes - */ - public function handlerBeginTag($xmlParser, $tagName, $tagAttributes) - { - switch($tagName) - { - case 'MetaData': - $this->inMetaDataTag = true; - break; - - case 'General': - if($this->inMetaDataTag) - { - $this->inMdGeneralTag = true; - } - break; - - case 'Description': - if($this->inMetaDataTag && $this->inMdGeneralTag) - { - $this->cdata = ''; - } - break; - - case 'Settings': - $this->inSettingsTag = true; - break; - - case 'Online': - case 'SkillService': - case 'ShowIntroStatement': - case 'IntroStatement': - case 'ShowFinalStatement': - case 'FinalStatement': - case 'MaxPasses': - case 'StartTimeEnabled': - case 'StartTime': - case 'EndTimeEnabled': - case 'EndTime': - case 'AllowWalkBack': - case 'ShowCurrentTrack': - case 'ShowQuestionsOverview': - case 'AllowInterruption': - case 'SkillServiceEnabled': - case 'AnswerFeedbackPoints': - case 'GenericAnswerFeedback': - case 'SpecificAnswerFeedback': - case 'InstantFeedbackSolution': - case 'NodeFeedbackAuthor': - case 'NodeFeedbackParticipant': - case 'NodeFeedbackParticipantRes': - case 'ProcessTime': - case 'CharSelectorAvailability': - case 'CharSelectorDefinition': - case 'ScoreReporting': - case 'ReportingDate': - if($this->inSettingsTag) - { - $this->cdata = ''; - } - break; - case 'SetId': - case 'SetTitle': - case 'SetDescription': - case 'OriginalId': - $this->cdata = ''; - break; - } - } - - /** - * @param $xmlParser - * @param $tagName - */ - public function handlerEndTag($xmlParser, $tagName) - { - switch($tagName) - { - case 'MetaData': - $this->inMetaDataTag = false; - break; - - case 'General': - if($this->inMetaDataTag) - { - $this->inMdGeneralTag = false; - } - break; - - case 'Title': - if($this->inMetaDataTag && $this->inMdGeneralTag) - { - $this->xtsf_obj->setTitle(trim($this->cdata)); - $this->cdata = ''; - } - break; - - case 'Description': - if($this->inMetaDataTag && $this->inMdGeneralTag) - { - $this->xtsf_obj->setDescription(trim($this->cdata)); - $this->cdata = ''; - } - break; - - case 'Settings': - $this->inSettingsTag = false; - break; - - case 'Online': - $this->xtsf_obj->setOnline((bool)trim($this->cdata)); - $this->cdata = ''; - break; - - case 'SkillService': - $this->xtsf_obj->setSkillServiceEnabled((bool)trim($this->cdata)); - $this->cdata = ''; - break; - case 'ShowIntroStatement': - $this->xtsf_obj->setShowIntroStatement(trim($this->cdata)); - $this->cdata = ''; - break; - case 'IntroStatement': - $this->xtsf_obj->setIntroStatement(trim($this->cdata)); - $this->cdata = ''; - break; - case 'ShowFinalStatement': - $this->xtsf_obj->setShowFinalStatement(trim($this->cdata)); - $this->cdata = ''; - break; - case 'FinalStatement': - $this->xtsf_obj->setFinalStatement(trim($this->cdata)); - $this->cdata = ''; - break; - case 'MaxPasses': - $this->xtsf_obj->setMaxPasses(trim($this->cdata)); - $this->cdata = ''; - break; - case 'StartTimeEnabled': - $this->xtsf_obj->setStartTimeEnabled(trim($this->cdata)); - $this->cdata = ''; - break; - case 'StartTime': - $this->xtsf_obj->setStartTime(new ilDateTime(trim($this->cdata), IL_CAL_TIMESTAMP)); - - $this->cdata = ''; - break; - case 'EndTimeEnabled': - $this->xtsf_obj->setEndTimeEnabled(trim($this->cdata)); - $this->cdata = ''; - break; - case 'EndTime': - $this->xtsf_obj->setEndTime(new ilDateTime(trim($this->cdata), IL_CAL_TIMESTAMP)); - $this->cdata = ''; - break; - case 'AllowWalkBack': - $this->xtsf_obj->setAllowWalkBack(trim($this->cdata)); - $this->cdata = ''; - break; - case 'ShowCurrentTrack': - $this->xtsf_obj->setShowCurrentTrack(trim($this->cdata)); - $this->cdata = ''; - break; - case 'ShowQuestionsOverview': - $this->xtsf_obj->setShowQuestionsOverview(trim($this->cdata)); - $this->cdata = ''; - break; - case 'AllowInterruption': - $this->xtsf_obj->setAllowInterruption(trim($this->cdata)); - $this->cdata = ''; - break; - case 'SkillServiceEnabled': - $this->xtsf_obj->setSkillServiceEnabled(trim($this->cdata)); - $this->cdata = ''; - break; - case 'AnswerFeedbackPoints': - $this->xtsf_obj->setAnswerFeedbackPoints(trim($this->cdata)); - $this->cdata = ''; - break; - case 'GenericAnswerFeedback': - $this->xtsf_obj->setGenericAnswerFeedback(trim($this->cdata)); - $this->cdata = ''; - break; - case 'SpecificAnswerFeedback': - $this->xtsf_obj->setSpecificAnswerFeedback(trim($this->cdata)); - $this->cdata = ''; - break; - case 'InstantFeedbackSolution': - $this->xtsf_obj->setInstantFeedbackSolution(trim($this->cdata)); - $this->cdata = ''; - break; - case 'NodeFeedbackAuthor': - $this->xtsf_obj->setNodeFeedbackAuthor(trim($this->cdata)); - $this->cdata = ''; - break; - case 'NodeFeedbackParticipant': - $this->xtsf_obj->setNodeFeedbackParticipant(trim($this->cdata)); - $this->cdata = ''; - break; - case 'NodeFeedbackParticipantRes': - $this->xtsf_obj->setNodeFeedbackParticipantRes(trim($this->cdata)); - $this->cdata = ''; - break; - case 'ProcessTime': - $this->xtsf_obj->setProcessTime(trim($this->cdata)); - $this->cdata = ''; - break; - case 'CharSelectorAvailability': - $this->xtsf_obj->setCharSelectorAvailability(trim($this->cdata)); - $this->cdata = ''; - break; - case 'CharSelectorDefinition': - $this->xtsf_obj->setCharSelectorDefinition(trim($this->cdata)); - $this->cdata = ''; - break; - case 'ScoreReporting': - $this->xtsf_obj->setScoreReporting(trim($this->cdata)); - $this->cdata = ''; - break; - case 'ReportingDate': - $this->xtsf_obj->setReportingDate(new ilDateTime(trim($this->cdata), IL_CAL_TIMESTAMP)); - $this->cdata = ''; - break; - - // sets - case 'SetId': - case 'SetTitle': - case 'SetDescription': - case 'OriginalId': - $this->import_set[$tagName] = trim($this->cdata); - $this->cdata = ''; - break; - // question - case 'QuestionId': - case 'QuestionIndex': - case 'QuestionOriginalId': - $this->import_question[$tagName] = trim($this->cdata); - $this->cdata = ''; - break; - // paths - case 'PathId': - case 'PathTitle': - case 'PathQuestionSetId': - case 'PathIndex': - $this->import_path[$tagName] = trim($this->cdata); - $this->cdata = ''; - break; - //nodes - case 'NodeId': - case 'NodeQuestionId': - case 'NodePathId': - case 'NodeIndex': - case 'NodeInitialCondition': - case 'NodeDominantScoring': - case 'NodeTrueFeedback': - case 'NodeFalseFeedback': - $this->import_node[$tagName] = trim($this->cdata); - $this->cdata = ''; - break; - // jump conditions - case 'JumpConditionId': - case 'JumpConditionText': - case 'JumpConditionNodeId': - case 'JumpConditionQuestionId': - case 'JumpConditionRepetitions': - case 'JumpConditionSorting': - case 'JumpConditionTrueFeedback': - case 'JumpConditionTrueJumpFeedback': - case 'JumpConditionFalseFeedback': - $this->import_jump_condition[$tagName] = trim($this->cdata); - $this->cdata = ''; - break; - case 'Set': - //'addSet'; - $this->sets[] = array($this->import_set, 'questions' => $this->questions, 'paths' => $this->paths); - $this->questions = array(); - $this->paths = array(); - $this->import_set = array(); - break; - - case 'Question': - // addQuesion - $this->questions[] = $this->import_question; - $this->import_question = array(); - break; - - case 'Path': - // addPath - $this->paths[] = array($this->import_path, 'nodes' => $this->nodes); - $this->nodes = array(); - $this->import_path = array(); - break; - - case 'Node': - // addNode - $this->nodes[] = array($this->import_node, 'jump_conditions' => $this->jump_conditions); - $this->jump_conditions = array(); - $this->import_node = array(); - break; - - case 'JumpCondition': - // addJumpConditition - $this->jump_conditions[] = $this->import_jump_condition; - $this->import_jump_condition = array(); - break; - } - } - - public function handlerCharacterData($xmlParser, $charData) - { - if($charData != "\n") - { - // Replace multiple tabs with one space - $charData = preg_replace("/\t+/", " ", $charData); - - $this->cdata .= $charData; - } - } - - /** - * @return mixed - */ - public function getFormATestObject() - { - return $this->xtsf_obj; - } - - - public function getSetsArray() - { - return $this->sets; - } -} \ No newline at end of file + /** + * @var ilObjFormATest + */ + private $xtsf_obj; + + private $inSettingsTag; + + private $inMetaDataTag; + private $inMdGeneralTag; + + public $sets = array(); + + private $questions = array(); + private $paths = array(); + private $nodes = array(); + private $jump_conditions = array(); + protected $importDirectory = ''; + + /** + * @param ilObjFormATest $xtsf_obj + * @param $xmlFile + */ + public function __construct($xtsf_obj, $xmlFile) + { + $this->xtsf_obj = $xtsf_obj; + + $this->inSettingsTag = false; + $this->inMetaDataTag = false; + $this->inMdGeneralTag = false; + + parent::__construct($xmlFile); + } + + /** + * Set import directory + * + * @param string import directory + */ + public function setImportDirectory($a_val) + { + $this->importDirectory = $a_val; + } + + /** + * Get import directory + * + * @return string import directory + */ + public function getImportDirectory() + { + return $this->importDirectory; + } + + /** + * @param $xmlParser + */ + public function setHandlers($xmlParser) + { + xml_set_object($xmlParser, $this); + xml_set_element_handler($xmlParser, 'handlerBeginTag', 'handlerEndTag'); + xml_set_character_data_handler($xmlParser, 'handlerCharacterData'); + } + + /** + * @param $xmlParser + * @param $tagName + * @param $tagAttributes + */ + public function handlerBeginTag($xmlParser, $tagName, $tagAttributes) + { + switch ($tagName) { + case 'MetaData': + $this->inMetaDataTag = true; + break; + + case 'General': + if ($this->inMetaDataTag) { + $this->inMdGeneralTag = true; + } + break; + + case 'Description': + if ($this->inMetaDataTag && $this->inMdGeneralTag) { + $this->cdata = ''; + } + break; + + case 'Settings': + $this->inSettingsTag = true; + break; + + case 'Online': + case 'SkillService': + case 'ShowIntroStatement': + case 'IntroStatement': + case 'ShowFinalStatement': + case 'FinalStatement': + case 'MaxPasses': + case 'StartTimeEnabled': + case 'StartTime': + case 'EndTimeEnabled': + case 'EndTime': + case 'AllowWalkBack': + case 'ShowCurrentTrack': + case 'ShowQuestionsOverview': + case 'AllowInterruption': + case 'SkillServiceEnabled': + case 'AnswerFeedbackPoints': + case 'GenericAnswerFeedback': + case 'SpecificAnswerFeedback': + case 'InstantFeedbackSolution': + case 'NodeFeedbackAuthor': + case 'NodeFeedbackParticipant': + case 'NodeFeedbackParticipantRes': + case 'ProcessTime': + case 'CharSelectorAvailability': + case 'CharSelectorDefinition': + case 'ScoreReporting': + case 'ReportingDate': + if ($this->inSettingsTag) { + $this->cdata = ''; + } + break; + case 'SetId': + case 'SetTitle': + case 'SetDescription': + case 'OriginalId': + $this->cdata = ''; + break; + } + } + + /** + * @param $xmlParser + * @param $tagName + */ + public function handlerEndTag($xmlParser, $tagName) + { + switch ($tagName) { + case 'MetaData': + $this->inMetaDataTag = false; + break; + + case 'General': + if ($this->inMetaDataTag) { + $this->inMdGeneralTag = false; + } + break; + + case 'Title': + if ($this->inMetaDataTag && $this->inMdGeneralTag) { + $this->xtsf_obj->setTitle(trim($this->cdata)); + $this->cdata = ''; + } + break; + + case 'Description': + if ($this->inMetaDataTag && $this->inMdGeneralTag) { + $this->xtsf_obj->setDescription(trim($this->cdata)); + $this->cdata = ''; + } + break; + + case 'Settings': + $this->inSettingsTag = false; + break; + + case 'Online': + $this->xtsf_obj->setOnline((bool) trim($this->cdata)); + $this->cdata = ''; + break; + + case 'SkillService': + $this->xtsf_obj->setSkillServiceEnabled((bool) trim($this->cdata)); + $this->cdata = ''; + break; + case 'ShowIntroStatement': + $this->xtsf_obj->setShowIntroStatement(trim($this->cdata)); + $this->cdata = ''; + break; + case 'IntroStatement': + $this->xtsf_obj->setIntroStatement(trim($this->cdata)); + $this->cdata = ''; + break; + case 'ShowFinalStatement': + $this->xtsf_obj->setShowFinalStatement(trim($this->cdata)); + $this->cdata = ''; + break; + case 'FinalStatement': + $this->xtsf_obj->setFinalStatement(trim($this->cdata)); + $this->cdata = ''; + break; + case 'MaxPasses': + $this->xtsf_obj->setMaxPasses(trim($this->cdata)); + $this->cdata = ''; + break; + case 'StartTimeEnabled': + $this->xtsf_obj->setStartTimeEnabled(trim($this->cdata)); + $this->cdata = ''; + break; + case 'StartTime': + $this->xtsf_obj->setStartTime(new ilDateTime(trim($this->cdata), IL_CAL_TIMESTAMP)); + + $this->cdata = ''; + break; + case 'EndTimeEnabled': + $this->xtsf_obj->setEndTimeEnabled(trim($this->cdata)); + $this->cdata = ''; + break; + case 'EndTime': + $this->xtsf_obj->setEndTime(new ilDateTime(trim($this->cdata), IL_CAL_TIMESTAMP)); + $this->cdata = ''; + break; + case 'AllowWalkBack': + $this->xtsf_obj->setAllowWalkBack(trim($this->cdata)); + $this->cdata = ''; + break; + case 'ShowCurrentTrack': + $this->xtsf_obj->setShowCurrentTrack(trim($this->cdata)); + $this->cdata = ''; + break; + case 'ShowQuestionsOverview': + $this->xtsf_obj->setShowQuestionsOverview(trim($this->cdata)); + $this->cdata = ''; + break; + case 'AllowInterruption': + $this->xtsf_obj->setAllowInterruption(trim($this->cdata)); + $this->cdata = ''; + break; + case 'SkillServiceEnabled': + $this->xtsf_obj->setSkillServiceEnabled(trim($this->cdata)); + $this->cdata = ''; + break; + case 'AnswerFeedbackPoints': + $this->xtsf_obj->setAnswerFeedbackPoints(trim($this->cdata)); + $this->cdata = ''; + break; + case 'GenericAnswerFeedback': + $this->xtsf_obj->setGenericAnswerFeedback(trim($this->cdata)); + $this->cdata = ''; + break; + case 'SpecificAnswerFeedback': + $this->xtsf_obj->setSpecificAnswerFeedback(trim($this->cdata)); + $this->cdata = ''; + break; + case 'InstantFeedbackSolution': + $this->xtsf_obj->setInstantFeedbackSolution(trim($this->cdata)); + $this->cdata = ''; + break; + case 'NodeFeedbackAuthor': + $this->xtsf_obj->setNodeFeedbackAuthor(trim($this->cdata)); + $this->cdata = ''; + break; + case 'NodeFeedbackParticipant': + $this->xtsf_obj->setNodeFeedbackParticipant(trim($this->cdata)); + $this->cdata = ''; + break; + case 'NodeFeedbackParticipantRes': + $this->xtsf_obj->setNodeFeedbackParticipantRes(trim($this->cdata)); + $this->cdata = ''; + break; + case 'ProcessTime': + $this->xtsf_obj->setProcessTime(trim($this->cdata)); + $this->cdata = ''; + break; + case 'CharSelectorAvailability': + $this->xtsf_obj->setCharSelectorAvailability(trim($this->cdata)); + $this->cdata = ''; + break; + case 'CharSelectorDefinition': + $this->xtsf_obj->setCharSelectorDefinition(trim($this->cdata)); + $this->cdata = ''; + break; + case 'ScoreReporting': + $this->xtsf_obj->setScoreReporting(trim($this->cdata)); + $this->cdata = ''; + break; + case 'ReportingDate': + $this->xtsf_obj->setReportingDate(new ilDateTime(trim($this->cdata), IL_CAL_TIMESTAMP)); + $this->cdata = ''; + break; + + // sets + case 'SetId': + case 'SetTitle': + case 'SetDescription': + case 'OriginalId': + $this->import_set[$tagName] = trim($this->cdata); + $this->cdata = ''; + break; + // question + case 'QuestionId': + case 'QuestionIndex': + case 'QuestionOriginalId': + $this->import_question[$tagName] = trim($this->cdata); + $this->cdata = ''; + break; + // paths + case 'PathId': + case 'PathTitle': + case 'PathQuestionSetId': + case 'PathIndex': + $this->import_path[$tagName] = trim($this->cdata); + $this->cdata = ''; + break; + //nodes + case 'NodeId': + case 'NodeQuestionId': + case 'NodePathId': + case 'NodeIndex': + case 'NodeInitialCondition': + case 'NodeDominantScoring': + case 'NodeTrueFeedback': + case 'NodeFalseFeedback': + $this->import_node[$tagName] = trim($this->cdata); + $this->cdata = ''; + break; + // jump conditions + case 'JumpConditionId': + case 'JumpConditionText': + case 'JumpConditionNodeId': + case 'JumpConditionQuestionId': + case 'JumpConditionRepetitions': + case 'JumpConditionSorting': + case 'JumpConditionTrueFeedback': + case 'JumpConditionTrueJumpFeedback': + case 'JumpConditionFalseFeedback': + $this->import_jump_condition[$tagName] = trim($this->cdata); + $this->cdata = ''; + break; + case 'Set': + //'addSet'; + $this->sets[] = array($this->import_set, 'questions' => $this->questions, 'paths' => $this->paths); + $this->questions = array(); + $this->paths = array(); + $this->import_set = array(); + break; + + case 'Question': + // addQuesion + $this->questions[] = $this->import_question; + $this->import_question = array(); + break; + + case 'Path': + // addPath + $this->paths[] = array($this->import_path, 'nodes' => $this->nodes); + $this->nodes = array(); + $this->import_path = array(); + break; + + case 'Node': + // addNode + $this->nodes[] = array($this->import_node, 'jump_conditions' => $this->jump_conditions); + $this->jump_conditions = array(); + $this->import_node = array(); + break; + + case 'JumpCondition': + // addJumpConditition + $this->jump_conditions[] = $this->import_jump_condition; + $this->import_jump_condition = array(); + break; + } + } + + public function handlerCharacterData($xmlParser, $charData) + { + if ($charData != "\n") { + // Replace multiple tabs with one space + $charData = preg_replace("/\t+/", " ", $charData); + + $this->cdata .= $charData; + } + } + + /** + * @return mixed + */ + public function getFormATestObject() + { + return $this->xtsf_obj; + } + + + public function getSetsArray() + { + return $this->sets; + } +} diff --git a/classes/controllers/abstract.ilXTSFControllerFormGUI.php b/classes/controllers/abstract.ilXTSFControllerFormGUI.php index 04ea894c3abda871073f832ed72008daa13e9670..2b57a9979f41a75c32d82ac1389417f4319b29c3 100644 --- a/classes/controllers/abstract.ilXTSFControllerFormGUI.php +++ b/classes/controllers/abstract.ilXTSFControllerFormGUI.php @@ -8,99 +8,97 @@ require_once "abstract.ilXTSFControllerGUI.php"; * Date: 02.10.13 * Time: 15:10 * @author Thomas Joußen - */ + */ abstract class ilXTSFControllerFormGUI extends ilXTSFControllerGUI { - /** - * @var ilPropertyFormGUI - */ - protected $form; - - public function edit() - { - $this->controller->ensurePermission("write"); - - $model = $this->loadModel(); - $this->initForm($model); - $this->bindModelToForm($model); - $this->tpl->setContent($this->form->getHTML()); - } - - public function update() - { - $this->controller->ensurePermission("write"); - - $model = $this->loadModel(); - $this->initForm($model); - if($this->form->checkInput() && $this->canUpdate()) - { - $item = $this->form->getItemByPostVar('online'); - if($item && (int)$this->form->getInput('online') && !$this->controller->object->isComplete()) - { - ilUtil::sendFailure($this->lng->txt('form_input_not_valid')); - $this->form->getItemByPostVar('online')->setAlert( - $this->plugin->txt('onp_no_sets_no_mark_steps') - ); - $this->form->setValuesByPost(); - $this->tpl->setContent($this->form->getHTML()); - return; - } - - $model->bindForm($this->form); - $model->update(); - ilUtil::sendSuccess($this->plugin->txt("msg_obj_modified"), true); - $this->redirect( - $this->getAfterUpdateRedirectCmd(), - $this->getAfterUpdateRedirectParams($model) - ); - } - - $this->form->setValuesByPost(); - $this->tpl->setContent($this->form->getHTML()); - } - - protected function canUpdate() - { - return true; - } - - - /** - * @param ilXTSFModelInterface $model - */ - protected function bindModelToForm(ilXTSFModelInterface $model) - { - $this->form->setValuesByArray($model->toArray()); - } - - /** - * Loads and returns the Model for the controller gui - * - * @return ilXTSFModel - */ - abstract protected function loadModel(); - - /** - * Initialize the PropertyFormGUI for this controller - * - * @param ilXTSFModel $model - * - * @return mixed - */ - abstract protected function initForm($model); - - /** - * Get the redirect action after an update was successful - * - * @return string - */ - abstract protected function getAfterUpdateRedirectCmd(); - - /** - * @param $model - * - * @return array - */ - abstract protected function getAfterUpdateRedirectParams($model); + /** + * @var ilPropertyFormGUI + */ + protected $form; + + public function edit() + { + $this->controller->ensurePermission("write"); + + $model = $this->loadModel(); + $this->initForm($model); + $this->bindModelToForm($model); + $this->tpl->setContent($this->form->getHTML()); + } + + public function update() + { + $this->controller->ensurePermission("write"); + + $model = $this->loadModel(); + $this->initForm($model); + if ($this->form->checkInput() && $this->canUpdate()) { + $item = $this->form->getItemByPostVar('online'); + if ($item && (int) $this->form->getInput('online') && !$this->controller->object->isComplete()) { + ilUtil::sendFailure($this->lng->txt('form_input_not_valid')); + $this->form->getItemByPostVar('online')->setAlert( + $this->plugin->txt('onp_no_sets_no_mark_steps') + ); + $this->form->setValuesByPost(); + $this->tpl->setContent($this->form->getHTML()); + return; + } + + $model->bindForm($this->form); + $model->update(); + ilUtil::sendSuccess($this->plugin->txt("msg_obj_modified"), true); + $this->redirect( + $this->getAfterUpdateRedirectCmd(), + $this->getAfterUpdateRedirectParams($model) + ); + } + + $this->form->setValuesByPost(); + $this->tpl->setContent($this->form->getHTML()); + } + + protected function canUpdate() + { + return true; + } + + + /** + * @param ilXTSFModelInterface $model + */ + protected function bindModelToForm(ilXTSFModelInterface $model) + { + $this->form->setValuesByArray($model->toArray()); + } + + /** + * Loads and returns the Model for the controller gui + * + * @return ilXTSFModel + */ + abstract protected function loadModel(); + + /** + * Initialize the PropertyFormGUI for this controller + * + * @param ilXTSFModel $model + * + * @return mixed + */ + abstract protected function initForm($model); + + /** + * Get the redirect action after an update was successful + * + * @return string + */ + abstract protected function getAfterUpdateRedirectCmd(); + + /** + * @param $model + * + * @return array + */ + abstract protected function getAfterUpdateRedirectParams($model); } diff --git a/classes/controllers/abstract.ilXTSFControllerGUI.php b/classes/controllers/abstract.ilXTSFControllerGUI.php index 861ff84842e3bdb6bc5e94a99ef33a349d4b2f02..aba6f1b1293fd2ec0d367425863535c9054ded8f 100644 --- a/classes/controllers/abstract.ilXTSFControllerGUI.php +++ b/classes/controllers/abstract.ilXTSFControllerGUI.php @@ -8,280 +8,254 @@ require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/ * Date: 23.09.13 * Time: 14:10 * @author Thomas Joußen - */ -abstract class ilXTSFControllerGUI { - - /** - * The main Controller of the Plugin - * - * @var ilObjFormATestGUI - */ - public $controller; - - /** - * @var ilCtrl - */ - protected $ctrl; - - /** - * @var ilToolbarGUI; - */ - protected $toolbar; - - /** - * @var ilTemplate - */ - protected $tpl; - - /** - * @var iPlugin - */ - protected $plugin; - - /** - * @var ilLanguage - */ - protected $lng; - - /** - * @var ilTabsGUI - */ - protected $tabs; - - /** - * @var ilObjUser - */ - protected $user; - - /** - * @param ilObjFormATestGUI $controller - */ - public function __construct(ilObjFormATestGUI $controller) - { - global $DIC; - - $this->controller = $controller; - $this->ctrl = $DIC->ctrl(); - $this->tpl = $DIC->ui()->mainTemplate(); - $this->plugin = $this->controller->plugin; - $this->lng = $DIC->language(); - $this->toolbar = $DIC->toolbar(); - $this->tabs = $DIC->tabs(); - $this->user = $DIC->user(); - $this->activateTab(); - $this->includeRequirements(); - } - - protected function initToolbar() - { - $this->toolbar->setFormAction($this->ctrl->getFormAction($this->controller, '', 'question_output')); - } - - protected function addToolbarButton($text, $command, array $params = array()) - { - if($this->toolbar == null) - { - $this->initToolbar(); - } - - foreach($params as $key => $param) - { - $this->ctrl->setParameter($this->controller, $key, $param); - } - - $link = $this->ctrl->getLinkTarget($this->controller, $command, 'question_output'); - - foreach($params as $key => $param) - { - $this->ctrl->setParameter($this->controller, $key, ""); - } - - $this->toolbar->addButton($this->plugin->txt($text),$link); - } - - /** - * Activates the tab for the current GUI - */ - private function activateTab() - { - - if($this->getCurrentTab() != "") - { - $this->tabs->activateTab($this->getCurrentTab()); - } - } - - private function includeRequirements() - { - $requirements = $this->getRequirements(); - - if(!empty($requirements)) - { - foreach($requirements as $requirement) - { - require_once $this->controller->plugin->getDirectory().DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR.$requirement; - } - } - } - - protected function redirect($command, $params = array()) - { - foreach($params as $key => $param) - { - $this->ctrl->setParameter($this->controller, $key, $param); - } - - $this->ctrl->redirect($this->controller, $command, 'question_output'); - } - - /** - * Returns the current tab name - * - * return string - */ - abstract protected function getCurrentTab(); - - /** - * @return array - */ - abstract protected function getRequirements(); - - /** - * @param ilFormATestSession $session - * @param array $hidden_buttons - */ - protected function addSessionSensitiveButton(ilFormATestSession $session, $hidden_buttons = array()) - { - $canStartTest = - ilFormATestPlayerAccessHelper::canDoTestAction($this->controller, $session) && - $this->controller->hasPermission("read"); - - if(!$this->controller->object->isComplete()) - { - ilUtil::sendInfo($this->plugin->txt('cs_no_sets_no_mark_steps'), true); - return; - } - else if (!$session->activeIdExists() && $canStartTest) - { - $button = ilSubmitButton::getInstance(); - $button->setCommand("ilFormATestPlayerControllerGUI.startTest"); - $button->setCaption($this->plugin->txt("start_test"), false); - $this->toolbar->addButtonInstance($button); -// $this->toolbar->addFormButton($this->plugin->txt("start_test"), "ilFormATestPlayerControllerGUI.startTest", "", true); - } - else if($canStartTest) - { - if (!$session->isPassFinished()) - { - $this->toolbar->addFormButton($this->plugin->txt("resume"), "ilFormATestPlayerControllerGUI.resumeTest", "", true); - } - else if($this->controller->object->getMaxPasses() == 0 || $session->getPass() + 1 < $this->controller->object->getMaxPasses()) - { - $this->toolbar->addFormButton($this->plugin->txt("start_new_pass"), "ilFormATestPlayerControllerGUI.startNewPass", "", true); - } - else - { - ilUtil::sendInfo($this->controller->lng->txt('maximum_nr_of_tries_reached'), true); - } - } - - if(!in_array('test_results', $hidden_buttons) && ($this->scoringReportingAlways() || $this->scoringReportingFinished($session) || $this->scoringReportingDate())) - { - $this->toolbar->addFormButton($this->plugin->txt("show_test_results"), "ilFormATestInfoScreenControllerGUI.showTestResults"); - } - - if($session->isPassFinished() && $this->controller->object->isSkillServiceEnabled() && ilObjFormATest::isSkillManagementGloballyActivated() ) - { - require_once './Modules/Test/classes/class.ilTestSkillEvaluationGUI.php'; - $link = $this->ctrl->getLinkTargetByClass( - array('ilTestSkillEvaluationGUI'), - ilTestSkillEvaluationGUI::CMD_SHOW - ); - - $this->toolbar->addButton($this->lng->txt("tst_show_comp_results"), $link); - } - } - - /** - * @param string $cancel - * @param string $confirm - * @param array $items - * @param string $header - */ - protected function renderConfirmationScreen($cancel, $confirm, $items = array(), $header = "", $params = array()) - { - $confirmation = new ilConfirmationGUI(); - foreach($params as $key => $value) - { - $this->ctrl->setParameter($this->controller, $key, $value); - } - $this->ctrl->setParameter($this->controller, "confirmed", true); - $confirmation->setFormAction($this->ctrl->getFormAction($this->controller, '', 'question_output')); - foreach($params as $key => $value) - { - $this->ctrl->setParameter($this->controller, $key, ""); - } - $this->ctrl->setParameter($this->controller, "confirmed", ""); - $confirmation->setHeaderText($header); - $confirmation->setCancel($this->lng->txt("cancel"), $cancel); - $confirmation->setConfirm($this->lng->txt("confirm"), $confirm); - - foreach ($items as $item) - { - $confirmation->addItem($item["name"], $item["id"], $item["text"]); - } - - $this->tpl->setContent($confirmation->getHTML()); - } - - protected function scoringReportingAlways() - { - return $this->controller->object->getScoreReporting() == ilObjFormATest::SCORE_REPORTING_ALWAYS && $this->controller->object->getParticipants()->hasParticipants(); - } - - protected function scoringReportingFinished(ilFormATestSession $session) - { - return $this->controller->object->getScoreReporting() == ilObjFormATest::SCORE_REPORTING_FINISHED && - $session->isPassFinished(); - } - - protected function scoringReportingDate() - { - $date = new ilDateTime(time(), IL_CAL_UNIX); - - return $this->controller->object->getScoreReporting() == ilObjFormATest::SCORE_REPORTING_DATE && - $date->_after($date, $this->controller->object->getReportingDate()); - } - - /** - * @param bool $finish_set - * @param ilQuestionSetPoolNode $node - * @param array $params - * - * @return string - */ - protected function generateJumpToNodeLink($finish_set, $node, $params = array(), $step = 0) - { - $this->ctrl->setParameter($this->controller, "node_id", $node["id"]); - $this->ctrl->setParameter($this->controller, "node_step", $step); - - if ($finish_set) - { - $this->ctrl->setParameter($this->controller, "finished", 1); - } - foreach($params as $key => $value) - { - $this->ctrl->setParameter($this->controller, $key, $value); - } - $href = $this->ctrl->getLinkTarget($this->controller, "ilFormATestPlayerControllerGUI.jumpToNode", 'question_output'); - foreach($params as $key => $value) - { - $this->ctrl->setParameter($this->controller, $key, ""); - } - - $this->ctrl->setParameter($this->controller, "node_id", ""); - $this->ctrl->setParameter($this->controller, "finished", ""); - - return $href; - } + */ +abstract class ilXTSFControllerGUI +{ + + /** + * The main Controller of the Plugin + * + * @var ilObjFormATestGUI + */ + public $controller; + + /** + * @var ilCtrl + */ + protected $ctrl; + + /** + * @var ilToolbarGUI; + */ + protected $toolbar; + + /** + * @var ilTemplate + */ + protected $tpl; + + /** + * @var iPlugin + */ + protected $plugin; + + /** + * @var ilLanguage + */ + protected $lng; + + /** + * @var ilTabsGUI + */ + protected $tabs; + + /** + * @var ilObjUser + */ + protected $user; + + /** + * @param ilObjFormATestGUI $controller + */ + public function __construct(ilObjFormATestGUI $controller) + { + global $DIC; + + $this->controller = $controller; + $this->ctrl = $DIC->ctrl(); + $this->tpl = $DIC->ui()->mainTemplate(); + $this->plugin = $this->controller->plugin; + $this->lng = $DIC->language(); + $this->toolbar = $DIC->toolbar(); + $this->tabs = $DIC->tabs(); + $this->user = $DIC->user(); + $this->activateTab(); + $this->includeRequirements(); + } + + protected function initToolbar() + { + $this->toolbar->setFormAction($this->ctrl->getFormAction($this->controller, '', 'question_output')); + } + + protected function addToolbarButton($text, $command, array $params = array()) + { + if ($this->toolbar == null) { + $this->initToolbar(); + } + + foreach ($params as $key => $param) { + $this->ctrl->setParameter($this->controller, $key, $param); + } + + $link = $this->ctrl->getLinkTarget($this->controller, $command, 'question_output'); + + foreach ($params as $key => $param) { + $this->ctrl->setParameter($this->controller, $key, ""); + } + + $this->toolbar->addButton($this->plugin->txt($text), $link); + } + + /** + * Activates the tab for the current GUI + */ + private function activateTab() + { + if ($this->getCurrentTab() != "") { + $this->tabs->activateTab($this->getCurrentTab()); + } + } + + private function includeRequirements() + { + $requirements = $this->getRequirements(); + + if (!empty($requirements)) { + foreach ($requirements as $requirement) { + require_once $this->controller->plugin->getDirectory() . DIRECTORY_SEPARATOR . "classes" . DIRECTORY_SEPARATOR . $requirement; + } + } + } + + protected function redirect($command, $params = array()) + { + foreach ($params as $key => $param) { + $this->ctrl->setParameter($this->controller, $key, $param); + } + + $this->ctrl->redirect($this->controller, $command, 'question_output'); + } + + /** + * Returns the current tab name + * + * return string + */ + abstract protected function getCurrentTab(); + + /** + * @return array + */ + abstract protected function getRequirements(); + + /** + * @param ilFormATestSession $session + * @param array $hidden_buttons + */ + protected function addSessionSensitiveButton(ilFormATestSession $session, $hidden_buttons = array()) + { + $canStartTest = + ilFormATestPlayerAccessHelper::canDoTestAction($this->controller, $session) && + $this->controller->hasPermission("read"); + + if (!$this->controller->object->isComplete()) { + ilUtil::sendInfo($this->plugin->txt('cs_no_sets_no_mark_steps'), true); + return; + } elseif (!$session->activeIdExists() && $canStartTest) { + $button = ilSubmitButton::getInstance(); + $button->setCommand("ilFormATestPlayerControllerGUI.startTest"); + $button->setCaption($this->plugin->txt("start_test"), false); + $this->toolbar->addButtonInstance($button); + // $this->toolbar->addFormButton($this->plugin->txt("start_test"), "ilFormATestPlayerControllerGUI.startTest", "", true); + } elseif ($canStartTest) { + if (!$session->isPassFinished()) { + $this->toolbar->addFormButton($this->plugin->txt("resume"), "ilFormATestPlayerControllerGUI.resumeTest", "", true); + } elseif ($this->controller->object->getMaxPasses() == 0 || $session->getPass() + 1 < $this->controller->object->getMaxPasses()) { + $this->toolbar->addFormButton($this->plugin->txt("start_new_pass"), "ilFormATestPlayerControllerGUI.startNewPass", "", true); + } else { + ilUtil::sendInfo($this->controller->lng->txt('maximum_nr_of_tries_reached'), true); + } + } + + if (!in_array('test_results', $hidden_buttons) && ($this->scoringReportingAlways() || $this->scoringReportingFinished($session) || $this->scoringReportingDate())) { + $this->toolbar->addFormButton($this->plugin->txt("show_test_results"), "ilFormATestInfoScreenControllerGUI.showTestResults"); + } + + if ($session->isPassFinished() && $this->controller->object->isSkillServiceEnabled() && ilObjFormATest::isSkillManagementGloballyActivated()) { + $link = $this->ctrl->getLinkTargetByClass( + array('ilFormATestSkillEvaluationGUI'), + ilTestSkillEvaluationGUI::CMD_SHOW + ); + + $this->toolbar->addButton($this->lng->txt("tst_show_comp_results"), $link); + } + } + + /** + * @param string $cancel + * @param string $confirm + * @param array $items + * @param string $header + */ + protected function renderConfirmationScreen($cancel, $confirm, $items = array(), $header = "", $params = array()) + { + $confirmation = new ilConfirmationGUI(); + foreach ($params as $key => $value) { + $this->ctrl->setParameter($this->controller, $key, $value); + } + $this->ctrl->setParameter($this->controller, "confirmed", true); + $confirmation->setFormAction($this->ctrl->getFormAction($this->controller, '', 'question_output')); + foreach ($params as $key => $value) { + $this->ctrl->setParameter($this->controller, $key, ""); + } + $this->ctrl->setParameter($this->controller, "confirmed", ""); + $confirmation->setHeaderText($header); + $confirmation->setCancel($this->lng->txt("cancel"), $cancel); + $confirmation->setConfirm($this->lng->txt("confirm"), $confirm); + + foreach ($items as $item) { + $confirmation->addItem($item["name"], $item["id"], $item["text"]); + } + + $this->tpl->setContent($confirmation->getHTML()); + } + + protected function scoringReportingAlways() + { + return $this->controller->object->getScoreReporting() == ilObjFormATest::SCORE_REPORTING_ALWAYS && $this->controller->object->getParticipants()->hasParticipants(); + } + + protected function scoringReportingFinished(ilFormATestSession $session) + { + return $this->controller->object->getScoreReporting() == ilObjFormATest::SCORE_REPORTING_FINISHED && + $session->isPassFinished(); + } + + protected function scoringReportingDate() + { + $date = new ilDateTime(time(), IL_CAL_UNIX); + + return $this->controller->object->getScoreReporting() == ilObjFormATest::SCORE_REPORTING_DATE && + $date->_after($date, $this->controller->object->getReportingDate()); + } + + /** + * @param bool $finish_set + * @param ilQuestionSetPoolNode $node + * @param array $params + * + * @return string + */ + protected function generateJumpToNodeLink($finish_set, $node, $params = array(), $step = 0) + { + $this->ctrl->setParameter($this->controller, "node_id", $node["id"]); + $this->ctrl->setParameter($this->controller, "node_step", $step); + + if ($finish_set) { + $this->ctrl->setParameter($this->controller, "finished", 1); + } + foreach ($params as $key => $value) { + $this->ctrl->setParameter($this->controller, $key, $value); + } + $href = $this->ctrl->getLinkTarget($this->controller, "ilFormATestPlayerControllerGUI.jumpToNode", 'question_output'); + foreach ($params as $key => $value) { + $this->ctrl->setParameter($this->controller, $key, ""); + } + + $this->ctrl->setParameter($this->controller, "node_id", ""); + $this->ctrl->setParameter($this->controller, "finished", ""); + + return $href; + } } diff --git a/classes/controllers/abstract.ilXTSFControllerTableGUI.php b/classes/controllers/abstract.ilXTSFControllerTableGUI.php index 8f2d6210a660fad68024a1abdd0cd32195b71b72..7fdddfe77a8c1ec67f37932b149625fe06a7f58f 100644 --- a/classes/controllers/abstract.ilXTSFControllerTableGUI.php +++ b/classes/controllers/abstract.ilXTSFControllerTableGUI.php @@ -8,17 +8,17 @@ require_once "abstract.ilXTSFControllerGUI.php"; * Date: 02.10.13 * Time: 15:11 * @author Thomas Joußen - */ + */ abstract class ilXTSFControllerTableGUI extends ilXTSFControllerGUI { - /** - * @param string $key - * - * @return bool - */ - protected function dataSelected($key) - { - return (isset($_POST[$key]) && is_array($_POST[$key]) && count($_POST[$key]) > 0); - } + /** + * @param string $key + * + * @return bool + */ + protected function dataSelected($key) + { + return (isset($_POST[$key]) && is_array($_POST[$key]) && count($_POST[$key]) > 0); + } } diff --git a/classes/controllers/class.ilFormATestHistoryGUI.php b/classes/controllers/class.ilFormATestHistoryGUI.php index cd9d5c14d9542a097510480b250681143f55dc61..042d3e9cd458470249e78b908b521d6aa1052db3 100644 --- a/classes/controllers/class.ilFormATestHistoryGUI.php +++ b/classes/controllers/class.ilFormATestHistoryGUI.php @@ -6,52 +6,46 @@ require_once 'abstract.ilXTSFControllerGUI.php'; */ class ilFormATestHistoryGUI extends ilXTSFControllerGUI { - /** - * @param ilObjFormATestGUI $controller - */ - public function __construct(ilObjFormATestGUI $controller) - { - parent::__construct($controller); - } + /** + * @param ilObjFormATestGUI $controller + */ + public function __construct(ilObjFormATestGUI $controller) + { + parent::__construct($controller); + } - public function showHistory() - { - $this->controller->ensurePermission('write'); + public function showHistory() + { + $this->controller->ensurePermission('write'); - require_once 'Modules/Test/classes/tables/class.ilTestHistoryTableGUI.php'; - require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php'; + $table = new ilTestHistoryTableGUI($this->controller, __CLASS__ . '.showHistory'); + $table->setTestObject($this->controller->object); - $table = new ilTestHistoryTableGUI($this->controller, __CLASS__ . '.showHistory'); - $table->setTestObject($this->controller->object); + $log = ilObjAssessmentFolder::_getLog(0, time(), $this->controller->object->getId(), true); + foreach ($log as $row_idx => $data) { + foreach ($data as $key => $val) { + if ('href' == $key && strpos($val, 'tst_') !== false) { + $log[$row_idx][$key] = str_replace('tst_', 'xtsf_', $val); + } + } + } + $table->setData($log); + $this->tpl->setContent($table->getHTML()); + } - $log = ilObjAssessmentFolder::_getLog(0, time(), $this->controller->object->getId(), true); - foreach($log as $row_idx => $data) - { - foreach($data as $key => $val) - { - if('href' == $key && strpos($val, 'tst_') !== false) - { - $log[$row_idx][$key] = str_replace('tst_', 'xtsf_', $val); - } - } - } - $table->setData($log); - $this->tpl->setContent($table->getHTML()); - } + /** + * Returns the current tab name + * return string + */ + protected function getCurrentTab() + { + return 'history'; + } - /** - * Returns the current tab name - * return string - */ - protected function getCurrentTab() - { - return 'history'; - } - - /** - * @return array - */ - protected function getRequirements() - { - } -} \ No newline at end of file + /** + * @return array + */ + protected function getRequirements() + { + } +} diff --git a/classes/controllers/class.ilFormATestInfoScreenControllerGUI.php b/classes/controllers/class.ilFormATestInfoScreenControllerGUI.php index 084e7c9e7ec4126e55e0409a5f1d766537739aed..f1bd43896266b548cd93a32618b639c724a804c4 100644 --- a/classes/controllers/class.ilFormATestInfoScreenControllerGUI.php +++ b/classes/controllers/class.ilFormATestInfoScreenControllerGUI.php @@ -8,93 +8,90 @@ require_once "abstract.ilXTSFControllerGUI.php"; * Date: 12.12.13 * Time: 14:39 * @author Thomas Joußen - */ + */ class ilFormATestInfoScreenControllerGUI extends ilXTSFControllerGUI { - /** - * @var ilFormATestSession - */ - protected $session; - - /** - * @param ilObjFormATestGUI $controller - */ - public function __construct($controller) - { - parent::__construct($controller); - - $this->session = new ilFormATestSession($controller->object); - $this->session->read($controller->object->getSetList()->getData()); - } - - public function show() - { - $this->initToolbar(); - $this->addSessionSensitiveButton($this->session); - - $info = new ilFormATestInfoScreenGUI($this->controller); - $info->setIntro($this->controller->object->getIntroStatement()); - $this->tpl->setContent($info->getHTML()); - } - - public function showTestResults() - { - $this->controller->ensurePermission("read"); - - $output = new ilFormATestResultOuputGUI($this->controller); - $output->setHeader($this->plugin->txt("test_pass_overview")); - - $output->renderTestData($this->session->getUserId()); - $output->renderPassesOverview($this->session->getActiveId(), __CLASS__ .".showDetails"); - - $this->initToolbar(); - $this->addSessionSensitiveButton($this->session, array('test_results')); - $this->toolbar->addButton($this->lng->txt('print'), 'javascript:window.print();'); - $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print'); - - $this->tpl->setContent($output->getHTML()); - } - - public function showDetails() - { - $output = new ilFormATestResultOuputGUI($this->controller); - $output->setHeader($this->plugin->txt("test_pass_overview")); - $output->setModus(ilFormATestResultOuputGUI::MODUS_PARTICIPANTS); - $output->renderTestData($this->session->getUserId()); - $output->renderStepsOverview((int)$_GET["session_id"]); - $output->renderQuestionDetails((int)$_GET["session_id"], $this->controller->object->getSetList()->getData(), true, null, true); - - $this->initToolbar(); - $this->addToolbarButton("back", __CLASS__.".showTestResults"); - $this->addSessionSensitiveButton($this->session, array('test_results')); - $this->toolbar->addButton($this->lng->txt('print'), 'javascript:window.print();'); - $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print'); - - $this->tpl->setContent($output->getHTML()); - } - - /** - * Returns the current tab name - * return string - */ - protected function getCurrentTab() - { - return "info_short"; - } - - /** - * @return array - */ - protected function getRequirements() - { - require_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php"; - - return array( - "models/class.ilFormATestSession.php", - "utils/abstract.ilFormATestPlayerAccessHelper.php", - "utils/class.ilFormATestInfoScreenGUI.php", - "controllers/class.ilFormATestResultOuputGUI.php" - ); - } + /** + * @var ilFormATestSession + */ + protected $session; + + /** + * @param ilObjFormATestGUI $controller + */ + public function __construct($controller) + { + parent::__construct($controller); + + $this->session = new ilFormATestSession($controller->object); + $this->session->read($controller->object->getSetList()->getData()); + } + + public function show() + { + $this->initToolbar(); + $this->addSessionSensitiveButton($this->session); + + $info = new ilFormATestInfoScreenGUI($this->controller); + $info->setIntro($this->controller->object->getIntroStatement()); + $this->tpl->setContent($info->getHTML()); + } + + public function showTestResults() + { + $this->controller->ensurePermission("read"); + + $output = new ilFormATestResultOuputGUI($this->controller); + $output->setHeader($this->plugin->txt("test_pass_overview")); + + $output->renderTestData($this->session->getUserId()); + $output->renderPassesOverview($this->session->getActiveId(), __CLASS__ . ".showDetails"); + + $this->initToolbar(); + $this->addSessionSensitiveButton($this->session, array('test_results')); + $this->toolbar->addButton($this->lng->txt('print'), 'javascript:window.print();'); + $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print'); + + $this->tpl->setContent($output->getHTML()); + } + + public function showDetails() + { + $output = new ilFormATestResultOuputGUI($this->controller); + $output->setHeader($this->plugin->txt("test_pass_overview")); + $output->setModus(ilFormATestResultOuputGUI::MODUS_PARTICIPANTS); + $output->renderTestData($this->session->getUserId()); + $output->renderStepsOverview((int) $_GET["session_id"]); + $output->renderQuestionDetails((int) $_GET["session_id"], $this->controller->object->getSetList()->getData(), true, null, true); + + $this->initToolbar(); + $this->addToolbarButton("back", __CLASS__ . ".showTestResults"); + $this->addSessionSensitiveButton($this->session, array('test_results')); + $this->toolbar->addButton($this->lng->txt('print'), 'javascript:window.print();'); + $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print'); + + $this->tpl->setContent($output->getHTML()); + } + + /** + * Returns the current tab name + * return string + */ + protected function getCurrentTab() + { + return "info_short"; + } + + /** + * @return array + */ + protected function getRequirements() + { + return array( + "models/class.ilFormATestSession.php", + "utils/abstract.ilFormATestPlayerAccessHelper.php", + "utils/class.ilFormATestInfoScreenGUI.php", + "controllers/class.ilFormATestResultOuputGUI.php" + ); + } } - \ No newline at end of file diff --git a/classes/controllers/class.ilFormATestLearningProgressGUI.php b/classes/controllers/class.ilFormATestLearningProgressGUI.php index 6cd63796f69334ddba5dde6e49fdc993bdfada73..8910d172eecdbd77d8a061e24e5576c753120009 100644 --- a/classes/controllers/class.ilFormATestLearningProgressGUI.php +++ b/classes/controllers/class.ilFormATestLearningProgressGUI.php @@ -1,293 +1,274 @@ lng->loadLanguageModule('trac'); - $this->addSubTabs(); - } - - private function addSubTabs() - { - if($this->controller->hasPermission('write')) - { - if($this->controller->object->getLearningProgressMode() != ilObjFormATest::LP_MODE_DEACTIVATED) - { - $this->tabs->addSubTab('lp_users', $this->plugin->txt('lp_users'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.showLPUsers')); - $this->tabs->addSubTab('lp_summary', $this->plugin->txt('lp_summary'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.showLPSummary')); - } - $this->tabs->addSubTab('lp_settings', $this->lng->txt('trac_settings'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.showLPSettings')); - } - else if($this->controller->hasPermission('read') && $this->controller->object->getLearningProgressMode() != ilObjFormATest::LP_MODE_DEACTIVATED) - { - $this->tabs->addSubTab('lp_users', $this->plugin->txt('lp_users'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.showLPUserDetails')); - } - } - - /** - * - */ - public function showLPSettings(ilPropertyFormGUI $form = null) - { - $this->tabs->activateSubTab('lp_settings'); - $this->controller->ensurePermission('write'); - - if(!($form instanceof ilPropertyFormGUI)) - { - $form = $this->getLearningProgressSettingsForm(); - } - - $this->tpl->setContent($form->getHTML()); - } - - /** - * Init property form - * - * @return ilPropertyFormGUI $form - */ - public function getLearningProgressSettingsForm() - { - $form = new ilPropertyFormGUI(); - $form->setTitle($this->lng->txt('tracking_settings')); - $form->setFormAction($this->ctrl->getFormAction($this->controller, __CLASS__ . '.saveLearningProgressSettings')); - - $mod = new ilRadioGroupInputGUI($this->lng->txt('trac_mode'), 'modus'); - $mod->setRequired(true); - $form->addItem($mod); - - foreach($this->controller->object->getLPValidModes() as $mode) - { - $opt = new ilRadioOption( - ilLPObjSettings::_mode2Text($mode), - $mode, - ilLPObjSettings::_mode2InfoText($mode) - ); - $mod->addOption($opt); - } - $mod->setValue($this->controller->object->getLearningProgressMode()); - - $form->addCommandButton(__CLASS__ . '.saveLearningProgressSettings', $this->lng->txt('save')); - - return $form; - } - - /** - * Save learning progress settings - */ - public function saveLearningProgressSettings() - { - $this->controller->ensurePermission('write'); - $form = $this->getLearningProgressSettingsForm(); - if($form->checkInput()) - { - $new_mode = (int)$form->getInput('modus'); - $old_mode = (int)$this->controller->object->getLearningProgressMode(); - $mode_changed = ($old_mode != $new_mode); - - $this->controller->object->setLearningProgressMode($new_mode); - $this->controller->object->update(); - - if($mode_changed) - { - include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php'; - ilLPStatusWrapper::_refreshStatus($this->controller->object->getId()); - } - - ilUtil::sendSuccess($this->lng->txt('trac_settings_saved'), true); - $this->ctrl->redirect($this->controller, __CLASS__ . '.showLPSettings'); - } - - $form->setValuesByPost(); - $this->showLPSettings($form); - } - - /** - * - */ - public function showLPUsers() - { - $this->tabs->activateSubTab('lp_users'); - $this->controller->ensurePermission('write'); - $this->plugin->includeClass('class.ilFormATestLPUsersTableGUI.php'); - $table = new ilFormATestLPUsersTableGUI($this->controller, __CLASS__ . '.showLPUsers', $this->controller->object->getId(), $this->controller->object->getRefId(), false); - $this->tpl->setContent(implode('
', array($table->getHTML(), ilLearningProgressBaseGUI::__getLegendHTML()))); - } - - /** - * - */ - public function showLPSummary() - { - $this->tabs->activateSubTab('lp_summary'); - $this->controller->ensurePermission('write'); - $this->plugin->includeClass('class.ilFormATestLPSummaryTableGUI.php'); - $table = new ilFormATestLPSummaryTableGUI($this->controller, __CLASS__ . '.showLPSummary', $this->controller->object->getRefId(), $this->plugin); - $this->tpl->setContent(implode('
', array($table->getHTML(), ilLearningProgressBaseGUI::__getLegendHTML()))); - } - - public function showLPUserDetails() - { - $this->tabs->activateSubTab('lp_summary'); - $this->controller->ensurePermission('read'); - - if($this->controller->object->getLearningProgressMode() == ilObjFormATest::LP_MODE_DEACTIVATED) - { - $this->ctrl->redirect($this->controller, $this->controller->getStandardCmd()); - } - - include_once('./Services/InfoScreen/classes/class.ilInfoScreenGUI.php'); - $cloned_controller = clone $this->controller; - $cloned_controller->object = null; - $info = new ilInfoScreenGUI($cloned_controller); - $info->setFormAction($this->ctrl->getFormAction($this->controller, __CLASS__ . '.editUser')); - $info->addSection($this->lng->txt('trac_learning_progress')); - include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php"); - $status = ilLearningProgressBaseGUI::__readStatus($this->controller->object->getId(), $this->user->getId()); - $status_path = ilLearningProgressBaseGUI::_getImagePathForStatus($status); - $status_text = ilLearningProgressBaseGUI::_getStatusText($status); - $info->addProperty($this->lng->txt('trac_status'), ilUtil::img($status_path, $status_text)." ".$status_text); - include_once 'Services/Tracking/classes/class.ilLPMarks.php'; - if(strlen($mark = ilLPMarks::_lookupMark($this->user->getId(), $this->controller->object->getId()))) - { - $info->addProperty($this->lng->txt('trac_mark'),$mark); - } - if(strlen($comment = ilLPMarks::_lookupComment($this->user->getId(), $this->controller->object->getId()))) - { - $info->addProperty($this->lng->txt('trac_comment'),$comment); - } - - $this->tpl->setContent(implode('
', array($info->getHTML(), ilLearningProgressBaseGUI::__getLegendHTML()))); - } - - /** - * @param ilPropertyFormGUI $form - */ - public function editUser(ilPropertyFormGUI $form = null) - { - $this->tabs->activateSubTab('lp_users'); - $this->controller->ensurePermission('write'); - - if(!isset($_GET['user_id'])) - { - return $this->showLPUsers(); - } - - $user = ilObjectFactory::getInstanceByObjId((int)$_GET['user_id'], false); - if(!$user instanceof ilObjUser) - { - return $this->showLPUsers(); - } - - include_once('./Services/InfoScreen/classes/class.ilInfoScreenGUI.php'); - $cloned_controller = clone $this->controller; - $cloned_controller->object = null; - $info = new ilInfoScreenGUI($cloned_controller); - $info->setFormAction($this->ctrl->getFormAction($this->controller, __CLASS__ . '.editUser')); - $info->addSection($this->lng->txt('trac_user_data')); - $info->addProperty($this->lng->txt('last_login'), ilDatePresentation::formatDate(new ilDateTime($user->getLastLogin(), IL_CAL_DATETIME))); - $info->addProperty($this->lng->txt('trac_total_online'), ilDatePresentation::secondsToString(ilOnlineTracking::getOnlineTime($user->getId()))); - - if(!$form instanceof ilPropertyFormGUI) - { - $form = $this->getLPMarksForm($user); - - include_once 'Services/Tracking/classes/class.ilLPMarks.php'; - $marks = new ilLPMarks($this->controller->object->getId(), $user->getId()); - - $form->setValuesByArray(array( - 'comment' => $marks->getComment(), - 'mark' => $marks->getMark() - )); - } - - $this->tpl->setContent(implode('
', array($form->getHTML(), $info->getHTML()))); - } - - /** - * @param ilObjUser $user - * @return ilPropertyFormGUI - */ - protected function getLPMarksForm(ilObjUser $user) - { - require_once 'Services/Form/classes/class.ilPropertyFormGUI.php'; - $form = new ilPropertyFormGUI(); - $this->ctrl->setParameter($this->controller, 'user_id', $user->getId()); - $form->setFormAction($this->ctrl->getFormAction($this->controller, __CLASS__ . '.editUser')); - $form->setTitle($this->lng->txt('edit'). ': '. $this->lng->txt('trac_learning_progress_tbl_header') . $user->getFullname() ); - $form->setDescription($this->lng->txt('trac_mode').': '.ilLPObjSettings::_mode2Text($this->controller->object->getLearningProgressMode())); - - $mark = new ilTextInputGUI($this->lng->txt('trac_mark'), 'mark'); - $mark->setSize(5); - $form->addItem($mark); - - $comment = new ilTextInputGUI($this->lng->txt('trac_comment'), 'comment'); - $form->addItem($comment); - - $form->addCommandButton(__CLASS__ . '.updateLPUsers', $this->lng->txt('save')); - $form->addCommandButton(__CLASS__ . '.showLPUsers', $this->lng->txt('cancel')); - - return $form; - } - - public function updateLPUsers() - { - $this->tabs->activateSubTab('lp_users'); - $this->controller->ensurePermission('write'); - - if(!isset($_GET['user_id'])) - { - return $this->showLPUsers(); - } - - $user = ilObjectFactory::getInstanceByObjId((int)$_GET['user_id'], false); - if(!$user instanceof ilObjUser) - { - return $this->showLPUsers(); - } - - $form = $this->getLPMarksForm($user); - if($form->checkInput()) - { - include_once 'Services/Tracking/classes/class.ilLPMarks.php'; - $marks = new ilLPMarks($this->controller->object->getId(), $user->getId()); - $marks->setMark($form->getInput('mark')); - $marks->setComment($form->getInput('comment')); - $marks->update(); - ilUtil::sendSuccess($this->lng->txt('trac_update_edit_user')); - return $this->showLPUsers(); - } - - $form->setValuesByPost(); - $this->editUser($form); - } - - /** - * Returns the current tab name - * return string - */ - protected function getCurrentTab() - { - return 'learning_progress'; - } - - /** - * @return array - */ - protected function getRequirements() - { - } -} \ No newline at end of file + /** + * @param ilObjFormATestGUI $controller + */ + public function __construct(ilObjFormATestGUI $controller) + { + parent::__construct($controller); + + $this->lng->loadLanguageModule('trac'); + $this->addSubTabs(); + } + + private function addSubTabs() + { + if ($this->controller->hasPermission('write')) { + if ($this->controller->object->getLearningProgressMode() != ilObjFormATest::LP_MODE_DEACTIVATED) { + $this->tabs->addSubTab('lp_users', $this->plugin->txt('lp_users'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.showLPUsers')); + $this->tabs->addSubTab('lp_summary', $this->plugin->txt('lp_summary'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.showLPSummary')); + } + $this->tabs->addSubTab('lp_settings', $this->lng->txt('trac_settings'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.showLPSettings')); + } elseif ($this->controller->hasPermission('read') && $this->controller->object->getLearningProgressMode() != ilObjFormATest::LP_MODE_DEACTIVATED) { + $this->tabs->addSubTab('lp_users', $this->plugin->txt('lp_users'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.showLPUserDetails')); + } + } + + /** + * + */ + public function showLPSettings(ilPropertyFormGUI $form = null) + { + $this->tabs->activateSubTab('lp_settings'); + $this->controller->ensurePermission('write'); + + if (!($form instanceof ilPropertyFormGUI)) { + $form = $this->getLearningProgressSettingsForm(); + } + + $this->tpl->setContent($form->getHTML()); + } + + /** + * Init property form + * + * @return ilPropertyFormGUI $form + */ + public function getLearningProgressSettingsForm() + { + $form = new ilPropertyFormGUI(); + $form->setTitle($this->lng->txt('tracking_settings')); + $form->setFormAction($this->ctrl->getFormAction($this->controller, __CLASS__ . '.saveLearningProgressSettings')); + + $mod = new ilRadioGroupInputGUI($this->lng->txt('trac_mode'), 'modus'); + $mod->setRequired(true); + $form->addItem($mod); + + foreach ($this->controller->object->getLPValidModes() as $mode) { + $opt = new ilRadioOption( + ilLPObjSettings::_mode2Text($mode), + $mode, + ilLPObjSettings::_mode2InfoText($mode) + ); + $mod->addOption($opt); + } + $mod->setValue($this->controller->object->getLearningProgressMode()); + + $form->addCommandButton(__CLASS__ . '.saveLearningProgressSettings', $this->lng->txt('save')); + + return $form; + } + + /** + * Save learning progress settings + */ + public function saveLearningProgressSettings() + { + $this->controller->ensurePermission('write'); + $form = $this->getLearningProgressSettingsForm(); + if ($form->checkInput()) { + $new_mode = (int) $form->getInput('modus'); + $old_mode = (int) $this->controller->object->getLearningProgressMode(); + $mode_changed = ($old_mode != $new_mode); + + $this->controller->object->setLearningProgressMode($new_mode); + $this->controller->object->update(); + + if ($mode_changed) { + ilLPStatusWrapper::_refreshStatus($this->controller->object->getId()); + } + + ilUtil::sendSuccess($this->lng->txt('trac_settings_saved'), true); + $this->ctrl->redirect($this->controller, __CLASS__ . '.showLPSettings'); + } + + $form->setValuesByPost(); + $this->showLPSettings($form); + } + + /** + * + */ + public function showLPUsers() + { + $this->tabs->activateSubTab('lp_users'); + $this->controller->ensurePermission('write'); + $this->plugin->includeClass('class.ilFormATestLPUsersTableGUI.php'); + $table = new ilFormATestLPUsersTableGUI($this->controller, __CLASS__ . '.showLPUsers', $this->controller->object->getId(), $this->controller->object->getRefId(), false); + $lpBaseGui = new ilLearningProgressBaseGUI( + ilLearningProgressBaseGUI::LP_CONTEXT_REPOSITORY, + $this->controller->object->getRefId(), + $this->user->getId() + ); + $this->tpl->setContent(implode('
', array($table->getHTML(), $lpBaseGui->__getLegendHTML()))); + } + + /** + * + */ + public function showLPSummary() + { + $this->tabs->activateSubTab('lp_summary'); + $this->controller->ensurePermission('write'); + $this->plugin->includeClass('class.ilFormATestLPSummaryTableGUI.php'); + $table = new ilFormATestLPSummaryTableGUI($this->controller, __CLASS__ . '.showLPSummary', $this->controller->object->getRefId(), $this->plugin); + $lpBaseGui = new ilLearningProgressBaseGUI( + ilLearningProgressBaseGUI::LP_CONTEXT_REPOSITORY, + $this->controller->object->getRefId(), + $this->user->getId() + ); + $this->tpl->setContent(implode('
', array($table->getHTML(), $lpBaseGui->__getLegendHTML()))); + } + + public function showLPUserDetails() + { + $this->tabs->activateSubTab('lp_summary'); + $this->controller->ensurePermission('read'); + + if ($this->controller->object->getLearningProgressMode() == ilObjFormATest::LP_MODE_DEACTIVATED) { + $this->ctrl->redirect($this->controller, $this->controller->getStandardCmd()); + } + + $cloned_controller = clone $this->controller; + $cloned_controller->object = null; + $info = new ilInfoScreenGUI($cloned_controller); + $info->setFormAction($this->ctrl->getFormAction($this->controller, __CLASS__ . '.editUser')); + $info->addSection($this->lng->txt('trac_learning_progress')); + $status = ilLearningProgressBaseGUI::__readStatus($this->controller->object->getId(), $this->user->getId()); + $status_path = ilLearningProgressBaseGUI::_getImagePathForStatus($status); + $status_text = ilLearningProgressBaseGUI::_getStatusText($status); + $info->addProperty($this->lng->txt('trac_status'), ilUtil::img($status_path, $status_text) . " " . $status_text); + if (strlen($mark = ilLPMarks::_lookupMark($this->user->getId(), $this->controller->object->getId()))) { + $info->addProperty($this->lng->txt('trac_mark'), $mark); + } + if (strlen($comment = ilLPMarks::_lookupComment($this->user->getId(), $this->controller->object->getId()))) { + $info->addProperty($this->lng->txt('trac_comment'), $comment); + } + + $this->tpl->setContent(implode('
', array($info->getHTML(), ilLearningProgressBaseGUI::__getLegendHTML()))); + } + + /** + * @param ilPropertyFormGUI $form + */ + public function editUser(ilPropertyFormGUI $form = null) + { + $this->tabs->activateSubTab('lp_users'); + $this->controller->ensurePermission('write'); + + if (!isset($_GET['user_id'])) { + return $this->showLPUsers(); + } + + $user = ilObjectFactory::getInstanceByObjId((int) $_GET['user_id'], false); + if (!$user instanceof ilObjUser) { + return $this->showLPUsers(); + } + + $cloned_controller = clone $this->controller; + $cloned_controller->object = null; + $info = new ilInfoScreenGUI($cloned_controller); + $info->setFormAction($this->ctrl->getFormAction($this->controller, __CLASS__ . '.editUser')); + $info->addSection($this->lng->txt('trac_user_data')); + $info->addProperty($this->lng->txt('last_login'), ilDatePresentation::formatDate(new ilDateTime($user->getLastLogin(), IL_CAL_DATETIME))); + $info->addProperty($this->lng->txt('trac_total_online'), ilDatePresentation::secondsToString(ilOnlineTracking::getOnlineTime($user->getId()))); + + if (!$form instanceof ilPropertyFormGUI) { + $form = $this->getLPMarksForm($user); + + $marks = new ilLPMarks($this->controller->object->getId(), $user->getId()); + + $form->setValuesByArray(array( + 'comment' => $marks->getComment(), + 'mark' => $marks->getMark() + )); + } + + $this->tpl->setContent(implode('
', array($form->getHTML(), $info->getHTML()))); + } + + /** + * @param ilObjUser $user + * @return ilPropertyFormGUI + */ + protected function getLPMarksForm(ilObjUser $user) + { + $form = new ilPropertyFormGUI(); + $this->ctrl->setParameter($this->controller, 'user_id', $user->getId()); + $form->setFormAction($this->ctrl->getFormAction($this->controller, __CLASS__ . '.editUser')); + $form->setTitle($this->lng->txt('edit') . ': ' . $this->lng->txt('trac_learning_progress_tbl_header') . $user->getFullname()); + $form->setDescription($this->lng->txt('trac_mode') . ': ' . ilLPObjSettings::_mode2Text($this->controller->object->getLearningProgressMode())); + + $mark = new ilTextInputGUI($this->lng->txt('trac_mark'), 'mark'); + $mark->setSize(5); + $form->addItem($mark); + + $comment = new ilTextInputGUI($this->lng->txt('trac_comment'), 'comment'); + $form->addItem($comment); + + $form->addCommandButton(__CLASS__ . '.updateLPUsers', $this->lng->txt('save')); + $form->addCommandButton(__CLASS__ . '.showLPUsers', $this->lng->txt('cancel')); + + return $form; + } + + public function updateLPUsers() + { + $this->tabs->activateSubTab('lp_users'); + $this->controller->ensurePermission('write'); + + if (!isset($_GET['user_id'])) { + return $this->showLPUsers(); + } + + $user = ilObjectFactory::getInstanceByObjId((int) $_GET['user_id'], false); + if (!$user instanceof ilObjUser) { + return $this->showLPUsers(); + } + + $form = $this->getLPMarksForm($user); + if ($form->checkInput()) { + $marks = new ilLPMarks($this->controller->object->getId(), $user->getId()); + $marks->setMark($form->getInput('mark')); + $marks->setComment($form->getInput('comment')); + $marks->update(); + ilUtil::sendSuccess($this->lng->txt('trac_update_edit_user')); + return $this->showLPUsers(); + } + + $form->setValuesByPost(); + $this->editUser($form); + } + + /** + * Returns the current tab name + * return string + */ + protected function getCurrentTab() + { + return 'learning_progress'; + } + + /** + * @return array + */ + protected function getRequirements() + { + } +} diff --git a/classes/controllers/class.ilFormATestOutputGUI.php b/classes/controllers/class.ilFormATestOutputGUI.php index 359f0dab50a762de2e82d16bc2e68f6e80b83645..d31da29dcff71281e932bcf4131081cab9643065 100644 --- a/classes/controllers/class.ilFormATestOutputGUI.php +++ b/classes/controllers/class.ilFormATestOutputGUI.php @@ -8,485 +8,473 @@ require_once "abstract.ilXTSFControllerGUI.php"; * Date: 13.01.14 * Time: 15:21 * @author Thomas Joußen - */ + */ class ilFormATestOutputGUI extends ilXTSFControllerGUI { - /** - * @var ilFormATestSession - */ - protected $session; - - /** - * @param \ilFormATestSession $session - */ - public function setSession($session) - { - $this->session = $session; - } - - protected function populateCharSelector() - { - global $DIC; - $ilSetting = $DIC->settings(); - - if ($ilSetting->get('char_selector_availability') > 0) - { - require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php'; - // Chat selector doesn't support plugins - $test = new ilObjTest(); - $test->setCharSelectorAvailability($this->controller->object->getCharSelectorAvailability()); - $test->setCharSelectorDefinition($this->controller->object->getCharSelectorDefinition()); - - $char_selector = ilCharSelectorGUI::_getCurrentGUI($test); - if($char_selector->getConfig()->getAvailability() == ilCharSelectorConfig::ENABLED) - { - $char_selector->addToPage(); - $this->tpl->setCurrentBlock('char_selector'); - $this->tpl->setVariable("CHAR_SELECTOR_IMAGE", ilUtil::getImagePath('icon_omega_test.svg','Services/UIComponent/CharSelector')); - $this->tpl->setVariable("CHAR_SELECTOR_TEXT", $this->lng->txt('char_selector')); - $this->tpl->setVariable("CHAR_SELECTOR_TEMPLATE", $char_selector->getSelectorHtml()); - $this->tpl->parseCurrentBlock(); - } - } - } - - public function outTestPage($node) - { - $this->controller->ensurePermission("read"); - - $this->session->trackProgress(); - $is_fb_requested = ilSession::get($this->controller->object->getInstantFeedbackSessionKey()); - - $this->tpl->addCss('./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/templates/default/xtsf_player.css'); - $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_xtsf_output.html", "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); - - if(!$this->session->isFirstStep() && $this->controller->object->isAllowWalkBack()) - { - $this->renderButton($this->tpl, "prev"); - } - if($this->controller->object->isAllowInterruption()) - { - $this->renderButton($this->tpl, "interrupt"); - } - $this->renderButton($this->tpl, "interruptset"); - - $this->renderButton($this->tpl, "next"); - $this->populateContentStyleBlock(); - $this->populateSyntaxStyleBlock(); - $this->populateCharSelector(); - $this->renderSidebar($this->tpl); - if ($this->controller->object->getShowCurrentTrack()) - { - $this->renderCurrentResults($this->tpl); - } - - if( - !$this->session->hasFixatedSolution($node->getId()) && - $this->session->isDeadlockPossible() - ) - { - ilFormATestUtil::addInfo($this->plugin->txt("fixation_possible_msg")); - } - - $gui = assQuestion::instantiateQuestionGUI($node->getQuestion()->getId()); - $gui->object->setStep($this->session->getStep()); - $gui->setTargetGuiClass("ilObjFormATestGUI"); - $gui->setQuestionHeaderBlockBuilder(new ilFormATestParticipantQuestionHeaderBuilder($this->plugin, $node, $this->session)); - - if(!$this->session->hasFixatedSolution($node->getId()) && $is_fb_requested) - { - // This controls if the solution should be shown. - // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Solutions" - - $is_instant_feedback = (bool)$this->controller->object->getInstantFeedbackSolution() && ilSession::get($this->controller->object->getInstantFeedbackSessionKey()); - ilSession::set($this->controller->object->getInstantFeedbackSessionKey(), false); - - // This controls if the instant feedback solution should be shown. - // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show best solution" - - $is_feedback_generic = (bool)$this->controller->object->getGenericAnswerFeedback(); - $is_feedback_specific = (bool) $this->controller->object->getSpecificAnswerFeedback(); - - if($is_instant_feedback) - { - $show_question_inline_score = $this->determineInlineScoreDisplay(); -// $solutionoutput = $gui->getSolutionOutput($this->session->getActiveId(), NULL, FALSE, $is_instant_feedback); - $solutionoutput = $gui->getSolutionOutput( - $this->session->getActiveId(), - NULL, - FALSE, - $is_instant_feedback, - FALSE, - FALSE, - $is_fb_requested, - FALSE, - true - ); - $this->populateSolutionBlock($solutionoutput); - } - - // This controls if the score should be shown. - // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Results (Only Points)" - if($this->controller->object->getAnswerFeedbackPoints()) - { - $reachedPoints = $gui->object->getAdjustedReachedPoints($this->session->getActiveId(), NULL); - $maxPoints = $gui->object->getMaximumPoints(); - - $this->populateScoreBlock($reachedPoints, $maxPoints); - } - - // This controls if the generic feedback should be shown. - // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Solutions" - if($this->controller->object->getGenericAnswerFeedback()) - { - $this->populateGenericFeedbackBlock($gui); - } - - // This controls if the specific feedback should be shown. - // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Answer-Specific Feedback" - if($this->controller->object->getSpecificAnswerFeedback()) - { - $this->populateSpecificFeedbackBlock($gui); - } - } - $this->fillQuestionRelatedNavigation($gui); - - ilFormATestUtil::send(); - $user_solutions = false; - if(array_key_exists('previouspost', $_SESSION)) - { - $user_solutions = $_SESSION['previouspost']; - unset($_SESSION['previouspost']); - } - - $gui->outQuestionForTest($this->getQuestionPageFormAction(), $this->session->getActiveId(), $this->session->getPass(), false, $user_solutions, $is_feedback_specific); - } - - private function showFeedbackButton() - { - $tpl = $this->tpl; - $lng = $this->lng; - $tpl->setCurrentBlock("direct_feedback"); - $tpl->setVariable("CMD_SHOW_INSTANT_RESPONSE", 'showInstantResponse'); - $tpl->setVariable("TEXT_SHOW_INSTANT_RESPONSE", $lng->txt("check")); - $tpl->parseCurrentBlock(); - } - - protected function populateSpecificFeedbackBlock($question_gui) - { - $this->tpl->setCurrentBlock( "specific_feedback" ); - $this->tpl->setVariable( "SPECIFIC_FEEDBACK", - $question_gui->getSpecificFeedbackOutput( - $this->session->getActiveId(), - NULL - ) - ); - $this->tpl->parseCurrentBlock(); - } - - protected function populateGenericFeedbackBlock($question_gui) - { - $this->tpl->setCurrentBlock( "answer_feedback" ); - $this->tpl->setVariable( "ANSWER_FEEDBACK", - $question_gui->getAnswerFeedbackOutput( $this->session->getActiveId(), - NULL - ) - ); - $this->tpl->parseCurrentBlock(); - } - - protected function populateScoreBlock($reachedPoints, $maxPoints) - { - $scoreInformation = sprintf( - $this->lng->txt( "you_received_a_of_b_points" ), $reachedPoints, $maxPoints - ); - - $this->tpl->setCurrentBlock( "received_points_information" ); - $this->tpl->setVariable("RECEIVED_POINTS_INFORMATION", $scoreInformation); - $this->tpl->parseCurrentBlock(); - } - - protected function populateSolutionBlock($solutionoutput) - { - $this->tpl->setCurrentBlock( "solution_output" ); - $this->tpl->setVariable( "CORRECT_SOLUTION", $this->lng->txt( "tst_best_solution_is" ) ); - $this->tpl->setVariable( "QUESTION_FEEDBACK", $solutionoutput ); - $this->tpl->parseCurrentBlock(); - } - - protected function fillQuestionRelatedNavigation(assQuestionGUI $questionGUI) - { - $tpl = $this->tpl; - - $parseQuestionRelatedNavigation = false; - - switch( 1 ) - { - case $this->controller->object->getSpecificAnswerFeedback(): - case $this->controller->object->getGenericAnswerFeedback(): - case $this->controller->object->getAnswerFeedbackPoints(): - case $this->controller->object->getInstantFeedbackSolution(): - - $this->showFeedbackButton(); - - $parseQuestionRelatedNavigation = true; - } - - if( $parseQuestionRelatedNavigation ) - { - $tpl->setCurrentBlock("question_related_navigation"); - $tpl->parseCurrentBlock(); - } - } - - public function outFinishSet() - { - $this->controller->ensurePermission("read"); - - $this->tpl->addCss('./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/templates/default/xtsf_player.css'); - $template = new ilTemplate("tpl.il_xtsf_finish_set.html", true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); - - if($this->session->hasNextSet() && !($this->controller->object->isAllowWalkBack() && $this->controller->object->getShowQuestionsOverview())) - { - ilUtil::sendInfo($this->plugin->txt("finish_set_information")); - $this->renderButton($template, "nextset"); - } - elseif($this->session->allSetsFinished()) - { - ilFormATestUtil::addInfo($this->plugin->txt("finish_test_information")); - } - else - { - ilFormATestUtil::addInfo($this->plugin->txt("finish_set_information_choose_list")); - } - $this->renderButton($template, "finishtest"); - - if($this->controller->object->isAllowInterruption()) - { - $this->renderButton($template, "interrupt"); - } - - if($this->controller->object->isAllowWalkBack()) - { - $this->renderButton($template, "back"); - } - - $template->setVariable("FORMACTION", $this->getQuestionPageFormAction()); - - $this->renderCurrentResults($template); - $this->renderSidebar($template, true); - - ilFormATestUtil::send(); - $this->tpl->setContent($template->get()); - } - - /** - * @param $template - * @param $type - */ - protected function renderButton($template, $type) - { - $template->setCurrentBlock("{$type}"); - $template->setVariable("CMD", "ilFormATestPlayerControllerGUI.$type"); - $template->setVariable("BTN", $this->plugin->txt($type)); - $template->parseCurrentBlock(); - - $template->setCurrentBlock("{$type}_bottom"); - $template->setVariable("CMD", "ilFormATestPlayerControllerGUI.$type"); - $template->setVariable("BTN", $this->plugin->txt($type)); - $template->parseCurrentBlock(); - } - - protected function populateContentStyleBlock() - { - include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php"); - $this->tpl->setCurrentBlock( "ContentStyle" ); - $this->tpl->setVariable( "LOCATION_CONTENT_STYLESHEET",ilObjStyleSheet::getContentStylePath(0)); - $this->tpl->parseCurrentBlock(); - - $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print"); - $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "ta.css", "Modules/Test"), "screen"); - } - - protected function populateSyntaxStyleBlock() - { - $this->tpl->setCurrentBlock( "SyntaxStyle" ); - $this->tpl->setVariable( "LOCATION_SYNTAX_STYLESHEET",ilObjStyleSheet::getSyntaxStylePath()); - $this->tpl->parseCurrentBlock(); - } - - /** - * @return string - */ - protected function getQuestionPageFormAction() - { - $this->ctrl->setParameter($this->controller, "active_id", $this->session->getActiveId()); - $this->ctrl->setParameter($this->controller, "xtsf_token", $this->session->getToken()); - $formaction = $this->ctrl->getFormAction($this->controller); - $this->ctrl->setParameter($this->controller, "active_id", ""); - $this->ctrl->setParameter($this->controller, "xtsf_token", ""); - - return $formaction; - } - - /** - * Returns the current tab name - * return string - */ - protected function getCurrentTab() - { - } - - /** - * @return array - */ - protected function getRequirements() - { - return array( - "models/class.ilFormATestSession.php", - "models/class.ilFormATestResultList.php", - "models/class.ilFormATestSetResultList.php", - "models/class.ilFormATestSetStepList.php", - "utils/class.ilFormATestParticipantQuestionHeaderBuilder.php", - "utils/class.ilFormATestParticipantQuestionHeaderBuilder.php", - "utils/class.ilFormATestAccordionGUI.php", - "utils/abstract.ilFormATestUtil.php", - "tables/class.ilFormATestResultsTableGUI.php", - "tables/class.ilFormATestSetResultTableGUI.php", - "controllers/class.ilFormATestResultOuputGUI.php" - ); - } - - /** - * @param ilTemplate $template - * @param bool $finish_set - */ - protected function renderSidebar($template, $finish_set = false) - { - if ($this->controller->object->getShowQuestionsOverview()) - { - $left_template = new ilTemplate('tpl.il_xtsf_result_path.html', true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); - - $sets = $this->controller->object->getSetList()->getData(); - - $i = 0; - foreach ($sets as $set) - { - $nodes_model = new ilFormATestSetStepList($this->controller->object, $set["id"], $this->session->getSessionId()); - $nodes = $nodes_model->getData(); - - $this->session->reachedDeadlock(); - $step = 0; - foreach($nodes as $node) - { - $title = $this->plugin->txt("header_step") . ": ". ++$step; - - if($this->session->hasFixatedSolution($node["id"])) - { - $title .= ' '; - } - - if($this->isCurrent($node)) - { - $title .= " ⊗"; - } - - if($this->isCurrent($node) || !$this->controller->object->isAllowWalkBack()) - { - $left_template->setCurrentBlock("unlinked_line"); - //$template->setVariable("QUESTION_INDEX", $node["question_index"]); - $left_template->setVariable("QUESTION_TITLE", $title); - $left_template->parseCurrentBlock(); - } - else - { - $left_template->setCurrentBlock("linked_line"); - $left_template->setVariable("LINK", $this->generateJumpToNodeLink( - $finish_set, - $node, - array("xtsf_token" => $this->session->getToken()), - $step - )); - - //$template->setVariable("QUESTION_INDEX", $node["question_index"]); - $left_template->setVariable("QUESTION_TITLE", $title); - $left_template->parseCurrentBlock(); - } - } - $status = $this->session->getSetStatus($set["id"]); - if($status != null) - { - $status = $this->plugin->txt("status_".$status); - } - else - { - $status = $this->plugin->txt("status_not_started"); - } - - $left_template->setCurrentBlock("set"); - $left_template->setVariable("SET_TITLE", ++$i . ". " . $set["title"]); - $left_template->setVariable("SET_STATUS", $status); - $left_template->parseCurrentBlock(); - } - $left_template->setCurrentBlock("result_path"); - $left_template->setVariable("QUESTIONS_OVERVIEW", $this->plugin->txt("questions_overview_title")); - $left_template->parseCurrentBlock(); - - $GLOBALS['tpl']->setLeftNavContent($left_template->get()); - } - } - - /** - * @param ilTemplate $template - */ - protected function renderCurrentResults($template) - { - $accordion = new ilFormATestAccordionGUI(); - $accordion->setId('accord_xtsf_' . $this->controller->plugin->getId()); - - $accordion->setOrientation(ilFormATestAccordionGUI::HORIZONTAL); - $accordion->setBehaviour(ilFormATestAccordionGUI::ONE_OPEN_SESSION); - - $accordion->setContentHeight("300px"); - - $result_overview = ""; - $i = 0; - $template->setVariable("RESULT_OVERVIEW_TITLE", $this->plugin->txt("result_overview_title")); - foreach($this->controller->object->getSetList()->getData() as $set) - { - $output = new ilFormATestResultOuputGUI($this->controller); - $output->initTemplate("tpl.xtsf_tst_question_overview.html"); - $output->setModus(ilFormATestResultOuputGUI::MODUS_PARTICIPANTS); - $output->renderQuestionDetails($this->session->getSessionId(), array($set), false, $this->session->getNodeId(), false); - - $force_open = $this->session->getSetId() == $set["id"]; - $accordion->addItem(++$i, $output->getHTML(), $force_open); - } - $result_overview .= $accordion->getHTML(); - $template->setVariable("RESULT_OVERVIEW", $result_overview); - } - - /** - * @param $node - * - * @return bool - */ - protected function isCurrent($node) - { - $is_current_node = ($node["id"] == $this->session->getNodeId() && $this->session->getSetStatus() == ilFormATestSession::STATUS_IN_PROGRESS); - - return $is_current_node; - } - - protected function determineInlineScoreDisplay() - { - $show_question_inline_score = FALSE; - if ($this->controller->object->getAnswerFeedbackPoints()) - { - $show_question_inline_score = TRUE; - return $show_question_inline_score; - } - return $show_question_inline_score; - } + /** + * @var ilFormATestSession + */ + protected $session; + + /** @var \ILIAS\GlobalScreen\Services */ + private $gs; + + public function __construct(ilObjFormATestGUI $controller) + { + global $DIC; + parent::__construct($controller); + + $this->gs = $DIC->globalScreen(); + } + + /** + * @param \ilFormATestSession $session + */ + public function setSession($session) + { + $this->session = $session; + } + + protected function populateCharSelector() + { + global $DIC; + $ilSetting = $DIC->settings(); + + if ($ilSetting->get('char_selector_availability') > 0) { + // Chat selector doesn't support plugins + $test = new ilObjTest(); + $test->setCharSelectorAvailability($this->controller->object->getCharSelectorAvailability()); + $test->setCharSelectorDefinition($this->controller->object->getCharSelectorDefinition()); + + $char_selector = ilCharSelectorGUI::_getCurrentGUI($test); + if ($char_selector->getConfig()->getAvailability() == ilCharSelectorConfig::ENABLED) { + $char_selector->addToPage(); + $this->tpl->setCurrentBlock('char_selector'); + $this->tpl->setVariable("CHAR_SELECTOR_IMAGE", ilUtil::getImagePath('icon_omega_test.svg', 'Services/UIComponent/CharSelector')); + $this->tpl->setVariable("CHAR_SELECTOR_TEXT", $this->lng->txt('char_selector')); + $this->tpl->setVariable("CHAR_SELECTOR_TEMPLATE", $char_selector->getSelectorHtml()); + $this->tpl->parseCurrentBlock(); + } + } + } + + public function outTestPage($node) + { + $this->controller->ensurePermission("read"); + + $this->session->trackProgress(); + $is_fb_requested = ilSession::get($this->controller->object->getInstantFeedbackSessionKey()); + + $this->tpl->addCss('./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/templates/default/xtsf_player.css'); + $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_xtsf_output.html", "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); + + if (!$this->session->isFirstStep() && $this->controller->object->isAllowWalkBack()) { + $this->renderButton($this->tpl, "prev"); + } + if ($this->controller->object->isAllowInterruption()) { + $this->renderButton($this->tpl, "interrupt"); + } + $this->renderButton($this->tpl, "interruptset"); + + $this->renderButton($this->tpl, "next"); + $this->populateContentStyleBlock(); + $this->populateSyntaxStyleBlock(); + $this->populateCharSelector(); + $this->renderSidebar($this->tpl); + if ($this->controller->object->getShowCurrentTrack()) { + $this->renderCurrentResults($this->tpl); + } + + if ( + !$this->session->hasFixatedSolution($node->getId()) && + $this->session->isDeadlockPossible() + ) { + ilFormATestUtil::addInfo($this->plugin->txt("fixation_possible_msg")); + } + + $gui = assQuestion::instantiateQuestionGUI($node->getQuestion()->getId()); + $gui->object->setStep($this->session->getStep()); + $gui->setTargetGuiClass("ilObjFormATestGUI"); + $gui->setQuestionHeaderBlockBuilder(new ilFormATestParticipantQuestionHeaderBuilder($this->plugin, $node, $this->session)); + + if (!$this->session->hasFixatedSolution($node->getId()) && $is_fb_requested) { + // This controls if the solution should be shown. + // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Solutions" + + $is_instant_feedback = (bool) $this->controller->object->getInstantFeedbackSolution() && ilSession::get($this->controller->object->getInstantFeedbackSessionKey()); + ilSession::set($this->controller->object->getInstantFeedbackSessionKey(), false); + + // This controls if the instant feedback solution should be shown. + // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show best solution" + + $is_feedback_generic = (bool) $this->controller->object->getGenericAnswerFeedback(); + $is_feedback_specific = (bool) $this->controller->object->getSpecificAnswerFeedback(); + + if ($is_instant_feedback) { + $show_question_inline_score = $this->determineInlineScoreDisplay(); + // $solutionoutput = $gui->getSolutionOutput($this->session->getActiveId(), NULL, FALSE, $is_instant_feedback); + $solutionoutput = $gui->getSolutionOutput( + $this->session->getActiveId(), + null, + false, + $is_instant_feedback, + false, + false, + $is_fb_requested, + false, + true + ); + $this->populateSolutionBlock($solutionoutput); + } + + // This controls if the score should be shown. + // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Results (Only Points)" + if ($this->controller->object->getAnswerFeedbackPoints()) { + $reachedPoints = $gui->object->getAdjustedReachedPoints($this->session->getActiveId(), null); + $maxPoints = $gui->object->getMaximumPoints(); + + $this->populateScoreBlock($reachedPoints, $maxPoints); + } + + // This controls if the generic feedback should be shown. + // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Solutions" + if ($this->controller->object->getGenericAnswerFeedback()) { + $this->populateGenericFeedbackBlock($gui); + } + + // This controls if the specific feedback should be shown. + // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Answer-Specific Feedback" + if ($this->controller->object->getSpecificAnswerFeedback()) { + $this->populateSpecificFeedbackBlock($gui); + } + } + $this->fillQuestionRelatedNavigation($gui); + + ilFormATestUtil::send(); + $user_solutions = false; + if (array_key_exists('previouspost', $_SESSION)) { + $user_solutions = $_SESSION['previouspost']; + unset($_SESSION['previouspost']); + } + + $gui->outQuestionForTest($this->getQuestionPageFormAction(), $this->session->getActiveId(), $this->session->getPass(), false, $user_solutions, $is_feedback_specific); + } + + private function showFeedbackButton() + { + $tpl = $this->tpl; + $lng = $this->lng; + $tpl->setCurrentBlock("direct_feedback"); + $tpl->setVariable("CMD_SHOW_INSTANT_RESPONSE", 'showInstantResponse'); + $tpl->setVariable("TEXT_SHOW_INSTANT_RESPONSE", $lng->txt("check")); + $tpl->parseCurrentBlock(); + } + + protected function populateSpecificFeedbackBlock($question_gui) + { + $this->tpl->setCurrentBlock("specific_feedback"); + $this->tpl->setVariable( + "SPECIFIC_FEEDBACK", + $question_gui->getSpecificFeedbackOutput( + $this->session->getActiveId(), + null + ) + ); + $this->tpl->parseCurrentBlock(); + } + + protected function populateGenericFeedbackBlock($question_gui) + { + $this->tpl->setCurrentBlock("answer_feedback"); + $this->tpl->setVariable( + "ANSWER_FEEDBACK", + $question_gui->getAnswerFeedbackOutput( + $this->session->getActiveId(), + null + ) + ); + $this->tpl->parseCurrentBlock(); + } + + protected function populateScoreBlock($reachedPoints, $maxPoints) + { + $scoreInformation = sprintf( + $this->lng->txt("you_received_a_of_b_points"), + $reachedPoints, + $maxPoints + ); + + $this->tpl->setCurrentBlock("received_points_information"); + $this->tpl->setVariable("RECEIVED_POINTS_INFORMATION", $scoreInformation); + $this->tpl->parseCurrentBlock(); + } + + protected function populateSolutionBlock($solutionoutput) + { + $this->tpl->setCurrentBlock("solution_output"); + $this->tpl->setVariable("CORRECT_SOLUTION", $this->lng->txt("tst_best_solution_is")); + $this->tpl->setVariable("QUESTION_FEEDBACK", $solutionoutput); + $this->tpl->parseCurrentBlock(); + } + + protected function fillQuestionRelatedNavigation(assQuestionGUI $questionGUI) + { + $tpl = $this->tpl; + + $parseQuestionRelatedNavigation = false; + + switch (1) { + case $this->controller->object->getSpecificAnswerFeedback(): + case $this->controller->object->getGenericAnswerFeedback(): + case $this->controller->object->getAnswerFeedbackPoints(): + case $this->controller->object->getInstantFeedbackSolution(): + + $this->showFeedbackButton(); + + $parseQuestionRelatedNavigation = true; + } + + if ($parseQuestionRelatedNavigation) { + $tpl->setCurrentBlock("question_related_navigation"); + $tpl->parseCurrentBlock(); + } + } + + public function outFinishSet() + { + $this->controller->ensurePermission("read"); + + $this->tpl->addCss('./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/templates/default/xtsf_player.css'); + $template = new ilTemplate("tpl.il_xtsf_finish_set.html", true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); + + if ($this->session->hasNextSet() && !($this->controller->object->isAllowWalkBack() && $this->controller->object->getShowQuestionsOverview())) { + ilUtil::sendInfo($this->plugin->txt("finish_set_information")); + $this->renderButton($template, "nextset"); + } elseif ($this->session->allSetsFinished()) { + ilFormATestUtil::addInfo($this->plugin->txt("finish_test_information")); + } else { + ilFormATestUtil::addInfo($this->plugin->txt("finish_set_information_choose_list")); + } + $this->renderButton($template, "finishtest"); + + if ($this->controller->object->isAllowInterruption()) { + $this->renderButton($template, "interrupt"); + } + + if ($this->controller->object->isAllowWalkBack()) { + $this->renderButton($template, "back"); + } + + $template->setVariable("FORMACTION", $this->getQuestionPageFormAction()); + + $this->renderCurrentResults($template); + $this->renderSidebar($template, true); + + ilFormATestUtil::send(); + $this->tpl->setContent($template->get()); + } + + /** + * @param $template + * @param $type + */ + protected function renderButton($template, $type) + { + $template->setCurrentBlock("{$type}"); + $template->setVariable("CMD", "ilFormATestPlayerControllerGUI.$type"); + $template->setVariable("BTN", $this->plugin->txt($type)); + $template->parseCurrentBlock(); + + $template->setCurrentBlock("{$type}_bottom"); + $template->setVariable("CMD", "ilFormATestPlayerControllerGUI.$type"); + $template->setVariable("BTN", $this->plugin->txt($type)); + $template->parseCurrentBlock(); + } + + protected function populateContentStyleBlock() + { + $this->tpl->setCurrentBlock("ContentStyle"); + $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0)); + $this->tpl->parseCurrentBlock(); + + $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print"); + $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "ta.css", "Modules/Test"), "screen"); + } + + protected function populateSyntaxStyleBlock() + { + $this->tpl->setCurrentBlock("SyntaxStyle"); + $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath()); + $this->tpl->parseCurrentBlock(); + } + + /** + * @return string + */ + protected function getQuestionPageFormAction() + { + $this->ctrl->setParameter($this->controller, "active_id", $this->session->getActiveId()); + $this->ctrl->setParameter($this->controller, "xtsf_token", $this->session->getToken()); + $formaction = $this->ctrl->getFormAction($this->controller); + $this->ctrl->setParameter($this->controller, "active_id", ""); + $this->ctrl->setParameter($this->controller, "xtsf_token", ""); + + return $formaction; + } + + /** + * Returns the current tab name + * return string + */ + protected function getCurrentTab() + { + } + + /** + * @return array + */ + protected function getRequirements() + { + return array( + "models/class.ilFormATestSession.php", + "models/class.ilFormATestResultList.php", + "models/class.ilFormATestSetResultList.php", + "models/class.ilFormATestSetStepList.php", + "utils/class.ilFormATestParticipantQuestionHeaderBuilder.php", + "utils/class.ilFormATestParticipantQuestionHeaderBuilder.php", + "utils/class.ilFormATestAccordionGUI.php", + "utils/abstract.ilFormATestUtil.php", + "tables/class.ilFormATestResultsTableGUI.php", + "tables/class.ilFormATestSetResultTableGUI.php", + "controllers/class.ilFormATestResultOuputGUI.php" + ); + } + + /** + * @param ilTemplate $template + * @param bool $finish_set + */ + protected function renderSidebar($template, $finish_set = false) + { + if ($this->controller->object->getShowQuestionsOverview()) { + $left_template = new ilTemplate('tpl.il_xtsf_result_path.html', true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); + + $sets = $this->controller->object->getSetList()->getData(); + + $i = 0; + foreach ($sets as $set) { + $nodes_model = new ilFormATestSetStepList($this->controller->object, $set["id"], $this->session->getSessionId()); + $nodes = $nodes_model->getData(); + + $this->session->reachedDeadlock(); + $step = 0; + foreach ($nodes as $node) { + $title = $this->plugin->txt("header_step") . ": " . ++$step; + + if ($this->session->hasFixatedSolution($node["id"])) { + $title .= ' '; + } + + if ($this->isCurrent($node)) { + $title .= " ⊗"; + } + + if ($this->isCurrent($node) || !$this->controller->object->isAllowWalkBack()) { + $left_template->setCurrentBlock("unlinked_line"); + //$template->setVariable("QUESTION_INDEX", $node["question_index"]); + $left_template->setVariable("QUESTION_TITLE", $title); + $left_template->parseCurrentBlock(); + } else { + $left_template->setCurrentBlock("linked_line"); + $left_template->setVariable("LINK", $this->generateJumpToNodeLink( + $finish_set, + $node, + array("xtsf_token" => $this->session->getToken()), + $step + )); + + //$template->setVariable("QUESTION_INDEX", $node["question_index"]); + $left_template->setVariable("QUESTION_TITLE", $title); + $left_template->parseCurrentBlock(); + } + } + $status = $this->session->getSetStatus($set["id"]); + if ($status != null) { + $status = $this->plugin->txt("status_" . $status); + } else { + $status = $this->plugin->txt("status_not_started"); + } + + $left_template->setCurrentBlock("set"); + $left_template->setVariable("SET_TITLE", ++$i . ". " . $set["title"]); + $left_template->setVariable("SET_STATUS", $status); + $left_template->parseCurrentBlock(); + } + $left_template->setCurrentBlock("result_path"); + $left_template->setVariable("QUESTIONS_OVERVIEW", $this->plugin->txt("questions_overview_title")); + $left_template->parseCurrentBlock(); + + $toolContext = $this->gs + ->tool() + ->context() + ->current(); + require_once __DIR__ . '/../providers/FormATestGlobalScreenToolsProvider.php'; + $additionalDataExists = $toolContext->getAdditionalData()->exists(FormATestGlobalScreenToolsProvider::LEFT_NAV); + if (false === $additionalDataExists) { + $toolContext->addAdditionalData(FormATestGlobalScreenToolsProvider::LEFT_NAV, $left_template->get()); + } + } + } + + /** + * @param ilTemplate $template + */ + protected function renderCurrentResults($template) + { + $accordion = new ilFormATestAccordionGUI(); + $accordion->setId('accord_xtsf_' . $this->controller->plugin->getId()); + + $accordion->setOrientation(ilFormATestAccordionGUI::HORIZONTAL); + $accordion->setBehaviour(ilFormATestAccordionGUI::ONE_OPEN_SESSION); + + $accordion->setContentHeight("300px"); + + $result_overview = ""; + $i = 0; + $template->setVariable("RESULT_OVERVIEW_TITLE", $this->plugin->txt("result_overview_title")); + foreach ($this->controller->object->getSetList()->getData() as $set) { + $output = new ilFormATestResultOuputGUI($this->controller); + $output->initTemplate("tpl.xtsf_tst_question_overview.html"); + $output->setModus(ilFormATestResultOuputGUI::MODUS_PARTICIPANTS); + $output->renderQuestionDetails($this->session->getSessionId(), array($set), false, $this->session->getNodeId(), false); + + $force_open = $this->session->getSetId() == $set["id"]; + $accordion->addItem(++$i, $output->getHTML(), $force_open); + } + $result_overview .= $accordion->getHTML(); + $template->setVariable("RESULT_OVERVIEW", $result_overview); + } + + /** + * @param $node + * + * @return bool + */ + protected function isCurrent($node) + { + $is_current_node = ($node["id"] == $this->session->getNodeId() && $this->session->getSetStatus() == ilFormATestSession::STATUS_IN_PROGRESS); + + return $is_current_node; + } + + protected function determineInlineScoreDisplay() + { + $show_question_inline_score = false; + if ($this->controller->object->getAnswerFeedbackPoints()) { + $show_question_inline_score = true; + return $show_question_inline_score; + } + return $show_question_inline_score; + } } diff --git a/classes/controllers/class.ilFormATestParticipantsGUI.php b/classes/controllers/class.ilFormATestParticipantsGUI.php index 5d57ebcb3c704dd8bd57cd0fc4ad349def11593d..aefa175435a39f456a21e1f8f06b3af3a54df6e2 100644 --- a/classes/controllers/class.ilFormATestParticipantsGUI.php +++ b/classes/controllers/class.ilFormATestParticipantsGUI.php @@ -8,254 +8,235 @@ require_once "abstract.ilXTSFControllerTableGUI.php"; * Date: 17.01.14 * Time: 11:21 * @author Thomas Joußen - */ + */ class ilFormATestParticipantsGUI extends ilXTSFControllerTableGUI { - - public function show() - { - $this->controller->ensurePermission("write"); - - $table = new ilFormATestParticipantsTableGUI($this->controller, $this->plugin, ""); - $table->setModelList($this->controller->object->getParticipants()); - $table->populate(); - $table->addCommandButton("ilFormATestParticipantsGUI.removeAllResults", $this->plugin->txt("remove_all_results")); - $table->addMultiCommand("ilFormATestParticipantsGUI.showSelectedUserResults", $this->plugin->txt("show_results")); - $table->addMultiCommand("ilFormATestParticipantsGUI.showSelectedUserAnswers", $this->plugin->txt("show_answers")); - $table->addMultiCommand("ilFormATestParticipantsGUI.showSelectedUserDetails", $this->plugin->txt("show_details")); - $table->addMultiCommand("ilFormATestParticipantsGUI.removeSelectedUserResults", $this->plugin->txt("remove_results")); - $this->tpl->setContent($table->getHTML()); - } - - public function showUserResults() - { - $this->controller->ensurePermission("write"); - $this->addToolbarButton("back", "ilFormATestParticipantsGUI.show"); - - $this->toolbar->addButton($this->lng->txt('print'), 'javascript:window.print();'); - /*$src = ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")); - $img = ''; - $this->ctrl->setParameter($this->controller, 'active_id', (int)$_GET["active_id"]); - $this->ctrl->setParameter($this->controller, 'pdf', '1'); - $this->toolbar->addButton($img . $this->lng->txt('pdf_export'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.showUserResults')); - $this->ctrl->setParameter($this->controller, 'pdf', '');*/ - $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print'); - - $output = new ilFormATestResultOuputGUI($this->controller); - $output->setHeader($this->plugin->txt("test_pass_overview_author")); - $output->renderTestData(ilFormATestSession::getUserIdByActiveId((int)$_GET["active_id"])); - $output->renderPassesOverview((int)$_GET["active_id"]); - - /*if(isset($_GET['pdf']) && $_GET['pdf'] == 1) - { - require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php'; - ilTestPDFGenerator::generatePDF($output->getHTML(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->controller->object->getTitle()); - }*/ - - $this->tpl->setContent($output->getHTML()); - } - - public function showUserDetails() - { - $this->controller->ensurePermission("write"); - - $user_id = ilFormATestSession::getUserIdBySessionId((int)$_GET["session_id"]); - $output = new ilFormATestResultOuputGUI($this->controller); - $output->setHeader($this->plugin->txt("test_pass_overview_author")); - $output->renderTestData($user_id); - $output->renderStepsOverview((int)$_GET["session_id"]); - $output->renderQuestionDetails((int)$_GET["session_id"], $this->controller->object->getSetList()->getData(), true, null, true); - - $this->addToolbarButton("back", "ilFormATestParticipantsGUI.showUserResults", array( - "active_id" => ilFormATestSession::getActiveIdBySessionId((int)$_GET["session_id"]) - )); - - $this->toolbar->addButton($this->lng->txt('print'), 'javascript:window.print();'); - /*$src = ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")); - $img = ''; - $this->ctrl->setParameter($this->controller, 'session_id', (int)$_GET["session_id"]); - $this->ctrl->setParameter($this->controller, 'pdf', '1'); - $this->toolbar->addButton($img . $this->lng->txt('pdf_export'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.showUserDetails')); - $this->ctrl->setParameter($this->controller, 'pdf', '');*/ - $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print'); - - /*if(isset($_GET['pdf']) && $_GET['pdf'] == 1) - { - require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php'; - ilTestPDFGenerator::generatePDF($output->getHTML(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->controller->object->getTitle()); - }*/ - - $this->tpl->setContent($output->getHTML()); - } - - - public function showSelectedUserResults() - { - $template = $this->initMultipleUserAction(); - - foreach($_POST["s_id"] as $session_id) - { - $user_id = ilFormATestSession::getUserIdBySessionId($session_id); - $output = new ilFormATestResultOuputGUI($this->controller); - $output->setModus(ilFormATestResultOuputGUI::MODUS_AUTHOR); - $output->setHeader($this->plugin->txt("test_pass_overview_author")); - $output->renderTestData($user_id); - $output->renderStepsOverview($session_id); - - $template->setCurrentBlock("user_ouput"); - $template->setVariable("USER_OUTPUT", $output->getHTML()); - $template->parseCurrentBlock(); - } - - $this->tpl->setContent($template->get()); - } - - public function showSelectedUserAnswers() - { - $template = $this->initMultipleUserAction(); - - foreach($_POST["s_id"] as $session_id) - { - $user_id = ilFormATestSession::getUserIdBySessionId($session_id); - $output = new ilFormATestResultOuputGUI($this->controller); - $output->setHeader($this->plugin->txt("test_pass_overview_author")); - $output->renderTestData($user_id); - $output->renderQuestionDetails($session_id, $this->controller->object->getSetList()->getData(), true, null, true); - - $template->setCurrentBlock("user_ouput"); - $template->setVariable("USER_OUTPUT", $output->getHTML()); - $template->parseCurrentBlock(); - } - - $this->tpl->setContent($template->get()); - } - - public function showSelectedUserDetails() - { - $template = $this->initMultipleUserAction(); - - foreach($_POST["s_id"] as $session_id) - { - $user_id = ilFormATestSession::getUserIdBySessionId($session_id); - $output = new ilFormATestResultOuputGUI($this->controller); - $output->setHeader($this->plugin->txt("test_pass_overview_author")); - $output->renderTestData($user_id); - $output->renderStepsOverview($session_id); - $output->renderQuestionDetails($session_id, $this->controller->object->getSetList()->getData(), true, null, true); - - $template->setCurrentBlock("user_ouput"); - $template->setVariable("USER_OUTPUT", $output->getHTML()); - $template->parseCurrentBlock(); - } - - $this->tpl->setContent($template->get()); - } - - public function removeSelectedUserResults() - { - $this->controller->ensurePermission("write"); - - if(!$this->dataSelected("s_id")) - { - ilUtil::sendFailure($this->plugin->txt("no_user_selected"), true); - $this->redirect("ilFormATestParticipantsGUI.show"); - } - - if((int)$_GET["confirmed"]) - { - $this->controller->object->getParticipants()->removeBySessionIds($_POST["s_id"]); - ilLPStatusWrapper::_refreshStatus($this->controller->object->getId()); - $this->controller->object->logAction($this->lng->txtlng("rep_robj_xqsp", "log_selected_user_data_removed", ilObjAssessmentFolder::_getLogLanguage())); - ilUtil::sendSuccess($this->plugin->txt("all_data_deleted")); - $this->redirect("ilFormATestParticipantsGUI.show"); - } - else - { - $items = array(); - foreach($_POST["s_id"] as $session_id) - { - $user_id = ilFormATestSession::getUserIdBySessionId($session_id); - $items[] = array( - "name" =>"s_id[]", - "id" => $session_id, - "text" => ilUserUtil::getNamePresentation($user_id) - ); - } - - $this->renderConfirmationScreen( - "ilFormATestParticipantsGUI.show", - "ilFormATestParticipantsGUI.removeSelectedUserResults", - $items, - $this->plugin->txt("remove_selected_results_confirm") - ); - } - } - - public function removeAllResults() - { - $this->controller->ensurePermission("write"); - if((int)$_GET["confirmed"]) - { - $this->controller->object->getParticipants()->removeAll(); - ilLPStatusWrapper::_refreshStatus($this->controller->object->getId()); - ilUtil::sendSuccess($this->plugin->txt("all_data_deleted")); - $this->controller->object->logAction($this->plugin->txt("log_user_data_removed")); - $this->redirect("ilFormATestParticipantsGUI.show"); - } - else - { - $this->renderConfirmationScreen( - "ilFormATestParticipantsGUI.show", - "ilFormATestParticipantsGUI.removeAllResults", - array(), - $this->plugin->txt("remove_all_results_confirm") - ); - } - } - - /** - * Returns the current tab name - * return string - */ - protected function getCurrentTab() - { - return "participants"; - } - - /** - * @return array - */ - protected function getRequirements() - { - require_once "Services/User/classes/class.ilUserUtil.php"; - require_once "Services/Utilities/classes/class.ilConfirmationGUI.php"; - require_once "Services/Tracking/classes/class.ilLPStatusWrapper.php"; - require_once "Services/Tracking/classes/status/class.ilLPStatusEvent.php"; - - return array( - "tables/class.ilFormATestParticipantsTableGUI.php", - "controllers/class.ilFormATestResultOuputGUI.php", - "models/class.ilFormATestSession.php" - ); - } - - /** - * @return ilTemplate - */ - protected function initMultipleUserAction() - { - $this->controller->ensurePermission("write"); - $this->addToolbarButton("back", "ilFormATestParticipantsGUI.show"); - - if (!$this->dataSelected("s_id")) - { - ilUtil::sendFailure($this->plugin->txt("no_user_selected"), true); - $this->redirect("ilFormATestParticipantsGUI.show"); - } - - $template = new ilTemplate("tpl.il_multiple_user_output.html", true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); - - return $template; - } + public function show() + { + $this->controller->ensurePermission("write"); + + $table = new ilFormATestParticipantsTableGUI($this->controller, $this->plugin, ""); + $table->setModelList($this->controller->object->getParticipants()); + $table->populate(); + $table->addCommandButton("ilFormATestParticipantsGUI.removeAllResults", $this->plugin->txt("remove_all_results")); + $table->addMultiCommand("ilFormATestParticipantsGUI.showSelectedUserResults", $this->plugin->txt("show_results")); + $table->addMultiCommand("ilFormATestParticipantsGUI.showSelectedUserAnswers", $this->plugin->txt("show_answers")); + $table->addMultiCommand("ilFormATestParticipantsGUI.showSelectedUserDetails", $this->plugin->txt("show_details")); + $table->addMultiCommand("ilFormATestParticipantsGUI.removeSelectedUserResults", $this->plugin->txt("remove_results")); + $this->tpl->setContent($table->getHTML()); + } + + public function showUserResults() + { + $this->controller->ensurePermission("write"); + $this->addToolbarButton("back", "ilFormATestParticipantsGUI.show"); + + $this->toolbar->addButton($this->lng->txt('print'), 'javascript:window.print();'); + /*$src = ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")); + $img = ''; + $this->ctrl->setParameter($this->controller, 'active_id', (int)$_GET["active_id"]); + $this->ctrl->setParameter($this->controller, 'pdf', '1'); + $this->toolbar->addButton($img . $this->lng->txt('pdf_export'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.showUserResults')); + $this->ctrl->setParameter($this->controller, 'pdf', '');*/ + $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print'); + + $output = new ilFormATestResultOuputGUI($this->controller); + $output->setHeader($this->plugin->txt("test_pass_overview_author")); + $output->renderTestData(ilFormATestSession::getUserIdByActiveId((int) $_GET["active_id"])); + $output->renderPassesOverview((int) $_GET["active_id"]); + + /*if(isset($_GET['pdf']) && $_GET['pdf'] == 1) + { + require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php'; + ilTestPDFGenerator::generatePDF($output->getHTML(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->controller->object->getTitle()); + }*/ + + $this->tpl->setContent($output->getHTML()); + } + + public function showUserDetails() + { + $this->controller->ensurePermission("write"); + + $user_id = ilFormATestSession::getUserIdBySessionId((int) $_GET["session_id"]); + $output = new ilFormATestResultOuputGUI($this->controller); + $output->setHeader($this->plugin->txt("test_pass_overview_author")); + $output->renderTestData($user_id); + $output->renderStepsOverview((int) $_GET["session_id"]); + $output->renderQuestionDetails((int) $_GET["session_id"], $this->controller->object->getSetList()->getData(), true, null, true); + + $this->addToolbarButton("back", "ilFormATestParticipantsGUI.showUserResults", array( + "active_id" => ilFormATestSession::getActiveIdBySessionId((int) $_GET["session_id"]) + )); + + $this->toolbar->addButton($this->lng->txt('print'), 'javascript:window.print();'); + /*$src = ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")); + $img = ''; + $this->ctrl->setParameter($this->controller, 'session_id', (int)$_GET["session_id"]); + $this->ctrl->setParameter($this->controller, 'pdf', '1'); + $this->toolbar->addButton($img . $this->lng->txt('pdf_export'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.showUserDetails')); + $this->ctrl->setParameter($this->controller, 'pdf', '');*/ + $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print'); + + /*if(isset($_GET['pdf']) && $_GET['pdf'] == 1) + { + require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php'; + ilTestPDFGenerator::generatePDF($output->getHTML(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->controller->object->getTitle()); + }*/ + + $this->tpl->setContent($output->getHTML()); + } + + + public function showSelectedUserResults() + { + $template = $this->initMultipleUserAction(); + + foreach ($_POST["s_id"] as $session_id) { + $user_id = ilFormATestSession::getUserIdBySessionId($session_id); + $output = new ilFormATestResultOuputGUI($this->controller); + $output->setModus(ilFormATestResultOuputGUI::MODUS_AUTHOR); + $output->setHeader($this->plugin->txt("test_pass_overview_author")); + $output->renderTestData($user_id); + $output->renderStepsOverview($session_id); + + $template->setCurrentBlock("user_ouput"); + $template->setVariable("USER_OUTPUT", $output->getHTML()); + $template->parseCurrentBlock(); + } + + $this->tpl->setContent($template->get()); + } + + public function showSelectedUserAnswers() + { + $template = $this->initMultipleUserAction(); + + foreach ($_POST["s_id"] as $session_id) { + $user_id = ilFormATestSession::getUserIdBySessionId($session_id); + $output = new ilFormATestResultOuputGUI($this->controller); + $output->setHeader($this->plugin->txt("test_pass_overview_author")); + $output->renderTestData($user_id); + $output->renderQuestionDetails($session_id, $this->controller->object->getSetList()->getData(), true, null, true); + + $template->setCurrentBlock("user_ouput"); + $template->setVariable("USER_OUTPUT", $output->getHTML()); + $template->parseCurrentBlock(); + } + + $this->tpl->setContent($template->get()); + } + + public function showSelectedUserDetails() + { + $template = $this->initMultipleUserAction(); + + foreach ($_POST["s_id"] as $session_id) { + $user_id = ilFormATestSession::getUserIdBySessionId($session_id); + $output = new ilFormATestResultOuputGUI($this->controller); + $output->setHeader($this->plugin->txt("test_pass_overview_author")); + $output->renderTestData($user_id); + $output->renderStepsOverview($session_id); + $output->renderQuestionDetails($session_id, $this->controller->object->getSetList()->getData(), true, null, true); + + $template->setCurrentBlock("user_ouput"); + $template->setVariable("USER_OUTPUT", $output->getHTML()); + $template->parseCurrentBlock(); + } + + $this->tpl->setContent($template->get()); + } + + public function removeSelectedUserResults() + { + $this->controller->ensurePermission("write"); + + if (!$this->dataSelected("s_id")) { + ilUtil::sendFailure($this->plugin->txt("no_user_selected"), true); + $this->redirect("ilFormATestParticipantsGUI.show"); + } + + if ((int) $_GET["confirmed"]) { + $this->controller->object->getParticipants()->removeBySessionIds($_POST["s_id"]); + ilLPStatusWrapper::_refreshStatus($this->controller->object->getId()); + $this->controller->object->logAction($this->lng->txtlng("rep_robj_xqsp", "log_selected_user_data_removed", ilObjAssessmentFolder::_getLogLanguage())); + ilUtil::sendSuccess($this->plugin->txt("all_data_deleted")); + $this->redirect("ilFormATestParticipantsGUI.show"); + } else { + $items = array(); + foreach ($_POST["s_id"] as $session_id) { + $user_id = ilFormATestSession::getUserIdBySessionId($session_id); + $items[] = array( + "name" => "s_id[]", + "id" => $session_id, + "text" => ilUserUtil::getNamePresentation($user_id) + ); + } + + $this->renderConfirmationScreen( + "ilFormATestParticipantsGUI.show", + "ilFormATestParticipantsGUI.removeSelectedUserResults", + $items, + $this->plugin->txt("remove_selected_results_confirm") + ); + } + } + + public function removeAllResults() + { + $this->controller->ensurePermission("write"); + if ((int) $_GET["confirmed"]) { + $this->controller->object->getParticipants()->removeAll(); + ilLPStatusWrapper::_refreshStatus($this->controller->object->getId()); + ilUtil::sendSuccess($this->plugin->txt("all_data_deleted")); + $this->controller->object->logAction($this->plugin->txt("log_user_data_removed")); + $this->redirect("ilFormATestParticipantsGUI.show"); + } else { + $this->renderConfirmationScreen( + "ilFormATestParticipantsGUI.show", + "ilFormATestParticipantsGUI.removeAllResults", + array(), + $this->plugin->txt("remove_all_results_confirm") + ); + } + } + + /** + * Returns the current tab name + * return string + */ + protected function getCurrentTab() + { + return "participants"; + } + + /** + * @return array + */ + protected function getRequirements() + { + return array( + "tables/class.ilFormATestParticipantsTableGUI.php", + "controllers/class.ilFormATestResultOuputGUI.php", + "models/class.ilFormATestSession.php" + ); + } + + /** + * @return ilTemplate + */ + protected function initMultipleUserAction() + { + $this->controller->ensurePermission("write"); + $this->addToolbarButton("back", "ilFormATestParticipantsGUI.show"); + + if (!$this->dataSelected("s_id")) { + ilUtil::sendFailure($this->plugin->txt("no_user_selected"), true); + $this->redirect("ilFormATestParticipantsGUI.show"); + } + + $template = new ilTemplate("tpl.il_multiple_user_output.html", true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); + + return $template; + } } - \ No newline at end of file diff --git a/classes/controllers/class.ilFormATestPlayerControllerGUI.php b/classes/controllers/class.ilFormATestPlayerControllerGUI.php index ebbab8e8f1efab70a299c3a38dfcffeba9deb0f1..eb1d246e25822bea86c6f695dfd5201a532eef94 100644 --- a/classes/controllers/class.ilFormATestPlayerControllerGUI.php +++ b/classes/controllers/class.ilFormATestPlayerControllerGUI.php @@ -8,647 +8,577 @@ require_once "abstract.ilXTSFControllerGUI.php"; * Date: 13.12.13 * Time: 11:40 * @author Thomas Joußen - */ + */ class ilFormATestPlayerControllerGUI extends ilXTSFControllerGUI { - /** - * @var ilFormATestSession - */ - protected $session; - - /** - * @var ilFormATestOutputGUI - */ - protected $output; - - public function __construct(ilObjFormATestGUI $controller) - { - parent::__construct($controller); - - $this->session = new ilFormATestSession($controller->object); - $this->session->read($controller->object->getSetList()->getData()); - $this->output = new ilFormATestOutputGUI($this->controller); - $this->output->setSession($this->session); - - $this->tabs->clearTargets(); - - if(!ilFormATestPlayerAccessHelper::canDoTestAction($this->controller, $this->session)) - { - $this->redirect("ilFormATestInfoScreenControllerGUI.show"); - } - } - - public function startTest() - { - $this->controller->ensurePermission('read'); - - if(!$this->session->activeIdExists()) - { - $this->session->create(); - $this->start(); - } - else{ - $this->redirectOutPage(); - } - } - - public function startNewPass() - { - $this->controller->ensurePermission("read"); - - if($this->session->isPassFinished() || !$this->controller->object->isAllowInterruption()) - { - $this->session->createNewPass(); - $this->start(); - } - else - { - $this->redirectOutPage(); - } - } - - public function resumeTest() - { - $this->controller->ensurePermission("read"); - - if(!$this->session->isPassFinished()) - { - if(!$this->session->isSetFinished()) - { - $this->session->setStatus(ilFormATestSession::STATUS_NOT_FINISHED); - $this->session->update(); - $this->redirectOutPage(); - } - else - { - $this->redirect("ilFormATestPlayerControllerGUI.finish", array( - "xtsf_token" => $this->session->getToken() - )); - } - } - else - { - $this->redirect("ilFormATestInfoScreenControllerGUI.show"); - } - } - - public function next() - { - $this->controller->ensurePermission("read"); - $this->redirectIfTokenIsInvalid(); - - $node = $this->getNodeFromSession(); - $status = $this->saveQuestionSolution($node); - - $this->handleSkillTriggering(); - - if($status == false) - { - if($this->isTokenValid()) - { - $_SESSION["previouspost"] = $_POST; - $this->output->outTestPage($node); - } - else - { - throw new ilException("Access Denied", 403); - } - return; - } - - ilFormATestConditionEvaluation::attach($this->controller->object); - $next_node = ilFormATestConditionEvaluation::getNextNode($node,$this->session); - ilFormATestConditionEvaluation::detach($this->controller->object); - - $this->reworkDominantScoring($node); - $this->session->saveHistory(); - - if($next_node == null) - { - if($this->session->isJump()) - { - ilFormATestUtil::addInfo($this->plugin->txt("triggered_termination")); - } - $this->redirect("ilFormATestPlayerControllerGUI.finish", array( - "xtsf_token" => $this->session->getToken() - )); - } - if($this->session->isJump()) - { - $this->session->removeStepsUntil($next_node->getIndex()+1); - $this->session->updateTrackNodeId($next_node->getId()); - $this->updateTestPassResults($node); - $this->handleSkillTriggering(); - if($node->getQuestion()->getId() == $next_node->getQuestion()->getId()) - { - ilFormATestUtil::addInfo($this->plugin->txt("triggered_repitition")); - } - else - { - ilFormATestUtil::addInfo($this->plugin->txt("triggered_jump")); - } - } - else - { - $this->session->step($next_node->getId()); - $this->handleDeadlock(); - $this->handleSkillTriggering(); - } - - $this->session->updateLP(); - $this->redirectOutPage(); - } - - public function prev() - { - $this->controller->ensurePermission("read"); - $this->redirectIfTokenIsInvalid(); - - if(!$this->session->isFirstStep() && $this->controller->object->isAllowWalkBack()) - { - $node = $this->getNodeFromSession(); - $hasSolutions = $this->session->stepHasSolution($node); - if($_GET["confirmed"] || !$hasSolutions) - { - if($hasSolutions) - { - ilFormATestUtil::addInfo($this->plugin->txt("triggered_prev")); - } - else - { - ilFormATestUtil::addInfo($this->plugin->txt("triggered_prev_no_delete")); - } - - - $this->session->removeStepsUntil($node->getIndex()); - - // delete current_step Feedback - $current_step = $node->getIndex(); - $this->session->removeFeedbackByStep($current_step); - - $previous_step = ilFormATestConditionEvaluation::getAnchorIndex($node); - // lösche Feedbacks des Steps, zu dem hingesprungen werden soll. - $this->session->removeFeedbackByStep($previous_step); - - $this->session->changePath($this->getNodeFromSession(), $node); - $this->updateTestPassResults($node); - $this->handleSkillTriggering(); - $this->redirectOutPage(); - } - else - { - $inTestStep = 1; - if (true === isset($_GET["node_step"])) { - $inTestStep = $_GET["node_step"]; - $int = (int) $inTestStep; - if ((string) $int !== (string) $inTestStep) { - throw new ilException('"node_step" MUST be an integer value', 403); - } - - $inTestStep = $inTestStep + 1; - } - - $this->renderConfirmationScreen( - "ilFormATestPlayerControllerGUI.resumeTest", - "ilFormATestPlayerControllerGUI.prev", - array( - array( - "name" => "n_id[]", - "id" => $this->session->getNodeId(), - "text" => $this->plugin->txt("header_step"). ": ". $inTestStep - ) - ), - $this->plugin->txt("confirm_walk_back"), - array( - "xtsf_token" => $this->session->getToken() - ) - ); - } - } - else - { - $this->redirectOutPage(); - } - } - - public function back() - { - $this->redirectIfTokenIsInvalid(); - $this->session->updateSetStatus(ilFormATestSession::STATUS_IN_PROGRESS); - - $node = $this->getNodeFromSession(); - if($node != null) - { - // delete current_step Feedback - $current_step = $node->getIndex(); - $this->session->removeFeedbackByStep($current_step); - - $previous_step = ilFormATestConditionEvaluation::getAnchorIndex($node); - // lösche Feedbacks des Steps, zu dem hingesprungen werden soll. - $this->session->removeFeedbackByStep($previous_step); - } - - $this->redirectOutPage(); - } - - public function interrupt() - { - $this->controller->ensurePermission("read"); - $this->redirectIfTokenIsInvalid(); - - if($this->controller->object->isAllowInterruption()) - { - if(!$this->session->isSetFinished()) - { - $node = $this->getNodeFromSession(); - $this->saveQuestionSolution($node); - $this->handleSkillTriggering(); - $this->reworkDominantScoring($node); - $this->session->updateLP(); - } - - $this->session->setStatus(ilFormATestSession::STATUS_INTERRUPTED); - $this->session->update(); - $this->redirect("ilFormATestInfoScreenControllerGUI.show"); - } - else - { - $this->redirectOutPage(); - } - } - - public function finish() - { - $this->controller->ensurePermission("read"); - $this->redirectIfTokenIsInvalid(); - $this->session->updateSetStatus(ilFormATestSession::STATUS_FINISHED); - $this->handleSkillTriggering(); - $this->output->outFinishSet(); - } - - public function interruptset() - { - $this->controller->ensurePermission("read"); - $this->redirectIfTokenIsInvalid(); - $node = $this->getNodeFromSession(); - $this->saveQuestionSolution($node); - $this->handleSkillTriggering(); - $this->reworkDominantScoring($node); - $this->session->updateSetStatus(ilFormATestSession::STATUS_FINISHED); - $this->session->updateLP(); - $this->output->outFinishSet(); - } - - public function finishTest() - { - $tpl = $this->tpl; - $ilCtrl = $this->ctrl; - $lng = $this->lng; - - $this->controller->ensurePermission("read"); - - if((int)$_GET["confirmed"]) - { - $this->session->setStatus(ilFormATestSession::STATUS_FINISHED); - $this->session->update(); - - ilUtil::sendSuccess($this->plugin->txt("saved_test_data"), true); - if($this->controller->object->getShowFinalStatement()) - { - - $template = new ilTemplate("tpl.xtsf_final_statement.html", true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); - $template->setVariable("FORMACTION", $ilCtrl->getFormAction($this->controller, 'ilFormATestPlayerControllerGUI.afterTestPassFinished')); - $template->setVariable("BUTTON_CONTINUE", $lng->txt("btn_next")); - $template->setVariable("CMD", "ilFormATestPlayerControllerGUI.afterTestPassFinished"); - - $template->setVariable("FINALSTATEMENT", $this->controller->object->getFinalStatement()); - - $tpl->setContent($template->get()); - } - else - { - $this->afterTestPassFinished(); - } - } - else - { - $message = $this->plugin->txt("confirm_finish_test"); - if(!$this->session->allSetsFinished()) - { - $message = $this->plugin->txt("confirm_finish_test_not_completed"); - } - $this->renderConfirmationScreen( - "ilFormATestPlayerControllerGUI.finish", - "ilFormATestPlayerControllerGUI.finishTest", - array(), - $message, - array( - "xtsf_token" => $this->session->getToken() - ) - ); - } - } - - /** - * - */ - public function afterTestPassFinished() - { - if($this->scoringReportingAlways() || $this->scoringReportingFinished($this->session) || $this->scoringReportingDate()) - { - $this->redirect("ilFormATestInfoScreenControllerGUI.showTestResults", array( - "active_id" => $this->session->getActiveId() - )); - } - else - { - $this->redirect("ilFormATestInfoScreenControllerGUI.show"); - } - } - - public function nextSet() - { - $this->controller->ensurePermission("read"); - $this->redirectIfTokenIsInvalid(); - - $this->start(); - } - - public function handleQuestionAction() - { - $this->controller->ensurePermission("read"); - $this->redirectIfTokenIsInvalid(); - - $node = $this->getNodeFromSession(); - $this->saveQuestionSolution($node); - $this->handleSkillTriggering(); - $this->reworkDominantScoring($node); - $this->session->updateLP(); - $this->redirectOutPage(); - } - - public function jumpToNode() - { - $this->controller->ensurePermission("read"); - $this->redirectIfTokenIsInvalid(); - - $node = new ilQuestionSetPoolNode((int)$_GET["node_id"]); - $node->read(); - - if($_GET["confirmed"] || !$this->session->hasStepsToDelete($node)) - { - if($this->session->hasStepsToDelete($node)) - { - ilFormATestUtil::addInfo($this->plugin->txt("triggered_jump_to")); - } - else - { - ilFormATestUtil::addInfo($this->plugin->txt("triggered_jump_to_no_delete")); - } - - $current_node = $this->getNodeFromSession(); - $this->session->swapCurrent($node->getPath()->getSet()->getId()); - $this->session->removeStepsUntil($node->getIndex()+1); - - // delete current_step Feedback - $current_step = $node->getIndex(); - $this->session->removeFeedbackByStep($current_step); - - $previous_step = ilFormATestConditionEvaluation::getAnchorIndex($node); - // lösche Feedbacks des Steps, zu dem hingesprungen werden soll. - $this->session->removeFeedbackByStep($previous_step); - - $this->session->changePath($this->getNodeFromSession(), $current_node); - - $this->updateTestPassResults($node); - $this->handleSkillTriggering(); - $this->redirectOutPage(); - } - else - { - $inTestStep = 0; - if (true === isset($_GET["node_step"])) { - $inTestStep = $_GET["node_step"]; - $int = (int) $inTestStep; - if ((string) $int !== (string) $inTestStep) { - throw new ilException('"node_step" MUST be an integer value', 403); - } - } - - $steps = $this->session->getStepsToDelete($node); - $items = array(); - foreach($steps as $step) - { - $inTestStep++; - $items[] = array( - "name" => "n_id[]", - "id" => $step["id"], - "text" => $this->plugin->txt("header_step"). ": ". $inTestStep - ); - } - $cancel = "ilFormATestPlayerControllerGUI.back"; - if((int)$_GET["finished"]) - { - $cancel = "ilFormATestPlayerControllerGUI.finish"; - } - - $this->ctrl->setParameter($this->controller, "node_id", (int)$_GET["node_id"]); - $this->renderConfirmationScreen( - $cancel, - "ilFormATestPlayerControllerGUI.jumpToNode", - $items, - $this->plugin->txt("confirm_jump_to_node"), - array( - "xtsf_token" => $this->session->getToken() - ) - ); - $this->ctrl->setParameter($this->controller, "node_id", ""); - } - } - - public function outPage() - { - if($this->isTokenValid()) - { - $node = $this->getNodeFromSession(); - $this->output->outTestPage($node); - } - else - { - throw new ilException("Access Denied", 403); - } - } - - protected function handleDeadlock() - { - if($this->session->hasFixatedSolution()) - { - $this->session->handleDeadlock(); - } - } - - /** - * @param ilQuestionSetPoolNode $node - */ - protected function updateTestPassResults($node) - { - assQuestion::setResultGateway(new ilObjTestGateway()); - assQuestion::_updateTestPassResults($this->session->getActiveId(), $this->session->getPass(), false, $node->getQuestion()->getProcessLocker()); - assQuestion::setResultGateway(null); - } - - /** - * @param ilQuestionSetPoolNode $node - */ - protected function reworkDominantScoring($node) - { - if($node->getDominantScoring() !== null) - { - assQuestion::setResultGateway(new ilObjTestGateway()); - $reworker = new ilFormATestDominantScoringReworker( - $this->session->getActiveId(), - $this->session->getStep(), - $this->session->getPass() - ); - $reworker->rework($node); - assQuestion::setResultGateway(null); - } - } - - protected function redirectOutPage() - { - if($this->session->hasFixatedSolution()) - { - ilFormATestUtil::addInfo($this->plugin->txt("triggered_deadlock")); - } - - $this->redirect("ilFormATestPlayerControllerGUI.outPage", array( - "xtsf_token" => $this->session->getToken() - )); - } - - protected function start() - { - $this->session->initCurrent(); - $this->session->step($this->session->getNodeId()); - $this->redirectOutPage(); - } - - /** - * @param ilQuestionSetPoolNode $node - * @return bool - */ - protected function saveQuestionSolution(ilQuestionSetPoolNode $node) - { - assQuestion::setResultGateway(new ilObjTestGateway()); - $gui = ilFatQuestionFactory::instantiateQuestionGUI($node->getQuestion()->getId()); - $gui->object->setStep($this->session->getStep()); - $saveStatus = true; - - if(!$this->session->hasFixatedSolution()) - { - $saveStatus = $gui->object->persistWorkingState($this->session->getActiveId(),$this->session->getPass(),false); - } - else - { - $gui->object->calculateResultsFromSolution($this->session->getActiveId(), $this->session->getPass(), false); - } - assQuestion::setResultGateway(null); - return $saveStatus; - } - - /** - * @return ilQuestionSetPoolNode - */ - protected function getNodeFromSession() - { - $node = new ilQuestionSetPoolNode($this->session->getNodeId()); - $node->read(); - - return $node; - } - - protected function isTokenValid() - { - return $this->session->getToken() == $_GET["xtsf_token"]; - } - - protected function handleSkillTriggering() - { - if($this->controller->object->isSkillServiceEnabled() && ilObjFormATest::isSkillManagementGloballyActivated()) - { - $handler = new ilFormATestSkillLevelHelper(); - $handler->setTestId($this->controller->object->getTestId()); - $handler->setRefId($this->controller->object->getRefId()); - $handler->setSession($this->session); - $handler->trigger($this->controller->object); - } - } - - protected function redirectIfTokenIsInvalid() - { - /*if(!$this->isTokenValid()) - { - ilUtil::sendFailure($this->plugin->txt("multiple_tab_detection"),true); - $this->redirect("ilFormATestInfoScreenControllerGUI.show"); - }*/ - } - - /** - * Returns the current tab name - * return string - */ - protected function getCurrentTab() - { - return "info_short"; - } - - /** - * @return array - */ - protected function getRequirements() - { - require_once "Services/Utilities/classes/class.ilConfirmationGUI.php"; - require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/models/class.ilQuestionSetPoolSet.php"; - require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/models/class.ilQuestionSetPoolPath.php"; - require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/models/class.ilQuestionSetPoolNode.php"; - - return array( - "models/class.ilFormATestSession.php", - "controllers/class.ilFormATestOutputGUI.php", - "utils/abstract.ilFormATestConditionEvaluation.php", - "utils/class.ilObjTestGateway.php", - "utils/abstract.ilFormATestPlayerAccessHelper.php", - "utils/class.ilFormATestDominantScoringReworker.php", - "utils/abstract.ilFormATestUtil.php", - 'utils/class.ilFormATestSkillLevelHelper.php', - "class.ilFatQuestionFactory.php", - "adapter/class.ilFatImageMapQuestionAdapter.php" - - ); - } - - public function showInstantResponse() - { - $this->controller->ensurePermission("read"); - - $this->redirectIfTokenIsInvalid(); - - $node = $this->getNodeFromSession(); - - if(!$this->session->hasFixatedSolution($node->getQuestion()->getId())) - { - $this->saveQuestionSolution($node); - ilSession::set($this->controller->object->getInstantFeedbackSessionKey(), true); - } - - $this->session->saveHistory(); - //@todo evtl. update learning progress -// $this->handleDeadlock(); -// $this->session->updateLP(); - - $this->redirectOutPage(); - } + /** + * @var ilFormATestSession + */ + protected $session; + + /** + * @var ilFormATestOutputGUI + */ + protected $output; + + public function __construct(ilObjFormATestGUI $controller) + { + parent::__construct($controller); + + $this->session = new ilFormATestSession($controller->object); + $this->session->read($controller->object->getSetList()->getData()); + $this->output = new ilFormATestOutputGUI($this->controller); + $this->output->setSession($this->session); + + $this->tabs->clearTargets(); + + if (!ilFormATestPlayerAccessHelper::canDoTestAction($this->controller, $this->session)) { + $this->redirect("ilFormATestInfoScreenControllerGUI.show"); + } + } + + public function startTest() + { + $this->controller->ensurePermission('read'); + + if (!$this->session->activeIdExists()) { + $this->session->create(); + $this->start(); + } else { + $this->redirectOutPage(); + } + } + + public function startNewPass() + { + $this->controller->ensurePermission("read"); + + if ($this->session->isPassFinished() || !$this->controller->object->isAllowInterruption()) { + $this->session->createNewPass(); + $this->start(); + } else { + $this->redirectOutPage(); + } + } + + public function resumeTest() + { + $this->controller->ensurePermission("read"); + + if (!$this->session->isPassFinished()) { + if (!$this->session->isSetFinished()) { + $this->session->setStatus(ilFormATestSession::STATUS_NOT_FINISHED); + $this->session->update(); + $this->redirectOutPage(); + } else { + $this->redirect("ilFormATestPlayerControllerGUI.finish", array( + "xtsf_token" => $this->session->getToken() + )); + } + } else { + $this->redirect("ilFormATestInfoScreenControllerGUI.show"); + } + } + + public function next() + { + $this->controller->ensurePermission("read"); + $this->redirectIfTokenIsInvalid(); + + $node = $this->getNodeFromSession(); + $status = $this->saveQuestionSolution($node); + + $this->handleSkillTriggering(); + + if ($status == false) { + if ($this->isTokenValid()) { + $_SESSION["previouspost"] = $_POST; + $this->output->outTestPage($node); + } else { + throw new ilException("Access Denied", 403); + } + return; + } + + ilFormATestConditionEvaluation::attach($this->controller->object); + $next_node = ilFormATestConditionEvaluation::getNextNode($node, $this->session); + ilFormATestConditionEvaluation::detach($this->controller->object); + + $this->reworkDominantScoring($node); + $this->session->saveHistory(); + + if ($next_node == null) { + if ($this->session->isJump()) { + ilFormATestUtil::addInfo($this->plugin->txt("triggered_termination")); + } + $this->redirect("ilFormATestPlayerControllerGUI.finish", array( + "xtsf_token" => $this->session->getToken() + )); + } + if ($this->session->isJump()) { + $this->session->removeStepsUntil($next_node->getIndex() + 1); + $this->session->updateTrackNodeId($next_node->getId()); + $this->updateTestPassResults($node); + $this->handleSkillTriggering(); + if ($node->getQuestion()->getId() == $next_node->getQuestion()->getId()) { + ilFormATestUtil::addInfo($this->plugin->txt("triggered_repitition")); + } else { + ilFormATestUtil::addInfo($this->plugin->txt("triggered_jump")); + } + } else { + $this->session->step($next_node->getId()); + $this->handleDeadlock(); + $this->handleSkillTriggering(); + } + + $this->session->updateLP(); + $this->redirectOutPage(); + } + + public function prev() + { + $this->controller->ensurePermission("read"); + $this->redirectIfTokenIsInvalid(); + + if (!$this->session->isFirstStep() && $this->controller->object->isAllowWalkBack()) { + $node = $this->getNodeFromSession(); + $hasSolutions = $this->session->stepHasSolution($node); + if ($_GET["confirmed"] || !$hasSolutions) { + if ($hasSolutions) { + ilFormATestUtil::addInfo($this->plugin->txt("triggered_prev")); + } else { + ilFormATestUtil::addInfo($this->plugin->txt("triggered_prev_no_delete")); + } + + + $this->session->removeStepsUntil($node->getIndex()); + + // delete current_step Feedback + $current_step = $node->getIndex(); + $this->session->removeFeedbackByStep($current_step); + + $previous_step = ilFormATestConditionEvaluation::getAnchorIndex($node); + // lösche Feedbacks des Steps, zu dem hingesprungen werden soll. + $this->session->removeFeedbackByStep($previous_step); + + $this->session->changePath($this->getNodeFromSession(), $node); + $this->updateTestPassResults($node); + $this->handleSkillTriggering(); + $this->redirectOutPage(); + } else { + $inTestStep = 1; + if (true === isset($_GET["node_step"])) { + $inTestStep = $_GET["node_step"]; + $int = (int) $inTestStep; + if ((string) $int !== (string) $inTestStep) { + throw new ilException('"node_step" MUST be an integer value', 403); + } + + $inTestStep = $inTestStep + 1; + } + + $this->renderConfirmationScreen( + "ilFormATestPlayerControllerGUI.resumeTest", + "ilFormATestPlayerControllerGUI.prev", + array( + array( + "name" => "n_id[]", + "id" => $this->session->getNodeId(), + "text" => $this->plugin->txt("header_step") . ": " . $inTestStep + ) + ), + $this->plugin->txt("confirm_walk_back"), + array( + "xtsf_token" => $this->session->getToken() + ) + ); + } + } else { + $this->redirectOutPage(); + } + } + + public function back() + { + $this->redirectIfTokenIsInvalid(); + $this->session->updateSetStatus(ilFormATestSession::STATUS_IN_PROGRESS); + + $node = $this->getNodeFromSession(); + if ($node != null) { + // delete current_step Feedback + $current_step = $node->getIndex(); + $this->session->removeFeedbackByStep($current_step); + + $previous_step = ilFormATestConditionEvaluation::getAnchorIndex($node); + // lösche Feedbacks des Steps, zu dem hingesprungen werden soll. + $this->session->removeFeedbackByStep($previous_step); + } + + $this->redirectOutPage(); + } + + public function interrupt() + { + $this->controller->ensurePermission("read"); + $this->redirectIfTokenIsInvalid(); + + if ($this->controller->object->isAllowInterruption()) { + if (!$this->session->isSetFinished()) { + $node = $this->getNodeFromSession(); + $this->saveQuestionSolution($node); + $this->handleSkillTriggering(); + $this->reworkDominantScoring($node); + $this->session->updateLP(); + } + + $this->session->setStatus(ilFormATestSession::STATUS_INTERRUPTED); + $this->session->update(); + $this->redirect("ilFormATestInfoScreenControllerGUI.show"); + } else { + $this->redirectOutPage(); + } + } + + public function finish() + { + $this->controller->ensurePermission("read"); + $this->redirectIfTokenIsInvalid(); + $this->session->updateSetStatus(ilFormATestSession::STATUS_FINISHED); + $this->handleSkillTriggering(); + $this->output->outFinishSet(); + } + + public function interruptset() + { + $this->controller->ensurePermission("read"); + $this->redirectIfTokenIsInvalid(); + $node = $this->getNodeFromSession(); + $this->saveQuestionSolution($node); + $this->handleSkillTriggering(); + $this->reworkDominantScoring($node); + $this->session->updateSetStatus(ilFormATestSession::STATUS_FINISHED); + $this->session->updateLP(); + $this->output->outFinishSet(); + } + + public function finishTest() + { + $tpl = $this->tpl; + $ilCtrl = $this->ctrl; + $lng = $this->lng; + + $this->controller->ensurePermission("read"); + + if ((int) $_GET["confirmed"]) { + $this->session->setStatus(ilFormATestSession::STATUS_FINISHED); + $this->session->update(); + + ilUtil::sendSuccess($this->plugin->txt("saved_test_data"), true); + if ($this->controller->object->getShowFinalStatement()) { + $template = new ilTemplate("tpl.xtsf_final_statement.html", true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); + $template->setVariable("FORMACTION", $ilCtrl->getFormAction($this->controller, 'ilFormATestPlayerControllerGUI.afterTestPassFinished')); + $template->setVariable("BUTTON_CONTINUE", $lng->txt("btn_next")); + $template->setVariable("CMD", "ilFormATestPlayerControllerGUI.afterTestPassFinished"); + + $template->setVariable("FINALSTATEMENT", $this->controller->object->getFinalStatement()); + + $tpl->setContent($template->get()); + } else { + $this->afterTestPassFinished(); + } + } else { + $message = $this->plugin->txt("confirm_finish_test"); + if (!$this->session->allSetsFinished()) { + $message = $this->plugin->txt("confirm_finish_test_not_completed"); + } + $this->renderConfirmationScreen( + "ilFormATestPlayerControllerGUI.finish", + "ilFormATestPlayerControllerGUI.finishTest", + array(), + $message, + array( + "xtsf_token" => $this->session->getToken() + ) + ); + } + } + + /** + * + */ + public function afterTestPassFinished() + { + if ($this->scoringReportingAlways() || $this->scoringReportingFinished($this->session) || $this->scoringReportingDate()) { + $this->redirect("ilFormATestInfoScreenControllerGUI.showTestResults", array( + "active_id" => $this->session->getActiveId() + )); + } else { + $this->redirect("ilFormATestInfoScreenControllerGUI.show"); + } + } + + public function nextSet() + { + $this->controller->ensurePermission("read"); + $this->redirectIfTokenIsInvalid(); + + $this->start(); + } + + public function handleQuestionAction() + { + $this->controller->ensurePermission("read"); + $this->redirectIfTokenIsInvalid(); + + $node = $this->getNodeFromSession(); + $this->saveQuestionSolution($node); + $this->handleSkillTriggering(); + $this->reworkDominantScoring($node); + $this->session->updateLP(); + $this->redirectOutPage(); + } + + public function jumpToNode() + { + $this->controller->ensurePermission("read"); + $this->redirectIfTokenIsInvalid(); + + $node = new ilQuestionSetPoolNode((int) $_GET["node_id"]); + $node->read(); + + if ($_GET["confirmed"] || !$this->session->hasStepsToDelete($node)) { + if ($this->session->hasStepsToDelete($node)) { + ilFormATestUtil::addInfo($this->plugin->txt("triggered_jump_to")); + } else { + ilFormATestUtil::addInfo($this->plugin->txt("triggered_jump_to_no_delete")); + } + + $current_node = $this->getNodeFromSession(); + $this->session->swapCurrent($node->getPath()->getSet()->getId()); + $this->session->removeStepsUntil($node->getIndex() + 1); + + // delete current_step Feedback + $current_step = $node->getIndex(); + $this->session->removeFeedbackByStep($current_step); + + $previous_step = ilFormATestConditionEvaluation::getAnchorIndex($node); + // lösche Feedbacks des Steps, zu dem hingesprungen werden soll. + $this->session->removeFeedbackByStep($previous_step); + + $this->session->changePath($this->getNodeFromSession(), $current_node); + + $this->updateTestPassResults($node); + $this->handleSkillTriggering(); + $this->redirectOutPage(); + } else { + $inTestStep = 0; + if (true === isset($_GET["node_step"])) { + $inTestStep = $_GET["node_step"]; + $int = (int) $inTestStep; + if ((string) $int !== (string) $inTestStep) { + throw new ilException('"node_step" MUST be an integer value', 403); + } + } + + $steps = $this->session->getStepsToDelete($node); + $items = array(); + foreach ($steps as $step) { + $inTestStep++; + $items[] = array( + "name" => "n_id[]", + "id" => $step["id"], + "text" => $this->plugin->txt("header_step") . ": " . $inTestStep + ); + } + $cancel = "ilFormATestPlayerControllerGUI.back"; + if ((int) $_GET["finished"]) { + $cancel = "ilFormATestPlayerControllerGUI.finish"; + } + + $this->ctrl->setParameter($this->controller, "node_id", (int) $_GET["node_id"]); + $this->renderConfirmationScreen( + $cancel, + "ilFormATestPlayerControllerGUI.jumpToNode", + $items, + $this->plugin->txt("confirm_jump_to_node"), + array( + "xtsf_token" => $this->session->getToken() + ) + ); + $this->ctrl->setParameter($this->controller, "node_id", ""); + } + } + + public function outPage() + { + if ($this->isTokenValid()) { + $node = $this->getNodeFromSession(); + $this->output->outTestPage($node); + } else { + throw new ilException("Access Denied", 403); + } + } + + protected function handleDeadlock() + { + if ($this->session->hasFixatedSolution()) { + $this->session->handleDeadlock(); + } + } + + /** + * @param ilQuestionSetPoolNode $node + */ + protected function updateTestPassResults($node) + { + assQuestion::setResultGateway(new ilObjTestGateway()); + assQuestion::_updateTestPassResults($this->session->getActiveId(), $this->session->getPass(), false, $node->getQuestion()->getProcessLocker()); + assQuestion::setResultGateway(null); + } + + /** + * @param ilQuestionSetPoolNode $node + */ + protected function reworkDominantScoring($node) + { + if ($node->getDominantScoring() !== null) { + assQuestion::setResultGateway(new ilObjTestGateway()); + $reworker = new ilFormATestDominantScoringReworker( + $this->session->getActiveId(), + $this->session->getStep(), + $this->session->getPass() + ); + $reworker->rework($node); + assQuestion::setResultGateway(null); + } + } + + protected function redirectOutPage() + { + if ($this->session->hasFixatedSolution()) { + ilFormATestUtil::addInfo($this->plugin->txt("triggered_deadlock")); + } + + $this->redirect("ilFormATestPlayerControllerGUI.outPage", array( + "xtsf_token" => $this->session->getToken() + )); + } + + protected function start() + { + $this->session->initCurrent(); + $this->session->step($this->session->getNodeId()); + $this->redirectOutPage(); + } + + /** + * @param ilQuestionSetPoolNode $node + * @return bool + */ + protected function saveQuestionSolution(ilQuestionSetPoolNode $node) + { + assQuestion::setResultGateway(new ilObjTestGateway()); + $gui = ilFatQuestionFactory::instantiateQuestionGUI($node->getQuestion()->getId()); + $gui->object->setStep($this->session->getStep()); + $saveStatus = true; + + if (!$this->session->hasFixatedSolution()) { + $saveStatus = $gui->object->persistWorkingState($this->session->getActiveId(), $this->session->getPass(), false); + } else { + $gui->object->calculateResultsFromSolution($this->session->getActiveId(), $this->session->getPass(), false); + } + assQuestion::setResultGateway(null); + return $saveStatus; + } + + /** + * @return ilQuestionSetPoolNode + */ + protected function getNodeFromSession() + { + $node = new ilQuestionSetPoolNode($this->session->getNodeId()); + $node->read(); + + return $node; + } + + protected function isTokenValid() + { + return $this->session->getToken() == $_GET["xtsf_token"]; + } + + protected function handleSkillTriggering() + { + if ($this->controller->object->isSkillServiceEnabled() && ilObjFormATest::isSkillManagementGloballyActivated()) { + $handler = new ilFormATestSkillLevelHelper(); + $handler->setTestId($this->controller->object->getTestId()); + $handler->setRefId($this->controller->object->getRefId()); + $handler->setSession($this->session); + $handler->trigger($this->controller->object); + } + } + + protected function redirectIfTokenIsInvalid() + { + /*if(!$this->isTokenValid()) + { + ilUtil::sendFailure($this->plugin->txt("multiple_tab_detection"),true); + $this->redirect("ilFormATestInfoScreenControllerGUI.show"); + }*/ + } + + /** + * Returns the current tab name + * return string + */ + protected function getCurrentTab() + { + return "info_short"; + } + + /** + * @return array + */ + protected function getRequirements() + { + require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/models/class.ilQuestionSetPoolSet.php"; + require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/models/class.ilQuestionSetPoolPath.php"; + require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/models/class.ilQuestionSetPoolNode.php"; + + return array( + "models/class.ilFormATestSession.php", + "controllers/class.ilFormATestOutputGUI.php", + "utils/abstract.ilFormATestConditionEvaluation.php", + "utils/class.ilObjTestGateway.php", + "utils/abstract.ilFormATestPlayerAccessHelper.php", + "utils/class.ilFormATestDominantScoringReworker.php", + "utils/abstract.ilFormATestUtil.php", + 'utils/class.ilFormATestSkillLevelHelper.php', + "class.ilFatQuestionFactory.php", + "adapter/class.ilFatImageMapQuestionAdapter.php" + + ); + } + + public function showInstantResponse() + { + $this->controller->ensurePermission("read"); + + $this->redirectIfTokenIsInvalid(); + + $node = $this->getNodeFromSession(); + + if (!$this->session->hasFixatedSolution($node->getQuestion()->getId())) { + $this->saveQuestionSolution($node); + ilSession::set($this->controller->object->getInstantFeedbackSessionKey(), true); + } + + $this->session->saveHistory(); + //@todo evtl. update learning progress + // $this->handleDeadlock(); + // $this->session->updateLP(); + + $this->redirectOutPage(); + } } - diff --git a/classes/controllers/class.ilFormATestPropertiesGUI.php b/classes/controllers/class.ilFormATestPropertiesGUI.php index 29d85f35d07b850334d213e77d5a4f6b16f63408..8a69c78ce93b107c77f8feb8855efe7da9111a83 100644 --- a/classes/controllers/class.ilFormATestPropertiesGUI.php +++ b/classes/controllers/class.ilFormATestPropertiesGUI.php @@ -8,329 +8,322 @@ require_once "abstract.ilXTSFControllerFormGUI.php"; * Date: 07.01.14 * Time: 09:56 * @author Thomas Joußen - */ + */ class ilFormATestPropertiesGUI extends ilXTSFControllerFormGUI { - /** - * @param ilXTSFModel $model - * @return mixed|void - */ - protected function initForm($model) - { - require_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; - $this->form = new ilPropertyFormGUI(); - $this->form->setTitle($this->plugin->txt("edit_properties")); - $this->form->setTableWidth("100%"); - $this->form->setId("xtsf_properties"); - $this->form->setFormAction($this->ctrl->getFormAction($this->controller)); - - if($this->controller->object->getParticipants()->hasParticipants()) - { - ilUtil::sendInfo($this->plugin->txt("unable_to_edit_settings")); - } - else - { - $this->form->addCommandButton("ilFormATestPropertiesGUI.update", $this->plugin->txt("save")); - } - - $title = new ilTextInputGUI($this->plugin->txt("title"), "title"); - $title->setRequired(true); - - $description = new ilTextAreaInputGUI($this->plugin->txt("description"), "description"); - $description->setRequired(false); - - $availability_header = new ilFormSectionHeaderGUI(); - $this->lng->loadLanguageModule('rep'); - $availability_header->setTitle($this->lng->txt("rep_activation_availability")); - - $online = new ilCheckboxInputGUI($this->plugin->txt("online"), "online"); - $online->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - $online->setValue(1); - - $information_header = new ilFormSectionHeaderGUI(); - $information_header->setTitle($this->lng->txt("tst_beginning_ending_information")); - - $sessionheader = new ilFormSectionHeaderGUI(); - $sessionheader->setTitle($this->lng->txt("tst_session_settings")); - - $max_passes = new ilNumberInputGUI($this->lng->txt("tst_nr_of_tries"), "max_passes"); - $max_passes->allowDecimals(false); - $max_passes->setMinValue(0); - $max_passes->setSize(3); - $max_passes->setRequired(true); - $max_passes->setSuffix($this->lng->txt("0_unlimited")); - $max_passes->setValue((int)$this->controller->object->getMaxPasses()); - $max_passes->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - - $enable_start_time = new ilCheckboxInputGUI($this->plugin->txt("start_time"), "enable_start_time"); - $enable_start_time->setValue(1); - $enable_start_time->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - - $start_time = new ilDateTimeInputGUI('', 'start_time'); - $start_time->setShowTime(true); - $start_time->setDate(new ilDateTime(time(), IL_CAL_UNIX)); - $start_time->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - $enable_start_time->addSubItem($start_time); - - $enable_end_time = new ilCheckboxInputGUI($this->plugin->txt("end_time"), "enable_end_time"); - $enable_end_time->setValue(1); - $enable_end_time->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - - $end_time = new ilDateTimeInputGUI('', 'end_time'); - $end_time->setShowTime(true); - $end_time->setDate(new ilDateTime(time(), IL_CAL_UNIX)); - $end_time->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - $enable_end_time->addSubItem($end_time); - - $test_execution_header = new ilFormSectionHeaderGUI(); - $test_execution_header->setTitle($this->lng->txt("tst_test_execution")); - - $allow_walk_back = new ilCheckboxInputGUI($this->plugin->txt("allow_walk_back"), "allow_walk_back"); - $allow_walk_back->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - $allow_walk_back->setValue(1); - - $show_current_track = new ilCheckboxInputGUI($this->plugin->txt("show_current_track"), "show_current_track"); - $show_current_track->setInfo($this->plugin->txt("show_current_track_info")); - $show_current_track->setValue(1); - $show_current_track->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - - $show_questions_overview = new ilCheckboxInputGUI($this->plugin->txt("show_questions_overview"), "show_questions_overview"); - $show_questions_overview->setInfo($this->plugin->txt("show_questions_overview_info")); - $show_questions_overview->setValue(1); - $show_questions_overview->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - - $allow_interruption = new ilCheckboxInputGUI($this->plugin->txt("allow_interruption"), "allow_interruption"); - $allow_interruption->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - $allow_interruption->setValue(1); - - $skill_service = new ilCheckboxInputGUI($this->plugin->txt("skill_service_setting"), "skill_service"); - global $DIC; - $ilSetting = $DIC->settings(); - $skill_setting_enabled = $ilSetting->_lookupValue('skmg','enable_skmg'); - - $skill_service->setDisabled($this->controller->object->getParticipants()->hasParticipants() || $skill_setting_enabled == false); - $skill_service->setInfo($this->plugin->txt('adm_enable_skmg_first')); - $skill_service->setValue(1); - - $this->form->addItem($title); - $this->form->addItem($description); - - $this->form->addItem($availability_header); - $this->form->addItem($online); - - $this->form->addItem($information_header); - $this->createStatementField($model, "intro_statement"); - $this->createStatementField($model, "final_statement"); - - $this->form->addItem($sessionheader); - $this->form->addItem($max_passes); - $this->form->addItem($enable_start_time); - $this->form->addItem($enable_end_time); - - $this->form->addItem($allow_walk_back); - $this->form->addItem($show_current_track); - $this->form->addItem($show_questions_overview); - $this->form->addItem($allow_interruption); - - $this->form->addItem($skill_service); - - $this->addQuestionBehaviourFormSection($this->form); - } - - private function addQuestionBehaviourFormSection(ilPropertyFormGUI $form) - { - //sequence properties - $seqheader = new ilFormSectionHeaderGUI(); - $seqheader->setTitle($this->lng->txt("tst_presentation_properties")); - $this->form->addItem($seqheader); - - // instant feedback - $instant_feedback = new ilCheckboxGroupInputGUI($this->lng->txt('tst_instant_feedback'), 'instant_feedback'); - - $instant_feedback->addOption(new ilCheckboxOption( - $this->lng->txt('tst_instant_feedback_results'), 'instant_feedback_points', - $this->lng->txt('tst_instant_feedback_results_desc') - )); - $instant_feedback->addOption(new ilCheckboxOption( - $this->lng->txt('tst_instant_feedback_answer_generic'), 'instant_feedback_generic', - $this->lng->txt('tst_instant_feedback_answer_generic_desc') - )); - $instant_feedback->addOption(new ilCheckboxOption( - $this->lng->txt('tst_instant_feedback_answer_specific'), 'instant_feedback_specific', - $this->lng->txt('tst_instant_feedback_answer_specific_desc') - )); - $instant_feedback->addOption(new ilCheckboxOption( - $this->lng->txt('tst_instant_feedback_solution'), 'instant_feedback_solution', - $this->lng->txt('tst_instant_feedback_solution_desc') - )); - - $values = array(); - - if ($this->controller->object->getSpecificAnswerFeedback()) - { - $values[] = 'instant_feedback_specific'; - } - if ($this->controller->object->getGenericAnswerFeedback()) - { - $values[] = 'instant_feedback_generic'; - } - if ($this->controller->object->getAnswerFeedbackPoints()) - { - $values[] = 'instant_feedback_points'; - } - if ($this->controller->object->getInstantFeedbackSolution()) - { - $values[] = 'instant_feedback_solution'; - } - $instant_feedback->setValue($values); - $this->form->addItem($instant_feedback); - - // node feedback - $node_feedback = new ilCheckboxGroupInputGUI($this->plugin->txt('tst_node_feedback'), 'node_feedback'); - - // author - $node_feedback->addOption(new ilCheckboxOption( - $this->plugin->txt('tst_node_feedback_author'), 'node_feedback_author', - $this->plugin->txt('tst_node_feedback_author_desc') - )); - - // participants - $node_feedback->addOption(new ilCheckboxOption( - $this->plugin->txt('tst_node_feedback_part'), 'node_feedback_part', - $this->plugin->txt('tst_node_feedback_part_desc') - )); - $node_feedback->addOption(new ilCheckboxOption( - $this->plugin->txt('tst_node_feedback_part_res'), 'node_feedback_part_res', - $this->plugin->txt('tst_node_feedback_part_res_desc') - )); - - $node_values = array(); - - if ($this->controller->object->getNodeFeedbackAuthor()) - { - $node_values[] = 'node_feedback_author'; - } - if ($this->controller->object->getNodeFeedbackParticipant()) - { - $node_values[] = 'node_feedback_part'; - } - if ($this->controller->object->getNodeFeedbackParticipantRes()) - { - $node_values[] = 'node_feedback_part_res'; - } - $node_feedback->setValue($node_values); - $this->form->addItem($node_feedback); - - // selector for unicode characters - global $DIC; - $ilSetting = $DIC->settings(); - if($ilSetting->get('char_selector_availability') > 0) - { - // If there will be more presentation settings in future, move this header creation - - require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php'; - $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_TEST); - $char_selector->getConfig()->setAvailability($this->controller->object->getCharSelectorAvailability()); - $char_selector->getConfig()->setDefinition($this->controller->object->getCharSelectorDefinition()); - $char_selector->addFormProperties($this->form); - $char_selector->setFormValues($this->form); - - $refl = new ReflectionObject($char_selector); - $statics = $refl->getStaticProperties(); - $allowrd_guis = $statics['allowed_guis']; - $allowrd_guis[] = 'ilObjFormATestGUI'; - $property = $refl->getProperty('allowed_guis'); - $property->setAccessible(true); - $property->setValue($allowrd_guis); - - $this->form->getItemByPostVar('char_selector_availability')->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - $this->form->getItemByPostVar('char_selector_blocks')->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - $this->form->getItemByPostVar('char_selector_custom_items')->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - } - } - - protected function canUpdate() - { - return !$this->controller->object->getParticipants()->hasParticipants(); - } - - - /** - * Returns the current tab name - * return string - */ - protected function getCurrentTab() - { - return "properties"; - } - - /** - * @return array - */ - protected function getRequirements() - { - array(); - } - - /** - * Loads and returns the Model for the controller gui - * @return ilPluginModelInterface - */ - protected function loadModel() - { - return $this->controller->object; - } - - /** - * Get the redirect action after an update was successful - * @return string - */ - protected function getRedirectAfterUpdate() - { - - } - - /** - * Get the redirect action after an update was successful - * @return string - */ - protected function getAfterUpdateRedirectCmd() - { - return "ilFormATestPropertiesGUI.edit"; - } - - /** - * @param $model - * - * @return array - */ - protected function getAfterUpdateRedirectParams($model) - { - return array(); - } - - /** - * @param $model - * @param $statement_type - */ - protected function createStatementField($model, $statement_type) - { - $statement = new ilTextAreaInputGUI($this->plugin->txt($statement_type), $statement_type); - $statement->setRows(10); - $statement->setUseRte(true); - $statement->addPlugin("latex"); - $statement->addButton("latex"); - $statement->setRTESupport($model->getId(), "tst", "assessment"); - $statement->setRteTagSet("full"); - $statement->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - - $show_statement = new ilCheckboxInputGUI($this->plugin->txt("{$statement_type}_show"), "show_$statement_type"); - $show_statement->setValue(1); - $show_statement->setOptionTitle($this->plugin->txt("{$statement_type}_label")); - $show_statement->setInfo($this->plugin->txt("{$statement_type}_desc")); - $show_statement->setDisabled($this->controller->object->getParticipants()->hasParticipants()); - - $show_statement->addSubItem($statement); - $this->form->addItem($show_statement); - } + /** + * @param ilXTSFModel $model + * @return mixed|void + */ + protected function initForm($model) + { + $this->form = new ilPropertyFormGUI(); + $this->form->setTitle($this->plugin->txt("edit_properties")); + $this->form->setTableWidth("100%"); + $this->form->setId("xtsf_properties"); + $this->form->setFormAction($this->ctrl->getFormAction($this->controller)); + + if ($this->controller->object->getParticipants()->hasParticipants()) { + ilUtil::sendInfo($this->plugin->txt("unable_to_edit_settings")); + } else { + $this->form->addCommandButton("ilFormATestPropertiesGUI.update", $this->plugin->txt("save")); + } + + $title = new ilTextInputGUI($this->plugin->txt("title"), "title"); + $title->setRequired(true); + + $description = new ilTextAreaInputGUI($this->plugin->txt("description"), "description"); + $description->setRequired(false); + + $availability_header = new ilFormSectionHeaderGUI(); + $this->lng->loadLanguageModule('rep'); + $availability_header->setTitle($this->lng->txt("rep_activation_availability")); + + $online = new ilCheckboxInputGUI($this->plugin->txt("online"), "online"); + $online->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + $online->setValue(1); + + $information_header = new ilFormSectionHeaderGUI(); + $information_header->setTitle($this->plugin->txt("tst_beginning_ending_information")); + + $sessionheader = new ilFormSectionHeaderGUI(); + $sessionheader->setTitle($this->lng->txt("tst_session_settings")); + + $max_passes = new ilNumberInputGUI($this->lng->txt("tst_nr_of_tries"), "max_passes"); + $max_passes->allowDecimals(false); + $max_passes->setMinValue(0); + $max_passes->setSize(3); + $max_passes->setRequired(true); + $max_passes->setSuffix($this->plugin->txt("0_unlimited")); + $max_passes->setValue((int) $this->controller->object->getMaxPasses()); + $max_passes->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + + $enable_start_time = new ilCheckboxInputGUI($this->plugin->txt("start_time"), "enable_start_time"); + $enable_start_time->setValue(1); + $enable_start_time->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + + $start_time = new ilDateTimeInputGUI('', 'start_time'); + $start_time->setShowTime(true); + $start_time->setDate(new ilDateTime(time(), IL_CAL_UNIX)); + $start_time->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + $enable_start_time->addSubItem($start_time); + + $enable_end_time = new ilCheckboxInputGUI($this->plugin->txt("end_time"), "enable_end_time"); + $enable_end_time->setValue(1); + $enable_end_time->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + + $end_time = new ilDateTimeInputGUI('', 'end_time'); + $end_time->setShowTime(true); + $end_time->setDate(new ilDateTime(time(), IL_CAL_UNIX)); + $end_time->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + $enable_end_time->addSubItem($end_time); + + $test_execution_header = new ilFormSectionHeaderGUI(); + $test_execution_header->setTitle($this->lng->txt("tst_test_execution")); + + $allow_walk_back = new ilCheckboxInputGUI($this->plugin->txt("allow_walk_back"), "allow_walk_back"); + $allow_walk_back->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + $allow_walk_back->setValue(1); + + $show_current_track = new ilCheckboxInputGUI($this->plugin->txt("show_current_track"), "show_current_track"); + $show_current_track->setInfo($this->plugin->txt("show_current_track_info")); + $show_current_track->setValue(1); + $show_current_track->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + + $show_questions_overview = new ilCheckboxInputGUI($this->plugin->txt("show_questions_overview"), "show_questions_overview"); + $show_questions_overview->setInfo($this->plugin->txt("show_questions_overview_info")); + $show_questions_overview->setValue(1); + $show_questions_overview->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + + $allow_interruption = new ilCheckboxInputGUI($this->plugin->txt("allow_interruption"), "allow_interruption"); + $allow_interruption->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + $allow_interruption->setValue(1); + + $skill_service = new ilCheckboxInputGUI($this->plugin->txt("skill_service_setting"), "skill_service"); + global $DIC; + $ilSetting = $DIC->settings(); + $skill_setting_enabled = $ilSetting->_lookupValue('skmg', 'enable_skmg'); + + $skill_service->setDisabled($this->controller->object->getParticipants()->hasParticipants() || $skill_setting_enabled == false); + $skill_service->setInfo($this->plugin->txt('adm_enable_skmg_first')); + $skill_service->setValue(1); + + $this->form->addItem($title); + $this->form->addItem($description); + + $this->form->addItem($availability_header); + $this->form->addItem($online); + + $this->form->addItem($information_header); + $this->createStatementField($model, "intro_statement"); + $this->createStatementField($model, "final_statement"); + + $this->form->addItem($sessionheader); + $this->form->addItem($max_passes); + $this->form->addItem($enable_start_time); + $this->form->addItem($enable_end_time); + + $this->form->addItem($allow_walk_back); + $this->form->addItem($show_current_track); + $this->form->addItem($show_questions_overview); + $this->form->addItem($allow_interruption); + + $this->form->addItem($skill_service); + + $this->addQuestionBehaviourFormSection($this->form); + } + + private function addQuestionBehaviourFormSection(ilPropertyFormGUI $form) + { + //sequence properties + $seqheader = new ilFormSectionHeaderGUI(); + $seqheader->setTitle($this->lng->txt("tst_presentation_properties")); + $this->form->addItem($seqheader); + + // instant feedback + $instant_feedback = new ilCheckboxGroupInputGUI($this->lng->txt('tst_instant_feedback'), 'instant_feedback'); + + $instant_feedback->addOption(new ilCheckboxOption( + $this->lng->txt('tst_instant_feedback_results'), + 'instant_feedback_points', + $this->lng->txt('tst_instant_feedback_results_desc') + )); + $instant_feedback->addOption(new ilCheckboxOption( + $this->lng->txt('tst_instant_feedback_answer_generic'), + 'instant_feedback_generic', + $this->lng->txt('tst_instant_feedback_answer_generic_desc') + )); + $instant_feedback->addOption(new ilCheckboxOption( + $this->lng->txt('tst_instant_feedback_answer_specific'), + 'instant_feedback_specific', + $this->lng->txt('tst_instant_feedback_answer_specific_desc') + )); + $instant_feedback->addOption(new ilCheckboxOption( + $this->lng->txt('tst_instant_feedback_solution'), + 'instant_feedback_solution', + $this->lng->txt('tst_instant_feedback_solution_desc') + )); + + $values = array(); + + if ($this->controller->object->getSpecificAnswerFeedback()) { + $values[] = 'instant_feedback_specific'; + } + if ($this->controller->object->getGenericAnswerFeedback()) { + $values[] = 'instant_feedback_generic'; + } + if ($this->controller->object->getAnswerFeedbackPoints()) { + $values[] = 'instant_feedback_points'; + } + if ($this->controller->object->getInstantFeedbackSolution()) { + $values[] = 'instant_feedback_solution'; + } + $instant_feedback->setValue($values); + $this->form->addItem($instant_feedback); + + // node feedback + $node_feedback = new ilCheckboxGroupInputGUI($this->plugin->txt('tst_node_feedback'), 'node_feedback'); + + // author + $node_feedback->addOption(new ilCheckboxOption( + $this->plugin->txt('tst_node_feedback_author'), + 'node_feedback_author', + $this->plugin->txt('tst_node_feedback_author_desc') + )); + + // participants + $node_feedback->addOption(new ilCheckboxOption( + $this->plugin->txt('tst_node_feedback_part'), + 'node_feedback_part', + $this->plugin->txt('tst_node_feedback_part_desc') + )); + $node_feedback->addOption(new ilCheckboxOption( + $this->plugin->txt('tst_node_feedback_part_res'), + 'node_feedback_part_res', + $this->plugin->txt('tst_node_feedback_part_res_desc') + )); + + $node_values = array(); + + if ($this->controller->object->getNodeFeedbackAuthor()) { + $node_values[] = 'node_feedback_author'; + } + if ($this->controller->object->getNodeFeedbackParticipant()) { + $node_values[] = 'node_feedback_part'; + } + if ($this->controller->object->getNodeFeedbackParticipantRes()) { + $node_values[] = 'node_feedback_part_res'; + } + $node_feedback->setValue($node_values); + $this->form->addItem($node_feedback); + + // selector for unicode characters + global $DIC; + $ilSetting = $DIC->settings(); + if ($ilSetting->get('char_selector_availability') > 0) { + // If there will be more presentation settings in future, move this header creation + + $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_TEST); + $char_selector->getConfig()->setAvailability($this->controller->object->getCharSelectorAvailability()); + $char_selector->getConfig()->setDefinition($this->controller->object->getCharSelectorDefinition()); + $char_selector->addFormProperties($this->form); + $char_selector->setFormValues($this->form); + + $refl = new ReflectionObject($char_selector); + $statics = $refl->getStaticProperties(); + $allowrd_guis = $statics['allowed_guis']; + $allowrd_guis[] = 'ilObjFormATestGUI'; + $property = $refl->getProperty('allowed_guis'); + $property->setAccessible(true); + $property->setValue($allowrd_guis); + + $this->form->getItemByPostVar('char_selector_availability')->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + $this->form->getItemByPostVar('char_selector_blocks')->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + $this->form->getItemByPostVar('char_selector_custom_items')->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + } + } + + protected function canUpdate() + { + return !$this->controller->object->getParticipants()->hasParticipants(); + } + + + /** + * Returns the current tab name + * return string + */ + protected function getCurrentTab() + { + return "properties"; + } + + /** + * @return array + */ + protected function getRequirements() + { + array(); + } + + /** + * Loads and returns the Model for the controller gui + * @return ilPluginModelInterface + */ + protected function loadModel() + { + return $this->controller->object; + } + + /** + * Get the redirect action after an update was successful + * @return string + */ + protected function getRedirectAfterUpdate() + { + } + + /** + * Get the redirect action after an update was successful + * @return string + */ + protected function getAfterUpdateRedirectCmd() + { + return "ilFormATestPropertiesGUI.edit"; + } + + /** + * @param $model + * + * @return array + */ + protected function getAfterUpdateRedirectParams($model) + { + return array(); + } + + /** + * @param $model + * @param $statement_type + */ + protected function createStatementField($model, $statement_type) + { + $statement = new ilTextAreaInputGUI($this->plugin->txt($statement_type), $statement_type); + $statement->setRows(10); + $statement->setUseRte(true); + $statement->addPlugin("latex"); + $statement->addButton("latex"); + $statement->setRTESupport($model->getId(), "tst", "assessment"); + $statement->setRteTagSet("full"); + $statement->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + + $show_statement = new ilCheckboxInputGUI($this->plugin->txt("{$statement_type}_show"), "show_$statement_type"); + $show_statement->setValue(1); + $show_statement->setOptionTitle($this->plugin->txt("{$statement_type}_label")); + $show_statement->setInfo($this->plugin->txt("{$statement_type}_desc")); + $show_statement->setDisabled($this->controller->object->getParticipants()->hasParticipants()); + + $show_statement->addSubItem($statement); + $this->form->addItem($show_statement); + } } diff --git a/classes/controllers/class.ilFormATestResultOuputGUI.php b/classes/controllers/class.ilFormATestResultOuputGUI.php index 7404904638b508e2173218ad20b2206b405f2207..16436213bf0d66197413ae67ffbdeede37f008b8 100644 --- a/classes/controllers/class.ilFormATestResultOuputGUI.php +++ b/classes/controllers/class.ilFormATestResultOuputGUI.php @@ -8,313 +8,284 @@ require_once "abstract.ilXTSFControllerGUI.php"; * Date: 22.01.14 * Time: 10:38 * @author Thomas Joußen - */ + */ class ilFormATestResultOuputGUI extends ilXTSFControllerGUI { - - const MODUS_AUTHOR = "author"; - const MODUS_PARTICIPANTS = "participants"; - - /** - * @var ilTemplate - */ - protected $template; - - /** - * @var string - */ - protected $modus; - - public function __construct($controller) - { - parent::__construct($controller); - - $this->initTemplate("tpl.il_xtsf_result.html"); - $this->modus = self::MODUS_AUTHOR; - } - - /** - * @param string $modus - */ - public function setModus($modus) - { - $this->modus = $modus; - } - - /** - * @param int $user_id - */ - public function renderTestData($user_id) - { - $this->template->setVariable("USER", ilUserUtil::getNamePresentation($user_id)); - $this->template->setVariable("DATE_OF_TEST_TITLE", $this->plugin->txt("date_of_test_title")); - $this->template->setVariable("DATE_OF_TEST", "DATUM ES TESTS"); - } - - /** - * @param int $active_id - * @param string $detailed_action - */ - public function renderPassesOverview($active_id, $detailed_action = "") - { - $table = new ilFormATestResultsTableGUI($this->controller, $this->plugin, ""); - $table->setDetailedAction($detailed_action); - $table->setModelList(new ilFormATestResultList($active_id)); - $table->populate(); - $this->template->setVariable("PASS_OVERVIEW_TITLE", $this->plugin->txt("test_result")); - $this->template->setCurrentBlock("pass_overview"); - $this->template->setVariable("PASS_OVERVIEW_TABLE", $table->getHTML()); - $this->template->parseCurrentBlock(); - } - - /** - * @param int $session_id - */ - public function renderStepsOverview($session_id) - { - - $gateway = new ilObjTestGateway(); - $points = $gateway->getMaxPointsPerSet(ilFormATestSession::getActiveIdBySessionId($session_id)); - $sets = $this->controller->object->getSetList()->getData(); - foreach($sets as $set) - { - $table = new ilFormATestSetResultTableGUI($this->controller, $this->plugin, true, $this->modus); - $table->setTotalMaxPoints($points[$set["id"]]); - $table->setTitle(sprintf($this->plugin->txt("result_path_for"), $set["title"])); - $table->setModelList(new ilFormATestSetResultList( - $this->controller->object, - $set["id"], - $session_id - )); - $table->populate(); - - $this->template->setCurrentBlock("step_overview_table"); - $this->template->setVariable("STEP_OVERVIEW_TABLE", $table->getHTML()); - $this->template->parseCurrentBlock(); - } - - $this->template->setCurrentBlock("steps_overview"); - $this->template->setVariable("STEP_OVERVIEW_TITLE", $this->plugin->txt("result_table_header")); - $this->template->parseCurrentBlock(); - } - - /** - * @param int $session_id - * @param int $set_id - * @param int $node_id - */ - public function renderFeedback($session_id, $set_id, $node_id, $step) - { - $feedbacks = $this->controller->object->getNodeFeedbacks($session_id, $set_id, $node_id, $step); - - if(!is_array($feedbacks)) return; - - $this->renderFeedbacks($feedbacks); - } - - /** - * @param int $session_id - * @param array $sets - * @param bool $graphical_output - * @param int|null $current_node_id - * @param bool $is_finished Flag für die Ausgabe des prozessbezogenen Feedbacks, zur Unterscheidung ob der Test schon abgeschlossen wurde oder nicht. - */ - public function renderQuestionDetails($session_id, $sets, $graphical_output, $current_node_id = null, $is_finished = false) - { - $pass = ilFormATestSession::getPassBySessionId($session_id); - $active_id = ilFormATestSession::getActiveIdBySessionId($session_id); - - $is_feedback_enabled = $this->controller->object->isFeedbackEnabled(); - $is_res_feedback_enabled = $this->controller->object->isResultFeedbackEnabled(); - - foreach($sets as $set) - { - $result_list = new ilFormATestSetResultList($this->controller->object,$set["id"],$session_id); - $data = $result_list->getData(); - - $data_exist = false; - - // feedback output "before FIRST question" - $feedback_exist = $this->controller->object->getNodeFeedbacks($session_id, $set['id'], null, 0); - if($feedback_exist && $this->modus == self::MODUS_AUTHOR) - { - $this->renderFeedbacks($feedback_exist); - $this->template->setCurrentBlock('path_overview_question'); - $this->template->parseCurrentBlock(); - } - else if( $feedback_exist && $this->modus == self::MODUS_PARTICIPANTS && $is_feedback_enabled && !$is_finished) - { - $this->renderFeedbacks($feedback_exist); - $this->template->setCurrentBlock('path_overview_question'); - $this->template->parseCurrentBlock(); - } - else if($feedback_exist && $this->modus == self::MODUS_PARTICIPANTS && $is_res_feedback_enabled && $is_finished) - { - $this->renderFeedbacks($feedback_exist); - $this->template->setCurrentBlock('path_overview_question'); - $this->template->parseCurrentBlock(); - } - - $step = 1; - foreach($data as $item) - { - if($current_node_id == null || $current_node_id != $item["id"]) - { - if($this->modus == self::MODUS_AUTHOR) - { - $this->renderFeedback($session_id, $item["set_fi"], null, $item['step']); - } - else if( $this->modus == self::MODUS_PARTICIPANTS && $is_feedback_enabled && !$is_finished) - { - $this->renderFeedback($session_id, $item["set_fi"], $item["id"], $item['step']); - } - else if( $this->modus == self::MODUS_PARTICIPANTS && $is_res_feedback_enabled && $is_finished) - { - $this->renderFeedback($session_id, $item["set_fi"], null, $item['step']); - } - - $data_exist = true; - $question_title = "(Q ". $item["question_index"]. ") ". $item["question_title"]; - if($this->modus == self::MODUS_PARTICIPANTS) - { - $question_title = $set["title"] . " - " . $this->plugin->txt("header_step"). ": ". $step; - $step++; - } - - $gui = assQuestion::instantiateQuestionGUI($item["question_fi"]); - $gui->object->setStep($item["step"]); - $output = $gui->getSolutionOutput($active_id, $pass, $graphical_output,false,true,$graphical_output); - - if($this->modus == self::MODUS_AUTHOR) - { - $this->template->setCurrentBlock("condition"); - $this->template->setVariable("PATH_OVERVIEW_QUESTION_INDEX", $item["question_index"]); - $this->template->setVariable("PATH_OVERVIEW_PATH", $item["title"]); - - if($item["matched_condition"] == "") - { - $item["matched_condition"] = $this->plugin->txt("empty_condition"); - } - $type = $this->plugin->txt("condition_type_initial"); - if($item["matched_condition_id"] != null) - { - $type = $this->plugin->txt("condition_type_jump"); - } - $this->template->setVariable("PATH_OVERVIEW_CONDITION", $item["matched_condition"]); - $this->template->setVariable("TYPE", $type); - $this->template->parseCurrentBlock(); - } - - if($graphical_output) - { - if($gui->object->getMaximumPoints() != $item["max_points"]) - { - $this->template->setCurrentBlock("dominant_scoring"); - $this->template->setVariable("POINTS_INFORMATION", "Für diese Antwort wurden Ihnen alternative Punkte zugewiesen."); - $this->template->setVariable("POSSIBLE_POINTS", sprintf($this->plugin->txt("possible_points"), $gui->object->calculateReachedPoints($active_id, $pass), $gui->object->getMaximumPoints())); - $this->template->parseCurrentBlock(); - } - } - $this->template->setCurrentBlock("path_overview_question"); - $this->template->setVariable("PATH_OVERVIEW_QUESTION", $output); - $this->template->setVariable("QUESTION_TITLE", $question_title); - $this->template->setVariable("REACHED_POINTS", sprintf($this->plugin->txt("reached_points"), $item["reached_points"], $item["max_points"])); - $this->template->parseCurrentBlock(); - } - - } - $this->template->setCurrentBlock("paths_set_overview"); - $this->template->setVariable("PATH_SET_OVERVIEW_TITLE", sprintf($this->plugin->txt("results_for_set"), $set["title"])); - $this->template->parseCurrentBlock(); - - - if(!$data_exist) - { - $this->template->setCurrentBlock("no_data"); - $this->template->setVariable("NO_DATA", $set["title"] . ": " . $this->plugin->txt("no_data")); - $this->template->parseCurrentBlock(); - } - } - - $this->populateContentStyleBlock(); - $this->template->setCurrentBlock("paths_overview"); - $this->template->setVariable("PATH_OVERVIEW_TITLE", $this->plugin->txt("test_result_details")); - $this->template->parseCurrentBlock(); - - } - - public function getHTML() - { - return $this->template->get(); - } - - /** - * @param string $header - */ - public function setHeader($header) - { - $this->template->setVariable("TITLE", $header); - } - - /** - * @param string $template_name - */ - public function initTemplate($template_name) - { - $this->template = new ilTemplate($template_name,true,true,"Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); - } - - protected function populateContentStyleBlock() - { - include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php"); - $this->tpl->setCurrentBlock( "ContentStyle" ); - $this->tpl->setVariable( "LOCATION_CONTENT_STYLESHEET",ilObjStyleSheet::getContentStylePath(0)); - $this->tpl->parseCurrentBlock(); - - $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print"); - $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "ta.css", "Modules/Test"), "screen"); - } - - /** - * Returns the current tab name - * return string - */ - protected function getCurrentTab() - { - return ""; - } - - /** - * @return array - */ - protected function getRequirements() - { - require_once "Services/User/classes/class.ilUserUtil.php"; - require_once "Modules/TestQuestionPool/classes/class.assQuestion.php"; - - return array( - "tables/class.ilFormATestResultsTableGUI.php", - "tables/class.ilFormATestSetResultTableGUI.php", - "models/class.ilFormATestResultList.php", - "models/class.ilFormATestSetResultList.php", - "models/class.ilFormATestSession.php", - "utils/class.ilObjTestGateway.php" - ); - } - - /** - * @param $feedbacks - */ - protected function renderFeedbacks($feedbacks) - { - foreach($feedbacks as $feedback) - { - if($feedback !== NULL && strlen(trim($feedback)) > 0) - { - $this->template->setCurrentBlock('node_feedback'); - $this->template->setVariable('NODE_FEEDBACK', ilUtil::prepareTextareaOutput($feedback, true)); - $this->template->parseCurrentBlock(); - } - } - } + const MODUS_AUTHOR = "author"; + const MODUS_PARTICIPANTS = "participants"; + + /** + * @var ilTemplate + */ + protected $template; + + /** + * @var string + */ + protected $modus; + + public function __construct($controller) + { + parent::__construct($controller); + + $this->initTemplate("tpl.il_xtsf_result.html"); + $this->modus = self::MODUS_AUTHOR; + } + + /** + * @param string $modus + */ + public function setModus($modus) + { + $this->modus = $modus; + } + + /** + * @param int $user_id + */ + public function renderTestData($user_id) + { + $this->template->setVariable("USER", ilUserUtil::getNamePresentation($user_id)); + $this->template->setVariable("DATE_OF_TEST_TITLE", $this->plugin->txt("date_of_test_title")); + $this->template->setVariable("DATE_OF_TEST", "DATUM ES TESTS"); + } + + /** + * @param int $active_id + * @param string $detailed_action + */ + public function renderPassesOverview($active_id, $detailed_action = "") + { + $table = new ilFormATestResultsTableGUI($this->controller, $this->plugin, ""); + $table->setDetailedAction($detailed_action); + $table->setModelList(new ilFormATestResultList($active_id)); + $table->populate(); + $this->template->setVariable("PASS_OVERVIEW_TITLE", $this->plugin->txt("test_result")); + $this->template->setCurrentBlock("pass_overview"); + $this->template->setVariable("PASS_OVERVIEW_TABLE", $table->getHTML()); + $this->template->parseCurrentBlock(); + } + + /** + * @param int $session_id + */ + public function renderStepsOverview($session_id) + { + $gateway = new ilObjTestGateway(); + $points = $gateway->getMaxPointsPerSet(ilFormATestSession::getActiveIdBySessionId($session_id)); + $sets = $this->controller->object->getSetList()->getData(); + foreach ($sets as $set) { + $table = new ilFormATestSetResultTableGUI($this->controller, $this->plugin, true, $this->modus); + $table->setTotalMaxPoints($points[$set["id"]]); + $table->setTitle(sprintf($this->plugin->txt("result_path_for"), $set["title"])); + $table->setModelList(new ilFormATestSetResultList( + $this->controller->object, + $set["id"], + $session_id + )); + $table->populate(); + + $this->template->setCurrentBlock("step_overview_table"); + $this->template->setVariable("STEP_OVERVIEW_TABLE", $table->getHTML()); + $this->template->parseCurrentBlock(); + } + + $this->template->setCurrentBlock("steps_overview"); + $this->template->setVariable("STEP_OVERVIEW_TITLE", $this->plugin->txt("result_table_header")); + $this->template->parseCurrentBlock(); + } + + /** + * @param int $session_id + * @param int $set_id + * @param int $node_id + */ + public function renderFeedback($session_id, $set_id, $node_id, $step) + { + $feedbacks = $this->controller->object->getNodeFeedbacks($session_id, $set_id, $node_id, $step); + + if (!is_array($feedbacks)) { + return; + } + + $this->renderFeedbacks($feedbacks); + } + + /** + * @param int $session_id + * @param array $sets + * @param bool $graphical_output + * @param int|null $current_node_id + * @param bool $is_finished Flag für die Ausgabe des prozessbezogenen Feedbacks, zur Unterscheidung ob der Test schon abgeschlossen wurde oder nicht. + */ + public function renderQuestionDetails($session_id, $sets, $graphical_output, $current_node_id = null, $is_finished = false) + { + $pass = ilFormATestSession::getPassBySessionId($session_id); + $active_id = ilFormATestSession::getActiveIdBySessionId($session_id); + + $is_feedback_enabled = $this->controller->object->isFeedbackEnabled(); + $is_res_feedback_enabled = $this->controller->object->isResultFeedbackEnabled(); + + foreach ($sets as $set) { + $result_list = new ilFormATestSetResultList($this->controller->object, $set["id"], $session_id); + $data = $result_list->getData(); + + $data_exist = false; + + // feedback output "before FIRST question" + $feedback_exist = $this->controller->object->getNodeFeedbacks($session_id, $set['id'], null, 0); + if ($feedback_exist && $this->modus == self::MODUS_AUTHOR) { + $this->renderFeedbacks($feedback_exist); + $this->template->setCurrentBlock('path_overview_question'); + $this->template->parseCurrentBlock(); + } elseif ($feedback_exist && $this->modus == self::MODUS_PARTICIPANTS && $is_feedback_enabled && !$is_finished) { + $this->renderFeedbacks($feedback_exist); + $this->template->setCurrentBlock('path_overview_question'); + $this->template->parseCurrentBlock(); + } elseif ($feedback_exist && $this->modus == self::MODUS_PARTICIPANTS && $is_res_feedback_enabled && $is_finished) { + $this->renderFeedbacks($feedback_exist); + $this->template->setCurrentBlock('path_overview_question'); + $this->template->parseCurrentBlock(); + } + + $step = 1; + foreach ($data as $item) { + if ($current_node_id == null || $current_node_id != $item["id"]) { + if ($this->modus == self::MODUS_AUTHOR) { + $this->renderFeedback($session_id, $item["set_fi"], null, $item['step']); + } elseif ($this->modus == self::MODUS_PARTICIPANTS && $is_feedback_enabled && !$is_finished) { + $this->renderFeedback($session_id, $item["set_fi"], $item["id"], $item['step']); + } elseif ($this->modus == self::MODUS_PARTICIPANTS && $is_res_feedback_enabled && $is_finished) { + $this->renderFeedback($session_id, $item["set_fi"], null, $item['step']); + } + + $data_exist = true; + $question_title = "(Q " . $item["question_index"] . ") " . $item["question_title"]; + if ($this->modus == self::MODUS_PARTICIPANTS) { + $question_title = $set["title"] . " - " . $this->plugin->txt("header_step") . ": " . $step; + $step++; + } + + $gui = assQuestion::instantiateQuestionGUI($item["question_fi"]); + $gui->object->setStep($item["step"]); + $output = $gui->getSolutionOutput($active_id, $pass, $graphical_output, false, true, $graphical_output); + + if ($this->modus == self::MODUS_AUTHOR) { + $this->template->setCurrentBlock("condition"); + $this->template->setVariable("PATH_OVERVIEW_QUESTION_INDEX", $item["question_index"]); + $this->template->setVariable("PATH_OVERVIEW_PATH", $item["title"]); + + if ($item["matched_condition"] == "") { + $item["matched_condition"] = $this->plugin->txt("empty_condition"); + } + $type = $this->plugin->txt("condition_type_initial"); + if ($item["matched_condition_id"] != null) { + $type = $this->plugin->txt("condition_type_jump"); + } + $this->template->setVariable("PATH_OVERVIEW_CONDITION", $item["matched_condition"]); + $this->template->setVariable("TYPE", $type); + $this->template->parseCurrentBlock(); + } + + if ($graphical_output) { + if ($gui->object->getMaximumPoints() != $item["max_points"]) { + $this->template->setCurrentBlock("dominant_scoring"); + $this->template->setVariable("POINTS_INFORMATION", "Für diese Antwort wurden Ihnen alternative Punkte zugewiesen."); + $this->template->setVariable("POSSIBLE_POINTS", sprintf($this->plugin->txt("possible_points"), $gui->object->calculateReachedPoints($active_id, $pass), $gui->object->getMaximumPoints())); + $this->template->parseCurrentBlock(); + } + } + $this->template->setCurrentBlock("path_overview_question"); + $this->template->setVariable("PATH_OVERVIEW_QUESTION", $output); + $this->template->setVariable("QUESTION_TITLE", $question_title); + $this->template->setVariable("REACHED_POINTS", sprintf($this->plugin->txt("reached_points"), $item["reached_points"], $item["max_points"])); + $this->template->parseCurrentBlock(); + } + } + $this->template->setCurrentBlock("paths_set_overview"); + $this->template->setVariable("PATH_SET_OVERVIEW_TITLE", sprintf($this->plugin->txt("results_for_set"), $set["title"])); + $this->template->parseCurrentBlock(); + + + if (!$data_exist) { + $this->template->setCurrentBlock("no_data"); + $this->template->setVariable("NO_DATA", $set["title"] . ": " . $this->plugin->txt("no_data")); + $this->template->parseCurrentBlock(); + } + } + + $this->populateContentStyleBlock(); + $this->template->setCurrentBlock("paths_overview"); + $this->template->setVariable("PATH_OVERVIEW_TITLE", $this->plugin->txt("test_result_details")); + $this->template->parseCurrentBlock(); + } + + public function getHTML() + { + return $this->template->get(); + } + + /** + * @param string $header + */ + public function setHeader($header) + { + $this->template->setVariable("TITLE", $header); + } + + /** + * @param string $template_name + */ + public function initTemplate($template_name) + { + $this->template = new ilTemplate($template_name, true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); + } + + protected function populateContentStyleBlock() + { + $this->tpl->setCurrentBlock("ContentStyle"); + $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0)); + $this->tpl->parseCurrentBlock(); + + $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print"); + $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "ta.css", "Modules/Test"), "screen"); + } + + /** + * Returns the current tab name + * return string + */ + protected function getCurrentTab() + { + return ""; + } + + /** + * @return array + */ + protected function getRequirements() + { + return array( + "tables/class.ilFormATestResultsTableGUI.php", + "tables/class.ilFormATestSetResultTableGUI.php", + "models/class.ilFormATestResultList.php", + "models/class.ilFormATestSetResultList.php", + "models/class.ilFormATestSession.php", + "utils/class.ilObjTestGateway.php" + ); + } + + /** + * @param $feedbacks + */ + protected function renderFeedbacks($feedbacks) + { + foreach ($feedbacks as $feedback) { + if ($feedback !== null && strlen(trim($feedback)) > 0) { + $this->template->setCurrentBlock('node_feedback'); + $this->template->setVariable('NODE_FEEDBACK', ilUtil::prepareTextareaOutput($feedback, true)); + $this->template->parseCurrentBlock(); + } + } + } } diff --git a/classes/controllers/class.ilFormATestScoringAndResultPropertiesGUI.php b/classes/controllers/class.ilFormATestScoringAndResultPropertiesGUI.php index c6ba8f271d4ed2c5f7ad771efc4eb6691386cf51..129a6a99aa81aaf9ad069c91b808acefadd71ac9 100644 --- a/classes/controllers/class.ilFormATestScoringAndResultPropertiesGUI.php +++ b/classes/controllers/class.ilFormATestScoringAndResultPropertiesGUI.php @@ -7,51 +7,50 @@ require_once 'class.ilFormATestPropertiesGUI.php'; */ class ilFormATestScoringAndResultPropertiesGUI extends ilFormATestPropertiesGUI { - /** - * @param ilXTSFModel $model - * @return mixed|void - */ - protected function initForm($model) - { - require_once 'Services/Form/classes/class.ilPropertyFormGUI.php'; - $this->form = new ilPropertyFormGUI(); - $this->form->setTitle($this->controller->lng->txt('test_results')); - $this->form->setTableWidth('100%'); - $this->form->setId('xtsf_scoring_results'); - $this->form->setFormAction($this->ctrl->getFormAction($this->controller)); - - // access to test results - $results_access = new ilRadioGroupInputGUI($this->controller->lng->txt('tst_results_access'), 'score_reporting'); - $results_access->addOption(new ilRadioOption($this->lng->txt('tst_results_access_always'), ilObjFormATest::SCORE_REPORTING_ALWAYS, '')); - $results_access->addOption(new ilRadioOption($this->lng->txt('tst_results_access_finished'), ilObjFormATest::SCORE_REPORTING_FINISHED, '')); - $results_access_date_limitation = new ilRadioOption($this->lng->txt('tst_results_access_date'), ilObjFormATest::SCORE_REPORTING_DATE, ''); - $results_access->addOption($results_access_date_limitation); - $results_access->addOption(new ilRadioOption($this->controller->lng->txt('tst_results_access_never'), ilObjFormATest::SCORE_REPORTING_NEVER, '')); - $results_access->setInfo($this->controller->lng->txt('tst_results_access_description')); - - // access date - $reporting_date = new ilDateTimeInputGUI('', 'reporting_date'); - $reporting_date->setShowTime(true); - $reporting_date->setDate(new ilDateTime(time(), IL_CAL_UNIX)); - - $results_access_date_limitation->addSubItem($reporting_date); - - $this->form->addItem($results_access); - - $this->form->addCommandButton('ilFormATestScoringAndResultPropertiesGUI.update', $this->plugin->txt("save")); - } - - protected function canUpdate() - { - return true; - } - - /** - * Get the redirect action after an update was successful - * @return string - */ - protected function getAfterUpdateRedirectCmd() - { - return "ilFormATestScoringAndResultPropertiesGUI.edit"; - } -} \ No newline at end of file + /** + * @param ilXTSFModel $model + * @return mixed|void + */ + protected function initForm($model) + { + $this->form = new ilPropertyFormGUI(); + $this->form->setTitle($this->controller->lng->txt('test_results')); + $this->form->setTableWidth('100%'); + $this->form->setId('xtsf_scoring_results'); + $this->form->setFormAction($this->ctrl->getFormAction($this->controller)); + + // access to test results + $results_access = new ilRadioGroupInputGUI($this->controller->lng->txt('tst_results_access_enabled'), 'score_reporting'); + $results_access->addOption(new ilRadioOption($this->lng->txt('tst_results_access_always'), ilObjFormATest::SCORE_REPORTING_ALWAYS, '')); + $results_access->addOption(new ilRadioOption($this->lng->txt('tst_results_access_finished'), ilObjFormATest::SCORE_REPORTING_FINISHED, '')); + $results_access_date_limitation = new ilRadioOption($this->lng->txt('tst_results_access_date'), ilObjFormATest::SCORE_REPORTING_DATE, ''); + $results_access->addOption($results_access_date_limitation); + $results_access->addOption(new ilRadioOption($this->controller->plugin->txt('tst_results_access_never'), ilObjFormATest::SCORE_REPORTING_NEVER, '')); + $results_access->setInfo($this->plugin->txt('tst_results_access_description')); + + // access date + $reporting_date = new ilDateTimeInputGUI('', 'reporting_date'); + $reporting_date->setShowTime(true); + $reporting_date->setDate(new ilDateTime(time(), IL_CAL_UNIX)); + + $results_access_date_limitation->addSubItem($reporting_date); + + $this->form->addItem($results_access); + + $this->form->addCommandButton('ilFormATestScoringAndResultPropertiesGUI.update', $this->plugin->txt("save")); + } + + protected function canUpdate() + { + return true; + } + + /** + * Get the redirect action after an update was successful + * @return string + */ + protected function getAfterUpdateRedirectCmd() + { + return "ilFormATestScoringAndResultPropertiesGUI.edit"; + } +} diff --git a/classes/controllers/class.ilFormATestSetsGUI.php b/classes/controllers/class.ilFormATestSetsGUI.php index 53ca772f67220dc16f683a0d458d9dfb0e43cb16..d44b6d1c9f4186ae7285704a3469ab82031806ff 100644 --- a/classes/controllers/class.ilFormATestSetsGUI.php +++ b/classes/controllers/class.ilFormATestSetsGUI.php @@ -8,215 +8,192 @@ require_once "abstract.ilXTSFControllerTableGUI.php"; * Date: 23.09.13 * Time: 14:17 * @author Thomas Joußen - */ + */ class ilFormATestSetsGUI extends ilXTSFControllerTableGUI { - - public function listSets() - { - $this->controller->ensurePermission("write"); - - $session = new ilFormATestSession($this->controller->object); - $session->read($this->controller->object->getSetList()->getData()); - - // @TODO Refactor: Remove setParameter("active_id"); - $has_participants = $this->controller->object->getParticipants()->hasParticipants(); - $table = new ilFormATestSetsTableGUI($this->controller, $this->plugin, "ilFormATestSetsGUI.listSets", true, $has_participants); - $table->setModelList($this->controller->object->getSetList()); - - $this->ctrl->setParameter($this->controller, "active_id", $session->getActiveId()); - $this->initToolbar(); - if(!$has_participants) - { - $this->addToolbarButton("browse_for_sets", 'ilFormATestSetsGUI.browseForSets'); - } - $this->ctrl->setParameter($this->controller, "active_id", ""); - $this->addSessionSensitiveButton($session); - - if($has_participants) - { - ilUtil::sendInfo($this->plugin->txt("participants_data_exists")); - } - else - { - $table->addMultiCommand("ilFormATestSetsGUI.removeSets", $this->lng->txt("remove")); - $table->addCommandButton("ilFormATestSetsGUI.saveSorting", $this->plugin->txt("save_sorting")); - } - - $table->populate(); - - $this->tpl->setContent($table->getHTML()); - } - - public function browseForSets() - { - $this->controller->ensurePermission("write"); - - if($this->controller->object->getParticipants()->hasParticipants()) - { - $this->redirect("ilFormATestSetsGUI.listSets"); - } - - $table = new ilFormATestSetsTableGUI($this->controller, $this->plugin, "ilFormATestSetsGUI.browseForSets"); - $modellist = new ilFormATestQuestionSetPoolSetList($this->controller->object); - $table->setModelList($modellist); - $table->addMultiCommand("ilFormATestSetsGUI.insertSets", $this->lng->txt("insert")); - $table->populate(); - - $data = $modellist->getData(); - if($data === null) - { - ilUtil::sendInfo($this->plugin->txt("no_access_to_sets"), true); - } - elseif(is_array($data) && count($data) == 0) - { - ilUtil::sendInfo($this->plugin->txt("no_sets_existing"), true); - } - - $this->tpl->setContent($table->getHTML()); - } - - public function insertSets() - { - $this->controller->ensurePermission("write"); - - if($this->controller->object->getParticipants()->hasParticipants()) - { - $this->redirect("ilFormATestSetsGUI.listSets"); - } - - if(!$this->dataSelected("s_id")) - { - ilUtil::sendInfo($this->plugin->txt("no_sets_selected"), true); - $this->redirect("ilFormATestSetsGUI.browseForSets"); - } - - $success = $this->controller->object->getSetList()->insert($_POST["s_id"]); - - if(!$success) - { - ilUtil::sendFailure($this->plugin->txt("sets_added_error"), true); - $this->redirect("ilFormATestSetsGUI.browseForSets"); - } - - ilUtil::sendSuccess($this->plugin->txt("sets_added"), true); - $this->redirect("ilFormATestSetsGUI.listSets"); - } - - public function removeSets() - { - $this->redirectIfUnableToDeleteSets(); - - if($_GET["confirmed"]) - { - $this->controller->object->getSetList()->remove($_POST["s_id"]); - $this->sortdata(); - - ilUtil::sendSuccess($this->plugin->txt("sets_removed"), true); - $this->redirect("ilFormATestSetsGUI.listSets"); - } - else - { - $items = array(); - foreach($_POST["s_id"] as $set_id) - { - $set = new ilQuestionSetPoolSet($set_id); - $set->read(); - - $items[] = array( - "name" => "s_id[]", - "id" => $set_id, - "text" => $set->getTitle() - ); - } - $this->renderConfirmationScreen( - "ilFormATestSetsGUI.listSets", - "ilFormATestSetsGUI.removeSets", - $items, - $this->plugin->txt("remove_selected_sets_confirm") - ); - } - } - - public function saveSorting() - { - $this->controller->ensurePermission("write"); - - if($this->controller->object->getParticipants()->hasParticipants()) - { - $this->redirect("ilFormATestSetsGUI.listSets"); - } - - $this->sortdata(); - ilUtil::sendSuccess($this->plugin->txt("saved_sorting"), true); - $this->redirect("ilFormATestSetsGUI.listSets"); - } - - protected function sortdata() - { - $data = $this->controller->object->getSetList()->loadData(); - - foreach($data as $key => $element) - { - $data[$key]["sorting"] = $_POST["sorting"][$key]; - } - - usort($data, function($a,$b){ - return $a["sorting"] - $b["sorting"]; - }); - - if(is_array($data)) - { - for($i = 0; $i < count($data); $i++) - { - $data[$i]["sorting"] = ($i + 1) * 10; - $this->controller->object->getSetList()->update($data[$i]); - } - } - return $data; - } - - - protected function redirectIfUnableToDeleteSets() - { - $this->controller->ensurePermission("write"); - - if (!$this->dataSelected("s_id")) - { - ilUtil::sendFailure($this->plugin->txt("no_sets_selected"), true); - $this->redirect("ilFormATestSetsGUI.listSets"); - } - - if($this->controller->object->getParticipants()->hasParticipants()) - { - ilUtil::sendFailure($this->plugin->txt("set_not_deleteable_cause_participants"), true); - $this->redirect("ilFormATestSetsGUI.listSets"); - } - } - - /** - * Returns the current tab name - * - * return string; - */ - protected function getCurrentTab() - { - return "sets"; - } - - /** - * @return array - */ - protected function getRequirements() - { - require_once "Services/Utilities/classes/class.ilConfirmationGUI.php"; - require_once "Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/models/class.ilQuestionSetPoolSet.php"; - - return array( - "tables/class.ilFormATestSetsTableGUI.php", - "models/class.ilFormATestQuestionSetPoolSetList.php", - "models/class.ilFormATestSession.php", - "utils/abstract.ilFormATestPlayerAccessHelper.php", - ); - } + public function listSets() + { + $this->controller->ensurePermission("write"); + + $session = new ilFormATestSession($this->controller->object); + $session->read($this->controller->object->getSetList()->getData()); + + // @TODO Refactor: Remove setParameter("active_id"); + $has_participants = $this->controller->object->getParticipants()->hasParticipants(); + $table = new ilFormATestSetsTableGUI($this->controller, $this->plugin, "ilFormATestSetsGUI.listSets", true, $has_participants); + $table->setModelList($this->controller->object->getSetList()); + + $this->ctrl->setParameter($this->controller, "active_id", $session->getActiveId()); + $this->initToolbar(); + if (!$has_participants) { + $this->addToolbarButton("browse_for_sets", 'ilFormATestSetsGUI.browseForSets'); + } + $this->ctrl->setParameter($this->controller, "active_id", ""); + $this->addSessionSensitiveButton($session); + + if ($has_participants) { + ilUtil::sendInfo($this->plugin->txt("participants_data_exists")); + } else { + $table->addMultiCommand("ilFormATestSetsGUI.removeSets", $this->lng->txt("remove")); + $table->addCommandButton("ilFormATestSetsGUI.saveSorting", $this->plugin->txt("save_sorting")); + } + + $table->populate(); + + $this->tpl->setContent($table->getHTML()); + } + + public function browseForSets() + { + $this->controller->ensurePermission("write"); + + if ($this->controller->object->getParticipants()->hasParticipants()) { + $this->redirect("ilFormATestSetsGUI.listSets"); + } + + $table = new ilFormATestSetsTableGUI($this->controller, $this->plugin, "ilFormATestSetsGUI.browseForSets"); + $modellist = new ilFormATestQuestionSetPoolSetList($this->controller->object); + $table->setModelList($modellist); + $table->addMultiCommand("ilFormATestSetsGUI.insertSets", $this->lng->txt("insert")); + $table->populate(); + + $data = $modellist->getData(); + if ($data === null) { + ilUtil::sendInfo($this->plugin->txt("no_access_to_sets"), true); + } elseif (is_array($data) && count($data) == 0) { + ilUtil::sendInfo($this->plugin->txt("no_sets_existing"), true); + } + + $this->tpl->setContent($table->getHTML()); + } + + public function insertSets() + { + $this->controller->ensurePermission("write"); + + if ($this->controller->object->getParticipants()->hasParticipants()) { + $this->redirect("ilFormATestSetsGUI.listSets"); + } + + if (!$this->dataSelected("s_id")) { + ilUtil::sendInfo($this->plugin->txt("no_sets_selected"), true); + $this->redirect("ilFormATestSetsGUI.browseForSets"); + } + + $success = $this->controller->object->getSetList()->insert($_POST["s_id"]); + + if (!$success) { + ilUtil::sendFailure($this->plugin->txt("sets_added_error"), true); + $this->redirect("ilFormATestSetsGUI.browseForSets"); + } + + ilUtil::sendSuccess($this->plugin->txt("sets_added"), true); + $this->redirect("ilFormATestSetsGUI.listSets"); + } + + public function removeSets() + { + $this->redirectIfUnableToDeleteSets(); + + if ($_GET["confirmed"]) { + $this->controller->object->getSetList()->remove($_POST["s_id"]); + $this->sortdata(); + + ilUtil::sendSuccess($this->plugin->txt("sets_removed"), true); + $this->redirect("ilFormATestSetsGUI.listSets"); + } else { + $items = array(); + foreach ($_POST["s_id"] as $set_id) { + $set = new ilQuestionSetPoolSet($set_id); + $set->read(); + + $items[] = array( + "name" => "s_id[]", + "id" => $set_id, + "text" => $set->getTitle() + ); + } + $this->renderConfirmationScreen( + "ilFormATestSetsGUI.listSets", + "ilFormATestSetsGUI.removeSets", + $items, + $this->plugin->txt("remove_selected_sets_confirm") + ); + } + } + + public function saveSorting() + { + $this->controller->ensurePermission("write"); + + if ($this->controller->object->getParticipants()->hasParticipants()) { + $this->redirect("ilFormATestSetsGUI.listSets"); + } + + $this->sortdata(); + ilUtil::sendSuccess($this->plugin->txt("saved_sorting"), true); + $this->redirect("ilFormATestSetsGUI.listSets"); + } + + protected function sortdata() + { + $data = $this->controller->object->getSetList()->loadData(); + + foreach ($data as $key => $element) { + $data[$key]["sorting"] = $_POST["sorting"][$key]; + } + + usort($data, function ($a, $b) { + return $a["sorting"] - $b["sorting"]; + }); + + if (is_array($data)) { + for ($i = 0; $i < count($data); $i++) { + $data[$i]["sorting"] = ($i + 1) * 10; + $this->controller->object->getSetList()->update($data[$i]); + } + } + return $data; + } + + + protected function redirectIfUnableToDeleteSets() + { + $this->controller->ensurePermission("write"); + + if (!$this->dataSelected("s_id")) { + ilUtil::sendFailure($this->plugin->txt("no_sets_selected"), true); + $this->redirect("ilFormATestSetsGUI.listSets"); + } + + if ($this->controller->object->getParticipants()->hasParticipants()) { + ilUtil::sendFailure($this->plugin->txt("set_not_deleteable_cause_participants"), true); + $this->redirect("ilFormATestSetsGUI.listSets"); + } + } + + /** + * Returns the current tab name + * + * return string; + */ + protected function getCurrentTab() + { + return "sets"; + } + + /** + * @return array + */ + protected function getRequirements() + { + require_once "Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/models/class.ilQuestionSetPoolSet.php"; + + return array( + "tables/class.ilFormATestSetsTableGUI.php", + "models/class.ilFormATestQuestionSetPoolSetList.php", + "models/class.ilFormATestSession.php", + "utils/abstract.ilFormATestPlayerAccessHelper.php", + ); + } } diff --git a/classes/controllers/class.ilFormATestSkillAdministrationGUI.php b/classes/controllers/class.ilFormATestSkillAdministrationGUI.php index 0d5f208ab3ae6a749ded95207e58e9f25b1b4b0e..ba5e0d2e85f082968099e52f2ff5ff2edfaa88d6 100644 --- a/classes/controllers/class.ilFormATestSkillAdministrationGUI.php +++ b/classes/controllers/class.ilFormATestSkillAdministrationGUI.php @@ -1,7 +1,6 @@ object = $controller->object; - - parent::__construct($controller); - } - - public function executeCommand() - { - global $DIC; - $ilDB = $DIC->database(); - $ilAccess = $DIC->access(); - - if( $this->isAccessDenied() ) - { - $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE); - } - - $nextClass = $this->ctrl->getNextClass(); - $this->setSubTabs($nextClass); - $questionContainerId = $this->object->getId(); - - - switch($nextClass) - { - case 'ilformatestassquestionskillassignmentsgui': - $helper = new ilFormATestSkillLevelHelper(); - $questionList = $helper->loadQuestionList($this->object); - - $gui = new ilFormATestAssQuestionSkillAssignmentsGUI($this->ctrl, $ilAccess, $this->tpl, $this->lng, $ilDB); - $gui->setAssignmentEditingEnabled($this->isAssignmentEditingRequired()); - $gui->setQuestionContainerId($questionContainerId); - $gui->setQuestionList($questionList); - $gui->setQuestionOrderSequence($questionList->getOrderSequence()); - $this->ctrl->forwardCommand($gui); - - break; - case 'iltestskilllevelthresholdsgui': - $gui = new ilTestSkillLevelThresholdsGUI($this->ctrl, $this->tpl, $this->lng, $ilDB, $this->object->getTestId()); - $gui->setQuestionAssignmentColumnsEnabled(false); - $gui->setQuestionContainerId($questionContainerId); - $this->ctrl->forwardCommand($gui); - break; - } - } - - private function getRequiredQuestionInstanceTypeFilter() - { - return ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES; - } - - protected function isAssignmentEditingRequired() - { - return true; - } - - protected function isAccessDenied() - { - if(!$this->object->isSkillServiceEnabled()) - { - return true; - } - - if(!ilObjFormATest::isSkillManagementGloballyActivated()) - { - return true; - } - - return false; - } - - /** - * Returns the current tab name - * return string - */ - protected function getCurrentTab() - { - return 'tst_tab_competences'; - } - - private function setSubTabs($controllerClass) - { - $link = $this->ctrl->getLinkTargetByClass( - 'ilFormATestAssQuestionSkillAssignmentsGUI', ilFormATestAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_QUEST_ASSIGNS - ); - $this->tabs->addSubTab( - 'ilformatestassquestionskillassignmentsgui', $this->lng->txt('qpl_skl_sub_tab_quest_assign'), $link - - ); - $link = $this->ctrl->getLinkTargetByClass( - 'ilTestSkillLevelThresholdsGUI', ilTestSkillLevelThresholdsGUI::CMD_SHOW_SKILL_THRESHOLDS - ); - $this->tabs->addSubTab( - 'iltestskilllevelthresholdsgui', $this->lng->txt('tst_skl_sub_tab_thresholds'), $link - ); - - $this->tabs->activateSubTab($controllerClass); - } - - /** - * @return array - */ - protected function getRequirements() - { - return array( - 'utils/class.ilFormATestSkillLevelHelper.php', - 'utils/class.ilFormATestAssQuestionSkillAssignmentsGUI.php', - ); - } + /** + * @var ilObjFormATest + */ + protected $object; + + public function __construct(ilObjFormATestGUI $controller) + { + $this->object = $controller->object; + + parent::__construct($controller); + } + + public function executeCommand() + { + global $DIC; + $ilDB = $DIC->database(); + $ilAccess = $DIC->access(); + + if ($this->isAccessDenied()) { + $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE); + } + + $nextClass = $this->ctrl->getNextClass(); + $this->setSubTabs($nextClass); + $questionContainerId = $this->object->getId(); + + + switch ($nextClass) { + case 'ilformatestassquestionskillassignmentsgui': + $helper = new ilFormATestSkillLevelHelper(); + $questionList = $helper->loadQuestionList($this->object); + + $gui = new ilFormATestAssQuestionSkillAssignmentsGUI($this->ctrl, $ilAccess, $this->tpl, $this->lng, $ilDB); + $gui->setAssignmentEditingEnabled($this->isAssignmentEditingRequired()); + $gui->setQuestionContainerId($questionContainerId); + $gui->setQuestionList($questionList); + $gui->setQuestionOrderSequence($questionList->getOrderSequence()); + $this->ctrl->forwardCommand($gui); + + break; + case 'iltestskilllevelthresholdsgui': + $gui = new ilTestSkillLevelThresholdsGUI($this->ctrl, $this->tpl, $this->lng, $ilDB, $this->object->getTestId()); + $gui->setQuestionAssignmentColumnsEnabled(false); + $gui->setQuestionContainerId($questionContainerId); + $this->ctrl->forwardCommand($gui); + break; + } + } + + private function getRequiredQuestionInstanceTypeFilter() + { + return ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES; + } + + protected function isAssignmentEditingRequired() + { + return true; + } + + protected function isAccessDenied() + { + if (!$this->object->isSkillServiceEnabled()) { + return true; + } + + if (!ilObjFormATest::isSkillManagementGloballyActivated()) { + return true; + } + + return false; + } + + /** + * Returns the current tab name + * return string + */ + protected function getCurrentTab() + { + return 'tst_tab_competences'; + } + + private function setSubTabs($controllerClass) + { + $link = $this->ctrl->getLinkTargetByClass( + 'ilFormATestAssQuestionSkillAssignmentsGUI', + ilFormATestAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_QUEST_ASSIGNS + ); + $this->tabs->addSubTab( + 'ilformatestassquestionskillassignmentsgui', + $this->lng->txt('qpl_skl_sub_tab_quest_assign'), + $link + + ); + $link = $this->ctrl->getLinkTargetByClass( + 'ilTestSkillLevelThresholdsGUI', + ilTestSkillLevelThresholdsGUI::CMD_SHOW_SKILL_THRESHOLDS + ); + $this->tabs->addSubTab( + 'iltestskilllevelthresholdsgui', + $this->lng->txt('tst_skl_sub_tab_thresholds'), + $link + ); + + $this->tabs->activateSubTab($controllerClass); + } + + /** + * @return array + */ + protected function getRequirements() + { + return array( + 'utils/class.ilFormATestSkillLevelHelper.php', + 'utils/class.ilFormATestAssQuestionSkillAssignmentsGUI.php', + ); + } } - \ No newline at end of file diff --git a/classes/dispatcher/class.ilXTSFPluginDispatcher.php b/classes/dispatcher/class.ilXTSFPluginDispatcher.php index b73bb3051baa49063b9c36ca64a9252c446df232..3eca4a31406cbfd693272292c675864f742aad36 100644 --- a/classes/dispatcher/class.ilXTSFPluginDispatcher.php +++ b/classes/dispatcher/class.ilXTSFPluginDispatcher.php @@ -6,116 +6,118 @@ * Date: 23.09.13 * Time: 14:32 * @author Thomas Joußen - */ -class ilXTSFPluginDispatcher { - - /** - * @var ilXTSFPluginDispatcher - */ - private static $_instance = null; - - /** - * @param ilObjectPluginGUI $baseController - * - * @return ilXTSFPluginDispatcher - */ - public static function getInstance($baseController) - { - if(self::$_instance == null) - { - self::$_instance = new ilXTSFPluginDispatcher($baseController); - } - - return self::$_instance; - } - - /** - * @param string $cmd - * - * @return mixed - */ - public function dispatch($cmd) - { - $controller = $this->getController($cmd); - $command = $this->getCommand($cmd); - - if(!is_object($controller)) - { - $controller = $this->instantiateController($controller); - } - - $controller->$command(); - } - - /** - * @param string $cmd - * - * @return string|ilPluginControllerGUI - */ - public function getController($cmd) - { - $controller = substr($cmd, 0, strpos($cmd, ".")); - - if($controller == "") - { - $controller = $this->baseController; - } - - return $controller; - } - - /** - * @param string $cmd - * - * @return string - */ - protected function getCommand($cmd) - { - $pos = strpos($cmd, "."); - - if($pos > 0) - { - $cmd = substr($cmd, $pos + 1); - } - - return $cmd; - } - - /** - * @param string $controller - * - * @return ilPluginControllerGUI - */ - protected function instantiateController($controller) - { - $this->requireController($controller); - - return new $controller($this->baseController); - } - - /** - * @return string - */ - protected function getControllerPath() - { - $path = $this->baseController->plugin->getDirectory() . - DIRECTORY_SEPARATOR . - "classes" . - DIRECTORY_SEPARATOR . - "controllers" . - DIRECTORY_SEPARATOR; - - return $path; - } - - /** - * @param $controller - */ - protected function requireController($controller) - { - require_once $this->getControllerPath() . "class.$controller.php"; - } - - private function __construct($baseController){$this->baseController = $baseController;} - private function __clone(){} + */ +class ilXTSFPluginDispatcher +{ + + /** + * @var ilXTSFPluginDispatcher + */ + private static $_instance = null; + + /** + * @param ilObjectPluginGUI $baseController + * + * @return ilXTSFPluginDispatcher + */ + public static function getInstance($baseController) + { + if (self::$_instance == null) { + self::$_instance = new ilXTSFPluginDispatcher($baseController); + } + + return self::$_instance; + } + + /** + * @param string $cmd + * + * @return mixed + */ + public function dispatch($cmd) + { + $controller = $this->getController($cmd); + $command = $this->getCommand($cmd); + + if (!is_object($controller)) { + $controller = $this->instantiateController($controller); + } + + $controller->$command(); + } + + /** + * @param string $cmd + * + * @return string|ilPluginControllerGUI + */ + public function getController($cmd) + { + $controller = substr($cmd, 0, strpos($cmd, ".")); + + if ($controller == "") { + $controller = $this->baseController; + } + + return $controller; + } + + /** + * @param string $cmd + * + * @return string + */ + protected function getCommand($cmd) + { + $pos = strpos($cmd, "."); + + if ($pos > 0) { + $cmd = substr($cmd, $pos + 1); + } + + return $cmd; + } + + /** + * @param string $controller + * + * @return ilPluginControllerGUI + */ + protected function instantiateController($controller) + { + $this->requireController($controller); + + return new $controller($this->baseController); + } + + /** + * @return string + */ + protected function getControllerPath() + { + $path = $this->baseController->plugin->getDirectory() . + DIRECTORY_SEPARATOR . + "classes" . + DIRECTORY_SEPARATOR . + "controllers" . + DIRECTORY_SEPARATOR; + + return $path; + } + + /** + * @param $controller + */ + protected function requireController($controller) + { + require_once $this->getControllerPath() . "class.$controller.php"; + } + + private function __construct($baseController) + { + $this->baseController = $baseController; + } + private function __clone() + { + } } diff --git a/classes/models/abstract.ilXTSFModel.php b/classes/models/abstract.ilXTSFModel.php index 37a039bc68be036f14df99dae16d79cf6fb01d42..1ec77474dacc3d318f1d940be008d943f187d3de 100644 --- a/classes/models/abstract.ilXTSFModel.php +++ b/classes/models/abstract.ilXTSFModel.php @@ -8,75 +8,72 @@ require_once "interface.ilXTSFModelInterface.php"; * Date: 21.11.13 * Time: 11:17 * @author Thomas Joußen - */ + */ abstract class ilXTSFModel implements ilXTSFModelInterface { - /** - * @var int - */ - protected $id; + /** + * @var int + */ + protected $id; - /** - * @var ilObjQuestionSetPool - */ - protected $question_set_pool; + /** + * @var ilObjQuestionSetPool + */ + protected $question_set_pool; - public function __construct(ilObjQuestionSetPool $question_set_pool, $id = 0) - { - $this->question_set_pool = $question_set_pool; - $this->id = $id; - } + public function __construct(ilObjQuestionSetPool $question_set_pool, $id = 0) + { + $this->question_set_pool = $question_set_pool; + $this->id = $id; + } - //abstract protected function create(); - //abstract protected function update(); + //abstract protected function create(); + //abstract protected function update(); - /** - * @param int $id - */ - public function setId($id) - { - $this->id = $id; - } + /** + * @param int $id + */ + public function setId($id) + { + $this->id = $id; + } - /** - * @return int - */ - public function getId() - { - return $this->id; - } + /** + * @return int + */ + public function getId() + { + return $this->id; + } - /** - * @param \ilObjQuestionSetPool $question_set_pool - */ - public function setQuestionSetPool($question_set_pool) - { - $this->question_set_pool = $question_set_pool; - } + /** + * @param \ilObjQuestionSetPool $question_set_pool + */ + public function setQuestionSetPool($question_set_pool) + { + $this->question_set_pool = $question_set_pool; + } - /** - * @return \ilObjQuestionSetPool - */ - public function getQuestionSetPool() - { - return $this->question_set_pool; - } + /** + * @return \ilObjQuestionSetPool + */ + public function getQuestionSetPool() + { + return $this->question_set_pool; + } - /** - * @return array - */ - public function toArray() - { - $result = array(); - foreach($this as $key => $value) - { - $result[$key] = $value; - } - - return $result; - } + /** + * @return array + */ + public function toArray() + { + $result = array(); + foreach ($this as $key => $value) { + $result[$key] = $value; + } + return $result; + } } - \ No newline at end of file diff --git a/classes/models/abstract.ilXTSFModelList.php b/classes/models/abstract.ilXTSFModelList.php index c993764448dd3cd07cd30180270f0b7122f97145..60a4d1f1a489599d1d4cbfeafd393543138de5f4 100644 --- a/classes/models/abstract.ilXTSFModelList.php +++ b/classes/models/abstract.ilXTSFModelList.php @@ -6,79 +6,77 @@ * Date: 06.11.13 * Time: 11:24 * @author Thomas Joußen - */ + */ abstract class ilXTSFModelList { - /** - * @var ilDB - */ - protected $db; + /** + * @var ilDB + */ + protected $db; - /** - * @var array - */ - private $data; + /** + * @var array + */ + private $data; - /** - * @var boolean - */ - protected $loaded; + /** + * @var boolean + */ + protected $loaded; - /** - * @var ilObjFormATest - */ - public $form_a_test; + /** + * @var ilObjFormATest + */ + public $form_a_test; - public function __construct(ilObjFormATest $form_a_test) - { - global $DIC; + public function __construct(ilObjFormATest $form_a_test) + { + global $DIC; - $this->form_a_test = $form_a_test; - $this->db = $DIC->database(); - } + $this->form_a_test = $form_a_test; + $this->db = $DIC->database(); + } - /** - * @return array - */ - public function getData() - { - if(!$this->isLoaded()) - { - $data = $this->loadData(); - $this->data = $this->createObjectsFromData($data); - $this->setLoaded(true); - } + /** + * @return array + */ + public function getData() + { + if (!$this->isLoaded()) { + $data = $this->loadData(); + $this->data = $this->createObjectsFromData($data); + $this->setLoaded(true); + } - return $this->data; - } + return $this->data; + } - /** - * @param boolean $loaded - */ - public function setLoaded($loaded) - { - $this->loaded = $loaded; - } + /** + * @param boolean $loaded + */ + public function setLoaded($loaded) + { + $this->loaded = $loaded; + } - /** - * @return boolean - */ - public function isLoaded() - { - return $this->loaded; - } + /** + * @return boolean + */ + public function isLoaded() + { + return $this->loaded; + } - /** - * @return array - */ - abstract public function loadData(); + /** + * @return array + */ + abstract public function loadData(); - /** - * @param array $data - * - * @return array - */ - abstract public function createObjectsFromData($data); + /** + * @param array $data + * + * @return array + */ + abstract public function createObjectsFromData($data); } - \ No newline at end of file diff --git a/classes/models/class.ilFormATestParticipantsList.php b/classes/models/class.ilFormATestParticipantsList.php index 9a1eb809194a06ce8eab76c2bb4e1871055cfc4d..3bcc9798a9c2bf22980a1b4527363a73a54f7817 100644 --- a/classes/models/class.ilFormATestParticipantsList.php +++ b/classes/models/class.ilFormATestParticipantsList.php @@ -8,163 +8,160 @@ require_once "abstract.ilXTSFModelList.php"; * Date: 20.01.14 * Time: 15:57 * @author Thomas Joußen - */ + */ class ilFormATestParticipantsList extends ilXTSFModelList { - /** - * @return array - */ - public function loadData() - { - require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/classes/providers/class.ilFormATestParticipantsProvider.php"; - - $provider = new ilFormATestParticipantsProvider(); - return $provider->loadData(array( - "test_id" => $this->form_a_test->getTestId() - )); - } - - public function removeAll() - { - $active_ids = $this->getAllActiveIds(); - $session_ids = $this->getAllSessionIdsByActiveIds($active_ids); - - $this->removeByActiveIdsAndSessionIds($active_ids, $session_ids); - } - - /** - * @param array $session_ids - */ - public function removeBySessionIds($session_ids) - { - $active_ids = $this->getAllActiveIdsBySessionIds($session_ids); - - $this->removeByActiveIdsAndSessionIds($active_ids, $session_ids); - } - - /** - * @return bool - */ - public function hasParticipants() - { - if(is_array($this->getData())) - return count($this->getData()) > 0; - } - - - /** - * @param array $data - * - * @return array - */ - public function createObjectsFromData($data) - { - return $data; - } - - /** - * @return array - */ - protected function getAllActiveIds() - { - $active_ids = array(); - - $result = $this->db->queryF( - "SELECT active_id FROM tst_active WHERE test_fi = %s", - array("integer"), - array($this->form_a_test->getTestId()) - ); - - while ($row = $this->db->fetchAssoc($result)) - { - $active_ids[] = $row["active_id"]; - } - - return $active_ids; - } - - /** - * @param array $active_ids - * - * @return array - */ - protected function getAllSessionIdsByActiveIds($active_ids) - { - $session_ids = array(); - - $in_active_id = $this->db->in("active_id", $active_ids, false, "integer"); - $query = "SELECT session_id FROM rep_robj_xtsf_session WHERE $in_active_id"; - $results = $this->db->query($query); - while ($row = $this->db->fetchAssoc($results)) - { - $session_ids[] = $row["session_id"]; - } - - return $session_ids; - } - - /** - * @param array $session_ids - * - * @return array - */ - protected function getAllActiveIdsBySessionIds($session_ids) - { - $active_ids = array(); - - $in_session_id = $this->db->in("session_id", $session_ids, false, "integer"); - $query = "SELECT active_id FROM rep_robj_xtsf_session WHERE $in_session_id"; - $results = $this->db->query($query); - while ($row = $this->db->fetchAssoc($results)) - { - $active_ids[] = $row["active_id"]; - } - - return $active_ids; - } - - /** - * @param $active_ids - * @param $session_ids - */ - protected function removeByActiveIdsAndSessionIds($active_ids, $session_ids) - { - $in_active_id = $this->db->in("active_id", $active_ids, false, "integer"); - $in_session_id = $this->db->in("session_fi", $session_ids, false, "integer"); - $in_active_fi = $this->db->in("active_fi", $active_ids, false, "integer"); - - $query = "DELETE FROM rep_robj_xtsf_session WHERE $in_active_id"; - $this->db->query($query); - - $query = "DELETE FROM rep_robj_xtsf_tracking WHERE $in_session_id"; - $this->db->query($query); - - $query = "DELETE FROM rep_robj_xtsf_trck_his WHERE $in_session_id"; - $this->db->query($query); - - $query = "DELETE FROM rep_robj_xtsf_set_trck WHERE $in_session_id"; - $this->db->query($query); - - $query = "DELETE FROM rep_robj_xtsf_solut WHERE $in_active_fi"; - $this->db->query($query); - - $query = "DELETE FROM tst_active WHERE $in_active_id"; - $this->db->query($query); - - $query = "DELETE FROM tst_result_cache WHERE $in_active_fi"; - $this->db->query($query); - - $query = "DELETE FROM tst_test_result WHERE $in_active_fi"; - $this->db->query($query); - - $query = "DELETE FROM tst_pass_result WHERE $in_active_fi"; - $this->db->query($query); - - $query = "DELETE FROM tst_solutions WHERE $in_active_fi"; - $this->db->query($query); - - $this->db->manipulate('DELETE FROM rep_robj_xtsf_fbt WHERE '.$this->db->in("session_id", $session_ids, false, "integer")); - } + /** + * @return array + */ + public function loadData() + { + require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/classes/providers/class.ilFormATestParticipantsProvider.php"; + + $provider = new ilFormATestParticipantsProvider(); + return $provider->loadData(array( + "test_id" => $this->form_a_test->getTestId() + )); + } + + public function removeAll() + { + $active_ids = $this->getAllActiveIds(); + $session_ids = $this->getAllSessionIdsByActiveIds($active_ids); + + $this->removeByActiveIdsAndSessionIds($active_ids, $session_ids); + } + + /** + * @param array $session_ids + */ + public function removeBySessionIds($session_ids) + { + $active_ids = $this->getAllActiveIdsBySessionIds($session_ids); + + $this->removeByActiveIdsAndSessionIds($active_ids, $session_ids); + } + + /** + * @return bool + */ + public function hasParticipants() + { + if (is_array($this->getData())) { + return count($this->getData()) > 0; + } + } + + + /** + * @param array $data + * + * @return array + */ + public function createObjectsFromData($data) + { + return $data; + } + + /** + * @return array + */ + protected function getAllActiveIds() + { + $active_ids = array(); + + $result = $this->db->queryF( + "SELECT active_id FROM tst_active WHERE test_fi = %s", + array("integer"), + array($this->form_a_test->getTestId()) + ); + + while ($row = $this->db->fetchAssoc($result)) { + $active_ids[] = $row["active_id"]; + } + + return $active_ids; + } + + /** + * @param array $active_ids + * + * @return array + */ + protected function getAllSessionIdsByActiveIds($active_ids) + { + $session_ids = array(); + + $in_active_id = $this->db->in("active_id", $active_ids, false, "integer"); + $query = "SELECT session_id FROM rep_robj_xtsf_session WHERE $in_active_id"; + $results = $this->db->query($query); + while ($row = $this->db->fetchAssoc($results)) { + $session_ids[] = $row["session_id"]; + } + + return $session_ids; + } + + /** + * @param array $session_ids + * + * @return array + */ + protected function getAllActiveIdsBySessionIds($session_ids) + { + $active_ids = array(); + + $in_session_id = $this->db->in("session_id", $session_ids, false, "integer"); + $query = "SELECT active_id FROM rep_robj_xtsf_session WHERE $in_session_id"; + $results = $this->db->query($query); + while ($row = $this->db->fetchAssoc($results)) { + $active_ids[] = $row["active_id"]; + } + + return $active_ids; + } + + /** + * @param $active_ids + * @param $session_ids + */ + protected function removeByActiveIdsAndSessionIds($active_ids, $session_ids) + { + $in_active_id = $this->db->in("active_id", $active_ids, false, "integer"); + $in_session_id = $this->db->in("session_fi", $session_ids, false, "integer"); + $in_active_fi = $this->db->in("active_fi", $active_ids, false, "integer"); + + $query = "DELETE FROM rep_robj_xtsf_session WHERE $in_active_id"; + $this->db->query($query); + + $query = "DELETE FROM rep_robj_xtsf_tracking WHERE $in_session_id"; + $this->db->query($query); + + $query = "DELETE FROM rep_robj_xtsf_trck_his WHERE $in_session_id"; + $this->db->query($query); + + $query = "DELETE FROM rep_robj_xtsf_set_trck WHERE $in_session_id"; + $this->db->query($query); + + $query = "DELETE FROM rep_robj_xtsf_solut WHERE $in_active_fi"; + $this->db->query($query); + + $query = "DELETE FROM tst_active WHERE $in_active_id"; + $this->db->query($query); + + $query = "DELETE FROM tst_result_cache WHERE $in_active_fi"; + $this->db->query($query); + + $query = "DELETE FROM tst_test_result WHERE $in_active_fi"; + $this->db->query($query); + + $query = "DELETE FROM tst_pass_result WHERE $in_active_fi"; + $this->db->query($query); + + $query = "DELETE FROM tst_solutions WHERE $in_active_fi"; + $this->db->query($query); + + $this->db->manipulate('DELETE FROM rep_robj_xtsf_fbt WHERE ' . $this->db->in("session_id", $session_ids, false, "integer")); + } } - \ No newline at end of file diff --git a/classes/models/class.ilFormATestQuestionSetPoolSetList.php b/classes/models/class.ilFormATestQuestionSetPoolSetList.php index 7e1af74794989fd02af3b3c8d08d5e23f3746b26..6e6cded7d22cc16cd091acbd6e3c290f3055b788 100644 --- a/classes/models/class.ilFormATestQuestionSetPoolSetList.php +++ b/classes/models/class.ilFormATestQuestionSetPoolSetList.php @@ -8,42 +8,40 @@ require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/ * Date: 06.11.13 * Time: 14:56 * @author Thomas Joußen - */ + */ class ilFormATestQuestionSetPoolSetList extends ilXTSFModelList { - /** - * @return array - */ - public function loadData() - { - require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/class.ilObjQuestionSetPool.php"; - require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/classes/providers/class.ilFormATestSetBrowserProvider.php"; - - $available_pools = array_keys(ilObjQuestionSetPool::getAvailableQuestionSetPools()); - - if(is_array($available_pools) && count($available_pools) == 0) - { - return null; - } - - $provider = new ilFormATestSetBrowserProvider(); - $data = $provider->loadData(array( - "set_pools" => $available_pools, - "form_a_test" => $this->form_a_test->getId() - )); - - return $data; - } - - /** - * @param array $data - * - * @return array - */ - public function createObjectsFromData($data) - { - return $data; - } + /** + * @return array + */ + public function loadData() + { + require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/class.ilObjQuestionSetPool.php"; + require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/classes/providers/class.ilFormATestSetBrowserProvider.php"; + + $available_pools = array_keys(ilObjQuestionSetPool::getAvailableQuestionSetPools()); + + if (is_array($available_pools) && count($available_pools) == 0) { + return null; + } + + $provider = new ilFormATestSetBrowserProvider(); + $data = $provider->loadData(array( + "set_pools" => $available_pools, + "form_a_test" => $this->form_a_test->getId() + )); + + return $data; + } + + /** + * @param array $data + * + * @return array + */ + public function createObjectsFromData($data) + { + return $data; + } } - \ No newline at end of file diff --git a/classes/models/class.ilFormATestResult.php b/classes/models/class.ilFormATestResult.php index 841414ec0d79fa872af1f4e6e56a8cd79f183db3..5d31677007b3fdd15dcd1a4335ea9ebead2f4b15 100644 --- a/classes/models/class.ilFormATestResult.php +++ b/classes/models/class.ilFormATestResult.php @@ -8,153 +8,150 @@ require_once "abstract.ilXTSFModel.php"; * Date: 16.01.14 * Time: 16:18 * @author Thomas Joußen - */ + */ class ilFormATestResult { - - protected $session_id; - - protected $active_id; - - protected $pass; - - protected $start_date; - - protected $end_date; - - protected $status; - - protected $answered_questions; - - protected $question_count; - - protected $tstamp; - - protected $points; - - protected $max_points; - - /** - * @param array $data - */ - public function init($data) - { - $this->session_id = $data["session_id"]; - $this->active_id = $data["active_id"]; - $this->pass = $data["pass"]; - $this->start_date = $data["start_date"]; - $this->end_date = $data["end_date"]; - $this->answered_questions = $data["answeredquestions"]; - $this->question_count = $data["questioncount"]; - $this->points = $data["points"]; - $this->max_points = $data["maxpoints"]; - $this->status = $data["status"]; - } - - /** - * @return mixed - */ - public function getActiveId() - { - return $this->active_id; - } - - /** - * @return mixed - */ - public function getAnsweredQuestions() - { - return $this->answered_questions; - } - - /** - * @return mixed - */ - public function getEndDate() - { - return $this->end_date; - } - - /** - * @return mixed - */ - public function getMaxPoints() - { - return $this->max_points; - } - - /** - * @return mixed - */ - public function getPass() - { - return $this->pass; - } - - /** - * @return mixed - */ - public function getPoints() - { - return $this->points; - } - - /** - * @return mixed - */ - public function getQuestionCount() - { - return $this->question_count; - } - - /** - * @return mixed - */ - public function getSessionId() - { - return $this->session_id; - } - - /** - * @return mixed - */ - public function getStartDate() - { - return $this->start_date; - } - - /** - * @return mixed - */ - public function getTstamp() - { - return $this->tstamp; - } - - /** - * @return float - */ - public function getReachedPercentage() - { - return ($this->points / $this->max_points) * 100; - } - - public function toArray() - { - return array( - "session_id" => $this->session_id, - "active_id" => $this->active_id, - "pass" => $this->pass, - "start_date" => $this->start_date, - "end_date" => $this->end_date, - "status" => $this->status, - "answered_questions" => $this->answered_questions, - "question_count" => $this->question_count, - "tstamp" => $this->tstamp, - "points" => $this->points, - "max_points" => $this->max_points - ); - } - + protected $session_id; + + protected $active_id; + + protected $pass; + + protected $start_date; + + protected $end_date; + + protected $status; + + protected $answered_questions; + + protected $question_count; + + protected $tstamp; + + protected $points; + + protected $max_points; + + /** + * @param array $data + */ + public function init($data) + { + $this->session_id = $data["session_id"]; + $this->active_id = $data["active_id"]; + $this->pass = $data["pass"]; + $this->start_date = $data["start_date"]; + $this->end_date = $data["end_date"]; + $this->answered_questions = $data["answeredquestions"]; + $this->question_count = $data["questioncount"]; + $this->points = $data["points"]; + $this->max_points = $data["maxpoints"]; + $this->status = $data["status"]; + } + + /** + * @return mixed + */ + public function getActiveId() + { + return $this->active_id; + } + + /** + * @return mixed + */ + public function getAnsweredQuestions() + { + return $this->answered_questions; + } + + /** + * @return mixed + */ + public function getEndDate() + { + return $this->end_date; + } + + /** + * @return mixed + */ + public function getMaxPoints() + { + return $this->max_points; + } + + /** + * @return mixed + */ + public function getPass() + { + return $this->pass; + } + + /** + * @return mixed + */ + public function getPoints() + { + return $this->points; + } + + /** + * @return mixed + */ + public function getQuestionCount() + { + return $this->question_count; + } + + /** + * @return mixed + */ + public function getSessionId() + { + return $this->session_id; + } + + /** + * @return mixed + */ + public function getStartDate() + { + return $this->start_date; + } + + /** + * @return mixed + */ + public function getTstamp() + { + return $this->tstamp; + } + + /** + * @return float + */ + public function getReachedPercentage() + { + return ($this->points / $this->max_points) * 100; + } + + public function toArray() + { + return array( + "session_id" => $this->session_id, + "active_id" => $this->active_id, + "pass" => $this->pass, + "start_date" => $this->start_date, + "end_date" => $this->end_date, + "status" => $this->status, + "answered_questions" => $this->answered_questions, + "question_count" => $this->question_count, + "tstamp" => $this->tstamp, + "points" => $this->points, + "max_points" => $this->max_points + ); + } } - \ No newline at end of file diff --git a/classes/models/class.ilFormATestResultList.php b/classes/models/class.ilFormATestResultList.php index 33eb0e4f67c5aa4aa340eac2a51506f8bbaaf8b1..3853d38c29977dadedf99107cbd66f5361bb4615 100644 --- a/classes/models/class.ilFormATestResultList.php +++ b/classes/models/class.ilFormATestResultList.php @@ -9,77 +9,75 @@ require_once "abstract.ilXTSFModelList.php"; * Date: 17.01.14 * Time: 09:51 * @author Thomas Joußen - */ + */ class ilFormATestResultList extends ilXTSFModelList { - /** - * @var int $active_id - */ - protected $active_id; + /** + * @var int $active_id + */ + protected $active_id; - /** - * @var ilFormATestResult[] - */ - protected $results = array(); + /** + * @var ilFormATestResult[] + */ + protected $results = array(); - /** - * @var ilDB - */ - protected $db; + /** + * @var ilDB + */ + protected $db; - /** - * @param int $active_id - */ - public function __construct($active_id) - { - global $DIC; + /** + * @param int $active_id + */ + public function __construct($active_id) + { + global $DIC; - $this->active_id = $active_id; - $this->db = $DIC->database(); - } + $this->active_id = $active_id; + $this->db = $DIC->database(); + } - /** - * @return \ilFormATestResult[] - */ - public function getResults() - { - return $this->results; - } + /** + * @return \ilFormATestResult[] + */ + public function getResults() + { + return $this->results; + } - public function loadData() - { - $result = $this->db->queryF( - "SELECT * FROM tst_pass_result result + public function loadData() + { + $result = $this->db->queryF( + "SELECT * FROM tst_pass_result result INNER JOIN rep_robj_xtsf_session session ON session.active_id = result.active_fi WHERE session.active_id = %s AND session.current_pass = result.pass ORDER BY session.current_pass ASC", - array('integer'), - array($this->active_id) - ); + array('integer'), + array($this->active_id) + ); - while($row = $this->db->fetchAssoc($result)) - { - $model = new ilFormATestResult(); - $model->init($row); - $this->results[] = $model; - } - } + while ($row = $this->db->fetchAssoc($result)) { + $model = new ilFormATestResult(); + $model->init($row); + $this->results[] = $model; + } + } - public function getData() - { - $this->loadData(); - return $this->results; - } + public function getData() + { + $this->loadData(); + return $this->results; + } - /** - * @param array $data - * - * @return array - */ - public function createObjectsFromData($data) - { - return $data; - } + /** + * @param array $data + * + * @return array + */ + public function createObjectsFromData($data) + { + return $data; + } } - \ No newline at end of file diff --git a/classes/models/class.ilFormATestSession.php b/classes/models/class.ilFormATestSession.php index afdbd9f82fae73d43383de61a9bdb06e3ffbfadc..da482537ce378d23cd570b94fdcc4b4fcf87f298 100644 --- a/classes/models/class.ilFormATestSession.php +++ b/classes/models/class.ilFormATestSession.php @@ -10,528 +10,507 @@ require_once "class.ilFormATestSessionSet.php"; */ class ilFormATestSession { - - const STATUS_FINISHED = "finished"; - const STATUS_INTERRUPTED = "interrupted"; - const STATUS_NOT_FINISHED = "not_finished"; - const STATUS_NOT_STARTED = "not_started"; - const STATUS_IN_PROGRESS = "in_progress"; - - /** - * @var int - */ - protected $obj_id; - - /** - * @var int - */ - protected $ref_id; - - /** - * @var null|int - */ - protected $session_id = null; - - /** - * @var null|int - */ - protected $active_id = null; - - /** - * @var int - */ - protected $user_id; - - /** - * @var int - */ - protected $test_id; - - /** - * @var int - */ - protected $pass; - - /** - * @var DateTime - */ - protected $start_date; - - /** - * @var DateTime - */ - protected $end_date; - - /** - * @var string - */ - protected $status; - - /** - * @var bool - */ - protected $fixate_solution; - - /** - * @var ilDB - */ - protected $db; - - /** - * @var ilFormATestSessionSet[] - */ - protected $sets; - - /** - * @var ilFormATestSessionSet - */ - protected $current_position; - - /** - * @param ilObjFormATest $test - */ - public function __construct($test) - { - global $DIC; - - $this->db = $DIC->database(); - $this->user_id = $DIC->user()->getId(); - $this->test_id = $test->getTestId(); - $this->obj_id = $test->getId(); - $this->ref_id = $test->getRefId(); - $this->fixate_solution = false; - } - - /** - * @return bool - */ - public function activeIdExists() - { - return $this->active_id != null; - } - - /** - * @return bool - */ - public function isPassFinished() - { - return $this->end_date != null; - } - - /** - * @return bool - */ - public function isSetFinished() - { - return $this->current_position->isFinished(); - } - - /** - * @return bool - */ - public function isFirstStep() - { - return $this->current_position->getStep() <= 1; - } - - /** - * @return mixed - */ - public function hasNextSet() - { - if(is_array($this->sets)) - { - $set_count = count($this->sets); - } - - return array_search($this->current_position, $this->sets) < $set_count - 1; - } - - /** - * @return bool - */ - public function isJump() - { - return $this->current_position->isJump(); - } - - public function unsetJump() - { - $this->current_position->setJump(false); - } - - - public function markSolutionToFixate() - { - $this->fixate_solution = true; - } - - /** - * @return bool - */ - public function allSetsFinished() - { - $status = true; - foreach($this->sets as $set) - { - $status = $status && $set->isFinished(); - } - - return $status; - } - - /** - * @return string - */ - public function getToken() - { - return md5("xtsf_" . $this->test_id . $this->session_id/* . $this->getNodeId()*/); - } - - /** - * Create a new test session for a user in a test - */ - public function create() - { - $this->active_id = $this->db->nextId("tst_active"); - - $this->db->insert( - "tst_active", - array( - "active_id" => array("integer", $this->active_id), - "user_fi" => array("integer", $this->user_id), - "test_fi" => array("integer", $this->test_id), - ) - ); - - $this->createNewPass(); - } - - /** - * Create a new session pass for a user in a test - */ - public function createNewPass() - { - $this->initNewPass(); - - $this->db->update( - "tst_active", - array( - "tries" => array("integer", $this->pass), - "tstamp" => array("integer", $this->start_date->getTimestamp()) - ), - array("active_id" => array("integer", $this->active_id)) - ); - - $this->db->insert( - "rep_robj_xtsf_session", - array( - "session_id" => array("integer", $this->session_id), - "active_id" => array("integer", $this->active_id), - "start_date" => array("integer", $this->start_date->getTimestamp()), - "current_pass" => array("integer", $this->pass), - "status" => array("text", self::STATUS_NOT_FINISHED) - ) - ); - } - - /** - * @param array $sets - */ - public function read($sets) - { - $result = $this->db->queryF( - "SELECT sess.* FROM tst_active tsta + const STATUS_FINISHED = "finished"; + const STATUS_INTERRUPTED = "interrupted"; + const STATUS_NOT_FINISHED = "not_finished"; + const STATUS_NOT_STARTED = "not_started"; + const STATUS_IN_PROGRESS = "in_progress"; + + /** + * @var int + */ + protected $obj_id; + + /** + * @var int + */ + protected $ref_id; + + /** + * @var null|int + */ + protected $session_id = null; + + /** + * @var null|int + */ + protected $active_id = null; + + /** + * @var int + */ + protected $user_id; + + /** + * @var int + */ + protected $test_id; + + /** + * @var int + */ + protected $pass; + + /** + * @var DateTime + */ + protected $start_date; + + /** + * @var DateTime + */ + protected $end_date; + + /** + * @var string + */ + protected $status; + + /** + * @var bool + */ + protected $fixate_solution; + + /** + * @var ilDB + */ + protected $db; + + /** + * @var ilFormATestSessionSet[] + */ + protected $sets; + + /** + * @var ilFormATestSessionSet + */ + protected $current_position; + + /** + * @param ilObjFormATest $test + */ + public function __construct($test) + { + global $DIC; + + $this->db = $DIC->database(); + $this->user_id = $DIC->user()->getId(); + $this->test_id = $test->getTestId(); + $this->obj_id = $test->getId(); + $this->ref_id = $test->getRefId(); + $this->fixate_solution = false; + } + + /** + * @return bool + */ + public function activeIdExists() + { + return $this->active_id != null; + } + + /** + * @return bool + */ + public function isPassFinished() + { + return $this->end_date != null; + } + + /** + * @return bool + */ + public function isSetFinished() + { + return $this->current_position->isFinished(); + } + + /** + * @return bool + */ + public function isFirstStep() + { + return $this->current_position->getStep() <= 1; + } + + /** + * @return mixed + */ + public function hasNextSet() + { + if (is_array($this->sets)) { + $set_count = count($this->sets); + } + + return array_search($this->current_position, $this->sets) < $set_count - 1; + } + + /** + * @return bool + */ + public function isJump() + { + return $this->current_position->isJump(); + } + + public function unsetJump() + { + $this->current_position->setJump(false); + } + + + public function markSolutionToFixate() + { + $this->fixate_solution = true; + } + + /** + * @return bool + */ + public function allSetsFinished() + { + $status = true; + foreach ($this->sets as $set) { + $status = $status && $set->isFinished(); + } + + return $status; + } + + /** + * @return string + */ + public function getToken() + { + return md5("xtsf_" . $this->test_id . $this->session_id/* . $this->getNodeId()*/); + } + + /** + * Create a new test session for a user in a test + */ + public function create() + { + $this->active_id = $this->db->nextId("tst_active"); + + $this->db->insert( + "tst_active", + array( + "active_id" => array("integer", $this->active_id), + "user_fi" => array("integer", $this->user_id), + "test_fi" => array("integer", $this->test_id), + ) + ); + + $this->createNewPass(); + } + + /** + * Create a new session pass for a user in a test + */ + public function createNewPass() + { + $this->initNewPass(); + + $this->db->update( + "tst_active", + array( + "tries" => array("integer", $this->pass), + "tstamp" => array("integer", $this->start_date->getTimestamp()) + ), + array("active_id" => array("integer", $this->active_id)) + ); + + $this->db->insert( + "rep_robj_xtsf_session", + array( + "session_id" => array("integer", $this->session_id), + "active_id" => array("integer", $this->active_id), + "start_date" => array("integer", $this->start_date->getTimestamp()), + "current_pass" => array("integer", $this->pass), + "status" => array("text", self::STATUS_NOT_FINISHED) + ) + ); + } + + /** + * @param array $sets + */ + public function read($sets) + { + $result = $this->db->queryF( + "SELECT sess.* FROM tst_active tsta INNER JOIN rep_robj_xtsf_session sess ON sess.active_id = tsta.active_id AND sess.current_pass = tsta.tries WHERE tsta.user_fi = %s AND tsta.test_fi = %s", - array("integer", "integer"), - array($this->user_id, $this->test_id) - ); - - if($result->numRows()) - { - $this->bindData($result); - } - $this->initSessionSet($sets); - } - - /** - * @return int|null - */ - public function getActiveId() - { - return $this->active_id; - } - - /** - * @return int|null - */ - public function getSessionId() - { - return $this->session_id; - } - - /** - * @return int - */ - public function getUserId() - { - return $this->user_id; - } - - /** - * Updates the current session - */ - public function update() - { - $date = null; - if($this->status == self::STATUS_FINISHED) - { - $this->end_date = new DateTime("now"); - $this->updateLP(); - $date = $this->end_date->getTimestamp(); - } - - $this->db->update( - "rep_robj_xtsf_session", - array( - "end_date" => array("integer", $date), - "status" => array("text", $this->status) - ), - array( - "session_id" => array("integer", $this->session_id) - ) - ); - } - - /** - * Does a new session step - * - * @param int $node_id - */ - public function step($node_id) - { - $this->current_position->setNodeId($node_id); - $this->current_position->save(); - } - - /** - * Initialize the current position for the session - */ - public function initCurrent() - { - foreach($this->sets as $set) - { - if($this->isCurrentSet($set) || ($set->isNotStarted() && $this->current_position->isFinished())) - { - $this->current_position = $set; - } - } - - if($this->current_position->getNodeId() == null) - { - $this->current_position->init(); - } - } - - /** - * @return int - */ - public function getNodeId() - { - return $this->current_position->getNodeId(); - } - - /** - * @return int - */ - public function getStep() - { - return $this->current_position->getStep(); - } - - /** - * @return int - */ - public function getPass() - { - return $this->pass; - } - - /** - * @param string $status - */ - public function setStatus($status) - { - $this->status = $status; - } - - /** - * @param int $node_id - * @param string $condition - * @param null|int $condition_id - */ - public function updateCondition($node_id, $condition, $condition_id = null) - { - $this->current_position->setConditionNodeId($node_id); - $this->current_position->setCondition($condition); - $this->current_position->setConditionId($condition_id); - $this->current_position->update(); - } - - /** - * @param string $status - */ - public function updateSetStatus($status) - { - $this->current_position->setStatus($status); - $this->current_position->update(); - if($this->current_position->isFinished()) - { - $this->current_position->setNodeId(NULL); - } - } - - /** - * @param int $index - */ - public function removeStepsUntil($index) - { - $this->current_position->removeUntil($index); - $this->current_position->read(); - } - - /** - * @param int $step - */ - public function removeFeedbackByStep($step) - { - $this->db->manipulateF(' + array("integer", "integer"), + array($this->user_id, $this->test_id) + ); + + if ($result->numRows()) { + $this->bindData($result); + } + $this->initSessionSet($sets); + } + + /** + * @return int|null + */ + public function getActiveId() + { + return $this->active_id; + } + + /** + * @return int|null + */ + public function getSessionId() + { + return $this->session_id; + } + + /** + * @return int + */ + public function getUserId() + { + return $this->user_id; + } + + /** + * Updates the current session + */ + public function update() + { + $date = null; + if ($this->status == self::STATUS_FINISHED) { + $this->end_date = new DateTime("now"); + $this->updateLP(); + $date = $this->end_date->getTimestamp(); + } + + $this->db->update( + "rep_robj_xtsf_session", + array( + "end_date" => array("integer", $date), + "status" => array("text", $this->status) + ), + array( + "session_id" => array("integer", $this->session_id) + ) + ); + } + + /** + * Does a new session step + * + * @param int $node_id + */ + public function step($node_id) + { + $this->current_position->setNodeId($node_id); + $this->current_position->save(); + } + + /** + * Initialize the current position for the session + */ + public function initCurrent() + { + foreach ($this->sets as $set) { + if ($this->isCurrentSet($set) || ($set->isNotStarted() && $this->current_position->isFinished())) { + $this->current_position = $set; + } + } + + if ($this->current_position->getNodeId() == null) { + $this->current_position->init(); + } + } + + /** + * @return int + */ + public function getNodeId() + { + return $this->current_position->getNodeId(); + } + + /** + * @return int + */ + public function getStep() + { + return $this->current_position->getStep(); + } + + /** + * @return int + */ + public function getPass() + { + return $this->pass; + } + + /** + * @param string $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * @param int $node_id + * @param string $condition + * @param null|int $condition_id + */ + public function updateCondition($node_id, $condition, $condition_id = null) + { + $this->current_position->setConditionNodeId($node_id); + $this->current_position->setCondition($condition); + $this->current_position->setConditionId($condition_id); + $this->current_position->update(); + } + + /** + * @param string $status + */ + public function updateSetStatus($status) + { + $this->current_position->setStatus($status); + $this->current_position->update(); + if ($this->current_position->isFinished()) { + $this->current_position->setNodeId(null); + } + } + + /** + * @param int $index + */ + public function removeStepsUntil($index) + { + $this->current_position->removeUntil($index); + $this->current_position->read(); + } + + /** + * @param int $step + */ + public function removeFeedbackByStep($step) + { + $this->db->manipulateF( + ' DELETE rep_robj_xtsf_fbt FROM rep_robj_xtsf_fbt WHERE session_id = %s AND set_id = %s AND step = %s ', - array('integer', 'integer', 'integer'), - array($this->session_id, $this->current_position->getSetId(), $step)); - } - - /** - * @param ilQuestionSetPoolNode $node - * @param ilQuestionSetPoolNode $current_node - */ - public function changePath($node, $current_node) - { - if($node->getPath()->getSet()->getId() == $current_node->getPath()->getSet()->getId()) - { - $newNode = $current_node->getPath()->getNodes()->getNodeByQuestionId($node->getQuestion()->getId()); - $newPreviousNode = $current_node->getPath()->getNodes()->getPreviousNode($newNode); - $previousNode = $node->getPath()->getNodes()->getPreviousNode($node); - - if($newPreviousNode != null && $previousNode != null) - { - $this->db->update( - "rep_robj_xtsf_tracking", - array( - "matched_condition_node_id" => array("integer", $newPreviousNode->getId()) - ), - array( - "session_fi" => array("integer", $this->session_id), - "set_fi" => array("integer", $this->getSetId()), - "node_fi" => array("integer", $previousNode->getId()) - ) - ); - } - - //Update node - $this->db->update( - "rep_robj_xtsf_tracking", - array( - "node_fi" => array("integer", $newNode->getId()) - ), - array( - "session_fi" => array("integer", $this->session_id), - "step" => array("integer", $this->getStep()), - "set_fi" => array("integer", $this->getSetId()), - ) - ); - } - } - - - /** - * Swap the current position to the delivered set - * - * @param int $set_id - */ - public function swapCurrent($set_id) - { - if($this->current_position != null && $this->current_position->getSetId() != $set_id && !$this->current_position->isFinished()) - { - $this->current_position->setStatus(self::STATUS_INTERRUPTED); - $this->current_position->update(); - } - - foreach($this->sets as $set) - { - if($set->getSetId() == $set_id) - { - $this->current_position = $set; - if($this->current_position->getNodeId() == null) - { - $this->current_position->init(); - $this->step($this->getNodeId()); - } - else - { - $this->updateSetStatus(self::STATUS_IN_PROGRESS); - } - } - } - - } - - /** - * @param null|int $set_id - * - * @return string - */ - public function getSetStatus($set_id = null) - { - if($set_id == null) - { - return $this->current_position->getStatus(); - } - else - { - foreach($this->sets as $set) - { - if($set->getSetId() == $set_id) - { - return $set->getStatus(); - } - } - } - - return self::STATUS_NOT_STARTED; - } - - /** - * @return int - */ - public function getSetId() - { - return $this->current_position->getSetId(); - } - - /** - * @param ilQuestionSetPoolNode $node - * - * @return array - */ - public function getStepsToDelete($node) - { - $result = $this->db->queryF( - "SELECT DISTINCT track.step, node.*, qst.title, qs_qst.question_index FROM rep_robj_xqsp_node node + array('integer', 'integer', 'integer'), + array($this->session_id, $this->current_position->getSetId(), $step) + ); + } + + /** + * @param ilQuestionSetPoolNode $node + * @param ilQuestionSetPoolNode $current_node + */ + public function changePath($node, $current_node) + { + if ($node->getPath()->getSet()->getId() == $current_node->getPath()->getSet()->getId()) { + $newNode = $current_node->getPath()->getNodes()->getNodeByQuestionId($node->getQuestion()->getId()); + $newPreviousNode = $current_node->getPath()->getNodes()->getPreviousNode($newNode); + $previousNode = $node->getPath()->getNodes()->getPreviousNode($node); + + if ($newPreviousNode != null && $previousNode != null) { + $this->db->update( + "rep_robj_xtsf_tracking", + array( + "matched_condition_node_id" => array("integer", $newPreviousNode->getId()) + ), + array( + "session_fi" => array("integer", $this->session_id), + "set_fi" => array("integer", $this->getSetId()), + "node_fi" => array("integer", $previousNode->getId()) + ) + ); + } + + //Update node + $this->db->update( + "rep_robj_xtsf_tracking", + array( + "node_fi" => array("integer", $newNode->getId()) + ), + array( + "session_fi" => array("integer", $this->session_id), + "step" => array("integer", $this->getStep()), + "set_fi" => array("integer", $this->getSetId()), + ) + ); + } + } + + + /** + * Swap the current position to the delivered set + * + * @param int $set_id + */ + public function swapCurrent($set_id) + { + if ($this->current_position != null && $this->current_position->getSetId() != $set_id && !$this->current_position->isFinished()) { + $this->current_position->setStatus(self::STATUS_INTERRUPTED); + $this->current_position->update(); + } + + foreach ($this->sets as $set) { + if ($set->getSetId() == $set_id) { + $this->current_position = $set; + if ($this->current_position->getNodeId() == null) { + $this->current_position->init(); + $this->step($this->getNodeId()); + } else { + $this->updateSetStatus(self::STATUS_IN_PROGRESS); + } + } + } + } + + /** + * @param null|int $set_id + * + * @return string + */ + public function getSetStatus($set_id = null) + { + if ($set_id == null) { + return $this->current_position->getStatus(); + } else { + foreach ($this->sets as $set) { + if ($set->getSetId() == $set_id) { + return $set->getStatus(); + } + } + } + + return self::STATUS_NOT_STARTED; + } + + /** + * @return int + */ + public function getSetId() + { + return $this->current_position->getSetId(); + } + + /** + * @param ilQuestionSetPoolNode $node + * + * @return array + */ + public function getStepsToDelete($node) + { + $result = $this->db->queryF( + "SELECT DISTINCT track.step, node.*, qst.title, qs_qst.question_index FROM rep_robj_xqsp_node node INNER JOIN rep_robj_xtsf_tracking track ON track.node_fi = node.id INNER JOIN qpl_questions qst ON qst.question_id = node.question_fi INNER JOIN rep_robj_xtsf_session sess ON sess.session_id = track.session_fi @@ -542,178 +521,171 @@ class ilFormATestSession WHERE track2.node_fi = %s AND track2.session_fi = %s ) AND track.set_fi = %s AND track.session_fi = %s ORDER BY track.step", - array("integer", "integer", "integer", "integer"), - array($node->getId(), $this->getSessionId(), $node->getPath()->getSet()->getId(), $this->getSessionId()) - ); - - $data = array(); - while($row = $this->db->fetchAssoc($result)) - { - $data[] = $row; - } - - return $data; - } - - /** - * @param ilQuestionSetPoolNode $node - * - * @return bool - */ - public function stepHasSolution($node) - { - $result = $node->getQuestion()->getUserQuestionResult($this->active_id, $this->pass); -if(is_array($result->getSolutions())) - return count($result->getSolutions()) > 0; - } - - /** - * @param ilQuestionSetPoolNode $node - * - * @return bool - */ - public function hasStepsToDelete($node) - { - if(is_array($this->getStepsToDelete($node))) - return count($this->getStepsToDelete($node)) > 0; - } - - /** - * Increments the pass counter - */ - protected function setPassCounter() - { - if($this->pass == null) - { - $this->pass = 0; - } - else - { - $this->pass++; - } - } - - /** - * @param ilFormATestSessionSet $session_set - * - * @return bool - */ - protected function isCurrentSet($session_set) - { - return - $this->current_position == null || - (($session_set->isCurrent() || $session_set->isFinished()) && !$this->current_position->isCurrent()) /*|| - ($session_set->isNotStarted() && $this->current_position->isFinished())*/ - ; - } - - /** - * Initialize a new Pass. Sets default data - */ - protected function initNewPass() - { - $this->session_id = $this->db->nextId("rep_robj_xtsf_session"); - $this->start_date = new DateTime("now"); - $this->end_date = null; - $this->current_position = null; - $this->setPassCounter(); - - foreach($this->sets as $key => $set) - { - $session_set = new ilFormATestSessionSet($set->getSetId()); - $session_set->setSessionId($this->session_id); - $session_set->setStatus(self::STATUS_NOT_STARTED); - $session_set->create(); - $this->sets[$key] = $session_set; - } - } - - /** - * @param array $sets - */ - protected function initSessionSet($sets) - { - foreach($sets as $set) - { - $session_set = new ilFormATestSessionSet($set["id"]); - $session_set->setSessionId($this->session_id); - $session_set->read(); - $this->sets[] = $session_set; - - if($this->isCurrentSet($session_set)) - { - $this->current_position = $session_set; - } - } - } - - /** - * @param object $result - */ - protected function bindData($result) - { - $row = $this->db->fetchAssoc($result); - $this->session_id = $row["session_id"]; - $this->active_id = $row["active_id"]; - $this->pass = $row["current_pass"]; - $this->start_date = $row["start_date"]; - $this->end_date = $row["end_date"]; - $this->status = $row["status"]; - } - - - /** - * @return bool - */ - public function reachedDeadlock() - { - if($this->isJump()) - { - return $this->current_position->isDeadlock(); - } - - return false; - } - - /** - * @return bool - */ - public function isDeadlockPossible() - { - return $this->current_position->isDeadlockPossible(); - } - - /** - * Saved the history of the test to track all steps and results - */ - public function saveHistory() - { - $this->db->queryF( - "INSERT INTO rep_robj_xtsf_trck_his (session_fi, step, node_fi, set_fi, matched_condition_node_id, matched_condition, matched_condition_id) + array("integer", "integer", "integer", "integer"), + array($node->getId(), $this->getSessionId(), $node->getPath()->getSet()->getId(), $this->getSessionId()) + ); + + $data = array(); + while ($row = $this->db->fetchAssoc($result)) { + $data[] = $row; + } + + return $data; + } + + /** + * @param ilQuestionSetPoolNode $node + * + * @return bool + */ + public function stepHasSolution($node) + { + $result = $node->getQuestion()->getUserQuestionResult($this->active_id, $this->pass); + if (is_array($result->getSolutions())) { + return count($result->getSolutions()) > 0; + } + } + + /** + * @param ilQuestionSetPoolNode $node + * + * @return bool + */ + public function hasStepsToDelete($node) + { + if (is_array($this->getStepsToDelete($node))) { + return count($this->getStepsToDelete($node)) > 0; + } + } + + /** + * Increments the pass counter + */ + protected function setPassCounter() + { + if ($this->pass == null) { + $this->pass = 0; + } else { + $this->pass++; + } + } + + /** + * @param ilFormATestSessionSet $session_set + * + * @return bool + */ + protected function isCurrentSet($session_set) + { + return + $this->current_position == null || + (($session_set->isCurrent() || $session_set->isFinished()) && !$this->current_position->isCurrent()) /*|| + ($session_set->isNotStarted() && $this->current_position->isFinished())*/ + ; + } + + /** + * Initialize a new Pass. Sets default data + */ + protected function initNewPass() + { + $this->session_id = $this->db->nextId("rep_robj_xtsf_session"); + $this->start_date = new DateTime("now"); + $this->end_date = null; + $this->current_position = null; + $this->setPassCounter(); + + foreach ($this->sets as $key => $set) { + $session_set = new ilFormATestSessionSet($set->getSetId()); + $session_set->setSessionId($this->session_id); + $session_set->setStatus(self::STATUS_NOT_STARTED); + $session_set->create(); + $this->sets[$key] = $session_set; + } + } + + /** + * @param array $sets + */ + protected function initSessionSet($sets) + { + foreach ($sets as $set) { + $session_set = new ilFormATestSessionSet($set["id"]); + $session_set->setSessionId($this->session_id); + $session_set->read(); + $this->sets[] = $session_set; + + if ($this->isCurrentSet($session_set)) { + $this->current_position = $session_set; + } + } + } + + /** + * @param object $result + */ + protected function bindData($result) + { + $row = $this->db->fetchAssoc($result); + $this->session_id = $row["session_id"]; + $this->active_id = $row["active_id"]; + $this->pass = $row["current_pass"]; + $this->start_date = $row["start_date"]; + $this->end_date = $row["end_date"]; + $this->status = $row["status"]; + } + + + /** + * @return bool + */ + public function reachedDeadlock() + { + if ($this->isJump()) { + return $this->current_position->isDeadlock(); + } + + return false; + } + + /** + * @return bool + */ + public function isDeadlockPossible() + { + return $this->current_position->isDeadlockPossible(); + } + + /** + * Saved the history of the test to track all steps and results + */ + public function saveHistory() + { + $this->db->queryF( + "INSERT INTO rep_robj_xtsf_trck_his (session_fi, step, node_fi, set_fi, matched_condition_node_id, matched_condition, matched_condition_id) SELECT trck.session_fi, ( SELECT (CASE WHEN MAX(trck2.step) IS NULL THEN 1 ELSE MAX(trck2.step)+1 END) step FROM rep_robj_xtsf_trck_his trck2 WHERE trck2.session_fi = %s AND trck2.set_fi = %s ), trck.node_fi, trck.set_fi, trck.matched_condition_node_id, trck.matched_condition, trck.matched_condition_id FROM rep_robj_xtsf_tracking trck WHERE trck.session_fi = %s AND trck.step = %s AND trck.set_fi = %s", - array("integer","integer","integer","integer","integer"), - array($this->getSessionId(),$this->getSetId(),$this->getSessionId(),$this->getStep(),$this->getSetId()) - ); - - if($this->fixate_solution) - { - $this->db->queryF( - "UPDATE rep_robj_xtsf_solut solut + array("integer","integer","integer","integer","integer"), + array($this->getSessionId(),$this->getSetId(),$this->getSessionId(),$this->getStep(),$this->getSetId()) + ); + + if ($this->fixate_solution) { + $this->db->queryF( + "UPDATE rep_robj_xtsf_solut solut INNER JOIN rep_robj_xqsp_node node ON node.question_fi = solut.question_fi SET fixated = %s WHERE active_fi = %s AND pass = %s AND node.id = %s", - array("integer","integer", "integer", "integer"), - array(0, $this->getActiveId(), $this->getPass(), $this->getNodeId()) - ); - } + array("integer","integer", "integer", "integer"), + array(0, $this->getActiveId(), $this->getPass(), $this->getNodeId()) + ); + } - $this->db->queryF( - "INSERT INTO rep_robj_xtsf_solut (solution_id, active_fi, question_fi, points, pass, tstamp, value1, value2, step, fixated) + $this->db->queryF( + "INSERT INTO rep_robj_xtsf_solut (solution_id, active_fi, question_fi, points, pass, tstamp, value1, value2, step, fixated) SELECT tst_solutions.solution_id, tst_solutions.active_fi, tst_solutions.question_fi, tst_solutions.points, tst_solutions.pass, tst_solutions.tstamp, tst_solutions.value1, tst_solutions.value2, ( SELECT MAX(trck2.step) FROM rep_robj_xtsf_trck_his trck2 WHERE trck2.set_fi = %s AND trck2.node_fi = %s AND trck2.session_fi = %s @@ -721,195 +693,181 @@ if(is_array($result->getSolutions())) FROM tst_solutions INNER JOIN rep_robj_xqsp_node node ON node.question_fi = tst_solutions.question_fi WHERE tst_solutions.active_fi = %s AND tst_solutions.pass = %s AND tst_solutions.step = %s AND node.id = %s", - array("integer","integer","integer","integer","integer","integer","integer","integer"), - array( - $this->getSetId(), - $this->getNodeId(), - $this->getSessionId(), - $this->fixate_solution, - $this->getActiveId(), - $this->getPass(), - $this->getStep(), - $this->getNodeId() - ) - ); - } - - /** - * @param null|int $node_id - * - * @return bool - */ - public function hasFixatedSolution($node_id = null) - { - return $this->current_position->hasFixatedSolution($node_id); - } - - public function handleDeadlock() - { - $this->db->queryF( - "INSERT INTO tst_solutions (solution_id, active_fi, question_fi, points, pass, tstamp, value1, value2, step) + array("integer","integer","integer","integer","integer","integer","integer","integer"), + array( + $this->getSetId(), + $this->getNodeId(), + $this->getSessionId(), + $this->fixate_solution, + $this->getActiveId(), + $this->getPass(), + $this->getStep(), + $this->getNodeId() + ) + ); + } + + /** + * @param null|int $node_id + * + * @return bool + */ + public function hasFixatedSolution($node_id = null) + { + return $this->current_position->hasFixatedSolution($node_id); + } + + public function handleDeadlock() + { + $this->db->queryF( + "INSERT INTO tst_solutions (solution_id, active_fi, question_fi, points, pass, tstamp, value1, value2, step) SELECT rep_robj_xtsf_solut.solution_id, rep_robj_xtsf_solut.active_fi, rep_robj_xtsf_solut.question_fi, rep_robj_xtsf_solut.points, rep_robj_xtsf_solut.pass, rep_robj_xtsf_solut.tstamp, rep_robj_xtsf_solut.value1, rep_robj_xtsf_solut.value2,%s FROM rep_robj_xtsf_solut INNER JOIN rep_robj_xqsp_node node ON node.question_fi = rep_robj_xtsf_solut.question_fi WHERE rep_robj_xtsf_solut.active_fi = %s AND rep_robj_xtsf_solut.pass = %s AND rep_robj_xtsf_solut.fixated = %s AND node.id = %s", - array("integer","integer","integer","integer","integer"), - array( - $this->getStep(), - $this->getActiveId(), - $this->getPass(), - 1, - $this->getNodeId() - ) - ); - } - - /** - * @param int $node_id - */ - public function updateTrackNodeId($node_id) - { - $this->current_position->updateTrackNodeId($node_id); - } - - /** - * @param int $active_id - * - * @return int - */ - public static function getUserIdByActiveId($active_id) - { - global $DIC; - $ilDB = $DIC->database(); - - $result = $ilDB->queryF( - "SELECT user_fi FROM tst_active WHERE active_id = %s", - array("integer"), - array($active_id) - ); - $row = $ilDB->fetchAssoc($result); - - return $row["user_fi"]; - } - - /** - * @param int $session_id - * - * @return int - */ - public static function getUserIdBySessionId($session_id) - { - global $DIC; - $ilDB = $DIC->database(); - -// $ilDB->setLimit(1, 0); - $result = $ilDB->queryF( - "SELECT user_fi FROM tst_active + array("integer","integer","integer","integer","integer"), + array( + $this->getStep(), + $this->getActiveId(), + $this->getPass(), + 1, + $this->getNodeId() + ) + ); + } + + /** + * @param int $node_id + */ + public function updateTrackNodeId($node_id) + { + $this->current_position->updateTrackNodeId($node_id); + } + + /** + * @param int $active_id + * + * @return int + */ + public static function getUserIdByActiveId($active_id) + { + global $DIC; + $ilDB = $DIC->database(); + + $result = $ilDB->queryF( + "SELECT user_fi FROM tst_active WHERE active_id = %s", + array("integer"), + array($active_id) + ); + $row = $ilDB->fetchAssoc($result); + + return $row["user_fi"]; + } + + /** + * @param int $session_id + * + * @return int + */ + public static function getUserIdBySessionId($session_id) + { + global $DIC; + $ilDB = $DIC->database(); + + // $ilDB->setLimit(1, 0); + $result = $ilDB->queryF( + "SELECT user_fi FROM tst_active INNER JOIN rep_robj_xtsf_session ON rep_robj_xtsf_session.active_id = tst_active.active_id WHERE rep_robj_xtsf_session.session_id = %s", - array("integer"), - array($session_id) - ); - $row = $ilDB->fetchAssoc($result); - - return $row["user_fi"]; - } - - /** - * @param int $session_id - * - * @return int - */ - public static function getActiveIdBySessionId($session_id) - { - global $DIC; - $ilDB = $DIC->database(); - -// $ilDB->setLimit(1, 0); - $result = $ilDB->queryF( - "SELECT active_id FROM rep_robj_xtsf_session WHERE session_id = %s", - array("integer"), - array($session_id) - ); - $row = $ilDB->fetchAssoc($result); - - return $row["active_id"]; - } - - /** - * @param $session_id - * - * @return mixed - */ - public static function getPassBySessionId($session_id) - { - global $DIC; - $ilDB = $DIC->database(); - -// $ilDB->setLimit(1, 0); - $result = $ilDB->queryF( - "SELECT current_pass FROM rep_robj_xtsf_session WHERE session_id = %s", - array("integer"), - array($session_id) - ); - $row = $ilDB->fetchAssoc($result); - - return $row["active_id"]; - } - - /** - * @param int $active_id - * @param int $pass - * - * @return int - */ - public static function getSessionIdByActiveIdAndPass($active_id, $pass) - { - global $DIC; - $ilDB = $DIC->database(); - - $result = $ilDB->queryF( - "SELECT session_id FROM rep_robj_xtsf_session WHERE active_id = %s and current_pass = %s", - array("integer", "integer"), - array($active_id, $pass) - ); - - $row = $ilDB->fetchAssoc($result); - - return $row["session_id"]; - } - - public function updateLP() - { - require_once "./Modules/Test/classes/class.ilObjTestAccess.php"; - require_once "./Services/Tracking/classes/status/class.ilLPStatusEvent.php"; - require_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php"; - require_once "./Services/Tracking/classes/class.ilLearningProgress.php"; - - ilLPStatusWrapper::_updateStatus( - $this->obj_id, - $this->user_id - ); - } - - public function trackProgress() - { - require_once "./Modules/Test/classes/class.ilObjTestAccess.php"; - require_once "./Services/Tracking/classes/class.ilChangeEvent.php"; - require_once "./Services/Tracking/classes/status/class.ilLPStatusEvent.php"; - require_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php"; - require_once "./Services/Tracking/classes/class.ilLearningProgress.php"; - - ilLearningProgress::_tracProgress( - $this->user_id, - $this->obj_id, - $this->ref_id, - 'xtsf' - ); - } - - - -} \ No newline at end of file + array("integer"), + array($session_id) + ); + $row = $ilDB->fetchAssoc($result); + + return $row["user_fi"]; + } + + /** + * @param int $session_id + * + * @return int + */ + public static function getActiveIdBySessionId($session_id) + { + global $DIC; + $ilDB = $DIC->database(); + + // $ilDB->setLimit(1, 0); + $result = $ilDB->queryF( + "SELECT active_id FROM rep_robj_xtsf_session WHERE session_id = %s", + array("integer"), + array($session_id) + ); + $row = $ilDB->fetchAssoc($result); + + return $row["active_id"]; + } + + /** + * @param $session_id + * + * @return mixed + */ + public static function getPassBySessionId($session_id) + { + global $DIC; + $ilDB = $DIC->database(); + + // $ilDB->setLimit(1, 0); + $result = $ilDB->queryF( + "SELECT current_pass FROM rep_robj_xtsf_session WHERE session_id = %s", + array("integer"), + array($session_id) + ); + $row = $ilDB->fetchAssoc($result); + + return $row["active_id"]; + } + + /** + * @param int $active_id + * @param int $pass + * + * @return int + */ + public static function getSessionIdByActiveIdAndPass($active_id, $pass) + { + global $DIC; + $ilDB = $DIC->database(); + + $result = $ilDB->queryF( + "SELECT session_id FROM rep_robj_xtsf_session WHERE active_id = %s and current_pass = %s", + array("integer", "integer"), + array($active_id, $pass) + ); + + $row = $ilDB->fetchAssoc($result); + + return $row["session_id"]; + } + + public function updateLP() + { + ilLPStatusWrapper::_updateStatus( + $this->obj_id, + $this->user_id + ); + } + + public function trackProgress() + { + ilLearningProgress::_tracProgress( + $this->user_id, + $this->obj_id, + $this->ref_id, + 'xtsf' + ); + } +} diff --git a/classes/models/class.ilFormATestSessionSet.php b/classes/models/class.ilFormATestSessionSet.php index 7e0a19312adb3ff6b3b876a8bebf6bcd51129f72..f3364367d466b78275ccd5fb8260d063c4eebf4a 100644 --- a/classes/models/class.ilFormATestSessionSet.php +++ b/classes/models/class.ilFormATestSessionSet.php @@ -8,384 +8,380 @@ require_once "class.ilFormATestSession.php"; * Date: 25.02.14 * Time: 09:02 * @author Thomas Joußen - */ + */ class ilFormATestSessionSet { - /** - * @var int - */ - protected $set_id; - - /** - * @var int - */ - protected $node_id; - - /** - * @var int - */ - protected $step; - - /** - * @var int - */ - protected $condition_id; - - /** - * @var string - */ - protected $condition; - - /** - * @var int - */ - protected $condition_node_id; - - /** - * @var bool - */ - protected $jump; - - /** - * @var string - */ - protected $status; - - /** - * @var int - */ - protected $session_id; - - /** - * @var ilDB - */ - protected $db; - - /** - * @param int $set_id - */ - public function __construct($set_id) - { - global $DIC; - $ilDB = $DIC->database(); - - $this->set_id = $set_id; - $this->db = $ilDB; - $this->step = 0; - } - - /** - * @return int - */ - public function getStep() - { - return $this->step; - } - - /** - * @return bool - */ - public function isJump() - { - return $this->jump; - } - - /** - * @param bool $is_jump - */ - public function setJump($is_jump) - { - $this->jump = $is_jump; - } - - /** - * @return bool - */ - public function isFinished() - { - return $this->status == ilFormATestSession::STATUS_FINISHED; - } - - /** - * @return bool - */ - public function isCurrent() - { - return $this->status == ilFormATestSession::STATUS_IN_PROGRESS; - } - - /** - * @return bool - */ - public function isNotStarted() - { - return $this->status == ilFormATestSession::STATUS_NOT_STARTED; - } - - /** - * - */ - public function read() - { - $result = $this->db->queryF( - "SELECT * FROM rep_robj_xtsf_set_trck trck + /** + * @var int + */ + protected $set_id; + + /** + * @var int + */ + protected $node_id; + + /** + * @var int + */ + protected $step; + + /** + * @var int + */ + protected $condition_id; + + /** + * @var string + */ + protected $condition; + + /** + * @var int + */ + protected $condition_node_id; + + /** + * @var bool + */ + protected $jump; + + /** + * @var string + */ + protected $status; + + /** + * @var int + */ + protected $session_id; + + /** + * @var ilDB + */ + protected $db; + + /** + * @param int $set_id + */ + public function __construct($set_id) + { + global $DIC; + $ilDB = $DIC->database(); + + $this->set_id = $set_id; + $this->db = $ilDB; + $this->step = 0; + } + + /** + * @return int + */ + public function getStep() + { + return $this->step; + } + + /** + * @return bool + */ + public function isJump() + { + return $this->jump; + } + + /** + * @param bool $is_jump + */ + public function setJump($is_jump) + { + $this->jump = $is_jump; + } + + /** + * @return bool + */ + public function isFinished() + { + return $this->status == ilFormATestSession::STATUS_FINISHED; + } + + /** + * @return bool + */ + public function isCurrent() + { + return $this->status == ilFormATestSession::STATUS_IN_PROGRESS; + } + + /** + * @return bool + */ + public function isNotStarted() + { + return $this->status == ilFormATestSession::STATUS_NOT_STARTED; + } + + /** + * + */ + public function read() + { + $result = $this->db->queryF( + "SELECT * FROM rep_robj_xtsf_set_trck trck LEFT JOIN rep_robj_xtsf_tracking tracking ON trck.session_fi = tracking.session_fi AND trck.set_fi = tracking.set_fi AND tracking.step = ( SELECT MAX(step) FROM rep_robj_xtsf_tracking WHERE set_fi = %s AND session_fi = %s ) WHERE trck.set_fi = %s AND trck.session_fi = %s ", - array("integer", "integer", "integer", "integer"), - array($this->set_id, $this->session_id, $this->set_id, $this->session_id) - ); - - if($result->numRows()) - { - $row = $this->db->fetchAssoc($result); - $this->step = $row["step"]; - $this->node_id = $row["node_fi"]; - $this->condition = $row["matched_condition"]; - $this->condition_id = $row["matched_condition_id"]; - $this->condition_node_id = $row["matched_condition_node_id"]; - $this->status = $row["status"]; - } - else - { - $this->step = 0; - $this->node_id = null; - $this->condition = null; - $this->condition_id = null; - $this->condition_node_id = null; - $this->status = null; - } - } - - /** - * @param int $node_id - */ - public function setNodeId($node_id) - { - $this->node_id = $node_id; - } - - /** - * @return int - */ - public function getNodeId() - { - return $this->node_id; - } - - /** - * @param int $session_id - */ - public function setSessionId($session_id) - { - $this->session_id = $session_id; - } - - /** - * @return int - */ - public function getSetId() - { - return $this->set_id; - } - - /** - * @TODO Refactor: Rename to step() - */ - public function save() - { - $this->step = $this->getStepByNodeId($this->node_id); - - $this->db->insert( - "rep_robj_xtsf_tracking", - array( - "session_fi" => array("integer", $this->session_id), - "step" => array("integer", $this->step), - "node_fi" => array("integer", $this->node_id), - "set_fi" => array("integer", $this->set_id) - ) - ); - } - - /** - * @param int $node_id - */ - public function getStepByNodeId($node_id) - { - global $DIC; - $ilDB = $DIC->database(); - - $res = $ilDB->queryF('SELECT node_index FROM rep_robj_xqsp_node WHERE id = %s', - array('integer'), array($node_id)); - - $step_index = 0; - while($row = $ilDB->fetchAssoc($res)) - { - $step_index = $row['node_index']; - } - - return (int)$step_index; - } - - /** - * Initialize the first node of the set - */ - public function init() - { - $this->db->setLimit(1, 0); - - $result = $this->db->queryF( - "SELECT node.id FROM rep_robj_xqsp_node node + array("integer", "integer", "integer", "integer"), + array($this->set_id, $this->session_id, $this->set_id, $this->session_id) + ); + + if ($result->numRows()) { + $row = $this->db->fetchAssoc($result); + $this->step = $row["step"]; + $this->node_id = $row["node_fi"]; + $this->condition = $row["matched_condition"]; + $this->condition_id = $row["matched_condition_id"]; + $this->condition_node_id = $row["matched_condition_node_id"]; + $this->status = $row["status"]; + } else { + $this->step = 0; + $this->node_id = null; + $this->condition = null; + $this->condition_id = null; + $this->condition_node_id = null; + $this->status = null; + } + } + + /** + * @param int $node_id + */ + public function setNodeId($node_id) + { + $this->node_id = $node_id; + } + + /** + * @return int + */ + public function getNodeId() + { + return $this->node_id; + } + + /** + * @param int $session_id + */ + public function setSessionId($session_id) + { + $this->session_id = $session_id; + } + + /** + * @return int + */ + public function getSetId() + { + return $this->set_id; + } + + /** + * @TODO Refactor: Rename to step() + */ + public function save() + { + $this->step = $this->getStepByNodeId($this->node_id); + + $this->db->insert( + "rep_robj_xtsf_tracking", + array( + "session_fi" => array("integer", $this->session_id), + "step" => array("integer", $this->step), + "node_fi" => array("integer", $this->node_id), + "set_fi" => array("integer", $this->set_id) + ) + ); + } + + /** + * @param int $node_id + */ + public function getStepByNodeId($node_id) + { + global $DIC; + $ilDB = $DIC->database(); + + $res = $ilDB->queryF( + 'SELECT node_index FROM rep_robj_xqsp_node WHERE id = %s', + array('integer'), + array($node_id) + ); + + $step_index = 0; + while ($row = $ilDB->fetchAssoc($res)) { + $step_index = $row['node_index']; + } + + return (int) $step_index; + } + + /** + * Initialize the first node of the set + */ + public function init() + { + $this->db->setLimit(1, 0); + + $result = $this->db->queryF( + "SELECT node.id FROM rep_robj_xqsp_node node INNER JOIN rep_robj_xqsp_path path ON path.id = node.path_fi WHERE path.questionset_fi = %s AND node.node_index = %s ORDER BY path.path_index", - array("integer", "integer"), - array($this->set_id, 1) - ); - - $data = $this->db->fetchAssoc($result); - $this->node_id = $data["id"]; - - $this->status = ilFormATestSession::STATUS_IN_PROGRESS; - $this->update(); - } - - /** - * @param string $condition - */ - public function setCondition($condition) - { - $this->condition = $condition; - } - - /** - * @param int $condition_id - */ - public function setConditionId($condition_id) - { - $this->condition_id = $condition_id; - if($condition_id != null) - { - $this->jump = true; - } - } - - /** - * @param int $condition_node_id - */ - public function setConditionNodeId($condition_node_id) - { - $this->condition_node_id = $condition_node_id; - } - - /** - * @param string $status - */ - public function setStatus($status) - { - $this->status = $status; - } - - /** - * @return string - */ - public function getStatus() - { - return $this->status; - } - - public function create() - { - $this->db->insert( - "rep_robj_xtsf_set_trck", - array( - "status" => array("text", $this->status), - "session_fi" => array("integer", $this->session_id), - "set_fi" => array("integer", $this->set_id) - ) - ); - } - - public function update() - { - $this->db->update( - "rep_robj_xtsf_set_trck", - array( - "status" => array("text", $this->status) - ), - array( - "session_fi" => array("integer", $this->session_id), - "set_fi" => array("integer", $this->set_id) - ) - ); - - $this->db->update( - "rep_robj_xtsf_tracking", - array( - "matched_condition" => array("text", $this->condition), - "matched_condition_id" => array("integer", $this->condition_id), - "matched_condition_node_id" => array("integer", $this->condition_node_id) - ), - array( - "session_fi" => array("integer", $this->session_id), - "set_fi" => array("integer", $this->set_id), - "step" => array("integer", $this->step) - ) - ); - } - - /** - * @param int $index - */ - public function removeUntil($index) - { - $steps = $this->getStepsByIndex($index); - foreach($steps as $step) - { - $this->removeTstSolutionsByStep($step); - $this->removeTstTestResultByStep($step); - $this->removeTrackingByStep($step); - $this->removeFeedbackByStep($step); - } - $this->read(); - } - - /** - * @param null|int $node_id - * - * @return bool - */ - public function hasFixatedSolution($node_id = null) - { - if($node_id == null) - { - $node_id = $this->node_id; - } - - $result = $this->db->queryF( - "SELECT COUNT(solution_id) num FROM rep_robj_xtsf_solut sol + array("integer", "integer"), + array($this->set_id, 1) + ); + + $data = $this->db->fetchAssoc($result); + $this->node_id = $data["id"]; + + $this->status = ilFormATestSession::STATUS_IN_PROGRESS; + $this->update(); + } + + /** + * @param string $condition + */ + public function setCondition($condition) + { + $this->condition = $condition; + } + + /** + * @param int $condition_id + */ + public function setConditionId($condition_id) + { + $this->condition_id = $condition_id; + if ($condition_id != null) { + $this->jump = true; + } + } + + /** + * @param int $condition_node_id + */ + public function setConditionNodeId($condition_node_id) + { + $this->condition_node_id = $condition_node_id; + } + + /** + * @param string $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + public function create() + { + $this->db->insert( + "rep_robj_xtsf_set_trck", + array( + "status" => array("text", $this->status), + "session_fi" => array("integer", $this->session_id), + "set_fi" => array("integer", $this->set_id) + ) + ); + } + + public function update() + { + $this->db->update( + "rep_robj_xtsf_set_trck", + array( + "status" => array("text", $this->status) + ), + array( + "session_fi" => array("integer", $this->session_id), + "set_fi" => array("integer", $this->set_id) + ) + ); + + $this->db->update( + "rep_robj_xtsf_tracking", + array( + "matched_condition" => array("text", $this->condition), + "matched_condition_id" => array("integer", $this->condition_id), + "matched_condition_node_id" => array("integer", $this->condition_node_id) + ), + array( + "session_fi" => array("integer", $this->session_id), + "set_fi" => array("integer", $this->set_id), + "step" => array("integer", $this->step) + ) + ); + } + + /** + * @param int $index + */ + public function removeUntil($index) + { + $steps = $this->getStepsByIndex($index); + foreach ($steps as $step) { + $this->removeTstSolutionsByStep($step); + $this->removeTstTestResultByStep($step); + $this->removeTrackingByStep($step); + $this->removeFeedbackByStep($step); + } + $this->read(); + } + + /** + * @param null|int $node_id + * + * @return bool + */ + public function hasFixatedSolution($node_id = null) + { + if ($node_id == null) { + $node_id = $this->node_id; + } + + $result = $this->db->queryF( + "SELECT COUNT(solution_id) num FROM rep_robj_xtsf_solut sol INNER JOIN rep_robj_xqsp_node node ON node.question_fi = sol.question_fi INNER JOIN rep_robj_xtsf_session sess ON sess.active_id = sol.active_fi AND sess.current_pass = sol.pass WHERE sess.session_id = %s AND node.id = %s AND sol.fixated = %s", - array("integer", "integer", "integer"), - array($this->session_id, $node_id, 1) - ); - - $row = $this->db->fetchAssoc($result); - return $row["num"] > 0; - } - - /** - * @return bool - */ - public function isDeadlockPossible() - { - $this->db->setLimit(1); - - $result = $this->db->queryF( - "SELECT COUNT(his.matched_condition_id) >= con.repititions possible + array("integer", "integer", "integer"), + array($this->session_id, $node_id, 1) + ); + + $row = $this->db->fetchAssoc($result); + return $row["num"] > 0; + } + + /** + * @return bool + */ + public function isDeadlockPossible() + { + $this->db->setLimit(1); + + $result = $this->db->queryF( + "SELECT COUNT(his.matched_condition_id) >= con.repititions possible FROM rep_robj_xqsp_jmp_con con LEFT JOIN rep_robj_xtsf_trck_his his ON con.id = his.matched_condition_id AND his.session_fi = %s INNER JOIN rep_robj_xqsp_node node ON node.id = con.node_fi @@ -395,24 +391,24 @@ class ilFormATestSessionSet WHERE node2.id = %s ) GROUP BY con.id, con.repititions ORDER BY possible DESC ", - array("integer", "integer"), - array($this->session_id, $this->node_id) - ); + array("integer", "integer"), + array($this->session_id, $this->node_id) + ); - $row = $this->db->fetchAssoc($result); + $row = $this->db->fetchAssoc($result); - return $row != null && $row["possible"] > 0; - } + return $row != null && $row["possible"] > 0; + } - /** - * @return bool - */ - public function isDeadlock() - { - $this->db->setLimit(1); + /** + * @return bool + */ + public function isDeadlock() + { + $this->db->setLimit(1); - $result = $this->db->queryF( - "SELECT COUNT(his.matched_condition_id) >= con.repititions possible + $result = $this->db->queryF( + "SELECT COUNT(his.matched_condition_id) >= con.repititions possible FROM rep_robj_xqsp_jmp_con con LEFT JOIN rep_robj_xtsf_trck_his his ON con.id = his.matched_condition_id AND his.session_fi = %s INNER JOIN rep_robj_xqsp_node node ON node.id = con.node_fi @@ -422,116 +418,113 @@ class ilFormATestSessionSet WHERE node2.id = %s ) AND con.id = %s GROUP BY con.id, con.repititions ORDER BY possible DESC ", - array("integer", "integer", "integer"), - array($this->session_id, $this->node_id, $this->condition_id) - ); - - $row = $this->db->fetchAssoc($result); - - return $row != null && $row["possible"] > 0; - } - - /** - * @param int $node_id - */ - public function updateTrackNodeId($node_id) - { - $this->db->update( - "rep_robj_xtsf_tracking", - array( - "node_fi" => array("integer", $node_id) - ), - array( - "session_fi" => array("integer", $this->session_id), - "step" => array("integer", $this->step), - "set_fi" => array("integer", $this->set_id), - "node_fi" => array("integer", $this->node_id) - ) - ); - } - - /** - * @param int $index - * - * @return array - */ - protected function getStepsByIndex($index) - { - $result = $this->db->queryF( - "SELECT step, node.node_index n_index FROM rep_robj_xtsf_tracking track + array("integer", "integer", "integer"), + array($this->session_id, $this->node_id, $this->condition_id) + ); + + $row = $this->db->fetchAssoc($result); + + return $row != null && $row["possible"] > 0; + } + + /** + * @param int $node_id + */ + public function updateTrackNodeId($node_id) + { + $this->db->update( + "rep_robj_xtsf_tracking", + array( + "node_fi" => array("integer", $node_id) + ), + array( + "session_fi" => array("integer", $this->session_id), + "step" => array("integer", $this->step), + "set_fi" => array("integer", $this->set_id), + "node_fi" => array("integer", $this->node_id) + ) + ); + } + + /** + * @param int $index + * + * @return array + */ + protected function getStepsByIndex($index) + { + $result = $this->db->queryF( + "SELECT step, node.node_index n_index FROM rep_robj_xtsf_tracking track INNER JOIN rep_robj_xqsp_node node ON node.id = track.node_fi WHERE track.set_fi = %s AND track.session_fi = %s AND node.node_index >= %s", - array("integer", "integer", "integer"), - array($this->set_id, $this->session_id, $index) - ); - - $steps = array(); - while($row = $this->db->fetchAssoc($result)) - { - $steps[$row["n_index"]] = $row["step"]; - } - return $steps; - } - - /** - * @param int $step - */ - protected function removeTstSolutionsByStep($step) - { - $this->db->manipulateF( - "DELETE tst_solutions FROM tst_solutions + array("integer", "integer", "integer"), + array($this->set_id, $this->session_id, $index) + ); + + $steps = array(); + while ($row = $this->db->fetchAssoc($result)) { + $steps[$row["n_index"]] = $row["step"]; + } + return $steps; + } + + /** + * @param int $step + */ + protected function removeTstSolutionsByStep($step) + { + $this->db->manipulateF( + "DELETE tst_solutions FROM tst_solutions INNER JOIN rep_robj_xtsf_session ON rep_robj_xtsf_session.active_id = tst_solutions.active_fi INNER JOIN rep_robj_xqsp_node ON rep_robj_xqsp_node.question_fi = tst_solutions.question_fi INNER JOIN rep_robj_xqsp_path ON rep_robj_xqsp_path.id = rep_robj_xqsp_node.path_fi WHERE rep_robj_xtsf_session.session_id = %s AND tst_solutions.step = %s AND rep_robj_xqsp_path.questionset_fi = %s", - array("integer", "integer", "integer"), - array($this->session_id, $step, $this->set_id) - ); - } - - /** - * @param int $step - */ - protected function removeTstTestResultByStep($step) - { - $this->db->manipulateF( - "DELETE tst_test_result FROM tst_test_result + array("integer", "integer", "integer"), + array($this->session_id, $step, $this->set_id) + ); + } + + /** + * @param int $step + */ + protected function removeTstTestResultByStep($step) + { + $this->db->manipulateF( + "DELETE tst_test_result FROM tst_test_result INNER JOIN rep_robj_xtsf_session ON rep_robj_xtsf_session.active_id = tst_test_result.active_fi INNER JOIN rep_robj_xqsp_node ON rep_robj_xqsp_node.question_fi = tst_test_result.question_fi INNER JOIN rep_robj_xqsp_path ON rep_robj_xqsp_path.id = rep_robj_xqsp_node.path_fi WHERE rep_robj_xtsf_session.session_id = %s AND tst_test_result.step = %s AND rep_robj_xqsp_path.questionset_fi = %s", - array("integer", "integer", "integer"), - array($this->session_id, $step, $this->set_id) - ); - } - - /** - * @param int $step - */ - protected function removeTrackingByStep($step) - { - $this->db->manipulateF( - "DELETE rep_robj_xtsf_tracking FROM rep_robj_xtsf_tracking + array("integer", "integer", "integer"), + array($this->session_id, $step, $this->set_id) + ); + } + + /** + * @param int $step + */ + protected function removeTrackingByStep($step) + { + $this->db->manipulateF( + "DELETE rep_robj_xtsf_tracking FROM rep_robj_xtsf_tracking WHERE session_fi = %s AND step = %s AND set_fi = %s", - array("integer", "integer","integer"), - array($this->session_id, $step, $this->set_id) - ); - } - - /** - * @param int $step - */ - protected function removeFeedbackByStep($step) - { - $this->db->manipulateF( - 'DELETE rep_robj_xtsf_fbt FROM rep_robj_xtsf_fbt + array("integer", "integer","integer"), + array($this->session_id, $step, $this->set_id) + ); + } + + /** + * @param int $step + */ + protected function removeFeedbackByStep($step) + { + $this->db->manipulateF( + 'DELETE rep_robj_xtsf_fbt FROM rep_robj_xtsf_fbt WHERE step = %s AND session_id = %s AND set_id = %s', - array('integer', 'integer', 'integer'), - array($step, $this->session_id, $this->set_id) - ); - } - + array('integer', 'integer', 'integer'), + array($step, $this->session_id, $this->set_id) + ); + } } - \ No newline at end of file diff --git a/classes/models/class.ilFormATestSetAssignment.php b/classes/models/class.ilFormATestSetAssignment.php index 445a845ca20af190bb68cb867fd5e51154d32721..5a4671f490b63df6c54ef102ea1a9c008ace7f2d 100644 --- a/classes/models/class.ilFormATestSetAssignment.php +++ b/classes/models/class.ilFormATestSetAssignment.php @@ -8,41 +8,40 @@ require_once "abstract.ilPluginModel.php"; * Date: 11.12.13 * Time: 09:23 * @author Thomas Joußen - */ + */ class ilFormATestSetAssignment extends ilPluginModel { - /** - * @var ilObjFormATest - */ - protected $form_a_test; - - /** - * @var ilQuestionSetPoolSet - */ - protected $set; - - /** - * @var int - */ - protected $sorting; - - public function update() - { - // TODO: Implement update() method. - } - - public function read() - { - // TODO: Implement read() method. - } - - /** - * @param ilPropertyFormGUI $form - */ - public function bindForm(ilPropertyFormGUI $form) - { - // TODO: Implement bindForm() method. - } + /** + * @var ilObjFormATest + */ + protected $form_a_test; + + /** + * @var ilQuestionSetPoolSet + */ + protected $set; + + /** + * @var int + */ + protected $sorting; + + public function update() + { + // TODO: Implement update() method. + } + + public function read() + { + // TODO: Implement read() method. + } + + /** + * @param ilPropertyFormGUI $form + */ + public function bindForm(ilPropertyFormGUI $form) + { + // TODO: Implement bindForm() method. + } } - \ No newline at end of file diff --git a/classes/models/class.ilFormATestSetList.php b/classes/models/class.ilFormATestSetList.php index f6c18848429e4928fada9360801b0776006d331d..ea656260e1004bd8d75b7ab3e7effdee4e6e4ed0 100644 --- a/classes/models/class.ilFormATestSetList.php +++ b/classes/models/class.ilFormATestSetList.php @@ -9,164 +9,152 @@ require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/ * Date: 10.12.13 * Time: 15:33 * @author Thomas Joußen - */ + */ class ilFormATestSetList extends ilXTSFModelList { - /** - * @var ilLanguage - */ - protected $lng; - - public function __construct(ilObjFormATest $form_a_test) - { - global $DIC; - - $this->lng = $DIC->language(); - - parent::__construct($form_a_test); - } - - - /** - * @return array - */ - public function loadData() - { - require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/classes/providers/class.ilFormATestSetProvider.php"; - - $provider = new ilFormATestSetProvider(); - return $provider->loadData(array( - "form_a_test" => $this->form_a_test->getId() - )); - } - - /** - * @param array $set_ids - * @return bool - */ - public function insert($set_ids, $do_clone = true) - { - require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/class.ilObjQuestionSetPool.php"; - - foreach($set_ids as $set_id) - { - $set = new ilQuestionSetPoolSet($set_id); - $set->read(); - - if($set != null ) - { - if($do_clone) - { - $clone = $set->duplicate($this->form_a_test->getId()); - $container_id = $clone->getId(); - } - else - { - $container_id = $set->getId(); - } - $success = $this->db->queryF( - "INSERT INTO rep_robj_xtsf_qs (obj_fi, questionset_fi, sorting) + /** + * @var ilLanguage + */ + protected $lng; + + public function __construct(ilObjFormATest $form_a_test) + { + global $DIC; + + $this->lng = $DIC->language(); + + parent::__construct($form_a_test); + } + + + /** + * @return array + */ + public function loadData() + { + require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/classes/providers/class.ilFormATestSetProvider.php"; + + $provider = new ilFormATestSetProvider(); + return $provider->loadData(array( + "form_a_test" => $this->form_a_test->getId() + )); + } + + /** + * @param array $set_ids + * @return bool + */ + public function insert($set_ids, $do_clone = true) + { + require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/class.ilObjQuestionSetPool.php"; + + foreach ($set_ids as $set_id) { + $set = new ilQuestionSetPoolSet($set_id); + $set->read(); + + if ($set != null) { + if ($do_clone) { + $clone = $set->duplicate($this->form_a_test->getId()); + $container_id = $clone->getId(); + } else { + $container_id = $set->getId(); + } + $success = $this->db->queryF( + "INSERT INTO rep_robj_xtsf_qs (obj_fi, questionset_fi, sorting) (SELECT %s,%s, CASE WHEN MAX(sorting) IS NULL THEN 10 ELSE MAX(sorting) + 10 END FROM rep_robj_xtsf_qs WHERE obj_fi = %s)", - array("integer", "integer", "integer"), - array($this->form_a_test->getId(), $container_id, $this->form_a_test->getId()) - ); - - if(!$success) - { - return false; - } - - $this->form_a_test->logAction($this->lng->txt("rep_robj_xtsf_log_set_added"), $set_id); - } - } - return true; - } - - public function remove($set_ids) - { - foreach($set_ids as $set_id) - { - $set = new ilQuestionSetPoolSet($set_id); - $set->read(); - - $set->remove(); - $sucess = $this->db->manipulateF( - "DELETE FROM rep_robj_xtsf_qs WHERE obj_fi = %s AND questionset_fi = %s", - array("integer", "integer"), - array($this->form_a_test->getId(), $set_id) - ); - - if(!$sucess) - { - return false; - } - - $this->form_a_test->logAction($this->lng->txt("rep_robj_xtsf_log_set_removed"), $set_id); - } - return true; - } - - public function removeAll() - { - $data = $this->loadData(); - - foreach($data as $item) - { - $set = new ilQuestionSetPoolSet($item["id"]); - $set->read(); - $set->remove(); - - $this->db->manipulateF( - "DELETE FROM rep_robj_xtsf_qs WHERE obj_fi = %s AND questionset_fi = %s", - array("integer", "integer"), - array($this->form_a_test->getId(), $set->getId()) - ); - } - } - - public function update($data) - { - return $this->db->update( - "rep_robj_xtsf_qs", - array( - "sorting" => array("integer", $data["sorting"]) - ), - array( - "obj_fi" => array("integer", $this->form_a_test->getId()), - "questionset_fi" => array("integer", $data["id"]) - ) - ); - } - - public function getSet($id) - { - $data = $this->getData(); - - foreach($data as $item) - { - if($item["id"] == $id) - { - return $item; - } - } - - return null; - } - - /** - * @param array $data - * - * @return array - */ - public function createObjectsFromData($data) - { - return $data; - } + array("integer", "integer", "integer"), + array($this->form_a_test->getId(), $container_id, $this->form_a_test->getId()) + ); + + if (!$success) { + return false; + } + + $this->form_a_test->logAction($this->lng->txt("rep_robj_xtsf_log_set_added"), $set_id); + } + } + return true; + } + + public function remove($set_ids) + { + foreach ($set_ids as $set_id) { + $set = new ilQuestionSetPoolSet($set_id); + $set->read(); + + $set->remove(); + $sucess = $this->db->manipulateF( + "DELETE FROM rep_robj_xtsf_qs WHERE obj_fi = %s AND questionset_fi = %s", + array("integer", "integer"), + array($this->form_a_test->getId(), $set_id) + ); + + if (!$sucess) { + return false; + } + + $this->form_a_test->logAction($this->lng->txt("rep_robj_xtsf_log_set_removed"), $set_id); + } + return true; + } + + public function removeAll() + { + $data = $this->loadData(); + + foreach ($data as $item) { + $set = new ilQuestionSetPoolSet($item["id"]); + $set->read(); + $set->remove(); + + $this->db->manipulateF( + "DELETE FROM rep_robj_xtsf_qs WHERE obj_fi = %s AND questionset_fi = %s", + array("integer", "integer"), + array($this->form_a_test->getId(), $set->getId()) + ); + } + } + + public function update($data) + { + return $this->db->update( + "rep_robj_xtsf_qs", + array( + "sorting" => array("integer", $data["sorting"]) + ), + array( + "obj_fi" => array("integer", $this->form_a_test->getId()), + "questionset_fi" => array("integer", $data["id"]) + ) + ); + } + + public function getSet($id) + { + $data = $this->getData(); + + foreach ($data as $item) { + if ($item["id"] == $id) { + return $item; + } + } + + return null; + } + + /** + * @param array $data + * + * @return array + */ + public function createObjectsFromData($data) + { + return $data; + } } - \ No newline at end of file diff --git a/classes/models/class.ilFormATestSetResultList.php b/classes/models/class.ilFormATestSetResultList.php index 8d85b1bb97c5855f422e73983d2d6b797a7e0bb7..bf462abcb8fb814f41dbc62bb524a4aa8d758ccc 100644 --- a/classes/models/class.ilFormATestSetResultList.php +++ b/classes/models/class.ilFormATestSetResultList.php @@ -6,33 +6,33 @@ * Date: 22.01.14 * Time: 12:15 * @author Thomas Joußen - */ + */ class ilFormATestSetResultList extends ilXTSFModelList { - /** - * @var int - */ - protected $set_id; + /** + * @var int + */ + protected $set_id; - /** - * @var int - */ - protected $session_id; + /** + * @var int + */ + protected $session_id; - public function __construct(ilObjFormATest $form_a_test, $set_id, $session_id) - { - $this->session_id = $session_id; - $this->set_id = $set_id; - parent::__construct($form_a_test); - } + public function __construct(ilObjFormATest $form_a_test, $set_id, $session_id) + { + $this->session_id = $session_id; + $this->set_id = $set_id; + parent::__construct($form_a_test); + } - /** - * @return array - */ - public function loadData() - { - $query = "SELECT tracking.step,tracking.matched_condition,tracking.matched_condition_id,matched_path.title, qs_qst.question_fi, qs_qst.question_index, questions.title as question_title, path.title as path_title, tst_result.points as reached_points, + /** + * @return array + */ + public function loadData() + { + $query = "SELECT tracking.step,tracking.matched_condition,tracking.matched_condition_id,matched_path.title, qs_qst.question_fi, qs_qst.question_index, questions.title as question_title, path.title as path_title, tst_result.points as reached_points, (CASE WHEN node.dominant_scoring IS NOT NULL THEN node.dominant_scoring @@ -54,29 +54,27 @@ class ilFormATestSetResultList extends ilXTSFModelList WHERE tracking.set_fi = %s AND sess.session_id = %s ORDER BY tracking.step ASC"; - $result = $this->db->queryF( - $query, - array("integer", "integer"), - array($this->set_id, $this->session_id) - ); + $result = $this->db->queryF( + $query, + array("integer", "integer"), + array($this->set_id, $this->session_id) + ); - $data = array(); - while($row = $this->db->fetchAssoc($result)) - { - $data[] = $row; - } + $data = array(); + while ($row = $this->db->fetchAssoc($result)) { + $data[] = $row; + } - return $data; - } + return $data; + } - /** - * @param array $data - * - * @return array - */ - public function createObjectsFromData($data) - { - return $data; - } + /** + * @param array $data + * + * @return array + */ + public function createObjectsFromData($data) + { + return $data; + } } - \ No newline at end of file diff --git a/classes/models/class.ilFormATestSetStepList.php b/classes/models/class.ilFormATestSetStepList.php index 3f238e8b23ffc6427d0dac5dcf10889a33420297..61e69ef1ec10b9e9f8f275282f9cc8fb9224e0b4 100644 --- a/classes/models/class.ilFormATestSetStepList.php +++ b/classes/models/class.ilFormATestSetStepList.php @@ -6,55 +6,53 @@ * Date: 22.01.14 * Time: 12:15 * @author Thomas Joußen - */ + */ class ilFormATestSetStepList extends ilXTSFModelList { - /** - * @var int - */ - protected $set_id; + /** + * @var int + */ + protected $set_id; - /** - * @var int - */ - protected $session_id; + /** + * @var int + */ + protected $session_id; - public function __construct(ilObjFormATest $form_a_test, $set_id, $session_id) - { - $this->session_id = $session_id; - $this->set_id = $set_id; - parent::__construct($form_a_test); - } + public function __construct(ilObjFormATest $form_a_test, $set_id, $session_id) + { + $this->session_id = $session_id; + $this->set_id = $set_id; + parent::__construct($form_a_test); + } - /** - * @return array - */ - public function loadData() - { - $data = array(); + /** + * @return array + */ + public function loadData() + { + $data = array(); - if($this->form_a_test->isAllowWalkBack()) - { - $result = $this->db->queryF( - "SELECT path.questionset_fi, node.id, node.node_index, qst.title, qs_qst.question_index + if ($this->form_a_test->isAllowWalkBack()) { + $result = $this->db->queryF( + "SELECT path.questionset_fi, node.id, node.node_index, qst.title, qs_qst.question_index FROM rep_robj_xqsp_qs_qst qs_qst INNER JOIN qpl_questions qst ON qst.question_id = qs_qst.question_fi INNER JOIN rep_robj_xqsp_node node ON qs_qst.question_fi = node.question_fi AND node.node_index = 1 INNER JOIN rep_robj_xqsp_path path ON path.id = node.path_fi AND path.path_index = 1 WHERE path.questionset_fi = %s", - array("integer"), - array($this->set_id) - ); + array("integer"), + array($this->set_id) + ); - while($row = $this->db->fetchAssoc($result)) - { - $data[$row["question_index"]] = $row; - } - } + while ($row = $this->db->fetchAssoc($result)) { + $data[$row["question_index"]] = $row; + } + } - $result = $this->db->queryF( - "SELECT path.questionset_fi, node.id, node.node_index, qst.title, qs_qst.question_index + $result = $this->db->queryF( + "SELECT path.questionset_fi, node.id, node.node_index, qst.title, qs_qst.question_index FROM rep_robj_xqsp_qs_qst qs_qst INNER JOIN qpl_questions qst ON qst.question_id = qs_qst.question_fi INNER JOIN rep_robj_xqsp_node node ON qs_qst.question_fi = node.question_fi @@ -62,26 +60,24 @@ class ilFormATestSetStepList extends ilXTSFModelList INNER JOIN rep_robj_xqsp_path path ON path.id = node.path_fi WHERE path.questionset_fi = %s AND tr.session_fi = %s ORDER BY tr.step ASC", - array("integer", "integer"), - array($this->set_id, $this->session_id) - ); + array("integer", "integer"), + array($this->set_id, $this->session_id) + ); - while($row = $this->db->fetchAssoc($result)) - { - $data[$row["question_index"]] = $row; - } + while ($row = $this->db->fetchAssoc($result)) { + $data[$row["question_index"]] = $row; + } - return $data; - } + return $data; + } - /** - * @param array $data - * - * @return array - */ - public function createObjectsFromData($data) - { - return $data; - } + /** + * @param array $data + * + * @return array + */ + public function createObjectsFromData($data) + { + return $data; + } } - \ No newline at end of file diff --git a/classes/models/interface.ilXTSFModelInterface.php b/classes/models/interface.ilXTSFModelInterface.php index 02a017e2c41790a1f6a560dbe48f241e34288f60..8f7aa41bc229171b002328d9f901f5d558e7c96f 100644 --- a/classes/models/interface.ilXTSFModelInterface.php +++ b/classes/models/interface.ilXTSFModelInterface.php @@ -7,19 +7,19 @@ * @author Thomas Joußen */ -interface ilXTSFModelInterface { +interface ilXTSFModelInterface +{ + public function update(); - public function update(); + public function read(); - public function read(); + /** + * @return array + */ + public function toArray(); - /** - * @return array - */ - public function toArray(); - - /** - * @param ilPropertyFormGUI $form - */ - public function bindForm(ilPropertyFormGUI $form); -} \ No newline at end of file + /** + * @param ilPropertyFormGUI $form + */ + public function bindForm(ilPropertyFormGUI $form); +} diff --git a/classes/providers/FormATestGlobalScreenToolsProvider.php b/classes/providers/FormATestGlobalScreenToolsProvider.php new file mode 100644 index 0000000000000000000000000000000000000000..6b11e22f52113d01a94242c76382c7e1d08f7b04 --- /dev/null +++ b/classes/providers/FormATestGlobalScreenToolsProvider.php @@ -0,0 +1,56 @@ + + */ +class FormATestGlobalScreenToolsProvider extends AbstractDynamicToolPluginProvider +{ + public const LEFT_NAV = 'left_nav'; + + /** + * @inheritDoc + */ + public function isInterestedInContexts() : \ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection + { + return $this->context_collection->main()->administration(); + } + + /** + * @inheritDoc + */ + public function getToolsForContextStack(\ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts $called_contexts) : array + { + $iff = function ($id) { + return $this->identification_provider->contextAwareIdentifier($id); + }; + $l = function (string $content) { + return $this->dic->ui()->factory()->legacy($content); + }; + + $tools = []; + + $additionalData = $called_contexts->getLast()->getAdditionalData(); + if ($additionalData->exists(self::LEFT_NAV)) { + $leftNav = $additionalData->get(self::LEFT_NAV); + + $title = $this->plugin->txt('questions_overview_title'); + $icon = $this->dic->ui()->factory()->symbol()->icon()->custom( + ilFormATestPlugin::_getIcon('xtsf', 'small'), + $this->plugin->txt('questions_overview_title') + ); + + $tools[] = $this->factory + ->tool($iff('FormATest|Navi')) + ->withTitle($title) + ->withSymbol($icon) + ->withContentWrapper(static function () use ($l, $leftNav) { + return $l($leftNav); + }); + } + + return $tools; + } +} diff --git a/classes/providers/abstract.ilXTSFTableDatabaseDataProvider.php b/classes/providers/abstract.ilXTSFTableDatabaseDataProvider.php index b0a02bc0355eb507f62c0cae8e226d075134855c..02750bd01c5d5853eff4e58b00b923e9b85ff22c 100644 --- a/classes/providers/abstract.ilXTSFTableDatabaseDataProvider.php +++ b/classes/providers/abstract.ilXTSFTableDatabaseDataProvider.php @@ -8,189 +8,184 @@ require_once "interface.ilXTSFTableDataProvider.php"; * Date: 24.09.13 * Time: 09:00 * @author Thomas Joußen - */ -abstract class ilXTSFTableDatabaseDataProvider implements ilXTSFTableDataProvider{ - - /** - * @var ilDB - */ - protected $db; - - /** - * @var int - */ - protected $limit = 0; - - /** - * @var int - */ - protected $offset = 0; - - /** - * @var string - */ - protected $query = ""; - - /** - * - */ - public function __construct() - { - global $DIC; - - $this->db = $DIC->database(); - } - - /** - * @param $limit - * - * @throws InvalidArgumentException - */ - public function setLimit($limit) - { - if (!is_numeric($limit)) - { - throw new InvalidArgumentException('Please provide a valid numerical limit.'); - } - $this->limit = $limit; - } - - /** - * @return int - */ - public function getLimit() - { - return $this->limit; - } - - - /** - * @param $offset - * - * @throws InvalidArgumentException - */ - public function setOffset($offset) - { - if (!is_numeric($offset)) - { - throw new InvalidArgumentException('Please provide a valid numerical offset.'); - } - - $this->offset = $offset; - } - - /** - * @return int - */ - public function getOffset() - { - return $this->offset; - } - - /** - * @param array $filter - * @param array $orderBy - * - * @return array - */ - public function loadData(array $filter, array $orderBy = array()) - { - $data = array(); - -// $this->db->setLimit($this->limit, $this->offset); - $this->buildQuery($filter, $orderBy); - - $res = $this->db->query($this->query); - - while ($row = $this->db->fetchAssoc($res)) - { - $data[] = $row; - } - - return $data; - } - - /** - * @param array $filter - * @param array $orderBy - * - * @return string - */ - protected function buildQuery(array $filter, array $orderBy) - { - $select = $this->getSelectPart(); - $where = $this->getWherePart($filter); - $from = $this->getFromPart(); - $join = $this->getJoinPart($filter); - $order = $this->getOrderByPart($orderBy); - $group = $this->getGroupByPart(); - $having = $this->getHavingPart($filter); - - $where = strlen($where)? 'WHERE ' . $where : ''; - $query = "SELECT {$select} FROM {$from} {$join} {$where}"; - - if (strlen($group)) - { - $query .= " GROUP BY {$group}"; - } - - if (strlen($having)) - { - $query .= " HAVING {$having}"; - } - - if (strlen($order)) - { - $query .= " ORDER BY {$order}"; - } - - $this->query = $query; - } - - /** - * @return string - * @abstract - */ - abstract protected function getSelectPart(); - - /** - * @return string - * @abstract - */ - abstract protected function getFromPart(); - - /** - * @param array $filter - * - * @return string - * @abstract - */ - abstract protected function getJoinPart(array $filter); - - /** - * @param array $filter - * @return string - * @abstract - */ - abstract protected function getWherePart(array $filter); - - /** - * @return string - * @abstract - */ - abstract protected function getGroupByPart(); - - /** - * @param array $filter - * @return string - * @abstract - */ - abstract protected function getHavingPart(array $filter); - - /** - * @param array $params - * @return string - * @abstract - */ - abstract protected function getOrderByPart(array $params); + */ +abstract class ilXTSFTableDatabaseDataProvider implements ilXTSFTableDataProvider +{ + + /** + * @var ilDB + */ + protected $db; + + /** + * @var int + */ + protected $limit = 0; + + /** + * @var int + */ + protected $offset = 0; + + /** + * @var string + */ + protected $query = ""; + + /** + * + */ + public function __construct() + { + global $DIC; + + $this->db = $DIC->database(); + } + + /** + * @param $limit + * + * @throws InvalidArgumentException + */ + public function setLimit($limit) + { + if (!is_numeric($limit)) { + throw new InvalidArgumentException('Please provide a valid numerical limit.'); + } + $this->limit = $limit; + } + + /** + * @return int + */ + public function getLimit() + { + return $this->limit; + } + + + /** + * @param $offset + * + * @throws InvalidArgumentException + */ + public function setOffset($offset) + { + if (!is_numeric($offset)) { + throw new InvalidArgumentException('Please provide a valid numerical offset.'); + } + + $this->offset = $offset; + } + + /** + * @return int + */ + public function getOffset() + { + return $this->offset; + } + + /** + * @param array $filter + * @param array $orderBy + * + * @return array + */ + public function loadData(array $filter, array $orderBy = array()) + { + $data = array(); + + // $this->db->setLimit($this->limit, $this->offset); + $this->buildQuery($filter, $orderBy); + + $res = $this->db->query($this->query); + + while ($row = $this->db->fetchAssoc($res)) { + $data[] = $row; + } + + return $data; + } + + /** + * @param array $filter + * @param array $orderBy + * + * @return string + */ + protected function buildQuery(array $filter, array $orderBy) + { + $select = $this->getSelectPart(); + $where = $this->getWherePart($filter); + $from = $this->getFromPart(); + $join = $this->getJoinPart($filter); + $order = $this->getOrderByPart($orderBy); + $group = $this->getGroupByPart(); + $having = $this->getHavingPart($filter); + + $where = strlen($where)? 'WHERE ' . $where : ''; + $query = "SELECT {$select} FROM {$from} {$join} {$where}"; + + if (strlen($group)) { + $query .= " GROUP BY {$group}"; + } + + if (strlen($having)) { + $query .= " HAVING {$having}"; + } + + if (strlen($order)) { + $query .= " ORDER BY {$order}"; + } + + $this->query = $query; + } + + /** + * @return string + * @abstract + */ + abstract protected function getSelectPart(); + + /** + * @return string + * @abstract + */ + abstract protected function getFromPart(); + + /** + * @param array $filter + * + * @return string + * @abstract + */ + abstract protected function getJoinPart(array $filter); + + /** + * @param array $filter + * @return string + * @abstract + */ + abstract protected function getWherePart(array $filter); + + /** + * @return string + * @abstract + */ + abstract protected function getGroupByPart(); + + /** + * @param array $filter + * @return string + * @abstract + */ + abstract protected function getHavingPart(array $filter); + + /** + * @param array $params + * @return string + * @abstract + */ + abstract protected function getOrderByPart(array $params); } diff --git a/classes/providers/class.ilFormATestParticipantsProvider.php b/classes/providers/class.ilFormATestParticipantsProvider.php index d94c83d7f02c9ec560109761e61b58b54001fb59..ba74659d098395bb9efe0b3dc5fed435fc0317e0 100644 --- a/classes/providers/class.ilFormATestParticipantsProvider.php +++ b/classes/providers/class.ilFormATestParticipantsProvider.php @@ -8,98 +8,97 @@ require_once "abstract.ilXTSFTableDatabaseDataProvider.php"; * Date: 20.01.14 * Time: 15:59 * @author Thomas Joußen - */ + */ class ilFormATestParticipantsProvider extends ilXTSFTableDatabaseDataProvider { - /** - * @return string - */ - protected function getSelectPart() - { - $select = join(", ", array( - "session.session_id", - "tst_active.active_id", - "tst_active.user_fi", - "tst_active.tstamp", - "usr_data.usr_id", - "usr_data.login", - "session.current_pass+1 passes" - )); + /** + * @return string + */ + protected function getSelectPart() + { + $select = join(", ", array( + "session.session_id", + "tst_active.active_id", + "tst_active.user_fi", + "tst_active.tstamp", + "usr_data.usr_id", + "usr_data.login", + "session.current_pass+1 passes" + )); - //$select .= ", (SELECT COUNT(session.current_pass) FROM rep_robj_xtsf_session s2 - //WHERE s2.active_id = tst_active.acitve_id) passes"; + //$select .= ", (SELECT COUNT(session.current_pass) FROM rep_robj_xtsf_session s2 + //WHERE s2.active_id = tst_active.acitve_id) passes"; - return $select; - } + return $select; + } - /** - * @return string - */ - protected function getFromPart() - { - return "tst_active"; - } + /** + * @return string + */ + protected function getFromPart() + { + return "tst_active"; + } - /** - * @param array $filter - * - * @return string - */ - protected function getJoinPart(array $filter) - { - return join(" ", array( - "LEFT JOIN usr_data ON usr_data.usr_id = tst_active.user_fi", - "INNER JOIN rep_robj_xtsf_session session ON session.active_id = tst_active.active_id + /** + * @param array $filter + * + * @return string + */ + protected function getJoinPart(array $filter) + { + return join(" ", array( + "LEFT JOIN usr_data ON usr_data.usr_id = tst_active.user_fi", + "INNER JOIN rep_robj_xtsf_session session ON session.active_id = tst_active.active_id AND session.current_pass = tst_active.tries" - )); - } + )); + } - /** - * @param array $filter - * - * @return string - */ - protected function getWherePart(array $filter) - { - return join(" AND ", array( - "tst_active.test_fi = ". $this->db->quote($filter["test_id"], "integer") - )); - } + /** + * @param array $filter + * + * @return string + */ + protected function getWherePart(array $filter) + { + return join(" AND ", array( + "tst_active.test_fi = " . $this->db->quote($filter["test_id"], "integer") + )); + } - /** - * @return string - */ - protected function getGroupByPart() - { - return join(", ", array( - "tst_active.active_id", - "tst_active.user_fi", - "tst_active.tstamp", - "session.session_id", - "usr_data.usr_id", - "usr_data.login", - "passes" - )); - } + /** + * @return string + */ + protected function getGroupByPart() + { + return join(", ", array( + "tst_active.active_id", + "tst_active.user_fi", + "tst_active.tstamp", + "session.session_id", + "usr_data.usr_id", + "usr_data.login", + "passes" + )); + } - /** - * @param array $filter - * - * @return string - */ - protected function getHavingPart(array $filter) - { - } + /** + * @param array $filter + * + * @return string + */ + protected function getHavingPart(array $filter) + { + } - /** - * @param array $params - * - * @return string - */ - protected function getOrderByPart(array $params) - { - // TODO: Implement getOrderByPart() method. - } + /** + * @param array $params + * + * @return string + */ + protected function getOrderByPart(array $params) + { + // TODO: Implement getOrderByPart() method. + } } - \ No newline at end of file diff --git a/classes/providers/class.ilFormATestQuestionListProvider.php b/classes/providers/class.ilFormATestQuestionListProvider.php index 84fa42cf5c487d141967b4e27068ca17a2a255b3..4171b33e8f3c2f08730e869235df4f8c4d506c11 100644 --- a/classes/providers/class.ilFormATestQuestionListProvider.php +++ b/classes/providers/class.ilFormATestQuestionListProvider.php @@ -11,71 +11,70 @@ require_once 'abstract.ilXTSFTableDatabaseDataProvider.php'; class ilFormATestQuestionListProvider extends ilXTSFTableDatabaseDataProvider { - /** - * @return string - */ - protected function getSelectPart() - { - return join(',', array('title','question_index','question_fi')); - } + /** + * @return string + */ + protected function getSelectPart() + { + return join(',', array('title','question_index','question_fi')); + } - /** - * @return string - */ - protected function getFromPart() - { - return 'rep_robj_xtsf_qs'; - } + /** + * @return string + */ + protected function getFromPart() + { + return 'rep_robj_xtsf_qs'; + } - /** - * @param array $filter - * - * @return string - */ - protected function getJoinPart(array $filter) - { - return join(' ', array( - 'INNER JOIN rep_robj_xqsp_qs ON rep_robj_xqsp_qs.id = rep_robj_xtsf_qs.questionset_fi', - 'INNER JOIN rep_robj_xqsp_qs_qst ON rep_robj_xqsp_qs_qst.questionset_fi = rep_robj_xtsf_qs.questionset_fi' - )); - } + /** + * @param array $filter + * + * @return string + */ + protected function getJoinPart(array $filter) + { + return join(' ', array( + 'INNER JOIN rep_robj_xqsp_qs ON rep_robj_xqsp_qs.id = rep_robj_xtsf_qs.questionset_fi', + 'INNER JOIN rep_robj_xqsp_qs_qst ON rep_robj_xqsp_qs_qst.questionset_fi = rep_robj_xtsf_qs.questionset_fi' + )); + } - /** - * @param array $filter - * - * @return string - */ - protected function getWherePart(array $filter) - { - return $this->db->equals('rep_robj_xtsf_qs.obj_fi', $filter['obj_fi'], 'integer'); - } + /** + * @param array $filter + * + * @return string + */ + protected function getWherePart(array $filter) + { + return $this->db->equals('rep_robj_xtsf_qs.obj_fi', $filter['obj_fi'], 'integer'); + } - /** - * @return string - */ - protected function getGroupByPart() - { - return ''; - } + /** + * @return string + */ + protected function getGroupByPart() + { + return ''; + } - /** - * @param array $filter - * - * @return string - */ - protected function getHavingPart(array $filter) - { - return ''; - } + /** + * @param array $filter + * + * @return string + */ + protected function getHavingPart(array $filter) + { + return ''; + } - /** - * @param array $params - * - * @return string - */ - protected function getOrderByPart(array $params) - { - return 'sorting, question_index ASC'; - } + /** + * @param array $params + * + * @return string + */ + protected function getOrderByPart(array $params) + { + return 'sorting, question_index ASC'; + } } - \ No newline at end of file diff --git a/classes/providers/class.ilFormATestSetBrowserProvider.php b/classes/providers/class.ilFormATestSetBrowserProvider.php index ad6c63babcab00da08460836f3ff1b7eb24058c2..58aecb89bf428a5daa765e8dd7c59aadaa0cee5b 100644 --- a/classes/providers/class.ilFormATestSetBrowserProvider.php +++ b/classes/providers/class.ilFormATestSetBrowserProvider.php @@ -8,89 +8,88 @@ require_once "abstract.ilXTSFTableDatabaseDataProvider.php"; * Date: 10.12.13 * Time: 16:21 * @author Thomas Joußen - */ + */ class ilFormATestSetBrowserProvider extends ilXTSFTableDatabaseDataProvider { - /** - * @return string - */ - protected function getSelectPart() - { - return join(",", array( - "qsp_set.id", - "qsp_set.title", - "qsp_set.description", - "qsp_set.questionsetpool_fi" - )); - } + /** + * @return string + */ + protected function getSelectPart() + { + return join(",", array( + "qsp_set.id", + "qsp_set.title", + "qsp_set.description", + "qsp_set.questionsetpool_fi" + )); + } - /** - * @return string - */ - protected function getFromPart() - { - return "rep_robj_xqsp_qs qsp_set"; - } + /** + * @return string + */ + protected function getFromPart() + { + return "rep_robj_xqsp_qs qsp_set"; + } - /** - * @param array $filter - * - * @return string - */ - protected function getJoinPart(array $filter) - { - return join(" ", array( - "INNER JOIN object_data od ON od.obj_id = qsp_set.questionsetpool_fi AND od.type = " . $this->db->quote('xqsp', 'text'), - "INNER JOIN rep_robj_xqsp_path xqsp_path ON xqsp_path.questionset_fi = qsp_set.id", - "LEFT JOIN rep_robj_xtsf_qs fat_set ON fat_set.questionset_fi = qsp_set.id AND fat_set.obj_fi = " . $this->db->quote($filter["form_a_test"], "integer") - )); - } + /** + * @param array $filter + * + * @return string + */ + protected function getJoinPart(array $filter) + { + return join(" ", array( + "INNER JOIN object_data od ON od.obj_id = qsp_set.questionsetpool_fi AND od.type = " . $this->db->quote('xqsp', 'text'), + "INNER JOIN rep_robj_xqsp_path xqsp_path ON xqsp_path.questionset_fi = qsp_set.id", + "LEFT JOIN rep_robj_xtsf_qs fat_set ON fat_set.questionset_fi = qsp_set.id AND fat_set.obj_fi = " . $this->db->quote($filter["form_a_test"], "integer") + )); + } - /** - * @param array $filter - * - * @return string - */ - protected function getWherePart(array $filter) - { - return join(" AND ", array( - $this->db->in("qsp_set.questionsetpool_fi", $filter["set_pools"], false, "integer"), - "fat_set.questionset_fi IS NULL", - )); - } + /** + * @param array $filter + * + * @return string + */ + protected function getWherePart(array $filter) + { + return join(" AND ", array( + $this->db->in("qsp_set.questionsetpool_fi", $filter["set_pools"], false, "integer"), + "fat_set.questionset_fi IS NULL", + )); + } - /** - * @return string - */ - protected function getGroupByPart() - { - return join(",", array( - "qsp_set.id", - "qsp_set.title", - "qsp_set.description", - "qsp_set.questionsetpool_fi" - )); - } + /** + * @return string + */ + protected function getGroupByPart() + { + return join(",", array( + "qsp_set.id", + "qsp_set.title", + "qsp_set.description", + "qsp_set.questionsetpool_fi" + )); + } - /** - * @param array $filter - * - * @return string - */ - protected function getHavingPart(array $filter) - { - return ""; - } + /** + * @param array $filter + * + * @return string + */ + protected function getHavingPart(array $filter) + { + return ""; + } - /** - * @param array $params - * - * @return string - */ - protected function getOrderByPart(array $params) - { - return ""; - } + /** + * @param array $params + * + * @return string + */ + protected function getOrderByPart(array $params) + { + return ""; + } } - \ No newline at end of file diff --git a/classes/providers/class.ilFormATestSetProvider.php b/classes/providers/class.ilFormATestSetProvider.php index 7e9af8db0a5679c110cd540375e5c048387c1a5f..574d5e5c90e3bfb597625b5105fb0716f4d4a713 100644 --- a/classes/providers/class.ilFormATestSetProvider.php +++ b/classes/providers/class.ilFormATestSetProvider.php @@ -8,80 +8,79 @@ require_once "abstract.ilXTSFTableDatabaseDataProvider.php"; * Date: 11.12.13 * Time: 09:41 * @author Thomas Joußen - */ + */ class ilFormATestSetProvider extends ilXTSFTableDatabaseDataProvider { - /** - * @return string - */ - protected function getSelectPart() - { - return join(", ", array( - "rep_robj_xqsp_qs.id", - "rep_robj_xtsf_qs.sorting", - "rep_robj_xqsp_qs.title", - "rep_robj_xqsp_qs.description", - "rep_robj_xqsp_qs.questionsetpool_fi" - )); - } + /** + * @return string + */ + protected function getSelectPart() + { + return join(", ", array( + "rep_robj_xqsp_qs.id", + "rep_robj_xtsf_qs.sorting", + "rep_robj_xqsp_qs.title", + "rep_robj_xqsp_qs.description", + "rep_robj_xqsp_qs.questionsetpool_fi" + )); + } - /** - * @return string - */ - protected function getFromPart() - { - return "rep_robj_xtsf_qs"; - } + /** + * @return string + */ + protected function getFromPart() + { + return "rep_robj_xtsf_qs"; + } - /** - * @param array $filter - * - * @return string - */ - protected function getJoinPart(array $filter) - { - return "INNER JOIN rep_robj_xqsp_qs ON rep_robj_xqsp_qs.id = rep_robj_xtsf_qs.questionset_fi"; - } + /** + * @param array $filter + * + * @return string + */ + protected function getJoinPart(array $filter) + { + return "INNER JOIN rep_robj_xqsp_qs ON rep_robj_xqsp_qs.id = rep_robj_xtsf_qs.questionset_fi"; + } - /** - * @param array $filter - * - * @return string - */ - protected function getWherePart(array $filter) - { - return join (" AND ", array( - "obj_fi = " . $this->db->quote($filter["form_a_test"], "integer") - )); - } + /** + * @param array $filter + * + * @return string + */ + protected function getWherePart(array $filter) + { + return join(" AND ", array( + "obj_fi = " . $this->db->quote($filter["form_a_test"], "integer") + )); + } - /** - * @return string - */ - protected function getGroupByPart() - { - return ""; - } + /** + * @return string + */ + protected function getGroupByPart() + { + return ""; + } - /** - * @param array $filter - * - * @return string - */ - protected function getHavingPart(array $filter) - { - return ""; - } + /** + * @param array $filter + * + * @return string + */ + protected function getHavingPart(array $filter) + { + return ""; + } - /** - * @param array $params - * - * @return string - */ - protected function getOrderByPart(array $params) - { - return "sorting ASC"; - } + /** + * @param array $params + * + * @return string + */ + protected function getOrderByPart(array $params) + { + return "sorting ASC"; + } } - \ No newline at end of file diff --git a/classes/providers/interface.ilXTSFTableDataProvider.php b/classes/providers/interface.ilXTSFTableDataProvider.php index 39a191b0d1dee36503f0187b162d23f1b2007f00..86fd15b4a6e28b6b97c80a8fb25a76bddee774b3 100644 --- a/classes/providers/interface.ilXTSFTableDataProvider.php +++ b/classes/providers/interface.ilXTSFTableDataProvider.php @@ -7,6 +7,6 @@ * @author Thomas Joußen */ -interface ilXTSFTableDataProvider { - -} \ No newline at end of file +interface ilXTSFTableDataProvider +{ +} diff --git a/classes/tables/abstract.ilXTSFTableGUI.php b/classes/tables/abstract.ilXTSFTableGUI.php index b6558d6b67b52842c3b84297edafad5c16573d8a..a61984c225610dd639e06a72de2c184dca5ade92 100644 --- a/classes/tables/abstract.ilXTSFTableGUI.php +++ b/classes/tables/abstract.ilXTSFTableGUI.php @@ -1,6 +1,5 @@ - */ + */ abstract class ilXTSFTableGUI extends ilTable2GUI { - /** - * @var ilPluginModelList - */ - protected $model_list; - - /** - * @var ilCtrl - */ - protected $ctrl; - - /** - * @var array - */ - protected $visibleOptionalColumns = array(); - - /** - * @var array - */ - protected $optionalColumns = array(); - - /** - * @var array - */ - protected $filter = array(); - - /** - * @var array - */ - protected $optional_filter = array(); - - /** - * @var - */ - protected $plugin; - - public function __construct($a_parent_obj, $a_parent_cmd = "", $plugin) - { - global $DIC; - - $this->ctrl = $DIC->ctrl(); - $this->plugin = $plugin; - parent::__construct($a_parent_obj, $a_parent_cmd); - - $this->lng->loadLanguageModule("assessment"); - } - - - /** - * @param ilXTSFModelList $model_list - */ - public function setModelList($model_list) - { - $this->model_list = $model_list; - } - - /** - * @return ilXTSFModelList - */ - public function getModelList() - { - return $this->model_list; - } - - /** - * @param string $column - * @return bool - */ - protected function isColumnVisible($column) - { - if(array_key_exists($column, $this->optionalColumns) && !isset($this->visibleOptionalColumns[$column])) - { - return false; - } - - return true; - } - - /** - * This method can be used to prepare values for sorting (e.g. translations), to filter items etc. - * It is called before sorting and segmentation. - * @param array $data - * @return array - */ - protected function prepareData(array &$data) - { - foreach($data as $key => $item) - { - if(!is_array($item)) - { - $data[$key] = $item->toArray(); - } - } - } - - /** - * This method can be used to manipulate the data of a row after sorting and segmentation - * @param array $row - * @return array - */ - protected function prepareRow(array &$row) - { - } - - /** - * Define a final formatting for a cell value - * @param mixed $column - * @param array $row - * @return mixed - */ - protected function formatCellValue($column, array $row) - { - return $row[$column]; - } - - /** - * @param array $row - */ - protected function fillRow($row) - { - $this->prepareRow($row); - - foreach($this->getStaticData() as $column) - { - $value = $this->formatCellValue($column, $row); - $this->tpl->setVariable('VAL_' . strtoupper($column), $value); - } - - if($this->tpl->blockExists("optional_column")) - { - $this->tpl->setCurrentBlock('optional_column'); - foreach($this->optionalColumns as $index => $definition) - { - if(!$this->isColumnVisible($index)) - { - continue; - } - - $value = $this->formatCellValue($index, $row); - if((string)$value === '') - { - $this->tpl->touchBlock('optional_column'); - } - else - { - $this->tpl->setVariable('OPTIONAL_COLUMN_VAL_' . strtoupper($index), $value); - } - } - $this->tpl->parseCurrentBlock(); - } - - } - - /** - * Return an array of all static (always visible) data fields in a row. - * For each key there has to be a variable name VAL_ in your defined row template. - * Example: - * return array('title', 'checkbox'); - * There have to be two template variables: VAL_TITLE and VAL_CHECKBOX - * @return array - * @abstract - */ - abstract protected function getStaticData(); - - /** - * @throws ilException - */ - public function populate() - { - $data = $this->getModelList()->getData(); - - if($data != null) - { - $this->prepareData($data); - } - $this->setData($data); - /** - * @TODO MOVE TO A PROVIDER! - */ - /*if(!$this->getExternalSegmentation() && $this->getExternalSorting()) - { - $this->determineOffsetAndOrder(true); - } - else if($this->getExternalSegmentation() || $this->getExternalSorting()) - { - $this->determineOffsetAndOrder(); - } - - $params = array(); - if($this->getExternalSegmentation()) - { - $params['limit'] = $this->getLimit(); - $params['offset'] = $this->getOffset(); - } - if($this->getExternalSorting()) - { - $params['order_field'] = $this->getOrderField(); - $params['order_direction'] = $this->getOrderDirection(); - } - - $this->determineSelectedFilters(); - $filter = $this->filter; - - foreach($this->optional_filter as $key => $value) - { - if($this->isFilterSelected($key)) - { - $filter[$key] = $value; - } - } - - $data = $this->getProvider()->getList($params, $filter); - - if(!count($data['items']) && $this->getOffset() > 0 && $this->getExternalSegmentation()) - { - $this->resetOffset(); - $params['limit'] = $this->getLimit(); - $params['offset'] = $this->getOffset(); - $data = $this->getProvider()->getList($params, $filter); - } - - $this->prepareData($data); - - $this->setData($data['items']); - if($this->getExternalSegmentation()) - { - $this->setMaxCount($data['cnt']); - } - */ - } + /** + * @var ilPluginModelList + */ + protected $model_list; + + /** + * @var ilCtrl + */ + protected $ctrl; + + /** + * @var array + */ + protected $visibleOptionalColumns = array(); + + /** + * @var array + */ + protected $optionalColumns = array(); + + /** + * @var array + */ + protected $filter = array(); + + /** + * @var array + */ + protected $optional_filter = array(); + + /** + * @var + */ + protected $plugin; + + public function __construct($a_parent_obj, $a_parent_cmd = "", $plugin) + { + global $DIC; + + $this->ctrl = $DIC->ctrl(); + $this->plugin = $plugin; + parent::__construct($a_parent_obj, $a_parent_cmd); + + $this->lng->loadLanguageModule("assessment"); + } + + + /** + * @param ilXTSFModelList $model_list + */ + public function setModelList($model_list) + { + $this->model_list = $model_list; + } + + /** + * @return ilXTSFModelList + */ + public function getModelList() + { + return $this->model_list; + } + + /** + * @param string $column + * @return bool + */ + protected function isColumnVisible($column) + { + if (array_key_exists($column, $this->optionalColumns) && !isset($this->visibleOptionalColumns[$column])) { + return false; + } + + return true; + } + + /** + * This method can be used to prepare values for sorting (e.g. translations), to filter items etc. + * It is called before sorting and segmentation. + * @param array $data + * @return array + */ + protected function prepareData(array &$data) + { + foreach ($data as $key => $item) { + if (!is_array($item)) { + $data[$key] = $item->toArray(); + } + } + } + + /** + * This method can be used to manipulate the data of a row after sorting and segmentation + * @param array $row + * @return array + */ + protected function prepareRow(array &$row) + { + } + + /** + * Define a final formatting for a cell value + * @param mixed $column + * @param array $row + * @return mixed + */ + protected function formatCellValue($column, array $row) + { + return $row[$column]; + } + + /** + * @param array $row + */ + protected function fillRow($row) + { + $this->prepareRow($row); + + foreach ($this->getStaticData() as $column) { + $value = $this->formatCellValue($column, $row); + $this->tpl->setVariable('VAL_' . strtoupper($column), $value); + } + + if ($this->tpl->blockExists("optional_column")) { + $this->tpl->setCurrentBlock('optional_column'); + foreach ($this->optionalColumns as $index => $definition) { + if (!$this->isColumnVisible($index)) { + continue; + } + + $value = $this->formatCellValue($index, $row); + if ((string) $value === '') { + $this->tpl->touchBlock('optional_column'); + } else { + $this->tpl->setVariable('OPTIONAL_COLUMN_VAL_' . strtoupper($index), $value); + } + } + $this->tpl->parseCurrentBlock(); + } + } + + /** + * Return an array of all static (always visible) data fields in a row. + * For each key there has to be a variable name VAL_ in your defined row template. + * Example: + * return array('title', 'checkbox'); + * There have to be two template variables: VAL_TITLE and VAL_CHECKBOX + * @return array + * @abstract + */ + abstract protected function getStaticData(); + + /** + * @throws ilException + */ + public function populate() + { + $data = $this->getModelList()->getData(); + + if ($data != null) { + $this->prepareData($data); + } + $this->setData($data); + /** + * @TODO MOVE TO A PROVIDER! + */ + /*if(!$this->getExternalSegmentation() && $this->getExternalSorting()) + { + $this->determineOffsetAndOrder(true); + } + else if($this->getExternalSegmentation() || $this->getExternalSorting()) + { + $this->determineOffsetAndOrder(); + } + + $params = array(); + if($this->getExternalSegmentation()) + { + $params['limit'] = $this->getLimit(); + $params['offset'] = $this->getOffset(); + } + if($this->getExternalSorting()) + { + $params['order_field'] = $this->getOrderField(); + $params['order_direction'] = $this->getOrderDirection(); + } + + $this->determineSelectedFilters(); + $filter = $this->filter; + + foreach($this->optional_filter as $key => $value) + { + if($this->isFilterSelected($key)) + { + $filter[$key] = $value; + } + } + + $data = $this->getProvider()->getList($params, $filter); + + if(!count($data['items']) && $this->getOffset() > 0 && $this->getExternalSegmentation()) + { + $this->resetOffset(); + $params['limit'] = $this->getLimit(); + $params['offset'] = $this->getOffset(); + $data = $this->getProvider()->getList($params, $filter); + } + + $this->prepareData($data); + + $this->setData($data['items']); + if($this->getExternalSegmentation()) + { + $this->setMaxCount($data['cnt']); + } + */ + } } diff --git a/classes/tables/class.ilFormATestExportTableGUI.php b/classes/tables/class.ilFormATestExportTableGUI.php index 06c246ab8140685bbb6d9db39cccf423eb327f02..3669a429bc7b26d732f99d3cc56130ad8e0c5997 100755 --- a/classes/tables/class.ilFormATestExportTableGUI.php +++ b/classes/tables/class.ilFormATestExportTableGUI.php @@ -1,53 +1,50 @@ */ class ilFormATestExportTableGUI extends ilExportTableGUI { - /** - * Constructor - * - * @access public - * @param - * @return - */ - public function __construct($a_parent_obj, $a_parent_cmd, $a_exp_obj) - { - parent::__construct($a_parent_obj, $a_parent_cmd, $a_exp_obj); + /** + * Constructor + * + * @access public + * @param + * @return + */ + public function __construct($a_parent_obj, $a_parent_cmd, $a_exp_obj) + { + parent::__construct($a_parent_obj, $a_parent_cmd, $a_exp_obj); - // NOT REQUIRED ANYMORE, PROBLEM NOW FIXED IN THE ROOT - // KEEP CODE, JF OPINIONS / ROOT FIXINGS CAN CHANGE - //$this->addCustomColumn($this->lng->txt('actions'), $this, 'formatActionsList'); - } + // NOT REQUIRED ANYMORE, PROBLEM NOW FIXED IN THE ROOT + // KEEP CODE, JF OPINIONS / ROOT FIXINGS CAN CHANGE + //$this->addCustomColumn($this->lng->txt('actions'), $this, 'formatActionsList'); + } - /** - * @param string $type - * @param string $filename - */ - protected function formatActionsList($type, $filename) - { - global $DIC; - $ilCtrl = $DIC->ctrl(); + /** + * @param string $type + * @param string $filename + */ + protected function formatActionsList($type, $filename) + { + global $DIC; + $ilCtrl = $DIC->ctrl(); - $list = new ilAdvancedSelectionListGUI(); - $list->setListTitle($this->lng->txt('actions')); - $ilCtrl->setParameter($this->getParentObject(), 'file', $type.':'.$filename); - $list->addItem($this->lng->txt('download'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'download')); - $ilCtrl->setParameter($this->getParentObject(), 'file', ''); - return $list->getHTML(); - } + $list = new ilAdvancedSelectionListGUI(); + $list->setListTitle($this->lng->txt('actions')); + $ilCtrl->setParameter($this->getParentObject(), 'file', $type . ':' . $filename); + $list->addItem($this->lng->txt('download'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'download')); + $ilCtrl->setParameter($this->getParentObject(), 'file', ''); + return $list->getHTML(); + } - /*** - * - */ - protected function initMultiCommands() - { - $this->addMultiCommand('confirmDeletion', $this->lng->txt('delete')); - } -} \ No newline at end of file + /*** + * + */ + protected function initMultiCommands() + { + $this->addMultiCommand('confirmDeletion', $this->lng->txt('delete')); + } +} diff --git a/classes/tables/class.ilFormATestParticipantsTableGUI.php b/classes/tables/class.ilFormATestParticipantsTableGUI.php index be6eb964b3c6f4133d2d944fcd9294178745770e..bccedeb65ca7e668fab03957b616b488a117927e 100644 --- a/classes/tables/class.ilFormATestParticipantsTableGUI.php +++ b/classes/tables/class.ilFormATestParticipantsTableGUI.php @@ -8,93 +8,87 @@ require_once "abstract.ilXTSFTableGUI.php"; * Date: 07.10.13 * Time: 13:49 * @author Thomas Joußen - */ + */ class ilFormATestParticipantsTableGUI extends ilXTSFTableGUI { + public function __construct($controller, $plugin, $action = "") + { + $this->setId("xtsf_participants_" . $controller->object->getId()); - public function __construct($controller, $plugin, $action = "") - { - $this->setId("xtsf_participants_" . $controller->object->getId()); + parent::__construct($controller, $action, $plugin); - parent::__construct($controller, $action, $plugin); + $this->createTable(); + } - $this->createTable(); - } + private function createTable() + { + $this->setTitle($this->plugin->txt("participants")); - private function createTable() - { - $this->setTitle($this->plugin->txt("participants")); + $this->setFormName('participants'); + $this->setStyle('table', 'fullwidth'); + $this->setDefaultOrderField("title"); + $this->setDefaultOrderDirection("ASC"); - $this->setFormName('participants'); - $this->setStyle('table', 'fullwidth'); - $this->setDefaultOrderField("title"); - $this->setDefaultOrderDirection("ASC"); + $this->addColumn('', '', '1%', true); + $this->addColumn($this->lng->txt("username"), 'username', ''); + $this->addColumn($this->lng->txt("name"), 'name', ''); + $this->addColumn($this->plugin->txt("test_passes"), 'test_passes', ''); + $this->addColumn($this->plugin->txt("last_access"), 'last_access', ''); + $this->addColumn('', '', '15%', true); - $this->addColumn('', '', '1%', true); - $this->addColumn($this->lng->txt("username"), 'username', ''); - $this->addColumn($this->lng->txt("name"), 'name', ''); - $this->addColumn($this->plugin->txt("test_passes"), 'test_passes', ''); - $this->addColumn($this->plugin->txt("last_access"), 'last_access', ''); - $this->addColumn('', '', '15%', true); + $this->setRowTemplate("tpl.il_xtsf_participants_row.html", $this->parent_obj->plugin->getDirectory()); - $this->setRowTemplate("tpl.il_xtsf_participants_row.html", $this->parent_obj->plugin->getDirectory()); + $this->setFormAction($this->ctrl->getFormAction($this->parent_obj)); - $this->setFormAction($this->ctrl->getFormAction($this->parent_obj)); + $this->setSelectAllCheckbox("s_id"); + $this->disable("sort"); + $this->enable('header'); + } - $this->setSelectAllCheckbox("s_id"); - $this->disable("sort"); - $this->enable('header'); - } + /** + * Return an array of all static (always visible) data fields in a row. + * For each key there has to be a variable name VAL_ in your defined row template. + * Example: + * return array('title', 'checkbox'); + * There have to be two template variables: VAL_TITLE and VAL_CHECKBOX + * @return array + */ + protected function getStaticData() + { + return array( + "id", + "session_id", + 'title', + "login", + "name", + "passes", + "tstamp", + "show_results" + ); + } - /** - * Return an array of all static (always visible) data fields in a row. - * For each key there has to be a variable name VAL_ in your defined row template. - * Example: - * return array('title', 'checkbox'); - * There have to be two template variables: VAL_TITLE and VAL_CHECKBOX - * @return array - */ - protected function getStaticData() - { - return array( - "id", - "session_id", - 'title', - "login", - "name", - "passes", - "tstamp", - "show_results" - ); - } - - /** - * Define a final formatting for a cell value - * - * @param mixed $column - * @param array $row - * - * @return mixed - */ - protected function formatCellValue($column, array $row) - { - require_once "Services/User/classes/class.ilUserUtil.php"; - - if ($column == "tstamp" || $column == "created") - { - $row["tstamp"] = ilDatePresentation::formatDate(new ilDateTime($row[$column], IL_CAL_UNIX)); - } - if($column == "name") - { - $row["name"] = ilUserUtil::getNamePresentation($row["usr_id"]); - } - if($column == "show_results") - { - $this->ctrl->setParameter($this->parent_obj, "active_id", $row["active_id"]); - $href = $this->ctrl->getLinkTarget($this->parent_obj, "ilFormATestParticipantsGUI.showUserResults"); - $this->ctrl->setParameter($this->parent_obj, "active_id", ""); - $row["show_results"] = ''.$this->plugin->txt("show_user_results").''; - } - return parent::formatCellValue($column, $row); - } + /** + * Define a final formatting for a cell value + * + * @param mixed $column + * @param array $row + * + * @return mixed + */ + protected function formatCellValue($column, array $row) + { + if ($column == "tstamp" || $column == "created") { + $row["tstamp"] = ilDatePresentation::formatDate(new ilDateTime($row[$column], IL_CAL_UNIX)); + } + if ($column == "name") { + $row["name"] = ilUserUtil::getNamePresentation($row["usr_id"]); + } + if ($column == "show_results") { + $this->ctrl->setParameter($this->parent_obj, "active_id", $row["active_id"]); + $href = $this->ctrl->getLinkTarget($this->parent_obj, "ilFormATestParticipantsGUI.showUserResults"); + $this->ctrl->setParameter($this->parent_obj, "active_id", ""); + $row["show_results"] = '' . $this->plugin->txt("show_user_results") . ''; + } + return parent::formatCellValue($column, $row); + } } diff --git a/classes/tables/class.ilFormATestResultsTableGUI.php b/classes/tables/class.ilFormATestResultsTableGUI.php index cb3a99c460d0975aa865899e2ec9e127f5f3c409..78a4f817e57c4c414fa6a271034624d64e95bb32 100644 --- a/classes/tables/class.ilFormATestResultsTableGUI.php +++ b/classes/tables/class.ilFormATestResultsTableGUI.php @@ -1,7 +1,6 @@ - */ + */ class ilFormATestResultsTableGUI extends ilXTSFTableGUI { - /** - * @var string - */ - protected $detailed_action = "ilFormATestParticipantsGUI.showUserDetails"; - - public function __construct($controller, $plugin, $action="") - { - $this->setId("xtsf_results"); - - parent::__construct($controller, $action, $plugin); - - $this->createTable(); - } - - public function createTable() - { - $this->setFormName('results'); - $this->setStyle('table', 'fullwidth'); - $this->setDefaultOrderField("title"); - $this->setDefaultOrderDirection("ASC"); - - $this->addColumn('', '', '1%', true); - $this->addColumn($this->plugin->txt("pass_title"), 'pass_title', ''); - $this->addColumn($this->plugin->txt("start_date_title"), 'start_date_title', ''); - $this->addColumn($this->plugin->txt("end_date_title"), 'end_date_title', ''); - $this->addColumn($this->plugin->txt("status_title"), 'status_title', ''); - $this->addColumn($this->plugin->txt("steps_title"), 'steps_title', ''); - $this->addColumn($this->plugin->txt("reached_points_title"), 'reached_points_title', ''); - $this->addColumn($this->plugin->txt("percentage_title"), 'percentage_title', ''); - $this->addColumn('', '', '15%', true); - - $this->setPrefix('p_id'); - $this->setRowTemplate("tpl.il_xtsf_results_row.html", $this->parent_obj->plugin->getDirectory()); - - $this->setFormAction($this->ctrl->getFormAction($this->parent_obj)); - - $this->disable("sort"); - $this->enable('header'); - } - - /** - * Return an array of all static (always visible) data fields in a row. - * For each key there has to be a variable name VAL_ in your defined row template. - * Example: - * return array('title', 'checkbox'); - * There have to be two template variables: VAL_TITLE and VAL_CHECKBOX - * @return array - */ - protected function getStaticData() - { - return array( - "pass", - 'start_date', - "end_date", - "status", - "answered_questions", - "reached_points", - "percentage", - "actions", - "scored" - ); - } - - protected function prepareData(array &$data) - { - parent::prepareData($data); - - if(is_array($data)) - $data[\count($data)-1]["scored"] = "⊗"; - } - - - /** - * Define a final formatting for a cell value - * - * @param mixed $column - * @param array $row - * - * @return mixed - */ - protected function formatCellValue($column, array $row) - { - require_once "Services/User/classes/class.ilUserUtil.php"; - - if($column == "pass") - { - $row["pass"] = $row["pass"]+1; - } - if ($column == "tstamp" || $column == "start_date" || $column == "end_date") - { - $row[$column] = ilDatePresentation::formatDate(new ilDateTime($row[$column], IL_CAL_UNIX)); - } - if($column == "reached_points") - { - $row["reached_points"] = sprintf($this->plugin->txt("points_of"), $row["points"], $row["max_points"]); - } - if($column == "percentage") - { - $row["percentage"] = 0; - if($row["max_points"]>0) - { - $row["percentage"] = number_format(($row["points"] / $row["max_points"])*100, 2); - } - $row["percentage"] .= "%"; - } - if($column == "status") - { - $row["status"] = $this->plugin->txt("status_".$row["status"]); - } - if($column == "actions") - { - $action = new ilAdvancedSelectionListGUI(); - $action->setId('asl_'.$row["session_id"]); - $action->setListTitle($this->lng->txt('actions')); - - $this->ctrl->setParameter($this->parent_obj, "session_id", $row["session_id"]); - $action->addItem($this->plugin->txt("details"),"", $this->ctrl->getLinkTarget($this->parent_obj, $this->detailed_action)); - $this->ctrl->setParameter($this->parent_obj, "session_id", ""); - - $row["actions"] = $action->getHTML(); - } - - return parent::formatCellValue($column, $row); - } - - /** - * @param string $detailed_action - */ - public function setDetailedAction($detailed_action) - { - if($detailed_action != "") - { - $this->detailed_action = $detailed_action; - } - } + /** + * @var string + */ + protected $detailed_action = "ilFormATestParticipantsGUI.showUserDetails"; + + public function __construct($controller, $plugin, $action = "") + { + $this->setId("xtsf_results"); + + parent::__construct($controller, $action, $plugin); + + $this->createTable(); + } + + public function createTable() + { + $this->setFormName('results'); + $this->setStyle('table', 'fullwidth'); + $this->setDefaultOrderField("title"); + $this->setDefaultOrderDirection("ASC"); + + $this->addColumn('', '', '1%', true); + $this->addColumn($this->plugin->txt("pass_title"), 'pass_title', ''); + $this->addColumn($this->plugin->txt("start_date_title"), 'start_date_title', ''); + $this->addColumn($this->plugin->txt("end_date_title"), 'end_date_title', ''); + $this->addColumn($this->plugin->txt("status_title"), 'status_title', ''); + $this->addColumn($this->plugin->txt("steps_title"), 'steps_title', ''); + $this->addColumn($this->plugin->txt("reached_points_title"), 'reached_points_title', ''); + $this->addColumn($this->plugin->txt("percentage_title"), 'percentage_title', ''); + $this->addColumn('', '', '15%', true); + + $this->setPrefix('p_id'); + $this->setRowTemplate("tpl.il_xtsf_results_row.html", $this->parent_obj->plugin->getDirectory()); + + $this->setFormAction($this->ctrl->getFormAction($this->parent_obj)); + + $this->disable("sort"); + $this->enable('header'); + } + + /** + * Return an array of all static (always visible) data fields in a row. + * For each key there has to be a variable name VAL_ in your defined row template. + * Example: + * return array('title', 'checkbox'); + * There have to be two template variables: VAL_TITLE and VAL_CHECKBOX + * @return array + */ + protected function getStaticData() + { + return array( + "pass", + 'start_date', + "end_date", + "status", + "answered_questions", + "reached_points", + "percentage", + "actions", + "scored" + ); + } + + protected function prepareData(array &$data) + { + parent::prepareData($data); + + if (is_array($data)) { + $data[\count($data) - 1]["scored"] = "⊗"; + } + } + + + /** + * Define a final formatting for a cell value + * + * @param mixed $column + * @param array $row + * + * @return mixed + */ + protected function formatCellValue($column, array $row) + { + if ($column == "pass") { + $row["pass"] = $row["pass"] + 1; + } + if ($column == "tstamp" || $column == "start_date" || $column == "end_date") { + $row[$column] = ilDatePresentation::formatDate(new ilDateTime($row[$column], IL_CAL_UNIX)); + } + if ($column == "reached_points") { + $row["reached_points"] = sprintf($this->plugin->txt("points_of"), $row["points"], $row["max_points"]); + } + if ($column == "percentage") { + $row["percentage"] = 0; + if ($row["max_points"] > 0) { + $row["percentage"] = number_format(($row["points"] / $row["max_points"]) * 100, 2); + } + $row["percentage"] .= "%"; + } + if ($column == "status") { + $row["status"] = $this->plugin->txt("status_" . $row["status"]); + } + if ($column == "actions") { + $action = new ilAdvancedSelectionListGUI(); + $action->setId('asl_' . $row["session_id"]); + $action->setListTitle($this->lng->txt('actions')); + + $this->ctrl->setParameter($this->parent_obj, "session_id", $row["session_id"]); + $action->addItem($this->plugin->txt("details"), "", $this->ctrl->getLinkTarget($this->parent_obj, $this->detailed_action)); + $this->ctrl->setParameter($this->parent_obj, "session_id", ""); + + $row["actions"] = $action->getHTML(); + } + + return parent::formatCellValue($column, $row); + } + + /** + * @param string $detailed_action + */ + public function setDetailedAction($detailed_action) + { + if ($detailed_action != "") { + $this->detailed_action = $detailed_action; + } + } } - \ No newline at end of file diff --git a/classes/tables/class.ilFormATestSetResultTableGUI.php b/classes/tables/class.ilFormATestSetResultTableGUI.php index e0ef5c3a6f38a8c111a22b39d9584f4cc5e54fe8..f13d509be4e56f24f98d3af6189435550e8cdf71 100644 --- a/classes/tables/class.ilFormATestSetResultTableGUI.php +++ b/classes/tables/class.ilFormATestSetResultTableGUI.php @@ -1,7 +1,6 @@ setId("xtsf_set_results"); - - parent::__construct($controller, "", $plugin); - - $this->render_optional = $render_optional; - $this->modus = $modus; - $this->createTable(); - } - - public function createTable() - { - $this->setFormName('set_results'); - $this->setStyle('table', 'fullwidth'); - $this->setDefaultOrderField("header_step"); - $this->setDefaultOrderDirection("ASC"); - - $this->addColumn($this->plugin->txt("header_step"), 'header_step', '1%'); - - if($this->modus == null || $this->modus != ilFormATestResultOuputGUI::MODUS_PARTICIPANTS) - { - $this->addColumn($this->plugin->txt("header_path"), 'header_path', '25%'); - $this->addColumn($this->plugin->txt("header_question"), 'header_question', '25%'); - } - - - if($this->render_optional) - { - $this->optionalColumns = array( - "max_points" => "max_points", - "reached_points" => "reached_points", - "percentage" => "percentage" - ); - $this->visibleOptionalColumns = array( - "max_points" => true, - "reached_points" => true, - "percentage" => true - ); - - $this->addColumn($this->plugin->txt("max_points_title"), 'max_points_title', ''); - $this->addColumn($this->plugin->txt("reached_points_title"), 'reached_points_title', ''); - $this->addColumn($this->plugin->txt("percentage_title"), 'percentage_title', ''); - } - - $this->setPrefix('s_id'); - $this->setRowTemplate("tpl.il_xtsf_set_result_row.html", $this->parent_obj->plugin->getDirectory()); - - $this->setFormAction($this->ctrl->getFormAction($this->parent_obj)); - - $this->disable("sort"); - $this->enable('header'); - } - - /** - * Return an array of all static (always visible) data fields in a row. - * For each key there has to be a variable name VAL_ in your defined row template. - * Example: - * return array('title', 'checkbox'); - * There have to be two template variables: VAL_TITLE and VAL_CHECKBOX - * @return array - */ - protected function getStaticData() - { - $data = array( - "step", - ); - - if($this->modus == null || $this->modus != ilFormATestResultOuputGUI::MODUS_PARTICIPANTS) - { - $data[] = "question_title"; - $data[] = "path_title"; - } - - return $data; - } - - protected function fillRow($row) - { - $this->prepareRow($row); - - if($this->modus == null) - { - $this->modus = "author"; - } - - if($this->tpl->blockExists($this->modus."_optional_column")) - { - $this->tpl->setCurrentBlock($this->modus.'_optional_column'); - foreach($this->optionalColumns as $index => $definition) - { - if(!$this->isColumnVisible($index)) - { - continue; - } - - $value = $this->formatCellValue($index, $row); - if($row["step"] == 'Total') - { - $row["step"] = ''.$this->plugin->txt("total").""; - } - if((string)$value === '') - { - $this->tpl->touchBlock($this->modus.'_optional_column'); - } - else - { - $this->tpl->setVariable('OPTIONAL_COLUMN_VAL_' . strtoupper($index), $value); - } - } - $this->tpl->parseCurrentBlock(); - } - - $this->tpl->setCurrentBlock($this->modus); - - foreach($this->getStaticData() as $column) - { - $value = $this->formatCellValue($column, $row); - $this->tpl->setVariable('VAL_' . strtoupper($column), $value); - } - - $this->tpl->parseCurrentBlock(); - } - - protected function prepareData(array &$data) - { - $total = array( - "step" => "Total", - "max_points" => $this->total_max_points, - "reached_points" => 0, - "percentage" => 0, - ); - - foreach($data as $row) - { - $total["reached_points"] += $row["reached_points"]; - } - - if($total["max_points"]> 0) - { - $total["percentage"] = number_format(($total["reached_points"]/$total["max_points"])*100,2); - } - $data[] = $total; - } - - - /** - * Define a final formatting for a cell value - * - * @param mixed $column - * @param array $row - * - * @return mixed - */ - protected function formatCellValue($column, array $row) - { - if ($column == "question_title" && $row["step"] != "Total") - { - $row[$column] = "(Q". $row["question_index"] . ") " . $row[$column]; - } - if($column == "percentage") - { - $row["percentage"] = 0; - if($row["max_points"] >0) - { - $row["percentage"] = number_format(($row["reached_points"] / $row["max_points"])*100, 2); - } - } - - if($row["step"] == "Total") - { - $row[$column] = "". $row[$column]. ""; - } - - return parent::formatCellValue($column, $row); - } - - /** - * @param int $total_max_points - */ - public function setTotalMaxPoints($total_max_points) - { - $this->total_max_points = $total_max_points; - } + /** + * @var bool + */ + protected $render_optional; + + /** + * @var int + */ + protected $total_max_points; + + /** + * @var null|string + */ + protected $modus = null; + + public function __construct($controller, $plugin, $render_optional = false, $modus = null) + { + $this->setId("xtsf_set_results"); + + parent::__construct($controller, "", $plugin); + + $this->render_optional = $render_optional; + $this->modus = $modus; + $this->createTable(); + } + + public function createTable() + { + $this->setFormName('set_results'); + $this->setStyle('table', 'fullwidth'); + $this->setDefaultOrderField("header_step"); + $this->setDefaultOrderDirection("ASC"); + + $this->addColumn($this->plugin->txt("header_step"), 'header_step', '1%'); + + if ($this->modus == null || $this->modus != ilFormATestResultOuputGUI::MODUS_PARTICIPANTS) { + $this->addColumn($this->plugin->txt("header_path"), 'header_path', '25%'); + $this->addColumn($this->plugin->txt("header_question"), 'header_question', '25%'); + } + + + if ($this->render_optional) { + $this->optionalColumns = array( + "max_points" => "max_points", + "reached_points" => "reached_points", + "percentage" => "percentage" + ); + $this->visibleOptionalColumns = array( + "max_points" => true, + "reached_points" => true, + "percentage" => true + ); + + $this->addColumn($this->plugin->txt("max_points_title"), 'max_points_title', ''); + $this->addColumn($this->plugin->txt("reached_points_title"), 'reached_points_title', ''); + $this->addColumn($this->plugin->txt("percentage_title"), 'percentage_title', ''); + } + + $this->setPrefix('s_id'); + $this->setRowTemplate("tpl.il_xtsf_set_result_row.html", $this->parent_obj->plugin->getDirectory()); + + $this->setFormAction($this->ctrl->getFormAction($this->parent_obj)); + + $this->disable("sort"); + $this->enable('header'); + } + + /** + * Return an array of all static (always visible) data fields in a row. + * For each key there has to be a variable name VAL_ in your defined row template. + * Example: + * return array('title', 'checkbox'); + * There have to be two template variables: VAL_TITLE and VAL_CHECKBOX + * @return array + */ + protected function getStaticData() + { + $data = array( + "step", + ); + + if ($this->modus == null || $this->modus != ilFormATestResultOuputGUI::MODUS_PARTICIPANTS) { + $data[] = "question_title"; + $data[] = "path_title"; + } + + return $data; + } + + protected function fillRow($row) + { + $this->prepareRow($row); + + if ($this->modus == null) { + $this->modus = "author"; + } + + if ($this->tpl->blockExists($this->modus . "_optional_column")) { + $this->tpl->setCurrentBlock($this->modus . '_optional_column'); + foreach ($this->optionalColumns as $index => $definition) { + if (!$this->isColumnVisible($index)) { + continue; + } + + $value = $this->formatCellValue($index, $row); + if ($row["step"] == 'Total') { + $row["step"] = '' . $this->plugin->txt("total") . ""; + } + if ((string) $value === '') { + $this->tpl->touchBlock($this->modus . '_optional_column'); + } else { + $this->tpl->setVariable('OPTIONAL_COLUMN_VAL_' . strtoupper($index), $value); + } + } + $this->tpl->parseCurrentBlock(); + } + + $this->tpl->setCurrentBlock($this->modus); + + foreach ($this->getStaticData() as $column) { + $value = $this->formatCellValue($column, $row); + $this->tpl->setVariable('VAL_' . strtoupper($column), $value); + } + + $this->tpl->parseCurrentBlock(); + } + + protected function prepareData(array &$data) + { + $total = array( + "step" => "Total", + "max_points" => $this->total_max_points, + "reached_points" => 0, + "percentage" => 0, + ); + + foreach ($data as $row) { + $total["reached_points"] += $row["reached_points"]; + } + + if ($total["max_points"] > 0) { + $total["percentage"] = number_format(($total["reached_points"] / $total["max_points"]) * 100, 2); + } + $data[] = $total; + } + + + /** + * Define a final formatting for a cell value + * + * @param mixed $column + * @param array $row + * + * @return mixed + */ + protected function formatCellValue($column, array $row) + { + if ($column == "question_title" && $row["step"] != "Total") { + $row[$column] = "(Q" . $row["question_index"] . ") " . $row[$column]; + } + if ($column == "percentage") { + $row["percentage"] = 0; + if ($row["max_points"] > 0) { + $row["percentage"] = number_format(($row["reached_points"] / $row["max_points"]) * 100, 2); + } + } + + if ($row["step"] == "Total") { + $row[$column] = "" . $row[$column] . ""; + } + + return parent::formatCellValue($column, $row); + } + + /** + * @param int $total_max_points + */ + public function setTotalMaxPoints($total_max_points) + { + $this->total_max_points = $total_max_points; + } } - \ No newline at end of file diff --git a/classes/tables/class.ilFormATestSetsTableGUI.php b/classes/tables/class.ilFormATestSetsTableGUI.php index a8bc69a7ccdaedaa6bc8ea1858bc92c1a237f718..35f3334f8625eec4624e90152758385aaf8afbf3 100644 --- a/classes/tables/class.ilFormATestSetsTableGUI.php +++ b/classes/tables/class.ilFormATestSetsTableGUI.php @@ -1,7 +1,6 @@ - */ + */ class ilFormATestSetsTableGUI extends ilXTSFTableGUI { - /** - * @var bool - */ - protected $has_participants = false; - - /** - * @var bool - */ - protected $show_sorting = false; - - public function __construct($controller, $plugin, $action = "", $show_sorting = false, $has_participants = false) - { - global $DIC; - - $this->ctrl = $DIC->ctrl(); - $this->has_participants = $has_participants; - $this->show_sorting = $show_sorting; - - $this->setId('xtsf_sets_' . $plugin->getId() . '_' . ($show_sorting ? 'list' : 'browsw')); - parent::__construct($controller, $action, $plugin); - - $this->createTable(); - } - - private function createTable() - { - $this->setTitle($this->plugin->txt("setsbrowser")); - - $this->setFormName('setsbrowser'); - $this->setStyle('table', 'fullwidth'); - $this->setDefaultOrderField("title"); - $this->setDefaultOrderDirection("ASC"); - - if(!$this->has_participants) - { - $this->addColumn('', '', '1%', true); - } - - if($this->show_sorting) - { - $this->addColumn($this->plugin->txt("sorting"), 'sorting', '5%'); - $this->setDefaultOrderField("sorting"); - $this->setDefaultOrderDirection("DESC"); - } - - $this->addColumn($this->lng->txt("title"), 'title', '25%'); - $this->addColumn($this->plugin->txt('set_id'), 'id', '5%'); - $this->addColumn($this->lng->txt("description"), 'description', '55%'); - - if(!$this->has_participants) - { - $this->setSelectAllCheckbox('s_id'); - } - - $this->setRowTemplate("tpl.il_xtsf_qs_row.html", $this->parent_obj->plugin->getDirectory()); - - $this->setFormAction($this->ctrl->getFormAction($this->parent_obj)); - - $this->disable("sort"); - $this->enable('header'); - } - - protected function prepareRow(array &$row) - { - if(!$this->has_participants) - { - $row['checkbox'] = ilUtil::formCheckbox(false, 's_id[]', $row['id']); - } - if($this->show_sorting) - { - $sort = new ilNumberInputGUI('', 'sorting[]'); - $sort->allowDecimals(false); - $sort->setSize(3); - $sort->setValue($row['sorting']); - if($this->has_participants) - { - $sort->setDisabled(true); - } - $row['sorting'] = $sort->render(); - } - else - { - unset($row['sorting']); - } - } - - /** - * Return an array of all static (always visible) data fields in a row. - * For each key there has to be a variable name VAL_ in your defined row template. - * Example: - * return array('title', 'checkbox'); - * There have to be two template variables: VAL_TITLE and VAL_CHECKBOX - * @return array - */ - protected function getStaticData() - { - $static_columns = array( - 'checkbox', - 'id', - 'title', - 'description', - ); - - if($this->show_sorting) - { - $static_columns[] = 'sorting'; - } - - return $static_columns; - } - - /** - * Define a final formatting for a cell value - * - * @param mixed $column - * @param array $row - * - * @return mixed - */ - protected function formatCellValue($column, array $row) - { - if ($column == "tstamp" || $column == "created") - { - return ilDatePresentation::formatDate(new ilDateTime($row[$column], IL_CAL_UNIX)); - } - if($column == "title" && !$this->has_participants) - { - $this->ctrl->setParameterByClass("ilObjFormATestQuestionSetPoolGUI", "set_id", $row["id"]); - $href = $this->ctrl->getLinkTargetByClass("ilObjFormATestQuestionSetPoolGUI", "ilQuestionSetPoolPathsGUI.listPaths"); - $this->ctrl->setParameterByClass("ilObjFormATestQuestionSetPoolGUI", "set_id", ""); - - $row[$column] = ''.$row[$column] . ''; - } - return parent::formatCellValue($column, $row); - } + /** + * @var bool + */ + protected $has_participants = false; + + /** + * @var bool + */ + protected $show_sorting = false; + + public function __construct($controller, $plugin, $action = "", $show_sorting = false, $has_participants = false) + { + global $DIC; + + $this->ctrl = $DIC->ctrl(); + $this->has_participants = $has_participants; + $this->show_sorting = $show_sorting; + + $this->setId('xtsf_sets_' . $plugin->getId() . '_' . ($show_sorting ? 'list' : 'browsw')); + parent::__construct($controller, $action, $plugin); + + $this->createTable(); + } + + private function createTable() + { + $this->setTitle($this->plugin->txt("setsbrowser")); + + $this->setFormName('setsbrowser'); + $this->setStyle('table', 'fullwidth'); + $this->setDefaultOrderField("title"); + $this->setDefaultOrderDirection("ASC"); + + if (!$this->has_participants) { + $this->addColumn('', '', '1%', true); + } + + if ($this->show_sorting) { + $this->addColumn($this->plugin->txt("sorting"), 'sorting', '5%'); + $this->setDefaultOrderField("sorting"); + $this->setDefaultOrderDirection("DESC"); + } + + $this->addColumn($this->lng->txt("title"), 'title', '25%'); + $this->addColumn($this->plugin->txt('set_id'), 'id', '5%'); + $this->addColumn($this->lng->txt("description"), 'description', '55%'); + + if (!$this->has_participants) { + $this->setSelectAllCheckbox('s_id'); + } + + $this->setRowTemplate("tpl.il_xtsf_qs_row.html", $this->parent_obj->plugin->getDirectory()); + + $this->setFormAction($this->ctrl->getFormAction($this->parent_obj)); + + $this->disable("sort"); + $this->enable('header'); + } + + protected function prepareRow(array &$row) + { + if (!$this->has_participants) { + $row['checkbox'] = ilUtil::formCheckbox(false, 's_id[]', $row['id']); + } + if ($this->show_sorting) { + $sort = new ilNumberInputGUI('', 'sorting[]'); + $sort->allowDecimals(false); + $sort->setSize(3); + $sort->setValue($row['sorting']); + if ($this->has_participants) { + $sort->setDisabled(true); + } + $row['sorting'] = $sort->render(); + } else { + unset($row['sorting']); + } + } + + /** + * Return an array of all static (always visible) data fields in a row. + * For each key there has to be a variable name VAL_ in your defined row template. + * Example: + * return array('title', 'checkbox'); + * There have to be two template variables: VAL_TITLE and VAL_CHECKBOX + * @return array + */ + protected function getStaticData() + { + $static_columns = array( + 'checkbox', + 'id', + 'title', + 'description', + ); + + if ($this->show_sorting) { + $static_columns[] = 'sorting'; + } + + return $static_columns; + } + + /** + * Define a final formatting for a cell value + * + * @param mixed $column + * @param array $row + * + * @return mixed + */ + protected function formatCellValue($column, array $row) + { + if ($column == "tstamp" || $column == "created") { + return ilDatePresentation::formatDate(new ilDateTime($row[$column], IL_CAL_UNIX)); + } + if ($column == "title" && !$this->has_participants) { + $this->ctrl->setParameterByClass("ilObjFormATestQuestionSetPoolGUI", "set_id", $row["id"]); + $href = $this->ctrl->getLinkTargetByClass("ilObjFormATestQuestionSetPoolGUI", "ilQuestionSetPoolPathsGUI.listPaths"); + $this->ctrl->setParameterByClass("ilObjFormATestQuestionSetPoolGUI", "set_id", ""); + + $row[$column] = '' . $row[$column] . ''; + } + return parent::formatCellValue($column, $row); + } } diff --git a/classes/utils/abstract.ilFormATestConditionEvaluation.php b/classes/utils/abstract.ilFormATestConditionEvaluation.php index 512e7d63dca35532177a4676430b2deb21a6f718..d5892320353e07bd219031f14637523dc3386901 100644 --- a/classes/utils/abstract.ilFormATestConditionEvaluation.php +++ b/classes/utils/abstract.ilFormATestConditionEvaluation.php @@ -14,393 +14,340 @@ require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/ * Date: 06.01.14 * Time: 16:43 * @author Thomas Joußen - */ + */ abstract class ilFormATestConditionEvaluation implements ilConditionEvaluationSubject, ilFormATestFeedbackConstants { - /** - * @var ilConditionEvaluationObserver[] - */ - public static $observers = array(); - - /** - * @var array - */ - public static $state = array(); - - /** - * @var array - */ - public static $fb = array(); - - /** - * @param ilQuestionSetPoolNode $current_node - * @param ilFormATestSession $session - * - * @return null|ilQuestionSetPoolNode - */ - public static function getNextNode($current_node, $session) - { - $evaluator = self::initializeEvaluator($current_node->getPath()->getSet()->getId(), $session); - self::resetFeedback(); - - if(ilFormATestConditionEvaluation::isConditionTrue($evaluator, $current_node->getInitialCondition())) - { - $session->updateCondition($current_node->getId(), $current_node->getInitialCondition()); - // Ausgangsbedingung, Feedback true - self::addFeedback($current_node, $current_node->getIndex(), $session, ilFormATestFeedbackConstants::INITIAL_FEEDBACK_TRUE); - self::notify(); - - return $current_node->getPath()->getNodes()->getNextNode($current_node); - } - else - { - // Ausgangsbedingung,Feedback false - self::addFeedback($current_node, $current_node->getIndex(), $session, ilFormATestFeedbackConstants::INITIAL_FEEDBACK_FALSE); - //self::notify(); - - $jump_conditions = $current_node->getJumpConditionList()->getData(); - foreach($jump_conditions as $item) - { - $condition = new ilQuestionSetPoolJumpCondition($item["id"]); - $condition->read(); - - if(ilFormATestConditionEvaluation::isConditionTrue($evaluator, $condition->getJumpCondition())) - { - $session->updateCondition($current_node->getId(), $condition->getJumpCondition(), $condition->getId()); - if(!$session->reachedDeadlock()) - { - $deleteIndex = null; - // Sprungbedingung,Feedback true - $nextNode = null; - - if($condition->getQuestion() != null) - { - $nextNode = $current_node->getPath()->getNodes()->getNodeByQuestionId($condition->getQuestion()->getId()); - - $node_index = self::getAnchorIndex($nextNode); - - // vorher - $deleteIndex = $node_index; - self::addFeedback($current_node, $node_index, $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE, $condition->getId()); - self::updateNodeIndex($node_index); - //self::notify(); - } - else - { - // WEnn das Set abgebrochen wird - self::addFeedback($current_node, $current_node->getIndex(), $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE, $condition->getId()); - self::updateNodeIndex($current_node->getIndex()); - //self::notify(); - } - - if($deleteIndex !== null) - { - self::deleteFeedback($deleteIndex, $session->getSetId(), $session->getSessionId()); - } - self::notify(); - return $nextNode; - } - else - { - // Sprungbedingung, Feedback no_jmp - self::addFeedback($current_node, $current_node->getIndex(), $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE_JUMP, $condition->getId()); - //self::notify(); - - $session->unsetJump(); - $session->markSolutionToFixate(); - } - } - else - { - // Sprungbedingung, Feedback false - self::addFeedback($current_node, $current_node->getIndex(), $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_FALSE, $condition->getId()); - //self::notify(); - } - } - return self::doPathShift($current_node, $session, $evaluator); - } - } - - /** - * @param CompositeEvaluator $evaluator - * @param string $condition - * - * @return bool - */ - public static function isConditionTrue($evaluator, $condition) - { - if(trim($condition) == "") - { - return false; - } - - $parser = new ConditionParser(); - $composite = $parser->parse($condition); - - return $evaluator->evaluate($composite); - } - - protected static function initializeEvaluator($set_id, $session) - { - $provider = new ilParserQuestionProvider($set_id); - $evaluator = new CompositeEvaluator($provider, $session); - - return $evaluator; - } - - /** - * @param ilQuestionSetPoolNode $current_node - * @param ilFormATestSession $session - * @param CompositeEvaluator $evaluator - * - * @return ilQuestionSetPoolNode|null - */ - protected static function doPathShift($current_node, $session, $evaluator) - { - $paths = $current_node->getPath()->getSet()->getPathList()->getData(); - foreach($paths as $path) - { - if($path["id"] != $current_node->getPath()->getId()) - { - $reset_feedback = false; - - $path = new ilQuestionSetPoolPath($path["id"]); - $path->read(); - - if($path->isEqualsUntilIndex($current_node->getPath(), $current_node->getIndex())) - { - $node = $path->getNodes()->getNodeByQuestionId($current_node->getQuestion()->getId()); - - if($node != null && self::arePreviousConditionsValid($evaluator, $path, $node)) - { - self::resetFeedback(true); - $reset_feedback = true; - - if(ilFormATestConditionEvaluation::isConditionTrue($evaluator, $node->getInitialCondition())) - { - $session->updateCondition($node->getId(), $node->getInitialCondition()); - - self::addFeedback($node, $node->getIndex(), $session, ilFormATestFeedbackConstants::INITIAL_FEEDBACK_TRUE); - self::updateNodeIndex($node->getIndex()); - self::notify(); - - return $node->getPath()->getNodes()->getNextNode($node); - } - else - { - self::addFeedback($node, $node->getIndex(), $session, ilFormATestFeedbackConstants::INITIAL_FEEDBACK_FALSE); - self::updateNodeIndex($node->getIndex()); - } - } - - $jump_conditions = $node->getJumpConditionList()->getData(); - foreach($jump_conditions as $item) - { - $condition = new ilQuestionSetPoolJumpCondition($item["id"]); - $condition->read(); - - if(self::arePreviousConditionsValid($evaluator, $path, $node)) - { - if(!$reset_feedback) - { - self::resetFeedback(true); - $reset_feedback = true; - } - if(ilFormATestConditionEvaluation::isConditionTrue($evaluator, $condition->getJumpCondition())) - { - $session->updateCondition($node->getId(), $condition->getJumpCondition(), $condition->getId()); - if(!$session->reachedDeadlock()) - { - $deleteIndex = null; - $nextNode = null; - if($condition->getQuestion() != null) - { - $nextNode = $node->getPath()->getNodes()->getNodeByQuestionId($condition->getQuestion()->getId()); - - $node_index = self::getAnchorIndex($nextNode); - $deleteIndex = $node_index; - - self::addFeedback($node, $node_index, $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE, $condition->getId()); - self::updateNodeIndex($node_index); - } - else - { - self::addFeedback($node, $node->getIndex(), $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE, $condition->getId()); - self::updateNodeIndex($node->getIndex()); - } - - if($deleteIndex !== null) - { - self::deleteFeedback($deleteIndex, $session->getSetId(), $session->getSessionId()); - } - self::notify(); - return $nextNode; - } - else - { - self::addFeedback($node, $node->getIndex(), $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE_JUMP, $condition->getId()); - self::updateNodeIndex($node->getIndex()); - - $session->unsetJump(); - $session->markSolutionToFixate(); - } - } - else - { - self::addFeedback($node, $node->getIndex(), $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_FALSE, $condition->getId()); - self::updateNodeIndex($node->getIndex()); - } - } - } - } - } - } - self::notify(); - return null; - } - - /** - * @param CompositeEvaluator $evaluator - * @param ilQuestionSetPoolPath $path - * @param ilQuestionSetPoolNode $node - * - * @return bool - */ - protected static function arePreviousConditionsValid($evaluator, $path, $node) - { - $nodes = $path->getNodes()->getData(); - - foreach($nodes as $prev_node) - { - if($prev_node["node_index"] >= $node->getIndex()) - { - break; - } - - if(!ilFormATestConditionEvaluation::isConditionTrue($evaluator,$prev_node["initial_condition"])) - { - return false; - } - } - - return true; - } - - /** - * @param ilConditionEvaluationObserver $observer - * @throws InvalidArgumentException - */ - public static function attach(ilConditionEvaluationObserver $observer) - { - $key = array_search($observer, self::$observers); - if($key) - { - throw new InvalidArgumentException('Observer already attached to subject.'); - } - self::$observers[] = $observer; - } - - /** - * @param ilConditionEvaluationObserver $observer - * @throws InvalidArgumentException - */ - public static function detach(ilConditionEvaluationObserver $observer) - { - $key = array_search($observer, self::$observers, true); - if($key === false) - { - throw new InvalidArgumentException('Observer not found in collection.'); - } - unset(self::$observers[$key]); - } - - public static function notify() - { - foreach(self::$observers as $observer) - { - foreach(self::$fb as $fb) { - $observer->updateConditionEvaluation($fb); - } - } - - self::resetFeedback(); - } - - public static function addFeedback($current_node, $node_index, $session, $feedback_type, $condition_id = NULL) - { - self::$fb[] = array( - 'node' => $current_node, - 'node_index' => $node_index, - 'session' => $session, - 'feedback_type' => $feedback_type, - 'condition_id' => $condition_id - ); - } - - /** - * @param bool|false $path_sift - */ - public static function resetFeedback($path_sift = false) - { - if($path_sift == true) - { - $tmp_fb = array(); - - foreach(self::$fb as $fb) - { - if($fb['feedback_type'] == ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE_JUMP) - { - $tmp_fb[] = $fb; - } - } - - self::$fb = $tmp_fb; - } - else - { - self::$fb = array(); - } - } - - public static function updateNodeIndex($node_index) - { - foreach(self::$fb as $key => $item) - { - self::$fb[$key]['node_index'] = $node_index; - } - } - - - public static function deleteFeedback($node_index, $set_id, $session_id) - { - foreach(self::$observers as $observer) - { - foreach(self::$fb as $fb) { - $observer->deleteFeedback($node_index, $set_id, $session_id); - } - } - } - - /** - * @param $nextNode - * - * @return int - */ - public static function getAnchorIndex($nextNode) - { - $feedbackAnchorNode = $nextNode->getPath()->getNodes()->getPreviousNode($nextNode); - if(is_object($feedbackAnchorNode)) - { - $node_index = $feedbackAnchorNode->getIndex(); - - return $node_index; - } - else - { - // Wenn kein Vorgänger vorhanden, dann muss Knotenindex immer 0 sein! - return 0; - } - } - + /** + * @var ilConditionEvaluationObserver[] + */ + public static $observers = array(); + + /** + * @var array + */ + public static $state = array(); + + /** + * @var array + */ + public static $fb = array(); + + /** + * @param ilQuestionSetPoolNode $current_node + * @param ilFormATestSession $session + * + * @return null|ilQuestionSetPoolNode + */ + public static function getNextNode($current_node, $session) + { + $evaluator = self::initializeEvaluator($current_node->getPath()->getSet()->getId(), $session); + self::resetFeedback(); + + if (ilFormATestConditionEvaluation::isConditionTrue($evaluator, $current_node->getInitialCondition())) { + $session->updateCondition($current_node->getId(), $current_node->getInitialCondition()); + // Ausgangsbedingung, Feedback true + self::addFeedback($current_node, $current_node->getIndex(), $session, ilFormATestFeedbackConstants::INITIAL_FEEDBACK_TRUE); + self::notify(); + + return $current_node->getPath()->getNodes()->getNextNode($current_node); + } else { + // Ausgangsbedingung,Feedback false + self::addFeedback($current_node, $current_node->getIndex(), $session, ilFormATestFeedbackConstants::INITIAL_FEEDBACK_FALSE); + //self::notify(); + + $jump_conditions = $current_node->getJumpConditionList()->getData(); + foreach ($jump_conditions as $item) { + $condition = new ilQuestionSetPoolJumpCondition($item["id"]); + $condition->read(); + + if (ilFormATestConditionEvaluation::isConditionTrue($evaluator, $condition->getJumpCondition())) { + $session->updateCondition($current_node->getId(), $condition->getJumpCondition(), $condition->getId()); + if (!$session->reachedDeadlock()) { + $deleteIndex = null; + // Sprungbedingung,Feedback true + $nextNode = null; + + if ($condition->getQuestion() != null) { + $nextNode = $current_node->getPath()->getNodes()->getNodeByQuestionId($condition->getQuestion()->getId()); + + $node_index = self::getAnchorIndex($nextNode); + + // vorher + $deleteIndex = $node_index; + self::addFeedback($current_node, $node_index, $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE, $condition->getId()); + self::updateNodeIndex($node_index); + //self::notify(); + } else { + // WEnn das Set abgebrochen wird + self::addFeedback($current_node, $current_node->getIndex(), $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE, $condition->getId()); + self::updateNodeIndex($current_node->getIndex()); + //self::notify(); + } + + if ($deleteIndex !== null) { + self::deleteFeedback($deleteIndex, $session->getSetId(), $session->getSessionId()); + } + self::notify(); + return $nextNode; + } else { + // Sprungbedingung, Feedback no_jmp + self::addFeedback($current_node, $current_node->getIndex(), $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE_JUMP, $condition->getId()); + //self::notify(); + + $session->unsetJump(); + $session->markSolutionToFixate(); + } + } else { + // Sprungbedingung, Feedback false + self::addFeedback($current_node, $current_node->getIndex(), $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_FALSE, $condition->getId()); + //self::notify(); + } + } + return self::doPathShift($current_node, $session, $evaluator); + } + } + + /** + * @param CompositeEvaluator $evaluator + * @param string $condition + * + * @return bool + */ + public static function isConditionTrue($evaluator, $condition) + { + if (trim($condition) == "") { + return false; + } + + $parser = new ConditionParser(); + $composite = $parser->parse($condition); + + return $evaluator->evaluate($composite); + } + + protected static function initializeEvaluator($set_id, $session) + { + $provider = new ilParserQuestionProvider($set_id); + $evaluator = new CompositeEvaluator($provider, $session); + + return $evaluator; + } + + /** + * @param ilQuestionSetPoolNode $current_node + * @param ilFormATestSession $session + * @param CompositeEvaluator $evaluator + * + * @return ilQuestionSetPoolNode|null + */ + protected static function doPathShift($current_node, $session, $evaluator) + { + $paths = $current_node->getPath()->getSet()->getPathList()->getData(); + foreach ($paths as $path) { + if ($path["id"] != $current_node->getPath()->getId()) { + $reset_feedback = false; + + $path = new ilQuestionSetPoolPath($path["id"]); + $path->read(); + + if ($path->isEqualsUntilIndex($current_node->getPath(), $current_node->getIndex())) { + $node = $path->getNodes()->getNodeByQuestionId($current_node->getQuestion()->getId()); + + if ($node != null && self::arePreviousConditionsValid($evaluator, $path, $node)) { + self::resetFeedback(true); + $reset_feedback = true; + + if (ilFormATestConditionEvaluation::isConditionTrue($evaluator, $node->getInitialCondition())) { + $session->updateCondition($node->getId(), $node->getInitialCondition()); + + self::addFeedback($node, $node->getIndex(), $session, ilFormATestFeedbackConstants::INITIAL_FEEDBACK_TRUE); + self::updateNodeIndex($node->getIndex()); + self::notify(); + + return $node->getPath()->getNodes()->getNextNode($node); + } else { + self::addFeedback($node, $node->getIndex(), $session, ilFormATestFeedbackConstants::INITIAL_FEEDBACK_FALSE); + self::updateNodeIndex($node->getIndex()); + } + } + + $jump_conditions = $node->getJumpConditionList()->getData(); + foreach ($jump_conditions as $item) { + $condition = new ilQuestionSetPoolJumpCondition($item["id"]); + $condition->read(); + + if (self::arePreviousConditionsValid($evaluator, $path, $node)) { + if (!$reset_feedback) { + self::resetFeedback(true); + $reset_feedback = true; + } + if (ilFormATestConditionEvaluation::isConditionTrue($evaluator, $condition->getJumpCondition())) { + $session->updateCondition($node->getId(), $condition->getJumpCondition(), $condition->getId()); + if (!$session->reachedDeadlock()) { + $deleteIndex = null; + $nextNode = null; + if ($condition->getQuestion() != null) { + $nextNode = $node->getPath()->getNodes()->getNodeByQuestionId($condition->getQuestion()->getId()); + + $node_index = self::getAnchorIndex($nextNode); + $deleteIndex = $node_index; + + self::addFeedback($node, $node_index, $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE, $condition->getId()); + self::updateNodeIndex($node_index); + } else { + self::addFeedback($node, $node->getIndex(), $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE, $condition->getId()); + self::updateNodeIndex($node->getIndex()); + } + + if ($deleteIndex !== null) { + self::deleteFeedback($deleteIndex, $session->getSetId(), $session->getSessionId()); + } + self::notify(); + return $nextNode; + } else { + self::addFeedback($node, $node->getIndex(), $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE_JUMP, $condition->getId()); + self::updateNodeIndex($node->getIndex()); + + $session->unsetJump(); + $session->markSolutionToFixate(); + } + } else { + self::addFeedback($node, $node->getIndex(), $session, ilFormATestFeedbackConstants::JMP_FEEDBACK_FALSE, $condition->getId()); + self::updateNodeIndex($node->getIndex()); + } + } + } + } + } + } + self::notify(); + return null; + } + + /** + * @param CompositeEvaluator $evaluator + * @param ilQuestionSetPoolPath $path + * @param ilQuestionSetPoolNode $node + * + * @return bool + */ + protected static function arePreviousConditionsValid($evaluator, $path, $node) + { + $nodes = $path->getNodes()->getData(); + + foreach ($nodes as $prev_node) { + if ($prev_node["node_index"] >= $node->getIndex()) { + break; + } + + if (!ilFormATestConditionEvaluation::isConditionTrue($evaluator, $prev_node["initial_condition"])) { + return false; + } + } + + return true; + } + + /** + * @param ilConditionEvaluationObserver $observer + * @throws InvalidArgumentException + */ + public static function attach(ilConditionEvaluationObserver $observer) + { + $key = array_search($observer, self::$observers); + if ($key) { + throw new InvalidArgumentException('Observer already attached to subject.'); + } + self::$observers[] = $observer; + } + + /** + * @param ilConditionEvaluationObserver $observer + * @throws InvalidArgumentException + */ + public static function detach(ilConditionEvaluationObserver $observer) + { + $key = array_search($observer, self::$observers, true); + if ($key === false) { + throw new InvalidArgumentException('Observer not found in collection.'); + } + unset(self::$observers[$key]); + } + + public static function notify() + { + foreach (self::$observers as $observer) { + foreach (self::$fb as $fb) { + $observer->updateConditionEvaluation($fb); + } + } + + self::resetFeedback(); + } + + public static function addFeedback($current_node, $node_index, $session, $feedback_type, $condition_id = null) + { + self::$fb[] = array( + 'node' => $current_node, + 'node_index' => $node_index, + 'session' => $session, + 'feedback_type' => $feedback_type, + 'condition_id' => $condition_id + ); + } + + /** + * @param bool|false $path_sift + */ + public static function resetFeedback($path_sift = false) + { + if ($path_sift == true) { + $tmp_fb = array(); + + foreach (self::$fb as $fb) { + if ($fb['feedback_type'] == ilFormATestFeedbackConstants::JMP_FEEDBACK_TRUE_JUMP) { + $tmp_fb[] = $fb; + } + } + + self::$fb = $tmp_fb; + } else { + self::$fb = array(); + } + } + + public static function updateNodeIndex($node_index) + { + foreach (self::$fb as $key => $item) { + self::$fb[$key]['node_index'] = $node_index; + } + } + + + public static function deleteFeedback($node_index, $set_id, $session_id) + { + foreach (self::$observers as $observer) { + foreach (self::$fb as $fb) { + $observer->deleteFeedback($node_index, $set_id, $session_id); + } + } + } + + /** + * @param $nextNode + * + * @return int + */ + public static function getAnchorIndex($nextNode) + { + $feedbackAnchorNode = $nextNode->getPath()->getNodes()->getPreviousNode($nextNode); + if (is_object($feedbackAnchorNode)) { + $node_index = $feedbackAnchorNode->getIndex(); + + return $node_index; + } else { + // Wenn kein Vorgänger vorhanden, dann muss Knotenindex immer 0 sein! + return 0; + } + } } - \ No newline at end of file diff --git a/classes/utils/abstract.ilFormATestPlayerAccessHelper.php b/classes/utils/abstract.ilFormATestPlayerAccessHelper.php index 0c6d0ce6690cabf6026f6839966b99fc8688c61d..29130517dbd5482ac25b69141f385a8050e9cf7a 100644 --- a/classes/utils/abstract.ilFormATestPlayerAccessHelper.php +++ b/classes/utils/abstract.ilFormATestPlayerAccessHelper.php @@ -6,64 +6,58 @@ * Date: 17.01.14 * Time: 17:16 * @author Thomas Joußen - */ + */ abstract class ilFormATestPlayerAccessHelper { - /** - * Check whether it is possible to start a test. - * Checks the test settings and the user access level - * - * @param ilObjFormATestGUI $controller - * - * @return bool - */ - public static function canDoTestAction($controller, ilFormATestSession $session) - { - if(!$controller->object->isOnline()) - { - ilUtil::sendInfo($controller->plugin->txt("test_is_offline")); - return false; - } + /** + * Check whether it is possible to start a test. + * Checks the test settings and the user access level + * + * @param ilObjFormATestGUI $controller + * + * @return bool + */ + public static function canDoTestAction($controller, ilFormATestSession $session) + { + if (!$controller->object->isOnline()) { + ilUtil::sendInfo($controller->plugin->txt("test_is_offline")); + return false; + } - if( - $controller->object->isStartTimeEnabled() && - ilDateTime::_after($controller->object->getStartTime(), new ilDateTime(time(), IL_CAL_UNIX)) - ){ + if ( + $controller->object->isStartTimeEnabled() && + ilDateTime::_after($controller->object->getStartTime(), new ilDateTime(time(), IL_CAL_UNIX)) + ) { + ilUtil::sendInfo(sprintf($controller->plugin->txt("test_start_future"), $controller->object->getStartTime())); + return false; + } - ilUtil::sendInfo(sprintf($controller->plugin->txt("test_start_future"), $controller->object->getStartTime())); - return false; - } + if ( + $controller->object->isEndTimeEnabled() && + ilDateTime::_before($controller->object->getEndTime(), new ilDateTime(time(), IL_CAL_UNIX)) + ) { + ilUtil::sendInfo(sprintf($controller->plugin->txt("test_start_past"), $controller->object->getEndTime())); + return false; + } - if( - $controller->object->isEndTimeEnabled() && - ilDateTime::_before($controller->object->getEndTime(), new ilDateTime(time(), IL_CAL_UNIX)) - ) - { - ilUtil::sendInfo(sprintf($controller->plugin->txt("test_start_past"), $controller->object->getEndTime())); - return false; - } - - // @todo @Thomas: Respect max passes setting - if( - $controller->object->getMaxPasses() > 0 && - $session->activeIdExists() && - ( - $session->getPass() + 1 >= $controller->object->getMaxPasses() - ) - ) - { - if( - ($session->getPass() + 1 == $controller->object->getMaxPasses() && $session->isPassFinished()) || - $session->getPass() + 1 > $controller->object->getMaxPasses() - ) - { - ilUtil::sendInfo($controller->lng->txt('maximum_nr_of_tries_reached'), true); - return false; - } - } - - return true; - } + // @todo @Thomas: Respect max passes setting + if ( + $controller->object->getMaxPasses() > 0 && + $session->activeIdExists() && + ( + $session->getPass() + 1 >= $controller->object->getMaxPasses() + ) + ) { + if ( + ($session->getPass() + 1 == $controller->object->getMaxPasses() && $session->isPassFinished()) || + $session->getPass() + 1 > $controller->object->getMaxPasses() + ) { + ilUtil::sendInfo($controller->lng->txt('maximum_nr_of_tries_reached'), true); + return false; + } + } + + return true; + } } - \ No newline at end of file diff --git a/classes/utils/abstract.ilFormATestUtil.php b/classes/utils/abstract.ilFormATestUtil.php index 76df49b1fbe5d0b42b5c78816afccf8510317274..0fbf6c4637e15cadd46ef21792c0dc88c37b2811 100644 --- a/classes/utils/abstract.ilFormATestUtil.php +++ b/classes/utils/abstract.ilFormATestUtil.php @@ -6,98 +6,94 @@ * Date: 17.04.14 * Time: 13:06 * @author Thomas Joußen - */ -abstract class ilFormATestUtil { + */ +abstract class ilFormATestUtil +{ + protected static $INFO_KEY = "XTSF_INFO"; + protected static $SUCCESS_KEY = "XTSF_SUCCESS"; + protected static $ERROR_KEY = "XTSF_ERROR"; - protected static $INFO_KEY = "XTSF_INFO"; - protected static $SUCCESS_KEY = "XTSF_SUCCESS"; - protected static $ERROR_KEY = "XTSF_ERROR"; + public static function addInfo($message) + { + self::createSessionEntryIfNotExist(self::$INFO_KEY); + self::add(self::$INFO_KEY, $message); + } - public static function addInfo($message) - { - self::createSessionEntryIfNotExist(self::$INFO_KEY); - self::add(self::$INFO_KEY, $message); - } + public static function addSuccess($message) + { + self::createSessionEntryIfNotExist(self::$SUCCESS_KEY); + self::add(self::$SUCCESS_KEY, $message); + } - public static function addSuccess($message) - { - self::createSessionEntryIfNotExist(self::$SUCCESS_KEY); - self::add(self::$SUCCESS_KEY, $message); - } + public static function addError($message) + { + self::createSessionEntryIfNotExist(self::$ERROR_KEY); + self::add(self::$ERROR_KEY, $message); + } - public static function addError($message) - { - self::createSessionEntryIfNotExist(self::$ERROR_KEY); - self::add(self::$ERROR_KEY, $message); - } + public static function send() + { + if (self::hasInfos()) { + $_SESSION["info"] = self::prepare(self::$INFO_KEY); + self::unsetSessionEntry(self::$INFO_KEY); + } + if (self::hasErorrs()) { + $_SESSION["failure"] = self::prepare(self::$ERROR_KEY); + self::unsetSessionEntry(self::$ERROR_KEY); + } + if (self::hasSuccess()) { + $_SESSION["success"] = self::prepare(self::$SUCCESS_KEY); + self::unsetSessionEntry(self::$SUCCESS_KEY); + } + } - public static function send() - { - if(self::hasInfos()) - { - $_SESSION["info"] = self::prepare(self::$INFO_KEY); - self::unsetSessionEntry(self::$INFO_KEY); - } - if(self::hasErorrs()) - { - $_SESSION["failure"] = self::prepare(self::$ERROR_KEY); - self::unsetSessionEntry(self::$ERROR_KEY); - } - if(self::hasSuccess()) - { - $_SESSION["success"] = self::prepare(self::$SUCCESS_KEY); - self::unsetSessionEntry(self::$SUCCESS_KEY); - } - } + protected static function hasInfos() + { + if (is_array($_SESSION[self::$INFO_KEY])) { + return count($_SESSION[self::$INFO_KEY]) > 0; + } + } - protected static function hasInfos() - { - if(is_array($_SESSION[self::$INFO_KEY])) - return count($_SESSION[self::$INFO_KEY]) > 0; - } + protected static function hasSuccess() + { + if (is_array($_SESSION[self::$SUCCESS_KEY])) { + return count($_SESSION[self::$SUCCESS_KEY]) > 0; + } + } - protected static function hasSuccess() - { - if(is_array($_SESSION[self::$SUCCESS_KEY])) - return count($_SESSION[self::$SUCCESS_KEY]) > 0; - } + protected static function hasErorrs() + { + if (is_array($_SESSION[self::$ERROR_KEY])) { + return count($_SESSION[self::$ERROR_KEY]) > 0; + } + } - protected static function hasErorrs() - { - if(is_array($_SESSION[self::$ERROR_KEY])) - return count($_SESSION[self::$ERROR_KEY]) > 0; - } + protected static function unsetSessionEntry($key) + { + unset($_SESSION[$key]); + } - protected static function unsetSessionEntry($key) - { - unset($_SESSION[$key]); - } + protected static function prepare($key) + { + if (is_array($_SESSION[$key]) && count($_SESSION[$key]) == 1) { + return current($_SESSION[$key]); + } - protected static function prepare($key) - { - if(is_array($_SESSION[$key]) && count($_SESSION[$key]) == 1) - { - return current($_SESSION[$key]); - } + $result = "
  • "; + $result .= join("
  • ", $_SESSION[$key]); + $result .= "
"; + return $result; + } - $result = "
  • "; - $result .= join("
  • ", $_SESSION[$key]); - $result .= "
"; - return $result; - } - - protected static function createSessionEntryIfNotExist($key) - { - if(!is_array($_SESSION[$key])) - { - $_SESSION[$key] = array(); - } - } - - protected static function add($key, $message) - { - $_SESSION[$key][] = $message; - } + protected static function createSessionEntryIfNotExist($key) + { + if (!is_array($_SESSION[$key])) { + $_SESSION[$key] = array(); + } + } + protected static function add($key, $message) + { + $_SESSION[$key][] = $message; + } } - \ No newline at end of file diff --git a/classes/utils/class.ilFormATestAccordionGUI.php b/classes/utils/class.ilFormATestAccordionGUI.php index 26e03f5e255a8fc591684e541a6c64e6db145eb2..53981110b0b045fcfe4ede015341c1c724152af5 100644 --- a/classes/utils/class.ilFormATestAccordionGUI.php +++ b/classes/utils/class.ilFormATestAccordionGUI.php @@ -6,395 +6,377 @@ * Date: 18.03.14 * Time: 11:59 * @author Thomas Joußen - */ + */ class ilFormATestAccordionGUI { - protected $items = array(); - protected $force_open; - protected static $accordion_cnt = 0; - - const VERTICAL = "vertical"; - const HORIZONTAL = "horizontal"; - const FORCE_ALL_OPEN = "ForceAllOpen"; - const FIRST_OPEN = "FirstOpen"; - const ONE_OPEN_SESSION = "OneOpenSession"; - - /** - * Constructor - */ - function __construct() - { - $this->setOrientation(ilFormATestAccordionGUI::VERTICAL); - } - - /** - * Set id - * - * @param string id - */ - function setId($a_val) - { - $this->id = $a_val; - } - - /** - * Get id - * - * @return string id - */ - function getId() - { - return $this->id; - } - - /** - * Set Orientation. - * - * @param string $a_orientation Orientation - */ - function setOrientation($a_orientation) - { - if (in_array($a_orientation, - array(ilFormATestAccordionGUI::VERTICAL, ilFormATestAccordionGUI::HORIZONTAL))) - { - $this->orientation = $a_orientation; - } - } - - /** - * Get Orientation. - * - * @return string Orientation - */ - function getOrientation() - { - return $this->orientation; - } - - /** - * Set Container CSS Class. - * - * @param string $a_containerclass Container CSS Class - */ - function setContainerClass($a_containerclass) - { - $this->containerclass = $a_containerclass; - } - - /** - * Get Container CSS Class. - * - * @return string Container CSS Class - */ - function getContainerClass() - { - return $this->containerclass; - } - - /** - * Set inner Container CSS Class. - * - * @param string $a_containerclass Container CSS Class - */ - function setInnerContainerClass($a_containerclass) - { - $this->icontainerclass = $a_containerclass; - } - - /** - * Get inner Container CSS Class. - * - * @return string Container CSS Class - */ - function getInnerContainerClass() - { - return $this->icontainerclass; - } - - /** - * Set Header CSS Class. - * - * @param string $a_headerclass Header CSS Class - */ - function setHeaderClass($a_headerclass) - { - $this->headerclass = $a_headerclass; - } - - /** - * Get Header CSS Class. - * - * @return string Header CSS Class - */ - function getHeaderClass() - { - return $this->headerclass; - } - - /** - * Set active header class - * - * @param string $a_h_class Active Header CSS Class - */ - function setActiveHeaderClass($a_h_class) - { - $this->active_headerclass = $a_h_class; - } - - /** - * Get active Header CSS Class. - * - * @return string Active header CSS Class - */ - function getActiveHeaderClass() - { - return $this->active_headerclass; - } - - /** - * Set Content CSS Class. - * - * @param string $a_contentclass Content CSS Class - */ - function setContentClass($a_contentclass) - { - $this->contentclass = $a_contentclass; - } - - /** - * Get Content CSS Class. - * - * @return string Content CSS Class - */ - function getContentClass() - { - return $this->contentclass; - } - - /** - * Set ContentWidth. - * - * @param integer $a_contentwidth ContentWidth - */ - function setContentWidth($a_contentwidth) - { - $this->contentwidth = $a_contentwidth; - } - - /** - * Get ContentWidth. - * - * @return integer ContentWidth - */ - function getContentWidth() - { - return $this->contentwidth; - } - - /** - * Set ContentHeight. - * - * @param integer $a_contentheight ContentHeight - */ - function setContentHeight($a_contentheight) - { - $this->contentheight = $a_contentheight; - } - - /** - * Get ContentHeight. - * - * @return integer ContentHeight - */ - function getContentHeight() - { - return $this->contentheight; - } - - /** - * Set behaviour "ForceAllOpen" | "FirstOpen" | "OneOpenSession" - * - * @param string behaviour - */ - function setBehaviour($a_val) - { - $this->behaviour = $a_val; - } - - /** - * Get behaviour - * - * @return - */ - function getBehaviour() - { - return $this->behaviour; - } - - /** - * Add javascript files that are necessary to run accordion - */ - static function addJavaScript() - { - global $DIC; - - include_once("./Services/YUI/classes/class.ilYuiUtil.php"); - ilYuiUtil::initEvent(); - ilYuiUtil::initDom(); - ilYuiUtil::initAnimation(); - ilYuiUtil::initConnection(); - $DIC->ui()->mainTemplate()->addJavaScript("./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/templates/default/accordion.js", true, 3); - } - - /** - * Add required css - */ - static function addCss() - { - global $DIC; - - $DIC->ui()->mainTemplate()->addCss("./Services/Accordion/css/accordion.css"); - } - - /** - * Add item - */ - function addItem($a_header, $a_content, $a_force_open = false) - { - $this->items[] = array("header" => $a_header, - "content" => $a_content); - - if($a_force_open && is_array($this->items)) - { - $this->force_open = count($this->items); - } - } - - /** - * Get all items - */ - function getItems() - { - return $this->items; - } - - function getHTML() - { - global $DIC; - $ilUser = $DIC->user(); - - self::$accordion_cnt++; - - $or_short = ($this->getOrientation() == ilFormATestAccordionGUI::HORIZONTAL) - ? "H" - : "V"; - - $width = (int) $this->getContentWidth(); - $height = (int) $this->getContentHeight(); - if ($this->getOrientation() == ilFormATestAccordionGUI::HORIZONTAL) - { - if ($width == 0) - { - $width = 200; - } - if ($height == 0) - { - $height = 100; - } - } - - $this->addJavaScript(); - $this->addCss(); - - $tpl = new ilTemplate("tpl.accordion.html", true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); - foreach ($this->getItems() as $item) - { - $tpl->setCurrentBlock("item"); - $tpl->setVariable("HEADER", $item["header"]); - $tpl->setVariable("CONTENT", $item["content"]); - $tpl->setVariable("HEADER_CLASS", $this->getHeaderClass() - ? $this->getHeaderClass() : "il_".$or_short."AccordionHead"); - $tpl->setVariable("CONTENT_CLASS", $this->getContentClass() - ? $this->getContentClass() : "il_".$or_short."AccordionContent"); - $tpl->setVariable("OR_SHORT", $or_short); - - $tpl->setVariable("INNER_CONTAINER_CLASS", $this->getInnerContainerClass() - ? $this->getInnerContainerClass() : "il_".$or_short."AccordionInnerContainer"); - - - if ($height > 0) - { - $tpl->setVariable("HEIGHT", "height:".$height."px;"); - } - if ($height > 0 && $this->getOrientation() == ilFormATestAccordionGUI::HORIZONTAL) - { - $tpl->setVariable("HHEIGHT", "height:".$height."px;"); - } - $tpl->parseCurrentBlock(); - } - - $tpl->setVariable("CNT", self::$accordion_cnt); - $tpl->setVariable("CONTAINER_CLASS", $this->getContainerClass() - ? $this->getContainerClass() : "il_".$or_short."AccordionContainer"); - $tpl->setVariable("ORIENTATION", $this->getOrientation()); - $tpl->setVariable("ID", $this->getId()); - if ($this->getBehaviour() == "OneOpenSession" && $this->getId() != "") - { - include_once("./Services/Accordion/classes/class.ilAccordionPropertiesStorage.php"); - $stor = new ilAccordionPropertiesStorage(); - - if($this->force_open) - { - $stor->storeProperty($this->getId(), $ilUser->getId(), - "opened", $this->force_open); - - $ctab = $this->force_open; - } - else - { - $ctab = $stor->getProperty($this->getId(), $ilUser->getId(), - "opened"); - } - - $tpl->setVariable("BEHAVIOUR", $ctab); - $tpl->setVariable("SAVE_URL", "./ilias.php?baseClass=ilaccordionpropertiesstorage&cmd=setOpenedTab". - "&accordion_id=".$this->getId()."&user_id=".$ilUser->getId()); - } - else if ($this->getBehaviour() != "") - { - $tpl->setVariable("BEHAVIOUR", $this->getBehaviour()); - } - $tpl->setVariable("OR2_SHORT", $or_short); - if ($width > 0) - { - $tpl->setVariable("WIDTH", $width); - } - else - { - $tpl->setVariable("WIDTH", "null"); - } - if ($width > 0 && $this->getOrientation() == ilFormATestAccordionGUI::VERTICAL) - { - $tpl->setVariable("CWIDTH", 'style="width:'.$width.'px;"'); - } - - if ($this->head_class_set) - { - $tpl->setVariable("ACTIVE_HEAD_CLASS", $this->getActiveHeaderClass()); - } - else - { - if ($this->getOrientation() == ilFormATestAccordionGUI::VERTICAL) - { - $tpl->setVariable("ACTIVE_HEAD_CLASS", "il_HAccordionHeadActive"); - } - else - { - $tpl->setVariable("ACTIVE_HEAD_CLASS", "il_VAccordionHeadActive"); - } - } - - return $tpl->get(); - } + protected $items = array(); + protected $force_open; + protected static $accordion_cnt = 0; + + const VERTICAL = "vertical"; + const HORIZONTAL = "horizontal"; + const FORCE_ALL_OPEN = "ForceAllOpen"; + const FIRST_OPEN = "FirstOpen"; + const ONE_OPEN_SESSION = "OneOpenSession"; + + /** + * Constructor + */ + public function __construct() + { + $this->setOrientation(ilFormATestAccordionGUI::VERTICAL); + } + + /** + * Set id + * + * @param string id + */ + public function setId($a_val) + { + $this->id = $a_val; + } + + /** + * Get id + * + * @return string id + */ + public function getId() + { + return $this->id; + } + + /** + * Set Orientation. + * + * @param string $a_orientation Orientation + */ + public function setOrientation($a_orientation) + { + if (in_array( + $a_orientation, + array(ilFormATestAccordionGUI::VERTICAL, ilFormATestAccordionGUI::HORIZONTAL) + )) { + $this->orientation = $a_orientation; + } + } + + /** + * Get Orientation. + * + * @return string Orientation + */ + public function getOrientation() + { + return $this->orientation; + } + + /** + * Set Container CSS Class. + * + * @param string $a_containerclass Container CSS Class + */ + public function setContainerClass($a_containerclass) + { + $this->containerclass = $a_containerclass; + } + + /** + * Get Container CSS Class. + * + * @return string Container CSS Class + */ + public function getContainerClass() + { + return $this->containerclass; + } + + /** + * Set inner Container CSS Class. + * + * @param string $a_containerclass Container CSS Class + */ + public function setInnerContainerClass($a_containerclass) + { + $this->icontainerclass = $a_containerclass; + } + + /** + * Get inner Container CSS Class. + * + * @return string Container CSS Class + */ + public function getInnerContainerClass() + { + return $this->icontainerclass; + } + + /** + * Set Header CSS Class. + * + * @param string $a_headerclass Header CSS Class + */ + public function setHeaderClass($a_headerclass) + { + $this->headerclass = $a_headerclass; + } + + /** + * Get Header CSS Class. + * + * @return string Header CSS Class + */ + public function getHeaderClass() + { + return $this->headerclass; + } + + /** + * Set active header class + * + * @param string $a_h_class Active Header CSS Class + */ + public function setActiveHeaderClass($a_h_class) + { + $this->active_headerclass = $a_h_class; + } + + /** + * Get active Header CSS Class. + * + * @return string Active header CSS Class + */ + public function getActiveHeaderClass() + { + return $this->active_headerclass; + } + + /** + * Set Content CSS Class. + * + * @param string $a_contentclass Content CSS Class + */ + public function setContentClass($a_contentclass) + { + $this->contentclass = $a_contentclass; + } + + /** + * Get Content CSS Class. + * + * @return string Content CSS Class + */ + public function getContentClass() + { + return $this->contentclass; + } + + /** + * Set ContentWidth. + * + * @param integer $a_contentwidth ContentWidth + */ + public function setContentWidth($a_contentwidth) + { + $this->contentwidth = $a_contentwidth; + } + + /** + * Get ContentWidth. + * + * @return integer ContentWidth + */ + public function getContentWidth() + { + return $this->contentwidth; + } + + /** + * Set ContentHeight. + * + * @param integer $a_contentheight ContentHeight + */ + public function setContentHeight($a_contentheight) + { + $this->contentheight = $a_contentheight; + } + + /** + * Get ContentHeight. + * + * @return integer ContentHeight + */ + public function getContentHeight() + { + return $this->contentheight; + } + + /** + * Set behaviour "ForceAllOpen" | "FirstOpen" | "OneOpenSession" + * + * @param string behaviour + */ + public function setBehaviour($a_val) + { + $this->behaviour = $a_val; + } + + /** + * Get behaviour + * + * @return + */ + public function getBehaviour() + { + return $this->behaviour; + } + + /** + * Add javascript files that are necessary to run accordion + */ + public static function addJavaScript() + { + global $DIC; + + ilYuiUtil::initEvent(); + ilYuiUtil::initDom(); + ilYuiUtil::initAnimation(); + ilYuiUtil::initConnection(); + $DIC->ui()->mainTemplate()->addJavaScript("./Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest/templates/default/accordion.js", true, 3); + } + + /** + * Add required css + */ + public static function addCss() + { + global $DIC; + + $DIC->ui()->mainTemplate()->addCss("./Services/Accordion/css/accordion.css"); + } + + /** + * Add item + */ + public function addItem($a_header, $a_content, $a_force_open = false) + { + $this->items[] = array("header" => $a_header, + "content" => $a_content); + + if ($a_force_open && is_array($this->items)) { + $this->force_open = count($this->items); + } + } + + /** + * Get all items + */ + public function getItems() + { + return $this->items; + } + + public function getHTML() + { + global $DIC; + $ilUser = $DIC->user(); + + self::$accordion_cnt++; + + $or_short = ($this->getOrientation() == ilFormATestAccordionGUI::HORIZONTAL) + ? "H" + : "V"; + + $width = (int) $this->getContentWidth(); + $height = (int) $this->getContentHeight(); + if ($this->getOrientation() == ilFormATestAccordionGUI::HORIZONTAL) { + if ($width == 0) { + $width = 200; + } + if ($height == 0) { + $height = 100; + } + } + + $this->addJavaScript(); + $this->addCss(); + + $tpl = new ilTemplate("tpl.accordion.html", true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); + foreach ($this->getItems() as $item) { + $tpl->setCurrentBlock("item"); + $tpl->setVariable("HEADER", $item["header"]); + $tpl->setVariable("CONTENT", $item["content"]); + $tpl->setVariable("HEADER_CLASS", $this->getHeaderClass() + ? $this->getHeaderClass() : "il_" . $or_short . "AccordionHead"); + $tpl->setVariable("CONTENT_CLASS", $this->getContentClass() + ? $this->getContentClass() : "il_" . $or_short . "AccordionContent"); + $tpl->setVariable("OR_SHORT", $or_short); + + $tpl->setVariable("INNER_CONTAINER_CLASS", $this->getInnerContainerClass() + ? $this->getInnerContainerClass() : "il_" . $or_short . "AccordionInnerContainer"); + + + if ($height > 0) { + $tpl->setVariable("HEIGHT", "height:" . $height . "px;"); + } + if ($height > 0 && $this->getOrientation() == ilFormATestAccordionGUI::HORIZONTAL) { + $tpl->setVariable("HHEIGHT", "height:" . $height . "px;"); + } + $tpl->parseCurrentBlock(); + } + + $tpl->setVariable("CNT", self::$accordion_cnt); + $tpl->setVariable("CONTAINER_CLASS", $this->getContainerClass() + ? $this->getContainerClass() : "il_" . $or_short . "AccordionContainer"); + $tpl->setVariable("ORIENTATION", $this->getOrientation()); + $tpl->setVariable("ID", $this->getId()); + if ($this->getBehaviour() == "OneOpenSession" && $this->getId() != "") { + $stor = new ilAccordionPropertiesStorage(); + + if ($this->force_open) { + $stor->storeProperty( + $this->getId(), + $ilUser->getId(), + "opened", + $this->force_open + ); + + $ctab = $this->force_open; + } else { + $ctab = $stor->getProperty( + $this->getId(), + $ilUser->getId(), + "opened" + ); + } + + $tpl->setVariable("BEHAVIOUR", $ctab); + $tpl->setVariable("SAVE_URL", "./ilias.php?baseClass=ilaccordionpropertiesstorage&cmd=setOpenedTab" . + "&accordion_id=" . $this->getId() . "&user_id=" . $ilUser->getId()); + } elseif ($this->getBehaviour() != "") { + $tpl->setVariable("BEHAVIOUR", $this->getBehaviour()); + } + $tpl->setVariable("OR2_SHORT", $or_short); + if ($width > 0) { + $tpl->setVariable("WIDTH", $width); + } else { + $tpl->setVariable("WIDTH", "null"); + } + if ($width > 0 && $this->getOrientation() == ilFormATestAccordionGUI::VERTICAL) { + $tpl->setVariable("CWIDTH", 'style="width:' . $width . 'px;"'); + } + + if ($this->head_class_set) { + $tpl->setVariable("ACTIVE_HEAD_CLASS", $this->getActiveHeaderClass()); + } else { + if ($this->getOrientation() == ilFormATestAccordionGUI::VERTICAL) { + $tpl->setVariable("ACTIVE_HEAD_CLASS", "il_HAccordionHeadActive"); + } else { + $tpl->setVariable("ACTIVE_HEAD_CLASS", "il_VAccordionHeadActive"); + } + } + + return $tpl->get(); + } } - \ No newline at end of file diff --git a/classes/utils/class.ilFormATestAssQuestionSkillAssignmentsGUI.php b/classes/utils/class.ilFormATestAssQuestionSkillAssignmentsGUI.php index 72a73aadf7b5aff2137c8bea57cb26f2a159fcda..17dca8255ed1db133fad45e3f76219e2478c2dd9 100644 --- a/classes/utils/class.ilFormATestAssQuestionSkillAssignmentsGUI.php +++ b/classes/utils/class.ilFormATestAssQuestionSkillAssignmentsGUI.php @@ -1,7 +1,5 @@ - */ + */ class ilFormATestDominantScoringReworker { - /** - * @var int - */ - protected $active_fi; + /** + * @var int + */ + protected $active_fi; - /** - * @var int - */ - protected $step; + /** + * @var int + */ + protected $step; - /** - * @var int - */ - protected $pass; + /** + * @var int + */ + protected $pass; - /** - * @var ilQuestionSetPoolNode - */ - protected $node; + /** + * @var ilQuestionSetPoolNode + */ + protected $node; - /** - * @param int $active_fi - * @param int $step - * @param int $pass - */ - public function __construct($active_fi, $step, $pass) - { - $this->active_fi = $active_fi; - $this->step = $step; - $this->pass = $pass; - } + /** + * @param int $active_fi + * @param int $step + * @param int $pass + */ + public function __construct($active_fi, $step, $pass) + { + $this->active_fi = $active_fi; + $this->step = $step; + $this->pass = $pass; + } - /** - * @param ilQuestionSetPoolNode $node - */ - public function rework($node) - { - $this->node = $node; - $points = $this->generateDominantPoints(); - $this->updateTstTestResult($points); - $this->node->getQuestion()->_updateTestPassResults($this->active_fi, $this->pass); - } + /** + * @param ilQuestionSetPoolNode $node + */ + public function rework($node) + { + $this->node = $node; + $points = $this->generateDominantPoints(); + $this->updateTstTestResult($points); + $this->node->getQuestion()->_updateTestPassResults($this->active_fi, $this->pass); + } - /** - * @return int - */ - protected function generateDominantPoints() - { - $reached_points = $this->node->getQuestion() - ->getReachedPoints($this->active_fi, $this->pass); - $max_points = $this->node->getQuestion()->getMaximumPoints(); + /** + * @return int + */ + protected function generateDominantPoints() + { + $reached_points = $this->node->getQuestion() + ->getReachedPoints($this->active_fi, $this->pass); + $max_points = $this->node->getQuestion()->getMaximumPoints(); - if ($max_points > 0) - { - return round($this->node->getDominantScoring() * ($reached_points / $max_points)); - } - return 0; - } + if ($max_points > 0) { + return round($this->node->getDominantScoring() * ($reached_points / $max_points)); + } + return 0; + } - /** - * @param int $points - */ - protected function updateTstTestResult($points) - { - global $DIC; - $ilDB = $DIC->database(); + /** + * @param int $points + */ + protected function updateTstTestResult($points) + { + global $DIC; + $ilDB = $DIC->database(); - $ilDB->update( - "tst_test_result", - array( - "points" => array("integer", $points) - ), - array( - "active_fi" => array("integer", $this->active_fi), - "question_fi" => array("integer", $this->node->getQuestion()->getId()), - "step" => array("integer", $this->step), - "pass" => array("integer", $this->pass) - ) - ); - } + $ilDB->update( + "tst_test_result", + array( + "points" => array("integer", $points) + ), + array( + "active_fi" => array("integer", $this->active_fi), + "question_fi" => array("integer", $this->node->getQuestion()->getId()), + "step" => array("integer", $this->step), + "pass" => array("integer", $this->pass) + ) + ); + } } - \ No newline at end of file diff --git a/classes/utils/class.ilFormATestInfoScreenGUI.php b/classes/utils/class.ilFormATestInfoScreenGUI.php index 6ed5f888a30911c7a176c465c16097e07fab5b2b..159a76cd2611b24be45d25877feeb3155056c52d 100644 --- a/classes/utils/class.ilFormATestInfoScreenGUI.php +++ b/classes/utils/class.ilFormATestInfoScreenGUI.php @@ -1,7 +1,5 @@ intro = $intro; - } - - /** - * get html - */ - function getHTML() - { - global $DIC; - $lng = $DIC->language(); - $ilSetting = $DIC->settings(); - $ilCtrl = $DIC->ctrl(); - $ilUser = $DIC->user(); - - $tpl= new ilTemplate("tpl.infoscreen.html", true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); - - if($this->intro != "") - { - $this->addSection($this->lng->txt("tst_introduction")); - $this->addProperty("", $this->intro); - } - - // other class handles form action (@todo: this is not implemented/tested) - if ($this->form_action == "") - { - $this->setFormAction($ilCtrl->getFormAction($this)); - } - - if($this->hidden) - { - $tpl->touchBlock("hidden_js"); - if($this->show_hidden_toggle) - { - $this->addButton($lng->txt("toggle_hidden_sections"), "JavaScript:toggleSections();"); - } - } - // add top buttons - if (is_array($this->top_buttons) && count($this->top_buttons) > 0) - { - $tpl->addBlockfile("TOP_BUTTONS", "top_buttons", "tpl.buttons.html"); - - foreach($this->top_buttons as $button) - { - // view button - $tpl->setCurrentBlock("btn_cell"); - $tpl->setVariable("BTN_LINK", $button["link"]); - $tpl->setVariable("BTN_TARGET", $button["target"]); - $tpl->setVariable("BTN_TXT", $button["title"]); - if($button["primary"]) - { - $tpl->setVariable("BTN_CLASS", " emphsubmit"); - } - $tpl->parseCurrentBlock(); - } - } - - // add top formbuttons - if ((is_array($this->top_formbuttons) && count($this->top_formbuttons) > 0) && (strlen($this->form_action) > 0)) - { - $tpl->addBlockfile("TOP_FORMBUTTONS", "top_submitbuttons", "tpl.submitbuttons.html", "Services/InfoScreen"); - - foreach($this->top_formbuttons as $button) - { - // view button - $tpl->setCurrentBlock("btn_submit_cell"); - $tpl->setVariable("BTN_COMMAND", $button["command"]); - $tpl->setVariable("BTN_NAME", $button["title"]); - $tpl->parseCurrentBlock(); - } - } - - // add form action - if (strlen($this->form_action) > 0) - { - if($this->open_form_tag) - { - $tpl->setCurrentBlock("formtop"); - $tpl->setVariable("FORMACTION", $this->form_action); - $tpl->parseCurrentBlock(); - } - - if($this->close_form_tag) - { - $tpl->touchBlock("formbottom"); - } - } - - if (is_array($this->hiddenelements) && count($this->hiddenelements)) - { - foreach ($this->hiddenelements as $hidden) - { - $tpl->setCurrentBlock("hidden_element"); - $tpl->setVariable("HIDDEN_NAME", $hidden["name"]); - $tpl->setVariable("HIDDEN_VALUE", $hidden["value"]); - $tpl->parseCurrentBlock(); - } - } - - // learning progress - if($this->learning_progress_enabled and $html = $this->showLearningProgress($tpl)) - { - $tpl->setCurrentBlock("learning_progress"); - $tpl->setVariable("LP_TABLE",$html); - $tpl->parseCurrentBlock(); - } - - // notes section - if ($this->private_notes_enabled && !$ilSetting->get('disable_notes')) - { - $html = $this->showNotesSection(); - $tpl->setCurrentBlock("notes"); - $tpl->setVariable("NOTES", $html); - $tpl->parseCurrentBlock(); - } - - // tagging - if (is_object($this->gui_object->object)) - { - $tags_set = new ilSetting("tags"); - if ($tags_set->get("enable") && $ilUser->getId() != ANONYMOUS_USER_ID) - { - $this->addTagging(); - } - } - - if(is_object($this->gui_object->object)) - { - $this->addObjectSections(); - } - - // render all sections - for($i = 1; $i <= $this->sec_nr; $i++) - { - if (is_array($this->section[$i]["properties"])) - { - // section properties - foreach($this->section[$i]["properties"] as $property) - { - if ($property["name"] != "") - { - if ($property["link"] == "") - { - $tpl->setCurrentBlock("pv"); - $tpl->setVariable("TXT_PROPERTY_VALUE", $property["value"]); - $tpl->parseCurrentBlock(); - } - else - { - $tpl->setCurrentBlock("lpv"); - $tpl->setVariable("TXT_PROPERTY_LVALUE", $property["value"]); - $tpl->setVariable("LINK_PROPERTY_VALUE", $property["link"]); - $tpl->parseCurrentBlock(); - } - $tpl->setCurrentBlock("property_row"); - $tpl->setVariable("TXT_PROPERTY", $property["name"]); - $tpl->parseCurrentBlock(); - } - else - { - $tpl->setCurrentBlock("property_full_row"); - $tpl->setVariable("TXT_PROPERTY_FULL_VALUE", $property["value"]); - $tpl->parseCurrentBlock(); - } - } - - // section header - if($this->section[$i]["hidden"]) - { - $tpl->setVariable("SECTION_HIDDEN", " style=\"display:none;\""); - $tpl->setVariable("SECTION_ID", "hidable_".$i); - } - else - { - $tpl->setVariable("SECTION_ID", $i); - } - $tpl->setVariable("TCLASS", $this->getTableClass()); - $tpl->setVariable("TXT_SECTION", $this->section[$i]["title"]); - $tpl->touchBlock("row"); - } - } - - return $tpl->get(); - } + */ +class ilFormATestInfoScreenGUI extends ilInfoScreenGUI +{ + + /** + * @var string + */ + protected $intro = ""; + + /** + * @param string $intro + */ + public function setIntro($intro) + { + $this->intro = $intro; + } + + /** + * get html + */ + public function getHTML() + { + global $DIC; + $lng = $DIC->language(); + $ilSetting = $DIC->settings(); + $ilCtrl = $DIC->ctrl(); + $ilUser = $DIC->user(); + + $tpl = new ilTemplate("tpl.infoscreen.html", true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest"); + + if ($this->intro != "") { + $this->addSection($this->lng->txt("tst_introduction")); + $this->addProperty("", $this->intro); + } + + // other class handles form action (@todo: this is not implemented/tested) + if ($this->form_action == "") { + $this->setFormAction($ilCtrl->getFormAction($this)); + } + + if ($this->hidden) { + $tpl->touchBlock("hidden_js"); + if ($this->show_hidden_toggle) { + $this->addButton($lng->txt("toggle_hidden_sections"), "JavaScript:toggleSections();"); + } + } + // add top buttons + if (is_array($this->top_buttons) && count($this->top_buttons) > 0) { + $tpl->addBlockfile("TOP_BUTTONS", "top_buttons", "tpl.buttons.html"); + + foreach ($this->top_buttons as $button) { + // view button + $tpl->setCurrentBlock("btn_cell"); + $tpl->setVariable("BTN_LINK", $button["link"]); + $tpl->setVariable("BTN_TARGET", $button["target"]); + $tpl->setVariable("BTN_TXT", $button["title"]); + if ($button["primary"]) { + $tpl->setVariable("BTN_CLASS", " emphsubmit"); + } + $tpl->parseCurrentBlock(); + } + } + + // add top formbuttons + if ((is_array($this->top_formbuttons) && count($this->top_formbuttons) > 0) && (strlen($this->form_action) > 0)) { + $tpl->addBlockfile("TOP_FORMBUTTONS", "top_submitbuttons", "tpl.submitbuttons.html", "Services/InfoScreen"); + + foreach ($this->top_formbuttons as $button) { + // view button + $tpl->setCurrentBlock("btn_submit_cell"); + $tpl->setVariable("BTN_COMMAND", $button["command"]); + $tpl->setVariable("BTN_NAME", $button["title"]); + $tpl->parseCurrentBlock(); + } + } + + // add form action + if (strlen($this->form_action) > 0) { + if ($this->open_form_tag) { + $tpl->setCurrentBlock("formtop"); + $tpl->setVariable("FORMACTION", $this->form_action); + $tpl->parseCurrentBlock(); + } + + if ($this->close_form_tag) { + $tpl->touchBlock("formbottom"); + } + } + + if (is_array($this->hiddenelements) && count($this->hiddenelements)) { + foreach ($this->hiddenelements as $hidden) { + $tpl->setCurrentBlock("hidden_element"); + $tpl->setVariable("HIDDEN_NAME", $hidden["name"]); + $tpl->setVariable("HIDDEN_VALUE", $hidden["value"]); + $tpl->parseCurrentBlock(); + } + } + + // learning progress + if ($this->learning_progress_enabled and $html = $this->showLearningProgress($tpl)) { + $tpl->setCurrentBlock("learning_progress"); + $tpl->setVariable("LP_TABLE", $html); + $tpl->parseCurrentBlock(); + } + + // notes section + if ($this->private_notes_enabled && !$ilSetting->get('disable_notes')) { + $html = $this->showNotesSection(); + $tpl->setCurrentBlock("notes"); + $tpl->setVariable("NOTES", $html); + $tpl->parseCurrentBlock(); + } + + // tagging + if (is_object($this->gui_object->object)) { + $tags_set = new ilSetting("tags"); + if ($tags_set->get("enable") && $ilUser->getId() != ANONYMOUS_USER_ID) { + $this->addTagging(); + } + } + + if (is_object($this->gui_object->object)) { + $this->addObjectSections(); + } + + // render all sections + for ($i = 1; $i <= $this->sec_nr; $i++) { + if (is_array($this->section[$i]["properties"])) { + // section properties + foreach ($this->section[$i]["properties"] as $property) { + if ($property["name"] != "") { + if ($property["link"] == "") { + $tpl->setCurrentBlock("pv"); + $tpl->setVariable("TXT_PROPERTY_VALUE", $property["value"]); + $tpl->parseCurrentBlock(); + } else { + $tpl->setCurrentBlock("lpv"); + $tpl->setVariable("TXT_PROPERTY_LVALUE", $property["value"]); + $tpl->setVariable("LINK_PROPERTY_VALUE", $property["link"]); + $tpl->parseCurrentBlock(); + } + $tpl->setCurrentBlock("property_row"); + $tpl->setVariable("TXT_PROPERTY", $property["name"]); + $tpl->parseCurrentBlock(); + } else { + $tpl->setCurrentBlock("property_full_row"); + $tpl->setVariable("TXT_PROPERTY_FULL_VALUE", $property["value"]); + $tpl->parseCurrentBlock(); + } + } + + // section header + if ($this->section[$i]["hidden"]) { + $tpl->setVariable("SECTION_HIDDEN", " style=\"display:none;\""); + $tpl->setVariable("SECTION_ID", "hidable_" . $i); + } else { + $tpl->setVariable("SECTION_ID", $i); + } + $tpl->setVariable("TCLASS", $this->getTableClass()); + $tpl->setVariable("TXT_SECTION", $this->section[$i]["title"]); + $tpl->touchBlock("row"); + } + } + + return $tpl->get(); + } } - \ No newline at end of file diff --git a/classes/utils/class.ilFormATestParticipantQuestionHeaderBuilder.php b/classes/utils/class.ilFormATestParticipantQuestionHeaderBuilder.php index 694eb89ae19a3d60825e506ee37c1c11149f60a9..4fff20bb2e3b13cdd58433cf3fd4b81948de5b11 100644 --- a/classes/utils/class.ilFormATestParticipantQuestionHeaderBuilder.php +++ b/classes/utils/class.ilFormATestParticipantQuestionHeaderBuilder.php @@ -1,70 +1,63 @@ - */ + */ class ilFormATestParticipantQuestionHeaderBuilder implements ilQuestionHeaderBlockBuilder { - /** - * @var ilPlugin - */ - protected $plugin; - - /** - * @var ilQuestionSetPoolNode - */ - protected $node; - - /** - * @var ilFormATestSession - */ - protected $session; - - /** - * @param ilPlugin $plugin - * @param ilQuestionSetPoolNode $node - * @param ilFormATestSession $session - */ - public function __construct($plugin, $node, $session) - { - $this->session = $session; - $this->node = $node; - $this->plugin = $plugin; - } - /** - * Get the HTML representation of the header block - * @return string - */ - public function getHTML() - { - $title = $this->node->getPath()->getSet()->getTitle() . " - " . $this->plugin->txt("header_step") . ": ". $this->session->getStep(); - - if($this->session->hasFixatedSolution($this->node->getId())) - { - $title .= ' ('.$this->plugin->txt("fixated_solution") . ')'; - } - elseif($this->session->isDeadlockPossible()) - { - $title .= ' ('.$this->plugin->txt("fixation_possible") . ')'; - } - return $title; - } - - public function getPresentationTitle() - { - return ''; - } - public function getQuestionInfoHTML() - { - return ''; - } - + /** + * @var ilPlugin + */ + protected $plugin; + + /** + * @var ilQuestionSetPoolNode + */ + protected $node; + + /** + * @var ilFormATestSession + */ + protected $session; + + /** + * @param ilPlugin $plugin + * @param ilQuestionSetPoolNode $node + * @param ilFormATestSession $session + */ + public function __construct($plugin, $node, $session) + { + $this->session = $session; + $this->node = $node; + $this->plugin = $plugin; + } + /** + * Get the HTML representation of the header block + * @return string + */ + public function getHTML() + { + $title = $this->node->getPath()->getSet()->getTitle() . " - " . $this->plugin->txt("header_step") . ": " . $this->session->getStep(); + + if ($this->session->hasFixatedSolution($this->node->getId())) { + $title .= ' (' . $this->plugin->txt("fixated_solution") . ')'; + } elseif ($this->session->isDeadlockPossible()) { + $title .= ' (' . $this->plugin->txt("fixation_possible") . ')'; + } + return $title; + } + + public function getPresentationTitle() + { + return ''; + } + public function getQuestionInfoHTML() + { + return ''; + } } - \ No newline at end of file diff --git a/classes/utils/class.ilFormATestQuestionHeaderBuilder.php b/classes/utils/class.ilFormATestQuestionHeaderBuilder.php index 3f48c7123e2c4b4da9588663423b55c4065cfa6e..40a35e2d13738815afb79c88ad26e71518f325a8 100644 --- a/classes/utils/class.ilFormATestQuestionHeaderBuilder.php +++ b/classes/utils/class.ilFormATestQuestionHeaderBuilder.php @@ -1,64 +1,61 @@ - */ + */ class ilFormATestQuestionHeaderBuilder implements ilQuestionHeaderBlockBuilder { - /** - * @var ilPlugin - */ - protected $plugin; + /** + * @var ilPlugin + */ + protected $plugin; - /** - * @var ilQuestionSetPoolNode - */ - protected $node; + /** + * @var ilQuestionSetPoolNode + */ + protected $node; - /** - * @var ilFormATestSession - */ - protected $session; + /** + * @var ilFormATestSession + */ + protected $session; - /** - * @param ilPlugin $plugin - * @param ilQuestionSetPoolNode $node - * @param ilFormATestSession $session - */ - public function __construct($plugin, $node, $session) - { - $this->session = $session; - $this->node = $node; - $this->plugin = $plugin; - } - /** - * Get the HTML representation of the header block - * @return string - */ - public function getHTML() - { - return sprintf( - $this->plugin->txt("question_title"), - $this->session->getStep(), - $this->node->getPath()->getTitle(), - $this->node->getQuestion()->getTitle() - ); - } - - public function getPresentationTitle() - { - return ''; - } - public function getQuestionInfoHTML() - { - return ''; - } + /** + * @param ilPlugin $plugin + * @param ilQuestionSetPoolNode $node + * @param ilFormATestSession $session + */ + public function __construct($plugin, $node, $session) + { + $this->session = $session; + $this->node = $node; + $this->plugin = $plugin; + } + /** + * Get the HTML representation of the header block + * @return string + */ + public function getHTML() + { + return sprintf( + $this->plugin->txt("question_title"), + $this->session->getStep(), + $this->node->getPath()->getTitle(), + $this->node->getQuestion()->getTitle() + ); + } + + public function getPresentationTitle() + { + return ''; + } + public function getQuestionInfoHTML() + { + return ''; + } } - \ No newline at end of file diff --git a/classes/utils/class.ilFormATestSkillAssQuestionList.php b/classes/utils/class.ilFormATestSkillAssQuestionList.php index f55faaf72e64554d28debdfe2d29f3b8dd5d93e8..b683353bfb33f9cf204a8243ffaaafd45df4afdb 100644 --- a/classes/utils/class.ilFormATestSkillAssQuestionList.php +++ b/classes/utils/class.ilFormATestSkillAssQuestionList.php @@ -1,7 +1,5 @@ orderSequence = array(); + /** + * @param ilDBInterface $db + * @param ilLanguage $lng + * @param ilPluginAdmin $pluginAdmin + * @param int $parentObjId + */ + public function __construct(ilDBInterface $db, ilLanguage $lng, ilPluginAdmin $pluginAdmin, $parentObjId) + { + $this->orderSequence = array(); - parent::__construct($db, $lng, $pluginAdmin); + parent::__construct($db, $lng, $pluginAdmin); - $this->setParentObjId($parentObjId); - } - - public function setProvider(ilXTSFTableDatabaseDataProvider $provider) - { - $this->provider = $provider; - } + $this->setParentObjId($parentObjId); + } + + public function setProvider(ilXTSFTableDatabaseDataProvider $provider) + { + $this->provider = $provider; + } - public function getProvider() - { - return $this->provider; - } - - - public function load() - { - parent::load(); + public function getProvider() + { + return $this->provider; + } + + + public function load() + { + parent::load(); - if($this->getProvider() instanceof ilXTSFTableDatabaseDataProvider) - { - $data = $this->getProvider()->loadData(array('obj_fi' => $this->getParentObjId())); - - foreach($data as $row) - { - $this->orderSequence[] = $row['question_fi']; - $questionId = $row['question_fi']; - if(array_key_exists($questionId, $this->questions)) - { - $title = $this->questions[$questionId]['title']; - $this->questions[$questionId]['title'] = '(Q' . $row['question_index'] . ') ' . $title . ' - ' . $row['title']; - } - } - } - } + if ($this->getProvider() instanceof ilXTSFTableDatabaseDataProvider) { + $data = $this->getProvider()->loadData(array('obj_fi' => $this->getParentObjId())); + + foreach ($data as $row) { + $this->orderSequence[] = $row['question_fi']; + $questionId = $row['question_fi']; + if (array_key_exists($questionId, $this->questions)) { + $title = $this->questions[$questionId]['title']; + $this->questions[$questionId]['title'] = '(Q' . $row['question_index'] . ') ' . $title . ' - ' . $row['title']; + } + } + } + } - /** - * @return array - */ - public function getOrderSequence() - { - return $this->orderSequence; - } + /** + * @return array + */ + public function getOrderSequence() + { + return $this->orderSequence; + } } - \ No newline at end of file diff --git a/classes/utils/class.ilFormATestSkillLevelHelper.php b/classes/utils/class.ilFormATestSkillLevelHelper.php index 9418c1265b83752b9c76250ac61575ae6f6682d3..b137fddd46933dc31ffd08245570635e3a6b8edf 100644 --- a/classes/utils/class.ilFormATestSkillLevelHelper.php +++ b/classes/utils/class.ilFormATestSkillLevelHelper.php @@ -14,159 +14,155 @@ require_once './Customizing/global/plugins/Services/Repository/RepositoryObject/ class ilFormATestSkillLevelHelper { - /** - * @var ilDBInterface - */ - protected $db; - - /** - * @var ilLanguage - */ - protected $lng; - - /** - * @var ilPluginAdmin - */ - protected $pluginAdmin; - - /** - * @var ilSetting - */ - protected $ilSettings; - - /** - * @var int - */ - protected $testId; - - /** - * @var ilFormATestSession - */ - protected $session; - - /** - * @var int - */ - protected $refId; - - public function __construct() - { - global $DIC; - - $this->db = $DIC->database(); - $this->lng = $DIC->language(); - $this->pluginAdmin = $DIC['ilPluginAdmin']; - $this->ilSetting = $DIC->settings(); - } - - /** - * @param ilObjFormATest $object - */ - public function trigger($object) - { - $skillEvaluation = $this->prepareSkillEvaluation(); - $questionList = $this->loadQuestionList($object); - $testResults = $this->getTestResults($object); - - $skillEvaluation->init($questionList); - $skillEvaluation->evaluate($testResults); - - $skillEvaluation->handleSkillTriggering(); - } - - /** - * @param \ilFormATestSession $session - */ - public function setSession($session) - { - $this->session = $session; - } - - /** - * @param int $testId - */ - public function setTestId($testId) - { - $this->testId = $testId; - } - - /** - * @param int $refId - */ - public function setRefId($refId) - { - $this->refId = $refId; - } - - /** - * @param ilObjFormATest - * - * @return ilFormATestSkillAssQuestionList - */ - public function loadQuestionList(ilObjFormATest $object) - { - $provider = new ilFormATestQuestionListProvider(); - - $questionList = new ilFormATestSkillAssQuestionList($this->db, $this->lng, $this->pluginAdmin, $object->getId()); - $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES); - $questionList->setProvider($provider); - $questionList->load(); - - return $questionList; - } - - /** - * @return ilTestSkillEvaluation - */ - protected function prepareSkillEvaluation() - { - require_once 'Modules/Test/classes/class.ilTestSkillEvaluation.php'; - $skillEvaluation = new ilTestSkillEvaluation($this->db, $this->testId, $this->refId); - - $skillEvaluation->setUserId($this->session->getUserId()); - $skillEvaluation->setActiveId($this->session->getActiveId()); - $skillEvaluation->setPass($this->session->getPass()); - - $skillEvaluation->setNumRequiredBookingsForSkillTriggering( - $this->ilSetting->get( - 'ass_skl_trig_num_answ_barrier', - ilObjAssessmentFolder::DEFAULT_SKL_TRIG_NUM_ANSWERS_BARRIER - ) - ); - - return $skillEvaluation; - } - - /** - * @param ilObjFormATest $object - * - * @return array - */ - public function getTestResults(ilObjFormATest $object) - { - $setProvider = new ilFormATestSetProvider(); - $sets = $setProvider->loadData(array('form_a_test' => $object->getId())); - - $results = array(); - foreach($sets as $set) - { - $provider = new ilFormATestSetResultList($object ,$set['id'], $this->session->getSessionId()); - $data = $provider->getData(); - $results = array_merge($results, $data); - } - - /** - * Manipulate results array to be usable by class.ilTestSkillLevelEvaluation.php - */ - foreach($results as $key => $result) - { - $results[$key]['reached'] = $result['reached_points']; - $results[$key]['points'] = $result['max_points']; - $results[$key]['qid'] = $result['question_fi']; - $results[$key]['workedthrough'] = true; - } - - return $results; - } + /** + * @var ilDBInterface + */ + protected $db; + + /** + * @var ilLanguage + */ + protected $lng; + + /** + * @var ilPluginAdmin + */ + protected $pluginAdmin; + + /** + * @var ilSetting + */ + protected $ilSettings; + + /** + * @var int + */ + protected $testId; + + /** + * @var ilFormATestSession + */ + protected $session; + + /** + * @var int + */ + protected $refId; + + public function __construct() + { + global $DIC; + + $this->db = $DIC->database(); + $this->lng = $DIC->language(); + $this->pluginAdmin = $DIC['ilPluginAdmin']; + $this->ilSetting = $DIC->settings(); + } + + /** + * @param ilObjFormATest $object + */ + public function trigger($object) + { + $skillEvaluation = $this->prepareSkillEvaluation(); + $questionList = $this->loadQuestionList($object); + $testResults = $this->getTestResults($object); + + $skillEvaluation->init($questionList); + $skillEvaluation->evaluate($testResults); + + $skillEvaluation->handleSkillTriggering(); + } + + /** + * @param \ilFormATestSession $session + */ + public function setSession($session) + { + $this->session = $session; + } + + /** + * @param int $testId + */ + public function setTestId($testId) + { + $this->testId = $testId; + } + + /** + * @param int $refId + */ + public function setRefId($refId) + { + $this->refId = $refId; + } + + /** + * @param ilObjFormATest + * + * @return ilFormATestSkillAssQuestionList + */ + public function loadQuestionList(ilObjFormATest $object) + { + $provider = new ilFormATestQuestionListProvider(); + + $questionList = new ilFormATestSkillAssQuestionList($this->db, $this->lng, $this->pluginAdmin, $object->getId()); + $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES); + $questionList->setProvider($provider); + $questionList->load(); + + return $questionList; + } + + /** + * @return ilTestSkillEvaluation + */ + protected function prepareSkillEvaluation() + { + $skillEvaluation = new ilTestSkillEvaluation($this->db, $this->testId, $this->refId); + + $skillEvaluation->setUserId($this->session->getUserId()); + $skillEvaluation->setActiveId($this->session->getActiveId()); + $skillEvaluation->setPass($this->session->getPass()); + + $skillEvaluation->setNumRequiredBookingsForSkillTriggering( + $this->ilSetting->get( + 'ass_skl_trig_num_answ_barrier', + ilObjAssessmentFolder::DEFAULT_SKL_TRIG_NUM_ANSWERS_BARRIER + ) + ); + + return $skillEvaluation; + } + + /** + * @param ilObjFormATest $object + * + * @return array + */ + public function getTestResults(ilObjFormATest $object) + { + $setProvider = new ilFormATestSetProvider(); + $sets = $setProvider->loadData(array('form_a_test' => $object->getId())); + + $results = array(); + foreach ($sets as $set) { + $provider = new ilFormATestSetResultList($object, $set['id'], $this->session->getSessionId()); + $data = $provider->getData(); + $results = array_merge($results, $data); + } + + /** + * Manipulate results array to be usable by class.ilTestSkillLevelEvaluation.php + */ + foreach ($results as $key => $result) { + $results[$key]['reached'] = $result['reached_points']; + $results[$key]['points'] = $result['max_points']; + $results[$key]['qid'] = $result['question_fi']; + $results[$key]['workedthrough'] = true; + } + + return $results; + } } - \ No newline at end of file diff --git a/classes/utils/class.ilObjTestGateway.php b/classes/utils/class.ilObjTestGateway.php index ca8b14386d82e204cd5ecd9893a0e9e6df487f3d..75883a2d6590d770ce7eefc6db6ba688e974e831 100644 --- a/classes/utils/class.ilObjTestGateway.php +++ b/classes/utils/class.ilObjTestGateway.php @@ -6,73 +6,72 @@ * Date: 13.01.14 * Time: 12:21 * @author Thomas Joußen - */ -class ilObjTestGateway { - - /** - * @param int $active_id - * @param int $pass - * - * @return array - */ - public function getQuestionCountAndPointsForPassOfParticipant($active_id, $pass) - { - global $DIC; - $ilDB = $DIC->database(); - - $data = array("count" => 0, "points" => 0); - $points = $this->getMaxPointsPerSet($active_id); - - $result = $ilDB->queryF( - "SELECT COUNT(tracking.step) qcount + */ +class ilObjTestGateway +{ + + /** + * @param int $active_id + * @param int $pass + * + * @return array + */ + public function getQuestionCountAndPointsForPassOfParticipant($active_id, $pass) + { + global $DIC; + $ilDB = $DIC->database(); + + $data = array("count" => 0, "points" => 0); + $points = $this->getMaxPointsPerSet($active_id); + + $result = $ilDB->queryF( + "SELECT COUNT(tracking.step) qcount FROM rep_robj_xtsf_tracking tracking INNER JOIN rep_robj_xtsf_session sess ON sess.session_id = tracking.session_fi WHERE sess.active_id = %s AND sess.current_pass = %s", - array("integer", "integer"), - array($active_id, $pass) - ); - - $row = $ilDB->fetchAssoc($result); - foreach($points as $element) - { - $data["points"] += $element; - } - - if(is_array($row)) - { - $data["count"] = $row["qcount"]; - } - - return $data; - } - - public function getWorkingTimeOfParticipantForPass($active_id, $pass) - { - global $DIC; - $ilDB = $DIC->database(); - - $result = $ilDB->queryF( - "SELECT start_date FROM rep_robj_xtsf_session WHERE active_id = %s AND current_pass = %s", - array("integer", "integer"), - array($active_id, $pass) - ); - - $row = $ilDB->fetchAssoc($result); - - $now = time(); - - return $now - $row["start_date"]; - } - - public function getMaxPointsPerSet($active_id) - { - global $DIC; - $ilDB = $DIC->database(); - - $points = array(); - - $result = $ilDB->queryF( - "SELECT SUM( + array("integer", "integer"), + array($active_id, $pass) + ); + + $row = $ilDB->fetchAssoc($result); + foreach ($points as $element) { + $data["points"] += $element; + } + + if (is_array($row)) { + $data["count"] = $row["qcount"]; + } + + return $data; + } + + public function getWorkingTimeOfParticipantForPass($active_id, $pass) + { + global $DIC; + $ilDB = $DIC->database(); + + $result = $ilDB->queryF( + "SELECT start_date FROM rep_robj_xtsf_session WHERE active_id = %s AND current_pass = %s", + array("integer", "integer"), + array($active_id, $pass) + ); + + $row = $ilDB->fetchAssoc($result); + + $now = time(); + + return $now - $row["start_date"]; + } + + public function getMaxPointsPerSet($active_id) + { + global $DIC; + $ilDB = $DIC->database(); + + $points = array(); + + $result = $ilDB->queryF( + "SELECT SUM( CASE WHEN node.dominant_scoring IS NOT NULL THEN node.dominant_scoring @@ -87,27 +86,20 @@ class ilObjTestGateway { INNER JOIN tst_active active ON active.test_fi = test.test_id WHERE active.active_id = %s GROUP BY path.id, set_id", - array("integer"), - array($active_id) - ); - - while(($row = $ilDB->fetchAssoc($result)) != null) - { - if(array_key_exists($row["set_id"], $points)) - { - if($points[$row["set_id"]] < $row["qsum"]) - { - $points[$row["set_id"]] = $row["qsum"]; - } - } - else - { - $points[$row["set_id"]] = $row["qsum"]; - } - } - - return $points; - } - + array("integer"), + array($active_id) + ); + + while (($row = $ilDB->fetchAssoc($result)) != null) { + if (array_key_exists($row["set_id"], $points)) { + if ($points[$row["set_id"]] < $row["qsum"]) { + $points[$row["set_id"]] = $row["qsum"]; + } + } else { + $points[$row["set_id"]] = $row["qsum"]; + } + } + + return $points; + } } - \ No newline at end of file diff --git a/interfaces/interface.ilConditionEvaluationObserver.php b/interfaces/interface.ilConditionEvaluationObserver.php index c78a6815801c48de94e08e3f1203a33b670104af..8fa061865b712d93000cbaa1015d53d4f4cf5245 100644 --- a/interfaces/interface.ilConditionEvaluationObserver.php +++ b/interfaces/interface.ilConditionEvaluationObserver.php @@ -8,10 +8,10 @@ require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/ */ interface ilConditionEvaluationObserver { - /** - * @param array $data - */ - public static function updateConditionEvaluation(array $data); - - public static function deleteFeedback($node_index, $set_id, $session_id); -} \ No newline at end of file + /** + * @param array $data + */ + public static function updateConditionEvaluation(array $data); + + public static function deleteFeedback($node_index, $set_id, $session_id); +} diff --git a/interfaces/interface.ilConditionEvaluationSubject.php b/interfaces/interface.ilConditionEvaluationSubject.php index 5815d1ba53cd49de25aec072424a90df3ddc61bc..2b28038306b03b2d6548b26b25d650cadd894dcf 100644 --- a/interfaces/interface.ilConditionEvaluationSubject.php +++ b/interfaces/interface.ilConditionEvaluationSubject.php @@ -6,18 +6,18 @@ */ interface ilConditionEvaluationSubject { - /** - * @param ilConditionEvaluationObserver $observer - */ - public static function attach(ilConditionEvaluationObserver $observer); + /** + * @param ilConditionEvaluationObserver $observer + */ + public static function attach(ilConditionEvaluationObserver $observer); - /** - * @param ilConditionEvaluationObserver $observer - */ - public static function detach(ilConditionEvaluationObserver $observer); + /** + * @param ilConditionEvaluationObserver $observer + */ + public static function detach(ilConditionEvaluationObserver $observer); - /** - * - */ - public static function notify(); -} \ No newline at end of file + /** + * + */ + public static function notify(); +} diff --git a/interfaces/interface.ilFormATestFeedbackConstants.php b/interfaces/interface.ilFormATestFeedbackConstants.php index 0925993c7049d0cb28f460b1997e1de585e694a5..cd2dfdfa179b0cdc2702b927319ed307b13ef3df 100644 --- a/interfaces/interface.ilFormATestFeedbackConstants.php +++ b/interfaces/interface.ilFormATestFeedbackConstants.php @@ -4,12 +4,12 @@ * User: nkrzywon * Date: 15.12.14 * Time: 10:24 - */ + */ interface ilFormATestFeedbackConstants { - const INITIAL_FEEDBACK_FALSE = 0; - const INITIAL_FEEDBACK_TRUE = 1; - const JMP_FEEDBACK_FALSE = 2; - const JMP_FEEDBACK_TRUE = 3; - const JMP_FEEDBACK_TRUE_JUMP = 4; -} \ No newline at end of file + const INITIAL_FEEDBACK_FALSE = 0; + const INITIAL_FEEDBACK_TRUE = 1; + const JMP_FEEDBACK_FALSE = 2; + const JMP_FEEDBACK_TRUE = 3; + const JMP_FEEDBACK_TRUE_JUMP = 4; +} diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 40b67b4aaff506d48261061ee384fa1e628f1601..c39ad61adec6b447f1799c03b8e25ca0082bcfbd 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -191,4 +191,7 @@ no_xqsp_pool_info#:#Wenn Sie, keinen FormATest-FragenSetPool verwenden, werden d existing_xqsp_pool#:#FormATest-FragenSetPool verwenden existing_xqsp_pool_info#:#Wählen Sie einen existierenden FormATest-FragenSetPool aus, oder lassen Sie einen neuen FragenSetPool automatisch erstellen. new_xqsp_pool#:#Neuen FragenSetPool erstellen und verwenden -select_xqsp_pool#:#FormATest-QuestionSets einfügen in \ No newline at end of file +select_xqsp_pool#:#FormATest-QuestionSets einfügen in +0_unlimited#:#(0 = unbegrenzt) +tst_results_access_never#:#Nie +tst_beginning_ending_information#:#Information at Beginning and End of Test \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 394a6641123eead35b6b4abb8a9d3275dc3ea13c..b1be9e2bd399f89636d5e83df145db1836c6f910 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -191,4 +191,7 @@ no_xqsp_pool_info#:#If you do not use a FormATest-QuestionSetPool, the imported existing_xqsp_pool#:#Use FormATest-QuestionSetPool existing_xqsp_pool_info#:#Select an existing FormATest-QuestionSetPool or create a new QuestionSetPool automatically. new_xqsp_pool#:#Create new QuestionSetPool -select_xqsp_pool#:#Insert FormATest-QuestionSets into \ No newline at end of file +select_xqsp_pool#:#Insert FormATest-QuestionSets into +0_unlimited#:#(0=unlimited) +tst_results_access_never#:#Never +tst_beginning_ending_information#:#Hinweis am Anfang und Ende des Tests \ No newline at end of file diff --git a/plugin.php b/plugin.php index 4f3d6fa07e0100a16fb4e6ffc4972e2c254aed25..3c46f8129ae6ed735f2fb9471fbfea688ce9b9b3 100644 --- a/plugin.php +++ b/plugin.php @@ -3,12 +3,12 @@ $id = 'xtsf'; // code version; must be changed for all code changes -$version = '6.0.0'; +$version = '7.0.2'; // ilias min and max version; must always reflect the versions that should // run with the plugin -$ilias_min_version = '5.3.0'; -$ilias_max_version = '5.4.999'; +$ilias_min_version = '6.0'; +$ilias_max_version = '6.999'; // optional, but useful: Add one or more responsible persons and a contact email $responsible = 'Thomas Joussen / Michael Jansen'; diff --git a/sql/dbupdate.php b/sql/dbupdate.php index 37a74f0a9402e02ce0052e63677e56ce572a7135..77aafa1cb241539a909884e9f3dfa2baeeb6a9b3 100644 --- a/sql/dbupdate.php +++ b/sql/dbupdate.php @@ -1,100 +1,96 @@ <#1> tableExists("rep_robj_xtsf_qs")) -{ - $fields = array( - 'obj_fi' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'questionset_fi' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => false - ), - 'sorting' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => false - ) - ); - $ilDB->createTable("rep_robj_xtsf_qs", $fields); - $ilDB->addPrimaryKey("rep_robj_xtsf_qs", array("obj_fi", "questionset_fi")); +if (!$ilDB->tableExists("rep_robj_xtsf_qs")) { + $fields = array( + 'obj_fi' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'questionset_fi' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => false + ), + 'sorting' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => false + ) + ); + $ilDB->createTable("rep_robj_xtsf_qs", $fields); + $ilDB->addPrimaryKey("rep_robj_xtsf_qs", array("obj_fi", "questionset_fi")); } ?> <#2> tableExists("rep_robj_xtsf_session")) -{ - $fields = array( - 'session_id' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'active_id' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'current_pass' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => false - ), - 'start_date' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'end_date' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => false - ), - ); +if (!$ilDB->tableExists("rep_robj_xtsf_session")) { + $fields = array( + 'session_id' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'active_id' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'current_pass' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => false + ), + 'start_date' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'end_date' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => false + ), + ); - $ilDB->createTable("rep_robj_xtsf_session", $fields); - $ilDB->addPrimaryKey("rep_robj_xtsf_session", array("session_id")); - $ilDB->createSequence("rep_robj_xtsf_session"); + $ilDB->createTable("rep_robj_xtsf_session", $fields); + $ilDB->addPrimaryKey("rep_robj_xtsf_session", array("session_id")); + $ilDB->createSequence("rep_robj_xtsf_session"); } ?> <#3> tableExists("rep_robj_xtsf_tracking")) -{ - $fields = array( - 'session_fi' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'step' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'node_fi' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - ); +if (!$ilDB->tableExists("rep_robj_xtsf_tracking")) { + $fields = array( + 'session_fi' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'step' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'node_fi' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + ); - $ilDB->createTable("rep_robj_xtsf_tracking", $fields); - $ilDB->addPrimaryKey("rep_robj_xtsf_tracking", array("session_fi", "step")); + $ilDB->createTable("rep_robj_xtsf_tracking", $fields); + $ilDB->addPrimaryKey("rep_robj_xtsf_tracking", array("session_fi", "step")); } ?> <#4> tableColumnExists("rep_robj_xtsf_tracking", "set_fi")) -{ - $ilDB->addTableColumn("rep_robj_xtsf_tracking", "set_fi", array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true - )); +if (!$ilDB->tableColumnExists("rep_robj_xtsf_tracking", "set_fi")) { + $ilDB->addTableColumn("rep_robj_xtsf_tracking", "set_fi", array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + )); } ?> <#5> @@ -104,488 +100,446 @@ $ilDB->addPrimaryKey("rep_robj_xtsf_tracking", array("session_fi", "step", "set_ ?> <#6> tableExists("rep_robj_xtsf_data")) -{ - $fields = array( - 'id' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true - ), - 'lp_mode' => array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => true, - 'default' => 0 - ) - ); - $ilDB->createTable('rep_robj_xtsf_data', $fields); - $ilDB->addPrimaryKey('rep_robj_xtsf_data', array('id')); - - $query = "SELECT od.obj_id FROM object_data od LEFT JOIN rep_robj_xtsf_data xtsfd ON xtsfd.id = od.obj_id WHERE xtsfd.id IS NULL AND od.type = " . $ilDB->quote('xtsf', 'text'); - $res = $ilDB->query($query); - while($row = $ilDB->fetchAssoc($res)) - { - $ilDB->manipulateF( - 'INSERT INTO rep_robj_xtsf_data (id) VALUES (%s)', - array('integer'), - array($row['obj_id']) - ); - } +if (!$ilDB->tableExists("rep_robj_xtsf_data")) { + $fields = array( + 'id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'lp_mode' => array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => true, + 'default' => 0 + ) + ); + $ilDB->createTable('rep_robj_xtsf_data', $fields); + $ilDB->addPrimaryKey('rep_robj_xtsf_data', array('id')); + + $query = "SELECT od.obj_id FROM object_data od LEFT JOIN rep_robj_xtsf_data xtsfd ON xtsfd.id = od.obj_id WHERE xtsfd.id IS NULL AND od.type = " . $ilDB->quote('xtsf', 'text'); + $res = $ilDB->query($query); + while ($row = $ilDB->fetchAssoc($res)) { + $ilDB->manipulateF( + 'INSERT INTO rep_robj_xtsf_data (id) VALUES (%s)', + array('integer'), + array($row['obj_id']) + ); + } } ?> <#7> tableExists("rep_robj_xtsf_data")) -{ - if(!$ilDB->tableColumnExists("rep_robj_xtsf_data", "is_online")) - { - $ilDB->addTableColumn("rep_robj_xtsf_data", "is_online", array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => false - )); - } - if(!$ilDB->tableColumnExists("rep_robj_xtsf_data", "max_passes")) - { - $ilDB->addTableColumn("rep_robj_xtsf_data", "max_passes", array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => false - )); - } - if(!$ilDB->tableColumnExists("rep_robj_xtsf_data", "process_time")) - { - $ilDB->addTableColumn("rep_robj_xtsf_data", "process_time", array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => false - )); - } - if(!$ilDB->tableColumnExists("rep_robj_xtsf_data", "allow_walk_back")) - { - $ilDB->addTableColumn("rep_robj_xtsf_data", "allow_walk_back", array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => false - )); - } - if(!$ilDB->tableColumnExists("rep_robj_xtsf_data", "show_current_track")) - { - $ilDB->addTableColumn("rep_robj_xtsf_data", "show_current_track", array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => false - )); - } - if(!$ilDB->tableColumnExists("rep_robj_xtsf_data", "allow_interruption")) - { - $ilDB->addTableColumn("rep_robj_xtsf_data", "allow_interruption", array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => false - )); - } - if(!$ilDB->tableColumnExists("rep_robj_xtsf_data", "show_intro_statement")) - { - $ilDB->addTableColumn("rep_robj_xtsf_data", "show_intro_statement", array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => false - )); - } - if(!$ilDB->tableColumnExists("rep_robj_xtsf_data", "show_final_statement")) - { - $ilDB->addTableColumn("rep_robj_xtsf_data", "show_final_statement", array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => false - )); - } - if(!$ilDB->tableColumnExists("rep_robj_xtsf_data", "intro_statement")) - { - $ilDB->addTableColumn("rep_robj_xtsf_data", "intro_statement", array( - 'type' => 'text', - 'length' => 4000, - 'notnull' => false - )); - } - if(!$ilDB->tableColumnExists("rep_robj_xtsf_data", "final_statement")) - { - $ilDB->addTableColumn("rep_robj_xtsf_data", "final_statement", array( - 'type' => 'text', - 'length' => 4000, - 'notnull' => false - )); - } +if ($ilDB->tableExists("rep_robj_xtsf_data")) { + if (!$ilDB->tableColumnExists("rep_robj_xtsf_data", "is_online")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "is_online", array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => false + )); + } + if (!$ilDB->tableColumnExists("rep_robj_xtsf_data", "max_passes")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "max_passes", array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => false + )); + } + if (!$ilDB->tableColumnExists("rep_robj_xtsf_data", "process_time")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "process_time", array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => false + )); + } + if (!$ilDB->tableColumnExists("rep_robj_xtsf_data", "allow_walk_back")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "allow_walk_back", array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => false + )); + } + if (!$ilDB->tableColumnExists("rep_robj_xtsf_data", "show_current_track")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "show_current_track", array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => false + )); + } + if (!$ilDB->tableColumnExists("rep_robj_xtsf_data", "allow_interruption")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "allow_interruption", array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => false + )); + } + if (!$ilDB->tableColumnExists("rep_robj_xtsf_data", "show_intro_statement")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "show_intro_statement", array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => false + )); + } + if (!$ilDB->tableColumnExists("rep_robj_xtsf_data", "show_final_statement")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "show_final_statement", array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => false + )); + } + if (!$ilDB->tableColumnExists("rep_robj_xtsf_data", "intro_statement")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "intro_statement", array( + 'type' => 'text', + 'length' => 4000, + 'notnull' => false + )); + } + if (!$ilDB->tableColumnExists("rep_robj_xtsf_data", "final_statement")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "final_statement", array( + 'type' => 'text', + 'length' => 4000, + 'notnull' => false + )); + } } ?> <#8> tableExists("rep_robj_xtsf_session")) -{ - if(!$ilDB->tableColumnExists("rep_robj_xtsf_session", "status")) - { - $ilDB->addTableColumn("rep_robj_xtsf_session", "status", array( - 'type' => 'text', - 'length' => 15, - 'notnull' => false - )); - } +if ($ilDB->tableExists("rep_robj_xtsf_session")) { + if (!$ilDB->tableColumnExists("rep_robj_xtsf_session", "status")) { + $ilDB->addTableColumn("rep_robj_xtsf_session", "status", array( + 'type' => 'text', + 'length' => 15, + 'notnull' => false + )); + } } ?> <#9> tableExists("rep_robj_xtsf_tracking")) -{ - - - if(!$ilDB->tableColumnExists("rep_robj_xtsf_tracking", "matched_condition_node_id")) - { - $ilDB->addTableColumn("rep_robj_xtsf_tracking", "matched_condition_node_id", array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => false - )); - } - if(!$ilDB->tableColumnExists("rep_robj_xtsf_tracking", "matched_condition")) - { - $ilDB->addTableColumn("rep_robj_xtsf_tracking", "matched_condition", array( - 'type' => 'text', - 'length' => 4000, - 'notnull' => false - )); - } - if(!$ilDB->tableColumnExists("rep_robj_xtsf_tracking", "matched_condition_id")) - { - $ilDB->addTableColumn("rep_robj_xtsf_tracking", "matched_condition_id", array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => false - )); - } +if ($ilDB->tableExists("rep_robj_xtsf_tracking")) { + if (!$ilDB->tableColumnExists("rep_robj_xtsf_tracking", "matched_condition_node_id")) { + $ilDB->addTableColumn("rep_robj_xtsf_tracking", "matched_condition_node_id", array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => false + )); + } + if (!$ilDB->tableColumnExists("rep_robj_xtsf_tracking", "matched_condition")) { + $ilDB->addTableColumn("rep_robj_xtsf_tracking", "matched_condition", array( + 'type' => 'text', + 'length' => 4000, + 'notnull' => false + )); + } + if (!$ilDB->tableColumnExists("rep_robj_xtsf_tracking", "matched_condition_id")) { + $ilDB->addTableColumn("rep_robj_xtsf_tracking", "matched_condition_id", array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => false + )); + } } ?> <#10> tableExists("rep_robj_xtsf_set_trck")) -{ - $fields = array( - 'session_fi' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'set_fi' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'status' => array( - 'type' => 'text', - 'length' => 15, - 'notnull' => false - ), - ); +if (!$ilDB->tableExists("rep_robj_xtsf_set_trck")) { + $fields = array( + 'session_fi' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'set_fi' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'status' => array( + 'type' => 'text', + 'length' => 15, + 'notnull' => false + ), + ); - $ilDB->createTable("rep_robj_xtsf_set_trck", $fields); - $ilDB->addPrimaryKey("rep_robj_xtsf_set_trck", array("session_fi", "set_fi")); + $ilDB->createTable("rep_robj_xtsf_set_trck", $fields); + $ilDB->addPrimaryKey("rep_robj_xtsf_set_trck", array("session_fi", "set_fi")); } ?> <#11> tableExists("rep_robj_xtsf_data")) -{ - if(!$ilDB->tableColumnExists("rep_robj_xtsf_data", "show_questions_overview")) - { - $ilDB->addTableColumn("rep_robj_xtsf_data", "show_questions_overview", array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => false - )); - } +if ($ilDB->tableExists("rep_robj_xtsf_data")) { + if (!$ilDB->tableColumnExists("rep_robj_xtsf_data", "show_questions_overview")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "show_questions_overview", array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => false + )); + } } ?> <#12> tableExists("rep_robj_xtsf_tracking")) -{ - if(!$ilDB->tableColumnExists("rep_robj_xtsf_tracking", "current_position")) - { - $ilDB->addTableColumn("rep_robj_xtsf_tracking", "current_position", array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => false - )); - } +if ($ilDB->tableExists("rep_robj_xtsf_tracking")) { + if (!$ilDB->tableColumnExists("rep_robj_xtsf_tracking", "current_position")) { + $ilDB->addTableColumn("rep_robj_xtsf_tracking", "current_position", array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => false + )); + } } ?> <#13> tableExists("rep_robj_xtsf_solut")) -{ - $fields = array( - 'solution_id' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'active_fi' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'question_fi' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'points' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => false - ), - 'pass' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'tstamp' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'value1' => array( - "type" => "clob", - 'notnull' => false - ), - 'value2' => array( - "type" => "clob", - 'notnull' => false - ), - 'step' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => false - ), - ); - $ilDB->createTable("rep_robj_xtsf_solut", $fields); - $ilDB->addPrimaryKey("rep_robj_xtsf_solut", array("solution_id")); - $ilDB->addIndex("rep_robj_xtsf_solut", array("question_fi"), "i1"); - $ilDB->addIndex("rep_robj_xtsf_solut", array("active_fi"), "i2"); +if (!$ilDB->tableExists("rep_robj_xtsf_solut")) { + $fields = array( + 'solution_id' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'active_fi' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'question_fi' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'points' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => false + ), + 'pass' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'tstamp' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'value1' => array( + "type" => "clob", + 'notnull' => false + ), + 'value2' => array( + "type" => "clob", + 'notnull' => false + ), + 'step' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => false + ), + ); + $ilDB->createTable("rep_robj_xtsf_solut", $fields); + $ilDB->addPrimaryKey("rep_robj_xtsf_solut", array("solution_id")); + $ilDB->addIndex("rep_robj_xtsf_solut", array("question_fi"), "i1"); + $ilDB->addIndex("rep_robj_xtsf_solut", array("active_fi"), "i2"); } ?> <#14> tableExists("rep_robj_xtsf_trck_his")) -{ - $fields = array( - 'session_fi' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'step' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'node_fi' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => true - ), - 'set_fi' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => false - ), - 'matched_condition_node_id' => array( - 'type' => 'integer', - 'length' => '4', - 'notnull' => false - ), - 'matched_condition' => array( - 'type' => 'text', - 'length' => 4000, - 'notnull' => false - ), - 'matched_condition_id' => array( - "type" => "integer", - "length" => 4, - 'notnull' => false - ), - ); - $ilDB->createTable("rep_robj_xtsf_trck_his", $fields); - $ilDB->addPrimaryKey("rep_robj_xtsf_trck_his", array("session_fi", "step", "set_fi")); +if (!$ilDB->tableExists("rep_robj_xtsf_trck_his")) { + $fields = array( + 'session_fi' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'step' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'node_fi' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => true + ), + 'set_fi' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => false + ), + 'matched_condition_node_id' => array( + 'type' => 'integer', + 'length' => '4', + 'notnull' => false + ), + 'matched_condition' => array( + 'type' => 'text', + 'length' => 4000, + 'notnull' => false + ), + 'matched_condition_id' => array( + "type" => "integer", + "length" => 4, + 'notnull' => false + ), + ); + $ilDB->createTable("rep_robj_xtsf_trck_his", $fields); + $ilDB->addPrimaryKey("rep_robj_xtsf_trck_his", array("session_fi", "step", "set_fi")); } ?> <#15> tableExists("rep_robj_xtsf_solut")) -{ - $ilDB->dropPrimaryKey("rep_robj_xtsf_solut"); - $ilDB->addPrimaryKey("rep_robj_xtsf_solut", array("solution_id", "step")); +if ($ilDB->tableExists("rep_robj_xtsf_solut")) { + $ilDB->dropPrimaryKey("rep_robj_xtsf_solut"); + $ilDB->addPrimaryKey("rep_robj_xtsf_solut", array("solution_id", "step")); } ?> <#16> tableExists("rep_robj_xtsf_tracking")) -{ - if($ilDB->tableColumnExists("rep_robj_xtsf_tracking", "current_position")) - { - $ilDB->dropTableColumn("rep_robj_xtsf_tracking", "current_position"); - } +if ($ilDB->tableExists("rep_robj_xtsf_tracking")) { + if ($ilDB->tableColumnExists("rep_robj_xtsf_tracking", "current_position")) { + $ilDB->dropTableColumn("rep_robj_xtsf_tracking", "current_position"); + } } ?> <#17> tableExists("rep_robj_xtsf_tracking")) -{ - $ilDB->dropPrimaryKey("rep_robj_xtsf_tracking"); - $ilDB->addPrimaryKey("rep_robj_xtsf_tracking", array("session_fi", "step", "set_fi")); +if ($ilDB->tableExists("rep_robj_xtsf_tracking")) { + $ilDB->dropPrimaryKey("rep_robj_xtsf_tracking"); + $ilDB->addPrimaryKey("rep_robj_xtsf_tracking", array("session_fi", "step", "set_fi")); } ?> <#18> tableExists("rep_robj_xtsf_solut")) -{ - $ilDB->addTableColumn("rep_robj_xtsf_solut", "fixated", array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => false - )); +if ($ilDB->tableExists("rep_robj_xtsf_solut")) { + $ilDB->addTableColumn("rep_robj_xtsf_solut", "fixated", array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => false + )); } ?> <#19> tableExists("rep_robj_xtsf_data")) -{ - $ilDB->addTableColumn("rep_robj_xtsf_data", "node_fb_author", array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => true, - 'default' => 0 - )); +if ($ilDB->tableExists("rep_robj_xtsf_data")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "node_fb_author", array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => true, + 'default' => 0 + )); } ?> <#20> tableExists("rep_robj_xtsf_data")) -{ - $ilDB->addTableColumn("rep_robj_xtsf_data", "node_fb_part", array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => true, - 'default' => 0 - )); +if ($ilDB->tableExists("rep_robj_xtsf_data")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "node_fb_part", array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => true, + 'default' => 0 + )); } ?> <#21> tableExists('rep_robj_xtsf_fbt')) -{ - $fields = array( - 'session_id' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true - ), - 'step' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true - ), - 'node_id' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true - ), - 'set_id' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => false - ), - 'condition_id' => array( - "type" => "integer", - "length" => 4, - 'notnull' => false - ), - 'feedback_type' => array( - "type" => "integer", - "length" => 1, - 'notnull' => true - ) - ); +if (!$ilDB->tableExists('rep_robj_xtsf_fbt')) { + $fields = array( + 'session_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'step' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'node_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'set_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => false + ), + 'condition_id' => array( + "type" => "integer", + "length" => 4, + 'notnull' => false + ), + 'feedback_type' => array( + "type" => "integer", + "length" => 1, + 'notnull' => true + ) + ); - $ilDB->createTable('rep_robj_xtsf_fbt', $fields); - $ilDB->addPrimaryKey("rep_robj_xtsf_fbt", array("session_id", "step", "node_id", "feedback_type")); + $ilDB->createTable('rep_robj_xtsf_fbt', $fields); + $ilDB->addPrimaryKey("rep_robj_xtsf_fbt", array("session_id", "step", "node_id", "feedback_type")); } ?> <#22> tableExists("rep_robj_xtsf_data")) -{ - $ilDB->addTableColumn("rep_robj_xtsf_data", "node_fb_part_res", array( - 'type' => 'integer', - 'length' => 1, - 'notnull' => true, - 'default' => 0 - )); +if ($ilDB->tableExists("rep_robj_xtsf_data")) { + $ilDB->addTableColumn("rep_robj_xtsf_data", "node_fb_part_res", array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => true, + 'default' => 0 + )); } ?> <#23> tableExists('rep_robj_xtsf_fbt')) -{ - if(!$ilDB->tableColumnExists('rep_robj_xtsf_fbt', 'fbt_time')) - { - $ilDB->addTableColumn('rep_robj_xtsf_fbt', 'fbt_time', array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true, - 'default' => 0 - )); - } +if ($ilDB->tableExists('rep_robj_xtsf_fbt')) { + if (!$ilDB->tableColumnExists('rep_robj_xtsf_fbt', 'fbt_time')) { + $ilDB->addTableColumn('rep_robj_xtsf_fbt', 'fbt_time', array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true, + 'default' => 0 + )); + } } ?> <#24> tableExists('rep_robj_xtsf_fbt')) -{ - if(!$ilDB->tableColumnExists('rep_robj_xtsf_fbt', 'fbt_id')) - { - $ilDB->addTableColumn('rep_robj_xtsf_fbt', 'fbt_id', array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true, - 'default' => 0 - )); - } +if ($ilDB->tableExists('rep_robj_xtsf_fbt')) { + if (!$ilDB->tableColumnExists('rep_robj_xtsf_fbt', 'fbt_id')) { + $ilDB->addTableColumn('rep_robj_xtsf_fbt', 'fbt_id', array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true, + 'default' => 0 + )); + } } $query = "SELECT * FROM rep_robj_xtsf_fbt"; -$res = $ilDB->query($query); +$res = $ilDB->query($query); $counter = 1; -while($row = $ilDB->fetchAssoc($res)) -{ - $ilDB->update( - 'rep_robj_xtsf_fbt', - array( - 'fbt_id' => array('integer', $counter) - ), - array( - 'session_id' => array('integer', $row['session_id']), - 'step' => array('integer', $row['step']), - 'node_id' => array('integer', $row['node_id']), - 'feedback_type' => array('integer', $row['feedback_type']) - ) - ); - ++$counter; +while ($row = $ilDB->fetchAssoc($res)) { + $ilDB->update( + 'rep_robj_xtsf_fbt', + array( + 'fbt_id' => array('integer', $counter) + ), + array( + 'session_id' => array('integer', $row['session_id']), + 'step' => array('integer', $row['step']), + 'node_id' => array('integer', $row['node_id']), + 'feedback_type' => array('integer', $row['feedback_type']) + ) + ); + ++$counter; } $ilDB->dropPrimaryKey('rep_robj_xtsf_fbt'); $ilDB->addPrimaryKey('rep_robj_xtsf_fbt', array('fbt_id')); @@ -597,33 +551,27 @@ $ilDB->createSequence('rep_robj_xtsf_fbt', $counter + 1); <#26> indexExistsByFields('rep_robj_xtsf_fbt', array('session_id'))) -{ - $ilDB->addIndex("rep_robj_xtsf_fbt", array("session_id"), "i1"); +if (!$ilDB->indexExistsByFields('rep_robj_xtsf_fbt', array('session_id'))) { + $ilDB->addIndex("rep_robj_xtsf_fbt", array("session_id"), "i1"); } -if(!$ilDB->indexExistsByFields('rep_robj_xtsf_fbt', array('node_id'))) -{ - $ilDB->addIndex("rep_robj_xtsf_fbt", array("node_id"), "i2"); +if (!$ilDB->indexExistsByFields('rep_robj_xtsf_fbt', array('node_id'))) { + $ilDB->addIndex("rep_robj_xtsf_fbt", array("node_id"), "i2"); } -if(!$ilDB->indexExistsByFields('rep_robj_xtsf_fbt', array('set_id'))) -{ - $ilDB->addIndex("rep_robj_xtsf_fbt", array("set_id"), "i3"); +if (!$ilDB->indexExistsByFields('rep_robj_xtsf_fbt', array('set_id'))) { + $ilDB->addIndex("rep_robj_xtsf_fbt", array("set_id"), "i3"); } -if(!$ilDB->indexExistsByFields('rep_robj_xtsf_fbt', array('condition_id'))) -{ - $ilDB->addIndex("rep_robj_xtsf_fbt", array("condition_id"), "i4"); +if (!$ilDB->indexExistsByFields('rep_robj_xtsf_fbt', array('condition_id'))) { + $ilDB->addIndex("rep_robj_xtsf_fbt", array("condition_id"), "i4"); } -if(!$ilDB->indexExistsByFields('rep_robj_xtsf_tracking', array('node_fi'))) -{ - $ilDB->addIndex("rep_robj_xtsf_tracking", array("node_fi"), "i1"); +if (!$ilDB->indexExistsByFields('rep_robj_xtsf_tracking', array('node_fi'))) { + $ilDB->addIndex("rep_robj_xtsf_tracking", array("node_fi"), "i1"); } -if(!$ilDB->indexExistsByFields('rep_robj_xtsf_trck_his', array('node_fi'))) -{ - $ilDB->addIndex("rep_robj_xtsf_trck_his", array("node_fi"), "i2"); +if (!$ilDB->indexExistsByFields('rep_robj_xtsf_trck_his', array('node_fi'))) { + $ilDB->addIndex("rep_robj_xtsf_trck_his", array("node_fi"), "i2"); } ?> diff --git a/templates/default/tpl.accordion.html b/templates/default/tpl.accordion.html index d9e930853c3332222223e2b104863f72d4fd6456..8e65cc6a3f057bed417462d42505ab439fb0ce80 100644 --- a/templates/default/tpl.accordion.html +++ b/templates/default/tpl.accordion.html @@ -10,14 +10,14 @@