michael-milette / moodle-filter_filtercodes

FilterCodes filter for Moodle enables content creators to easily customize and personalize course and site content using plain text tags (no HTML). For premium support, contact us at https://www.tngconsulting.ca/contact
https://moodle.org/plugins/filter_filtercodes
GNU General Public License v3.0
32 stars 43 forks source link

[BUG] Method "hasonlyarchetype" return wrong result #210

Open erickcomp opened 2 years ago

erickcomp commented 2 years ago

The method "hasonlyarchetype" used for {ifstudent} filter returns wrong result. After verifying that user has no other archetypes, code checks if user is site_admin, but it's returning true when user is_siteadmin and false otherwise. It should be the opposite of it.

michael-milette commented 1 year ago

Hi @erickcomp ,

Thank you for this and your pull request. Could you please share the details of a sample scenario with me?

It tries to identify if you have a specified archetype. If you do, or you switched roles, or you are a site admin, it returns true. Otherwise false. This was done so that Site Administrators always end up returning true.

While I am not sure that I agree with your proposal. I think there is room for improvement here. Ideally, in my opinion, the code should be revised to include the following logic:

Looking forward to your thoughts and example on this.

Best regards,

Michael