Weeks visibility

Weeks visibility

by Philip Templeton -
Number of replies: 4

I am trying to add a button to "edit settings" that would give course creators the option of setting the display of all the weeks in the course as visible.  The courses are already built and have the visibility of weeks either collapsed or invisible. I have added a checkbox to the mform in course_edit.  I've created a customized format based on the default. Do I need to add a database record so when the edit form submits the form values to the format it keeps track of the new button value?  Even after adding the button it seems that the only values being sent are only specific values in the mform, what dictates which values are sent to the format?  Thanks for the help!

 

Phil 

Average of ratings: -
In reply to Philip Templeton

Re: Weeks visibility

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Phil,

It depends if you are using Moodle 2.4 or 2.3-.  If the former then use course format settings then you don't need a custom form.  If the latter then you need a bespoke table with course id and your data setting along with getting the data out of the form, say with $mform->getData() when it is submitted.

If you say what version of Moodle you are using, then I can point you further in the direction you need to go.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Weeks visibility

by Philip Templeton -

Hello,

Thanks, I am back in 1.9.  Im in a new LMS environment here... The migration is in the works but more of a distant goal.  

As I am watching the data flow and I get to the conditional in the edit.php where it splits either updating based of the form ($editfomr->set-data($course) or creating a new course ($data = $editform->get_data()) and when all is said and done I dump the var and it contains the array with my value however after submit is pressed it doesnt pass the var so maybe its not a database entry...?  Maybe something in the post?

Phil

In reply to Philip Templeton

Re: Weeks visibility

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Phil,

Ah, ok smile

Without going into confusing detail here, I've implemented forms in a 1.9 course format, so if you download Collapsed Topics for Moodle 1.9 - https://moodle.org/plugins/pluginversion.php?id=1078 - as it contains forms for layout and cookie consent.  Then in reading the code I hope you'll be able to see how its done and if not have a common frame of reference to ask things like 'why does this do that' etc.

Cheers,

Gareth