Moodle

eWiki Uses non-API Method for Dealing with Separate Groups

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: 1.9, 1.9.1
  • Fix Version/s: None
  • Component/s: Groups, Wiki (1.x)
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE

Description

Whereas all other "separate groups"-compatible modules use groups_print_activity_menu() and groups_get_activity_group() (inc. assignment, chat, choice, data, forum, quiz, survey and workshop), the wiki module uses a very different, seemingly-deprecated method.

Here's the way the forum module determines separate groups (mod/forum/view.php):
79 groups_print_activity_menu($cm, 'view.php?id=' . $cm->id);
80 $currentgroup = groups_get_activity_group($cm);
81 $groupmode = groups_get_activity_groupmode($cm);

The data module uses a similar method (mod/data/view.php):
245 groups_print_activity_menu($cm, $returnurl);
246 $currentgroup = groups_get_activity_group($cm);
247 $groupmode = groups_get_activity_groupmode($cm);

Now, let's take a look at the wiki's method (mod/wiki/lib.php):
402 $groupmode = groups_get_activity_groupmode($wiki);
403 // if groups mode is in use and no group supplied, use the first one found
404 if ($groupmode && !$groupid) {
405 if(($mygroupids=mygroupid($course->id)) && count($mygroupids)>0) { 406 // Use first group. They ought to be able to change later 407 $groupid=$mygroupids[0]; 408 } else {
409 // Whatever groups are in the course, pick one
410 $coursegroups = groups_get_all_groups($course->id);
411 if(!$coursegroups || count($coursegroups)==0) { 412 error("Can't access wiki in group mode when no groups are configured for the course"); 413 }
414 $unkeyed=array_values($coursegroups); // Make sure first item is index 0
415 $groupid=$unkeyed[0]->id;
416 }
417 }

This is definitely not the right way to go! The function mygroupid(), which fuels the selection of a group for the wiki, is now located in lib/deprerecatedlib.php, which definitely seems incorrect. It also operates without taking into account groupings or anything of that sort. A consequence of this is that we don't even get a call to groups_print_activity_menu(), so we don't even get the API method for changing groups. We can switch groups by adding &groupid= to the URI, so the standard API function should be fairly easily implementable.

Activity

Hide
Eric Bollens added a comment -

Here's a really solid example of the non-API method employed by the wiki mod:

405 if(($mygroupids=mygroupid($course->id)) && count($mygroupids)>0) { 406 // Use first group. They ought to be able to change later 407 $groupid=$mygroupids[0]; 408 } else {
409 // Whatever groups are in the course, pick one
410 $coursegroups = groups_get_all_groups($course->id);
411 if(!$coursegroups || count($coursegroups)==0) { 412 error("Can't access wiki in group mode when no groups are configured for the course"); 413 }
414 $unkeyed=array_values($coursegroups); // Make sure first item is index 0
415 $groupid=$unkeyed[0]->id;
416 }

In the other modules, this whole process is accomplished through groups_get_activity_group()

Show
Eric Bollens added a comment - Here's a really solid example of the non-API method employed by the wiki mod: 405 if(($mygroupids=mygroupid($course->id)) && count($mygroupids)>0) { 406 // Use first group. They ought to be able to change later 407 $groupid=$mygroupids[0]; 408 } else { 409 // Whatever groups are in the course, pick one 410 $coursegroups = groups_get_all_groups($course->id); 411 if(!$coursegroups || count($coursegroups)==0) { 412 error("Can't access wiki in group mode when no groups are configured for the course"); 413 } 414 $unkeyed=array_values($coursegroups); // Make sure first item is index 0 415 $groupid=$unkeyed[0]->id; 416 } In the other modules, this whole process is accomplished through groups_get_activity_group()
Hide
Petr Škoda (skodak) added a comment -

Hopefully the new wiki in 2.0 will not have similar problems, thank you for the report.

Petr Skoda

Show
Petr Škoda (skodak) added a comment - Hopefully the new wiki in 2.0 will not have similar problems, thank you for the report. Petr Skoda

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: