Squashed commit of the following:

commit 6f0451da65ab947d0b1a2993e498d555ae25c6fd
Author: Vaughany <paulieboo@gmail.com>
Date:   Wed Jun 4 20:51:42 2014 +0100

    Changes to the script to assign the correct capability to the role after creation, and logic to handle Moodle 2.0 and 2.1 slightly differently. Slightly more testing.

commit 1abee8644918dcb16fccbac5d617587c786fe185
Author: Paul Vaughan <paulvaughan@southdevon.ac.uk>
Date:   Wed Jun 4 15:13:27 2014 +0100

    Emergency commit.