-
Bug
-
Resolution: Fixed
-
Minor
-
2.1, 2.2.1, 2.3
-
MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
-
MOODLE_21_STABLE, MOODLE_22_STABLE
-
MDL-31015-master -
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!)