public QuestionFormVM GetPreviewQuestionPartial(int questionId)
        {
            var currentQuestion = context.Questions
                                  .Include(q => q.Answers)
                                  .Single(o => o.Id == questionId);

            var viewModel = new QuestionFormVM()
            {
                IsInTestSession = false,
                Answers         = currentQuestion.Answers.Select(o => new AnswerDetailVM()
                {
                    AnswerId      = o.Id,
                    AnswerText    = o.AnswerText,
                    ShowAsCorrect = o.IsCorrect,
                    IsChecked     = o.IsCorrect
                }).ToList(),
                QuestionText = currentQuestion.QuestionText,
                HasComment   = currentQuestion.HasComment,
                QuestionType = currentQuestion.QuestionType
            };

            return(viewModel);
        }
Beispiel #2
0
        public IActionResult ViewQuestion(int testSessionId, int questionIndex, QuestionFormVM viewModel, string submit)
        {
            var hasTimeLeft = repository.EditSessionAnswers(testSessionId, questionIndex, viewModel.SelectedAnswers, viewModel.Comment);

            if (string.Equals("previous", submit, StringComparison.OrdinalIgnoreCase))
            {
                questionIndex--;
            }
            else if (string.Equals("next", submit, StringComparison.OrdinalIgnoreCase))
            {
                questionIndex++;
            }
            else if (string.Equals("submit", submit, StringComparison.OrdinalIgnoreCase))
            {
                repository.SubmitTestSession(testSessionId);
                return(RedirectToAction(nameof(SessionCompleted),
                                        new { TestSessionId = testSessionId, completedReason = (int)SessionCompletedReason.Completed }));
            }
            else
            {
                throw new Exception("Unknown submit value");
            }

            if (hasTimeLeft)
            {
                //var session = repository.GetTestSessionById(testSessionId);
                //session.SecondsLeft = secondsLeft;

                return(RedirectToAction(nameof(ViewQuestion),
                                        new { TestSessionId = testSessionId, QuestionIndex = questionIndex }));
            }
            else
            {
                return(RedirectToAction(nameof(SessionCompleted),
                                        new { TestSessionId = testSessionId, completedReason = (int)SessionCompletedReason.TimedOut }));
            }
        }
        public ActionResult PreviewQuestionPartial(int id)
        {
            QuestionFormVM viewModelPartial = repository.GetPreviewQuestionPartial(id);

            return(PartialView("_PreviewQuestionFormPartial", viewModelPartial));
        }
Beispiel #4
0
        public StudyUnitVM(MainWindowVM mainWindowVM, StudyUnit studyUnit) : base(mainWindowVM, studyUnit)
        {
            this.studyUnit = studyUnit;

            EventFormVM eventFormViewModel = new EventFormVM(this);
            MenuItemVM  categoryEvent      = new MenuItemVM(MenuElem.C_EVENT, eventFormViewModel); //1
            MenuItemVM  menuEvent          = new MenuItemVM(MenuElem.M_EVENT, eventFormViewModel); //2

            menuEvent.IsSelected = true;
            categoryEvent.Add(menuEvent);
            this.MenuItems.Add(categoryEvent);

            memberForm      = new MemberFormVM(this);
            abstractForm    = new AbstractFormVM(this);
            coverageForm    = new CoverageFormVM(this);
            fundingInfoForm = new FundingInfoFormVM(this);

            MenuItemVM categoryStudy     = new MenuItemVM(MenuElem.C_STUDY, memberForm);             //3
            MenuItemVM menuStudyMember   = new MenuItemVM(MenuElem.M_MEMBER, memberForm);            //4
            MenuItemVM menuStudyAbstract = new MenuItemVM(MenuElem.M_ABSTRACT, abstractForm);        //5
            MenuItemVM menuStudyRange    = new MenuItemVM(MenuElem.M_COVERAGE, coverageForm);        //6
            MenuItemVM menuFund          = new MenuItemVM(MenuElem.M_FUNDING_INFO, fundingInfoForm); //7

            categoryStudy.Add(menuStudyMember);
            categoryStudy.Add(menuStudyAbstract);
            categoryStudy.Add(menuStudyRange);
            categoryStudy.Add(menuFund);
            this.MenuItems.Add(categoryStudy);

            samplingForm = new SamplingFormVM(this);

            MenuItemVM categoryScheme = new MenuItemVM(MenuElem.C_SAMPLING, samplingForm); //8
            MenuItemVM menuScheme     = new MenuItemVM(MenuElem.M_SAMPLING, samplingForm); //9

            categoryScheme.Add(menuScheme);
            this.MenuItems.Add(categoryScheme);

            conceptForm       = new ConceptFormVM(this);
            categoryForm      = new CategoryFormVM(this);
            codeForm          = new CodeFormVM(this);
            questionForm      = new QuestionFormVM(this);      //QuestionForm needs to be genarated after concept, category and code
            questionGroupForm = new QuestionGroupFormVM(this); // QuestionGroupForm needs to be genarated before SequenceForm
            sequenceForm      = new SequenceFormVM(this);

            MenuItemVM categoryQuestion  = new MenuItemVM(MenuElem.C_QUESTION, conceptForm);  //10
            MenuItemVM menuConcept       = new MenuItemVM(MenuElem.M_CONCEPT, conceptForm);   //11
            MenuItemVM menuQuestion      = new MenuItemVM(MenuElem.M_QUESTION, questionForm); //12
            MenuItemVM menuCategory      = new MenuItemVM(MenuElem.M_CATEGORY, categoryForm); //13
            MenuItemVM menuCode          = new MenuItemVM(MenuElem.M_CODE, codeForm);         //14
            MenuItemVM menuSequence      = new MenuItemVM(MenuElem.M_SEQUENCE, sequenceForm); //15
            MenuItemVM menuQuestionGroup = new MenuItemVM(MenuElem.M_QUESTION_GROUP, questionGroupForm);

            categoryQuestion.Add(menuConcept);
            categoryQuestion.Add(menuQuestion);
            categoryQuestion.Add(menuCategory);
            categoryQuestion.Add(menuCode);
            categoryQuestion.Add(menuSequence);
            categoryQuestion.Add(menuQuestionGroup);
            this.MenuItems.Add(categoryQuestion);

            variableForm = new VariableFormVM(this);
            MenuItemVM categoryVariable = new MenuItemVM(MenuElem.C_VARIABLE, variableForm); //16
            MenuItemVM menuVariable     = new MenuItemVM(MenuElem.M_VARIABLE, variableForm); //17

            categoryVariable.Add(menuVariable);
            this.MenuItems.Add(categoryVariable);

            dataSetForm    = new DataSetFormVM(this);
            dataFileForm   = new DataFileFormVM(this);
            bookForm       = new BookFormVM(this);
            statisticsForm = new StatisticsFormVM(this);
            MenuItemVM categoryData          = new MenuItemVM(MenuElem.C_DATA, dataSetForm);       //18
            MenuItemVM menuDataRelation      = new MenuItemVM(MenuElem.M_DATA_SET, dataSetForm);   //19
            MenuItemVM menuPhysicalStructure = new MenuItemVM(MenuElem.M_DATA_FILE, dataFileForm); //20
            MenuItemVM menuBooks             = new MenuItemVM(MenuElem.M_BOOKS, bookForm);
            MenuItemVM menuAggregate         = new MenuItemVM(MenuElem.M_STATISTICS, statisticsForm);

            categoryData.Add(menuDataRelation);
            categoryData.Add(menuPhysicalStructure);
            categoryData.Add(menuBooks);
            categoryData.Add(menuAggregate);
            this.MenuItems.Add(categoryData);
            this.SelectedMenuItem = categoryEvent;

            OnRemoveBooks();
        }