Feature Requests

Please do NOT use this section of the forum to request help if Joomdle does not work for you in some particular way. Your post will be deleted.

[Closed] Search Returns Hidden Courses/Categories/Topics

More
7 years 1 month ago - 4 years 2 weeks ago #1 by ncy
When courses/categories/topics are hidden in Moodle, they should not come up in Joomdle search results. Currently, this is what shows when they shouldn't:
  1. Courses (Search types: any, exact)
  2. Categories (Search types: all, any, exact)
  3. Topics, when they are unhidden but their parent Course/Category is hidden (Search types: all, any, exact)
Some adjustments are needed in /auth/joomdle/auth.php.

Search courses:
Code:
public function search_courses ($text, $phrase, $ordering, $limit) { ... default: ... break; } + $where = '(' . $where . ') AND ca.visible = 1 AND co.visible = 1'; // The check for co.visible is also in the SQL query, so either here or there. Main change is adding parentheses.

Search categories:
Code:
public function search_categories ($text, $phrase, $ordering, $limit) { ... default: ... break; } + $where = '(' . $where . ') AND ca.visible = 1'; // The check for ca.visible is not in SQL query

Search topics:
Code:
public function search_topics ($text, $phrase, $ordering, $limit = 50) { ... default: ... break; } - $where .= " and cs.visible = 1"; + $where = '(' . $where . ') AND cs.visible = 1 AND co.visible = 1'; // Need parentheses, and the check for cs.visible and co.visible is not in SQL query

Side note, while testing I discovered that searching for the word "topic" will ignore course sections that do not have a custom title set, even though they are automatically labeled as "Topic X" by Moodle. I guess that's because technically those titles are blank.
Last edit: 4 years 2 weeks ago by Antonio Durán. Reason: sql fix

Please Log in or Create an account to join the conversation.

More
7 years 1 month ago #2 by Antonio Durán
Replied by Antonio Durán on topic Search Returns Hidden Courses/Categories/Topics
Thanks for the info. We'll look into adding the changes for next release.

Please Log in or Create an account to join the conversation.

More
7 years 2 weeks ago #3 by Antonio Durán
Replied by Antonio Durán on topic Search Returns Hidden Courses/Categories/Topics
Hi.

Just wanted to tell you that I incorporated your changes for next release.

As for searching for "topic X", I don't think it is worth it to return results for that, as it would be a kludge.

Please Log in or Create an account to join the conversation.

More
7 years 2 weeks ago #4 by ncy
Cool, glad that I could help.

Yea, I was looking at the "topic X" thing too and decided I would just point it out and let you decide :)

Please Log in or Create an account to join the conversation.

More
6 years 9 months ago - 6 years 9 months ago #5 by ncy
I'm testing v1.2.6 and still running into these cases:
  1. Search for topics still shows results for topics of hidden courses.
  2. Search for topics still shows results for topics of visible courses in hidden categories.
  3. Search for courses still shows results for hidden courses.
  4. Search for courses still shows results for courses in hidden categories.
The changes to fix are still what I described above (noted again below, with some other code fixes I noticed).

auth.php:
Code:
public function search_courses ( ... ) { ... $where = '(' . $where . ') AND ca.visible = 1 AND co.visible = 1'; // ***Add parens and ANDs*** switch ( $ordering ) { ... } public function search_topics ( ... ) { ... $params[] = $word; // ***This should be $word, not $text since it's not an Exact Phrase search*** $where2 = '(' . implode( ') OR (', $likes ) . ')'; $wheres2[] = $where2; } $where = '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wheres2 ) . ')'; break; } $where = '(' . $where . ') AND cs.visible = 1 AND co.visible = 1'; // ***Add parens and ANDs*** ... $query = "SELECT cs.id, cs.name as sec_name, // ***Add "as sec_name" otherwise section name doesn't show*** co.id AS remoteid, co.fullname, cs.course, //cs.section, // ***Remove duplicate cs.section*** cs.summary, ca.id as cat_id, ca.name as cat_name, cs.section ... if ($c['sec_name']) // ***Use "sec_name" instead of "name" otherwise section name doesn't show*** $c['sec_name'] = format_string($c['sec_name']); }

Last edit: 6 years 9 months ago by ncy.

Please Log in or Create an account to join the conversation.

More
6 years 9 months ago #6 by Antonio Durán
Replied by Antonio Durán on topic Search Returns Hidden Courses/Categories/Topics
Thank you for the detailed report. I will check it and make the changes.

Please Log in or Create an account to join the conversation.