Setting default values and removing the option to edit them when adding a new Activity/Resource

Setting default values and removing the option to edit them when adding a new Activity/Resource

by Sami A -
Number of replies: 6

Hello,


Our issue is that we are trying to minimize the effort and options that are needed to create a new activity or resource. We are doing this by removing the many settings they have when creating/editing an activity. (see screenshot below)


How can we hide these settings visually from the user while also setting a default value for them. Any help is appreciated



Average of ratings: -
In reply to Sami A

Re: Setting default values and removing the option to edit them when adding a new Activity/Resource

by Sami A -
bump smile Any help is greatly appreciated!
In reply to Sami A

Re: Setting default values and removing the option to edit them when adding a new Activity/Resource

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

Edit the code for the form, replacing the settings you don't want users to change with 'hidden' elements (with default values set to what you want them to have).

It will require a lot of changes to the core code for those forms that you will have to maintain carefully during all future upgrades.


In reply to Davo Smith

Re: Setting default values and removing the option to edit them when adding a new Activity/Resource

by Sami A -
Yeah this is what we're trying to do. We can't find out where is the form code cause it seems like theres lots of files involved at once. Mind helping us with locating it?

We're willing to maintain it during future upgrades.
In reply to Davo Smith

Re: Setting default values and removing the option to edit them when adding a new Activity/Resource

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers
I took a different approach, although admittedly mine was only for a single setting.
I built a block that I put on every applicable page (no displayed content, only visible when editing), and in that block I used javascript to set the values of the form I needed, and css to hide them from sight.
It's far from infallible - knowledgeable users can 'inspect element' to reveal the form elements and can then still edit them for example (that may be a JS tweak to set the values on saving the form rather than on opening it?) , but it removes the need for ongoing core hacks on every update, so is a compromise solution.
In reply to Richard Oelmann

Re: Setting default values and removing the option to edit them when adding a new Activity/Resource

by Sami A -
This is a clever workaround and helps with any updates that happen I'm guessing. Just curious tho, how'd you use css to hide the specific items you want to hide?
In reply to Sami A

Re: Setting default values and removing the option to edit them when adding a new Activity/Resource

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers
You can’t set default values for some of those areas (eg. activity completion, restrict access, competencies and tags). If you’re not going to use any/all of those, they can be turned off and not display on that page anyway. For the rest, use {display: none;} on the appropriate CSS selectors. Do you have the ability to inspect the CSS? If not, and if you can narrow down the list, I can give you the relevant selectors.

And that screenshot is from the Assignment module - is it only that module that you want to hide these settings for, or other types of activities? If so, which activities and which settings?