Moodle
  1. Moodle
  2. MDL-14693

Previous and Next links are wrong in the block calendar within a resource page

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.7, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.8, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.9
    • Fix Version/s: None
    • Component/s: Calendar, Resource
    • Labels:
      None
    • Affected Branches:
      MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE
    • Rank:
      12536

      Description

      When the calendar block is showed in a resource page, the next and previous month's links are wrong. Instead of using the resource id in the link, it uses the course id.

      Example:
      Actual link (which is wrong): http://moodle.polymtl.ca/mod/resource/view.php?id=33&cal_m=6&cal_y=2008 where 33 is the course id.

      The correct link should be: http://moodle.polymtl.ca/mod/resource/view.php?id=3473&cal_m=5&cal_y=2008 where 3473 is the current resource id.

      Since the link is /mod/resource/view.php, Moodle shows (or try to show) the resource id #33 (which is the course id).

      1. MDL-14693.patch
        0.8 kB
        Jérôme Mouneyrac

        Issue Links

          Activity

          Hide
          Eloy Lafuente (stronk7) added a comment -

          Hi Jérôme,

          can you research a bit about this and how we could handle calendar appearing in different Moodle pages (course page, site page, my moodle page, resource page...).

          Some proposal here will be welcome. TIA!

          Show
          Eloy Lafuente (stronk7) added a comment - Hi Jérôme, can you research a bit about this and how we could handle calendar appearing in different Moodle pages (course page, site page, my moodle page, resource page...). Some proposal here will be welcome. TIA!
          Hide
          Jérôme Mouneyrac added a comment -

          the bug is due to the fact that calendar code considers that the calendar can only be on Front Page or Course page. The current behavior is: if the page is not the Front Page so it is a course page:

          $courseshown = $COURSE->id;

          if ($courseshown == SITEID)

          { calendar_top_controls('frontpage'... }

          else

          { calendar_top_controls('course',... }

          1- we could add some other cases (resource, my moodle) but I don't know how recognize where we are
          2- we could try to do something generic. Get the url and add the calender parameters "cal_m=M&cal_y=YYYY". It is ugly and will not work if ever the calendar is displayed on a page that need POST parameters.
          3- we could transform the calendar in AJAX (user-friendly and bug expectation)

          I'm still thinking about that... you have some ideas don't hesitate to share

          Show
          Jérôme Mouneyrac added a comment - the bug is due to the fact that calendar code considers that the calendar can only be on Front Page or Course page. The current behavior is: if the page is not the Front Page so it is a course page: $courseshown = $COURSE->id; if ($courseshown == SITEID) { calendar_top_controls('frontpage'... } else { calendar_top_controls('course',... } 1- we could add some other cases (resource, my moodle) but I don't know how recognize where we are 2- we could try to do something generic. Get the url and add the calender parameters "cal_m=M&cal_y=YYYY". It is ugly and will not work if ever the calendar is displayed on a page that need POST parameters. 3- we could transform the calendar in AJAX (user-friendly and bug expectation) I'm still thinking about that... you have some ideas don't hesitate to share
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Well, for 2.0 I expect the calendar to be revamped and so, so the AJAX alternative (always optional, leaving one non-ajax solution working) could be done.

          But that's only for 2.0... we need to make it work under 1.9 without any "dramatic" change like the planned for 2.0. AFAIK all the pages able to have blocks have (or use) something called "pagelib" to be rendered.

          Perhaps that pagelib object has some member storing what are we viewing and can use it to rebuild the calendar links? Or perhaps we need to use FULLME and so? Those are the two alternatives I can imagine to chage it in a easy way.

          I really thing that all those pages are always GET pages... so we won't have the "POST" problem.

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Well, for 2.0 I expect the calendar to be revamped and so, so the AJAX alternative (always optional, leaving one non-ajax solution working) could be done. But that's only for 2.0... we need to make it work under 1.9 without any "dramatic" change like the planned for 2.0. AFAIK all the pages able to have blocks have (or use) something called "pagelib" to be rendered. Perhaps that pagelib object has some member storing what are we viewing and can use it to rebuild the calendar links? Or perhaps we need to use FULLME and so? Those are the two alternatives I can imagine to chage it in a easy way. I really thing that all those pages are always GET pages... so we won't have the "POST" problem. Ciao
          Hide
          Jérôme Mouneyrac added a comment -

          Ok I think I went through all pages with Calendar:

          • front page
          • course
          • my moodle (front page)
          • resource: compose a text page / compose a web page

          In conclusion the current code only omit this two resources. A little patch can it make it works:

          $courseshown = $COURSE->id;

          if ($courseshown == SITEID)

          { ... }

          else

          { + $courseshown = optional_param( 'id', 0, PARAM_INT ); // Forcibly filter events to include only those from the particular course we are in. $filtercourse = array($courseshown => $COURSE); $groupeventsfrom = array($courseshown => 1); }
          Show
          Jérôme Mouneyrac added a comment - Ok I think I went through all pages with Calendar: front page course my moodle (front page) resource: compose a text page / compose a web page In conclusion the current code only omit this two resources. A little patch can it make it works: $courseshown = $COURSE->id; if ($courseshown == SITEID) { ... } else { + $courseshown = optional_param( 'id', 0, PARAM_INT ); // Forcibly filter events to include only those from the particular course we are in. $filtercourse = array($courseshown => $COURSE); $groupeventsfrom = array($courseshown => 1); }
          Hide
          Jérôme Mouneyrac added a comment - - edited

          Note: Calendar block is not displayed in block for activities. It could be a missing functionalities. However the patch should still work.
          I created a issue form the missing calendar block: MDL-16104

          Show
          Jérôme Mouneyrac added a comment - - edited Note: Calendar block is not displayed in block for activities. It could be a missing functionalities. However the patch should still work. I created a issue form the missing calendar block: MDL-16104

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: