How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Amrata Ramchandani -
Number of replies: 14

Hi,

I am developing one plugin,where I require to add new quiz settings,I want to group few elements but that group doesn't come inside Extra Restrictions,Rather it come outside,Why so ? and how do i get it inside it ?

below is the screenshot attached for the same,as you can see when the elements are not grouped,they are inside the "Extra restrictions block",as soon as I make them as a group they get out of it.

Screenshot for the behaviour of elements after grouping.

Moreover,Is there any way I can disable these links until the select option is YES ? I have checked with disabledIf function but that doesn't seem to work for LINKS. Is the Javascript only way to do it ? Or shall I convert these links into buttons and then use disabledIf ? 

Any suggestions will be highly appreciated.

Thanks !

La media da valetaziuns: -
In reply to Amrata Ramchandani

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Tim Hunt -
Maletg da 	Core developers Maletg da 	Documentation writers Maletg da 	Particularly helpful Moodlers Maletg da 	Peer reviewers Maletg da 	Plugin developers

You will need to tell us something about the code you have written. Something more than "I tried something and it did not work".

I mean, you did not even say what sort of plugin you are making!

Is the code on github, or similar?

La media da valetaziuns: -
In reply to Tim Hunt

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Amrata Ramchandani -

Hi Tim,

I am making quiz access plugin called User-IP Mappings. This plugin let us allow to assign IP Address to the user in order to attempt the quiz.The user will be able to attempt the quiz only from the allotted IP Address.

We make this as an optional functionality by keeping this in Quiz settings,where it can be enabled or disabled as and when required.

Below is the github repo. for the same

https://github.com/AmrataRamchandani/moodle/tree/useripmappings/mod/quiz/accessrule/useripmapping

La media da valetaziuns: -
In reply to Amrata Ramchandani

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Tim Hunt -
Maletg da 	Core developers Maletg da 	Documentation writers Maletg da 	Particularly helpful Moodlers Maletg da 	Peer reviewers Maletg da 	Plugin developers

Is the quiz settings form the best place to put this? It might be better to try to add an extra link in the quiz settings block (that appears if you turn on a simple yet/no option in the settings form).

Is that possible? Does it work if you create a lib.php file in your plugin, and put a quizaccess_useripmapping_extend_settings_navigation function in there?

My guess would be that it does not just work. To make it work, you would need to add some code to quiz_extend_settings_navigation in mod/quiz/lib.php, to call a method in each accessrule plugin, to let them add links to the navigation.

If you wanted to code that, i think it would be a good addition to Moodle.



However, to answer the question you asked, I don't know why your form fields are getting added outside the right section. I can't see anything wrong with your code. I think you will just have to debug it.

With your UI, you are using links to open the other pages, and I don't think there is anyway to disable a link in HTML. I think you will ahve to write some custom javascript of some sort. (e.g. change the link to a span if no is selected) or change the links to buttons which can be disabled.

La media da valetaziuns: -
In reply to Tim Hunt

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Amrata Ramchandani -

Hi Tim,

It seems to be a good idea and I tried coding it and it worked,I first did the changes in quiz_extend_settings_navigation in mod/quiz/lib.php file which loop around all the access rule plugins to check a pluginname_extend_settings_navigation function in their respective lib files.If found that link would be added under the Parent Link Access Rules,as you can see in the below image.


Here is the updated plugin code : https://github.com/AmrataRamchandani/moodle/commit/da38acc90ec6c7c6d6d66ef34bdab44dd60e8faa

(skip readme.txt file which is still under construction)

And also,form fields are now getting inside the "Extra Restriction on Attempts" block, I couldn't find the exact problem but it seem to be some naming conflict as by just changing the group name things worked out.

La media da valetaziuns: -
In reply to Tim Hunt

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Amrata Ramchandani -

And, also I have two links named Import Mappings and Edit Mapping inside Manage Mappings Page.

What would be the best way to keep those links ?

 In the manage mappings page or a child of Manage Mappings Link in the Quiz Settings Block. as shown below.



                                                                                     OR



this way ?


I personally felt,keeping the sublinks in the settings block would make the list too long,so we should avoid it.But I still would like to take your inputs.


La media da valetaziuns: -
In reply to Amrata Ramchandani

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Tim Hunt -
Maletg da 	Core developers Maletg da 	Documentation writers Maletg da 	Particularly helpful Moodlers Maletg da 	Peer reviewers Maletg da 	Plugin developers

Since I have not tried your code, I don't know what the difference is between Edit mappings and Manage mappings.

The kind of thing I would expect is that you have one page the just displays a list of all the mappings, with edit/delete links next to each one, and "Add new mapping" button at the bottom. That would also be a logical place to put the import link.

All this could be accessed from a single link in the settings block.


The code https://github.com/AmrataRamchandani/moodle/commit/da38acc90ec6c7c6d6d66ef34bdab44dd60e8faa#diff-60e3ef4888f88976f619dd788dff385aR1843 is about the sort of thing I was thinking of. If you look at how other, similar bits of code work, then you will see that mostly that sort of loop over plugins is doen in the quiz_access_manager class. This is just a layer of encapsulation, to try to keep the code tidy, but it would be nice if your code could follow the same pattern. Thanks for working on this. Once it is tidied up, it would be nice to get the core Moodle chagnes submitted for integration (and your plugin submitted to the plugins database).

La media da valetaziuns: -
In reply to Tim Hunt

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Amrata Ramchandani -

Manage Mappings doesn't do anything,we have just made names it as a common heading for both Import Mappings and Edit Mappings.

We have followed this approach by looking at Upload Users functionality available in Moodle.

1) Import Mappings -> It will take Mappings in CSV format and upload it to DB.

2) Edit Mapping -> It will edit the mapped IP by searching the required student based on provided username or idnumber.We purposely have not kept delete option as we thought that it would be good to maintain the history.Only the latest assigned IP's will be used to limit the student.

Currently,the plugin has the workflow shown in this following document

https://docs.google.com/document/d/1VYXW82I-UHqseKOfZL4PsAQuI-dorCNABIdcs2ezJTg/edit?usp=sharing

Please comment in the document if you find anything not required stuff or needs improvement

I will go through the quiz access manager class and check how it can be linked up to extend navigation.

La media da valetaziuns: -
In reply to Tim Hunt

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Amrata Ramchandani -

Hi Tim,

Can you please elaborate how to link extend navigation function with access manager class ? How the function calls should be ?

Do we want the the plugin_extend_navigation function in the rule.php ? instead of plugin/lib.php ?


La media da valetaziuns: -
In reply to Amrata Ramchandani

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Tim Hunt -
Maletg da 	Core developers Maletg da 	Documentation writers Maletg da 	Particularly helpful Moodlers Maletg da 	Peer reviewers Maletg da 	Plugin developers

It could work either way.

Having a function in lib.php would be more consistent with how other plugins handle navigation.

Having a method in rule.php would be more consistent with now access rule plugins handle everything else.

I don't have a strong feeling which is better.

La media da valetaziuns: -
In reply to Tim Hunt

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Amrata Ramchandani -

Okay,So shall I keep it the way it is now ? i.e a function in lib.php ?

Later in the peer reviewing if somebody finds the better way we can modify the code accordingly ?

Because,rest everything is done from my end,i am waiting to push the code

La media da valetaziuns: -
In reply to Amrata Ramchandani

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Tim Hunt -
Maletg da 	Core developers Maletg da 	Documentation writers Maletg da 	Particularly helpful Moodlers Maletg da 	Peer reviewers Maletg da 	Plugin developers

That sounds sensible.

La media da valetaziuns: -
In reply to Tim Hunt

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Amrata Ramchandani -

Hi Tim,

The tracker issue to integrate the above code is been made.Below is the link for the same

https://tracker.moodle.org/browse/MDL-60597

La media da valetaziuns: -
In reply to Amrata Ramchandani

Re: How to group elements in Quiz Settings, inside "Extra Restrictions on attempts fieldset"

by Tim Hunt -
Maletg da 	Core developers Maletg da 	Documentation writers Maletg da 	Particularly helpful Moodlers Maletg da 	Peer reviewers Maletg da 	Plugin developers

Yes, I saw that. Thanks.

If you were able to get your code onto github, that would make it easier to work with, but if not, I can work with the patch.

La media da valetaziuns: -