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
30 stars 42 forks source link

Feature Request: {activityid} - See {coursemoduleid} #256

Closed lxd1979 closed 9 months ago

lxd1979 commented 1 year ago

Prerequisites

Feature Request - The User Story

Hi Michael

Thank you for this plugin, it is is superb.

I've been using the filters below to manage instructions for students based on their state of completion within an activity. {ifactivitycompleted id}{/ifactivitycompleted} {ifnotactivitycompleted id}{/ifnotactivitycompleted}

It would really help if the id could be pulled from the current activity rather than manually entering it. This would also reduce the effort associated with editing the ids in restored courses. Therefore I propose a new {activityid} that can be used in conjunction with those exisiting filter codes.

Thanks

Screenshots / Mock-ups

No response

Alterative you have considered

I've tried playing around with the {scrape} filter but to no avail.

Additional information

No response

Planning on submitting a solution in a pull request (PR)?

Yes

Code of Conduct

michael-milette commented 1 year ago

Hi @lxd1979 ,

Thank you for your suggestion of a new {activityid} tag. However, that functionality currently exists in FilterCodes since version 2.2 released in May 2021. The tag is called %7Bcoursemoduleid%7D. The curly braces are escaped because it was originally intended for use in a URL. Note that this tag only works in an activity.

I also just added a {coursemoduleid} tag with the curly brackets. If you would rather use that version, download the latest version available here on GitHub and please let me know if it works for you. Either way, the curly braces version will be included in the next release of FilterCodes.

Best regards,

Michael

lxd1979 commented 12 months ago

Hi Michael

Thank you for getting back to me. %7Bcoursemoduleid%7D displays the activity id. However, it does not work in conjunction with {ifactivitycompleted id}{/ifactivitycompleted}e.g. ifactivitycompleted %7Bcoursemoduleid%7D}{/ifactivitycompleted} it displays the id but the filter displays the string and the information between the curly brackets whether the activity is completed or not. It will only work if activity id is manually entered e.g. {ifactivitycompleted 98795}{/ifactivitycompleted}, as described in the documentation. Is it possible to specify 'this activity' in the filter, so if for example a course is copied the rules from the filters persists.

Thank you!

michael-milette commented 12 months ago

Hi @lxd1979 ,

Got it! I should be able to fix that. Will let you know as soon as it is ready again for testing.

Best regards,

Michael

michael-milette commented 11 months ago

Hi @lxd1979 ,

Great news! You can now embed any of the following tags including the "coursemoduleid" tag that you requested:

In your case, you can now do something like this:

{ifactivitycompleted {coursemoduleid}}You're done!{/ifactivitycompleted}{ifnotactivitycompleted {coursemoduleid}}You're not done yet!{/ifnotactivitycompleted}

This change is currently only available in the version of FilterCodes here on GitHub. I would be thankful if you would be so kind as to try it out and let me know if it works for you. If it does, this change will be included in the next release of FilterCodes.

Best regards,

Michael

michael-milette commented 9 months ago

Hi @lxd1979 ,

As it has been almost 2 months since I last heard from you, I will assume that this is all working correctly. This will be included in the upcoming release on moodle.org within the next few weeks.

Thanks again for the Feature Request.

Best regards,

Michael