×
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.
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
4 years 9 months ago
1 year 8 months ago by Antonio Durán. Reason: sql fix
Topic Author
[Closed] Search Returns Hidden Courses/Categories/Topics #1
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:
Search courses:
Search categories:
Search topics:
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.
- Courses (Search types: any, exact)
- Categories (Search types: all, any, exact)
- Topics, when they are unhidden but their parent Course/Category is hidden (Search types: all, any, exact)
Search courses:
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:
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:
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.
Please Log in or Create an account to join the conversation.
4 years 9 months ago
[Closed] Search Returns Hidden Courses/Categories/Topics #2
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.
4 years 8 months ago
[Closed] Search Returns Hidden Courses/Categories/Topics #3
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.
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.
4 years 8 months ago
Topic Author
[Closed] Search Returns Hidden Courses/Categories/Topics #4
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
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.
4 years 5 months ago
4 years 5 months ago by ncy.
Topic Author
[Closed] Search Returns Hidden Courses/Categories/Topics #5
I'm testing v1.2.6 and still running into these cases:
auth.php:
- Search for topics still shows results for topics of hidden courses.
- Search for topics still shows results for topics of visible courses in hidden categories.
- Search for courses still shows results for hidden courses.
- Search for courses still shows results for courses in hidden categories.
auth.php:
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']);
}
Please Log in or Create an account to join the conversation.
4 years 5 months ago
[Closed] Search Returns Hidden Courses/Categories/Topics #6
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.