Details
Description
When adding a 'Link to a file or web site' resource, it's possible to save changes without filling in the location field.
To ensure that the location field is filled in, the following code could be added to course/mod.php at approx line 40
if ($mod->reference == 'http://' // $mod->reference == '') { error('Please select a file or webpage to add', view.php?id=$course->id); }
This redirects the user to the course page. Would it be possible to redirect back to the page containing the form?
From Martin Dougiamas (martin at moodle.com) Sunday, 19 June 2005, 02:01 PM:
Must be fixed, but I think we can do it with Javascript as well (before submitting the page!)
From wild girl (helen.foster at altoncollege.ac.uk) Tuesday, 21 June 2005, 05:27 PM:
If my suggested code is added at approx line 40 then it also prevents users from deleting resources!
Instead, it needs to be placed within the add and update sections of the switch block.
You're right about the javascript - which file should it go in?
From wild girl (helen.foster at altoncollege.ac.uk) Tuesday, 21 June 2005, 11:14 PM:
Sorry for not testing my suggestion enough previously - just amended the code to make it more specific!
if ($mod->type == 'file' && ($mod->reference == 'http://' // $mod->reference == '')) { error('Please select a file or webpage to add', view.php?id=$course->id); }