private GroupQuiz GetGroupQuiz(string level = null)
        {
            this.groupQuizManager = new GroupQuizManager(this.UserId);
            var listOfGroup = this.groupQuizManager.GetAllQuestions(level);

            Session["AllGroupQuestions"] = this.groupQuizManager.AllQuestions = listOfGroup;
            return(this.groupQuizManager.LoadQuiz(1));
        }
        public ActionResult CustomerAssessment(QuestionOnePost question)
        {
            // Get Report
            string companyName = string.Empty, address = string.Empty, contactName = string.Empty;
            var    userInfo = new Repository <Organization>();
            var    user     = userInfo.Filter(q => q.Id == this.UserId).FirstOrDefault();

            if (user != null)
            {
                companyName = user.Name;
                address     = user.Address;
                contactName = user.ContactName;
            }

            if (question.hdnaction != string.Empty && (question.hdnaction.Contains("PDF") || question.hdnaction.Contains("CSV")))
            {
                var level = question.hdnaction.Split('-')[1];
                if (question.hdnaction.Contains("PDF"))
                {
                    return(PdfExport(companyName, address, contactName, level));
                }
                else
                {
                    return(CsvExport(companyName, address, contactName, level));
                }
            }
            else
            {
                GroupQuiz groupQuiz = null;
                int       groupId   = int.Parse(question.QInfo);
                if (question.hdnaction == "Previous")
                {
                    groupId = groupId - 1;
                    if (groupId <= 0)
                    {
                        groupId = 1;
                    }
                }
                else
                {
                    groupId = groupId + 1;
                }
                this.groupQuizManager = new GroupQuizManager(this.UserId);
                this.groupQuizManager.AllQuestions = (List <GroupQuiz>)Session["AllGroupQuestions"];
                if (this.groupQuizManager.MoveToNextGroup(groupId))
                {
                    groupQuiz = this.groupQuizManager.LoadQuiz(groupId);
                }
                else
                {
                    groupQuiz = this.groupQuizManager.LoadQuiz(--groupId);
                }

                return(PartialView("QuizGroupPartial", groupQuiz));
            }
        }
        private GroupQuiz GetLastGroupQuiz()
        {
            this.groupQuizManager = new GroupQuizManager(this.UserId);
            var listOfGroup = this.groupQuizManager.GetAllQuestions(null);

            Session["AllGroupQuestions"] = this.groupQuizManager.AllQuestions = listOfGroup;
            var groupId = listOfGroup.Count;

            return(this.groupQuizManager.LoadQuiz(groupId));
        }
Exemplo n.º 4
0
        private GroupQuiz GetGroupQuiz(int id, string level)
        {
            var groupQuizManager = new GroupQuizManager(id);
            var listOfGroup      = groupQuizManager.GetAllQuestions(level);

            groupQuizManager.AllQuestions = listOfGroup;
            var groupQuiz = groupQuizManager.LoadQuiz(1);

            groupQuiz.UserId = id;
            return(groupQuiz);
        }
Exemplo n.º 5
0
        public ActionResult CustomerAssessmentReport(QuestionOnePost question)
        {
            //PDF-1-Level 1

            if (question.hdnaction != string.Empty && (question.hdnaction.Contains("PDF") || question.hdnaction.Contains("CSV")))
            {
                var values = question.hdnaction.Split('-');
                if (question.hdnaction.Contains("PDF"))
                {
                    return(PdfExport(int.Parse(values[1]), values[2]));
                }
                else
                {
                    return(CsvExport(int.Parse(values[1]), values[2]));
                }
            }
            else
            {
                var groupQuizManager = new GroupQuizManager(question.UserId);
                var listOfGroup      = groupQuizManager.GetAllQuestions(question.Level);
                groupQuizManager.AllQuestions = listOfGroup;

                GroupQuiz groupQuiz = new GroupQuiz();
                int       groupId   = int.Parse(question.QInfo);
                if (question.hdnaction == "Previous")
                {
                    groupId = groupId - 1;
                    if (groupId <= 0)
                    {
                        groupId = 1;
                    }
                }
                else
                {
                    if (listOfGroup.Count > groupId)
                    {
                        groupId = groupId + 1;
                    }
                }

                if (groupQuizManager.MoveToNextGroup(groupId))
                {
                    groupQuiz = groupQuizManager.LoadQuiz(groupId);
                }
                groupQuiz.UserId = question.UserId;
                return(PartialView("~/Views/ManageUser/QuizGroupPartial.cshtml", groupQuiz));
            }
        }
        public ActionResult QuizGroup(FormCollection questionCode)
        {
            int groupId = 0;
            //string result = string.Empty;
            //if (questionCode["Origin"] != null && questionCode["Origin"].Equals("Result"))
            //{
            //    groupId = int.Parse(questionCode["Id"].ToString());
            //    var groupQuiz = GetGroupQuiz(--groupId);
            //    return RedirectToAction("QuizGroup", new { quiz = groupQuiz });
            //}
            //else
            //{


            bool isAction  = false;
            var  groupQuiz = new List <QuestionQuiz>();

            foreach (string user in questionCode.Keys)
            {
                if (user == "hdnaction")
                {
                    isAction = questionCode["hdnaction"].Equals("Previous", StringComparison.OrdinalIgnoreCase) ? true : false;
                    continue;
                }
                if (user == "UIGroupId")
                {
                    continue;
                }

                string[] values = questionCode[user].Split('~');
                var      quiz   = new QuestionQuiz();
                quiz.GroupId      = Convert.ToInt16(values[0]);
                quiz.QuestionId   = Convert.ToInt16(values[1]);
                quiz.UserOptionId = Convert.ToInt16(values[2]);
                quiz.UIGroupId    = Convert.ToInt16(values[3]);
                groupQuiz.Add(quiz);
            }
            this.groupQuizManager = new GroupQuizManager(this.UserId);
            if (groupQuiz.Count == 0)
            {
                groupId = int.Parse(questionCode[1]);
            }
            else
            {
                groupId = groupQuiz[0].GroupId;
            }

            this.groupQuizManager.AllQuestions = (List <GroupQuiz>)Session["AllGroupQuestions"];
            var lQuestions = this.groupQuizManager.GetMandatoryQuestion(groupId);

            this.groupQuizManager.SaveAnswer(groupQuiz);

            bool isMandatoryAnswerd = true;

            foreach (var q in lQuestions)
            {
                if (groupQuiz == null || groupQuiz.Count == 0 || !groupQuiz.Exists(t => t.QuestionId == q.Questions.QuestionId))
                {
                    ViewBag.AssessmentName = q.AssessmentName;
                    isMandatoryAnswerd     = false;
                    break;
                }
            }

            if (isMandatoryAnswerd)
            {
                groupId = groupQuiz.First().UIGroupId;

                if (!isAction)
                {
                    groupId = groupId + 1;
                }
                else
                {
                    groupId = Convert.ToInt16(questionCode["UIGroupId"].ToString());
                    groupId = groupId - 1;
                }

                if (groupId == 0)
                {
                    groupId = 1;
                }
            }
            else
            {
                groupId     = groupQuiz.Count > 0 ? groupQuiz.First().UIGroupId : groupId;
                ViewBag.Msg = "Please Fill the Mandatroy Questions";
            }

            this.groupQuizManager.AllQuestions = (List <GroupQuiz>)Session["AllGroupQuestions"];
            if (this.groupQuizManager.MoveToNextGroup(groupId))
            {
                var question = this.groupQuizManager.LoadQuiz(groupId);
                ViewBag.AssessmentName = question.AssessmentName;
                return(View(question));
            }
            //}
            return(RedirectToAction("ShowResults", new { origin = "Group" }));
        }