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

{wwwroot} tag issue for students (when using Log In As) #205

Closed brunohcury closed 2 years ago

brunohcury commented 2 years ago

Hello Michael, I'm using the following link inside atto:

For my admin user, the link is working correctly, but in the student's view the filtercodes cannot interpret the tags, see the images below. Can you help me Thank you very much

view-admin view-student

michael-milette commented 2 years ago

Hi @brunohcury

First thing I would do is to try the latest version of FilterCodes here on GitHub. I recently fixed several regex parsing issues for many of the tags.

I have seen this issue with tags in URLs when people are using nginx, in front of Moodle, which has not been configured correctly. Without nginx, it seems to work properly in my experience.

If that is not it, this can so happen if the PHP developer is using is different code depending on the role. The output of the PHP code must be passed through the format_text() or format_string() Moodle Output API functions. If that is not the case, the only way to fix it would be to have the PHP code fixed.

I have yet to reproduce the issue myself locally or on any server to which I have access. Until I can, I will be unable to troubleshoot. I am always willing to offer my troubleshooting services.

That said, I suspect that it might be due to nginx. When my clients have fixed their nginx configuration, the problem seems to go away.

For more information, see the Moodle documentation on configuring nginx. If you do figure out the setting which is causing this, please share if you can. I would add it to the FilterCodes documentation. I am sure tjat would help out many others.

Best regards,

Michael

brunohcury commented 2 years ago

Hello Michael, Thanks for the quick response. I believe this is not so. Because as an administrator it works normally, only as a student the {wwwroot} filter cannot be applied.

michael-milette commented 2 years ago

Can you tell me exactly where you are putting the link to the page? I need enough information in order to be able to reproduce the problem on my own sites.

brunohcury commented 2 years ago

I am inserting the link inside the resource page in the atto editor.

link-atto preview

michael-milette commented 2 years ago

Hi @brunohcury ,

Using version 2.2.8 (2022033123) version of FilterCodes here on GitHub, I put your exact HTML code into a page and it worked perfectly.

<div style="text-align: left;" class="attostylebox-solid atto-stylesbox-solid-blue" data-uw-styling-context="true"><span style="font-size: x-large;" data-uw-styling-context="true"><span class="" style="font-size: x-large;" data-uw-styling-context="true">1 -- Collelacao entre marketing e logistica</span></span>
    <p style="float:right; " data-uw-styling-context="true"><a href="{wwwroot}/course/view.php?id={courseid}#section-{sectionid}" class="btn btn-outline" style="font-size:14px; color:#fff; text-decoration:none;" data-uw-styling-context="true">[fa-undo] VOLTAR</a></p>
</div>

You can easily get the version of FilterCodes by using the {filtercodes} tag.

Unfortunately, it looks like this is an issue specific to your Moodle installation. Let me know if I can be of service to you in this matter.

Best regards,

Michael

michael-milette commented 2 years ago

Hi @brunohcury

I noticed that you are also using another filter, the FontAwesome plugin, which is not working either. I can see the [fa-undo] tag.

Did you know? FilterCodes also supports FontAwesome icons.

In your example using the FontAwesome plugin: [fa-undo]

In FilterCodes it would be: {fa fa-undo}

Best regards,

Michael

brunohcury commented 2 years ago

Hello Michael, Good to know that FilterCodes can also be used with FontAwesome. About the HTML code, here in my Moodle it works normally in the admin user, but when I am logged in as a student, the link does not work, when I move the mouse over the link the student sees {wwwroot}, and the tag {fa fa-undo} it works perfectly. I still haven't figured out what it could be. Did you test the link as a student? Thanks in advance for your immense help.

brunohcury commented 2 years ago

Michael,

My FontAwesome is working correctly, the print sent shows the tag in page editing mode in the atto editor, but when saved to display the content, it is normal.

michael-milette commented 2 years ago

Yes, I tested it both as a student and as an administrator. It worked perfectly as designed.

I am not sure what more to tell you. I can see in your screenshots that the other tags in the URL are working so obviously FilterCodes is correctly configured. The only times I have ever seen this happen, NGINX was involved. I can only suggest that you contact your server administrator and check with them.

The last time this happened (last year), I sent the following link to the server administrator (I did not have access to the server config).

https://docs.moodle.org/en/Nginx

Two hours later, he emailed me back and said that the problem was solved and that it was related to nginx being used as a proxy server in front of the server. Unfortunately he never answered my request to find out what it was that he changed.

Hope this helps.

Best regards,

Michael

brunohcury commented 2 years ago

Hello Michael, Thanks for your prompt help. Find out the problem. This is happening when "access as student", this way shows the {wwwroot} tag in the url, however, when accessing directly with the student's username and password, the problem is not displayed. Will it be a bug? Thanks in advance for your help

michael-milette commented 2 years ago

Hi @brunohcury ,

"Log in as" has a bug in Moodle. I have experienced it before where Moodle rewrites some HTML during output. It is not clear to me why Moodle processes HTML differently when using that feature.

For more information, see:

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

Please vote for this issue if you agree that it needs to be fixed.

I am not sure if there is anything more I can do from a filter point of view.

It is good to be aware of this. Good catch and thank you for sharing your findings.

Best regards,

Michael

michael-milette commented 2 years ago

I just added a note in the FilterCodes documentation for issues relating to both the use of nginx and log in as. Thank you!