@@ -78,16 +78,16 @@ public function definition() {
7878 ORDER BY c.parent, c.sortorder, c.name ASC " ,
7979 []
8080 );
81-
82- // Build hierarchical options array
81+
82+ // Build hierarchical options array.
8383 $ options = ['' => get_string ('choosedots ' )];
8484 $ categorytree = [];
85-
86- // First pass: organize categories by parent
85+
86+ // First pass: organize categories by parent.
8787 foreach ($ categories as $ category ) {
8888 $ categorytree [$ category ->parent ][] = $ category ;
8989 }
90-
90+
9191 // Second pass: build hierarchical display, starting from the children of the 'top' categories
9292 // to prevent the 'top' categories from appearing in the dropdown.
9393 if (isset ($ categorytree [0 ])) {
@@ -96,7 +96,7 @@ public function definition() {
9696 $ this ->build_category_options ($ categorytree , $ options , $ topcategory ->id , $ context , 0 );
9797 }
9898 }
99-
99+
100100 $ mform ->addElement ('select ' , 'questioncategory ' , get_string ('questioncategory ' , 'quizgame ' ), $ options );
101101 $ mform ->addHelpButton ('questioncategory ' , 'questioncategory ' , 'quizgame ' );
102102 $ mform ->addRule ('questioncategory ' , null , 'required ' , null , 'client ' );
@@ -119,13 +119,13 @@ private function build_category_options($categorytree, &$options, $parentid, $co
119119 if (!isset ($ categorytree [$ parentid ])) {
120120 return ;
121121 }
122-
122+
123123 foreach ($ categorytree [$ parentid ] as $ category ) {
124124 $ indent = str_repeat (' ' , $ level );
125125 $ name = format_string ($ category ->name , true , ['context ' => $ context ]);
126126 $ options [$ category ->id ] = $ indent . $ name ;
127-
128- // Recursively add child categories
127+
128+ // Recursively add child categories.
129129 $ this ->build_category_options ($ categorytree , $ options , $ category ->id , $ context , $ level + 1 );
130130 }
131131 }
0 commit comments