コード例 #1
0
ファイル: FairlyCertain.cs プロジェクト: mdmilic/ABTesting
        /// <summary>
        /// Mark this user as having converted for the specified tests.
        /// </summary>
        public void ScoreConversion(string testName)
        {
            ABUser user = IdentifyUser();

            if (!user.Tests.Contains(testName) || user.Conversions.Contains(testName))
            {
                // not part of the test or already scored.
                return;
            }

            SerializableDictionary <string, Experiment> tests = GetTests();

            if (tests.ContainsKey(testName))
            {
                Experiment t = tests[testName];

                ABAlternative choice = t.GetUserAlternative(user.ID);
                choice.ScoreConversion();

                user.Conversions.Add(testName);
                user.SaveToCookie();

                SaveTests(tests);
            }
        }
コード例 #2
0
ファイル: FairlyCertain.cs プロジェクト: mdmilic/ABTesting
        /// <summary>
        /// For the specified test, pick an alternative to always show this user, and return that alternative.
        /// </summary>
        /// <param name="test"></param>
        /// <returns></returns>
        public ABAlternative GetUserAlternative(Experiment test)
        {
            //complete an experiment as soon as we reach our required sample size...
            if (test.IsComplete)
            {
                return(test.GetBestAlternative());
            }

            ABUser        user   = IdentifyUser();
            ABAlternative choice = test.GetUserAlternative(user.ID);

            if (!user.Tests.Contains(test.TestName) && !IsBotRequest()) //don't score the participation more than once for an identified user (don't score for bots either)
            {
                choice.ScoreParticipation();
                user.Tests.Add(test.TestName);
                user.SaveToCookie();

                //persist the new participant count to the file store...
                ScoreParticipation(test.TestName, choice);
            }

            return(choice);
        }
コード例 #3
0
        /// <summary>
        /// For the specified test, pick an alternative to always show this user, and return that alternative.
        /// </summary>
        /// <param name="test"></param>
        /// <returns></returns>
        public ABAlternative GetUserAlternative(Experiment test)
        {
            //complete an experiment as soon as we reach our required sample size...
            if (test.IsComplete)
            {
                return test.GetBestAlternative();
            }

            ABUser user = IdentifyUser();
            ABAlternative choice = test.GetUserAlternative(user.ID);

            if (!user.Tests.Contains(test.TestName) && !IsBotRequest()) //don't score the participation more than once for an identified user (don't score for bots either)
            {
                choice.ScoreParticipation();
                user.Tests.Add(test.TestName);
                user.SaveToCookie();

                //persist the new participant count to the file store...
                ScoreParticipation(test.TestName, choice);
            }

            return choice;
        }