Moodle

Site front page calendar doesn't show all the events for the user

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.5.3
  • Fix Version/s: None
  • Component/s: Calendar
  • Labels:
    None
  • Environment:
    All
  • Affected Branches:
    MOODLE_15_STABLE

Description

On the Moodle site front page, no course events are shown initially. When a user goes to a course calendar, then the events from that course stick around, but the front page calendar still doesn't show all the events for the courses that the user is attending.

This was working in 1.4.5+ and has been broken with the no all course events for admins, please code change. The bug could be in calendar_get_default_courses but I lost patience while hunting it and trying to fix it sorry: my brain hurts after a global variable $SESSION, calendar_set_filters setting values back to the parameters (hunted the $courses for a while, where oh where does this come from...) and so on... Arg.

I also tried to search for a previous bug on this, but didn't find any.

Activity

Hide
Martin Dougiamas added a comment -

From Samuli Karevaara (samuli.karevaara at lamk.fi) Thursday, 8 September 2005, 06:49 PM:

At least the bit

if(isset($USER->student) && is_array($USER->student)) { $courses = $USER->student; }

if(isset($USER->teacher) && is_array($USER->teacher)) { $courses = $USER->teacher; }

can't be right. For teachers all the courses that they are enrolled in as a student are overwritten with the $courses = $USER->teacher;

From Samuli Karevaara (samuli.karevaara at lamk.fi) Thursday, 8 September 2005, 06:54 PM:

Okay, more on this: changing the upper code to

if(isset($USER->teacher) && is_array($USER->teacher)) { $courses = $USER->teacher + $courses; }

fixes this for the initial visit on the front page, but visiting a course calendar sets the front page calendar to show the events for that visited single course also.

From Jon Papaioannou (pj at moodle.org) Friday, 9 September 2005, 12:56 AM:

Thanks for digging into this Samuli!

I 'll take a look as soon as I get the chance to see what exactly is going on. Keep writing here if there's anything else of interest you find out.

Also, I apologize for the voodoo which is going on with the $SESSION variables and such, but it was either this or hardcoding calendar-related information in all URLs throughout Moodle. I hope you agree that it was the lesser evil. [Considering that when developing the calendar I didn't even have CVS access, it was not even a choice really]

From Samuli Karevaara (samuli.karevaara at lamk.fi) Friday, 9 September 2005, 01:29 PM:

I understand that solutions like this are sometimes/often necessary to get anything done, instead of half-done non-working clean beginnings (like most of my projects ). I hope I didn't sound harsh, just a bit frustrated... Also, coding around other peoples code is tricky enough.

On my wish list: classes for User, Course and so on, with precise-info-loading capabilities, methods like fetch just the course names + id's to produce course listings (instead of loading everything to $courses to print just the titles) and so on. I know they are on your wish list too

The user belongs to these courses would be a nice method, for example Static methods, lazy loading tricks and session caching could be used to make these more efficient than the current everything you need is here, just dig deeper

(Okay, running out of smileys here...)

From Samuli Karevaara (samuli.karevaara at lamk.fi) Wednesday, 12 October 2005, 10:17 PM:

What's going on here is: calendar/view.php checks if it has to switch to show another courses events by reading optional_variable($_GET['course'], 0);

(one nono in my mind is that this writes back to $_GET, that is, the query string...)

First issue that arises is that the site front page calendar block doesn't provide the course number (SITEID in this case) if you click the month name to get to the calendar view. Thus, you end up looking at the events for the last course that you viewed the calendar for, even though you're coming from SITEID.

Secondly, the front page block still wouldn't show the events for all of the users courses, as it has no such course switch check, just the calendar/view.php.

IMHO the front page calendar should always show events for all of the users courses, as it has no visual clue to tell you which course it's showing the events for.

I did a temporary ugly hack (you see, I complain about this to others but still do it my self, the way of the world i Guess :_) ) and added following lines to be called somewhere from the /index.php:

$SESSION->cal_courses_shown = calendar_get_default_courses(true);

$SESSION->cal_course_referer = intval(SITEID);

More things, really overloading this bug comment thread, a nono also:

  • Isn't there another (maybe still not an elegant, but more consistent) way to check what course are we sitting on at? (the course global hack?)
  • Is there a reason to use a home cooked session object $SESSION instead of the built-in $_SESSION one?
Show
Martin Dougiamas added a comment - From Samuli Karevaara (samuli.karevaara at lamk.fi) Thursday, 8 September 2005, 06:49 PM: At least the bit if(isset($USER->student) && is_array($USER->student)) { $courses = $USER->student; } if(isset($USER->teacher) && is_array($USER->teacher)) { $courses = $USER->teacher; } can't be right. For teachers all the courses that they are enrolled in as a student are overwritten with the $courses = $USER->teacher; From Samuli Karevaara (samuli.karevaara at lamk.fi) Thursday, 8 September 2005, 06:54 PM: Okay, more on this: changing the upper code to if(isset($USER->teacher) && is_array($USER->teacher)) { $courses = $USER->teacher + $courses; } fixes this for the initial visit on the front page, but visiting a course calendar sets the front page calendar to show the events for that visited single course also. From Jon Papaioannou (pj at moodle.org) Friday, 9 September 2005, 12:56 AM: Thanks for digging into this Samuli! I 'll take a look as soon as I get the chance to see what exactly is going on. Keep writing here if there's anything else of interest you find out. Also, I apologize for the voodoo which is going on with the $SESSION variables and such, but it was either this or hardcoding calendar-related information in all URLs throughout Moodle. I hope you agree that it was the lesser evil. [Considering that when developing the calendar I didn't even have CVS access, it was not even a choice really] From Samuli Karevaara (samuli.karevaara at lamk.fi) Friday, 9 September 2005, 01:29 PM: I understand that solutions like this are sometimes/often necessary to get anything done, instead of half-done non-working clean beginnings (like most of my projects ). I hope I didn't sound harsh, just a bit frustrated... Also, coding around other peoples code is tricky enough. On my wish list: classes for User, Course and so on, with precise-info-loading capabilities, methods like fetch just the course names + id's to produce course listings (instead of loading everything to $courses to print just the titles) and so on. I know they are on your wish list too The user belongs to these courses would be a nice method, for example Static methods, lazy loading tricks and session caching could be used to make these more efficient than the current everything you need is here, just dig deeper (Okay, running out of smileys here...) From Samuli Karevaara (samuli.karevaara at lamk.fi) Wednesday, 12 October 2005, 10:17 PM: What's going on here is: calendar/view.php checks if it has to switch to show another courses events by reading optional_variable($_GET['course'], 0); (one nono in my mind is that this writes back to $_GET, that is, the query string...) First issue that arises is that the site front page calendar block doesn't provide the course number (SITEID in this case) if you click the month name to get to the calendar view. Thus, you end up looking at the events for the last course that you viewed the calendar for, even though you're coming from SITEID. Secondly, the front page block still wouldn't show the events for all of the users courses, as it has no such course switch check, just the calendar/view.php. IMHO the front page calendar should always show events for all of the users courses, as it has no visual clue to tell you which course it's showing the events for. I did a temporary ugly hack (you see, I complain about this to others but still do it my self, the way of the world i Guess :_) ) and added following lines to be called somewhere from the /index.php: $SESSION->cal_courses_shown = calendar_get_default_courses(true); $SESSION->cal_course_referer = intval(SITEID); More things, really overloading this bug comment thread, a nono also:
  • Isn't there another (maybe still not an elegant, but more consistent) way to check what course are we sitting on at? (the course global hack?)
  • Is there a reason to use a home cooked session object $SESSION instead of the built-in $_SESSION one?
Hide
Gustav W Delius added a comment -

I have updated this from "trivial" to "major" because dates not showing up in the calendar when they should is used as an excuse by our students to ignore deadlines.

Show
Gustav W Delius added a comment - I have updated this from "trivial" to "major" because dates not showing up in the calendar when they should is used as an excuse by our students to ignore deadlines.
Hide
Dan Marsden added a comment -

flagging this as cannot reproduce - Events have changed a lot since 1.5 but let me know if it's still an issue and I'll re-open.

Show
Dan Marsden added a comment - flagging this as cannot reproduce - Events have changed a lot since 1.5 but let me know if it's still an issue and I'll re-open.

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: