History

Add wentToEntry step to tutorial

Ryan Huffman committed 10 years ago

Commit dd4e06e1 parent e3ee7a22 files · +36 −6Browse files

Showing the changes to tutorial/tutorial.js (1 of 2 files). Show all

Unified · Split

tutorial/tutorial.js+27−5
@@ -972,12 +972,17 @@ TutorialManager = function() { · 971 unmodified lines
972 var startedTutorialAt = 0;972 var startedTutorialAt = 0;
973 var startedLastStepAt = 0;973 var startedLastStepAt = 0;
974 974
975 var WENT_TO_ENTRY_STEP_NUM = 20;
976 var VERSION = 1;
977 var tutorialID;
978
975 var self = this;979 var self = this;
976 980
977 this.startTutorial = function() {981 this.startTutorial = function() {
978 currentStepNum = -1;982 currentStepNum = -1;
979 currentStep = null;983 currentStep = null;
980 startedTutorialAt = Date.now();984 startedTutorialAt = Date.now();
985 tutorialID = Script.generateUUID();
981 STEPS = [986 STEPS = [
982 new stepStart("start"),987 new stepStart("start"),
983 new stepOrient("orient"),988 new stepOrient("orient"),
@@ -999,10 +1004,7 @@ TutorialManager = function() { · 15 unmodified lines
999 this.onFinish = function() {1004 this.onFinish = function() {
1000 debug("onFinish", currentStepNum);1005 debug("onFinish", currentStepNum);
1001 if (currentStep && currentStep.shouldLog !== false) {1006 if (currentStep && currentStep.shouldLog !== false) {
1002 var timeToFinishStep = (Date.now() - startedLastStepAt) / 1000;1007 self.trackStep(currentStep.tag, currentStepNum);
1003 var tutorialTimeElapsed = (Date.now() - startedTutorialAt) / 1000;
1004 UserActivityLogger.tutorialProgress(
1005 currentStep.tag, currentStepNum, timeToFinishStep, tutorialTimeElapsed);
1006 }1008 }
1007 1009
1008 self.startNextStep();1010 self.startNextStep();
@@ -1015,6 +1017,12 @@ TutorialManager = function() { · 6 unmodified lines
1015 1017
1016 ++currentStepNum;1018 ++currentStepNum;
1017 1019
1020 // This always needs to be set because we use this value when
1021 // tracking that the user has gone through the entry portal. When the
1022 // tutorial finishes, there is a last "pseudo" step that the user
1023 // finishes when stepping into the portal.
1024 startedLastStepAt = Date.now();
1025
1018 if (currentStepNum >= STEPS.length) {1026 if (currentStepNum >= STEPS.length) {
1019 // Done1027 // Done
1020 info("DONE WITH TUTORIAL");1028 info("DONE WITH TUTORIAL");
@@ -1024,7 +1032,6 @@ TutorialManager = function() { · 3 unmodified lines
1024 } else {1032 } else {
1025 info("Starting step", currentStepNum);1033 info("Starting step", currentStepNum);
1026 currentStep = STEPS[currentStepNum];1034 currentStep = STEPS[currentStepNum];
1027 startedLastStepAt = Date.now();
1028 currentStep.start(this.onFinish);1035 currentStep.start(this.onFinish);
1029 return true;1036 return true;
1030 }1037 }
@@ -1046,6 +1053,21 @@ TutorialManager = function() { · 15 unmodified lines
1046 currentStepNum = -1;1053 currentStepNum = -1;
1047 currentStep = null;1054 currentStep = null;
1048 }1055 }
1056
1057 this.trackStep = function(name, stepNum) {
1058 var timeToFinishStep = (Date.now() - startedLastStepAt) / 1000;
1059 var tutorialTimeElapsed = (Date.now() - startedTutorialAt) / 1000;
1060 UserActivityLogger.tutorialProgress(
1061 name, stepNum, timeToFinishStep, tutorialTimeElapsed,
1062 tutorialID, VERSION);
1063 }
1064
1065 // This is a message sent from the "entry" portal in the courtyard,
1066 // after the tutorial has finished.
1067 this.enteredEntryPortal = function() {
1068 info("Got enteredEntryPortal, tracking");
1069 this.trackStep("wentToEntry", WENT_TO_ENTRY_STEP_NUM);
1070 }
1049}1071}
1050 1072
1051// To run the tutorial:1073// To run the tutorial: