- Posts: 18
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 Topics Plugin - Doesn't Search Name
- ncy
- Topic Author
- Offline
- New Member
-
Less
More
6 years 10 months ago - 6 years 5 months ago #1
by ncy
[Closed] Search Topics Plugin - Doesn't Search Name was created by ncy
Maybe I'm missing the reasoning, but why does Search Topics only search the summary text? Shouldn't it also search the name? To be more clear, I mean adding these lines in /auth/joomdle/auth.php for the search_topics() function:
Would then need to add to /auth/joomdle/helpers/externallib.php:
And replace 'summary' with 'sec_name' in /plugins/search/coursetopics/coursetopics.php:
Code:
@@ -3563,6 +3563,9 @@
$text = '%'.$text.'%';
$likes = array ();
+ $like = $DB->sql_like('cs.name', '?', false);
+ $likes[] = $like;
+ $params[] = $text;
$like = $DB->sql_like('cs.summary', '?', false);
$likes[] = $like;
$params[] = $text;
@@ -3580,6 +3583,9 @@
$likes = array ();
+ $like = $DB->sql_like('cs.name', '?', false);
+ $likes[] = $like;
+ $params[] = $word;
$like = $DB->sql_like('cs.summary', '?', false);
$likes[] = $like;
$params[] = $word;
@@ -3614,6 +3620,7 @@
$query = "SELECT cs.id,
co.id AS remoteid,
co.fullname,
+ cs.name AS sec_name,
cs.course,
cs.section,
cs.summary,
@@ -3640,6 +3647,15 @@
$c['fullname'] = format_string($c['fullname']);
$c['summary'] = format_text($c['summary'], FORMAT_MOODLE, $options);
$c['cat_name'] = format_string($c['cat_name']);
+
+ // Use Course Name if course topic title is blank
+ if (empty($c['sec_name'])) {
+ $c['sec_name'] = format_string($c['fullname']);
+ }
+ else {
+ $c['sec_name'] = format_string($c['sec_name']);
+ }
+
$data[] = $c;
}
Would then need to add to /auth/joomdle/helpers/externallib.php:
Code:
public static function search_topics_returns() {
return new external_multiple_structure(
new external_single_structure(
array(
'remoteid' => new external_value(PARAM_INT, 'course id'),
'fullname' => new external_value(PARAM_TEXT, 'course name'),
'course' => new external_value(PARAM_TEXT, 'course name'),
'section' => new external_value(PARAM_TEXT, 'course name'),
'summary' => new external_value(PARAM_RAW, 'summary'),
'cat_id' => new external_value(PARAM_INT, 'category id'),
'cat_name' => new external_value(PARAM_TEXT, 'category name'),
+ 'sec_name' => new external_value(PARAM_TEXT, 'section name'),
)
)
);
}
And replace 'summary' with 'sec_name' in /plugins/search/coursetopics/coursetopics.php:
Code:
- $rows_result[$i]->title= substr (strip_tags ($row['summary']), 0, 50);
+ $rows_result[$i]->title= $row['sec_name'];
Last edit: 6 years 5 months ago by Antonio Durán.
Please Log in or Create an account to join the conversation.
- Antonio Durán
-
- Offline
- Moderator
-
Less
More
- Posts: 7909
6 years 10 months ago #2
by Antonio Durán
Replied by Antonio Durán on topic Search Topics Plugin - Doesn't Search Name
Hi.
Thanks for the suggestion and the code, I will check it and see if we can add your mods to Joomdle.
> Maybe I'm missing the reasoning, but why does Search Topics only search the summary text? Shouldn't it also search the name?
Yes. I checked, and the reason for this is that in Moodle 1.9 (when Joomdle started) there was no name field in couse_sections table. We didn't notice the new field, and nobody asked about it until you did
Thanks for the suggestion and the code, I will check it and see if we can add your mods to Joomdle.
> Maybe I'm missing the reasoning, but why does Search Topics only search the summary text? Shouldn't it also search the name?
Yes. I checked, and the reason for this is that in Moodle 1.9 (when Joomdle started) there was no name field in couse_sections table. We didn't notice the new field, and nobody asked about it until you did
Please Log in or Create an account to join the conversation.