Example #1
0
        public IActionResult ManageQuestion(int queryNumber, int questionNumber)
        {
            var      username = User.Identity.Name.ToString();
            var      user     = UserOptions.GetUser(username);
            Query    query    = QueryOptions.Load(user, queryNumber);
            Question question = QuestionOptions.Load(query, questionNumber);

            return(View("LoadQuestion", question));
        }
Example #2
0
        public IActionResult ManageAnswer()
        {
            var      username = User.Identity.Name.ToString();
            var      user     = UserOptions.GetUser(username);
            Query    query    = QueryOptions.Load(user, 1);
            Question question = QuestionOptions.Load(query, 1);
            Answer   answer   = AnswerOptions.Load(question, 1);

            return(View("LoadAnswer", answer));
        }
Example #3
0
        public IActionResult LoadAnswer(int queryNumber, int questionNumber, int answerNumber)
        {
            var      username = User.Identity.Name.ToString();
            var      user     = UserOptions.GetUser(username);
            Query    query    = QueryOptions.Load(user, queryNumber);
            Question question = QuestionOptions.Load(query, questionNumber);
            Answer   answer   = AnswerOptions.Load(question, answerNumber);

            return(View("LoadAnswer", answer));
        }
Example #4
0
        public IActionResult InsertAnswer(int queryNumber, int questionNumber)
        {
            var username = User.Identity.Name.ToString();
            var user     = UserOptions.GetUser(username);
            var query    = QueryOptions.Load(user, queryNumber);
            var question = QuestionOptions.Load(query, questionNumber);

            QuestionOptions.AddAnswer(question);

            return(RedirectToAction("LoadAnswer", "Answer", new { queryNumber = question.QueryNumber, questionNumber = question.Number, answerNumber = question.Answers.Max(x => x.Number) }));
        }
Example #5
0
        public IActionResult ClientView()
        {
            var      username       = User.Identity.Name.ToString();
            var      user           = UserOptions.GetUser(username);
            var      test           = user.Queries[0];
            var      queryNumber    = test.Number;
            Query    query          = QueryOptions.Load(user, queryNumber);
            var      t              = query.Questions[0];
            var      questionNumber = t.Number;
            Question question       = QuestionOptions.Load(query, questionNumber);

            return(View("ClientView", question));
        }
Example #6
0
        public IActionResult InsertQuestion(int queryID)
        {
            var username = User.Identity.Name.ToString();
            var user     = UserOptions.GetUser(username);
            var query    = QueryOptions.Load(user, queryID);

            QueryOptions.AddQuestion(query);

            var questionNumber = query.Questions.Max(x => x.Number);
            var question       = QuestionOptions.Load(query, questionNumber);

            return(RedirectToAction("LoadQuestion", "Question", question));
        }
Example #7
0
        public IActionResult AddAnswer(int queryNumber, int number, string answerName)
        {
            var username = User.Identity.Name.ToString();
            var user     = UserOptions.GetUser(username);
            var query    = QueryOptions.Load(user, queryNumber);

            query.Questions = query.Questions.OrderBy(q => q.Order).ToList();
            var question = QuestionOptions.Load(query, number);

            question.Answers = question.Answers.OrderBy(a => a.Order).ToList();

            QuestionOptions.AddAnswer(question, 0, answerName);

            return(RedirectToAction("LoadActiveQuery", new { queryID = queryNumber }));
        }
Example #8
0
        public IActionResult LoadNextQuestion(int queryNumber, int questionNumber, bool fromDelete = false)
        {
            var username = User.Identity.Name.ToString();
            var user     = UserOptions.GetUser(username);
            var query    = QueryOptions.Load(user, queryNumber);

            query.Questions = query.Questions.OrderBy(q => q.Order).ToList();
            var question = QuestionOptions.Load(query, questionNumber);

            question.Answers = question.Answers.OrderBy(a => a.Order).ToList();

            int index = 0;

            for (int i = 0; i < query.Questions.Count; ++i)
            {
                if (query.Questions[i].Number == question.Number)
                {
                    index = i;
                }
            }

            try
            {
                if (fromDelete)
                {
                    QuestionOptions.SetNextActive(question, query.Questions[index].Number);
                }
                else
                {
                    QuestionOptions.SetNextActive(question, query.Questions[index + 1].Number);
                }
            }
            catch (ArgumentOutOfRangeException ex) { }

            try
            {
                //var nextQuestionNumber = query.Questions.First(x => x.Number > questionNumber).Number;
                //var nextQuestion = QuestionOptions.Load(query, nextQuestionNumber);
                var nextQuestion = QuestionOptions.GetActive(query.Questions[index + 1].Number, query.Code, false);
                question.Answers = question.Answers.OrderBy(a => a.Order).ToList();
                return(View("LoadActiveQuestion", nextQuestion));
            }
            catch
            {
                QueryOptions.Close(query);
                return(RedirectToAction(nameof(UserController.Index), "User"));
            }
        }
Example #9
0
        public IActionResult InsertQuestion(int queryNumber, int Order, string NewQuestionName)
        {
            var username = User.Identity.Name.ToString();
            var user     = UserOptions.GetUser(username);
            var query    = QueryOptions.Load(user, queryNumber);

            query.Questions = query.Questions.OrderBy(q => q.Order).ToList();

            QueryOptions.AddQuestion(query, NewQuestionName, Order + 1);

            var questionNumber = query.Questions.Max(x => x.Number);
            var question       = QuestionOptions.Load(query, questionNumber);

            question.Answers = question.Answers.OrderBy(a => a.Order).ToList();

            return(View("LoadActiveQuestion", question));
        }
Example #10
0
        public IActionResult LoadActiveQuery(int queryID)
        {
            var username = User.Identity.Name.ToString();
            var user     = UserOptions.GetUser(username);
            var query    = QueryOptions.Load(user, queryID);

            query.Questions = query.Questions.OrderBy(q => q.Order).ToList();

            if (query.Questions.Count > 0)
            {
                var question = QuestionOptions.Load(query, query.Questions.First().Number);
                question.Answers = question.Answers.OrderBy(a => a.Order).ToList();

                QuestionOptions.SetFirstActive(query);

                question.Code = query.Code;

                return(View("LoadActiveQuestion", question));
            }

            return(RedirectToAction(nameof(UserController.Index), "User"));
        }
Example #11
0
        public IActionResult DisplayResults(int queryNumber, int questionNumber)
        {
            var username = User.Identity.Name.ToString();
            var user     = UserOptions.GetUser(username);
            var query    = QueryOptions.Load(user, queryNumber);

            query.Questions = query.Questions.OrderBy(q => q.Order).ToList();

            if (query != null)
            {
                var question = QuestionOptions.Load(query, questionNumber);
                question.Answers = question.Answers.OrderBy(a => a.Order).ToList();

                /*var username = User.Identity.Name.ToString();
                 * var user = UserOptions.GetUser(username);
                 * var query = QueryOptions.Load(user, 3);
                 * DataManager.Question question = new Question();
                 */

                /*foreach (DataManager.Question item in query.Questions)
                 * {
                 *  if(item != null)
                 *  {
                 *      question = item;
                 *  }
                 * }*/
                if (question == null)
                {
                    return(RedirectToAction(nameof(UserController.Index), "User"));
                }

                return(View("DisplayResults", question));
            }
            //var q = QuestionOptions.Load(query, question.Number);
            //question.Answers = question.Answers.OrderBy(a => a.Order).ToList();

            return(RedirectToAction(nameof(UserController.Index), "User"));
        }