Issue Details (XML | Word | Printable)

Key: MDL-9059
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Yu Zhang
Reporter: Julian Ridden
Votes: 15
Watchers: 20
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

When teacher creates Group event on calendar, they cannot see it

Created: 27/Mar/07 07:18 AM   Updated: 04/Nov/08 01:52 PM
Return to search
Component/s: Calendar
Affects Version/s: 1.8, 1.8.1, 1.8.2, 1.9
Fix Version/s: 1.6.6, 1.7.4, 1.8.4, 1.9

File Attachments: 1. Text File basicgrouplib.php.patch (0.8 kB)
2. Text File calendar-lib.php.patch (0.8 kB)
3. File calendar-lib.php.patch.20070628 (0.8 kB)

Image Attachments:

1. test_moodle_com_calendar_error.png
(233 kB)
Issue Links:
Duplicate
 
Relates
 

Database: MySQL
URL: http://quantum.riverview.nsw.edu.au
Participants: A. T. Wyatt, Ann Adamcik, Borka Khan, Daniel Miksik, Elena Ivanova, Isaac Marco Blancas, Juan Segarra Montesinos, Julian Ridden, Kenneth Newquist, Martin Dougiamas, Motoyuki OHMORI, Nicolas Martignoni, Roger Emery, Wen Hao Chuang and Yu Zhang
Security Level: None
QA Assignee: Nicolas Martignoni
Affected Branches: MOODLE_18_STABLE, MOODLE_19_STABLE
Fixed Branches: MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE


 Description  « Hide
When a teacher creates a group event and assigns it to a course group, it does not appear to studets or teachers.

At the Admin level however the event is visible.

The event also has no course information displayed. My understanding is that even though it is a group event, it should still display the course name in wich it was created.

Either way, without teacher or student being able to see the created event, the point is moot :)

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Isaac Marco Blancas added a comment - 19/May/07 05:46 PM - edited
Very similar here.

-Students doesn't see their group events.
-Teachers can see all the events (only if the teacher is not in the group). I think they should see their groups events.


Motoyuki OHMORI added a comment - 15/Jun/07 07:00 PM - edited
I met same problems. Teachers can always all events in a course because they have a right to do that by deafult setting.

After having look at code, there seems to be typo in the routine,
groups_get_all_groups_for_user(), defined in group/lib/basicgrouplib.php.

I attached the patch for this issue even though I am not sure if this is right way or not (at least, the code seems to be different from what comment of routine says).


Motoyuki OHMORI made changes - 15/Jun/07 07:00 PM
Field Original Value New Value
Attachment basicgrouplib.php.patch [ 11411 ]
Kenneth Newquist added a comment - 22/Jun/07 02:25 AM
We're running Moodle 1.8.1 (2007021510).

I'm seeing a similar issue: when a teacher creates an event for a group, it does not show up in the calendar. No one can see it – not teachers, not students and not even admins. Looking in the database, I can see my events in mdl_events and they do have a groupid associated with them.


Kenneth Newquist added a comment - 22/Jun/07 10:58 PM
I tried the patch, but it had no effect on this problem.

A. T. Wyatt added a comment - 23/Jun/07 06:08 AM
Moodle 1.8.1 (2007021510) WIMP server, XP IIS 6, PHP Version 5.1.2, mysql 4.1.22

Course created, teacher assigned, student assigned, group created and student placed in group.

I login as admin, I add a group event in a course.

  • As admin, I cannot see group event.
  • As admin, switching to role "teacher", I CAN see group event.
  • As admin, switching to role "student", I cannot see group event.
  • As teacher, I can see the group event that admin added to the course.

I login as teacher, I add a group event in a course.

  • As teacher, I can see group event
  • As teacher, switching to role "non-editing teacher", I can see the group event
  • As teacher, switching to role "student", I cannot see the group event

I login as student, I cannot see the group event.


Motoyuki OHMORI added a comment - 23/Jun/07 02:56 PM
Hi, Kenneth,

> I tried the patch, but it had no effect on this problem.

Could you let me know the version written in version.php?

I am afraid that your moodle code does not include the fix which should be applied before applying my patch.


Ann Adamcik added a comment - 24/Jun/07 12:19 AM
Version 1.8.1+ (2007021510), Solaris 10/sparc, CoolStack 1.1 (Apache 2.2.3, mySql 5.0.33, PHP 5.2.0)

I upgraded to 1.8.1_STABLE yesterday and tried this patch. Here's what I'm seeing:

  • Login as a teacher or admin
  • Add a group event
  • The event is visible to students in the group.
  • The event is not visible to the teacher or admin.

Ann Adamcik added a comment - 24/Jun/07 01:01 AM
After a bit more testing -

Admins do see the group events if the calendar setting 'Admins See All' is checked (Administration->Appearance->Calendar).

I have a test user who is a Course Creator in Course A, and a Teacher in Course B.

  • Logged in as the test user, I created a group event in Course A.
  • From within Course A, I hover over the date and do not see the event.
  • I click on the date to bring up the day view for Course A and do not see the event
  • I select All courses from the day view drop-down, and the group event created in Course A appears.
  • From the front page, or from Course B, I hover over the date and the group event created in Course A appears.
  • Group events created by the teacher in Course B are not visible to this user anywhere.

Motoyuki OHMORI added a comment - 24/Jun/07 01:50 AM
I noticed that I missed the anothre patch I made before. I attached the patch for calendar/lib.php (1.8+ today) and it would fix the problem that teachers cannot see events.

Motoyuki OHMORI made changes - 24/Jun/07 01:50 AM
Attachment calendar-lib.php.patch [ 11449 ]
Kenneth Newquist added a comment - 26/Jun/07 04:29 AM
Motoyuki – I'm at Groups version 2007012400. Do I need to get a more current version from CVS?

A. T. Wyatt added a comment - 27/Jun/07 10:27 PM - edited
Further testing: I set up a course, 2 groups, 1 student in each group, 1 group event for each group in calendar. Teacher is not a member of either group.

It doesn't seem to matter how I set up the course. I get the same results for each possible setting: course settings with no group mode set, no force but separate, no force but visible, forced separate, forced visible.

Teacher sees both events, student 1 sees no events, student 2 sees no events, admin does not see shading on calendar or link in upcoming events, but DOES see the events if clicking on the calendar link to go to the daily view.

I actually logged out and in as each role to verify (no switching).

That bit about what the admin can see is a little different. Did anyone else actually click on the "go to calendar" link to verify events displayed there?

I am using default role definitions.


Kenneth Newquist added a comment - 27/Jun/07 11:29 PM
When I don't have "Admins See All" enabled, then I can see all events in the calendar. Otherwise I can see nothing.

I'm at Groups version 2007012400 running Moodle 1.8.1 (2007021510). If it matters, this site was created using Moodle 1.7.0 and our upgrade path was Moodle 1.7.0->Moodle 1.7.1->Moodle 1.8.0->Moodle 1.8.1.

Here's the results of my most recent run through:

Create a new course with group mode set to "separate".

Login as faculty test account to new course.

Create Group A, which consists of Joe
Create Group B, which consists of Jill

Assign Joe to Group A
Assign Jill to Group B.

Create an event for Group A taking place on 6/29 with no duration.
Create an event for Group B taking place on 6/30 with no duration.

Teacher can not see either event.

Login as Joe. Joe can see Group A event created by the teacher.
Login as Jill. Jill can see Group B events create by the teacher.

Login as site admin. Admin can not see any group events.
Login as myself (also with admin rights). Still can't see any group events.
Create an event for Group A, also on June 30 in my admin role. I can't see the event.

Login as Joe. Joe can see the event.

Login as Teacher. Teacher can't see the event; downshifting to the non-editing teacher or student roles doesn't show the events. If I change the group type to "visible" and try downshifting to student again, I still can't see the events.


Motoyuki OHMORI added a comment - 28/Jun/07 02:31 AM
Hi, Kenneth,

Your code seems not to be old and enough new. The bug might be brought into newer code that you use. I try newest code (I do not actually use the newest code now).


Motoyuki OHMORI added a comment - 28/Jun/07 04:00 AM
I tried on today's 1.8+.

After applying my two patches, group events are visible to members of students and teachers.

BTW, if and only if 'group mode' is set to 'no' and 'force' is set to 'no', students and teachers cannot see event according to the code. I am not sure the reason though.

In adittion, when 'adminseesall' is checked, admin can see all group events even in upcomming event in my environment (today's 1.8+). Speaking of editing the event, admin seems to be able to edit all events anytime according to the code.


Kenneth Newquist added a comment - 28/Jun/07 04:14 AM
I figured out the problem, or at least my problem as it applies to teachers. Motoyuki's "calendar-lib.php.patch" points the way. The problem file is htdocs/calendar/lib.php.

See this query?

$sql = "SELECT id, groupid FROM {$CFG->prefix}groups_courses_groups WHERE courseid IN (".implode(',', $groupids).')';

This produces something like this:

SELECT id, groupid FROM mdl_groups_courses_groups WHERE courseid IN (740);

Which returns results that look like this:

-----------+

id groupid

-----------+

51 54
52 55

-----------+

The 'id' here refers to the primary key for the "mdl_groups_courses_groups" table; the groupid is the primary key for the "mdl_groups" table

Now if you look for this code from the calendar-lib.php.patch, around line 1196, you'll see the problem.

foreach ($grouprecords as $grouprecord) {
array_push($grouparray, $grouprecord->id);
}

$grouprecord->id is referring to the primary key of the "mdl_groups_courses_groups" table NOT the actual id of the group, which is what's in the second column of the data returned.

If we change "$grouprecord->id" to "$grouprecord->groupid", then we pull the right value from the data that was returned.

This allows faculty to see the groups available in their courses. When I made this change, the events were displayed correctly on the courses page and on the calendar page.

The original code has the same problem, but in a different way:

$grouparray = array_merge($grouparray, array_keys($grouprecords))

This takes the keys of the array returned from the initial query, which are the same as the keys for the table "mdl_groups_courses_groups", but NOT the same as the actual groupid numbers in "mdl_groups".


Motoyuki OHMORI added a comment - 28/Jun/07 06:27 AM
Hi, Kenneth,

You are right and sorry the patch file was different from my own patch file in my PC...
my calendar-lib.php.patch is wrong and I attached correct one to this.

BTW, I write down what I notice:

  • basicgrouplib.php.patch works well for a little bit old 1.8+ (even though the patch seems to still fix group bug of current 1.8+).
  • calendar-lib.php.patch-20070628 works well for current 1.8+ (2007/06/17 or later maybe)

Sorry for my confusing you.


Motoyuki OHMORI made changes - 28/Jun/07 06:27 AM
Attachment calendar-lib.php.patch.20070628 [ 11475 ]
Kenneth Newquist added a comment - 28/Jun/07 11:18 PM
Excellent, thanks. What do we need to do to get this into Moodle core for the 1.8.2 update?

Motoyuki OHMORI added a comment - 29/Jun/07 12:19 AM
Maybe we need to request it to the assignee or other people who are core member of Moodle.

Borka Khan added a comment - 05/Jul/07 09:48 PM
Thanks for all your work guys... nonetheless, when I tried manually changing files in my 1.8+ installation, it did not resolve the issue. Any idea when is this fix going to be included in the daily built? We are just starting to use Moodle in our university, and it really did not look good when one of our most valued profs pointed this problem out and we still haven't been able to resolve the issue after more than a week

Elena Ivanova added a comment - 20/Jul/07 01:50 AM - edited
(updating, since I've made a mistake in the report)

Admin:
Role Capabilities: Manage Own and Manage Any calendar entries are set to Allow.

  • Can add User event fine
  • Can try to add"Course event, but it will not show up on the calendar
  • Can add Site event fine

Teacher:
Role Capabilities: Manage Own and Manage Any calendar entries are set to Allow.

  • Can add User event fine
  • Selection for Group events is there, and they can try to add events. But they will not appear on the Calendar.
  • Can add Course event fine

Kenneth Newquist added a comment - 25/Jul/07 01:52 AM
Bori and Elena: which versions of Moodle are you working on? I've only tried this under Moodle 1.8.1, not the newer builds (though I will be trying it under 1.8.2 when I update the development server on Wednesday).

Elena Ivanova added a comment - 25/Jul/07 02:07 AM
ops, 1.8.2 +

Borka Khan added a comment - 27/Jul/07 01:34 AM
1.8.1+ here...

Wen Hao Chuang added a comment - 02/Oct/07 08:10 AM
I just tested this on http://test.moodle.com and on 1.9 it would generate a really bad error message. Please see the screenshot. As Jon is not maintaining the calendar right now and Petr had the most recent commit to /calendar/event.php so maybe Petr could help with this please? Thanks!

Wen Hao Chuang made changes - 02/Oct/07 08:10 AM
Fix Version/s 1.8.3 [ 10230 ]
Affects Version/s 1.9 [ 10190 ]
Fix Version/s 1.9 [ 10190 ]
Assignee Jon Papaioannou [ pj ] Petr Skoda [ skodak ]
Affects Version/s 1.8.2 [ 10220 ]
Affects Version/s 1.8.1 [ 10213 ]
Wen Hao Chuang made changes - 02/Oct/07 08:12 AM
Attachment test_moodle_com_calendar_error.png [ 11951 ]
Wen Hao Chuang made changes - 02/Oct/07 08:15 AM
Fix Version/s 1.7.3 [ 10212 ]
Fix Version/s 1.6.6 [ 10211 ]
Priority Major [ 3 ] Critical [ 2 ]
Nicolas Martignoni made changes - 10/Oct/07 03:17 PM
Link This issue has been marked as being related by MDL-10353 [ MDL-10353 ]
Nicolas Martignoni made changes - 10/Oct/07 03:21 PM
Link This issue is duplicated by MDL-11189 [ MDL-11189 ]
moodler committed 1 file to 'Moodle CVS' - 10/Oct/07 04:18 PM
Just a small fix that would make this SQL work ... no idea what bug it would fix. It's not MDL-9059
MODIFY calendar/lib.php   Rev. 1.206    (+5 -3 lines)
Martin Dougiamas added a comment - 10/Oct/07 04:20 PM
Nicolas, can you get to the bottom of this? I'm pretty sure you need to be looking in calendar_set_filters() in calendar/lib.php ...

Martin Dougiamas made changes - 10/Oct/07 04:20 PM
Assignee Petr Skoda [ skodak ] Nicolas Connault [ nicolasconnault ]
Nicolas Martignoni made changes - 10/Oct/07 04:48 PM
QA Assignee mina
Martin Dougiamas added a comment - 10/Oct/07 05:02 PM
Yu seems to have taken it on.

Martin Dougiamas made changes - 10/Oct/07 05:02 PM
Assignee Nicolas Connault [ nicolasconnault ] Yu Zhang [ lazyfish ]
Nicolas Martignoni added a comment - 10/Oct/07 05:48 PM
Yu, have now tested on 1.8.2+ for creation of group events. It doesn't work: editing teacher can't create group events (whether it belongs to the group or no).

It's reproducible too on original 1.8!

Seems same symptoms like on HEAD before your fix.


Roger Emery added a comment - 10/Oct/07 06:16 PM
Same problem here on

Version 1.8.2+ (2007021520)


Martin Dougiamas made changes - 11/Oct/07 02:41 PM
Fix Version/s 1.8.4 [ 10242 ]
Fix Version/s 1.8.3 [ 10230 ]
Martin Dougiamas made changes - 11/Oct/07 03:23 PM
Fix Version/s 1.7.3 [ 10212 ]
Fix Version/s 1.7.4 [ 10243 ]
toyomoyo committed 2 files to 'Moodle CVS' on branch 'MOODLE_18_STABLE' - 11/Oct/07 03:59 PM
MDL-9059, fixing students can't view group entries in calendar
MODIFY group/lib/Attic/basicgrouplib.php   Rev. 1.10.2.5    (+1 -1 lines)
MODIFY calendar/lib.php   Rev. 1.164.2.23    (+4 -3 lines)
Yu Zhang added a comment - 11/Oct/07 04:03 PM
Thanks guys for the report and proposed fix, the problem is group related, Moodle 1.8 was caching the wrong groupids and groups were not returned correctly. Fixed in 1.8.

Hi Nicholas and Roger, I was unable to reproduce the problem of teachers unable to post, I can add group events as teacher. Could you please post more info on this? Do you get error messages? Can you post a screenshot? The fix on 1.9 is totally unrelated to this, the fix on 1.9 was on perf patch.

Cheers,

Yu


Nicolas Martignoni added a comment - 11/Oct/07 04:19 PM
I'm sorry to say that though it worked yesterday (before MOODLE_19_STABLE branching), it doesn't work anymore, on 1.9beta2 and 2.0dev too.

Nicolas Martignoni added a comment - 11/Oct/07 08:20 PM
Hi Yu,

I just installed a fresh 1.8.3 and made some tests. Here are the results, following A.T.Wyatt protocol (see above):

Course created, teacher assigned, student assigned, 2 groups created and student placed in group 1, teacher in group 2.

I login as admin, I add group events in a course, in multiple groups.

  • As admin, I CAN see group events in the calendar view, but NOT in the calendar and Upcoming Events blocks.
  • As admin, switching to role "teacher", I CAN see group events in the calendar view, but NOT in the calendar
    and Upcoming Events blocks.
  • As admin, switching to role "student", I CANNOT see group events at all.

I login as teacher.

  • As teacher, I can see the group events that admin added to the course, in the calendar view AND in
    the calendar and upcoming events blocks.
  • As teacher, I add group events in a course (both groups) and see them everywhere.
  • As teacher, switching to role "non-editing teacher", I can see all the group events everywhere.
  • As teacher, switching to role "student", I can see all my group events everywhere.

I login as student, I can see all my group events everywhere.

Summary
=======

The remaining problem in 1.8.3 are the lacking view in the blocks for the admin and switching roles.


Juan Segarra Montesinos added a comment - 11/Oct/07 08:44 PM
Hi all.

I've have a similar problem. Perhaps it's related or perhaps its another issue with calendar. A teacher was seeing group events from groups she was not member of. And group events that she should be able to see were not appearing.

Problem is in function calendar_set_filters() at calendar/lib.php. Look at the query:

$sql = "SELECT id, groupid
FROM {$CFG->prefix}groups_courses_groups
WHERE courseid IN (".implode(',', $groupids).')';

and change the order of the fields in the SELECT line:

$sql = "SELECT groupid, id
FROM {$CFG->prefix}groups_courses_groups
WHERE courseid IN (".implode(',', $groupids).')';

The $grouparray variable was not filled with groupids. That was our problem... hope this helps.


toyomoyo committed 1 file to 'Moodle CVS' on branch 'MOODLE_18_STABLE' - 16/Oct/07 11:45 AM
MDL-9059, admins don't see group event in course
MODIFY blocks/calendar_month/block_calendar_month.php   Rev. 1.27.2.2    (+12 -1 lines)
toyomoyo committed 1 file to 'Moodle CVS' on branch 'MOODLE_19_STABLE' - 16/Oct/07 11:46 AM
MDL-9059, admins can't see group events in course
MODIFY blocks/calendar_month/block_calendar_month.php   Rev. 1.30.2.1    (+12 -1 lines)
toyomoyo committed 1 file to 'Moodle CVS' - 16/Oct/07 11:47 AM
MDL-9059, admins can't see group events in calendar
MODIFY blocks/calendar_month/block_calendar_month.php   Rev. 1.31    (+12 -1 lines)
Yu Zhang added a comment - 16/Oct/07 11:53 AM
Hi Nicolas, admins should now be able to see group events in a course. I think switch role in this situation is very tricky because the switched role does not have a course, nor a group, and I suspect the code follows the current user's group and courses set in session, thus the strange behavior.

Juan, I am not able to duplicate this problem, I see correct groups for my users. Could you please describe how to reproduce the problem in greater detail? I think using the ids of groups_courses_groups in 1.8 is correct.

Cheers,

Yu


Juan Segarra Montesinos added a comment - 18/Oct/07 07:11 PM
Hi Yu, delete my comment Sorry but the modification i've proposed is equivalent to that in the patch of lib.php in calendar directory.

Sorry for the noisy comment


Juan Segarra Montesinos added a comment - 18/Oct/07 08:11 PM
Well... i'm here again. It's quite dificult to reproduce in a normal way. You can reproduce the problem by inserting a row in mdl_groups_courses_groups where id (not groupid) is equal to the id of an existing group. This is the situation that makes the magic thing The array $grouparray ends having a list of id but must end with a list of groupid

Kenneth guess it before Both his or our patch solves the problem we described.

Sorry if i misunderstud something, but there are lots of comments now :-P

Thanks for your work Yu


toyomoyo committed 1 file to 'Moodle CVS' on branch 'MOODLE_18_STABLE' - 19/Oct/07 10:27 AM
MDL-9059, broken sql in calendar_set_filters()
MODIFY calendar/lib.php   Rev. 1.164.2.25    (+2 -2 lines)
Yu Zhang added a comment - 19/Oct/07 10:34 AM
Hi Juan, you are right, normally there's a one to one relationships but that is not always enforced. I have fixed this in code. Thanks very much. Other than the switch roles issues, are there any more issues? Cheers.

Nicolas Martignoni added a comment - 23/Oct/07 03:44 AM
Yu, sorry for the delay, I was on vacation :-D

The blocks problem is fixed in 1.8.3+. I have yet to test it in 1.9beta2.


Nicolas Martignoni added a comment - 24/Oct/07 02:28 AM
Yu, I just tested on 1.9beta2 (fresh from CVS).

The problem is still present


Yu Zhang added a comment - 24/Oct/07 09:52 AM
Hi Nicolas, sorry there are too many problems listed in this bug, can you please tell me exactly which one you are talking about and whether it is fixed in 1.8.3+?

Cheers,

Yu


Nicolas Martignoni added a comment - 24/Oct/07 05:39 PM
Yu, I was talking of the initial issue : "When a teacher creates a group event and assigns it to a course group, it does not appear to students or teachers" which is now fixed on 1.8.x but not on 1.9beta2. Further, the problem is present too for admins.

Should I close this bug and open another one?

Ciao
Nicolas


Yu Zhang added a comment - 12/Nov/07 02:28 PM
Hi Nicolas, can you please try again? It is a different issue this time but should be fixed now in HEAD and 19.

Cheers,

Yu


toyomoyo committed 1 file to 'Moodle CVS' on branch 'MOODLE_19_STABLE' - 12/Nov/07 03:26 PM
MDL-9059, when teacher creates group event on calendar, they can not see it
MODIFY calendar/lib.php   Rev. 1.206.2.5    (+18 -3 lines)
toyomoyo committed 1 file to 'Moodle CVS' - 12/Nov/07 03:27 PM
MDL-9059, when teacher creates group event on calendar, they can not see it
MODIFY calendar/lib.php   Rev. 1.211    (+18 -3 lines)
Nicolas Martignoni added a comment - 12/Nov/07 03:46 PM
Right, Yu, this works now. Verified on 1.9.beta2 (fresh from CVS).

Thank you


Nicolas Martignoni made changes - 12/Nov/07 03:46 PM
Status Open [ 1 ] Closed [ 6 ]
Resolution Fixed [ 1 ]
Elena Ivanova added a comment - 06/May/08 05:30 AM
I do not believe that this was fixed completely.
We had this issue in 1.8.3+, and it is still the same with 1.8.5 which we have got 2 days ago - students cannot see their group events.
Other users are also reporting the same problem: http://moodle.org/mod/forum/discuss.php?d=89015

Daniel Miksik added a comment - 04/Nov/08 01:52 PM
We have just upgraded to the latest 1.8.7+ and I am still seeing this issue. A group event in a course with either visible or separate groups is not shown to students.