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: "Visibility" #196

Closed bfriesenvcc closed 2 years ago

bfriesenvcc commented 2 years ago

It would be awesome if there were a tag for course visibility. :-) Love this plugin!

michael-milette commented 2 years ago

Interesting! Can you give me an example of how you would use this?

bfriesenvcc commented 2 years ago

Using FilterCodes, we've created a "sticky block" called, "Need Help?" This block expands to show useful links, but some of the most important things (in our opinion) are visible at the top. If there were a visibility tag, we would add the line "Course Visibility: HIDE" or "Course Visibility: SHOW." Something like that, anyway. :-)

Hmm... now that I've written that out, I'm thinking it may be better to have conditional filters like {ifhidden}{/ifhidden} instead.

Collapsed view:

NeedHelp1

Expanded view:

NeedHelp2
michael-milette commented 2 years ago

Hi @bfriesenvcc ,

Why would you want to show the course visibility status to students? If the course visibility is set to hidden, students would not be able to access the course.

On a side note, if you don't mind, I am very curious on how you created the expandable sticky block using FilterCodes. Would you mind sharing?

Best regards,

Michael

bfriesenvcc commented 2 years ago

Sorry, Michael. I neglected to mention that we use your filtercodes to show the students something else in the same block: needhelpstudents

The previous images are what course editors only will see.

So, I created an HTML block on the front page of Moodle and set the page contexts settings to "Display throughout the entire site."

I then went to edit the HTML within a random course, immediately changing Display on Page types setting to "Any type of course main page."

I then added the content of the block which contained all of the code and made great use of your filtercodes. needhelpcode

Previously, I used permissions to show a sticky block only to editors and NOTHING to students. However, somewhere around Moodle 3.2 (I think) the permissions trick stopped working for sticky blocks and only worked for regular blocks. Then I got the idea of using your filtercodes and it saved us.

michael-milette commented 2 years ago

Hi @bfriesenvcc ,

Nice! Thank you.

I am still not clear on why you would you want to show the course visibility status to students. It sounds to me like all you are really looking for is a set of {ifnotvisible}{/ifnotvisible} tags or something like that which would enable you to display a warning when the course is not set to "show".

Michael

bfriesenvcc commented 2 years ago

No, the student view doesn't show the course visibility. They only see the suggestion to report issues to the instructors. Only the course editors see the view that would include the visibility. And, yes, I think the if/ifnot tags would do the job nicely because I could word it any way that I chose.

michael-milette commented 2 years ago

Thanks for your feedback. Last thing before I do this. Do you understand that this tag will only work in a course? It will not work outside of the course or in course listings.

bfriesenvcc commented 2 years ago

Yes, that makes sense to me and that's how I plan to use it. :-)

michael-milette commented 2 years ago

ok, give me a few minutes. I am testing it now.

michael-milette commented 2 years ago

Hi @bfriesenvcc ,

Just pulled it out of the oven! Looks ready to me. If you have a few minutes, I would really appreciate it if you could test the new tag for me and let me know if it meets your needs. Here is an example of how it could be used:

{ifnotvisible}Warning: Course visibility is set to Hide.{/ifnotvisible}

Please note that this new tag is only available here on GitHub at the moment. It will be released on Moodle.org around the same time as Moodle 4.0.

Best regards,

Michael Milette

bfriesenvcc commented 2 years ago

Michael, you are truly amazing! I will try to test before I leave today. I'm pretty sure I can get that done.

bfriesenvcc commented 2 years ago

It seems that I cannot use nested conditionals.

The screenshot shows my block on the right and, on the same page, a label resource in the content area. The ifnotvisible is working as expected in the label, but not in my block. I suspect it's because I'm trying to put the {ifnotvisible} inside the {ifminassistant} code:

{ifminassistant}This is for course editors only. {ifnotvisible}Warning: Course is set to Hide!{/ifnotvisible}{/ifminassistant} ifnotvisible

michael-milette commented 2 years ago

Hi @bfriesenvcc ,

It works fine for me exactly as you typed it. Here is the code that I put into an HTML block:

{details}{summary}More information{/summary}
Contact us for help.
{ifminassistant}This is for course editors only. {ifnotvisible}Warning: Course is set to Hide!{/ifnotvisible}{/ifminassistant}
{/details}

Some people have mentioned that extra codes get pasted into the editor when they copy from GitHub and paste in Moodle's Atto editor. Take a look at the HTML view to see if some unexpected characters might have accidentally been added to your text.

Best regards,

Michael

bfriesenvcc commented 2 years ago

OK, I've done quite a bit of playing around, and pulling out of hair, but I've solved the issue IN MY CASE.

Basically, long story short, I believe it was related to the use of {courseenddate} when the end date was disabled for that particular course.

Any of the following methods solved the problem:

  1. Adding an end date to the course (easy solution, but we have issues forcing end dates)
  2. Adding a line break in the SOURCE code before the {ifnotvisible} (also easy but took forever to realize this)
  3. Moving the {ifnotvisible}{/ifnotvisible} above the course end date.
  4. Adding a paragraph break after the {courseenddate} entry and (for some reason) removing the class="" from the

    tag.

To reproduce the first two methods, mentioned above:

  1. Paste the following source code into an HTML block of a course with no end date:
    <p>Your Course ID is <strong>{courseid}</strong><br> Start date: {coursestartdate}<br>End date: {courseenddate}<br>{ifnotvisible}<strong>Warning: Course visibility is set to Hide</strong>.{/ifnotvisible}<br>{ifeditmode}editing is turned on.{/ifeditmode}
    </p>
  2. Notice that neither the ifnotvisible nor the ifeditmode warnings are showing.(image1)
  3. Go enable the end date of the course and save.
  4. Notice that both ifnotvisible and ifeditmode warnings are showing.(image2)
  5. Disable the end date, again.
  6. Notice that, once again, neither the ifnotvisible nor the ifeditmode warnings are showing.(image1)
  7. Edit the course code of the block, simply adding a line break before {ifnotvisible} (images 3 and 4)
  8. Notice that both the ifnotvisible and ifeditmode warnings are showing again.

Image1:

Image1

Image2:

Image2

Image3:

Image3

Image4:

Image4
michael-milette commented 2 years ago

A couple of questions:

  1. What version of Moodle are you using?
  2. Are you using NGINX?
bfriesenvcc commented 2 years ago

We're using Moodle 3.9.11, but I had to Google NGINX, so I'm going to say "no."

jb-fol commented 2 years ago

This is a really nice filtercode! Just sharing an example for others to see if interested:

Screenshot 2022-01-25 at 22 51 58

{ifnotvisible}
<div class="samsc-warning">
    <h5 class="card-title">This course is not visible to participants!</h5>
    <a href="/course/edit.php?id={courseid}"><i class="fas fa-cog" aria-hidden="true"></i> Edit settings</a>
</div>
{/ifnotvisible}

<h5 class="card-title">Quick Links</h5>

{ifincourse}
<ul class="fa-ul" style="margin-left: 0;">
    <li><span class="fa-li"><i class="fas fa-users" aria-hidden="true"></i></span><a href="/user/index.php?id={courseid}">Course Participants</a></li>
    <li><span class="fa-li"><i class="fas fa-chart-line" aria-hidden="true"></i></span><a href="/report/completion/index.php?course={courseid}">Completion Report</a></li>
    <li><span class="fa-li"><i class="fas fa-bullhorn" aria-hidden="true"></i></span><a href="/mod/feedback/index.php?id={courseid}">Evaluation Form</a></li>
    <li><span class="fa-li"><i class="far fa-file" aria-hidden="true"></i></span><a href="/mod/customcert/index.php?id={courseid}">Certificates</a></li>
</ul>
{/ifincourse}

<ul class="fa-ul" style="margin-left: 0;">
    <li><span class="fa-li"><i class="fas fa-graduation-cap" aria-hidden="true"></i></span><a href="/course">All courses</a>
    </li>
</ul>
bfriesenvcc commented 2 years ago

Great example, jb-fol!