This hack is very much in the development stage. DO NOT USE THIS ON A PRODUCTION SYSTEM. You have been warned.
Installation
- Attached should be the file "moodle_activity_locking.zip". This contains the following files:
- course/lib.php
- course/lock.php
- course/view.php
- pix/t/lock.gif
- pix/t/open.gif
- pix/t/closed.gif
- lib/locklib.php
- Extract them to the corresponding folders within your Moodle installation.
- The following piece of code needs to be pasted into view.php files of each module you have installed. Look in the "mod" folder of your Moodle installation, then look in each module folder in turn.
require_once($CFG->libdir.'/locklib.php');
if (($locks = islocked($cm, $course)) and array_search("closed", $locks) and !isteacher()) {
print_lock_notice($locks, $course);
}
/// End Activity Locking ///
- This code needs to be placed after the "require_login" function and before any "add_to_log" function.
- A new table needs to be added to your Moodle database as per the sql file included in the zip.
- That's it
- Log in as a user that has rights to modify a course
- In the course view window (the one where you can move, delete etc the activities within a course) and go into Edit mode.
- You will now see a new icon after the activity names: a padlock
- Clicking on the padlock will take you to the activity locking screen for that activity. If any grades are selected on this screen, then that activity must be completed to that level before this activity may be accessed.
- To unlock an activity, set all predecessors' grades to 0.
- Locked activities will appear "dimmed" with "(locked)" after the title. A number of icons will appear showing the number of predecessors for that activity and how many are completed.
- Sloppy programming
- Poor code commenting (I just get carried away with coding)
- No language strings used. Currently all labels, notices, alerts etc are in English.
- Need to test what happens when an activity is deleted. It should delete all locks associated with that activity, but it hasn't been tested.
- Not sure how it behaves alongside Bernard's activity linking (or indeed any other hacks).
- 2 or more activities can be locked to each other, meaning it is possible to create an impossible loop that a student can't break into. I'll leave it to you not to do that! Do I really need to code a safeguard against this?
- Poor on-screen instructions.
- Plenty more I can't think of at the moment!
- Test Test Test. Install it. Play with it. Let me know how it behaves. Remember, this is for Moodle 1.4.5 ONLY.
- How can improve how predecessors are shown on the course view? Currently, those little tick/cross icons are displayed. Is there a better way?
- Are there any performance issues with this hack? Obviously, the more locks you have, the more database queries there will be. I'm not sure just how many more though.
- Any other comments.
THIS IS FOR MOODLE 1.4.5 ONLY. DO NOT USE ON A PRODUCTION SYSTEM. THIS IS STILL IN THE TESTING PHASE