course catalogue #3: course categories not selectable as filter
Expected behavior / Resultado esperado / Résultat attendu
View course catalogue on selected course categories
Actual behavior / Resultado real / Résultat réel
Course categories cannot be selected
Steps to reproduce / Pasos para reproducir / Étapes pour reproduire

Here you cannot choose anything else but "all" or "none".
More info: the categories seem to be gone completely but the course_category table still has them. The query
SELECT t1.name, t1.code, t1.parent_id, t1.tree_pos, t1.children_count, COUNT(DISTINCT t3.code) AS nbr_courses FROM course_category t1 INNER JOIN access_url_rel_course_category a ON (t1.id = a.course_category_id) LEFT JOIN course_category t2 ON t1.code = t2.parent_id LEFT JOIN course t3 ON t3.category_code=t1.code WHERE 1 = 1 AND (t1.parent_id IS NULL OR t1.parent_id = '' ) AND a.access_url_id = 1 GROUP BY t1.name, t1.code, t1.parent_id, t1.tree_pos, t1.children_count ORDER BY t1.tree_posArray ( )
from course_category.lib.php does not return any rows because of the (t1.id = a.course_category_id).
[edit;] The access_url_rel_course_category does not have the right rows for the join to return anything. Something went wrong with an update.
When the access_url_rel_course_category table is polulated another strange thing appears: the categories are displayed in the ptalform admin categories page but the number of courses is set to 1 in the php code:
https://github.com/chamilo/chamilo-lms/blame/master/main/inc/lib/course_category.lib.php#L93
lines 93-95
foreach ($categories as &$categoryItem) { $categoryItem['nbr_courses'] = 1;
Why? Remove these lines and the number of courses in the categories are displayed correctly. Or remove the nbr_courses from the query. No use in counting courses in SQL and then setting them all to 1 unless you want to waste CPU cycles.
I fixed the number of sub-categories
Looks good to me now
