Esempio n. 1
0
        public ActionResult ViewExampaper(int id, int objectId, int path = 1, string backUrl = "", int showAnswer = 0)
        {
            ViewBag.objectId = objectId;
            ViewBag.path     = path;
            ViewBag.backUrl  = Server.UrlDecode(backUrl);

            var model   = _surveyManager.GetSurveyExampaperById(id);
            var answers = new List <RetechWing.Models.Views.SurveyReplyAnswer>();

            if (showAnswer == 0)
            {
                answers = _surveyManager.GetOtherExampaperReplyAnswers(objectId, path, id, CurrentUser.UserId);
            }
            foreach (var question in model.Questions)
            {
                var answer = answers.FirstOrDefault(p => p.QuestionId == question.QuestionID);
                if (answer != null)
                {
                    if (question.QuestionType != 2)
                    {
                        question.SelectAnswer = answer.ObjectiveAnswer;
                    }
                    else
                    {
                        question.SelectAnswer = answer.SubjectiveAnswer;
                    }
                }
            }
            return(View(model));
        }