Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-81359

Availability condition display 'show more' sometimes doesn't show more

XMLWordPrintable

    • MOODLE_403_STABLE
    • MOODLE_403_STABLE
    • MDL-81359-m403
    • MDL-81359-main
    • Hide

      Using any course:

      1. Create a new Page activity. Set the name to 'Test page for completion', type anything in 'Page content', expand 'Completion conditions' and choose 'Students must manually mark the activity as done'; then save and return to course.
      2. Create a second new Page activity called 'Restricted'. Set the page content to any text. Expand 'Restrict access', click 'Add restriction', click 'Activity completion', and choose 'Test page for completion' from the dropdown; then save and return to course.
      3. Look at the availability restrictions shown underneath the 'Restricted' Page.
        • EXPECTED: It should say 'Not available unless: The activity Test page for completion is marked complete', and there should not be a 'Show more' button.
      4. Using the pencil icon, edit the name of the first Page activity 'Test page for completion' to 'Test page for completion with a really really really long name'.
      5. After the edit completes, reload the page (it doesn't update fully otherwise).
      6. Look at the availability restrictions shown underneath the 'Restricted' Page.
        • EXPECTED (no change): The text should be cut off before it gets to the end of the long activity name, and there shoul now be a 'Show more' button; clicking the button will reveal the full name.
      Show
      Using any course: Create a new Page activity. Set the name to 'Test page for completion', type anything in 'Page content', expand 'Completion conditions' and choose 'Students must manually mark the activity as done'; then save and return to course. Create a second new Page activity called 'Restricted'. Set the page content to any text. Expand 'Restrict access', click 'Add restriction', click 'Activity completion', and choose 'Test page for completion' from the dropdown; then save and return to course. Look at the availability restrictions shown underneath the 'Restricted' Page. EXPECTED: It should say 'Not available unless: The activity Test page for completion is marked complete', and there should not be a 'Show more' button. Using the pencil icon, edit the name of the first Page activity 'Test page for completion' to 'Test page for completion with a really really really long name'. After the edit completes, reload the page (it doesn't update fully otherwise). Look at the availability restrictions shown underneath the 'Restricted' Page. EXPECTED (no change): The text should be cut off before it gets to the end of the long activity name, and there shoul now be a 'Show more' button; clicking the button will reveal the full name.

      If you set up an availability condition ('Restrict access') on an item, this sometimes displays a 'Show more' link. There are 2 conditions for the 'Show more' link to appear:

      • If there are multiple conditions
      • If the single condition has long text

      However, there is a situation in which the 'Show more' link appears, but when you click it, no additional text is revealed. To reproduce:

      • Create a Page called 'Test page for completion', which has completion enabled (e.g. student must view the page to complete it).
      • Create a second Page; in the 'Restrict access' section, add a restriction based on completion - student must complete the first page.

      Now the course page will show

      Not available unless: The activity Test page for completion is marked complete ... (Show more)

      But if you click 'Show more', this changes to:

      Not available unless: The activity Test page for completion is marked complete (Show less)

      In other words it actually shows less (the ellipsis goes away) when you click 'Show more'.

      This bug occurs because the code in course/format/classes/output/local/content/section/availability.php line 212 uses html_to_text to decide if the text is too long. For the completion condition, the text includes a link, and html_to_text includes this at the end of the text, like (example from a local custom plugin but it's the same principle):

      The activity NEW SUBPAGE [1] is available (hidden otherwise) 
      Links: 
      ------ 
      [1] http://localhost/ou-moodle2/mod/oustudyplansubpage/view.php?id=12 
      

            quen Sam Marshall
            quen Sam Marshall
            Katie Ransom Katie Ransom
            Amaia Anabitarte Amaia Anabitarte
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 15 minutes
                1h 15m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.