private void Start(object sender, RoutedEventArgs e) { this._selectedItem = (TestItem)this.TestList.SelectedItem; ToeicTest _test = ToeicTestManager.GetTestManager().GetTest(this._selectedItem.ID); this.Visibility = Visibility.Hidden; ExamView exView = new ExamView(_test); if (exView.ShowDialog() == true) { IDataAccess dbAccess = LocalDataAccess.GetDBAccess(); Dictionary <int, List <string> > testCorrectAnswer = dbAccess.GetTestCorrectAnswer(int.Parse(this._selectedItem.ID)); Dictionary <int, string> listeningAnswer = exView.GetListenningAnswers(); Dictionary <int, string> readingAnswer = exView.GetReadingAnswers(); Dictionary <int, int> listeningScoreChecklist = dbAccess.GetListeningScoreCheckList(); Dictionary <int, int> readingScoreChecklist = dbAccess.GetReadingScoreCheckList(); ResultView resultView = new ResultView(); resultView.SetDataAndCalculate( int.Parse(this._selectedItem.ID), testCorrectAnswer, listeningAnswer, readingAnswer, listeningScoreChecklist, readingScoreChecklist); resultView.ShowDialog(); } this.Visibility = Visibility.Visible; }
/// <summary> /// Examination view constructor /// </summary> /// <param name="test">Test basic resource</param> public ExamView(ToeicTest test = null) { InitializeComponent(); this._timer = new CountdownTimer( this._defaultTimeSpan, this.Dispatcher, this.CountIntervalCallBack, this.TimeUp); if (test != null) { this._test = test; this.Initialize(); } }
private void LoadTests() { Dictionary <int, List <string> > tests = LocalDataAccess.GetDBAccess().GetAllTest(); for (int i = 1; i <= tests.Count; i++) { List <string> infor = tests[i]; string testSourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, infor[1]); DirectoryInfo dirInfo = new DirectoryInfo(testSourcePath); DirectoryInfo[] parts = dirInfo.GetDirectories(); ToeicTest test = new ToeicTest(); this._tests.Add(i.ToString(), test); test.Name = infor[0]; foreach (DirectoryInfo part in parts) { if (string.Equals(part.Name, Common.AUDIO)) { FileInfo[] audio = part.GetFiles(); if (audio.Length > 0) { test.Audio = audio[0].FullName; } else { this._tests.Remove(i.ToString()); break; } } else if (string.Equals(part.Name, Common.LISTEN)) { FileInfo[] listening = part.GetFiles(); if (listening.Length > 0) { test.Listening = listening[0].FullName; } else { this._tests.Remove(i.ToString()); break; } } else if (string.Equals(part.Name, Common.READ)) { FileInfo[] reading = part.GetFiles(); if (reading.Length > 0) { test.Reading = reading[0].FullName; } else { this._tests.Remove(i.ToString()); break; } } } } }