moodle-an-hochschulen / moodle-availability_password

Moodle availability plugin which lets users restrict resources and activities with password access
GNU General Public License v3.0
4 stars 6 forks source link

Problem with display restriction section in lessons #22

Closed smokwawelskine closed 1 year ago

smokwawelskine commented 1 year ago

I have a problem with the "Restriction by password" (moodle-availability_password) plugin on Moodle 3.11.4 (Build: 20211108). I can install and set restrictions properly in activities and resources settings, but there is a problem when I want to change the password or show the restriction configuration which was set in the lessons. I can't expand the restriction section in the lesson edit menu (in other activities and resources it works well). Any idea how to fix it?

alina-kiz commented 1 year ago

Hi, I think, I have the same problem. I create an External tool activity and set a Restriction by password, then save and return to course. When I go to change the Restrictions, I can't expand the restriction section. By inspecting the HTML can you see that div with id="fitem_id_availabilityconditionsjson" gets a style="display:none;" hidden = "hidden"

I have it try on Moodle 3.9.19+ (Build: 20230210) and Moodle 4.1.1+ (Build: 20230210)

abias commented 1 year ago

Hi @smokwawelskine and @alina-kiz ,

thank you for highlighting this issue.

After some debugging, I found out that the lesson activity has a "Password protected lesson" form field and the external tool activity has a password form field as well. Now, when the activity settings are shown, JavaScript code is run by Moodle core which hides particular form fields based on some conditions.

Unfortunately, the password field of this plugin just got the internal name "password" when it was implemented. Against this background, the Moodle core code found this field and hid it even if it wanted to hide something completely different on the same page.

I will fix this by changing the name of the internal name and will publish a new release of the plugin soon.

Cheers, Alex