Provide checkbox while creating a page (resource)

Provide checkbox while creating a page (resource)

by George Abraham -
Number of replies: 2

Hi,

While creating a page for a course, I want to provide the course creator some option to specify if the page is an "outline" or "content" of the course. I need this particular detail for my research work.

Is there some method by which I can do this, like provide a checkbox to the creator to click and specify which type of page it is?

Can someone provide me with some technical assistance on this, please. It is URGENT!!

Average of ratings: -
In reply to George Abraham

Re: Provide checkbox while creating a page (resource)

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If I have understood you correctly, you are wanting to add an extra option to the 'page' resource settings page to mark a particular resource as being either 'outline' or 'content'?

You have a couple of options for this - you could create a new type of 'page' resource - this would involve duplicating all the code in 'mod/page' and then going through carefully and changing all the references to 'page' in the duplicate to 'mynewname'. This can be very fiddly to do.

The other alternative is to modify the core code of 'mod/page', but this has the disadvantage that you will have to manage Moodle upgrades very carefully, as any upgrade is likely to overwrite the changes you have made (using 'git' to manage site customisations is one way to approach this).

Either way, you will need to modify the 'mdl_page' table to add an extra field to store the new value (using Site admin > developer > xmldb editor, is the best way to generate the PHP code that needs to go in mod/page/db/upgrade.php to make the DB change for you). You will also need to modify 'mod/page/mod_form.php' to add the extra 'select' element to include the type (or a checkbox).

You may also need to add some logic to mod/page/lib.php in the functions 'page_add_instance()' and 'page_update_instance()' to make sure the correct values are saved into the database.

After that, you might also want to look in mod/page/view.php to add some way of displaying what type of resource it is (alternatively, there are ways to alter the icon or add extra information on the course page itself).

If you need this urgently and don't have time to learn how to do this yourself (and are able to pay for it), there are a list of official 'Moodle partners' at http://moodle.com who can do this work for you (including my own employers Synergy Learning), with the added bonus that a proportion of the money you pay goes back to funding ongoing Moodle development.

 

Average of ratings: Useful (1)
In reply to Davo Smith

Re: Provide checkbox while creating a page (resource)

by George Abraham -

@Davo Smith

Thanks for the solution. I will look into it and see how I can work things out.