コード例 #1
0
        /// <summary>
        /// Get question's answers.
        /// </summary>
        /// <returns>A List of DisplayAnswerModel.</returns>
        public async Task <List <DisplayAnswerModel> > GetAnswers()
        {
            AnswerData answerData = new AnswerData(_db);
            List <DisplayAnswerModel> answerModels     = new List <DisplayAnswerModel>();
            List <DataAnswerModel>    dataAnswerModels = await answerData.GetAnswers();

            foreach (var dataAnswerModel in dataAnswerModels)
            {
                DisplayAnswerModel newDisplayAnswerModel = new DisplayAnswerModel
                {
                    Answer       = dataAnswerModel.Answer,
                    Id           = dataAnswerModel.Id,
                    PlayerAnswer = dataAnswerModel.PlayerAnswer,
                    Type         = dataAnswerModel.Type,
                };

                if (!DisplayLinks.Any(x => x.AnswerId == dataAnswerModel.Id))
                {
                    // Unadded questions are added to the dropdown
                    answerModels.Add(newDisplayAnswerModel);
                }
                else
                {
                    // Already linked questions are displayed in the table
                    DisplayAnswers.Add(newDisplayAnswerModel);
                }
            }

            return(answerModels);
        }
コード例 #2
0
        /// <summary>
        /// Get quiz's questions.
        /// </summary>
        /// <returns>A List of DisplayQuestionModel.</returns>
        public async Task <List <DisplayQuestionModel> > GetQuestions()
        {
            QuestionData questionData = new QuestionData(_db);
            List <DisplayQuestionModel> questionModels     = new List <DisplayQuestionModel>();
            List <DataQuestionModel>    dataQuestionModels = await questionData.GetQuestions();

            foreach (var dataQuestionModel in dataQuestionModels)
            {
                DisplayQuestionModel newDisplayQuestionModel = new DisplayQuestionModel
                {
                    DomainId       = dataQuestionModel.DomainId,
                    Id             = dataQuestionModel.Id,
                    Question       = dataQuestionModel.Question,
                    QuestionTypeId = dataQuestionModel.QuestionTypeId,
                };

                if (!DisplayLinks.Any(x => x.QuestionId == dataQuestionModel.Id))
                {
                    // Les questions non ajoutées sont ajoutées dans la liste déroulante
                    questionModels.Add(newDisplayQuestionModel);
                }
                else
                {
                    // Les questions déjà liées sont affichées dans le tableau
                    DisplayQuestions.Add(newDisplayQuestionModel);
                }
            }

            return(questionModels);
        }