diff --git a/README.md b/README.md index 4415220fffaeb6173418f0902ece57882eae1fe8..d0463d6d847596d520913c6582519d263e7e6550 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ILIAS FormATest -* For ILIAS versions: 5.3.0 - 5.3.999 +* For ILIAS versions: 5.3.0 - 5.4.999 ## Installation Instructions 1. Clone this repository to /Customizing/global/plugins/Services/Repository/RepositoryObject/FormATest diff --git a/classes/class.ilFormATestExporter.php b/classes/class.ilFormATestExporter.php index 9e7588ac18fb5ddc83438c5b084b6b90a1ab9372..aee500ed64605ea7e394deb6eda32a6c06995ca6 100755 --- a/classes/class.ilFormATestExporter.php +++ b/classes/class.ilFormATestExporter.php @@ -299,7 +299,7 @@ class ilFormATestExporter extends ilXmlExporter $this->questions[$question['question_id']] = $question['question_id']; } $this->xml_writer->xmlEndTag('Questions'); - if(count($this->questions) > 0) + if(is_array($this->questions) && count($this->questions) > 0) { $this->exportQuestions(); } diff --git a/classes/class.ilFormATestImporter.php b/classes/class.ilFormATestImporter.php index 4c3e1dbb1d2e511552ee6c35e9f0d7966cedd3cc..4f85b953e4fddb1752269864feb66db0f8b90c67 100644 --- a/classes/class.ilFormATestImporter.php +++ b/classes/class.ilFormATestImporter.php @@ -372,7 +372,7 @@ class ilFormATestImporter extends ilXmlImporter $this->addNodeMapping($node_data[0]['NodeId'], $node->getId()); $jump_conditions = $node_data['jump_conditions']; - if(count($jump_conditions) == 0) + if(is_array($jump_conditions) && count($jump_conditions) == 0) { continue 1; } diff --git a/classes/class.ilFormATestXmlValidator.php b/classes/class.ilFormATestXmlValidator.php index 029ac28c059dc6564e4b18b79feaacccb1c6f905..1abe6db87d3ae375683788d4a61fe1923cb1799a 100644 --- a/classes/class.ilFormATestXmlValidator.php +++ b/classes/class.ilFormATestXmlValidator.php @@ -229,7 +229,7 @@ class ilFormATestXmlValidator return true; } - if(count($this->errors)) + if(is_array($this->errors) && count($this->errors)) { return false; } @@ -275,7 +275,7 @@ class ilFormATestXmlValidator } } libxml_clear_errors(); - if(count($this->errors)) + if(is_array($this->errors) && count($this->errors)) { return false; } diff --git a/classes/class.ilObjFormATest.php b/classes/class.ilObjFormATest.php index 544ad27a8f25a738c00abd9b3a75c9cec9a7d0db..f5e23247d734ac04c99715033d1b9ecaa667521f 100644 --- a/classes/class.ilObjFormATest.php +++ b/classes/class.ilObjFormATest.php @@ -1333,7 +1333,7 @@ class ilObjFormATest extends ilObjectPlugin implements ilLPStatusPluginInterface global $DIC; $ilDB = $DIC->database(); - if(count($obj_ids) == 1) + if(is_array($obj_ids) && count($obj_ids) == 1) { $in = ' id = ' . $ilDB->quote(current($obj_ids), 'integer') . ' '; } @@ -1378,11 +1378,12 @@ class ilObjFormATest extends ilObjectPlugin implements ilLPStatusPluginInterface */ final public function isComplete() { - if(!count($this->mark_schema->mark_steps)) + if(is_array($this->mark_schema->mark_steps) && !count($this->mark_schema->mark_steps)) { return false; } + if(is_array($this->getSetList()->getData())) return count((array)$this->getSetList()->getData()) > 0; } diff --git a/classes/class.ilObjFormATestGUI.php b/classes/class.ilObjFormATestGUI.php index 30640bccdbed86ae6085f9cfe49cae8041ff697b..c120bc5547246f6036eea1607d2b2f9b1098b56b 100644 --- a/classes/class.ilObjFormATestGUI.php +++ b/classes/class.ilObjFormATestGUI.php @@ -474,7 +474,7 @@ class ilObjFormATestGUI extends ilObjectPluginGUI implements ilDesktopItemHandli $xqsp_available_pools = ilObjQuestionSetPool::getAvailableQuestionSetPools(TRUE); $options_1 = array(ilFormATestImporter::SINGLE_IMPORT_NEW_POOL => $this->plugin->txt("new_xqsp_pool")); - if (count($xqsp_available_pools)) + if (is_array($xqsp_available_pools) && count($xqsp_available_pools)) { foreach ($xqsp_available_pools as $key => $xqsp_obj) { @@ -498,7 +498,7 @@ class ilObjFormATestGUI extends ilObjectPluginGUI implements ilDesktopItemHandli ilFormATestImporter::SINGLE_IMPORT_NO_POOL => $this->lng->txt('assessment_no_pool') ); - if (count($questionpools)) + if (is_array($questionpools) && count($questionpools)) { foreach ($questionpools as $key => $value) { diff --git a/classes/class.ilObjFormATestQuestionSetPoolGUI.php b/classes/class.ilObjFormATestQuestionSetPoolGUI.php index 746391da5eda0c199c1a40e7f46052aa6c20827a..d45e4255ed0c552c947773668d4a70114ca2dd6d 100644 --- a/classes/class.ilObjFormATestQuestionSetPoolGUI.php +++ b/classes/class.ilObjFormATestQuestionSetPoolGUI.php @@ -90,26 +90,29 @@ class ilObjFormATestQuestionSetPoolGUI extends ilObjQuestionSetPoolGUI $this->performCommand($cmd); $reflection = new ReflectionClass(get_class($this->tpl)); - $property = $reflection->getProperty('message'); + $property = $reflection->getProperty('message'); $property->setAccessible(true); $values = $property->getValue($this->tpl); $values = (array)$values; - if(ilObjQuestionSetPool::canSynchronizeSet($set->getOriginalId())) + if(is_array($values['failure'])) { - if(!strlen($_SESSION['failure']) && !count($values['failure'])) + if(ilObjQuestionSetPool::canSynchronizeSet($set->getOriginalId())) { - $ilCtrl->setParameter($this, "set_id", $set->getId()); - $ilToolbar->setFormAction($ilCtrl->getFormAction($this)); - $ilCtrl->setParameter($this, "set_id", ""); - $ilToolbar->addFormButton($this->plugin->txt("synchronize_set"),"ilQuestionSetPoolSetsGUI.synchronize", "", true); + if(!strlen($_SESSION['failure']) && !count($values['failure'])) + { + $ilCtrl->setParameter($this, "set_id", $set->getId()); + $ilToolbar->setFormAction($ilCtrl->getFormAction($this)); + $ilCtrl->setParameter($this, "set_id", ""); + $ilToolbar->addFormButton($this->plugin->txt("synchronize_set"), "ilQuestionSetPoolSetsGUI.synchronize", "", true); + } } - } - else - { - if(!strlen($_SESSION['failure']) && !count($values['failure'])) + else { - ilUtil::sendInfo($this->plugin->txt("not_in_test")); + if(!strlen($_SESSION['failure']) && !count($values['failure'])) + { + ilUtil::sendInfo($this->plugin->txt("not_in_test")); + } } } } diff --git a/classes/controllers/abstract.ilXTSFControllerTableGUI.php b/classes/controllers/abstract.ilXTSFControllerTableGUI.php index bbfab7995fb52e453e005578d8d58850168f75de..8f2d6210a660fad68024a1abdd0cd32195b71b72 100644 --- a/classes/controllers/abstract.ilXTSFControllerTableGUI.php +++ b/classes/controllers/abstract.ilXTSFControllerTableGUI.php @@ -19,6 +19,6 @@ abstract class ilXTSFControllerTableGUI extends ilXTSFControllerGUI */ protected function dataSelected($key) { - return (isset($_POST[$key]) && count($_POST[$key]) > 0); + return (isset($_POST[$key]) && is_array($_POST[$key]) && count($_POST[$key]) > 0); } } diff --git a/classes/controllers/class.ilFormATestSetsGUI.php b/classes/controllers/class.ilFormATestSetsGUI.php index f42019ebb718290674aff390da88d41e071d4082..53ca772f67220dc16f683a0d458d9dfb0e43cb16 100644 --- a/classes/controllers/class.ilFormATestSetsGUI.php +++ b/classes/controllers/class.ilFormATestSetsGUI.php @@ -68,7 +68,7 @@ class ilFormATestSetsGUI extends ilXTSFControllerTableGUI { ilUtil::sendInfo($this->plugin->txt("no_access_to_sets"), true); } - elseif(count($data) == 0) + elseif(is_array($data) && count($data) == 0) { ilUtil::sendInfo($this->plugin->txt("no_sets_existing"), true); } @@ -165,12 +165,14 @@ class ilFormATestSetsGUI extends ilXTSFControllerTableGUI return $a["sorting"] - $b["sorting"]; }); - for($i = 0; $i < count($data); $i++) + if(is_array($data)) { - $data[$i]["sorting"] = ($i + 1)* 10; - $this->controller->object->getSetList()->update($data[$i]); + for($i = 0; $i < count($data); $i++) + { + $data[$i]["sorting"] = ($i + 1) * 10; + $this->controller->object->getSetList()->update($data[$i]); + } } - return $data; } diff --git a/classes/models/class.ilFormATestParticipantsList.php b/classes/models/class.ilFormATestParticipantsList.php index 58727a18fece9de9804ba4a9781e13076ba858b7..9a1eb809194a06ce8eab76c2bb4e1871055cfc4d 100644 --- a/classes/models/class.ilFormATestParticipantsList.php +++ b/classes/models/class.ilFormATestParticipantsList.php @@ -48,6 +48,7 @@ class ilFormATestParticipantsList extends ilXTSFModelList */ public function hasParticipants() { + if(is_array($this->getData())) return count($this->getData()) > 0; } diff --git a/classes/models/class.ilFormATestQuestionSetPoolSetList.php b/classes/models/class.ilFormATestQuestionSetPoolSetList.php index 54994e6e5ce36543cace2b63cb1105366fb37524..7e1af74794989fd02af3b3c8d08d5e23f3746b26 100644 --- a/classes/models/class.ilFormATestQuestionSetPoolSetList.php +++ b/classes/models/class.ilFormATestQuestionSetPoolSetList.php @@ -22,7 +22,7 @@ class ilFormATestQuestionSetPoolSetList extends ilXTSFModelList $available_pools = array_keys(ilObjQuestionSetPool::getAvailableQuestionSetPools()); - if(count($available_pools) == 0) + if(is_array($available_pools) && count($available_pools) == 0) { return null; } diff --git a/classes/models/class.ilFormATestSession.php b/classes/models/class.ilFormATestSession.php index 02778f1473612837800cd8e0a469d10594361153..afdbd9f82fae73d43383de61a9bdb06e3ffbfadc 100644 --- a/classes/models/class.ilFormATestSession.php +++ b/classes/models/class.ilFormATestSession.php @@ -139,7 +139,12 @@ class ilFormATestSession */ public function hasNextSet() { - return array_search($this->current_position, $this->sets) < count($this->sets) - 1; + if(is_array($this->sets)) + { + $set_count = count($this->sets); + } + + return array_search($this->current_position, $this->sets) < $set_count - 1; } /** @@ -558,7 +563,7 @@ class ilFormATestSession public function stepHasSolution($node) { $result = $node->getQuestion()->getUserQuestionResult($this->active_id, $this->pass); - +if(is_array($result->getSolutions())) return count($result->getSolutions()) > 0; } @@ -569,6 +574,7 @@ class ilFormATestSession */ public function hasStepsToDelete($node) { + if(is_array($this->getStepsToDelete($node))) return count($this->getStepsToDelete($node)) > 0; } diff --git a/classes/tables/class.ilFormATestResultsTableGUI.php b/classes/tables/class.ilFormATestResultsTableGUI.php index 3471c5d4936b95bdc264fd0eb6789aea1d96035c..cb3a99c460d0975aa865899e2ec9e127f5f3c409 100644 --- a/classes/tables/class.ilFormATestResultsTableGUI.php +++ b/classes/tables/class.ilFormATestResultsTableGUI.php @@ -80,6 +80,7 @@ class ilFormATestResultsTableGUI extends ilXTSFTableGUI { parent::prepareData($data); + if(is_array($data)) $data[\count($data)-1]["scored"] = "⊗"; } diff --git a/classes/utils/abstract.ilFormATestUtil.php b/classes/utils/abstract.ilFormATestUtil.php index c2f2be346595b065290d777f3df2b2c1c8ffe5fe..76df49b1fbe5d0b42b5c78816afccf8510317274 100644 --- a/classes/utils/abstract.ilFormATestUtil.php +++ b/classes/utils/abstract.ilFormATestUtil.php @@ -52,16 +52,19 @@ abstract class ilFormATestUtil { protected static function hasInfos() { + if(is_array($_SESSION[self::$INFO_KEY])) return count($_SESSION[self::$INFO_KEY]) > 0; } protected static function hasSuccess() { + if(is_array($_SESSION[self::$SUCCESS_KEY])) return count($_SESSION[self::$SUCCESS_KEY]) > 0; } protected static function hasErorrs() { + if(is_array($_SESSION[self::$ERROR_KEY])) return count($_SESSION[self::$ERROR_KEY]) > 0; } @@ -72,7 +75,7 @@ abstract class ilFormATestUtil { protected static function prepare($key) { - if(count($_SESSION[$key]) == 1) + if(is_array($_SESSION[$key]) && count($_SESSION[$key]) == 1) { return current($_SESSION[$key]); } diff --git a/classes/utils/class.ilFormATestAccordionGUI.php b/classes/utils/class.ilFormATestAccordionGUI.php index 2ca56a71a6f1e3c84639a7a0425b9542988f7e0e..26e03f5e255a8fc591684e541a6c64e6db145eb2 100644 --- a/classes/utils/class.ilFormATestAccordionGUI.php +++ b/classes/utils/class.ilFormATestAccordionGUI.php @@ -264,9 +264,9 @@ class ilFormATestAccordionGUI $this->items[] = array("header" => $a_header, "content" => $a_content); - if($a_force_open) + if($a_force_open && is_array($this->items)) { - $this->force_open = sizeof($this->items); + $this->force_open = count($this->items); } } diff --git a/classes/utils/class.ilFormATestInfoScreenGUI.php b/classes/utils/class.ilFormATestInfoScreenGUI.php index 98ce17c88e4b80dc9f1f4eec4216b13e93bcbe2e..6ed5f888a30911c7a176c465c16097e07fab5b2b 100644 --- a/classes/utils/class.ilFormATestInfoScreenGUI.php +++ b/classes/utils/class.ilFormATestInfoScreenGUI.php @@ -61,7 +61,7 @@ class ilFormATestInfoScreenGUI extends ilInfoScreenGUI { } } // add top buttons - if (count($this->top_buttons) > 0) + if (is_array($this->top_buttons) && count($this->top_buttons) > 0) { $tpl->addBlockfile("TOP_BUTTONS", "top_buttons", "tpl.buttons.html"); @@ -81,7 +81,7 @@ class ilFormATestInfoScreenGUI extends ilInfoScreenGUI { } // add top formbuttons - if ((count($this->top_formbuttons) > 0) && (strlen($this->form_action) > 0)) + if ((is_array($this->top_formbuttons) && count($this->top_formbuttons) > 0) && (strlen($this->form_action) > 0)) { $tpl->addBlockfile("TOP_FORMBUTTONS", "top_submitbuttons", "tpl.submitbuttons.html", "Services/InfoScreen"); @@ -111,7 +111,7 @@ class ilFormATestInfoScreenGUI extends ilInfoScreenGUI { } } - if (count($this->hiddenelements)) + if (is_array($this->hiddenelements) && count($this->hiddenelements)) { foreach ($this->hiddenelements as $hidden) { diff --git a/plugin.php b/plugin.php index 4b604735f080f20478a4ea7bc036756303612b5c..4f3d6fa07e0100a16fb4e6ffc4972e2c254aed25 100644 --- a/plugin.php +++ b/plugin.php @@ -3,12 +3,12 @@ $id = 'xtsf'; // code version; must be changed for all code changes -$version = '5.0.2'; +$version = '6.0.0'; // ilias min and max version; must always reflect the versions that should // run with the plugin $ilias_min_version = '5.3.0'; -$ilias_max_version = '5.3.999'; +$ilias_max_version = '5.4.999'; // optional, but useful: Add one or more responsible persons and a contact email $responsible = 'Thomas Joussen / Michael Jansen';