Here is a screenshot from one of the Open Atrium 2 tours:

If you do as instructed and click "Group" it will actually end the tour. :-/

The reason is that the tour functionality is dependent on ?tour=tourname&step=X in the URL string, but if the user follows the URL (or submits the form or whatever) themselves, it won't be present:


I've created a patch to Bootstrap Tour that does the following things:

  1. Stores the current tour name in the session, it knows what tour the user was on if they wander off.
  2. If the user shows initiative and goes to the next step themselves, it'll advance the step counter.
  3. And if the user goes to a totally unrelated URL, it'll show a message saying they've wandered off from the tour and give them the option to return or end the tour:

I'll attach the patch in a moment (I need the issue nid)!

Comments

dsnopek’s picture

Status: Active » Needs review
StatusFileSize
new5.79 KB

Patch is attached! Please let me know what you think.

mcrittenden’s picture

Title: When user follows tour instructions, they are taken off the tour! (patch to fix included) » When user follows tour instructions, they are taken off the tour!

Awesome, thanks for the patch!

Before reviewing and committing, I wanted to mention one thing. Bootstrap Tour supports "reflex" mode per step which makes it so that clicking on the element that is being pointed at continues the tour just as if you had clicked the "Next" button. See http://bootstraptour.com/api/ and ctrl+f for "reflex" to see the option.

Maybe turning that on for all steps would help this this? I still think the dialog to confirm leaving the tour and storing the current tour state in the session are smart additions in general though. What do you think?

dsnopek’s picture

I haven't tried "reflex" mode, but looking at the docs, it seemed that was meant for tours that stay on the same page. We can try it!

But also, we don't necessarily know that the users will get to the next page by clicking the element. For example, if it's a content creation form and we're are pointing at the "Title" element (or some other random bit of the form) and the user goes all the way to submit the form, we should take them to the step that is on the following page, regardless of it they clicked the element or not. So, it's about catching up with the user when they showed initiative and did what the tour said, but that can go off the current page.

mcrittenden’s picture

Status: Needs review » Fixed

Awesome, thanks again for this great patch. Pushed to 7.x-1.x in 4c87f68.

dsnopek’s picture

Thanks! Sorry, I never got around to testing 'reflex' but I still plan to! I suspect it won't make sense to be on by default, but it might be useful as an option you can select for some steps. I'll need to mod-up some real tours (probably the OA tours) and see it in practice, though. :-)

spazfox’s picture

This feature, at least as implemented in 7.x-1.0-beta7, is very buggy. I'm having so many issues with it that I'm not even quite sure how/where to begin documenting them. Basically, though, the "you have wandered off from the tour" message is popping up all the time (and seemingly at inappropriate times) and I seem to be unable to cancel the tour at all. It is has rendered this module unusable for me, and I'll need to roll back to a previous version until this is fixed. I'll try to provide more extensive and clear documentation of what I'm experiencing when I get a chance. Is this feature working correctly for anyone else?

dsnopek’s picture

This is has been working for me on Open Atrium with the tours it bundles. I haven't done much testing outside of that context, though.

Can you create a Feature which has one of your problem tours (or minimal steps to create a problem tour) and give the steps to reproduce?

Since I created the original patch, I feel responsible for getting to work right. :-)

spazfox’s picture

I don't have any experience creating Features, but I'll look into doing that if it would help. Has this been tested on a vanilla Drupal 7 install at all? It is behaving very erratically for me (unable to end tours at all, tours resuming at strange times for no reason, tours do not begin on the correct step, the "leaving tour" warning window displaying when it shouldn't, etc.). The module was working fine before beta7.

spazfox’s picture

Status: Fixed » Needs work
mpotter’s picture

I am also experiencing some bad behavior from this patch in the OA 2.15 version.

When in a space that has a custom domain, this is getting the session from the wrong domain. This causes tours to popup in weird places. In particular, it can cause bootstrap_tour.js to get executed on system/ajax urls, which then breaks the ajax callback stuff. I have a very obscure case with media browser that is exhibiting this behavior that I traced to this path.

Because of this and the other issues being reported, I am going to revert this patch for now.

dsnopek’s picture

I talked with Mike Potter today about a reproducible case where tours would start unexpected when using a single site that accessible at multiple domains. Since it's reproducible, I'll look into when I have a chance - new issue here: #2207737: Tours unexpected return on sites with multiple domains

@spazfox: Since I can't reproduce your problems, there's nothing I can do. However, if you post steps to reproduce, I'd be happy to take a look!

dsnopek’s picture

Er, I didn't realize that this was actually reverted in Git! I just assumed Mike was reverting OA to an older version. In that case, my new issue doesn't actually make sense, and I'll work on it in this issue.

Here's the information I had put on that:

Let's say that, for example, you have a site that's accessible at both:

  • sub1.example.com
  • sub2.example.com

... and your tour takes from from sub1.example.com to sub2.example.com, it will initiate a new tour at sub2.example.com, but leave the old tour running on sub1.example.com. When users return to sub1.example.com it'll try to redirect them back to the tour, even if they finished it on sub2.example.com.

I'm not entirely sure the best way to deal with this, but I discussed some possibilities with Mike Potter. Here's some stuff I definitely want to try:

  • Syncing the "tour state" between Javascript and backend. Bootstrap tour stores whether a tour is still running in window.localStorage (which is per-domain!) and we also store it in the session. When a tour is ended, we should make an AJAX call to the server to end it in the session as well. This won't fix that stale data could be on window.localStorage for some domain, but it would prevent us from starting a tour that previously finished on another domain.
  • Prevent URL intiation of tours when it's not on step=1 and the session has no previous record of the tour. When you cross-domains in the middle of a tour, it'll start you on some step in the middle (ie. path?tour=tour&step=4). This would work fine, if the user has configured $cookie_domain so that sessions are stored across domains, but will create problems if not. We can store the domain used when starting the tour and detect if they have $cookie_domain setup properly.

Anyway, not sure what will work in the end, but I have some place to start!

spazfox’s picture

I haven't had time to try to provide reproducible steps on a clean install yet, but in case it is related, I should note that my entire site is running through HTTPS. There is no switching between HTTP and HTTPS, so session cookies should not be lost because of that, but is there something about having secure sessions that could be impacting the patch in this thread? I am not using multiple domains on my site.

dsnopek’s picture

Well, switching between HTTP and HTTPS would have the same effect as switching domains would. But since you're not doing that, there really isn't anything about being on HTTPS that could have an effect. The main site I'm using this patch on is also HTTPS only, and there are no problems. :-/ Anyway, I'll look into the issues Mike Potter found soon and maybe (if we're lucky!) it'll fix your problems too. :-)

dsnopek’s picture

Status: Needs work » Needs review
StatusFileSize
new2.65 KB
new6.99 KB

Ok, here is an attempt to fix the issues that Mike Potter found. Mike can you try this with your use case? I was able to reproduce lots of weirdness with multiple domains, but not the exact system/ajax Javascript error that you had... If it's still present I may need some more info on reproducing it.

I've also included an interdiff too so you can see what I added.

@spazfox: If you have the time to test and see if this has any affect on your problems, that'd be nice too!

dsnopek’s picture

Status: Needs review » Needs work

There are still some issues with my patch for tours with only one step (like the "Welcome to OA2" tour). I'll make a fix soon!

dsnopek’s picture

Status: Needs work » Needs review
StatusFileSize
new7.24 KB
new778 bytes

Ok! I've got a new patch that fixes a number of things:

  • Tours with only one step
  • Tours that have a later step that is on the same path as the first step
  • Correctly detecting the path of the next step, when it's on the same page (and so doesn't include a path in it's definition)

The new patch is attached along with an interdiff from the last one!

I also found a number of weird problems with the Open Atrium tours, which turned out to be problems with those tours themselves - see these PRs for an explanation and fix (already merged):

https://github.com/phase2/oa_core/pull/59
https://github.com/phase2/oa_core/pull/60

At this point, my patch works for me with all the Open Atrium tours AND allows you to actually follow the tour instructions WITHOUT losing the tour! It also doesn't have any problems I can reproduce with multiple domains.

Please review when you have a chance!

dsnopek’s picture

Ah, sorry, I uploaded the wrong patches! :-/ These should be the correct ones. Please just ignore the patches on #17, those were from yesterday before I discovered some of the problems mentioned in that comment.

  • Commit e276a7d on 7.x-1.x authored by dsnopek, committed by mpotter:
    Issue #2191715 by dsnopek: Fixed When user follows tour instructions,...
mpotter’s picture

Status: Needs review » Fixed

Thanks, I appreciate the work on this!

Committed to e276a7d.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.