chamilo-lms icon indicating copy to clipboard operation
chamilo-lms copied to clipboard

course catalogue #3: course categories not selectable as filter

Open jderriks opened this issue 10 years ago • 4 comments

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

chamilo-catelog-categories

Here you cannot choose anything else but "all" or "none".

jderriks avatar Dec 01 '16 23:12 jderriks

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.

jderriks avatar Dec 23 '16 10:12 jderriks

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.

jderriks avatar Dec 23 '16 12:12 jderriks

I fixed the number of sub-categories

AngelFQC avatar Mar 10 '17 22:03 AngelFQC

Looks good to me now cata

ywarnier avatar Mar 22 '17 18:03 ywarnier