Talk:User tours

From MoodleDocs

I have a number of questions about User tours, but this page is quite a good starting point. There is no forum topic in Moodle in English for them, so it's difficult to filter posts about User tours although very few seem to exist at all.

  • What options for troubleshooting are there?
  • When can we expect the UI to be upgraded to draggable items as in main course pages?
  • What is a 'tab stop'? What does this section even mean?

"A note about user tours and keyboard focus (tab stops)

If you test your user tour with the keyboard, you may notice that sometimes there appear to be two tab stops where there should be one. For example if you have the HTML

and use the CSS selector .my-link for your tour step, then, while the tour is visible, it will appear that there are two tab stops for the one link. This is because the target of the tour is always made into a tab stop.

The way to avoid this is to target the tour at the link itself in your tour, using .my-link a. The same thing applies in other similar situations. "

Avoid query params in user tour URL patterns

I just encountered a problem with a user tour not working, because it had a URL pattern like "/course/view.php?id=2" as (previously) specified in this manual page.

The problem was that the course was using the Onetopic course format plugin, and that internally sets the current page's URL to ".../course/view.php?id=2&section=0". This change is not visible in the browser's address bar, but the user tours matcher goes on what's in the "$PAGE->url" global variable rather than what's in the address bar. And since the pattern has no "%" wildcard, the user tours looked only for an exact match and didn't find it. The result is that the user tour wouldn't show, even though the pattern seemed to match what was in the address bar.

Now this is probably the worst-case, because it's dependent on using a non-core plugin that changes the page URL without redirecting. But more broadly, the pattern matcher used by user tours is extremely simple and doesn't parse the URL at all. So for instance if I had changed it to "/course/view.php?id=2%" (with a "%" at the end), that would indeed match in the case of additional params, but it would also match any ID that starts with 2 such as 21, 242987, etc. Also, it would fail if the params were in a different order, such as ".../course/view.php?section=0&id=2".

So I'd say, be careful using query params in your URL pattern, because the match will be fairly brittle. In the case of courses, there is also a user tour filter setting to match the course, so the query params are not necessary.