private ParticipationFeedback computeFeedback(Activity chosenActivity, DateTime startDate, DateTime endDate)
        {
            if (this.demanded_nextParticipationActivity != null)
            {
                if (!this.demanded_nextParticipationActivity.Matches(chosenActivity))
                {
                    string summary = "THE IRE OF THE EXPERIMENT GODS RAINS ON YOU AND YOUR BROKEN PROMISES";
                    string details = "You previously initiated an experiment where you promised that you would be willing to do " +
                                     this.demanded_nextParticipationActivity.ActivityName + ". Instead you did " + chosenActivity.Name + ". If you " +
                                     "don't follow through on your promises, then your data might be skewed in strange ways. For example, it's possible that " +
                                     "in the evening that you may choose to skip doing difficult tasks and save them for the morning. This could cause you to " +
                                     "take more time working on any individual task in the morning than in the evening, which could incorrectly suggest that " +
                                     "your efficiency is lower in the morning than in the evening.";
                    return(new ParticipationFeedback(chosenActivity, summary, false, new TextblockLayout(details)));
                }
                return(null); // no feedback for experiments
            }
            ParticipationFeedback standardFeedback = this.engine.computeStandardParticipationFeedback(chosenActivity, startDate, endDate);

            if (standardFeedback != null)
            {
                return(standardFeedback);
            }
            if (this.activityDatabase.RootActivity.NumParticipations < 20)
            {
                string summary = "You're off to a good start!";

                LayoutChoice_Set detailedLayout = new HelpWindowBuilder()
                                                  .AddMessage("Participation Feedback!")
                                                  .AddMessage("After you've entered enough data, the button on the previous screen will give you feedback about how you will feel about what you are doing.")
                                                  .AddMessage("(This may take a couple of days and requires that you give some ratings too, in the box on the left)")
                                                  .AddMessage("I have 128 different feedback messages that I know how to give!")
                                                  .AddMessage("When you press the feedback button, you will see a more detailed analysis on this screen.")
                                                  .AddMessage("Isn't that cool?")
                                                  .Build();

                return(new ParticipationFeedback(chosenActivity, summary, null, detailedLayout));
            }
            return(null);
        }
Ejemplo n.º 2
0
        public override void PreviewParticipation(Participation newParticipation)
        {
            logCounter++;
            // resolve some parameters
            Activity activity = this.activityDatabase.ResolveDescriptor(newParticipation.ActivityDescriptor);
            DateTime when     = newParticipation.StartDate;

            if (logCounter % 1000 == 0)
            {
                this.log("Processing participation at " + when + " for " + activity.Name);
            }
            ParticipationFeedback feedbackObject = this.engine.computeStandardParticipationFeedback(activity, when, newParticipation.EndDate);

            if (feedbackObject != null)
            {
                // remove the number
                string fullFeedback = feedbackObject.Summary;
                string feedback     = this.stripLeadingNumbers(fullFeedback);

                // save into this.feedbacks
                string prefix = "Feedback at " + when + " for " + activity + ":";
                //this.log(this.padColumn(prefix) + " " + fullFeedback);
                if (!this.feedbacks.ContainsKey(feedback))
                {
                    this.feedbacks[feedback] = new Dictionary <Activity, int>();
                }
                Dictionary <Activity, int> counts = feedbacks[feedback];
                if (!counts.ContainsKey(activity))
                {
                    counts[activity] = 0;
                }
                counts[activity]++;
            }
            // call parent class
            base.PreviewParticipation(newParticipation);
        }
        private void Update_FeedbackBlock_Text()
        {
            ParticipationFeedback participationFeedback = null;
            Activity activity = this.nameBox.Activity;

            if (activity != null && this.startDateBox.IsDateValid() && this.endDateBox.IsDateValid())
            {
                // We have a valid activity and valid dates, so give feedback about the participation
                DateTime startDate = this.startDateBox.GetDate();
                DateTime endDate   = this.endDateBox.GetDate();
                participationFeedback = this.computeFeedback(activity, startDate, endDate);
                if (participationFeedback != null)
                {
                    this.participationFeedbackButtonLayout.setText(participationFeedback.Summary);
                    bool?happySummary = participationFeedback.happySummary;
                    if (happySummary != null)
                    {
                        if (happySummary.Value == true)
                        {
                            this.participationFeedbackButtonLayout.setTextColor(Color.Green);
                        }
                        else
                        {
                            this.participationFeedbackButtonLayout.setTextColor(Color.Red);
                        }
                    }
                    else
                    {
                        this.participationFeedbackButtonLayout.resetTextColor();
                    }
                    this.promptHolder.SubLayout = this.participationFeedbackButtonLayout;
                }
                else
                {
                    this.promptHolder.SubLayout = null;
                }
            }
            else
            {
                if (this.nameBox.NameText == null || this.nameBox.NameText == "")
                {
                    // If we have no text in the activity name box, then we do have space for a response and there isn't a current activity to give feedback on
                    Participation latestParticipation = this.LatestParticipation;
                    if (latestParticipation != null && latestParticipation.RelativeEfficiencyMeasurement != null)
                    {
                        this.promptHolder.SubLayout = this.experimentFeedbackLayout;
                    }
                    else
                    {
                        // If the user has submitted a participation before, it should be fast to get a suggestion, so we do that now
                        if (this.wasEverCleared)
                        {
                            this.updateSuggestion();
                            if (this.suggestedActivityName != null)
                            {
                                this.promptHolder.SubLayout = this.suggestionsLayout;
                                this.suggestionLayout.setText("How about " + this.suggestedActivityName + "?");
                            }
                            else
                            {
                                this.promptHolder.SubLayout = null;
                            }
                        }
                        else
                        {
                            // If the user hasn't submitted a participation during this usage of ActivityRecommender yet, then it will probably be slow to get a suggestion, so we'll wait until later before showing a suggestion
                            this.promptHolder.SubLayout = null;
                        }
                    }
                }
                else
                {
                    // If we have no valid activity name but we do have some text in the name box, then we don't need to say anything
                    // The name entry box will offer autocomplete suggestions and/or help
                    this.promptHolder.SubLayout = null;
                }
            }
            // Note that this is the only method that modifies either participationFeedback or responseButtonLayout.text,
            // so we can ensure that they match
            this.participationFeedback = participationFeedback;
            this.feedbackIsUpToDate    = true;
        }