Browse Source

Merge pull request #1328 from jloguercio/1.11.x

Fix skill parent "None" that shows if a root skill already exists - Refs #8370
José Loguercio 8 years ago
parent
commit
461f0c06c2
1 changed files with 12 additions and 1 deletions
  1. 12 1
      main/admin/skill_create.php

+ 12 - 1
main/admin/skill_create.php

@@ -46,7 +46,18 @@ if ($skillParentId > 0) {
 $allSkills = $objSkill->get_all();
 $allGradebooks = $objGradebook->find('all');
 
-$skillList = [0 => get_lang('None')];
+// This procedure is for check if there is already a Skill with no Parent (Root by default)
+
+$isAlreadyRootSkill = false;
+
+foreach ($allSkills as $checkedSkill) {
+    if (intval($checkedSkill['parent_id']) > 0) {
+        $isAlreadyRootSkill = true;
+        break;
+    }
+}
+
+$skillList = $isAlreadyRootSkill ? [] : [0 => get_lang('None')];
 $gradebookList = [];
 
 foreach ($allSkills as $skill) {