Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: {mycoursescards[ categoryID(s)]} tag gets left behind #278

Open
8 of 11 tasks
Thomas-Nichay opened this issue Nov 10, 2023 · 4 comments
Open
8 of 11 tasks

Bug: {mycoursescards[ categoryID(s)]} tag gets left behind #278

Thomas-Nichay opened this issue Nov 10, 2023 · 4 comments

Comments

@Thomas-Nichay
Copy link

Thomas-Nichay commented Nov 10, 2023

Prerequisites

  • I'm reporting the issue to the correct repository.
  • I am running the latest version of this plugin (if not, please upgrade first).
  • I checked the README.md and Wiki documentation but did not find my answer.
  • I searched to make sure that this issue had not already been reported.
  • I have, or I know someone who has, the ability and willingness to test the fix on a Moodle LMS-based site.
  • I am submitting no more than one bug report per issue ticket (please do not submit multiple bugs in one issue ticket).
  • I understand that support is provided by volunteer(s).

What happened?

When {mycoursescards[ categoryID(s)]} is used with the optional categoryID parameter but the query finds no courses, the tag does not get replaced with an empty string, being shown in whatever content like it was not filtered.

What do you think should have happened?

I expected that if the query doesn't find any course to generate cards, to not show anything, not even the original tag.

Steps to reproduce

  1. Login as 'admin'
  2. Go to dashboard (or wherever you can create a test block)
  3. create/edit a block and add the filtercode {mycoursescards 0} to the editor and save it.(any other category id with no courses that the user has been enrolled in gives the same result)
  4. See that instead of the block being either blank or have course cards rendered, it show the string for the tag itself.

Screenshots

No response

Moodle version

Moodle 4.1.5 (Build: 20230814)

Installed Moodle UI Language packs.

  • English only
  • One or more other languages/regional dialects (specify below)
  • Other

If other language(s), please specify

No response

Workaround

No response

Additional information

i fixed it locally by adding

else {
    $replace['/' . $tag . '/isuU'] = '';
}

to the line 2932 of filter.php

if (!empty($content)) {
$replace['/' . $tag . '/isuU'] = $card->header . $content . $card->footer;
}

System information

No response

Code of Conduct

@michael-milette
Copy link
Owner

Hi @Thomas-Nichay ,

FilterCodes only processes valid tags. If a tag is not valid, as is the case with an invalid category ID, the tag is not interpreted so that you can see that it is not working.

Best regards,

Michael

@Thomas-Nichay
Copy link
Author

Thank you for explaining @michael-milette,
I still believe this should be looked at. because even when a valid category id is given with plenty of courses in that category, if a student has not yet enrolled in any of those courses, they will still get presented with a "debug message" in the form of a tag that they are not intended to see or comprehend.

In such cases, cases an empty return would be much more preferable.

@michael-milette
Copy link
Owner

Hi @Thomas-Nichay

If you are trying to display courses in which the user may or may not have yet enrolled, you might want to consider using the {coursecards} tag instead. Sounds to me like this might better suit your needs.

Best regards,

Michael

@Thomas-Nichay
Copy link
Author

I was trying to keep the issue generic, in terms of use cases, but in my specific use case, I am attempting to beautify the category navigation, giving students an easier way to view courses they are enrolled in, while concealing those they have chosen not to enroll or have yet to enroll. The enrollment process is handled separately.

The results are a navigation panel that works really well with the breadcrumb links in each course no matter the category they are in.

Click to expand

filled

The mycoursescards tag works great for this, besides the fact of the debug error message if it ends up not finding any courses enrolled. If the result is empty i am able to give an actual error message with some feedback "No enrolled courses in this category" but printing the full tag as it is, prevents this form being handled instantly with css.

Tag returning empty string:

working

Tag returning itself as debug:

broken

This is why i think this behavior as it is now is undesirable, filtercodes didn't hit anything invalid it just found an empty query result that is correct to be returned as empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants