From 60443a890ca5a2267d32aa2007af40b5512430b1 Mon Sep 17 00:00:00 2001 From: nmatuschek Date: Thu, 7 Mar 2019 09:44:55 +0100 Subject: [PATCH 1/2] PHP 7.2 compatibility --- classes/class.ilFormATestExporter.php | 2 +- classes/class.ilFormATestImporter.php | 2 +- classes/class.ilFormATestXmlValidator.php | 4 +-- classes/class.ilObjFormATest.php | 5 ++-- classes/class.ilObjFormATestGUI.php | 4 +-- ...class.ilObjFormATestQuestionSetPoolGUI.php | 27 ++++++++++--------- .../abstract.ilXTSFControllerTableGUI.php | 2 +- .../controllers/class.ilFormATestSetsGUI.php | 12 +++++---- .../class.ilFormATestParticipantsList.php | 1 + ...lass.ilFormATestQuestionSetPoolSetList.php | 2 +- classes/models/class.ilFormATestSession.php | 10 +++++-- .../class.ilFormATestResultsTableGUI.php | 1 + classes/utils/abstract.ilFormATestUtil.php | 5 +++- .../utils/class.ilFormATestAccordionGUI.php | 4 +-- .../utils/class.ilFormATestInfoScreenGUI.php | 6 ++--- plugin.php | 4 +-- 16 files changed, 54 insertions(+), 37 deletions(-) diff --git a/classes/class.ilFormATestExporter.php b/classes/class.ilFormATestExporter.php index 9e7588a..aee500e 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 4c3e1db..4f85b95 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 029ac28..1abe6db 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 544ad27..f5e2324 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 30640bc..c120bc5 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 746391d..d45e425 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 bbfab79..8f2d621 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 f42019e..53ca772 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 58727a1..9a1eb80 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 54994e6..7e1af74 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 02778f1..afdbd9f 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 3471c5d..cb3a99c 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 c2f2be3..76df49b 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 2ca56a7..26e03f5 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 98ce17c..6ed5f88 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 4b60473..4f3d6fa 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'; -- GitLab From 2257cbbb3b17dc7fdc2ebc5a93386dc6a630d17d Mon Sep 17 00:00:00 2001 From: nmatuschek Date: Mon, 11 Mar 2019 09:10:29 +0100 Subject: [PATCH 2/2] Changed plugin version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4415220..d0463d6 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 -- GitLab