New capability - Print View within lesson module for Students

New capability - Print View within lesson module for Students

by Steve Bilton -
Number of replies: 9
Hi,

Could some kind folk please tell me how and where I can create a new capability.

I am making some changes to the lesson module which require a new capability. It is very similar to non-editing teacher role with regards to mod/lesson:manage & the view provided to non-editing teachers within lessons, but I require further restrictions as this role is for students. I don't want them to view reports/grades etc, just the alternative view for the lesson module.

I am providing 'edit' mode which I will rename the string for students to "Print View" for lesson module, so all pages can be displayed on a single web page without the editing buttons/links etc ..

I'm afraid the mod/lesson:edit & mod/lesson:manage capabilities simply do not suffice. I'm sure there should be a mod/lesson:view capability too, but its missing from my 1.8.8 moodle, never mind.

I have read the documentation for /lib/locallib.php and checked out /lib/db/access.php and within mod/lesson/db/access.php, but i'm still not clear where to add my new capabilities, or how to get it to update the capabilties for moodle tables. It's probably just a version file though. If it is the version.php file is it the one within the moodle root?

The rest of the coding within the lesson module seems straight forward to acheive what I am after, it is just the creation of new capabilities i'm confused over mixed.

Print View for students, that'll stop em complaining about the lack of available printed copies of our lessons, hurrah smile (hopefully)

Thanks for any tips.

Steve
Average of ratings: -
In reply to Steve Bilton

Re: New capability - Print View within lesson module for Students

by Akinsaya Delamarre -
To add a capability you have to modify the access.php in mod/lesson/db and in mod/lesson/version.php. Add your capability in access.php.

You can follow the same format of the current lesson capabilities that are already in the access.php. However for more details on what options are available have a look at http://docs.moodle.org/en/Development:NEWMODULE_Adding_capabilities for more information. It will give you a more general overview.

After adding your capability you will need to bump up the lesson version in version.php in mod/lesson. This basically tells Moodle that there is a change to that module and it essentially needs to be "reloaded".

Save your changes and click on the 'notifications' link in the admin block.

On a side note this may be of interest to you. I made a 'print PDF' feature for the lesson module that uses the tcpdf library to allow a student to download a pdf of the entire lesson. It was primarily useful for lessons that contain branch pages and images only. There is no code in there to handle the displaying of questions in a nice way. However the modification was done for Moodle 193.
In reply to Akinsaya Delamarre

Re: New capability - Print View within lesson module for Students

by Joseph Rézeau -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators
Can we have a look at your 'print PDF' for the lesson module feature please?
In reply to Joseph Rézeau

Re: New capability - Print View within lesson module for Students

by Akinsaya Delamarre -
Here is a patch for the lesson files and patch for the lesson language string.
In reply to Akinsaya Delamarre

Re: New capability - Print View within lesson module for Students

by Steve Bilton -
Hi,

Thanks for your help folks, that's cleared that one up for me.

I'll share any successful changes I make.

PS. I'd be very interested if this patch can be easily modified for 1.8.8 moodle?

I'm also having difficulties uncompressing the .tgz. so far only 7zip seems to uncompress it, but it still seems corrupt, I have a 40KB patch file with many strange symbols. Any chance of a fresh upload in an alternative compression format? (using Linux & Wind'ohz smile

Thanks Akinsaya!

Steve
In reply to Steve Bilton

Re: New capability - Print View within lesson module for Students

by Joseph Rézeau -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators
This is to confirm that Akinsaya's file is not correctly zipped, I can't unzip it. Please re-zip with a more standard zipper.
In reply to Joseph Rézeau

Re: New capability - Print View within lesson module for Students

by Steve Bilton -
Hi,

I have managed to untangle the compressed files... weird.

Anyway the files are now attached in standard zip format.

Can anyone4 tell me if this is compatible with 1.8.8.

I have a very customised lesson module and don't want to apply this patch, it will break my lesson mod.

Steve


In reply to Joseph Rézeau

Re: New capability - Print View within lesson module for Students

by Akinsaya Delamarre -
Attaching the patch again. Let me know if this works.
In reply to Akinsaya Delamarre

Re: New capability - Print View within lesson module for Students

by Salisha Mussio -

i have been attempting to add a three new capabilities to a the assingment module and when i increase the version number and log on as admin, it says tables for the databas have already been updated, when i use command line to check the inputs into the mdl_capabilities table, the information is not there.  can you help me please i need some suggestions on how to get these new capabilities working.

thank you