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 45 forks source link

Feature request: {ifactivitycompleted} and {ifnotactivitycompleted} tags #163

Closed davefoord closed 2 years ago

davefoord commented 3 years ago

Would it be possible to add a filter code that is based on the completion of another activity within the course? If it was, then this would be really useful.

Not sure exactly now this would work - as we would want something that updates if a course is backed up and restored, so the restored course updates to the new activity not the original activity. Could we include the activity URL in the filter code?

michael-milette commented 3 years ago

Hi @davefoord ,

It would be possible to create an {if...} tag that is based on the completion of an activity however it is not possible to have it change when you clone or backup/restore the course unless it is referring to the activity in which it is currently embedded (basically itself).

Michael

davefoord commented 3 years ago

I guess this would be OK, as long as we put a big caveat in the information page, so people are aware of this, and use the feature accordingly.

michael-milette commented 3 years ago

Hi @davefoord ,

Could you please provide me with a use case of how you would use this?

I am also not clear on what information page you are referring to.

Best regards,

Michael

davefoord commented 3 years ago

Hi @michael-milette - when I say information page. I mean this page https://moodle.org/plugins/filter_filtercodes (and the equivalent on github).

The use case scenario for me, is I have a course, where I have created my own 'tiles' which link to the different activities (see image)

image

Some of the tiles are links to other courses, and some are links to activities within the course. This looks far better than anything I can do with any of the other Moodle formats (and I have tried a lot of them), but it isn't as clear to the user which ones they have completed and which they haven't.

If I have an {if} filter code, I can basically have pairs of tiles for each item, one is if they haven't completed it, and looks as present, and then other one is then for if they have completed that activity in which case they see the same image, but with a 'completed' banner across the corner or similar.

I really appreciate the work you do on this plugin (which is at the moment, my favourite Moodle plugin), and if my use case is really obscure and not likely to be used by others, then don't spend time working on it.

My other request about course completion, is related to this one, if creating an if statement on course completion was easier, then I can at least identify the links to other courses that are complete, whereas with activity completion I could do both (as I am using the sub-course activity to link to courses.

michael-milette commented 3 years ago

Hi @davefoord ,

Thank you. This is actually a really good explanation and I can see how it would be useful to identify completed courses. Activity completion is a bit more of a stretch. I will need to give that one more thought. Putting this issue in the backlog for now. I will see what I can do about the other ticket for an {ifcoursecompleted} - or something like that.

You might also want to take a look at the Completion Progress plugin to help people identify activities in a course that have yet to be completed. It can be installed in both a course and on the dashboard.

Best regards,

Michael

davefoord commented 3 years ago

Hi @michael-milette - Yes I am using the Completion Progress block already (see screenshot below), I am just trying to make this really, really good.

image

And you will also notice the 'Your Details' block above it, which uses filter codes to populate the information.

baris83 commented 2 years ago

Hi @michael-milette first of all i'd like to thank you for such a useful plugin. I'm also interested in this topic. I create courses based on custom layouts and in this part i should also thank @davefoord too. I'm a big fan of his video tutorials. I'm surprised that we both needed the same functionality.

I'll try to explain my situation. As you will see in the image below, i'm not showing the activities directly to the students. student

When there is an order that they have to follow, it is not such a big deal. I can manage that with restrictions and combinations of buttons (image below). But if there is no priority order (in some courses i have tens of activities), it gets comlicated. admin

That would be a wonderful feature for course designers.

davefoord commented 2 years ago

Glad that you like my videos @baris83

I understand the problem that you have, and I too have tried to find a solution to this, but have not succeeded. One option (which doesn't use filter codes) is to show your buttons vertically rather than horizontally, and for each button you actually have a pair of buttons, one that is green and one that it blue, the green one shows if the corresponding activity is completed, the blue one shows if the activity isn't complete - and the student will see one or the other but not both.

So what I think @baris83 is asking, is whether it is possible to create a filter code to show or hide content based on activity completion or not completion - as with that it would be possible to show the buttons horizontally in a single label, rather than vertically as I have described above.

baris83 commented 2 years ago

Hi @davefoord that's exactly what i'm doing right now (showing button vertically) and that really limits the creativity. That feature can provide much more flexibility for a course layout design.

michael-milette commented 2 years ago

Hi @davefoord and @baris83

You asked for it, you got it!

In order for these tags to work, they require:

  1. That completion be enabled for the site
  2. That completion be enabled for the course
  3. That the specified activity id exists in the current course. Be sure to replace "id" with the activity id found in the URL of the link to the activity.
  4. That completion criteria be configured in the specified activity.

Otherwise, the tags will be displayed instead of being filtered.

Reminder: Activity IDs change when you copy or restore a course. In such cases, you will need to manually edit and correct the IDs in the tags to reflect the new activity id numbers so as to restore their functionality.

If you would be so kind as to try the new {ifactivitycompleted id}{/ifactivitycompleted} and {ifnotactivitycompleted id}{/ifnotactivitycompleted} tags out and get back to me with your feedback (good or bad), it would be much appreciated. AS they are meant to be used in a course, I have only tested it from within courses so far, but there is a good chance that it will also work on the Front page.

These new tags are currently only available here on GitHub. If there are no issues, it will be released on Moodle.org around the same time as the upcoming Moodle 4.0.

Best regards,

Michael

michael-milette commented 2 years ago

@davefoord I love your Moodle (and FilterCodes!) videos too. Thank you so much for your support. It is really very much appreciated.

baris83 commented 2 years ago

Hi @michael-milette,

Thank you so much for your support, you made my day :) As you will see below it's working as expected. I'd like to ask if we can use these tag in nested conditions like {ifactivitycompleted 143}{ifnotactivitycompleted 146} Code here ... {/ifnotactivitycompleted }{/ifactivitycompleted} testActivity

michael-milette commented 2 years ago

Hi @baris83 ,

{ifactivitycompleted 143} {ifnotactivitycompleted 146} Code here ... {/ifnotactivitycompleted} {/ifactivitycompleted}

Should work. Make sure there are no spaces inside the closing tag (as seen in your example). However:

{ifactivitycompleted 143} {ifactivitycompleted 146} Code here ... {/ifactivitycompleted} {/ifactivitycompleted}

...or...

{ifactivitycompleted 143} {ifactivitycompleted 146} Code here... {/ifactivitycompleted} Code here ... {/ifactivitycompleted}

...would not work as expected because the parser will not match up the identical nested closing tags correctly. The first opening tag would match up with the first closing tag instead of the last closing tag.

Hope this helps.

Best regards,

Michael

michael-milette commented 2 years ago

Very nice by the way! 🙂👍

davefoord commented 2 years ago

I have tested this, and works superbly - this is really, really useful. Thanks for doing this.

michael-milette commented 2 years ago

Thanks for testing Dave. I really appreciate it.

Best regards,

Michael