Moodle

Students can't search in separate groups forum.

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.8, 1.8.1, 1.8.2, 1.9, 2.0
  • Fix Version/s: 1.8.4, 1.9, 2.0
  • Component/s: Forum, Groups
  • Labels:
    None
  • Database:
    PostgreSQL
  • Affected Branches:
    MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

Description

If there are a sentence in a post of a student that are in a separate group, he can't to find it using the forum search, there are no results. (They are in same group)

The student can't find the same sentence that him wrote.

Activity

Hide
Oksana Yasynska added a comment -

The following fix works for us:

/mod/forum/lib.php

function forum_get_readable_forums($userid, $courseid=0)

line: $forum->accessgroup = $group->id; // The user can only access
// discussions for this group.

should be replaced:

$forum->accessgroup = $group[$course->id]->id; // The user can only access
// discussions for this group.

Cheers,
Oksana

Show
Oksana Yasynska added a comment - The following fix works for us: /mod/forum/lib.php function forum_get_readable_forums($userid, $courseid=0) line: $forum->accessgroup = $group->id; // The user can only access // discussions for this group. should be replaced: $forum->accessgroup = $group[$course->id]->id; // The user can only access // discussions for this group. Cheers, Oksana
Hide
Gustavo Augusto Hennig added a comment -

It's not work for me.

I had to put a code like:

foreach ($group as $grp) {
if (isset($grp->id)) { $forum->accessgroup = $grp->id; break; }
}

It's worked, I think it's working fine now.

Show
Gustavo Augusto Hennig added a comment - It's not work for me. I had to put a code like: foreach ($group as $grp) { if (isset($grp->id)) { $forum->accessgroup = $grp->id; break; } } It's worked, I think it's working fine now.
Hide
Gustavo Augusto Hennig added a comment -

I corrected my last comment, now it's work when a student is in more that one group.

foreach ($group as $grp) {
if (isset($grp->id)) { $forum->accessgroup .= $grp->id. ','; //break; }
}

if(!empty($forum->accessgroup)){ $forum->accessgroup = substr($forum->accessgroup , 0, strlen($forum->accessgroup)-1); }

and in the function:
function forum_search_posts

replace this line
$selectdiscussion .= " AND (d.groupid = {$forums[$i]->accessgroup}";

by
$selectdiscussion .= " AND (d.groupid in ( {$forums[$i]->accessgroup} )";

I think, this resolve the problem because it worked to me.

Can any body confirm it to me?

Show
Gustavo Augusto Hennig added a comment - I corrected my last comment, now it's work when a student is in more that one group. foreach ($group as $grp) { if (isset($grp->id)) { $forum->accessgroup .= $grp->id. ','; //break; } } if(!empty($forum->accessgroup)){ $forum->accessgroup = substr($forum->accessgroup , 0, strlen($forum->accessgroup)-1); } and in the function: function forum_search_posts replace this line $selectdiscussion .= " AND (d.groupid = {$forums[$i]->accessgroup}"; by $selectdiscussion .= " AND (d.groupid in ( {$forums[$i]->accessgroup} )"; I think, this resolve the problem because it worked to me. Can any body confirm it to me?
Hide
Yolanda Ordoñez Rufat added a comment -

We change a bit the Henning's solution for the function forum_get_readable_forums cause the user group within a course is the same for all the forums.

/mod/forum/lib.php

function forum_get_readable_forums($userid, $courseid=0)
after line:
$group = user_group($course->id, $userid);
we add the code:
foreach($group as $grp) {
if (isset($grp->id)) { $groupsid .= $grp->id.','; }
}
$groupsid = substr($groupsid,0,-1);

and change the line:
$forum->accessgroup = $group->id;
by this one:
$forum->accessgroup = $groupsid;

So, like Hennings, in in the function:
function forum_search_posts
we replace this line:
$selectdiscussion .= " AND (d.groupid = {$forums[$i]->accessgroup}";
by
$selectdiscussion .= " AND (d.groupid in ( {$forums[$i]->accessgroup} )";

We test the solution on a 1.7.2 moodle with a 8.2.4 postgres installed in a SUSE Linux Enterprise Server 10 SP1; and a 1.7.2 moodle with a 4.1.22 mysql installed in a SUSE LINUX Enterprise Server 9

Show
Yolanda Ordoñez Rufat added a comment - We change a bit the Henning's solution for the function forum_get_readable_forums cause the user group within a course is the same for all the forums. /mod/forum/lib.php function forum_get_readable_forums($userid, $courseid=0) after line: $group = user_group($course->id, $userid); we add the code: foreach($group as $grp) { if (isset($grp->id)) { $groupsid .= $grp->id.','; } } $groupsid = substr($groupsid,0,-1); and change the line: $forum->accessgroup = $group->id; by this one: $forum->accessgroup = $groupsid; So, like Hennings, in in the function: function forum_search_posts we replace this line: $selectdiscussion .= " AND (d.groupid = {$forums[$i]->accessgroup}"; by $selectdiscussion .= " AND (d.groupid in ( {$forums[$i]->accessgroup} )"; We test the solution on a 1.7.2 moodle with a 8.2.4 postgres installed in a SUSE Linux Enterprise Server 10 SP1; and a 1.7.2 moodle with a 4.1.22 mysql installed in a SUSE LINUX Enterprise Server 9
Hide
Martin Dougiamas added a comment -

One for you, Yu!

Show
Martin Dougiamas added a comment - One for you, Yu!
Hide
Martin Dougiamas added a comment -

This basically needs good testing to make sure it really works for all cases (including non-grouped forums).

I'd also use implode() as a more elegant way to build that list of ids.

Show
Martin Dougiamas added a comment - This basically needs good testing to make sure it really works for all cases (including non-grouped forums). I'd also use implode() as a more elegant way to build that list of ids.
Hide
Yu Zhang added a comment -

slightly modified patch in CVS, please test. Thanks for the report and patch.

Show
Yu Zhang added a comment - slightly modified patch in CVS, please test. Thanks for the report and patch.

People

Dates

  • Created:
    Updated:
    Resolved: