Exemplo n.º 1
0
        /// <summary>
        /// Invokes CompleteActivity with CurrentActivity as activity.
        /// </summary>
        /// <param name="grade">What grade the user gives the activity.</param>
        /// <param name="comment">Any feedback the user leaves to the activity. Can be left blank or nulled.</param>
        /// <returns>A list of the name of all trophies and challenges that was earned. If nothing is earned then an empty list, safe to use for each.</returns>
        public List <Notification> CompleteCurrentActivity(int grade, string comment)
        {
            var ChallengeActivated = connectToDatabase.onGoingChallenge(Username);

            connectToDatabase.SubmitComment(grade, comment, Username, CurrentActivity.Activity.Name);

            connectToDatabase.CompleteActivity(Username, CurrentActivity.Activity.Name);
            trophiesEarned = connectToDatabase.getTrophiesEarnedAfterActivity(Username);

            var notifications = new List <Notification>();

            // add all, if any, trophies earned to the list
            foreach (Trophy t in trophiesEarned)
            {
                notifications.Add(new Notification("Trophy Earned!", "Congratulations, you earned the trophy: " + t.Name + "!"));
            }

            foreach (Trophy t in trophiesEarned)
            {
                Debug.WriteLine("" + t.Name);
            }

            // reset CurrentActivity and done
            DropCurrentActivity();
            return(notifications);
        }
Exemplo n.º 2
0
        public Presenter(MainForm view, User user)
        {
            connectToDatabase = new ConnectToDatabase("halso_hub");
            this.user = user;
            this.view = view;
            moodButtonState = 0;
            view.setPresenter(this);
            setupGUI();

			if (connectToDatabase.onGoingChallenge(user.Username) == true)
            {
                ChallengeActivitiesLeftInCurrentChallenge();
                StartChallengeButtonPressed();
                view.HideChallengesDisplayed();
                view.ShowActivitiesForChallenge();

				currentChallengeHover = connectToDatabase.GetCurrentChallenge(user.Username);
				Challenge startedChallenge = user.GetChallengeQuery(currentChallengeHover);

                if (startedChallenge != null && challengeSelected == false)
				{
					challengeSelected = true;
                    user.SetCurrentChallenge(startedChallenge);
                }

				view.ChangeChallengeDescriptionAndLabel(startedChallenge.Name, startedChallenge.Description);
			}
			else
			{
				GetAndShowChallenges();
			}
        }
Exemplo n.º 3
0
        public Presenter(MainForm view, User user)
        {
            connectToDatabase = new ConnectToDatabase("halso_hub");
            this.user         = user;
            this.view         = view;
            moodButtonState   = 0;
            view.setPresenter(this);
            setupGUI();

            if (connectToDatabase.onGoingChallenge(user.Username) == true)
            {
                ChallengeActivitiesLeftInCurrentChallenge();
                StartChallengeButtonPressed();
                view.HideChallengesDisplayed();
                view.ShowActivitiesForChallenge();

                currentChallengeHover = connectToDatabase.GetCurrentChallenge(user.Username);
                Challenge startedChallenge = user.GetChallengeQuery(currentChallengeHover);

                if (startedChallenge != null && challengeSelected == false)
                {
                    challengeSelected = true;
                    user.SetCurrentChallenge(startedChallenge);
                }

                view.ChangeChallengeDescriptionAndLabel(startedChallenge.Name, startedChallenge.Description);
            }
            else
            {
                GetAndShowChallenges();
            }
        }