Skip to content
<?php <?php
include_once("./Services/Repository/classes/class.ilRepositoryObjectPlugin.php");
/** /**
* Class ilQuestionSetPoolPlugin * Class ilQuestionSetPoolPlugin
* *
...@@ -73,8 +71,7 @@ class ilQuestionSetPoolPlugin extends ilRepositoryObjectPlugin ...@@ -73,8 +71,7 @@ class ilQuestionSetPoolPlugin extends ilRepositoryObjectPlugin
*/ */
public static function getInstance() public static function getInstance()
{ {
if(null !== self::$instance) if (null !== self::$instance) {
{
return self::$instance; return self::$instance;
} }
...@@ -110,7 +107,9 @@ class ilQuestionSetPoolPlugin extends ilRepositoryObjectPlugin ...@@ -110,7 +107,9 @@ class ilQuestionSetPoolPlugin extends ilRepositoryObjectPlugin
public static function _getIcon($a_type, $a_size) public static function _getIcon($a_type, $a_size)
{ {
return ilPlugin::_getImagePath( return ilPlugin::_getImagePath(
IL_COMP_SERVICE, 'Repository', 'robj', IL_COMP_SERVICE,
'Repository',
'robj',
ilPlugin::lookupNameForId(IL_COMP_SERVICE, 'Repository', 'robj', $a_type), ilPlugin::lookupNameForId(IL_COMP_SERVICE, 'Repository', 'robj', $a_type),
'icon_' . $a_type . '.svg' 'icon_' . $a_type . '.svg'
); );
...@@ -123,49 +122,39 @@ class ilQuestionSetPoolPlugin extends ilRepositoryObjectPlugin ...@@ -123,49 +122,39 @@ class ilQuestionSetPoolPlugin extends ilRepositoryObjectPlugin
*/ */
global $ilDB; global $ilDB;
if($ilDB->tableExists('rep_robj_xqsp_data')) if ($ilDB->tableExists('rep_robj_xqsp_data')) {
{
$ilDB->dropTable('rep_robj_xqsp_data'); $ilDB->dropTable('rep_robj_xqsp_data');
} }
if($ilDB->tableExists('rep_robj_xqsp_jmp_con')) if ($ilDB->tableExists('rep_robj_xqsp_jmp_con')) {
{
$ilDB->dropTable('rep_robj_xqsp_jmp_con'); $ilDB->dropTable('rep_robj_xqsp_jmp_con');
} }
if($ilDB->sequenceExists('rep_robj_xqsp_jmp_con')) if ($ilDB->sequenceExists('rep_robj_xqsp_jmp_con')) {
{
$ilDB->dropSequence('rep_robj_xqsp_jmp_con'); $ilDB->dropSequence('rep_robj_xqsp_jmp_con');
} }
if($ilDB->tableExists('rep_robj_xqsp_node')) if ($ilDB->tableExists('rep_robj_xqsp_node')) {
{
$ilDB->dropTable('rep_robj_xqsp_node'); $ilDB->dropTable('rep_robj_xqsp_node');
} }
if($ilDB->sequenceExists('rep_robj_xqsp_node')) if ($ilDB->sequenceExists('rep_robj_xqsp_node')) {
{
$ilDB->dropSequence('rep_robj_xqsp_node'); $ilDB->dropSequence('rep_robj_xqsp_node');
} }
if($ilDB->tableExists('rep_robj_xqsp_path')) if ($ilDB->tableExists('rep_robj_xqsp_path')) {
{
$ilDB->dropTable('rep_robj_xqsp_path'); $ilDB->dropTable('rep_robj_xqsp_path');
} }
if($ilDB->sequenceExists('rep_robj_xqsp_path')) if ($ilDB->sequenceExists('rep_robj_xqsp_path')) {
{
$ilDB->dropSequence('rep_robj_xqsp_path'); $ilDB->dropSequence('rep_robj_xqsp_path');
} }
if($ilDB->tableExists('rep_robj_xqsp_qs')) if ($ilDB->tableExists('rep_robj_xqsp_qs')) {
{
$ilDB->dropTable('rep_robj_xqsp_qs'); $ilDB->dropTable('rep_robj_xqsp_qs');
} }
if($ilDB->sequenceExists('rep_robj_xqsp_qs')) if ($ilDB->sequenceExists('rep_robj_xqsp_qs')) {
{
$ilDB->dropSequence('rep_robj_xqsp_qs'); $ilDB->dropSequence('rep_robj_xqsp_qs');
} }
if($ilDB->tableExists('rep_robj_xqsp_qs_qst')) if ($ilDB->tableExists('rep_robj_xqsp_qs_qst')) {
{
$ilDB->dropTable('rep_robj_xqsp_qs_qst'); $ilDB->dropTable('rep_robj_xqsp_qs_qst');
} }
} }
......
...@@ -52,12 +52,12 @@ class ilQuestionSetPoolXmlValidator ...@@ -52,12 +52,12 @@ class ilQuestionSetPoolXmlValidator
/** /**
* @var null * @var null
*/ */
protected $xml_file = NULL; protected $xml_file = null;
/** /**
* @var null * @var null
*/ */
protected $xsd_file = NULL; protected $xsd_file = null;
/** /**
* @var string * @var string
...@@ -224,13 +224,11 @@ class ilQuestionSetPoolXmlValidator ...@@ -224,13 +224,11 @@ class ilQuestionSetPoolXmlValidator
// validate against schema // validate against schema
$this->setXml(@file_get_contents($this->getXmlFile())); $this->setXml(@file_get_contents($this->getXmlFile()));
if(!$this->validateXml($this->getXml(), false)) if (!$this->validateXml($this->getXml(), false)) {
{
return true; return true;
} }
if(is_array($this->errors) && count($this->errors)) if (is_array($this->errors) && count($this->errors)) {
{
return false; return false;
} }
return true; return true;
...@@ -251,15 +249,12 @@ class ilQuestionSetPoolXmlValidator ...@@ -251,15 +249,12 @@ class ilQuestionSetPoolXmlValidator
$dom->loadXML($a_xml); $dom->loadXML($a_xml);
$dom->schemaValidate($this->getSchema()); $dom->schemaValidate($this->getSchema());
foreach(libxml_get_errors() as $error) foreach (libxml_get_errors() as $error) {
{
ilLoggerFactory::getLogger('xqsp')->warning('XML schema validation failed: ' . $error->line . ': ' . $error->message); ilLoggerFactory::getLogger('xqsp')->warning('XML schema validation failed: ' . $error->line . ': ' . $error->message);
/* @var $error LibXMLError */ /* @var $error LibXMLError */
if($error->code == self::DOM_MISSING_NS_CODE) if ($error->code == self::DOM_MISSING_NS_CODE) {
{ if (!$a_add_default_namespace) {
if(!$a_add_default_namespace)
{
// add default namespace to xml // add default namespace to xml
$xml = simplexml_load_string($a_xml); $xml = simplexml_load_string($a_xml);
$xml->addAttribute('xmlns', self::NAME_SPACE_URI); $xml->addAttribute('xmlns', self::NAME_SPACE_URI);
...@@ -268,18 +263,14 @@ class ilQuestionSetPoolXmlValidator ...@@ -268,18 +263,14 @@ class ilQuestionSetPoolXmlValidator
libxml_clear_errors(); libxml_clear_errors();
return $this->validateXml($xml->asXML(), true); return $this->validateXml($xml->asXML(), true);
} }
} } else {
else
{
$this->errors[] = $error->line . ': ' . $error->message; $this->errors[] = $error->line . ': ' . $error->message;
} }
} }
libxml_clear_errors(); libxml_clear_errors();
if(is_array($this->errors) && count($this->errors)) if (is_array($this->errors) && count($this->errors)) {
{
return false; return false;
} }
return true; return true;
} }
} }
...@@ -29,8 +29,7 @@ abstract class ilPluginControllerFormGUI extends ilPluginControllerGUI ...@@ -29,8 +29,7 @@ abstract class ilPluginControllerFormGUI extends ilPluginControllerGUI
{ {
$model = $this->loadModel(); $model = $this->loadModel();
$this->initForm($model); $this->initForm($model);
if($this->form->checkInput()) if ($this->form->checkInput()) {
{
$model->bindForm($this->form); $model->bindForm($this->form);
$model->update(); $model->update();
ilUtil::sendSuccess($this->plugin->txt("msg_obj_modified"), true); ilUtil::sendSuccess($this->plugin->txt("msg_obj_modified"), true);
......
...@@ -9,7 +9,8 @@ require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/ ...@@ -9,7 +9,8 @@ require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/
* Time: 14:10 * Time: 14:10
* @author Thomas Joußen <tjoussen@databay.de> * @author Thomas Joußen <tjoussen@databay.de>
*/ */
abstract class ilPluginControllerGUI { abstract class ilPluginControllerGUI
{
/** /**
* The main Controller of the Plugin * The main Controller of the Plugin
...@@ -34,7 +35,7 @@ abstract class ilPluginControllerGUI { ...@@ -34,7 +35,7 @@ abstract class ilPluginControllerGUI {
protected $tpl; protected $tpl;
/** /**
* @var iPlugin * @var ilPlugin
*/ */
protected $plugin; protected $plugin;
...@@ -53,6 +54,11 @@ abstract class ilPluginControllerGUI { ...@@ -53,6 +54,11 @@ abstract class ilPluginControllerGUI {
*/ */
protected $user; protected $user;
/** @var \ILIAS\UI\Factory */
protected $uiFactory;
/** @var \ILIAS\UI\Renderer */
protected $uiRenderer;
/** /**
* @param ilObjQuestionSetPoolGUI $controller * @param ilObjQuestionSetPoolGUI $controller
*/ */
...@@ -68,6 +74,9 @@ abstract class ilPluginControllerGUI { ...@@ -68,6 +74,9 @@ abstract class ilPluginControllerGUI {
$this->toolbar = $DIC->toolbar(); $this->toolbar = $DIC->toolbar();
$this->tabs = $DIC->tabs(); $this->tabs = $DIC->tabs();
$this->user = $DIC->user(); $this->user = $DIC->user();
$this->uiFactory = $DIC->ui()->factory();
$this->uiRenderer = $DIC->ui()->renderer();
$this->activateTab(); $this->activateTab();
$this->includeRequirements(); $this->includeRequirements();
} }
...@@ -79,20 +88,17 @@ abstract class ilPluginControllerGUI { ...@@ -79,20 +88,17 @@ abstract class ilPluginControllerGUI {
protected function addToolbarButton($text, $command, array $params = array()) protected function addToolbarButton($text, $command, array $params = array())
{ {
if($this->toolbar == null) if ($this->toolbar == null) {
{
$this->initToolbar(); $this->initToolbar();
} }
foreach($params as $key => $param) foreach ($params as $key => $param) {
{
$this->ctrl->setParameter($this->controller, $key, $param); $this->ctrl->setParameter($this->controller, $key, $param);
} }
$link = $this->ctrl->getLinkTarget($this->controller, $command); $link = $this->ctrl->getLinkTarget($this->controller, $command);
foreach($params as $key => $param) foreach ($params as $key => $param) {
{
$this->ctrl->setParameter($this->controller, $key, ""); $this->ctrl->setParameter($this->controller, $key, "");
} }
...@@ -111,10 +117,8 @@ abstract class ilPluginControllerGUI { ...@@ -111,10 +117,8 @@ abstract class ilPluginControllerGUI {
{ {
$requirements = $this->getRequirements(); $requirements = $this->getRequirements();
if(!empty($requirements)) if (!empty($requirements)) {
{ foreach ($requirements as $requirement) {
foreach($requirements as $requirement)
{
require_once $this->controller->plugin->getDirectory() . DIRECTORY_SEPARATOR . "classes" . DIRECTORY_SEPARATOR . $requirement; require_once $this->controller->plugin->getDirectory() . DIRECTORY_SEPARATOR . "classes" . DIRECTORY_SEPARATOR . $requirement;
} }
} }
...@@ -122,8 +126,7 @@ abstract class ilPluginControllerGUI { ...@@ -122,8 +126,7 @@ abstract class ilPluginControllerGUI {
protected function redirect($command, $params = array()) protected function redirect($command, $params = array())
{ {
foreach($params as $key => $param) foreach ($params as $key => $param) {
{
$this->ctrl->setParameter($this->controller, $key, $param); $this->ctrl->setParameter($this->controller, $key, $param);
} }
......
...@@ -13,7 +13,6 @@ require_once "Customizing/global/plugins/Services/Repository/RepositoryObject/Qu ...@@ -13,7 +13,6 @@ require_once "Customizing/global/plugins/Services/Repository/RepositoryObject/Qu
*/ */
abstract class ilQuestionSetPoolConditionGUI extends ilPluginControllerFormGUI abstract class ilQuestionSetPoolConditionGUI extends ilPluginControllerFormGUI
{ {
public function showPreview() public function showPreview()
{ {
$gui = assQuestion::instantiateQuestionGUI((int) $_GET["question_id"]); $gui = assQuestion::instantiateQuestionGUI((int) $_GET["question_id"]);
...@@ -28,7 +27,7 @@ abstract class ilQuestionSetPoolConditionGUI extends ilPluginControllerFormGUI ...@@ -28,7 +27,7 @@ abstract class ilQuestionSetPoolConditionGUI extends ilPluginControllerFormGUI
*/ */
public function afterQuestionChanged() public function afterQuestionChanged()
{ {
$template = new ilTemplate('tpl.il_xqsp_after_question_changed.html', FALSE, FALSE, 'Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool'); $template = new ilTemplate('tpl.il_xqsp_after_question_changed.html', false, false, 'Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool');
$this->tpl->setContent($template->get()); $this->tpl->setContent($template->get());
} }
...@@ -43,15 +42,12 @@ abstract class ilQuestionSetPoolConditionGUI extends ilPluginControllerFormGUI ...@@ -43,15 +42,12 @@ abstract class ilQuestionSetPoolConditionGUI extends ilPluginControllerFormGUI
$this->controller->populateContentStyleBlock(); $this->controller->populateContentStyleBlock();
$this->controller->populateSyntaxStyleBlock(); $this->controller->populateSyntaxStyleBlock();
include_once "./Services/Administration/classes/class.ilSetting.php";
$mathJaxSetting = new ilSetting("MathJax"); $mathJaxSetting = new ilSetting("MathJax");
if($mathJaxSetting->get("enable")) if ($mathJaxSetting->get("enable")) {
{
$this->controller->tpl->addJavaScript($mathJaxSetting->get("path_to_mathjax")); $this->controller->tpl->addJavaScript($mathJaxSetting->get("path_to_mathjax"));
} }
foreach ($questions as $key => $question_data) foreach ($questions as $key => $question_data) {
{
$params = array( $params = array(
'node_id' => (int) $_GET['node_id'], 'node_id' => (int) $_GET['node_id'],
'cmd' => get_class($this) . '.afterQuestionChanged' 'cmd' => get_class($this) . '.afterQuestionChanged'
...@@ -72,9 +68,7 @@ abstract class ilQuestionSetPoolConditionGUI extends ilPluginControllerFormGUI ...@@ -72,9 +68,7 @@ abstract class ilQuestionSetPoolConditionGUI extends ilPluginControllerFormGUI
$template->setVariable("TXT_QUESTION", $this->controller->lng->txt('question')); $template->setVariable("TXT_QUESTION", $this->controller->lng->txt('question'));
$template->setVariable("TXT_ACTIONS", $this->controller->lng->txt('actions')); $template->setVariable("TXT_ACTIONS", $this->controller->lng->txt('actions'));
$template->setVariable("PREVIEW_LINK", $this->ctrl->getLinkTarget($this->controller, get_class($this) . ".showPreview", "", true)); $template->setVariable("PREVIEW_LINK", $this->ctrl->getLinkTarget($this->controller, get_class($this) . ".showPreview", "", true));
include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
$template->setVariable('CLOSE_IMG_SRC', ilGlyphGUI::get(ilGlyphGUI::CLOSE)); $template->setVariable('CLOSE_IMG_SRC', ilGlyphGUI::get(ilGlyphGUI::CLOSE));
$template->setVariable('CLOSE_IMG_ALT', $this->controller->lng->txt('close')); $template->setVariable('CLOSE_IMG_ALT', $this->controller->lng->txt('close'));
} }
} }
...@@ -20,9 +20,7 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -20,9 +20,7 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI
public function edit() public function edit()
{ {
include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
iljQueryUtil::initjQuery(); iljQueryUtil::initjQuery();
include_once 'Services/YUI/classes/class.ilYuiUtil.php';
ilYuiUtil::initPanel(); ilYuiUtil::initPanel();
ilYuiUtil::initOverlay(); ilYuiUtil::initOverlay();
$this->tpl->addJavascript('./Services/UIComponent/Overlay/js/ilOverlay.js'); $this->tpl->addJavascript('./Services/UIComponent/Overlay/js/ilOverlay.js');
...@@ -39,7 +37,6 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -39,7 +37,6 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI
$template->setVariable("FORM", $this->form->getHTML()); $template->setVariable("FORM", $this->form->getHTML());
$template->setVariable("INFO", ilQuestionSetPoolInfoBox::render($this->plugin)); $template->setVariable("INFO", ilQuestionSetPoolInfoBox::render($this->plugin));
require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
$button = ilLinkButton::getInstance(); $button = ilLinkButton::getInstance();
$button->addCSSClass('toggle_feedback'); $button->addCSSClass('toggle_feedback');
$button->setCaption($this->plugin->txt('hide_feedback_form_parts'), false); $button->setCaption($this->plugin->txt('hide_feedback_form_parts'), false);
...@@ -54,8 +51,7 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -54,8 +51,7 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI
{ {
$model = $this->loadModel(); $model = $this->loadModel();
$this->initForm($model); $this->initForm($model);
if($this->form->checkInput()) if ($this->form->checkInput()) {
{
$model->bindForm($this->form); $model->bindForm($this->form);
$isValid = ilQuestionSetPoolConditionValidator::isValid( $isValid = ilQuestionSetPoolConditionValidator::isValid(
...@@ -65,8 +61,7 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -65,8 +61,7 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI
$this->plugin $this->plugin
); );
if($isValid) if ($isValid) {
{
$model->update(); $model->update();
$this->copyTemporaryMobs($model); $this->copyTemporaryMobs($model);
...@@ -127,8 +122,6 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -127,8 +122,6 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI
*/ */
protected function initForm($model) protected function initForm($model)
{ {
require_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
$this->form = new ilPropertyFormGUI(); $this->form = new ilPropertyFormGUI();
$this->form->setName('condition_form'); $this->form->setName('condition_form');
$this->form->setTableWidth("100%"); $this->form->setTableWidth("100%");
...@@ -150,7 +143,7 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -150,7 +143,7 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI
$this->form->addItem($initial_condition); $this->form->addItem($initial_condition);
$true_feedback = new ilTextAreaInputGUI($this->plugin->txt('true_feedback'), 'true_feedback'); $true_feedback = new ilTextAreaInputGUI($this->plugin->txt('true_feedback'), 'true_feedback');
$true_feedback->setUseRte(TRUE); $true_feedback->setUseRte(true);
$true_feedback->addPlugin("latex"); $true_feedback->addPlugin("latex");
$true_feedback->addButton("latex"); $true_feedback->addButton("latex");
$true_feedback->setRTESupport($model->getId(), 'x_itf:html', 'assessment'); $true_feedback->setRTESupport($model->getId(), 'x_itf:html', 'assessment');
...@@ -158,7 +151,7 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -158,7 +151,7 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI
$this->form->addItem($true_feedback); $this->form->addItem($true_feedback);
$false_feedback = new ilTextAreaInputGUI($this->plugin->txt('false_feedback'), 'false_feedback'); $false_feedback = new ilTextAreaInputGUI($this->plugin->txt('false_feedback'), 'false_feedback');
$false_feedback->setUseRte(TRUE); $false_feedback->setUseRte(true);
$false_feedback->addPlugin("latex"); $false_feedback->addPlugin("latex");
$false_feedback->addButton("latex"); $false_feedback->addButton("latex");
$false_feedback->setRTESupport($model->getId(), 'x_iff:html', 'assessment'); $false_feedback->setRTESupport($model->getId(), 'x_iff:html', 'assessment');
...@@ -226,16 +219,12 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -226,16 +219,12 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI
global $DIC; global $DIC;
$ilUser = $DIC->user(); $ilUser = $DIC->user();
foreach($this->feedback_types as $type) foreach ($this->feedback_types as $type) {
{
$mediaObjects = ilRTE::_getMediaObjects($this->form->getInput($type['post_var']), 0); $mediaObjects = ilRTE::_getMediaObjects($this->form->getInput($type['post_var']), 0);
$myMediaObjects = ilObjMediaObject::_getMobsOfObject('x_' . $type['obj_type'] . ':html', $ilUser->getId()); $myMediaObjects = ilObjMediaObject::_getMobsOfObject('x_' . $type['obj_type'] . ':html', $ilUser->getId());
foreach($mediaObjects as $mob) foreach ($mediaObjects as $mob) {
{ foreach ($myMediaObjects as $myMob) {
foreach($myMediaObjects as $myMob) if ($mob == $myMob) {
{
if($mob == $myMob)
{
// change usage // change usage
ilObjMediaObject::_removeUsage($mob, 'x_' . $type['obj_type'] . ':html', $ilUser->getId()); ilObjMediaObject::_removeUsage($mob, 'x_' . $type['obj_type'] . ':html', $ilUser->getId());
break; break;
...@@ -248,27 +237,19 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -248,27 +237,19 @@ class ilQuestionSetPoolInitialConditionGUI extends ilQuestionSetPoolConditionGUI
protected function deleteUnusedMobs($model) protected function deleteUnusedMobs($model)
{ {
foreach($this->feedback_types as $type) foreach ($this->feedback_types as $type) {
{
// remove usage of deleted media objects
include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
$oldMediaObjects = ilObjMediaObject::_getMobsOfObject('x_' . $type['obj_type'] . ':html', $model->getId()); $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('x_' . $type['obj_type'] . ':html', $model->getId());
$curMediaObjects = ilRTE::_getMediaObjects($this->form->getInput($type['post_var']), 0); $curMediaObjects = ilRTE::_getMediaObjects($this->form->getInput($type['post_var']), 0);
foreach($oldMediaObjects as $oldMob) foreach ($oldMediaObjects as $oldMob) {
{
$found = false; $found = false;
foreach($curMediaObjects as $curMob) foreach ($curMediaObjects as $curMob) {
{ if ($oldMob == $curMob) {
if($oldMob == $curMob)
{
$found = true; $found = true;
break; break;
} }
} }
if(!$found) if (!$found) {
{ if (ilObjMediaObject::_exists($oldMob)) {
if(ilObjMediaObject::_exists($oldMob))
{
ilObjMediaObject::_removeUsage($oldMob, 'x_' . $type['obj_type'] . ':html', $model->getId()); ilObjMediaObject::_removeUsage($oldMob, 'x_' . $type['obj_type'] . ':html', $model->getId());
$mob_obj = new ilObjMediaObject($oldMob); $mob_obj = new ilObjMediaObject($oldMob);
$mob_obj->delete(); $mob_obj->delete();
......
...@@ -27,9 +27,7 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -27,9 +27,7 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
public function edit() public function edit()
{ {
include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
iljQueryUtil::initjQuery(); iljQueryUtil::initjQuery();
include_once 'Services/YUI/classes/class.ilYuiUtil.php';
ilYuiUtil::initPanel(); ilYuiUtil::initPanel();
ilYuiUtil::initOverlay(); ilYuiUtil::initOverlay();
$this->tpl->addJavascript('./Services/UIComponent/Overlay/js/ilOverlay.js'); $this->tpl->addJavascript('./Services/UIComponent/Overlay/js/ilOverlay.js');
...@@ -48,7 +46,6 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -48,7 +46,6 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
$template->setVariable("FORM", $this->form->getHTML()); $template->setVariable("FORM", $this->form->getHTML());
$template->setVariable("INFO", ilQuestionSetPoolInfoBox::render($this->plugin)); $template->setVariable("INFO", ilQuestionSetPoolInfoBox::render($this->plugin));
require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
$button = ilLinkButton::getInstance(); $button = ilLinkButton::getInstance();
$button->addCSSClass('toggle_feedback'); $button->addCSSClass('toggle_feedback');
$button->setCaption($this->plugin->txt('hide_feedback_form_parts'), false); $button->setCaption($this->plugin->txt('hide_feedback_form_parts'), false);
...@@ -61,12 +58,10 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -61,12 +58,10 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
public function update() public function update()
{ {
include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
$this->model = $this->loadModel(); $this->model = $this->loadModel();
$this->initForm($this->model); $this->initForm($this->model);
if($this->form->checkInput()) if ($this->form->checkInput()) {
{
$this->model->bindForm($this->form); $this->model->bindForm($this->form);
$isValid = ilQuestionSetPoolConditionValidator::isValid( $isValid = ilQuestionSetPoolConditionValidator::isValid(
...@@ -75,8 +70,7 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -75,8 +70,7 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
$this->model->getNode()->getPath()->getNodes()->getData(), $this->model->getNode()->getPath()->getNodes()->getData(),
$this->plugin $this->plugin
); );
if($isValid) if ($isValid) {
{
$this->model->update(); $this->model->update();
$this->copyTemporaryMobs(); $this->copyTemporaryMobs();
...@@ -106,10 +100,8 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -106,10 +100,8 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
{ {
$condition = $this->loadModel(); $condition = $this->loadModel();
$data = $condition->getNode()->getJumpConditionList()->getData(); $data = $condition->getNode()->getJumpConditionList()->getData();
foreach($data as $key => $element) foreach ($data as $key => $element) {
{ if ($element["id"] == $condition->getId()) {
if($element["id"] == $condition->getId())
{
$this->swap($condition, $data[$key - 1]["id"]); $this->swap($condition, $data[$key - 1]["id"]);
break; break;
} }
...@@ -125,10 +117,8 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -125,10 +117,8 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
{ {
$condition = $this->loadModel(); $condition = $this->loadModel();
$data = $condition->getNode()->getJumpConditionList()->getData(); $data = $condition->getNode()->getJumpConditionList()->getData();
foreach($data as $key => $element) foreach ($data as $key => $element) {
{ if ($element["id"] == $condition->getId()) {
if($element["id"] == $condition->getId())
{
$this->swap($condition, $data[$key + 1]["id"]); $this->swap($condition, $data[$key + 1]["id"]);
break; break;
} }
...@@ -193,12 +183,11 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -193,12 +183,11 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
global $DIC; global $DIC;
$ilUser = $DIC->user(); $ilUser = $DIC->user();
require_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
$this->form = new ilPropertyFormGUI(); $this->form = new ilPropertyFormGUI();
$this->form->setName('condition_form'); $this->form->setName('condition_form');
$this->form->setTableWidth("100%"); $this->form->setTableWidth("100%");
$this->form->setTitle(sprintf($this->plugin->txt("jump_condition_title"), $this->form->setTitle(sprintf(
$this->plugin->txt("jump_condition_title"),
$model->getNode()->getPath()->getSet()->getTitle(), $model->getNode()->getPath()->getSet()->getTitle(),
$model->getNode()->getPath()->getTitle(), $model->getNode()->getPath()->getTitle(),
$model->getNode()->getIndex() $model->getNode()->getIndex()
...@@ -227,45 +216,36 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -227,45 +216,36 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
$this->form->addItem($repititions); $this->form->addItem($repititions);
$true_feedback = new ilTextAreaInputGUI($this->plugin->txt('true_feedback'), 'true_feedback'); $true_feedback = new ilTextAreaInputGUI($this->plugin->txt('true_feedback'), 'true_feedback');
$true_feedback->setUseRte(TRUE); $true_feedback->setUseRte(true);
$true_feedback->addPlugin("latex"); $true_feedback->addPlugin("latex");
$true_feedback->addButton("latex"); $true_feedback->addButton("latex");
if($_GET["condition_id"]) if ($_GET["condition_id"]) {
{
$true_feedback->setRTESupport($_GET["condition_id"], 'x_tf', 'assessment'); $true_feedback->setRTESupport($_GET["condition_id"], 'x_tf', 'assessment');
} } else {
else
{
$true_feedback->setRTESupport($ilUser->getId(), 'x_tf~', 'assessment'); $true_feedback->setRTESupport($ilUser->getId(), 'x_tf~', 'assessment');
} }
$true_feedback->setRteTagSet('full'); $true_feedback->setRteTagSet('full');
$this->form->addItem($true_feedback); $this->form->addItem($true_feedback);
$true_jump_feedback = new ilTextAreaInputGUI($this->plugin->txt('true_jump_feedback'), 'true_jump_feedback'); $true_jump_feedback = new ilTextAreaInputGUI($this->plugin->txt('true_jump_feedback'), 'true_jump_feedback');
$true_jump_feedback->setUseRte(TRUE); $true_jump_feedback->setUseRte(true);
$true_jump_feedback->addPlugin("latex"); $true_jump_feedback->addPlugin("latex");
$true_jump_feedback->addButton("latex"); $true_jump_feedback->addButton("latex");
if($_GET["condition_id"]) if ($_GET["condition_id"]) {
{
$true_jump_feedback->setRTESupport($_GET["condition_id"], 'x_tjf', 'assessment'); $true_jump_feedback->setRTESupport($_GET["condition_id"], 'x_tjf', 'assessment');
} } else {
else
{
$true_jump_feedback->setRTESupport($ilUser->getId(), 'x_tjf~:html', 'assessment'); $true_jump_feedback->setRTESupport($ilUser->getId(), 'x_tjf~:html', 'assessment');
} }
$true_jump_feedback->setRteTagSet('full'); $true_jump_feedback->setRteTagSet('full');
$this->form->addItem($true_jump_feedback); $this->form->addItem($true_jump_feedback);
$false_feedback = new ilTextAreaInputGUI($this->plugin->txt('false_feedback'), 'false_feedback'); $false_feedback = new ilTextAreaInputGUI($this->plugin->txt('false_feedback'), 'false_feedback');
$false_feedback->setUseRte(TRUE); $false_feedback->setUseRte(true);
$false_feedback->addPlugin("latex"); $false_feedback->addPlugin("latex");
$false_feedback->addButton("latex"); $false_feedback->addButton("latex");
if($_GET["condition_id"]) if ($_GET["condition_id"]) {
{
$false_feedback->setRTESupport($_GET["condition_id"], 'x_ff:html', 'assessment'); $false_feedback->setRTESupport($_GET["condition_id"], 'x_ff:html', 'assessment');
} } else {
else
{
$false_feedback->setRTESupport($ilUser->getId(), 'x_ff~:html', 'assessment'); $false_feedback->setRTESupport($ilUser->getId(), 'x_ff~:html', 'assessment');
} }
$false_feedback->setRteTagSet('full'); $false_feedback->setRteTagSet('full');
...@@ -280,7 +260,6 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -280,7 +260,6 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
$this->ctrl->setParameter($this->controller, "condition_id", ""); $this->ctrl->setParameter($this->controller, "condition_id", "");
$this->form->addCommandButton("ilQuestionSetPoolJumpConditionGUI.update", $this->plugin->txt("save")); $this->form->addCommandButton("ilQuestionSetPoolJumpConditionGUI.update", $this->plugin->txt("save"));
$this->form->addCommandButton("ilQuestionSetPoolNodesGUI.listNodes", $this->plugin->txt("cancel")); $this->form->addCommandButton("ilQuestionSetPoolNodesGUI.listNodes", $this->plugin->txt("cancel"));
} }
protected function bindModelToForm(ilPluginModelInterface $model) protected function bindModelToForm(ilPluginModelInterface $model)
...@@ -290,8 +269,7 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -290,8 +269,7 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
$item->setValue($model->getNode()->getId()); $item->setValue($model->getNode()->getId());
$question_id = "-"; $question_id = "-";
if($model->getQuestion() != null) if ($model->getQuestion() != null) {
{
$question_id = $model->getQuestion()->getId(); $question_id = $model->getQuestion()->getId();
} }
$item = $this->form->getItemByPostVar("question"); $item = $this->form->getItemByPostVar("question");
...@@ -319,8 +297,7 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -319,8 +297,7 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
array($this->model->getNode()->getPath()->getId(), $this->model->getNode()->getIndex()) array($this->model->getNode()->getPath()->getId(), $this->model->getNode()->getIndex())
); );
while(($row = $ilDB->fetchAssoc($result)) != null) while (($row = $ilDB->fetchAssoc($result)) != null) {
{
$questions[$row["question_id"]] = "Q" . $row['question_index'] . " - " . $row["title"]; $questions[$row["question_id"]] = "Q" . $row['question_index'] . " - " . $row["title"];
} }
...@@ -382,16 +359,12 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -382,16 +359,12 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
global $DIC; global $DIC;
$ilUser = $DIC->user(); $ilUser = $DIC->user();
foreach($this->feedback_types as $type) foreach ($this->feedback_types as $type) {
{
$mediaObjects = ilRTE::_getMediaObjects($this->form->getInput($type['post_var']), 0); $mediaObjects = ilRTE::_getMediaObjects($this->form->getInput($type['post_var']), 0);
$myMediaObjects = ilObjMediaObject::_getMobsOfObject('x_' . $type['obj_type'] . '~:html', $ilUser->getId()); $myMediaObjects = ilObjMediaObject::_getMobsOfObject('x_' . $type['obj_type'] . '~:html', $ilUser->getId());
foreach($mediaObjects as $mob) foreach ($mediaObjects as $mob) {
{ foreach ($myMediaObjects as $myMob) {
foreach($myMediaObjects as $myMob) if ($mob == $myMob) {
{
if($mob == $myMob)
{
// change usage // change usage
ilObjMediaObject::_removeUsage($mob, 'x_' . $type['obj_type'] . '~:html', $ilUser->getId()); ilObjMediaObject::_removeUsage($mob, 'x_' . $type['obj_type'] . '~:html', $ilUser->getId());
break; break;
...@@ -407,27 +380,19 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -407,27 +380,19 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
*/ */
protected function deleteUnusedMobs() protected function deleteUnusedMobs()
{ {
foreach($this->feedback_types as $type) foreach ($this->feedback_types as $type) {
{
// remove usage of deleted media objects
include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
$oldMediaObjects = ilObjMediaObject::_getMobsOfObject('x_' . $type['obj_type'] . ':html', $this->model->getId()); $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('x_' . $type['obj_type'] . ':html', $this->model->getId());
$curMediaObjects = ilRTE::_getMediaObjects($this->form->getInput($type['post_var']), 0); $curMediaObjects = ilRTE::_getMediaObjects($this->form->getInput($type['post_var']), 0);
foreach($oldMediaObjects as $oldMob) foreach ($oldMediaObjects as $oldMob) {
{
$found = false; $found = false;
foreach($curMediaObjects as $curMob) foreach ($curMediaObjects as $curMob) {
{ if ($oldMob == $curMob) {
if($oldMob == $curMob)
{
$found = true; $found = true;
break; break;
} }
} }
if(!$found) if (!$found) {
{ if (ilObjMediaObject::_exists($oldMob)) {
if(ilObjMediaObject::_exists($oldMob))
{
ilObjMediaObject::_removeUsage($oldMob, 'x_' . $type['obj_type'] . ':html', $this->model->getId()); ilObjMediaObject::_removeUsage($oldMob, 'x_' . $type['obj_type'] . ':html', $this->model->getId());
$mob_obj = new ilObjMediaObject($oldMob); $mob_obj = new ilObjMediaObject($oldMob);
$mob_obj->delete(); $mob_obj->delete();
...@@ -445,26 +410,18 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI ...@@ -445,26 +410,18 @@ class ilQuestionSetPoolJumpConditionGUI extends ilQuestionSetPoolConditionGUI
global $DIC; global $DIC;
$ilUser = $DIC->user(); $ilUser = $DIC->user();
try try {
{ foreach ($this->feedback_types as $type) {
include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
foreach($this->feedback_types as $type)
{
$mobs = ilObjMediaObject::_getMobsOfObject('x_' . $type['obj_type'] . '~:html', $ilUser->getId()); $mobs = ilObjMediaObject::_getMobsOfObject('x_' . $type['obj_type'] . '~:html', $ilUser->getId());
foreach($mobs as $mob) foreach ($mobs as $mob) {
{ if (ilObjMediaObject::_exists($mob)) {
if(ilObjMediaObject::_exists($mob))
{
ilObjMediaObject::_removeUsage($mob, 'x_' . $type['obj_type'] . '~:html', $ilUser->getId()); ilObjMediaObject::_removeUsage($mob, 'x_' . $type['obj_type'] . '~:html', $ilUser->getId());
$mob_obj = new ilObjMediaObject($mob); $mob_obj = new ilObjMediaObject($mob);
$mob_obj->delete(); $mob_obj->delete();
} }
} }
} }
} } catch (Exception $e) {
catch(Exception $e)
{
} }
} }
} }
...@@ -11,7 +11,6 @@ require_once "abstract.ilPluginControllerFormGUI.php"; ...@@ -11,7 +11,6 @@ require_once "abstract.ilPluginControllerFormGUI.php";
*/ */
class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI
{ {
protected $redirectCmd = "ilQuestionSetPoolNodesGUI.listNodes"; protected $redirectCmd = "ilQuestionSetPoolNodesGUI.listNodes";
public function edit() public function edit()
...@@ -32,19 +31,16 @@ class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI ...@@ -32,19 +31,16 @@ class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI
public function removeConfirmation() public function removeConfirmation()
{ {
require_once "./Services/Utilities/classes/class.ilConfirmationGUI.php";
$model = $this->loadModel(); $model = $this->loadModel();
$model->read(); $model->read();
if(!$model->getId() || $model->getPath()->getSet()->getContainerObjId() != $this->controller->object->getId()) if (!$model->getId() || $model->getPath()->getSet()->getContainerObjId() != $this->controller->object->getId()) {
{ if ($model->getId()) {
if($model->getId())
{
ilUtil::sendFailure(sprintf($this->plugin->txt('nodes_del_perm_err_s'), implode(', ', array($model->getIndex()))), true); ilUtil::sendFailure(sprintf($this->plugin->txt('nodes_del_perm_err_s'), implode(', ', array($model->getIndex()))), true);
} }
$this->controller->ctrl->setParameter($this->controller, 'set_id', (int)$_GET['set_id']); $this->ctrl->setParameter($this->controller, 'set_id', (int) $_GET['set_id']);
$this->controller->ctrl->setParameter($this->controller, 'path_id', (int)$_GET['path_id']); $this->ctrl->setParameter($this->controller, 'path_id', (int) $_GET['path_id']);
$this->controller->ctrl->redirect($this->controller, 'ilQuestionSetPoolNodesGUI.listNodes'); $this->ctrl->redirect($this->controller, 'ilQuestionSetPoolNodesGUI.listNodes');
return; return;
} }
...@@ -69,29 +65,24 @@ class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI ...@@ -69,29 +65,24 @@ class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI
$model = $this->loadModel(); $model = $this->loadModel();
$model->read(); $model->read();
if(!$model->getId() || $model->getPath()->getSet()->getContainerObjId() != $this->controller->object->getId()) if (!$model->getId() || $model->getPath()->getSet()->getContainerObjId() != $this->controller->object->getId()) {
{ if ($model->getId()) {
if($model->getId())
{
ilUtil::sendFailure(sprintf($this->plugin->txt('nodes_del_perm_err_s'), implode(', ', array($model->getIndex()))), true); ilUtil::sendFailure(sprintf($this->plugin->txt('nodes_del_perm_err_s'), implode(', ', array($model->getIndex()))), true);
} }
$this->controller->ctrl->setParameter($this->controller, 'set_id', (int)$_GET['set_id']); $this->ctrl->setParameter($this->controller, 'set_id', (int) $_GET['set_id']);
$this->controller->ctrl->setParameter($this->controller, 'path_id', (int)$_GET['path_id']); $this->ctrl->setParameter($this->controller, 'path_id', (int) $_GET['path_id']);
$this->controller->ctrl->redirect($this->controller, 'ilQuestionSetPoolNodesGUI.listNodes'); $this->ctrl->redirect($this->controller, 'ilQuestionSetPoolNodesGUI.listNodes');
return; return;
} }
$data = $model->getPath()->getNodes()->getData(); $data = $model->getPath()->getNodes()->getData();
foreach($data as $key => $element) foreach ($data as $key => $element) {
{ if ($element["id"] == $model->getId()) {
if($element["id"] == $model->getId())
{
unset($data[$key]); unset($data[$key]);
} }
} }
if($model->getIndex() == 1) if ($model->getIndex() == 1) {
{
ilUtil::sendFailure($this->plugin->txt("cant_delete_first_node"), true); ilUtil::sendFailure($this->plugin->txt("cant_delete_first_node"), true);
$this->redirect( $this->redirect(
...@@ -101,38 +92,32 @@ class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI ...@@ -101,38 +92,32 @@ class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI
} }
$canBeDeleted = true; $canBeDeleted = true;
foreach($data as $node) foreach ($data as $node) {
{
$node = new ilQuestionSetPoolNode($node["id"]); $node = new ilQuestionSetPoolNode($node["id"]);
$node->read(); $node->read();
if(!ilQuestionSetPoolConditionValidator::isValid($node->getInitialCondition(),$node,$data,$this->plugin)) if (!ilQuestionSetPoolConditionValidator::isValid($node->getInitialCondition(), $node, $data, $this->plugin)) {
{
$canBeDeleted = false; $canBeDeleted = false;
ilUtil::sendFailure($this->plugin->txt("node_used_in_initial_condition"), true); ilUtil::sendFailure($this->plugin->txt("node_used_in_initial_condition"), true);
} }
$conditions = $node->getJumpConditionList()->getData(); $conditions = $node->getJumpConditionList()->getData();
foreach($conditions as $condition) foreach ($conditions as $condition) {
{ if (!ilQuestionSetPoolConditionValidator::isValid($condition["jump_condition"], $node, $data, $this->plugin)) {
if(!ilQuestionSetPoolConditionValidator::isValid($condition["jump_condition"],$node,$data,$this->plugin))
{
$canBeDeleted = false; $canBeDeleted = false;
ilUtil::sendFailure($this->plugin->txt("node_used_in_jump_condition"), true); ilUtil::sendFailure($this->plugin->txt("node_used_in_jump_condition"), true);
} }
if ($condition["question_fi"] == $model->getQuestion()->getId() && if ($condition["question_fi"] == $model->getQuestion()->getId() &&
$condition["node_fi"] != $model->getId() $condition["node_fi"] != $model->getId()
) ) {
{
$canBeDeleted = false; $canBeDeleted = false;
ilUtil::sendFailure($this->plugin->txt("node_is_used_as_target"), true); ilUtil::sendFailure($this->plugin->txt("node_is_used_as_target"), true);
} }
} }
} }
if($canBeDeleted) if ($canBeDeleted) {
{
$model->remove(); $model->remove();
ilUtil::sendSuccess($this->plugin->txt("node_deleted"), true); ilUtil::sendSuccess($this->plugin->txt("node_deleted"), true);
} }
...@@ -163,10 +148,9 @@ class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI ...@@ -163,10 +148,9 @@ class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI
*/ */
protected function initForm($model) protected function initForm($model)
{ {
require_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
$this->form = new ilPropertyFormGUI(); $this->form = new ilPropertyFormGUI();
$this->form->setTitle(sprintf($this->plugin->txt("set_node_title"), $this->form->setTitle(sprintf(
$this->plugin->txt("set_node_title"),
$model->getPath()->getSet()->getTitle(), $model->getPath()->getSet()->getTitle(),
$model->getPath()->getTitle() $model->getPath()->getTitle()
)); ));
...@@ -244,13 +228,11 @@ class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI ...@@ -244,13 +228,11 @@ class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI
$questions = $model->getPath()->getSet()->getQuestionList()->getData(); $questions = $model->getPath()->getSet()->getQuestionList()->getData();
$options = array(); $options = array();
foreach ($questions as $question) foreach ($questions as $question) {
{
$options[$question['question_id']] = $question['title']; $options[$question['question_id']] = $question['title'];
} }
foreach($nodes as $node) foreach ($nodes as $node) {
{
if (array_key_exists($node["question_fi"], $options)) { if (array_key_exists($node["question_fi"], $options)) {
unset($options[$node["question_fi"]]); unset($options[$node["question_fi"]]);
} }
...@@ -264,11 +246,11 @@ class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI ...@@ -264,11 +246,11 @@ class ilQuestionSetPoolNodeGUI extends ilPluginControllerFormGUI
*/ */
protected function redirectIfUnableToAddNewNode($model) protected function redirectIfUnableToAddNewNode($model)
{ {
if (is_array($this->getQuestionOptions($model)) && count($this->getQuestionOptions($model)) == 0) if (is_array($this->getQuestionOptions($model)) && count($this->getQuestionOptions($model)) == 0) {
{
ilUtil::sendFailure($this->plugin->txt("unable_to_add_new_node"), true); ilUtil::sendFailure($this->plugin->txt("unable_to_add_new_node"), true);
$this->redirect( $this->redirect(
"ilQuestionSetPoolNodesGUI.listNodes", array( "ilQuestionSetPoolNodesGUI.listNodes",
array(
"path_id" => (int) $_GET["path_id"], "path_id" => (int) $_GET["path_id"],
"set_id" => (int) $_GET["set_id"] "set_id" => (int) $_GET["set_id"]
) )
......
...@@ -11,7 +11,6 @@ require_once "abstract.ilPluginControllerTableGUI.php"; ...@@ -11,7 +11,6 @@ require_once "abstract.ilPluginControllerTableGUI.php";
*/ */
class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI
{ {
public function __construct(ilObjQuestionSetPoolGUI $controller) public function __construct(ilObjQuestionSetPoolGUI $controller)
{ {
parent::__construct($controller); parent::__construct($controller);
...@@ -25,8 +24,7 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI ...@@ -25,8 +24,7 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI
{ {
$this->controller->ensurePermission('write'); $this->controller->ensurePermission('write');
if(!isset($_GET['q_id']) || !(int)$_GET['q_id']) if (!isset($_GET['q_id']) || !(int) $_GET['q_id']) {
{
$this->listNodes(); $this->listNodes();
return; return;
} }
...@@ -60,7 +58,8 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI ...@@ -60,7 +58,8 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI
$table->setTitle( $table->setTitle(
$model->getSet()->getTitle() . " - " . $model->getSet()->getTitle() . " - " .
$model->getTitle() . " - " . $model->getTitle() . " - " .
$this->plugin->txt('nodes')); $this->plugin->txt('nodes')
);
$table->addCommandButton("ilQuestionSetPoolNodesGUI.saveSorting", $this->plugin->txt("save_sorting")); $table->addCommandButton("ilQuestionSetPoolNodesGUI.saveSorting", $this->plugin->txt("save_sorting"));
$table->addCommandButton("ilQuestionSetPoolNodesGUI.saveDominantScoring", $this->plugin->txt("save_dominant_scoring")); $table->addCommandButton("ilQuestionSetPoolNodesGUI.saveDominantScoring", $this->plugin->txt("save_dominant_scoring"));
...@@ -86,16 +85,12 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI ...@@ -86,16 +85,12 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI
$model->read(); $model->read();
$data = $model->getNodes()->getData(); $data = $model->getNodes()->getData();
foreach($data as $element) foreach ($data as $element) {
{
$node = new ilQuestionSetPoolNode($element["id"]); $node = new ilQuestionSetPoolNode($element["id"]);
$node->read(); $node->read();
if($_POST["dominant_scoring"][$node->getId()] === "") if ($_POST["dominant_scoring"][$node->getId()] === "") {
{
$node->setDominantScoring(null); $node->setDominantScoring(null);
} } else {
else
{
$node->setDominantScoring((int) $_POST["dominant_scoring"][$node->getId()]); $node->setDominantScoring((int) $_POST["dominant_scoring"][$node->getId()]);
} }
$node->update(); $node->update();
...@@ -114,10 +109,8 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI ...@@ -114,10 +109,8 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI
$model->read(); $model->read();
$data = $model->getNodes()->getData(); $data = $model->getNodes()->getData();
foreach($data as $key => $element) foreach ($data as $key => $element) {
{ if ($element["node_index"] != 1) {
if($element["node_index"] != 1)
{
$minimumTwo = (int) $_POST["sorting"][$element["id"]]; $minimumTwo = (int) $_POST["sorting"][$element["id"]];
$data[$key]["node_index"] = $minimumTwo > 1 ? $minimumTwo : 2; $data[$key]["node_index"] = $minimumTwo > 1 ? $minimumTwo : 2;
} }
...@@ -127,8 +120,7 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI ...@@ -127,8 +120,7 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI
return $a["node_index"] - $b["node_index"]; return $a["node_index"] - $b["node_index"];
}); });
if(!$this->conditionsAreValid($data)) if (!$this->conditionsAreValid($data)) {
{
ilUtil::sendFailure($this->plugin->txt("sorting_error_jmp_conditions"), true); ilUtil::sendFailure($this->plugin->txt("sorting_error_jmp_conditions"), true);
$this->redirect("ilQuestionSetPoolNodesGUI.listNodes", array( $this->redirect("ilQuestionSetPoolNodesGUI.listNodes", array(
"set_id" => (int) $_GET["set_id"], "set_id" => (int) $_GET["set_id"],
...@@ -136,10 +128,8 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI ...@@ -136,10 +128,8 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI
)); ));
} }
if(is_array($data)) if (is_array($data)) {
{ for ($i = 0; $i < count($data); $i++) {
for($i = 0; $i < count($data); $i++)
{
$data[$i]["node_index"] = ($i + 1); $data[$i]["node_index"] = ($i + 1);
$model->getNodes()->update($data[$i]); $model->getNodes()->update($data[$i]);
} }
...@@ -175,14 +165,23 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI ...@@ -175,14 +165,23 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI
$this->ctrl->setParameter($this->controller, "set_id", (int) $_GET['set_id']); $this->ctrl->setParameter($this->controller, "set_id", (int) $_GET['set_id']);
$ilTabs->addSubTab("set_questions", $this->plugin->txt("questions"), $ilTabs->addSubTab(
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolSetQuestionsGUI.listQuestions")); "set_questions",
$this->plugin->txt("questions"),
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolSetQuestionsGUI.listQuestions")
);
$ilTabs->addSubTab("paths", $this->plugin->txt("paths"), $ilTabs->addSubTab(
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathsGUI.listPaths")); "paths",
$this->plugin->txt("paths"),
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathsGUI.listPaths")
);
$ilTabs->addSubTab("path_overview", $this->plugin->txt("path_overview"), $ilTabs->addSubTab(
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathGraphGUI.showPathOverview")); "path_overview",
$this->plugin->txt("path_overview"),
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathGraphGUI.showPathOverview")
);
$ilTabs->activateSubTab("paths"); $ilTabs->activateSubTab("paths");
...@@ -196,41 +195,31 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI ...@@ -196,41 +195,31 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI
*/ */
protected function conditionsAreValid($data) protected function conditionsAreValid($data)
{ {
if(is_array($data)) if (is_array($data)) {
{ for ($index = 1; $index < count($data); $index++) {
for($index = 1; $index < count($data); $index++)
{
$node = new ilQuestionSetPoolNode($data[$index]["id"]); $node = new ilQuestionSetPoolNode($data[$index]["id"]);
$node->read(); $node->read();
$node->setIndex($data[$index]["node_index"]); $node->setIndex($data[$index]["node_index"]);
if(!ilQuestionSetPoolConditionValidator::isValid($node->getInitialCondition(), $node, $data, $this->plugin)) if (!ilQuestionSetPoolConditionValidator::isValid($node->getInitialCondition(), $node, $data, $this->plugin)) {
{
return false; return false;
} }
foreach($data[$index]["jump_conditions"] as $jump_condition) foreach ($data[$index]["jump_conditions"] as $jump_condition) {
{ if (!ilQuestionSetPoolConditionValidator::isValid($jump_condition["jump_condition"], $node, $data, $this->plugin)) {
if(!ilQuestionSetPoolConditionValidator::isValid($jump_condition["jump_condition"], $node, $data, $this->plugin))
{
return false; return false;
} }
$error = false; $error = false;
for($inner_index = 0; $inner_index <= $index; $inner_index++) for ($inner_index = 0; $inner_index <= $index; $inner_index++) {
{ if ($data[$inner_index]["question_fi"] == $jump_condition["question_fi"] || $jump_condition["question_fi"] == null) {
if($data[$inner_index]["question_fi"] == $jump_condition["question_fi"] || $jump_condition["question_fi"] == null)
{
$error = false; $error = false;
break; break;
} } else {
else
{
$error = true; $error = true;
} }
} }
if($error) if ($error) {
{
return false; return false;
} }
} }
...@@ -239,4 +228,3 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI ...@@ -239,4 +228,3 @@ class ilQuestionSetPoolNodesGUI extends ilPluginControllerTableGUI
return true; return true;
} }
} }
\ No newline at end of file
...@@ -11,7 +11,6 @@ require_once "abstract.ilPluginControllerFormGUI.php"; ...@@ -11,7 +11,6 @@ require_once "abstract.ilPluginControllerFormGUI.php";
*/ */
class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI
{ {
protected $redirectCmd = "ilQuestionSetPoolNodesGUI.listNodes"; protected $redirectCmd = "ilQuestionSetPoolNodesGUI.listNodes";
public function edit() public function edit()
...@@ -30,8 +29,7 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI ...@@ -30,8 +29,7 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI
$model = $this->loadModel(); $model = $this->loadModel();
$this->initForm($model); $this->initForm($model);
if($this->form->checkInput()) if ($this->form->checkInput()) {
{
$model->bindForm($this->form); $model->bindForm($this->form);
$model->update(); $model->update();
ilUtil::sendSuccess($this->plugin->txt("msg_path_modified"), true); ilUtil::sendSuccess($this->plugin->txt("msg_path_modified"), true);
...@@ -72,7 +70,6 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI ...@@ -72,7 +70,6 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI
*/ */
protected function initForm($model) protected function initForm($model)
{ {
require_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
$this->form = new ilPropertyFormGUI(); $this->form = new ilPropertyFormGUI();
$this->form->setTitle( $this->form->setTitle(
sprintf( sprintf(
...@@ -85,8 +82,7 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI ...@@ -85,8 +82,7 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI
$title->setRequired(true); $title->setRequired(true);
$this->form->addItem($title); $this->form->addItem($title);
if($model->getId() <= 0) if ($model->getId() <= 0) {
{
$start_question = new ilSelectInputGUI($this->plugin->txt('start_question'), "start_question"); $start_question = new ilSelectInputGUI($this->plugin->txt('start_question'), "start_question");
$start_question->setRequired(true); $start_question->setRequired(true);
$start_question->setOptions($this->getStartQuestionOptions($model)); $start_question->setOptions($this->getStartQuestionOptions($model));
...@@ -113,8 +109,7 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI ...@@ -113,8 +109,7 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI
$options = array(); $options = array();
$questions = $this->getExistingStartQuestion($model); $questions = $this->getExistingStartQuestion($model);
if($questions == null) if ($questions == null) {
{
$set = new ilQuestionSetPoolSet((int) $_GET["set_id"]); $set = new ilQuestionSetPoolSet((int) $_GET["set_id"]);
$set->read(); $set->read();
$questions = $set->getQuestionList()->getData(); $questions = $set->getQuestionList()->getData();
...@@ -122,8 +117,7 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI ...@@ -122,8 +117,7 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI
ilUtil::sendInfo($this->plugin->txt("start_question_defined"), false); ilUtil::sendInfo($this->plugin->txt("start_question_defined"), false);
} }
foreach ($questions as $question) foreach ($questions as $question) {
{
$options[$question['question_id']] = $question['title']; $options[$question['question_id']] = $question['title'];
} }
...@@ -153,8 +147,7 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI ...@@ -153,8 +147,7 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI
$data = $ilDB->fetchAssoc($result); $data = $ilDB->fetchAssoc($result);
if($data != null) if ($data != null) {
{
$data = array($data); $data = array($data);
} }
...@@ -204,11 +197,11 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI ...@@ -204,11 +197,11 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI
* *
* @return array * @return array
*/ */
protected function getAfterUpdateRedirectParams($model = NULL) protected function getAfterUpdateRedirectParams($model = null)
{ {
return array( return array(
"set_id" => (int) $_GET['set_id'], "set_id" => (int) $_GET['set_id'],
"path_id" => ($model == NULL ? NULL : (int)$model->getId()) "path_id" => ($model == null ? null : (int) $model->getId())
); );
} }
...@@ -217,8 +210,7 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI ...@@ -217,8 +210,7 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI
$set = new ilQuestionSetPoolSet((int) $_GET["set_id"]); $set = new ilQuestionSetPoolSet((int) $_GET["set_id"]);
$set->read(); $set->read();
if (!$this->doesSetHaveQuestions($set)) if (!$this->doesSetHaveQuestions($set)) {
{
ilUtil::sendFailure($this->plugin->txt("no_questions_in_set"), true); ilUtil::sendFailure($this->plugin->txt("no_questions_in_set"), true);
$this->redirect( $this->redirect(
$this->getAfterUpdateRedirectCmd(), $this->getAfterUpdateRedirectCmd(),
...@@ -227,4 +219,3 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI ...@@ -227,4 +219,3 @@ class ilQuestionSetPoolPathGUI extends ilPluginControllerFormGUI
} }
} }
} }
\ No newline at end of file
...@@ -30,9 +30,17 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI ...@@ -30,9 +30,17 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI
$template->setVariable('SET_TITLE', $set->getTitle()); $template->setVariable('SET_TITLE', $set->getTitle());
$template->setVariable('GRAPH_TITLE', $this->plugin->txt("graph_viz_title")); $template->setVariable('GRAPH_TITLE', $this->plugin->txt("graph_viz_title"));
$components = [];
try {
$template->setVariable('PATH_GRAPH_SRC', $this->renderPathGraph()); $template->setVariable('PATH_GRAPH_SRC', $this->renderPathGraph());
$components[] = $this->uiFactory->legacy($template->get());
} catch (Exception $e) {
$components[] = $this->uiFactory->legacy($template->get());
$components[] = $this->uiFactory->messageBox()->failure('Could not display graph: ' . $e->getMessage());
}
$this->tpl->setContent($template->get()); $this->tpl->setContent($this->uiRenderer->render($components));
} }
/** /**
...@@ -46,15 +54,13 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI ...@@ -46,15 +54,13 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI
$graph = new Fhaculty\Graph\Graph(); $graph = new Fhaculty\Graph\Graph();
$pathes = $set->getPathList()->getData(); $pathes = $set->getPathList()->getData();
foreach($pathes as $path) foreach ($pathes as $path) {
{
$model = new ilQuestionSetPoolPath($path['id']); $model = new ilQuestionSetPoolPath($path['id']);
$model->read(); $model->read();
$nodes = $model->getNodes()->getData(); $nodes = $model->getNodes()->getData();
$num_nodes = is_array($nodes) ? count($nodes): 0; $num_nodes = is_array($nodes) ? count($nodes): 0;
for($i = 0; $i < $num_nodes; $i++) for ($i = 0; $i < $num_nodes; $i++) {
{
$nodeId = 'Q' . $nodes[$i]['question_index']; $nodeId = 'Q' . $nodes[$i]['question_index'];
try { try {
$graph->getVertex($nodeId); $graph->getVertex($nodeId);
...@@ -69,57 +75,43 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI ...@@ -69,57 +75,43 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI
$edges = array(); $edges = array();
foreach($pathes as $path) foreach ($pathes as $path) {
{
$model = new ilQuestionSetPoolPath($path['id']); $model = new ilQuestionSetPoolPath($path['id']);
$model->read(); $model->read();
$nodes = $model->getNodes()->getData(); $nodes = $model->getNodes()->getData();
$num_nodes = is_array($nodes) ? count($nodes): 0; $num_nodes = is_array($nodes) ? count($nodes): 0;
for($i = 0; $i < $num_nodes; $i++) for ($i = 0; $i < $num_nodes; $i++) {
{ if (isset($nodes[$i + 1])) {
if(isset($nodes[$i + 1]))
{
$edges["Q" . $nodes[$i]['question_index']]["Q" . $nodes[$i + 1]['question_index']]['initial'][trim($nodes[$i]['initial_condition'])] = $nodes[$i]['initial_condition']; $edges["Q" . $nodes[$i]['question_index']]["Q" . $nodes[$i + 1]['question_index']]['initial'][trim($nodes[$i]['initial_condition'])] = $nodes[$i]['initial_condition'];
} } else {
else
{
$edges["Q" . $nodes[$i]['question_index']][$this->controller->plugin->txt('end_of_set')]['initial'][trim($nodes[$i]['initial_condition'])] = $nodes[$i]['initial_condition']; $edges["Q" . $nodes[$i]['question_index']][$this->controller->plugin->txt('end_of_set')]['initial'][trim($nodes[$i]['initial_condition'])] = $nodes[$i]['initial_condition'];
} }
foreach((array)$nodes[$i]['jump_conditions'] as $condition) foreach ((array) $nodes[$i]['jump_conditions'] as $condition) {
{ if ($condition['question_index']) {
if($condition['question_index'])
{
$edges["Q" . $nodes[$i]['question_index']]["Q" . $condition['question_index']]['jump'][trim($condition['jump_condition'])] = $condition['jump_condition']; $edges["Q" . $nodes[$i]['question_index']]["Q" . $condition['question_index']]['jump'][trim($condition['jump_condition'])] = $condition['jump_condition'];
} } else {
else
{
$edges["Q" . $nodes[$i]['question_index']][$this->controller->plugin->txt('end_of_set')]['end'][trim($condition['jump_condition'])] = $condition['jump_condition']; $edges["Q" . $nodes[$i]['question_index']][$this->controller->plugin->txt('end_of_set')]['end'][trim($condition['jump_condition'])] = $condition['jump_condition'];
} }
} }
} }
} }
foreach($edges as $node_source => $data_target) foreach ($edges as $node_source => $data_target) {
{ foreach ($data_target as $node_target => $data_conditions) {
foreach($data_target as $node_target => $data_conditions) if (is_array($data_conditions['initial']) && count($data_conditions['initial']) > 0) {
{
if(is_array($data_conditions['initial']) && count($data_conditions['initial']) > 0)
{
$initial = join("\n", array_filter($data_conditions['initial'])); $initial = join("\n", array_filter($data_conditions['initial']));
$edge = new Fhaculty\Graph\Edge\Directed($graph->getVertex($node_source), $graph->getVertex($node_target)); $edge = new Fhaculty\Graph\Edge\Directed($graph->getVertex($node_source), $graph->getVertex($node_target));
$edge->setAttribute('graphviz.color', 'darkgreen'); $edge->setAttribute('graphviz.color', 'darkgreen');
$edge->setAttribute('graphviz.label', $initial); $edge->setAttribute('graphviz.label', $initial);
} }
if(is_array($data_conditions['jump']) && count($data_conditions['jump']) > 0) if (is_array($data_conditions['jump']) && count($data_conditions['jump']) > 0) {
{
$jump = join("\n", array_filter($data_conditions['jump'])); $jump = join("\n", array_filter($data_conditions['jump']));
$edge = new Fhaculty\Graph\Edge\Directed($graph->getVertex($node_source), $graph->getVertex($node_target)); $edge = new Fhaculty\Graph\Edge\Directed($graph->getVertex($node_source), $graph->getVertex($node_target));
$edge->setAttribute('graphviz.color', 'blue'); $edge->setAttribute('graphviz.color', 'blue');
$edge->setAttribute('graphviz.label', $jump); $edge->setAttribute('graphviz.label', $jump);
} }
if(is_array($data_conditions['end']) && count($data_conditions['end']) > 0) if (is_array($data_conditions['end']) && count($data_conditions['end']) > 0) {
{
$end = join("\n", array_filter($data_conditions['end'])); $end = join("\n", array_filter($data_conditions['end']));
$edge = new Fhaculty\Graph\Edge\Directed($graph->getVertex($node_source), $graph->getVertex($node_target)); $edge = new Fhaculty\Graph\Edge\Directed($graph->getVertex($node_source), $graph->getVertex($node_target));
$edge->setAttribute('graphviz.color', 'red'); $edge->setAttribute('graphviz.color', 'red');
...@@ -160,14 +152,23 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI ...@@ -160,14 +152,23 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI
$this->ctrl->setParameter($this->controller, "set_id", (int) $_GET['set_id']); $this->ctrl->setParameter($this->controller, "set_id", (int) $_GET['set_id']);
$ilTabs->addSubTab("set_questions", $this->plugin->txt("questions"), $ilTabs->addSubTab(
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolSetQuestionsGUI.listQuestions")); "set_questions",
$this->plugin->txt("questions"),
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolSetQuestionsGUI.listQuestions")
);
$ilTabs->addSubTab("paths", $this->plugin->txt("paths"), $ilTabs->addSubTab(
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathsGUI.listPaths")); "paths",
$this->plugin->txt("paths"),
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathsGUI.listPaths")
);
$ilTabs->addSubTab("path_overview", $this->plugin->txt("path_overview"), $ilTabs->addSubTab(
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathGraphGUI.showPathOverview")); "path_overview",
$this->plugin->txt("path_overview"),
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathGraphGUI.showPathOverview")
);
$ilTabs->activateSubTab("path_overview"); $ilTabs->activateSubTab("path_overview");
...@@ -181,18 +182,15 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI ...@@ -181,18 +182,15 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI
protected function renderPathTable($set, $template) protected function renderPathTable($set, $template)
{ {
$pathes = $set->getPathList()->getData(); $pathes = $set->getPathList()->getData();
foreach ($pathes as $path_data) foreach ($pathes as $path_data) {
{
$path = new ilQuestionSetPoolPath($path_data['id']); $path = new ilQuestionSetPoolPath($path_data['id']);
$path->read(); $path->read();
$nodes = $path->getNodes()->getData(); $nodes = $path->getNodes()->getData();
foreach ($nodes as $node) foreach ($nodes as $node) {
{
$template->setCurrentBlock("initial_condition"); $template->setCurrentBlock("initial_condition");
$condition = $node["initial_condition"]; $condition = $node["initial_condition"];
if ($condition == "") if ($condition == "") {
{
$condition = $this->plugin->txt("empty_condition"); $condition = $this->plugin->txt("empty_condition");
} }
$template->setVariable("INITIAL_CONDITION", $condition); $template->setVariable("INITIAL_CONDITION", $condition);
...@@ -202,19 +200,14 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI ...@@ -202,19 +200,14 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI
$template->setVariable("QUESTION_INDEX", $node["question_index"]); $template->setVariable("QUESTION_INDEX", $node["question_index"]);
$template->parseCurrentBlock(); $template->parseCurrentBlock();
if (is_array($node["jump_conditions"]) && count($node["jump_conditions"]) > 0) if (is_array($node["jump_conditions"]) && count($node["jump_conditions"]) > 0) {
{ foreach ($node["jump_conditions"] as $jump_condition) {
foreach ($node["jump_conditions"] as $jump_condition)
{
$condition = ""; $condition = "";
if ($jump_condition["question_index"] != null) if ($jump_condition["question_index"] != null) {
{
$condition .= $this->plugin->txt("target_question") . ": "; $condition .= $this->plugin->txt("target_question") . ": ";
$condition .= "Q" . $jump_condition["question_index"]; $condition .= "Q" . $jump_condition["question_index"];
} } else {
else
{
$condition .= $this->plugin->txt("tst_termination"); $condition .= $this->plugin->txt("tst_termination");
} }
$template->setCurrentBlock("jump_condition"); $template->setCurrentBlock("jump_condition");
...@@ -222,9 +215,7 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI ...@@ -222,9 +215,7 @@ class ilQuestionSetPoolPathGraphGUI extends ilPluginControllerGUI
$template->setVariable("TARGET", $condition . "<br />" . $this->plugin->txt("repititions") . ": " . $jump_condition["repititions"]); $template->setVariable("TARGET", $condition . "<br />" . $this->plugin->txt("repititions") . ": " . $jump_condition["repititions"]);
$template->parseCurrentBlock(); $template->parseCurrentBlock();
} }
} } else {
else
{
$template->setCurrentBlock("jump_condition"); $template->setCurrentBlock("jump_condition");
$template->setVariable("JUMP_CONDITION", "&nbsp;"); $template->setVariable("JUMP_CONDITION", "&nbsp;");
$template->setVariable("TARGET", "&nbsp;"); $template->setVariable("TARGET", "&nbsp;");
......
...@@ -11,7 +11,6 @@ require_once "abstract.ilPluginControllerTableGUI.php"; ...@@ -11,7 +11,6 @@ require_once "abstract.ilPluginControllerTableGUI.php";
*/ */
class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI
{ {
public function __construct(ilObjQuestionSetPoolGUI $controller) public function __construct(ilObjQuestionSetPoolGUI $controller)
{ {
parent::__construct($controller); parent::__construct($controller);
...@@ -20,8 +19,7 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI ...@@ -20,8 +19,7 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI
public function listPaths() public function listPaths()
{ {
if($this->controller->object instanceof ilObjQuestionSetPool) if ($this->controller->object instanceof ilObjQuestionSetPool) {
{
$this->addToolbarButton("back_to_set_list", "ilQuestionSetPoolSetsGUI.show"); $this->addToolbarButton("back_to_set_list", "ilQuestionSetPoolSetsGUI.show");
} }
...@@ -55,27 +53,23 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI ...@@ -55,27 +53,23 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI
public function copy() public function copy()
{ {
if($this->dataSelected("path_id")) if ($this->dataSelected("path_id")) {
{
$set = new ilQuestionSetPoolSet((int) $_GET['set_id']); $set = new ilQuestionSetPoolSet((int) $_GET['set_id']);
$set->read(); $set->read();
$path_titles = $set->getPathTitles(); $path_titles = $set->getPathTitles();
foreach($_POST["path_id"] as $path_id) foreach ($_POST["path_id"] as $path_id) {
{
$path = new ilQuestionSetPoolPath($path_id); $path = new ilQuestionSetPoolPath($path_id);
$path->read(); $path->read();
$data = $path->getSet()->getQuestionList()->getData(); $data = $path->getSet()->getQuestionList()->getData();
$question_ids = array(); $question_ids = array();
foreach($data as $element) foreach ($data as $element) {
{
$question_ids[$element["question_id"]] = $element["question_id"]; $question_ids[$element["question_id"]] = $element["question_id"];
} }
$title = $path->getTitle(); $title = $path->getTitle();
$i = 2; $i = 2;
while(in_array($title . ' (' . $i . ')', $path_titles)) while (in_array($title . ' (' . $i . ')', $path_titles)) {
{
$i++; $i++;
} }
...@@ -92,9 +86,7 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI ...@@ -92,9 +86,7 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI
$this->redirect("ilQuestionSetPoolPathsGUI.listPaths", array( $this->redirect("ilQuestionSetPoolPathsGUI.listPaths", array(
"set_id" => $_GET["set_id"] "set_id" => $_GET["set_id"]
)); ));
} } else {
else
{
ilUtil::sendInfo($this->plugin->txt('no_path_selected')); ilUtil::sendInfo($this->plugin->txt('no_path_selected'));
$this->listPaths(); $this->listPaths();
return; return;
...@@ -106,8 +98,7 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI ...@@ -106,8 +98,7 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI
*/ */
public function removeConfirmation() public function removeConfirmation()
{ {
if(!isset($_GET['path_id'])) if (!isset($_GET['path_id'])) {
{
ilUtil::sendInfo($this->plugin->txt('no_path_selected')); ilUtil::sendInfo($this->plugin->txt('no_path_selected'));
$this->listPaths(); $this->listPaths();
return; return;
...@@ -122,8 +113,7 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI ...@@ -122,8 +113,7 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI
*/ */
public function removeMultipleConfirmation() public function removeMultipleConfirmation()
{ {
if(!isset($_POST['path_id']) || !is_array($_POST['path_id'])) if (!isset($_POST['path_id']) || !is_array($_POST['path_id'])) {
{
ilUtil::sendInfo($this->plugin->txt('no_path_selected')); ilUtil::sendInfo($this->plugin->txt('no_path_selected'));
$this->listPaths(); $this->listPaths();
return; return;
...@@ -134,49 +124,36 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI ...@@ -134,49 +124,36 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI
$set = new ilQuestionSetPoolSet((int) $_GET["set_id"]); $set = new ilQuestionSetPoolSet((int) $_GET["set_id"]);
$set->read(); $set->read();
require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
$confirmation = new ilConfirmationGUI(); $confirmation = new ilConfirmationGUI();
$num_items = 0; $num_items = 0;
$missing_perm_path_titles = array(); $missing_perm_path_titles = array();
foreach($_POST['path_id'] as $path_id) foreach ($_POST['path_id'] as $path_id) {
{
$path = new ilQuestionSetPoolPath((int) $path_id); $path = new ilQuestionSetPoolPath((int) $path_id);
$path->read(); $path->read();
if($path->getSet()->getContainerObjId() == $this->controller->object->getId()) if ($path->getSet()->getContainerObjId() == $this->controller->object->getId()) {
{
$confirmation->addItem('path_id[]', $path->getId(), $path->getTitle()); $confirmation->addItem('path_id[]', $path->getId(), $path->getTitle());
++$num_items; ++$num_items;
} } else {
else
{
$missing_perm_path_titles[] = $path->getTitle(); $missing_perm_path_titles[] = $path->getTitle();
} }
} }
if(1 == $num_items) if (1 == $num_items) {
{
$confirmation->setHeaderText($this->plugin->txt('confirm_delete_paths_s')); $confirmation->setHeaderText($this->plugin->txt('confirm_delete_paths_s'));
} } elseif ($num_items > 1) {
else if($num_items > 1)
{
$confirmation->setHeaderText($this->plugin->txt('confirm_delete_paths_p')); $confirmation->setHeaderText($this->plugin->txt('confirm_delete_paths_p'));
} }
$missing_perm_path_titles = array_filter($missing_perm_path_titles); $missing_perm_path_titles = array_filter($missing_perm_path_titles);
if(is_array($missing_perm_path_titles)) if (is_array($missing_perm_path_titles)) {
{ if (1 == count($missing_perm_path_titles)) {
if(1 == count($missing_perm_path_titles))
{
ilUtil::sendFailure(sprintf($this->plugin->txt('paths_del_perm_err_s'), implode(', ', $missing_perm_path_titles))); ilUtil::sendFailure(sprintf($this->plugin->txt('paths_del_perm_err_s'), implode(', ', $missing_perm_path_titles)));
} } elseif (count($missing_perm_path_titles) > 1) {
else if(count($missing_perm_path_titles) > 1)
{
ilUtil::sendFailure(sprintf($this->plugin->txt('paths_del_perm_err_p'), implode(', ', $missing_perm_path_titles))); ilUtil::sendFailure(sprintf($this->plugin->txt('paths_del_perm_err_p'), implode(', ', $missing_perm_path_titles)));
} }
} }
if(!$num_items) if (!$num_items) {
{
$this->listPaths(); $this->listPaths();
return; return;
} }
...@@ -194,8 +171,7 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI ...@@ -194,8 +171,7 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI
*/ */
public function remove() public function remove()
{ {
if(!isset($_POST['path_id']) || !is_array($_POST['path_id'])) if (!isset($_POST['path_id']) || !is_array($_POST['path_id'])) {
{
ilUtil::sendInfo($this->plugin->txt('no_path_selected')); ilUtil::sendInfo($this->plugin->txt('no_path_selected'));
$this->listPaths(); $this->listPaths();
return; return;
...@@ -206,39 +182,28 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI ...@@ -206,39 +182,28 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI
$num_items = 0; $num_items = 0;
$missing_perm_path_titles = array(); $missing_perm_path_titles = array();
foreach($_POST['path_id'] as $path_id) foreach ($_POST['path_id'] as $path_id) {
{
$path = new ilQuestionSetPoolPath((int) $path_id); $path = new ilQuestionSetPoolPath((int) $path_id);
$path->read(); $path->read();
if($path->getSet()->getContainerObjId() == $this->controller->object->getId()) if ($path->getSet()->getContainerObjId() == $this->controller->object->getId()) {
{
++$num_items; ++$num_items;
$path->remove(); $path->remove();
} } else {
else
{
$missing_perm_path_titles[] = $path->getTitle(); $missing_perm_path_titles[] = $path->getTitle();
} }
} }
if(1 == $num_items) if (1 == $num_items) {
{
ilUtil::sendSuccess($this->plugin->txt('deleted_paths_s'), true); ilUtil::sendSuccess($this->plugin->txt('deleted_paths_s'), true);
} } elseif ($num_items > 1) {
else if($num_items > 1)
{
ilUtil::sendSuccess($this->plugin->txt('deleted_paths_p'), true); ilUtil::sendSuccess($this->plugin->txt('deleted_paths_p'), true);
} }
$missing_perm_path_titles = array_filter($missing_perm_path_titles); $missing_perm_path_titles = array_filter($missing_perm_path_titles);
if(is_array($missing_perm_path_titles)) if (is_array($missing_perm_path_titles)) {
{ if (1 == count($missing_perm_path_titles)) {
if(1 == count($missing_perm_path_titles))
{
ilUtil::sendFailure(sprintf($this->plugin->txt('paths_del_perm_err_s'), implode(', ', $missing_perm_path_titles))); ilUtil::sendFailure(sprintf($this->plugin->txt('paths_del_perm_err_s'), implode(', ', $missing_perm_path_titles)));
} } elseif (count($missing_perm_path_titles) > 1) {
else if(count($missing_perm_path_titles) > 1)
{
ilUtil::sendFailure(sprintf($this->plugin->txt('paths_del_perm_err_p'), implode(', ', $missing_perm_path_titles))); ilUtil::sendFailure(sprintf($this->plugin->txt('paths_del_perm_err_p'), implode(', ', $missing_perm_path_titles)));
} }
} }
...@@ -274,14 +239,23 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI ...@@ -274,14 +239,23 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI
$this->ctrl->setParameter($this->controller, "set_id", (int) $_GET['set_id']); $this->ctrl->setParameter($this->controller, "set_id", (int) $_GET['set_id']);
$ilTabs->addSubTab("set_questions", $this->plugin->txt("questions"), $ilTabs->addSubTab(
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolSetQuestionsGUI.listQuestions")); "set_questions",
$this->plugin->txt("questions"),
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolSetQuestionsGUI.listQuestions")
);
$ilTabs->addSubTab("paths", $this->plugin->txt("paths"), $ilTabs->addSubTab(
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathsGUI.listPaths")); "paths",
$this->plugin->txt("paths"),
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathsGUI.listPaths")
);
$ilTabs->addSubTab("path_overview", $this->plugin->txt("path_overview"), $ilTabs->addSubTab(
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathGraphGUI.showPathOverview")); "path_overview",
$this->plugin->txt("path_overview"),
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathGraphGUI.showPathOverview")
);
$ilTabs->activateSubTab("paths"); $ilTabs->activateSubTab("paths");
...@@ -294,20 +268,18 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI ...@@ -294,20 +268,18 @@ class ilQuestionSetPoolPathsGUI extends ilPluginControllerTableGUI
$model->read(); $model->read();
$data = $model->getPathList()->getData(); $data = $model->getPathList()->getData();
foreach($data as $key => $element) foreach ($data as $key => $element) {
{
$data[$key]["path_index"] = (int) $_POST["sorting"][$element["id"]]; $data[$key]["path_index"] = (int) $_POST["sorting"][$element["id"]];
} }
usort( usort(
$data, function ($a, $b) { $data,
function ($a, $b) {
return $a["path_index"] - $b["path_index"]; return $a["path_index"] - $b["path_index"];
} }
); );
if(is_array($data)) if (is_array($data)) {
{ for ($i = 0; $i < count($data); $i++) {
for($i = 0; $i < count($data); $i++)
{
$data[$i]["path_index"] = ($i + 1); $data[$i]["path_index"] = ($i + 1);
$model->getPathList()->update($data[$i]); $model->getPathList()->update($data[$i]);
} }
......
...@@ -11,10 +11,8 @@ require_once "abstract.ilPluginControllerFormGUI.php"; ...@@ -11,10 +11,8 @@ require_once "abstract.ilPluginControllerFormGUI.php";
*/ */
class ilQuestionSetPoolPropertiesGUI extends ilPluginControllerFormGUI class ilQuestionSetPoolPropertiesGUI extends ilPluginControllerFormGUI
{ {
protected function initForm($model) protected function initForm($model)
{ {
require_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
$this->form = new ilPropertyFormGUI(); $this->form = new ilPropertyFormGUI();
$title = new ilTextInputGUI($this->plugin->txt("title"), "title"); $title = new ilTextInputGUI($this->plugin->txt("title"), "title");
...@@ -32,14 +30,11 @@ class ilQuestionSetPoolPropertiesGUI extends ilPluginControllerFormGUI ...@@ -32,14 +30,11 @@ class ilQuestionSetPoolPropertiesGUI extends ilPluginControllerFormGUI
$ilSetting = $DIC->settings(); $ilSetting = $DIC->settings();
$skill_setting_enabled = $ilSetting->_lookupValue('skmg', 'enable_skmg'); $skill_setting_enabled = $ilSetting->_lookupValue('skmg', 'enable_skmg');
if($skill_setting_enabled == false) if ($skill_setting_enabled == false) {
{
$skill_service->setChecked($skill_setting_enabled); $skill_service->setChecked($skill_setting_enabled);
$skill_service->setValue(0); $skill_service->setValue(0);
$skill_service->setDisabled(true); $skill_service->setDisabled(true);
} } else {
else
{
$skill_service->setValue(1); $skill_service->setValue(1);
} }
...@@ -84,7 +79,6 @@ class ilQuestionSetPoolPropertiesGUI extends ilPluginControllerFormGUI ...@@ -84,7 +79,6 @@ class ilQuestionSetPoolPropertiesGUI extends ilPluginControllerFormGUI
*/ */
protected function getRedirectAfterUpdate() protected function getRedirectAfterUpdate()
{ {
} }
/** /**
......
...@@ -11,26 +11,21 @@ require_once "abstract.ilPluginControllerFormGUI.php"; ...@@ -11,26 +11,21 @@ require_once "abstract.ilPluginControllerFormGUI.php";
*/ */
class ilQuestionSetPoolSetGUI extends ilPluginControllerFormGUI class ilQuestionSetPoolSetGUI extends ilPluginControllerFormGUI
{ {
public function update() public function update()
{ {
$model = $this->loadModel(); $model = $this->loadModel();
$this->initForm($model); $this->initForm($model);
if($this->form->checkInput()) if ($this->form->checkInput()) {
{
$model->bindForm($this->form); $model->bindForm($this->form);
if($model->isTitleUnique()) if ($model->isTitleUnique()) {
{
$model->update(); $model->update();
ilUtil::sendSuccess($this->plugin->txt("msg_obj_modified"), true); ilUtil::sendSuccess($this->plugin->txt("msg_obj_modified"), true);
$this->redirect( $this->redirect(
$this->getAfterUpdateRedirectCmd(), $this->getAfterUpdateRedirectCmd(),
$this->getAfterUpdateRedirectParams($model) $this->getAfterUpdateRedirectParams($model)
); );
} } else {
else
{
ilUtil::sendFailure($this->plugin->txt("set_title_not_unique"), true); ilUtil::sendFailure($this->plugin->txt("set_title_not_unique"), true);
} }
} }
...@@ -60,8 +55,6 @@ class ilQuestionSetPoolSetGUI extends ilPluginControllerFormGUI ...@@ -60,8 +55,6 @@ class ilQuestionSetPoolSetGUI extends ilPluginControllerFormGUI
protected function initForm($model) protected function initForm($model)
{ {
require_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
$this->form = new ilPropertyFormGUI(); $this->form = new ilPropertyFormGUI();
$this->form->setTitle(sprintf( $this->form->setTitle(sprintf(
$this->plugin->txt("question_set_title"), $this->plugin->txt("question_set_title"),
......
...@@ -24,8 +24,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -24,8 +24,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
{ {
$this->controller->ensurePermission('write'); $this->controller->ensurePermission('write');
if($this->controller->object instanceof ilObjQuestionSetPool) if ($this->controller->object instanceof ilObjQuestionSetPool) {
{
$this->addToolbarButton("back_to_set_list", "ilQuestionSetPoolSetsGUI.show"); $this->addToolbarButton("back_to_set_list", "ilQuestionSetPoolSetsGUI.show");
} }
$this->addToolbarButton("browse_for_questions", "ilQuestionSetPoolSetQuestionsGUI.browseForQuestions", array( $this->addToolbarButton("browse_for_questions", "ilQuestionSetPoolSetQuestionsGUI.browseForQuestions", array(
...@@ -82,8 +81,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -82,8 +81,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
{ {
$this->controller->ensurePermission('write'); $this->controller->ensurePermission('write');
if(!$this->dataSelected("q_id")) if (!$this->dataSelected("q_id")) {
{
ilUtil::sendInfo($this->plugin->txt("no_questions_selected"), true); ilUtil::sendInfo($this->plugin->txt("no_questions_selected"), true);
$this->redirect("ilQuestionSetPoolSetQuestionsGUI.browseForQuestions", array( $this->redirect("ilQuestionSetPoolSetQuestionsGUI.browseForQuestions", array(
'set_id' => (int) $_GET['set_id'] 'set_id' => (int) $_GET['set_id']
...@@ -94,8 +92,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -94,8 +92,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
$set->read(); $set->read();
$success = $set->getQuestionList()->insert($_POST['q_id'], $this->controller->object); $success = $set->getQuestionList()->insert($_POST['q_id'], $this->controller->object);
if(!$success) if (!$success) {
{
ilUtil::sendFailure($this->plugin->txt("questions_added_error"), true); ilUtil::sendFailure($this->plugin->txt("questions_added_error"), true);
$this->redirect("ilQuestionSetPoolSetQuestionsGUI.browseForQuestions", array( $this->redirect("ilQuestionSetPoolSetQuestionsGUI.browseForQuestions", array(
'set_id' => (int) $_GET['set_id'] 'set_id' => (int) $_GET['set_id']
...@@ -113,8 +110,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -113,8 +110,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
*/ */
public function removeConfirmation() public function removeConfirmation()
{ {
if(!isset($_GET['q_id'])) if (!isset($_GET['q_id'])) {
{
ilUtil::sendInfo($this->plugin->txt('no_questions_selected_to_delete')); ilUtil::sendInfo($this->plugin->txt('no_questions_selected_to_delete'));
$this->listQuestions(); $this->listQuestions();
return; return;
...@@ -131,8 +127,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -131,8 +127,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
{ {
$this->controller->ensurePermission('write'); $this->controller->ensurePermission('write');
if(!isset($_POST['q_id']) || !is_array($_POST['q_id']) || !count($_POST['q_id'])) if (!isset($_POST['q_id']) || !is_array($_POST['q_id']) || !count($_POST['q_id'])) {
{
ilUtil::sendFailure($this->lng->txt('copy_no_questions_selected')); ilUtil::sendFailure($this->lng->txt('copy_no_questions_selected'));
$this->listQuestions(); $this->listQuestions();
} }
...@@ -142,14 +137,10 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -142,14 +137,10 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
$set = new ilQuestionSetPoolSet((int) $_GET["set_id"]); $set = new ilQuestionSetPoolSet((int) $_GET["set_id"]);
$set->read(); $set->read();
$set->getQuestionList()->insert($question_ids, $this->controller->object); $set->getQuestionList()->insert($question_ids, $this->controller->object);
if(is_array($question_ids)) if (is_array($question_ids)) {
{ if (1 == count($question_ids)) {
if(1 == count($question_ids))
{
ilUtil::sendSuccess($this->plugin->txt('copy_questions_success_s'), true); ilUtil::sendSuccess($this->plugin->txt('copy_questions_success_s'), true);
} } else {
else
{
ilUtil::sendSuccess($this->plugin->txt('copy_questions_success_p'), true); ilUtil::sendSuccess($this->plugin->txt('copy_questions_success_p'), true);
} }
$this->redirect("ilQuestionSetPoolSetQuestionsGUI.listQuestions", array( $this->redirect("ilQuestionSetPoolSetQuestionsGUI.listQuestions", array(
...@@ -165,8 +156,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -165,8 +156,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
{ {
$this->controller->ensurePermission('write'); $this->controller->ensurePermission('write');
if(!$this->dataSelected('q_id')) if (!$this->dataSelected('q_id')) {
{
ilUtil::sendInfo($this->plugin->txt('no_questions_selected_to_delete')); ilUtil::sendInfo($this->plugin->txt('no_questions_selected_to_delete'));
$this->listQuestions(); $this->listQuestions();
return; return;
...@@ -182,20 +172,15 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -182,20 +172,15 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
$confirmation->setConfirm($this->lng->txt('confirm'), __CLASS__ . '.removeQuestions'); $confirmation->setConfirm($this->lng->txt('confirm'), __CLASS__ . '.removeQuestions');
$num_items = 0; $num_items = 0;
require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php'; foreach ($_POST['q_id'] as $question_id) {
foreach($_POST['q_id'] as $question_id)
{
$question = assQuestion::_instanciateQuestion($question_id); $question = assQuestion::_instanciateQuestion($question_id);
$confirmation->addItem('q_id[]', $question_id, $question->getTitle()); $confirmation->addItem('q_id[]', $question_id, $question->getTitle());
++$num_items; ++$num_items;
} }
if(1 == $num_items) if (1 == $num_items) {
{
$confirmation->setHeaderText($this->plugin->txt('remove_selected_questions_s')); $confirmation->setHeaderText($this->plugin->txt('remove_selected_questions_s'));
} } else {
else
{
$confirmation->setHeaderText($this->plugin->txt('remove_selected_questions_p')); $confirmation->setHeaderText($this->plugin->txt('remove_selected_questions_p'));
} }
...@@ -206,8 +191,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -206,8 +191,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
{ {
$this->controller->ensurePermission('write'); $this->controller->ensurePermission('write');
if(!$this->dataSelected('q_id')) if (!$this->dataSelected('q_id')) {
{
ilUtil::sendInfo($this->plugin->txt('no_questions_selected_to_delete'), true); ilUtil::sendInfo($this->plugin->txt('no_questions_selected_to_delete'), true);
$this->redirect('ilQuestionSetPoolSetQuestionsGUI.listQuestions', array( $this->redirect('ilQuestionSetPoolSetQuestionsGUI.listQuestions', array(
'set_id' => (int) $_GET['set_id'] 'set_id' => (int) $_GET['set_id']
...@@ -222,12 +206,9 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -222,12 +206,9 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
$model->read(); $model->read();
$model->getQuestionList()->remove($questions_to_delete); $model->getQuestionList()->remove($questions_to_delete);
if(is_array($questions_to_delete) && count($questions_to_delete) == 1) if (is_array($questions_to_delete) && count($questions_to_delete) == 1) {
{
ilUtil::sendSuccess($this->plugin->txt('deleted_selected_questions_s'), true); ilUtil::sendSuccess($this->plugin->txt('deleted_selected_questions_s'), true);
} } else {
else
{
ilUtil::sendSuccess($this->plugin->txt('deleted_selected_questions_p'), true); ilUtil::sendSuccess($this->plugin->txt('deleted_selected_questions_p'), true);
} }
$this->redirect('ilQuestionSetPoolSetQuestionsGUI.listQuestions', array( $this->redirect('ilQuestionSetPoolSetQuestionsGUI.listQuestions', array(
...@@ -241,12 +222,9 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -241,12 +222,9 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
public function showQuestionPreview() public function showQuestionPreview()
{ {
$this->ctrl->setParameter($this->controller, "set_id", (int) $_GET['set_id']); $this->ctrl->setParameter($this->controller, "set_id", (int) $_GET['set_id']);
if(isset($_GET['referer']) && 'browse' == $_GET['referer']) if (isset($_GET['referer']) && 'browse' == $_GET['referer']) {
{
$this->toolbar->addButton($this->plugin->txt('back_to_qst_list'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.browseForQuestions')); $this->toolbar->addButton($this->plugin->txt('back_to_qst_list'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.browseForQuestions'));
} } else {
else
{
$this->toolbar->addButton($this->plugin->txt('back_to_qst_list'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.listQuestions')); $this->toolbar->addButton($this->plugin->txt('back_to_qst_list'), $this->ctrl->getLinkTarget($this->controller, __CLASS__ . '.listQuestions'));
} }
$this->ctrl->setParameter($this->controller, "set_id", ""); $this->ctrl->setParameter($this->controller, "set_id", "");
...@@ -254,7 +232,6 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -254,7 +232,6 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
$this->controller->populateContentStyleBlock(); $this->controller->populateContentStyleBlock();
$this->controller->populateSyntaxStyleBlock(); $this->controller->populateSyntaxStyleBlock();
require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
$gui = assQuestion::instantiateQuestionGUI((int) $_GET['q_id']); $gui = assQuestion::instantiateQuestionGUI((int) $_GET['q_id']);
$gui->setTargetGuiClass('ilObjQuestionSetPoolGUI'); $gui->setTargetGuiClass('ilObjQuestionSetPoolGUI');
$preview = $gui->getPreview(); $preview = $gui->getPreview();
...@@ -297,9 +274,6 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -297,9 +274,6 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
*/ */
protected function getRequirements() protected function getRequirements()
{ {
require_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
require_once "Modules/Test/classes/class.ilObjAssessmentFolder.php";
return array( return array(
"tables/class.ilQuestionSetPoolQuestionsTableGUI.php", "tables/class.ilQuestionSetPoolQuestionsTableGUI.php",
"tables/class.ilQuestionSetPoolSetQuestionsTableGUI.php", "tables/class.ilQuestionSetPoolSetQuestionsTableGUI.php",
...@@ -317,8 +291,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -317,8 +291,7 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
{ {
$this->controller->ensurePermission('write'); $this->controller->ensurePermission('write');
if(!isset($_GET['q_id']) || !(int)$_GET['q_id']) if (!isset($_GET['q_id']) || !(int) $_GET['q_id']) {
{
$this->listQuestions(); $this->listQuestions();
return; return;
} }
...@@ -336,14 +309,23 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -336,14 +309,23 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
{ {
$this->ctrl->setParameter($this->controller, "set_id", (int) $_GET['set_id']); $this->ctrl->setParameter($this->controller, "set_id", (int) $_GET['set_id']);
$this->tabs->addSubTab("set_questions", $this->plugin->txt("questions"), $this->tabs->addSubTab(
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolSetQuestionsGUI.listQuestions")); "set_questions",
$this->plugin->txt("questions"),
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolSetQuestionsGUI.listQuestions")
);
$this->tabs->addSubTab("paths", $this->plugin->txt("paths"), $this->tabs->addSubTab(
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathsGUI.listPaths")); "paths",
$this->plugin->txt("paths"),
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathsGUI.listPaths")
);
$this->tabs->addSubTab("path_overview", $this->plugin->txt("path_overview"), $this->tabs->addSubTab(
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathGraphGUI.showPathOverview")); "path_overview",
$this->plugin->txt("path_overview"),
$this->ctrl->getLinkTarget($this->controller, "ilQuestionSetPoolPathGraphGUI.showPathOverview")
);
$this->tabs->activateSubTab("set_questions"); $this->tabs->activateSubTab("set_questions");
...@@ -359,18 +341,16 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI ...@@ -359,18 +341,16 @@ class ilQuestionSetPoolSetQuestionsGUI extends ilPluginControllerTableGUI
$model->read(); $model->read();
$paths = $model->getPathList()->getData(); $paths = $model->getPathList()->getData();
foreach((array)$_POST['q_id'] as $question_id) foreach ((array) $_POST['q_id'] as $question_id) {
{ foreach ($paths as $path_data) {
foreach($paths as $path_data)
{
$path = new ilQuestionSetPoolPath($path_data['id']); $path = new ilQuestionSetPoolPath($path_data['id']);
$path->read(); $path->read();
if($path->isQuestionInPath($question_id)) if ($path->isQuestionInPath($question_id)) {
{
ilUtil::sendFailure($this->plugin->txt('questions_used_in_path'), true); ilUtil::sendFailure($this->plugin->txt('questions_used_in_path'), true);
$this->redirect( $this->redirect(
'ilQuestionSetPoolSetQuestionsGUI.listQuestions', array( 'ilQuestionSetPoolSetQuestionsGUI.listQuestions',
array(
'set_id' => (int) $_GET['set_id'] 'set_id' => (int) $_GET['set_id']
) )
); );
......
...@@ -11,7 +11,6 @@ require_once "abstract.ilPluginControllerTableGUI.php"; ...@@ -11,7 +11,6 @@ require_once "abstract.ilPluginControllerTableGUI.php";
*/ */
class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI
{ {
public function show() public function show()
{ {
$this->addToolbarButton("add_set", "ilQuestionSetPoolSetGUI.edit"); $this->addToolbarButton("add_set", "ilQuestionSetPoolSetGUI.edit");
...@@ -30,8 +29,7 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI ...@@ -30,8 +29,7 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI
*/ */
public function removeConfirmation() public function removeConfirmation()
{ {
if(!isset($_GET['set_id'])) if (!isset($_GET['set_id'])) {
{
ilUtil::sendInfo($this->plugin->txt('no_set_selected')); ilUtil::sendInfo($this->plugin->txt('no_set_selected'));
$this->show(); $this->show();
return; return;
...@@ -46,8 +44,7 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI ...@@ -46,8 +44,7 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI
*/ */
public function removeMultipleConfirmation() public function removeMultipleConfirmation()
{ {
if(!isset($_POST['set_id']) || !is_array($_POST['set_id'])) if (!isset($_POST['set_id']) || !is_array($_POST['set_id'])) {
{
ilUtil::sendInfo($this->plugin->txt('no_set_selected')); ilUtil::sendInfo($this->plugin->txt('no_set_selected'));
$this->show(); $this->show();
return; return;
...@@ -55,49 +52,36 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI ...@@ -55,49 +52,36 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI
$this->tabs->activateSubTab('paths'); $this->tabs->activateSubTab('paths');
require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
$confirmation = new ilConfirmationGUI(); $confirmation = new ilConfirmationGUI();
$num_items = 0; $num_items = 0;
$missing_perm_nodes_titles = array(); $missing_perm_nodes_titles = array();
foreach($_POST['set_id'] as $set_id) foreach ($_POST['set_id'] as $set_id) {
{
$set = new ilQuestionSetPoolSet((int) $set_id); $set = new ilQuestionSetPoolSet((int) $set_id);
$set->read(); $set->read();
if($set->getContainerObjId() == $this->controller->object->getId()) if ($set->getContainerObjId() == $this->controller->object->getId()) {
{
$confirmation->addItem('set_id[]', $set->getId(), $set->getTitle()); $confirmation->addItem('set_id[]', $set->getId(), $set->getTitle());
++$num_items; ++$num_items;
} } else {
else
{
$missing_perm_nodes_titles[] = $set->getTitle(); $missing_perm_nodes_titles[] = $set->getTitle();
} }
} }
if(1 == $num_items) if (1 == $num_items) {
{
$confirmation->setHeaderText($this->plugin->txt('confirm_delete_sets_s')); $confirmation->setHeaderText($this->plugin->txt('confirm_delete_sets_s'));
} } else {
else
{
$confirmation->setHeaderText($this->plugin->txt('confirm_delete_sets_p')); $confirmation->setHeaderText($this->plugin->txt('confirm_delete_sets_p'));
} }
$missing_perm_nodes_titles = array_filter($missing_perm_nodes_titles); $missing_perm_nodes_titles = array_filter($missing_perm_nodes_titles);
if(is_array($missing_perm_nodes_titles)) if (is_array($missing_perm_nodes_titles)) {
{ if (1 == count($missing_perm_nodes_titles)) {
if(1 == count($missing_perm_nodes_titles))
{
ilUtil::sendFailure(sprintf($this->plugin->txt('sets_del_perm_err_s'), implode(', ', $missing_perm_nodes_titles))); ilUtil::sendFailure(sprintf($this->plugin->txt('sets_del_perm_err_s'), implode(', ', $missing_perm_nodes_titles)));
} } elseif (count($missing_perm_nodes_titles) > 1) {
else if(count($missing_perm_nodes_titles) > 1)
{
ilUtil::sendFailure(sprintf($this->plugin->txt('sets_del_perm_err_p'), implode(', ', $missing_perm_nodes_titles))); ilUtil::sendFailure(sprintf($this->plugin->txt('sets_del_perm_err_p'), implode(', ', $missing_perm_nodes_titles)));
} }
} }
if(!$num_items) if (!$num_items) {
{
$this->show(); $this->show();
return; return;
} }
...@@ -114,8 +98,7 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI ...@@ -114,8 +98,7 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI
*/ */
public function remove() public function remove()
{ {
if(!isset($_POST['set_id']) || !is_array($_POST['set_id'])) if (!isset($_POST['set_id']) || !is_array($_POST['set_id'])) {
{
ilUtil::sendInfo($this->plugin->txt('no_set_selected')); ilUtil::sendInfo($this->plugin->txt('no_set_selected'));
$this->show(); $this->show();
return; return;
...@@ -123,39 +106,28 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI ...@@ -123,39 +106,28 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI
$num_items = 0; $num_items = 0;
$missing_perm_nodes_titles = array(); $missing_perm_nodes_titles = array();
foreach($_POST['set_id'] as $set_id) foreach ($_POST['set_id'] as $set_id) {
{
$set = new ilQuestionSetPoolSet((int) $set_id); $set = new ilQuestionSetPoolSet((int) $set_id);
$set->read(); $set->read();
if($set->getContainerObjId() == $this->controller->object->getId()) if ($set->getContainerObjId() == $this->controller->object->getId()) {
{
$set->remove(); $set->remove();
++$num_items; ++$num_items;
} } else {
else
{
$missing_perm_nodes_titles[] = $set->getTitle(); $missing_perm_nodes_titles[] = $set->getTitle();
} }
} }
if(1 == $num_items) if (1 == $num_items) {
{
ilUtil::sendSuccess($this->plugin->txt('deleted_sets_s'), true); ilUtil::sendSuccess($this->plugin->txt('deleted_sets_s'), true);
} } elseif ($num_items > 1) {
else if($num_items > 1)
{
ilUtil::sendSuccess($this->plugin->txt('deleted_sets_p'), true); ilUtil::sendSuccess($this->plugin->txt('deleted_sets_p'), true);
} }
$missing_perm_nodes_titles = array_filter($missing_perm_nodes_titles); $missing_perm_nodes_titles = array_filter($missing_perm_nodes_titles);
if(is_array($missing_perm_nodes_titles)) if (is_array($missing_perm_nodes_titles)) {
{ if (1 == count($missing_perm_nodes_titles)) {
if(1 == count($missing_perm_nodes_titles))
{
ilUtil::sendFailure(sprintf($this->plugin->txt('sets_del_perm_err_s'), implode(', ', $missing_perm_nodes_titles))); ilUtil::sendFailure(sprintf($this->plugin->txt('sets_del_perm_err_s'), implode(', ', $missing_perm_nodes_titles)));
} } elseif (count($missing_perm_nodes_titles) > 1) {
else if(count($missing_perm_nodes_titles) > 1)
{
ilUtil::sendFailure(sprintf($this->plugin->txt('sets_del_perm_err_p'), implode(', ', $missing_perm_nodes_titles))); ilUtil::sendFailure(sprintf($this->plugin->txt('sets_del_perm_err_p'), implode(', ', $missing_perm_nodes_titles)));
} }
} }
...@@ -164,14 +136,12 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI ...@@ -164,14 +136,12 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI
public function duplicate() public function duplicate()
{ {
if(!$this->dataSelected("set_id")) if (!$this->dataSelected("set_id")) {
{
ilUtil::sendInfo($this->plugin->txt('no_set_selected')); ilUtil::sendInfo($this->plugin->txt('no_set_selected'));
$this->redirect("ilQuestionSetPoolSetsGUI.show"); $this->redirect("ilQuestionSetPoolSetsGUI.show");
} }
foreach($_POST["set_id"] as $set_id) foreach ($_POST["set_id"] as $set_id) {
{
$set = new ilQuestionSetPoolSet((int) $set_id); $set = new ilQuestionSetPoolSet((int) $set_id);
$set->read(); $set->read();
$set->duplicate($this->controller->object->getId()); $set->duplicate($this->controller->object->getId());
...@@ -187,8 +157,7 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI ...@@ -187,8 +157,7 @@ class ilQuestionSetPoolSetsGUI extends ilPluginControllerTableGUI
$set = new ilQuestionSetPoolSet((int) $_GET["set_id"]); $set = new ilQuestionSetPoolSet((int) $_GET["set_id"]);
$set->read(); $set->read();
if(ilObjQuestionSetPool::canSynchronizeSet($set->getOriginalId())) if (ilObjQuestionSetPool::canSynchronizeSet($set->getOriginalId())) {
{
$original = new ilQuestionSetPoolSet($set->getOriginalId()); $original = new ilQuestionSetPoolSet($set->getOriginalId());
$original->read(); $original->read();
$old_questions = $original->getQuestionList()->getData(); $old_questions = $original->getQuestionList()->getData();
......
<?php <?php
require_once 'abstract.ilPluginControllerGUI.php'; require_once 'abstract.ilPluginControllerGUI.php';
require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentsGUI.php';
require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillUsagesTableGUI.php';
require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
/** /**
...@@ -37,8 +34,7 @@ class ilQuestionSetPoolSkillAdministrationGUI extends ilPLuginControllerGUI ...@@ -37,8 +34,7 @@ class ilQuestionSetPoolSkillAdministrationGUI extends ilPLuginControllerGUI
$ilPluginAdmin = $DIC['ilPluginAdmin']; $ilPluginAdmin = $DIC['ilPluginAdmin'];
$ilAccess = $DIC->access(); $ilAccess = $DIC->access();
if( $this->isAccessDenied() ) if ($this->isAccessDenied()) {
{
$this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE); $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
} }
...@@ -46,8 +42,7 @@ class ilQuestionSetPoolSkillAdministrationGUI extends ilPLuginControllerGUI ...@@ -46,8 +42,7 @@ class ilQuestionSetPoolSkillAdministrationGUI extends ilPLuginControllerGUI
$this->setSubTabs($nextClass); $this->setSubTabs($nextClass);
$questionContainerId = $this->object->getId(); $questionContainerId = $this->object->getId();
switch($nextClass) switch ($nextClass) {
{
case 'ilassquestionskillassignmentsgui': case 'ilassquestionskillassignmentsgui':
$provider = new ilQuestionSetPoolSkillQuestionListProvider(); $provider = new ilQuestionSetPoolSkillQuestionListProvider();
...@@ -86,13 +81,11 @@ class ilQuestionSetPoolSkillAdministrationGUI extends ilPLuginControllerGUI ...@@ -86,13 +81,11 @@ class ilQuestionSetPoolSkillAdministrationGUI extends ilPLuginControllerGUI
protected function isAccessDenied() protected function isAccessDenied()
{ {
if(!$this->object->isSkillServiceEnabled()) if (!$this->object->isSkillServiceEnabled()) {
{
return true; return true;
} }
if(!ilObjQuestionSetPool::isSkillManagementGloballyActivated()) if (!ilObjQuestionSetPool::isSkillManagementGloballyActivated()) {
{
return true; return true;
} }
...@@ -111,17 +104,23 @@ class ilQuestionSetPoolSkillAdministrationGUI extends ilPLuginControllerGUI ...@@ -111,17 +104,23 @@ class ilQuestionSetPoolSkillAdministrationGUI extends ilPLuginControllerGUI
private function setSubTabs($controllerClass) private function setSubTabs($controllerClass)
{ {
$link = $this->ctrl->getLinkTargetByClass( $link = $this->ctrl->getLinkTargetByClass(
'ilAssQuestionSkillAssignmentsGUI', ilAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_QUEST_ASSIGNS 'ilAssQuestionSkillAssignmentsGUI',
ilAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_QUEST_ASSIGNS
); );
$this->tabs->addSubTab( $this->tabs->addSubTab(
'ilassquestionskillassignmentsgui', $this->lng->txt('qpl_skl_sub_tab_quest_assign'), $link 'ilassquestionskillassignmentsgui',
$this->lng->txt('qpl_skl_sub_tab_quest_assign'),
$link
); );
$link = $this->ctrl->getLinkTargetByClass( $link = $this->ctrl->getLinkTargetByClass(
'ilAssQuestionSkillUsagesTableGUI', ilAssQuestionSkillUsagesTableGUI::CMD_SHOW 'ilAssQuestionSkillUsagesTableGUI',
ilAssQuestionSkillUsagesTableGUI::CMD_SHOW
); );
$this->tabs->addSubTab( $this->tabs->addSubTab(
'ilassquestionskillusagestablegui', $this->lng->txt('qpl_skl_sub_tab_usages'), $link 'ilassquestionskillusagestablegui',
$this->lng->txt('qpl_skl_sub_tab_usages'),
$link
); );
...@@ -139,4 +138,3 @@ class ilQuestionSetPoolSkillAdministrationGUI extends ilPLuginControllerGUI ...@@ -139,4 +138,3 @@ class ilQuestionSetPoolSkillAdministrationGUI extends ilPLuginControllerGUI
); );
} }
} }
\ No newline at end of file
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
* Time: 14:32 * Time: 14:32
* @author Thomas Joußen <tjoussen@databay.de> * @author Thomas Joußen <tjoussen@databay.de>
*/ */
class ilPluginDispatcher { class ilPluginDispatcher
{
/** /**
* @var ilPluginDispatcher * @var ilPluginDispatcher
...@@ -21,8 +22,7 @@ class ilPluginDispatcher { ...@@ -21,8 +22,7 @@ class ilPluginDispatcher {
*/ */
public static function getInstance($baseController) public static function getInstance($baseController)
{ {
if(self::$_instance == null) if (self::$_instance == null) {
{
self::$_instance = new ilPluginDispatcher($baseController); self::$_instance = new ilPluginDispatcher($baseController);
} }
...@@ -39,8 +39,7 @@ class ilPluginDispatcher { ...@@ -39,8 +39,7 @@ class ilPluginDispatcher {
$controller = $this->getController($cmd); $controller = $this->getController($cmd);
$command = $this->getCommand($cmd); $command = $this->getCommand($cmd);
if(!is_object($controller)) if (!is_object($controller)) {
{
$controller = $this->instantiateController($controller); $controller = $this->instantiateController($controller);
} }
...@@ -56,8 +55,7 @@ class ilPluginDispatcher { ...@@ -56,8 +55,7 @@ class ilPluginDispatcher {
{ {
$controller = substr($cmd, 0, strpos($cmd, ".")); $controller = substr($cmd, 0, strpos($cmd, "."));
if($controller == "") if ($controller == "") {
{
$controller = $this->baseController; $controller = $this->baseController;
} }
...@@ -73,8 +71,7 @@ class ilPluginDispatcher { ...@@ -73,8 +71,7 @@ class ilPluginDispatcher {
{ {
$pos = strpos($cmd, "."); $pos = strpos($cmd, ".");
if($pos > 0) if ($pos > 0) {
{
$cmd = substr($cmd, $pos + 1); $cmd = substr($cmd, $pos + 1);
} }
...@@ -116,6 +113,11 @@ class ilPluginDispatcher { ...@@ -116,6 +113,11 @@ class ilPluginDispatcher {
require_once $this->getControllerPath() . "class.$controller.php"; require_once $this->getControllerPath() . "class.$controller.php";
} }
private function __construct($baseController){$this->baseController = $baseController;} private function __construct($baseController)
private function __clone(){} {
$this->baseController = $baseController;
}
private function __clone()
{
}
} }
...@@ -47,13 +47,10 @@ abstract class ilPluginModel implements ilPluginModelInterface ...@@ -47,13 +47,10 @@ abstract class ilPluginModel implements ilPluginModelInterface
public function toArray() public function toArray()
{ {
$result = array(); $result = array();
foreach($this as $key => $value) foreach ($this as $key => $value) {
{
$result[$key] = $value; $result[$key] = $value;
} }
return $result; return $result;
} }
} }
\ No newline at end of file