Skip to content

Add setting to allow tutorials to run on every unique login

omar_compucorp requested to merge omar_compucorp/tutorial:run-onlogin into master

Overview

If you have a public demo site with a single shared demo account (Say similar to https://dmaster.demo.civicrm.org/), you may want to set tutorials so they run once every time a different person login using the same account. At the moment there is a checkbox called "Auto-Run" which allow running the tutorial once per user account but not per unique login:

image

With the work done here, site admins can now create a CiviCRM setting with the key tutorial_runOnEveryUniqueLogin and set its value to 1, which can be done using several ways such as using API v3 or by executing something like this using cv tool:

Civi::settings()->set('tutorial_runOnEveryUniqueLogin', 1);

this setting combined with the "Auto-Run" flag, will ensure that each tutorial will run per unique login, where if this setting is not set then things will just work same as they usually do at the moment.

Technical details

If tutorial_runOnEveryUniqueLogin setting is set to 1, then I check if the tutorial id is stored in the browser cookies, if not then I mark the tutorial as not viewed, and then store the tutorial id with value = "viewed" in cookies to prevent it from running again.

Also given that I don't check the session id (which I don't think is necessary), this means that if the same person logs in then logs out using the same device and browser, then the tutorial won't show up again for that person, but if they use separate browser or incognito mode then the tutorial will show up again.

Merge request reports