Esempio n. 1
0
        public async Task FindExistingQuiz(string username, string quizId)
        {
            var player = new Player
            {
                ConnectionId = Context.ConnectionId,
                Username     = username
            };
            var quiz = QuizState.GetExistingQuiz(player, quizId);

            if (QuizState.IsUsernameTaken(quizId, username).GetValueOrDefault())
            {
                await Clients.Caller.SendAsync("UsernameTaken");

                return;
            }
            if (quiz == null)
            {
                //need to wait
                await Groups.AddToGroupAsync(player.ConnectionId, quizId);

                await Clients.Caller.SendAsync("Waiting");

                QuizState.AddToWaiting(player, quizId);
            }
        }
Esempio n. 2
0
    /// <summary>
    /// Load the scenario that belongs to this quiz question.
    /// Won't continue the quiz until this scenario calls EndScenario() on its own.
    /// </summary>
    /// <param name="scenario">Scenario name to look for. Has to match with an entry from the serializable scenarios property.</param>
    void LoadScenario(String scenario)
    {
        state = QuizState.ShowingScenario;

        currentScenario = FindScenarioByName(scenario);
        currentScenario.Load();
    }
Esempio n. 3
0
 public void init()
 {
     leftCount = choices.Count(c => c.Item2);
     Array.Clear(ans, 0, 5);
     isAllRight = true;
     state      = QuizState.NoAns;
 }
Esempio n. 4
0
        public async Task MakeNewQuiz(string username, string quizId, QuizOptions quizOptions)
        {
            var player = new Player
            {
                ConnectionId = Context.ConnectionId,
                Username     = username
            };

            if (QuizState.IsUsernameTaken(quizId, username).GetValueOrDefault())
            {
                await Clients.Caller.SendAsync("UsernameTaken");
            }
            var quiz = new Models.Quiz
            {
                Id      = quizId,
                Players = new List <Player>()
                {
                    player
                },
            };

            quiz.Players.Add(player);
            QuizState.GetWaitingPlayers(quizId).ForEach(player =>
            {
                quiz.Players.Add(player);
            });
            await Clients.Group(quizId).SendAsync("NewQuiz");

            QuizState.AddQuiz(quiz);
        }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        switch (state)
        {
        case QuizState.START:

            validateButton.active     = true;
            summary.gameObject.active = false;
            continueButton.active     = false;

            toggle1.gameObject.active = false;
            toggle2.gameObject.active = false;

            quizText.text = "Quelle est ta couleur préférée ?";

            prepareAnswers(new List <string>()
            {
                "Bleu", "Jaune", "Vert"
            });
            goodAnswers = new List <string>()
            {
                "Bleu", "Jaune"
            };

            state = QuizState.QUESTION1WAITINGANSWER;
            break;

        case QuizState.QUESTION1WAITINGANSWER:
            break;

        case QuizState.QUESTION2PREPARATION:
            quizText.text = "Quelle est ta couleur détestée ?";

            prepareAnswers(new List <string>()
            {
                "Violet", "Indigo", "Pourpre"
            });
            goodAnswers = new List <string>()
            {
                "Pourpre"
            };

            state = QuizState.QUESTION2WAITINGANSWER;
            break;

        case QuizState.QUESTION2WAITINGANSWER:
            break;

        case QuizState.END:
            quizText.text = "Résumé";

            validateButton.active     = false;
            summary.gameObject.active = true;
            continueButton.active     = true;

            summary.text = "t'es trop fort";

            break;
        }
    }
Esempio n. 6
0
		public QuizInfoModel(QuizModel model, SlideBlock currentBlock, int index, QuizState quizState)
		{
			QuizModel = model;
			CurrentBlock = currentBlock;
			BlockIndex = index;
			QuizState = quizState;
		}
        public void should_set_has_passed_to_true_if_each_quiz_has_one_successful_quiz_state()
        {
            var failedQuizState = _status.Courses.First().Quizzes.First().QuizStatuses.First();

            failedQuizState.Status = QuizStatus.Completed;
            failedQuizState.Answers.Add(new QuizAnswer {
                QuestionId = _question.Id.ToString(), SelectedAnswers = new List <string> {
                    "Nope"
                }
            });
            var successfulQuizState = new QuizState {
                HasPassed = true, IsComplete = true, Status = QuizStatus.Completed, Answers = new List <QuizAnswer>()
            };

            successfulQuizState.Answers.Add(new QuizAnswer {
                QuestionId = _question.Id.ToString(), SelectedAnswers = new List <string> {
                    "Ok", "Yep"
                }
            });
            _status.Courses.First().Quizzes.First().QuizStatuses.Add(successfulQuizState);

            var result = _updator.Update(_status);

            result.Courses.First().HasPassed.Should().BeTrue();
        }
Esempio n. 8
0
 private void QuizReplyProcessing(string sessionId, QueryResult queryResult, QuizState state)
 {
     AnswerResponse(sessionId, queryResult.Parameters.Fields["alpha"].ListValue.Values.ToArray(),
                    state.LastState.GetValueOrDefault());
     //graph.Typing(sessionId);
     Thread.Sleep(Startup.LONG_PAUSE);
     NextQuestionAsync(sessionId, state.LastState.GetValueOrDefault() + 1, Startup.BotContext.Quiz.ToString());
 }
Esempio n. 9
0
        private object GetQuizStateForSerialization(QuizState state)
        {
            var minState = new
            {
                Id   = state.Id,
                Name = state.Name
            };

            return(minState);
        }
Esempio n. 10
0
    private void InitQuiz()
    {
        currentQuestionIndex = 0;
        correctAnswerCount   = 0;
        pickedLayers         = GetRandomLayers(maxQuestions);

        resultContainer.SetActive(false);

        state = QuizState.START;
    }
Esempio n. 11
0
 private void EndQuiz(string sessionId, QueryResult queryResult, QuizState state)
 {
     AnswerResponse(sessionId, queryResult.Parameters.Fields["alpha"].ListValue.Values.ToArray(), state.LastState.GetValueOrDefault());
     Thread.Sleep(Startup.LONG_PAUSE);
     graph.PrintScore(sessionId);
     //graph.SendMessage((GenericMessage("What are other information related to safety and emergency that you want to know? " +
     //                                  "Do you have any other comments? Just type in.", sessionId).ToJson()));
     //graph.SetState(sessionId, -1, Startup.BotContext.Feedback.ToString());
     graph.SetState(sessionId, -1, Startup.BotContext.Email.ToString());
     EmailPre(sessionId);
 }
Esempio n. 12
0
    /// <summary>
    /// Boot up the quiz, loading questions and showing the first one.
    /// </summary>
    void StartQuiz()
    {
        state               = QuizState.Initializing;
        answeredCorrectly   = new List <QuizQuestion>();
        answeredIncorrectly = new List <QuizQuestion>();

        remainingQuestions = LoadQuestionsFromFile("Quiz/Questions");
        remainingQuestions.Shuffle();

        StartNextQuestion();
    }
Esempio n. 13
0
        private async Task ResumeQuiz(IDialogContext context, QuizState state)
        {
            var quiz = (IDialog <object>)GeneralQuizDialog;

            if (Quiz == QuizPathOptions.NetworkingOption)
            {
                quiz = NetworkQuizDialog;
            }

            await context.Forward(quiz, ResumeAfterQuizDialog, QuizState.Started, CancellationToken.None);
        }
Esempio n. 14
0
 private void updateState(QuizState newState)
 {
     if (newState == QuizState.CHECK)
     {
         buttonNext.Content = "Check";
     }
     if (newState == QuizState.NEXT)
     {
         buttonNext.Content = "Next";
     }
     currentState = newState;
 }
Esempio n. 15
0
 void UpdateQuiz()
 {
     if (currentQuestionIndex < maxQuestions)
     {
         accordion.MoveTo(pickedLayers[currentQuestionIndex].Key, nextQuestionDelay);
     }
     else
     {
         this.state = QuizState.RESULT;
         accordion.MoveToStart(nextQuestionDelay);
     }
 }
Esempio n. 16
0
    /// <summary>
    /// End the game. No more questions can be answered.
    /// Will also allow the player to return to the central hub.
    /// </summary>
    /// <param name="completed">Whether the quiz was completed (all questions answered) or if it's a game over (no lives remaining).</param>
    void EndGame(bool completed)
    {
        state = QuizState.EndingGame;

        int scoreAsInt = Convert.ToInt32(score);

        monitor.ShowGameEnded(completed, scoreAsInt);
        Debug.Log("The game has ended.");
        Debug.Log(String.Format($"Your final score is: {score}"));

        StartCoroutine(WaitLoadMainMenu(delayBeforeLoadMenu));
    }
Esempio n. 17
0
    /// <summary>
    /// Submit an answer.
    /// Called by QuizButton script.
    /// </summary>
    /// <param name="qb"></param>
    public void SubmitAnswer(QuizButton qb)
    {
        if (state == QuizState.AwaitingAnswer)
        {
            // Security check to make sure this button is relevant.
            // E.g. the fourth button isn't relevant for a question with only three answers.
            if ((buttons.IndexOf(qb) + 1) > currentQuestion.Answers.Count)
            {
                Debug.Log("Ignoring input from this button as no answer has been assigned.");
                return;
            }

            qb.PlaySubmitSound();
            state = QuizState.ShowingResult;
            StartCoroutine(WaitRevealAnswer(buttons.IndexOf(qb)));
        }
    }
Esempio n. 18
0
    public void OnAccordionMovementFinsh()
    {
        switch (state)
        {
        case QuizState.START:
            this.state = QuizState.NEXT_QUESTION;
            accordion.MoveTo(pickedLayers[currentQuestionIndex].Key, nextQuestionDelay);
            break;

        case QuizState.NEXT_QUESTION:
            ShowNextQuestion();
            break;

        case QuizState.RESULT:
            ShowResult();
            break;
        }
    }
Esempio n. 19
0
        private void buttonNext_Click(object sender, RoutedEventArgs e)
        {
            if (currentState == QuizState.NEXT)
            {
                activeQuestion = questionRandomizer.Next();

                textBoxAnswerInput.Text    = "";
                textBlockResponseHint.Text = activeQuestion.ResponseHint;

                textBlockQuestion.Text        = activeQuestion.Question;
                textBlockAnswer.Text          = "";
                textBoxAnswerInput.Background = Brushes.White;

                updateState(currentState = QuizState.CHECK);
            }
            else if (currentState == QuizState.CHECK)
            {
                string response = textBoxAnswerInput.Text.Trim();

                totalQuestions++;

                if (activeQuestion.Evaluate(response))
                {
                    textBlockAnswer.Text          = $"Correct!";
                    textBoxAnswerInput.Background = Brushes.LightGreen;
                    totalCorrect++;
                }
                else
                {
                    textBlockAnswer.Text          = $"Incorrect! Correct: {activeQuestion.Response}";
                    textBoxAnswerInput.Background = Brushes.LightPink;
                }

                pointsText.Text = $"{totalCorrect}/{totalQuestions}";
                if (totalCorrect != totalQuestions)
                {
                    pointsRectangle.Fill = Brushes.LightYellow;
                }

                updateState(QuizState.NEXT);
            }
        }
Esempio n. 20
0
 public bool?Test(int idx)
 {
     if (state == QuizState.Finish || ans[idx])
     {
         return(null);
     }
     state    = QuizState.Ansing;
     ans[idx] = true;
     if (choices[idx].Item2)
     {
         if (--leftCount == 0)
         {
             state = QuizState.Finish;
         }
         return(true);
     }
     else
     {
         return(isAllRight = false);
     }
 }
Esempio n. 21
0
        private void QuizContextProcessing(string sessionId, string detectedIntent, QueryResult queryResult, QuizState state)
        {
            switch (detectedIntent)
            {
            case "Answer":
                if (queryResult.Parameters.Fields["alpha"].ListValue.Values.ToArray().Length > 0)
                {
                    if (!validitycheck(state.LastState.GetValueOrDefault(),
                                       queryResult.Parameters.Fields["alpha"].ListValue.Values.ToArray()))
                    {
                        QuizWrongInput(sessionId, state.LastState.GetValueOrDefault());
                    }
                    else if (state.LastState <= Startup.quiz.Questions.Count - 2)
                    {
                        QuizReplyProcessing(sessionId, queryResult, state);
                    }
                    else
                    {
                        EndQuiz(sessionId, queryResult, state);
                    }
                    break;
                }
                else
                {
                    QuizWrongInput(sessionId, state.LastState.GetValueOrDefault());
                    break;
                }

            case "Exit":
                ExitQuiz(sessionId);
                break;

            case "Start":
                RestartQuiz(sessionId);
                break;

            default:
                if (queryResult.QueryText == Startup.Force_Wrong)
                {
                    graph.SendMessage((GenericMessage("Sorry, I can't process attachments or emojis", sessionId).ToJson()));
                }
                QuizWrongInput(sessionId, state.LastState.GetValueOrDefault());
                break;
            }
        }
Esempio n. 22
0
 /// <summary>
 /// Start waiting for user input.
 /// </summary>
 void AwaitAnswer()
 {
     ShowQuestionAndAnswers(currentQuestion);
     state = QuizState.AwaitingAnswer;
 }
Esempio n. 23
0
		private Dictionary<string, bool> GetResultForQuizes(string courseId, string userId, string slideId, QuizState state)
		{
			return userQuizzesRepo.GetQuizBlocksTruth(courseId, userId, slideId);
		}
Esempio n. 24
0
 // exits quiz
 public void onContinue()
 {
     GenericQuizUI.close();
     state = QuizState.START;
 }
Esempio n. 25
0
 public void init()
 {
     leftCount = choices.Count(c => c.Item2);
     Array.Clear(ans, 0, 5);
     isAllRight = true;
     state = QuizState.NoAns;
 }
Esempio n. 26
0
 private Dictionary <string, int> GetResultForQuizes(string courseId, string userId, Guid slideId, QuizState state)
 {
     return(userQuizzesRepo.GetQuizBlocksTruth(courseId, userId, slideId));
 }
Esempio n. 27
0
 public QuizStateEventArgs(QuizState newState)
 {
     this.NewState = newState;
 }
Esempio n. 28
0
 public bool CanUserFillQuiz(QuizState state)
 {
     return(state == QuizState.NotPassed || state == QuizState.WaitForCheck);
 }
Esempio n. 29
0
		public QuizBlockData(QuizModel model, int index, QuizState quizState)
		{
			QuizModel = model;
			BlockIndex = index;
			QuizState = quizState;
		}
Esempio n. 30
0
        public void OnTimer()
        {
            if (m_quizShow.Count < ServerKernel.QUIZ_MAX_QUESTION)
            {
                return;                                                    // no questions, no quiz
            }
            DateTime now = DateTime.Now;

            if (ServerKernel.QUIZ_SHOW_HOUR.Contains(now.Hour + 1))
            {
                if (now.Minute == 55 &&
                    now.Second == 0 &&
                    m_state < QuizState.STARTING)
                {
                    ServerKernel.SendMessageToAll("Quiz show will start in 5 minutes.", ChatTone.TOP_LEFT);
                }

                // Quiz starting
                if (now.Minute == 59 &&
                    now.Second <= 1 &&
                    m_state < QuizState.STARTING)
                {
                    if (now.DayOfWeek == DayOfWeek.Sunday &&
                        now.Hour + 1 == 22)
                    {
                        return;
                    }

                    ReloadQuestions();

                    // reset basic variable
                    m_nActualQuestion = 0;
                    m_quizUserInformation.Clear();
                    m_temporaryQuestions.Clear();

                    // start the quiz
                    m_state = QuizState.STARTING;
                    // and send the initial packet :)
                    var pMsg = new MsgQuiz
                    {
                        Type            = QuizShowType.START_QUIZ,
                        TimeTillStart   = (ushort)(60 - now.Second),
                        TimePerQuestion = ServerKernel.QUIZ_TIME_PER_QUESTION,
                        QuestionAmount  = ServerKernel.QUIZ_MAX_QUESTION,
                        FirstPrize      = ServerKernel.QUIZ_SHOW_AWARD[0],
                        SecondPrize     = ServerKernel.QUIZ_SHOW_AWARD[1],
                        ThirdPrize      = ServerKernel.QUIZ_SHOW_AWARD[2]
                    };
                    // send to all players
                    foreach (var plr in ServerKernel.Players.Values)
                    {
                        // create the user object that will be held by the server while it's alive
                        var plrObj = new QuizShowUserObject
                        {
                            Experience   = 0,
                            Name         = plr.Character.Name,
                            Points       = 0,
                            TimeTaken    = 0,
                            UserIdentity = plr.Identity,
                            Canceled     = false
                        };
                        m_quizUserInformation.Add(plr.Identity, plrObj); // save the info
                        plr.Send(pMsg);                                  // send packet to client
                    }

                    // quiz will only happen if there is at least 20 questions
                    if (m_quizShow.Count > ServerKernel.QUIZ_MAX_QUESTION)
                    {
                        List <KeyValuePair <uint, DbGameQuiz> > tempList = new List <KeyValuePair <uint, DbGameQuiz> >();
                        Random rand = new Random();

                        foreach (var question in m_quizShow.Values)
                        {
                            tempList.Add(new KeyValuePair <uint, DbGameQuiz>((uint)rand.Next(), question));
                        }

                        int num = 0;
                        foreach (var question in tempList.OrderBy(x => x.Key).Where(question => num++ < ServerKernel.QUIZ_MAX_QUESTION))
                        {
                            m_temporaryQuestions.Add(question.Value);
                        }
                    }
                    else
                    {
                        if (m_quizShow.Count < ServerKernel.QUIZ_MAX_QUESTION)
                        {
                            m_state = QuizState.STOPPED;
                            return;
                        }
                        // we have exactly 20 questions :) so ok
                        foreach (var question in m_quizShow.Values)
                        {
                            m_temporaryQuestions.Add(question);
                        }
                    }
                    // send message to all (supposing they didn't receive the window lol)
                    ServerKernel.SendMessageToAll(ServerString.STR_QUIZ_SHOW_START, ChatTone.TOP_LEFT);
                }
            }
            if (ServerKernel.QUIZ_SHOW_HOUR.Contains(now.Hour) &&
                now.Minute <= (ServerKernel.QUIZ_MAX_QUESTION * ServerKernel.QUIZ_TIME_PER_QUESTION) / 60)
            {
                // quiz started
                if (m_state == QuizState.STARTING &&
                    now.Minute == 0)
                {
                    m_state = QuizState.RUNNING;
                    m_pNextQuestion.Startup(ServerKernel.QUIZ_TIME_PER_QUESTION);
                    m_pEventCheck.Startup(800);

                    DbGameQuiz question = m_temporaryQuestions[m_nActualQuestion++];
                    var        pMsg     = new MsgQuiz
                    {
                        Type              = QuizShowType.QUESTION_QUIZ,
                        QuestionNumber    = (ushort)(m_nActualQuestion),
                        LastCorrectAnswer = 0,
                        ExperienceAwarded = 1,
                        TimeTakenTillNow  = 0,
                        CurrentScore      = 0
                    };
                    pMsg.AddString(question.Question, question.Answer0, question.Answer1, question.Answer2,
                                   question.Answer3);
                    foreach (var plr in ServerKernel.Players.Values)
                    {
                        plr.Send(pMsg);
                    }
                }

                // quiz running
                if (m_state == QuizState.RUNNING &&
                    m_pNextQuestion.ToNextTime() &&
                    m_nActualQuestion < ServerKernel.QUIZ_MAX_QUESTION)
                {
                    foreach (var usr in m_quizUserInformation.Values)
                    {
                        if (usr.LastQuestion < m_nActualQuestion)
                        {
                            usr.Points    += 1;
                            usr.TimeTaken += ServerKernel.QUIZ_TIME_PER_QUESTION;
                        }
                    }

                    UpdateRanking();

                    DbGameQuiz question = m_temporaryQuestions[m_nActualQuestion++];
                    var        pMsg     = new MsgQuiz
                    {
                        Type              = QuizShowType.QUESTION_QUIZ,
                        QuestionNumber    = (ushort)m_nActualQuestion,
                        LastCorrectAnswer = m_temporaryQuestions[m_nActualQuestion - 2].Correct
                    };
                    pMsg.AddString(question.Question, question.Answer0, question.Answer1, question.Answer2,
                                   question.Answer3);
                    foreach (var plr in ServerKernel.Players.Values.Where(x => !x.Character.QuizCanceled))
                    {
                        var plrObj = m_quizUserInformation.Values.FirstOrDefault(x => x.UserIdentity == plr.Identity);
                        if (plrObj == null)
                        {
                            plrObj = new QuizShowUserObject
                            {
                                Experience   = 0,
                                Name         = plr.Character.Name,
                                Points       = 0,
                                TimeTaken    = 0,
                                UserIdentity = plr.Identity,
                                LastQuestion = 0
                            };
                        }

                        if (plrObj.LastQuestion < m_nActualQuestion - 2)
                        {
                            pMsg.LastCorrectAnswer = 0;
                        }
                        pMsg.CurrentScore      = plrObj.Points;
                        pMsg.ExperienceAwarded = plrObj.Experience;
                        pMsg.TimeTakenTillNow  = plrObj.TimeTaken;
                        plrObj.LastQuestion    = m_nActualQuestion - 1;
                        plr.Send(pMsg);
                    }
                    if (m_nActualQuestion >= ServerKernel.QUIZ_MAX_QUESTION)
                    {
                        m_state = QuizState.ENDED;
                    }
                }

                if (m_state == QuizState.ENDED &&
                    m_pNextQuestion.ToNextTime())
                {
                    foreach (var usr in m_quizUserInformation.Values)
                    {
                        if (usr.LastQuestion < m_nActualQuestion)
                        {
                            usr.Points    += 1;
                            usr.TimeTaken += ServerKernel.QUIZ_TIME_PER_QUESTION;

                            Client pClient;
                            if (ServerKernel.Players.TryGetValue(usr.UserIdentity, out pClient))
                            {
                                var pMsg = new MsgQuiz
                                {
                                    Type         = QuizShowType.AFTER_REPLY,
                                    CurrentScore = usr.Points,
                                    TimeTaken    = usr.TimeTaken,
                                    Rank         = usr.Rank
                                };
                                var rank = RankingStrings();
                                pMsg.AddString(rank[0].Name, rank[0].Points, rank[0].TimeTaken);
                                pMsg.AddString(rank[1].Name, rank[1].Points, rank[1].TimeTaken);
                                pMsg.AddString(rank[2].Name, rank[2].Points, rank[2].TimeTaken);
                                pClient.Send(pMsg);
                            }
                        }

                        Client pUser = null;
                        if (ServerKernel.Players.TryGetValue(usr.UserIdentity, out pUser))
                        {
                            try
                            {
                                pUser.Character.QuizPoints += usr.Points;
                                int i = 0;
                                foreach (var tmp in m_quizUserInformation.Values.OrderByDescending(x => x.Points))
                                {
                                    if (i++ > 3)
                                    {
                                        break;
                                    }
                                    if (tmp.UserIdentity == usr.UserIdentity)
                                    {
                                        long amount =
                                            (ServerKernel.GetExpBallExperience(pUser.Character.Level) / 600) *
                                            ServerKernel.QUIZ_SHOW_AWARD[i - 1];
                                        pUser.Character.AwardExperience(amount);

                                        ushort emoney = ServerKernel.QUIZ_SHOW_EMONEY[i - 1];
                                        uint   money  = ServerKernel.QUIZ_SHOW_MONEY[i - 1];
                                        pUser.Character.AwardEmoney(emoney);
                                        pUser.Character.AwardMoney(money);
                                        pUser.Character.Send(
                                            string.Format("You awarded {0} CPs and {2} for winning on {1} place on Quiz Show.",
                                                          emoney, i, money));
                                    }
                                }

                                MsgQuiz pMsg = new MsgQuiz
                                {
                                    Type       = QuizShowType.FINISH_QUIZ,
                                    Score      = usr.Rank,
                                    Rank       = usr.TimeTaken,
                                    FirstPrize = usr.Points,
                                    FinalPrize = usr.Experience
                                };
                                QuizShowUserObject[] pList = RankingStrings();
                                pMsg.AddString(pList[0].Name, pList[0].Points, pList[0].TimeTaken);
                                pMsg.AddString(pList[1].Name, pList[1].Points, pList[1].TimeTaken);
                                pMsg.AddString(pList[2].Name, pList[2].Points, pList[2].TimeTaken);
                                pUser.Send(pMsg);
                            }
                            catch
                            {
                            }
                        }
                        else
                        {
                            try
                            {
                                // disconnected? still have prize to claim
                                DbUser dbObj = new CharacterRepository().SearchByIdentity(usr.UserIdentity);
                                if (dbObj == null)
                                {
                                    continue;
                                }

                                Character pTemp = new Character(null, dbObj, null);
                                pTemp.QuizPoints += usr.Points;

                                int i = 1;
                                foreach (var tmp in m_quizUserInformation.Values.OrderByDescending(x => x.Points))
                                {
                                    if (i++ > 3)
                                    {
                                        break;
                                    }
                                    if (tmp.UserIdentity == usr.UserIdentity)
                                    {
                                        long amount =
                                            (ServerKernel.GetExpBallExperience(pTemp.Level) / 600) *
                                            ServerKernel.QUIZ_SHOW_AWARD[i - 1];
                                        pTemp.AwardExperience(amount);
                                    }
                                }
                                pTemp.Save();
                                pTemp = null;
                            }
                            catch
                            {
                            }
                        }
                    }

                    ServerKernel.SendMessageToAll(ServerString.STR_QUIZ_SHOW_ENDED, ChatTone.TOP_LEFT);
                    m_state = QuizState.STOPPED;
                }
            }
        }
Esempio n. 31
0
 public QuizBlockData(QuizModel model, int index, QuizState quizState)
 {
     QuizModel  = model;
     BlockIndex = index;
     QuizState  = quizState;
 }
Esempio n. 32
0
 public bool? Test(int idx)
 {
     if (state == QuizState.Finish || ans[idx])
         return null;
     state = QuizState.Ansing;
     ans[idx] = true;
     if (choices[idx].Item2)
     {
         if (--leftCount == 0)
             state = QuizState.Finish;
         return true;
     }
     else
         return isAllRight = false;
 }
Esempio n. 33
0
		public bool CanUserFillQuiz(QuizState state)
		{
			return state == QuizState.NotPassed || state == QuizState.WaitForCheck;
		}