public Answer Create(Answer obj)
        {
            QuestionnaireQuestion qq = Read(obj.Question.Id, false);

            obj.Id = FindNextAvailableAnswerId();

            if (qq.QuestionType == QuestionType.Open || qq.QuestionType == QuestionType.Mail)
            {
                _ctx.Answers.Add(OpenConvertToDao((OpenAnswer)obj));
            }
            else
            {
                MultipleAnswer ma = (MultipleAnswer)obj;
                _ctx.Answers.Add(MultipleConvertToDao(ma));
                foreach (String s in ma.Choices)
                {
                    int id = ReadOptionId(s, ma.Question.Id);
                    _ctx.Choices.Add(ConvertToDao(id, ma.Id, _ctx.Choices.Count() + 1));
                }
            }

            _ctx.SaveChanges();

            return(obj);
        }
예제 #2
0
    public void submitAnswer()
    {
        if (SelectedAnswer == null)
        {
            submit.interactable = false;
            return;
        }
        if (!MonsterManager)
        {
            MonsterManager = FindObjectOfType <MonsterManager>();
        }

        if (SelectedAnswer.getAnswer() == enemyAnswerNeeded)
        {
            MonsterManager.currentEnemy.MonsterHurt();
        }
        else
        {
            MonsterManager.currentEnemy.EnemyAttack();
        }

        submit.interactable = false;
        SelectedAnswer.GetComponent <Image>().color = Color.white;
        SelectedAnswer = null;
    }
 private AnswersDao MultipleConvertToDao(MultipleAnswer obj)
 {
     return(new AnswersDao
     {
         AnswerId = obj.Id,
         QQuestionId = obj.Question.Id,
         UserId = obj.User.Id
     });
 }
예제 #4
0
    void MultipleAnswers(QuizButton a_running, float multiple)
    {
        SelectedAnswer      = null;
        submit.interactable = false;

        DisableMultipleChoiceButtons();

        MultipleBackground.SetActive(true);

        TransitionButtons(true, a_running);

        foreach (MultipleAnswer item in answers)
        {
            item.setAnswer(-1);
        }
        int index = Random.Range(0, 6);

        answersList = new List <int>
        {
            enemyAnswerNeeded
        };


        if (a_running.enemyChoices > 6)
        {
            a_running.enemyChoices = 6;
        }

        if (Defend)
        {
            Defend.gameObject.SetActive(true);
        }

        answers[index].gameObject.SetActive(true);
        answers[index].setAnswer(enemyAnswerNeeded);

        for (int i = 1; i < a_running.enemyChoices; i++)
        {
            int wrongAnswer = -3;
            while (wrongAnswer <= a_running.minAnswer || CheckMultiple(a_running, wrongAnswer))
            {
                int range = Random.Range(-a_running.enemyAnswerRange, a_running.enemyAnswerRange);
                wrongAnswer = enemyAnswerNeeded + range;
            }

            index = Random.Range(0, 6);
            while (answers[index].getAnswer() != -1)
            {
                index = Random.Range(0, 6);
            }
            answers[index].gameObject.SetActive(true);
            answers[index].setAnswer(wrongAnswer);
        }
    }
예제 #5
0
    internal void RemoveSingle()
    {
        MultipleAnswer removing = null;

        foreach (MultipleAnswer item in answers)
        {
            if (item.getAnswer() != enemyAnswerNeeded && item.getAnswer() > 0)
            {
                removing = item;
            }
        }
        if (removing)
        {
            removing.setAnswer(-2);
            removing.gameObject.SetActive(false);
        }
    }
        public IEnumerable <Answer> ReadAll(int questionId)
        {
            List <Answer> myQuery = new List <Answer>();

            foreach (AnswersDao dao in _ctx.Answers.ToList().FindAll(a => a.QQuestionId == questionId))
            {
                if (!_ctx.Choices.Where(c => c.AnswerId == dao.AnswerId).Any())
                {
                    myQuery.Add(ConvertToDomain(dao));
                }
                else
                {
                    MultipleAnswer toAdd = ReadMultipleAnswer(dao.AnswerId, false);
                    myQuery.Add(toAdd);
                }
            }

            return(myQuery);
        }
        private MultipleAnswer ConvertToDomain(AnswersDao answersDao, List <OptionsDao> chosenOptionsDao)
        {
            MultipleAnswer ma = null;

            ma.Id   = answersDao.AnswerId;
            ma.User = new UimvcUser {
                Id = answersDao.UserId
            };
            ma.Question = new QuestionnaireQuestion {
                Id = answersDao.QQuestionId
            };
            ma.DropdownList = chosenOptionsDao.Count == 1;

            foreach (OptionsDao dao in chosenOptionsDao)
            {
                ma.Choices.Add(dao.OptionText);
            }

            return(ma);
        }