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

{mygroups} and {ifingroup} #221

Closed garetharnott closed 2 years ago

garetharnott commented 2 years ago

Hi Michael,

I noticed a weird thing - the {ifingroup xx}{/ifingroup} tags would not work on a page (in this case a book) where I also used the {mygroups] tag. At first I found it weird that the {ifingroup} tag was not working, when it worked fine on another page. Then I copied the text directly from the other page and it still didn't work. Then I decided to delete the {mygroups} tag and then {ifingroup} worked. I also had another tag {participantcount} which worked and didn't affect anything whether it was there or not.

Sorry - I know bugs can be a bug - but I thought I should report it.

regards Gareth

michael-milette commented 2 years ago

Hi @garetharnott ,

Don't apologize. I appreciate learning about bugs and fix them rather than have people get frustrated and give up saying that FilterCodes doesn't work.

I will look into this but need your help in reproducing the problem. Could you please tell me exactly where you place the tags and provide me with a sample of text that includes the tags (order may matter) that does not work?

Also, when it does not work, does it simply display the tag or does it get replaced with incorrect information?

Best regards,

Michael

garetharnott commented 2 years ago

Hi Michael,

The original place I noticed this was in a rather complicated chapter (3 column table with three different languages), but I have reproduced the bug in a simple label with no other text other than the {mygroups} or {ifingroup} tags. Order does not matter - whenever {mygroups} is present {ifingroup} produces nothing (blank). I then tried the same thing in another course (different module) from last year and the same thing happened. There I had {alternatename} {mygroups} and {ifingroup}. {ifingroup} gave a blank. I moved {mygroups} to last position, and {ifingroup} still did not work. I deleted {mygroups} and {ifingroup} worked, I deleted {alternatename} and added back {mygroups} to last position and {ifingroup} was again blank.

My completely ignorant guess is that {mygroups} is somehow stealing or overwriting the processing of {ifingroup}.

Do you get the same result?

I do not know 100% which Moodle we are on, but it is at least 3.10. If you need more information let me know what so I can get it from the IT guys.

kind regards Gareth

michael-milette commented 2 years ago

Found the bug. You were right, I had a variable called $mygroups that was used for both tags. One clobbered the other if they were both used. An error was displayed when debugging mode was enabled to the DEVELOPER level:

Warning: Invalid argument supplied for foreach() in filter/filtercodes/filter.php on line 3053

I should have that fixed shortly.

Michael

michael-milette commented 2 years ago

Hi @garetharnott ,

I believe the issue has been resolved. If you would be so kind, I would appreciate it very much if you would install the latest version here on GitHub and let me know if it resolves the issue for you.

If it works, I will push the fixed version to Moodle.org shortly after.

Best regards,

Michael

garetharnott commented 2 years ago

Hi @michael-milette

Well done and thanks! I don't have the capability as I am not admin, but I have contacted our support staff and asked if they can test on the development site. I'll let you know when I get feedback.

regards Gareth

garetharnott commented 2 years ago

Hi Michael - I have been able to test the update and it works (a big shout-out to our IT guys who pulled some strings).

many thanks! Gareth

michael-milette commented 2 years ago

Thanks for letting me know. That is good news. I will push the update out on Moodle.org in the next few days.