Tutorials #

Read more about the Tutorials system in Hiro here.

Functions #

Get #

Get all tutorials defined and progress made by the user towards them.

1
2
3
4
5
6
userId := "userId"

tutorials, err := systems.GetTutorialsSystem().Get(ctx, logger, nk, userId)
if err != nil {
  return err
}

Accept #

Mark a tutorial as accepted by the user.

1
2
3
4
5
6
7
tutorialId := "tutorialId"
userId := "userId"

tutorial, err := systems.GetTutorialsSystem().Accept(ctx, logger, nk, tutorialId, userId)
if err != nil {
  return err
}

Decline #

Mark a tutorial as declined by the user.

1
2
3
4
5
6
7
tutorialId := "tutorialId"
userId := "userId"

tutorial, err := systems.GetTutorialsSystem().Decline(ctx, logger, nk, tutorialId, userId)
if err != nil {
  return err
}

Abandon #

Mark a tutorial as abandoned by the user.

1
2
3
4
5
6
7
tutorialId := "tutorialId"
userId := "userId"

tutorial, err := systems.GetTutorialsSystem().Abandon(ctx, logger, nk, tutorialId, userId)
if err != nil {
  return err
}

Update #

Modify a tutorial’s current step for a user.

1
2
3
4
5
6
7
8
userId := "userId"
tutorialId := "tutorialId"
step := 2

tutorials, err := systems.GetTutorialsSystem().Update(ctx, logger, nk, userId, tutorialId, step)
if err != nil {
  return err
}

Reset #

Reset all known state for the given tutorial(s).

1
2
3
4
5
6
7
userId := "userId"
tutorialIds := []string{"tutorialId_001", "tutorialId_002"}

tutorials, err := systems.GetTutorialsSystem().Reset(ctx, logger, nk, userId, tutorialIds)
if err != nil {
  return err
}

Hooks #

SetOnStepCompleted #

1
2
3
4
5
6
systems.GetTutorialsSystem().SetOnStepCompleted(OnStepCompleted)

func OnStepCompleted(func(ctx, logger, nk, userID, tutorialID string, config, resetCount, step, prevStep)){
  // Take additional actions.
  return nil
}