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

File/URL resource: 'Open' option does not work in all situations

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.1.5, 2.2.2
    • 2.1, 2.2.1, 2.3
    • Resource
    • MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • MOODLE_21_STABLE, MOODLE_22_STABLE
    • MDL-31015-master
    • Hide

      Note: For behaviour to be exactly as described, you have to be using a browser/computer which is capable of displaying PDFs directly in the browser. (This is default for most sysetms.) Otherwise it will download instead.

      Note: Checks marked are unchanged from existing behaviour.

      1. On a test course, ensure that completion is enabled, then add the following activities, all of which should have the default (manual) completion type so they get a tickbox:
      a) A File resource containing a PDF set to display type 'Open'.
      b) A File resource containing a PDF set to display type 'Force download'.
      c) A URL resource (to whatever link) set to display type 'Open'.

      2. Click on the file (a), second file (b), and URL (c) from the main course page. (After the first file and URL you will need to click Back to return to the page.)
      + The PDF (a) should open directly in same browser window without an intermediate page.
      + The PDF (b) should show as a download prompt dialog.
      + When showing the download prompt the browser should NOT briefly display a new tab.
      + The URL (c) should open directly in the same browser window.

      3. Ctrl/Command-click the three links.
      + (a) and (c) should open directly in new tabs.
      + (b) should (in Firefox) show a new empty tab then the download prompt. (Other browsers might get rid of the tab afterwards or something, not sure, but Firefox doesn't. Its call anyhow.)

      4. Expand the navigation block and click on the three links.
      + Results should be the same as in step 2.

      5. Go to the course / Reports / Activity completion. From the completion table, click on the three links.
      + Results should be the same as in step 2.

      Following tests originally from MDL-31247, which this is supposed to fix too

      Using an embeddable media type

      • create a new file resource and upload a PDF
      • set the 'Display' setting to 'Automatic' and save changes
      • click the link for the resource
        • the PDF should embed
      • update the resource and set the Display to 'Embed' and save changes
      • click the link for the resource
        • the PDF should embed
      • update the resource and set the Display to 'Force Download' and save changes
      • click the link for the resource
        • a new window may (or may not) be opened and the file will be downloaded. The browser window should close after accepting the download
      • update the resource and set the Display to 'Open' and save changes
      • click the link for the resource
        • the PDF should open (or download if the browser doesn't support opening in the browser window)
      • update the resource and set the Display to 'In pop-up' and save changes
      • click the link for the resource
        • the PDF should open in a popup window

      Using an non-embeddable media type

      • create a new file resource and upload a zip file
      • set the 'Display' setting to 'Automatic' and save changes
      • click the link for the resource
        • a new window may (or may not) be opened and the file will be downloaded. The browser window should close after accepting the download
      • update the resource and set the Display to 'Embed' and save changes
      • click the link for the resource
        • the file information will be displayed with a download link
        • the download link should download the file
      • update the resource and set the Display to 'Force Download' and save changes
      • click the link for the resource
        • a new window may (or may not) be opened and the file will be downloaded. The browser window should close after accepting the download
      • update the resource and set the Display to 'Open' and save changes
      • click the link for the resource
        • the file should be downloaded
      • update the resource and set the Display to 'In pop-up' and save changes
      • click the link for the resource
        • A popup window will be opened, the file should download, the popup doesn't close (this sucks, but is the existing behaviour)

      Make sure this is tested in all supported browsers

      Show
      Note: For behaviour to be exactly as described, you have to be using a browser/computer which is capable of displaying PDFs directly in the browser. (This is default for most sysetms.) Otherwise it will download instead. Note: Checks marked are unchanged from existing behaviour. 1. On a test course, ensure that completion is enabled, then add the following activities, all of which should have the default (manual) completion type so they get a tickbox: a) A File resource containing a PDF set to display type 'Open'. b) A File resource containing a PDF set to display type 'Force download'. c) A URL resource (to whatever link) set to display type 'Open'. 2. Click on the file (a), second file (b), and URL (c) from the main course page. (After the first file and URL you will need to click Back to return to the page.) + The PDF (a) should open directly in same browser window without an intermediate page. + The PDF (b) should show as a download prompt dialog. + When showing the download prompt the browser should NOT briefly display a new tab. + The URL (c) should open directly in the same browser window. 3. Ctrl/Command-click the three links. + (a) and (c) should open directly in new tabs. + (b) should (in Firefox) show a new empty tab then the download prompt. (Other browsers might get rid of the tab afterwards or something, not sure, but Firefox doesn't. Its call anyhow.) 4. Expand the navigation block and click on the three links. + Results should be the same as in step 2. 5. Go to the course / Reports / Activity completion. From the completion table, click on the three links. + Results should be the same as in step 2. Following tests originally from MDL-31247 , which this is supposed to fix too Using an embeddable media type create a new file resource and upload a PDF set the 'Display' setting to 'Automatic' and save changes click the link for the resource the PDF should embed update the resource and set the Display to 'Embed' and save changes click the link for the resource the PDF should embed update the resource and set the Display to 'Force Download' and save changes click the link for the resource a new window may (or may not) be opened and the file will be downloaded. The browser window should close after accepting the download update the resource and set the Display to 'Open' and save changes click the link for the resource the PDF should open (or download if the browser doesn't support opening in the browser window) update the resource and set the Display to 'In pop-up' and save changes click the link for the resource the PDF should open in a popup window Using an non-embeddable media type create a new file resource and upload a zip file set the 'Display' setting to 'Automatic' and save changes click the link for the resource a new window may (or may not) be opened and the file will be downloaded. The browser window should close after accepting the download update the resource and set the Display to 'Embed' and save changes click the link for the resource the file information will be displayed with a download link the download link should download the file update the resource and set the Display to 'Force Download' and save changes click the link for the resource a new window may (or may not) be opened and the file will be downloaded. The browser window should close after accepting the download update the resource and set the Display to 'Open' and save changes click the link for the resource the file should be downloaded update the resource and set the Display to 'In pop-up' and save changes click the link for the resource A popup window will be opened, the file should download, the popup doesn't close (this sucks, but is the existing behaviour) Make sure this is tested in all supported browsers

      In File and URL resources, one of the display options is 'Open'. When you choose this option, the resource is supposed to open directly without an intermediate page.

      For example, if the file is a PDF, you can have an entry on the main course page that says 'Book 1 (PDF)' and when users click it, the PDF loads immediately in their browser. Similarly, you could have an entry on the main course page that says 'BBC News' and when users click it they are taken immediately to the BBC news website.

      This works by using JavaScript on the main page to load the module's view.php with the extra parameter redirect=1.

      While this works fine on the main page when clicking the link normally it does not work in any other situation. For example:

      • If you click the links in the navigation block, you get the intermediate page.
      • If you middle-click the links to open in a new tab (which bypasses the JavaScript), you get the intermediate page.
      • If you use a link from pretty much any other location in Moodle (these tend to be fairly obscure places), such as the activity completion report, you get the intermediate page.
      • If you use some link in another module (we have a couple of OU custom ones that do this) which redirects to the standard view.php for mod/resource or mod/url, you get the intermediate page.

      This is currently our most frequently reported 'bug' in our Moodle 2 system. Users think 'I just clicked the link to open it - now you're giving me another screen that says please click the link to open it? wtf?'

      It should be easy to solve this problem: in cases where the display type is 'open', automatically default to redirect=1. As there is then no benefit to having the JavaScript, we can also remove the JavaScript (for this case).

      The same applies, but is less annoying, for the 'force download' option. In this case there is some slightly confusing JavaScript which (at least in Firefox) opens a new tab very briefly before the download starts. There is a slight performance benefit to this as it goes directly to the file rather than to the view.php, but it doesn't seem like a significant one and makes the code more complicated, so I suggest removing this too.

      JavaScript is of course still required for the 'pop up' option which I don't propose changing. That one makes a bit more sense to click twice if you have to. There may also be justification for making sure the JavaScript actually works in certain locations (e.g. navigation), but I think the most important fix is to make it work without JavaScript because that solves every case - improving the JS is a 'nice-to-have' for popups.

      Benefits:

      • Makes 'Open' and 'Force download' options on File and (in former case) URL work correctly however the File/URL is accessed.
      • Simplifies code. (Actually reduces line count!)

            quen Sam Marshall
            quen Sam Marshall
            Andrew Lyons Andrew Lyons
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Rossiani Wijaya Rossiani Wijaya
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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