コード例 #1
0
        public IActionResult Index(int surveyId)
        {
            Survey survey = surveyService.GetSurvey(surveyId);

            if (questionService.GetCountQuestion(surveyId) > 0)
            {
                List <Question> questions = questionService.GetQuestionsForSurvey(surveyId).Take(1).ToList();
                survey.Questions = new List <Question>();
                foreach (Question question in questions)
                {
                    List <QuestionOption> options = questionService.GetOptionsForQuestion(question.QuestionId);
                    question.Options = new List <QuestionOption>();
                    question.Options.AddRange(options);
                    survey.Questions.Add(question);
                }
                ResponseQuestion respQ = new ResponseQuestion()
                {
                    Survey   = survey,
                    Question = questions[0],
                };

                ViewBag.page = 0;
                return(View("Views/CompleteSurvey/Index.cshtml", respQ));
            }
            else
            {
                return(View("Views/Home/Index.cshtml"));
            }
        }
コード例 #2
0
ファイル: ADQuestions.cs プロジェクト: JPCaamal/Pruebas
        public ResponseQuestion deleteQuestion(RequestQuestion Parametros)
        {
            ResponseQuestion respuesta = new ResponseQuestion();
            questionsCore    core      = new questionsCore();
            string           mensaje   = "";
            int idProfessor            = new professorsCore().validateProfessor(Parametros.RQ.professor_number, Parametros.RQ.professor_password, ref mensaje);

            if (idProfessor != -1)
            {
                bool Correcto = core.deleteQuestion(Parametros, ref mensaje);
                if (Correcto)
                {
                    ResponseQuestion Respuesta = new ResponseQuestion();
                    Respuesta.code    = CodigosRespuesta.codigo.OK;
                    Respuesta.estatus = mensaje;
                    respuesta         = Respuesta;
                }
                else
                {
                    ResponseQuestion Respuesta = new ResponseQuestion();
                    Respuesta.code    = CodigosRespuesta.codigo.INTERNAL_SERVER_ERROR;
                    Respuesta.estatus = mensaje;
                    respuesta         = Respuesta;
                }
            }
            else
            {
                ResponseQuestion Respuesta = new ResponseQuestion();
                Respuesta.code    = CodigosRespuesta.codigo.FORBIDDEN;
                Respuesta.estatus = MensajesEstados.ErrorAcceso;
                respuesta         = Respuesta;
            }

            return(respuesta);
        }
コード例 #3
0
        public async Task SimulateUserAsync(string quizHubEndpoint)
        {
            Console.WriteLine("Starting quiz user simulator");
            var quizHubUri = new Uri(quizHubEndpoint);
            var connection = new HubConnectionBuilder()
                             .WithUrl(quizHubEndpoint, options =>
            {
                options.Cookies.Add(new System.Net.Cookie()
                {
                    Name   = "QuizUserId",
                    Value  = _userID,
                    Domain = quizHubUri.Host
                });
                options.AccessTokenProvider = () => Task.FromResult(_userID);
            })
                             .WithAutomaticReconnect()
                             .Build();

            connection.On <Quiz>("Quiz", QuizReceived);
            connection.On <Connection>("Connected", ConnectionHandler);
            connection.On <Connection>("Disconnected", ConnectionHandler);

            await connection.StartAsync(_cancellationTokenSource.Token);

            while (!_cancellationTokenSource.IsCancellationRequested)
            {
                if (_responseTime < DateTime.Now &&
                    _quizzes.TryDequeue(out Quiz quiz))
                {
                    if (quiz.Questions.Count > 0)
                    {
                        Console.WriteLine($"Submitting response to '{quiz.Title}'");
                        var response = new Response
                        {
                            ID     = quiz.ID,
                            UserID = _userID
                        };

                        foreach (var question in quiz.Questions)
                        {
                            var selectedOption   = question.Options[_random.Next(question.Options.Count)];
                            var responseQuestion = new ResponseQuestion()
                            {
                                ID = question.ID,
                            };
                            responseQuestion.Options.Add(selectedOption.OptionId);
                            response.Responses.Add(responseQuestion);

                            Console.WriteLine($"For question '{question.Title}' my answer is '{selectedOption.OptionText}'.");
                        }

                        await connection.InvokeAsync <Response>("QuizResponse", response, _cancellationTokenSource.Token);
                    }
                }

                await Task.Delay(500, _cancellationTokenSource.Token);
            }
        }
コード例 #4
0
 private void GameOneStepSevenCorrect()
 {
     print("Tapped game one step seven correct");
     overlay.HideFtueMessages();
     grid.ClearFtueHighlights();
     overlay.ShowFtueGameplayMessage(Constants.FtueStrings.GameOneStringTen);
     keyboard.HideKeyboard(); //.SetKeyboardEnabled(false);
     currentQuestion = ResponseQuestion.questionNone;
     overlay.SubscribeForFullScreenTap(GameOneStepEightTap);
     analyticsController.TutorialStepComplete(10, "GameOneComplete");
 }
コード例 #5
0
 private void GameOneStepThreeTap()
 {
     print("Tapped game one step three");
     overlay.HideFtueMessages();
     grid.ClearFtueHighlights();
     overlay.ShowFtueGameplayMessage(Constants.FtueStrings.GameOneStringFour, showTapHand: false);
     currentQuestion = ResponseQuestion.questionOne;
     //keyboard.SetKeyboardEnabled(true);
     keyboard.ShowKeyboard();
     keyboard.HighlightKeyboard();
     analyticsController.TutorialStepComplete(4, "SelectNumber");
 }
コード例 #6
0
 private void GameOneStepSevenTap()
 {
     print("Tapped game one step seven");
     overlay.HideFtueMessages();
     grid.ClearFtueHighlights();
     overlay.ShowFtueGameplayMessage(Constants.FtueStrings.GameOneStringNine, showTapHand: false);
     keyboard.ShowKeyboard();//.SetKeyboardEnabled(true);
     keyboard.HighlightKeyboard();
     currentQuestion = ResponseQuestion.questionThree;
     grid.HighlightSquare(currentTarget.Index);
     grid.ShowArrowHighlight(39, FtueArrowDirection.Left);
     analyticsController.TutorialStepComplete(9, "SquareQuestion");
 }
コード例 #7
0
 private void GameOneStepFiveTap()
 {
     print("Tapped game one step five");
     overlay.HideFtueMessages();
     grid.ClearFtueHighlights();
     overlay.ShowFtueGameplayMessage(Constants.FtueStrings.GameOneStringSix, showTapHand: false);
     keyboard.ShowKeyboard();//SetKeyboardEnabled(true);
     keyboard.HighlightKeyboard();
     currentQuestion = ResponseQuestion.questionTwo;
     grid.ResetFtueGrid();
     currentTarget = grid.GetFtueTargetAtIndex(63);
     grid.HighlightColumn(currentTarget.Index);
     grid.ShowArrowHighlight(0, FtueArrowDirection.Up);
     analyticsController.TutorialStepComplete(6, "ColQuestion");
 }
コード例 #8
0
ファイル: ResponseReader.cs プロジェクト: 24/source_04
 private void SaveQuestion(ResponseQuestion responseQuestion)
 {
     if (_trace)
     {
         Trace.WriteLine($"save question \"{responseQuestion.QuestionNumber}\"");
     }
     foreach (ResponseQuestion responseQuestion2 in _responseQuestions)
     {
         if (Math.Abs(responseQuestion.Position - responseQuestion2.Position) <= 2)
         {
             throw new PBException($"missing response for \"{responseQuestion2.Year} - question no {responseQuestion2.QuestionNumber}\", line {_lineNumber} file \"{_filename}\"");
         }
     }
     _responseQuestions.Add(responseQuestion);
 }
コード例 #9
0
ファイル: ResponseReader.cs プロジェクト: 24/source_04
 private Response SetResponse(ZValue value, int index, int length, ResponseQuestion responseQuestion)
 {
     if (responseQuestion == null)
     {
         responseQuestion = GetResponseQuestion(GetMiddlePosition(index, length));
     }
     if (_trace)
     {
         Trace.WriteLine($"set response \"{value}\" question {responseQuestion.QuestionNumber} index {index} length {length}");
     }
     responseQuestion.FoundResponse = true;
     return(new Response {
         Category = _category, Year = responseQuestion.Year, QuestionNumber = responseQuestion.QuestionNumber, Responses = (string)value,
         SourceFile = responseQuestion.SourceFile, SourceLine = responseQuestion.SourceLineNumber
     });
 }
コード例 #10
0
ファイル: ResponseReader.cs プロジェクト: 24/source_04
 private ResponseQuestion NewQuestion(ZValue value, int index, int length, ResponseQuestion responseQuestion)
 {
     if (_trace)
     {
         Trace.WriteLine($"new question \"{value}\" index {index} length {length}");
     }
     if (responseQuestion != null)
     {
         SaveQuestion(responseQuestion);
     }
     responseQuestion = new ResponseQuestion(int.Parse((string)value), index, length)
     {
         SourceFile = _sourceFile, SourceLineNumber = _lineNumber
     };
     responseQuestion.Year = GetYear(responseQuestion.Position);
     return(responseQuestion);
 }
コード例 #11
0
ファイル: ADQuestions.cs プロジェクト: JPCaamal/Pruebas
        public ResponseListQuestion getListQuestion(RequestQuestion Parametros)
        {
            ResponseListQuestion respuesta = new ResponseListQuestion();
            questionsCore        core      = new questionsCore();
            string mensaje     = "";
            int    idProfessor = new professorsCore().validateProfessor(Parametros.RQ.professor_number, Parametros.RQ.professor_password, ref mensaje);

            if (idProfessor != -1)
            {
                List <Questions> ListQuestions = core.getListQuestion(Parametros.RQ.ID_lesson, ref mensaje);
                if (ListQuestions.Count > 0)
                {
                    ResponseQuestion Respuesta = new ResponseQuestion();
                    Respuesta.code    = CodigosRespuesta.codigo.OK;
                    Respuesta.estatus = mensaje;

                    respuesta.Response  = Respuesta;
                    respuesta.Questions = ListQuestions;
                }
                else
                {
                    ResponseQuestion Respuesta = new ResponseQuestion();
                    Respuesta.code    = CodigosRespuesta.codigo.NOT_FOUND;
                    Respuesta.estatus = MensajesEstados.SIN_RESULTADOS;

                    respuesta.Response  = Respuesta;
                    respuesta.Questions = null;
                }
            }
            else
            {
                ResponseQuestion Respuesta = new ResponseQuestion();
                Respuesta.code      = CodigosRespuesta.codigo.FORBIDDEN;
                Respuesta.estatus   = MensajesEstados.ErrorAcceso;
                respuesta.Response  = Respuesta;
                respuesta.Questions = null;
            }

            return(respuesta);
        }
コード例 #12
0
ファイル: ResponseReader.cs プロジェクト: 24/source_04
        private IEnumerable <Response> _Read()
        {
            _filename          = zPath.GetFileName(_file);
            _lineNumber        = 0;
            _years             = new List <ResponseYear>();
            _responseQuestions = new List <ResponseQuestion>();
            bool questionBlock  = false;
            int  emptyLineCount = 0;

            Trace.WriteLine($"read response file \"{_filename}\"");
            foreach (string line in zFile.ReadLines(_file))
            {
                _lineNumber++;
                //string line2 = line.Trim();
                if (line == "")
                {
                    //if (++emptyLineCount == _maxEmptyLine)
                    if (++emptyLineCount == _maxEmptyLine && _years.Count > 0)
                    {
                        break;
                    }
                    //int _maxEmptyLine
                    //if (_responseQuestions.Count > 0)
                    //    throw new PBException($"missing response for {GetQuestionWithoutResponse().zToStringValues(", ")}, line {_lineNumber}");
                    continue;
                }

                emptyLineCount = 0;
                bool        verifyRemainText = true;
                FindText_v2 findText         = _regexList.Find(line, contiguous: true);
                if (findText.Success)
                {
                    //MatchValues matchValues = findText.matchValues;
                    //while (matchValues.Match.Success)
                    ResponseQuestion responseQuestion = null;
                    while (findText.Success)
                    {
                        //ResponseQuestion responseQuestion = null;
                        //foreach (KeyValuePair<string, ZValue> namedValue in findText.GetValues())
                        foreach (KeyValuePair <string, RegexValue <ZValue> > namedValue in findText.GetRegexValues())
                        {
                            switch (namedValue.Key.ToLower())
                            {
                            case "category":
                                if (!_manageCategory)
                                {
                                    throw new PBException($"manage category is not activated");
                                }
                                if (_trace)
                                {
                                    Trace.WriteLine($"new category \"{namedValue.Value.Value}\"");
                                }
                                _category     = (string)namedValue.Value.Value;
                                _years        = new List <ResponseYear>();
                                questionBlock = false;
                                break;

                            case "year":
                                //if (_responseQuestions.Count != 0)
                                if (questionBlock)
                                {
                                    throw new PBException($"wrong year position, line {_lineNumber} column {findText.MatchIndex + 1} file \"{_filename}\"");
                                }
                                //AddYear(namedValue.Value, findText.Match.Index, findText.Match.Length);
                                AddYear(namedValue.Value.Value, namedValue.Value.Index, namedValue.Value.Length);
                                //_years.Add(new ResponseYear(int.Parse((string)namedValue.Value), matchValues.Match.Index, matchValues.Match.Length));
                                break;

                            case "questionnumber":
                                //if (responseQuestion != null)
                                //    //_responseQuestions.Add(responseQuestion);
                                //    SaveQuestion(responseQuestion);
                                //responseQuestion = new ResponseQuestion(int.Parse((string)namedValue.Value), matchValues.Match.Index, matchValues.Match.Length);
                                //responseQuestion.Year = GetYear(responseQuestion.Position);
                                //responseQuestion = NewQuestion(namedValue.Value, findText.Match.Index, findText.Match.Length, responseQuestion);
                                responseQuestion = NewQuestion(namedValue.Value.Value, namedValue.Value.Index, namedValue.Value.Length, responseQuestion);
                                questionBlock    = true;
                                break;

                            case "characterresponsecodes":
                                //if (responseQuestion == null)
                                //    throw new PBException($"unknow question, line {_lineNumber} column {matchValues.Match.Index + 1}");
                                //if (namedValue.Value != null)
                                //{
                                //if (responseQuestion == null)
                                //    responseQuestion = GetResponseQuestion(GetMiddlePosition(matchValues.Match.Index, matchValues.Match.Length));
                                ////GetYear(GetMiddlePosition(matchValues.Match.Index, matchValues.Match.Length))
                                ////Responses = ((string)namedValue.Value).ToCharArray()
                                //yield return new Response { Year = responseQuestion.Year, QuestionNumber = responseQuestion.QuestionNumber, Responses = (string)namedValue.Value };
                                //responseQuestion.FoundResponse = true;
                                //yield return SetResponse(namedValue.Value, findText.Match.Index, findText.Match.Length, responseQuestion);
                                yield return(SetResponse(namedValue.Value.Value, namedValue.Value.Index, namedValue.Value.Length, responseQuestion));

                                responseQuestion = null;
                                //}
                                break;

                            case "numericresponsecodes":
                                yield return(SetResponse(ConvertNumericResponseCodes(namedValue.Value.Value), namedValue.Value.Index, namedValue.Value.Length, responseQuestion));

                                responseQuestion = null;
                                break;
                            }
                        }
                        //if (responseQuestion != null)
                        //    //_responseQuestions.Add(responseQuestion);
                        //    SaveQuestion(responseQuestion);
                        //matchValues = matchValues.Next();
                        //findText.Next();
                        findText.FindNext(contiguous: true);
                    }

                    // control text not found
                    //if (findText.MatchIndex + findText.MatchLength < line.Length)
                    //{
                    //    string textNotFound = line.Substring(findText.MatchIndex + findText.MatchLength).Trim();
                    //    if (textNotFound.Length > 0)
                    //        Trace.WriteLine($"warning remain text \"{textNotFound}\" line {_lineNumber} column {findText.MatchIndex + findText .MatchLength + 1}");
                    //}

                    if (responseQuestion != null)
                    {
                        //_responseQuestions.Add(responseQuestion);
                        SaveQuestion(responseQuestion);
                    }


                    bool questionWithoutResponse = false;
                    foreach (ResponseQuestion responseQuestion2 in _responseQuestions)
                    {
                        if (!responseQuestion2.FoundResponse)
                        {
                            questionWithoutResponse = true;
                            break;
                        }
                    }
                    if (!questionWithoutResponse)
                    {
                        _responseQuestions = new List <ResponseQuestion>();
                    }
                }
                else if (_acceptUnknowText)
                {
                    Trace.WriteLine($"  unknow text \"{line}\" line {_lineNumber} file \"{_filename}\"");
                    verifyRemainText = false;
                }

                // control text not found
                if (verifyRemainText && findText.MatchIndex + findText.MatchLength < line.Length)
                {
                    string textNotFound = line.Substring(findText.MatchIndex + findText.MatchLength).Trim();
                    if (textNotFound.Length > 0)
                    {
                        //Trace.WriteLine($"unknow text \"{textNotFound}\" line {_lineNumber} column {findText.MatchIndex + findText.MatchLength + 1} file \"{_filename}\"");
                        throw new PBException($"  unknow text \"{textNotFound}\" line {_lineNumber} column {findText.MatchIndex + findText.MatchLength + 1} file \"{_filename}\"");
                    }
                }
            }
            foreach (ResponseQuestion responseQuestion2 in _responseQuestions)
            {
                if (!responseQuestion2.FoundResponse)
                {
                    Trace.WriteLine($"no response for {responseQuestion2.Year} - question {responseQuestion2.QuestionNumber}");
                }
            }
        }
コード例 #13
0
        public async Task <IHttpActionResult> SubmitQuestionResponse(int idSurvey, int idQuestion, [FromBody] ResponseQuestion form)
        {
            var identity = (ClaimsIdentity)User.Identity;
            var username = identity.Claims.Where(a => a.Type == ClaimTypes.Name).Select(c => c.Value).FirstOrDefault();
            var findUser = db.accounts.Where(a => a.username == username).FirstOrDefault();

            if (findUser != null)
            {
                var findSurvey = db.surveys.Where(a => a.id == idSurvey &&
                                                  a.date_start <= DateTime.Now &&
                                                  a.deleted == false && a.publish == true).FirstOrDefault();
                if (findSurvey.surveys_type_id == 0)
                {
                    //Check question null or not null
                    var question = (from a in db.questions
                                    from b in db.question_text
                                    where a.id == idQuestion && b.question_id == a.id
                                    select b).FirstOrDefault();
                    if (question != null)
                    {
                        //See if the user has joined
                        var surveyRes = db.surveys_response
                                        .Where(a => a.surveys_id == findSurvey.id && a.username == username).FirstOrDefault();
                        if (surveyRes != null)
                        {
                            //tim xem da co cau tra loi chua
                            var findQuestionRes = db.question_text_response
                                                  .Where(a => a.accounts_id == findUser.id && a.question_id == question.question_id).FirstOrDefault();
                            if (findQuestionRes == null)
                            {
                                question_text_response text = new question_text_response();
                                text.question_id         = question.question_id;
                                text.surveys_response_id = surveyRes.id;
                                text.question_text_id    = question.id;
                                text.accounts_id         = findUser.id;
                                text.create_at           = DateTime.Now;
                                text.text = form.text;
                                db.question_text_response.Add(text);
                                int check = await db.SaveChangesAsync();

                                if (check > 0)
                                {
                                    return(Ok("Ok")); //tra ve thong tin
                                }
                                else
                                {
                                    return(BadRequest("Submit fails."));
                                }
                            }
                            else
                            {
                                findQuestionRes.create_at       = DateTime.Now;
                                findQuestionRes.text            = form.text;
                                db.Entry(findQuestionRes).State = System.Data.Entity.EntityState.Modified;
                                if (await db.SaveChangesAsync() > 0)
                                {
                                    return(Ok("Update submit success."));
                                }
                                else
                                {
                                    return(BadRequest("Submit fails."));
                                }
                            }
                        }
                        else
                        {
                            return(BadRequest("You dont join surveys."));
                        }
                    }
                    else
                    {
                        return(BadRequest("Question not found."));
                    }
                }
                else if (findSurvey.surveys_type_id == 1)
                {
                    //find question for surveys
                    var question = (from a in db.questions
                                    from b in db.question_choice
                                    where a.id == idQuestion && b.question_id == a.id
                                    select b).FirstOrDefault();
                    if (question != null)
                    {
                        //find survey for username
                        var surveyRes = db.surveys_response
                                        .Where(a => a.surveys_id == findSurvey.id && a.username == username).FirstOrDefault();
                        if (surveyRes != null)
                        {
                            //See if the user has answered the question
                            var findQuestionRes = db.question_choice_response
                                                  .Where(a => a.accounts_id == findUser.id && a.question_id == question.question_id).FirstOrDefault();
                            if (findQuestionRes == null)
                            {
                                //create new answer from user
                                question_choice_response choice = new question_choice_response();
                                choice.question_id         = question.question_id;
                                choice.surveys_response_id = surveyRes.id;
                                choice.accounts_id         = findUser.id;
                                choice.create_at           = DateTime.Now;
                                choice.question_choice_id  = form.question_choice_id;
                                db.question_choice_response.Add(choice);
                                int check = await db.SaveChangesAsync();

                                if (check > 0)
                                {
                                    return(Ok("Success"));
                                }
                                else
                                {
                                    return(BadRequest("Submit fails."));
                                }
                            }
                            else
                            {
                                //Update new aswer from user
                                findQuestionRes.question_choice_id = form.question_choice_id;
                                findQuestionRes.create_at          = DateTime.Now;
                                db.Entry(findQuestionRes).State    = System.Data.Entity.EntityState.Modified;
                                if (await db.SaveChangesAsync() > 0)
                                {
                                    return(Ok("Update submit success."));
                                }
                                else
                                {
                                    return(BadRequest("Submit fails."));
                                }
                            }
                        }
                        else
                        {
                            return(BadRequest("You dont join surveys."));
                        }
                    }
                    else
                    {
                        return(BadRequest("Question not found."));
                    }
                }
                else
                {
                    return(BadRequest("Survey not found."));
                }
            }
            else
            {
                return(BadRequest("Account not found"));
            }
        }
コード例 #14
0
        public String EditQuestion()
        {
            String JSON;

            try
            {
                Response.ContentType = "application/json; charset=UTF-8";
                String metodoDeEnvioHTTP = System.Web.HttpContext.Current.Request.HttpMethod;

                if (metodoDeEnvioHTTP != "POST")
                {
                    ResponseQuestion Respuesta = new ResponseQuestion();
                    Respuesta.code    = CodigosRespuesta.codigo.INTERNAL_SERVER_ERROR;
                    Respuesta.estatus = MensajesEstados.ERROR_POST_REQUEST;

                    JSON = JsonConvert.SerializeObject(new ResponseAddQuestions(Respuesta));
                }
                else
                {
                    string POST;
                    using (Stream receiveStream = Request.InputStream)
                    {
                        using (StreamReader readStream = new StreamReader(receiveStream, Request.ContentEncoding))
                        {
                            POST = readStream.ReadToEnd();
                        }
                    }
                    if (POST == null || POST == "")
                    {
                        ResponseQuestion Respuesta = new ResponseQuestion();
                        Respuesta.code    = CodigosRespuesta.codigo.INTERNAL_SERVER_ERROR;
                        Respuesta.estatus = MensajesEstados.ErrorFatal;
                        JSON = JsonConvert.SerializeObject(new ResponseAddQuestions(Respuesta));
                    }
                    else
                    {
                        RequestQuestion Parametros = JsonConvert.DeserializeObject <RequestQuestion>(POST);
                        string          Mensaje    = "";
                        if (parametrosValidosEdit(Parametros, ref Mensaje))
                        {
                            ADQuestions      coursesAD = new ADQuestions();
                            ResponseQuestion Respuesta = coursesAD.editQuestion(Parametros);
                            JSON = JsonConvert.SerializeObject(new ResponseAddQuestions(Respuesta));
                        }
                        else
                        {
                            ResponseQuestion Respuesta = new ResponseQuestion();
                            Respuesta.estatus = Mensaje;
                            Respuesta.code    = CodigosRespuesta.codigo.BAD_REQUEST;
                            JSON = JsonConvert.SerializeObject(new ResponseAddQuestions(Respuesta));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ResponseQuestion Respuesta = new ResponseQuestion();
                Respuesta.estatus = MensajesEstados.ErrorFatal + e.Message.ToString();
                Respuesta.code    = CodigosRespuesta.codigo.INTERNAL_SERVER_ERROR;
                JSON = JsonConvert.SerializeObject(new ResponseAddQuestions(Respuesta));
            }
            return(JSON);
        }
コード例 #15
0
        public ActionResult AddResponse(int surveyId, int page, ResponseQuestion response)
        {
            if (response.SelectedOptionId == 0)
            {
                Survey survey = surveyService.GetSurvey(surveyId);

                List <Question> surveyQuestions = questionService.GetQuestionsForSurvey(surveyId).Skip(page).Take(1).ToList();

                survey.Questions = new List <Question>();
                foreach (Question question in surveyQuestions)
                {
                    List <QuestionOption> options = questionService.GetOptionsForQuestion(question.QuestionId);
                    question.Options = new List <QuestionOption>();
                    question.Options.AddRange(options);
                    survey.Questions.Add(question);
                }

                ResponseQuestion resp = new ResponseQuestion()
                {
                    Survey   = survey,
                    Question = surveyQuestions[0],
                };
                ViewBag.errorComplete = "Select an option!";
                response.Survey       = survey;
                ViewBag.page          = page;
                return(View("Views/CompleteSurvey/Index.cshtml", resp));
            }

            QuestionOption questionOption   = questionService.GetOptionById(response.SelectedOptionId);
            Response       responseQuestion = new Response();

            responseQuestion.Survey         = surveyService.GetSurvey(surveyId);
            responseQuestion.QuestionOption = questionOption;
            responseQuestion.Question       = questionOption.Question;
            responseService.AddResponse(responseQuestion);

            page++;
            ViewBag.page = page;

            List <Question> questions = questionService.GetQuestionsForSurvey(surveyId).Skip(page).Take(1).ToList();

            responseQuestion.Survey.Questions = new List <Question>();
            foreach (Question question in questions)
            {
                List <QuestionOption> options = questionService.GetOptionsForQuestion(question.QuestionId);
                question.Options = new List <QuestionOption>();
                question.Options.AddRange(options);
                responseQuestion.Survey.Questions.Add(question);
            }

            if (questions.Count <= 0)
            {
                List <Survey> surveys = surveyService.GetSurveys();
                return(View("Views/CompleteSurvey/CompletedSuccessfully.cshtml", surveys));
            }
            ResponseQuestion respQ = new ResponseQuestion()
            {
                Survey   = responseQuestion.Survey,
                Question = questions[0],
            };

            return(View("Views/CompleteSurvey/Index.cshtml", respQ));
        }