예제 #1
0
        private void SetChoice(int chosenChoiceNo)
        {
            //this.choices = new ObservableCollection<ChoiceSelector>();
            int i = 1;

            if (QuestionSelect.Question.Choices.Count() > 0)
            {
                foreach (var item in QuestionSelect.Question.Choices)
                {
                    ChoiceSelector choice = new ChoiceSelector()
                    {
                        ChoiceNo   = i,
                        _id        = item._id,
                        Detail     = item.Detail,
                        IsCorrect  = false,
                        IsSelected = i == chosenChoiceNo,
                        QuestionNo = QuestionSelect.Question.QuestionNumber
                    };

                    if (TestingData.State == "CheckAnswer")
                    {
                        choice.IsCorrect  = item.IsCorrect.HasValue ? item.IsCorrect.Value : false;
                        choice.IsSelected = item._id == QuestionSelect.Question.UserAnswer?._id;
                    }

                    ChoiceViewModel c = new ChoiceViewModel();

                    c.Choice   = choice;
                    c.ChoiceNo = choice.ChoiceNo;
                    c.Callback = SetCurrentChoice;

                    if (choice.ChoiceNo == 1)
                    {
                        First = c;
                    }
                    else if (choice.ChoiceNo == 2)
                    {
                        Second = c;
                    }
                    else if (choice.ChoiceNo == 3)
                    {
                        Third = c;
                    }
                    else if (choice.ChoiceNo == 4)
                    {
                        Fourth = c;
                    }
                    i++;
                }
            }
        }
예제 #2
0
        public ExamViewModel()
        {
            if (!DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject()))
            {
                svc          = new OnsiteServices();
                CurrentSheet = new ExamSheetResponse();
                CurrentSheet = TestingData.sheet;
                IsTimpUp     = false;
                State        = TestingData.State;


                BorderColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 0));

                First = new ChoiceViewModel {
                    Callback = SetCurrentChoice
                };
                Second = new ChoiceViewModel {
                    Callback = SetCurrentChoice
                };
                Third = new ChoiceViewModel {
                    Callback = SetCurrentChoice
                };
                Fourth = new ChoiceViewModel {
                    Callback = SetCurrentChoice
                };
                QuestionSelect = new QuestionViewModel {
                    Callback = SetQPreview
                };

                ChoiceSelect = new ChoiceSelector();

                SelectIndex = 0;

                currentQuestionNo = 1;
                CurrentAnswer     = new Answer();
                Answers           = new List <Answer>();
                InitializeAnswers();
                //MainExamVisibility = Visibility.Collapsed;

                //ExamAns = new ExamAnsViewModel();
                //ExamAns.Answers = Answers;
                QuestionSelect = new QuestionViewModel();

                #region TimeCal
                if (TestingData.State != "CheckAnswer" && this.IsTimpUp == false)
                {
                    Duration        = new TimeSpan(0, 0, TestingData.TestDuration);
                    DisplayDuration = Duration.ToString();
                    Timer           = new DispatcherTimer
                    {
                        Interval = TimeSpan.FromSeconds(1)
                    };
                    Timer.Tick += (sndr, se) =>
                    {
                        if (Duration <= new TimeSpan(0, 0, 0))
                        {
                            SendResult();
                            if (this.IsTimpUp)
                            {
                                SendResultEvent(this, new Models.SendResultArgs {
                                    IsTimeUp = true
                                });
                                this.IsTimpUp = false;
                            }
                        }
                        Duration = Duration.Subtract(TimeSpan.FromSeconds(1));
                        TestingData.TestDuration = (int)Duration.TotalSeconds;
                        DisplayDuration          = Duration.ToString();
                    };
                    Timer.Start();
                }
                #endregion TimeCal

                ProfilePhoto         = TestingData.ProfilePhoto;
                FullName             = TestingData.sheet.FirstName + "  " + TestingData.sheet.LastName;
                SubjectName          = TestingData.sheet.SubjectName;
                TestingData.Activity = StudentActivity.Testing; // ART

                //if (Answers.Count() == 0)
                //{
                //    InitializeAnswers();
                //}

                //set current question  choice
                SetCurrentQuestion(currentQuestionNo);

                MainExamVisibility  = Visibility.Visible;
                ExamAnsVisibility   = Visibility.Collapsed;
                SendExamVisibility  = Visibility.Collapsed;
                AlertResult         = Visibility.Collapsed;
                BtnChooseVisibility = Visibility.Collapsed;
            }
        }