Example #1
0
    /// <summary>
    /// evaluates a question by comparing the annotation with the input text
    /// Shows a MessageBox to indicate success or failure
    /// </summary>
    /// <param name="annotation">The selected annotation</param>
    /// <param name="input">The user input to compare to the annotation's text</param>
    /// <returns>true if input is equal to the annotations text, else false</returns>
    private bool EvaluateQuestion(Annotation annotation, string input)
    {
        if (annotation.Text == input)
        {
            MessageBox.Show(LocalizationManager.Instance.ResolveString("Correct"), MessageBoxType.SUCCESS);
            correctlyAnswered++;
            progressBar.Progress = (float)correctlyAnswered / annotations.Count;

            annotation.Answered = true;
            InformListeners();
            CurrentlySelectedName = "";


            GamificationFramework.Instance.TriggerAction(gamificationManager.gameId, GameAction.CreateActionId(annotation, QuizName));

            if (progressBar.Progress == 1)
            {
                CloseListeners();

                // also trigger the default action
                GamificationFramework.Instance.TriggerAction(gamificationManager.gameId, "defaultAction");
                badgeManager.WinBadge();
            }

            return(true);
        }
        else
        {
            MessageBox.Show(LocalizationManager.Instance.ResolveString("Incorrect"), MessageBoxType.ERROR);
            return(false);
        }
    }
Example #2
0
    public override void Delete(AnnotationContainer annotationContainer)
    {
        base.Delete(annotationContainer);

        // handle gamification: delete action which is related to the question
        GamificationFramework.Instance.DeleteAction(gamificationManager.gameId, GameAction.CreateActionId(annotationContainer.Annotation, QuizName),
                                                    resCode =>
        {
            if (resCode != 200)
            {
                Debug.Log("Could not delete gamified question (Code " + resCode + ")");
                gamificationManager.Quest.RemoveAction(annotationContainer.Annotation.Position.ToString() + "_" + QuizName);
            }
        }
                                                    );

        // also decrease target for achievement
        UpdateAchievementPoints();
    }