public static List <ExamTest> GetQuestionForTestExam(String courseCode, String level, int quantity) { String query = "Exec sp_GetQuestion '" + courseCode + "', '" + level + "', " + quantity; SqlDataReader reader = ExecSqlDataReader(query); List <ExamTest> listExam = new List <ExamTest>(); while (reader.Read()) { ExamTest exam = new ExamTest { QuestionCode = reader.GetInt32(0), QuestionContent = reader.GetString(1), A = reader.GetString(2), B = reader.GetString(3), C = reader.GetString(4), D = reader.GetString(5), TrueAnswer = reader.GetString(6), YourAnswer = String.Empty }; listExam.Add(exam); } reader.Close(); // <- too easy to forget reader.Dispose(); // <- too easy to forget return(listExam); }
/// <summary> /// Randoms the words. /// </summary> /// <param name="model">The model.</param> /// <returns> /// Exam words for test /// </returns> public async Task <ExamTest> RandomWords(StartRequestExamTestModel model) { var knownLanguageType = await _flashcardDbContext.LanguageTypes.FirstOrDefaultAsync(l => l.Id == model.KnownLanguageTypeId); if (knownLanguageType == null) { throw new NotFoundException("Known language type not found"); } var learningLanguageType = await _flashcardDbContext.LanguageTypes.FirstOrDefaultAsync(l => l.Id == model.LearningLanguageTypeId); if (learningLanguageType == null) { throw new NotFoundException("Learning language type not found"); } var examTest = new ExamTest { KnownLanguageType = knownLanguageType, LearningLanguageType = learningLanguageType, Created = DateTime.Now }; using (var transaction = _flashcardDbContext.Database.BeginTransaction()) { try { await _flashcardDbContext.ExamTests.AddAsync(examTest); var examTestWords = (await _wordService.GetRandomWords(model.CategoryId, model.WordsLength))?.Select(w => new ExamTestWord { ExamTest = examTest, Word = w }) ?? new List <ExamTestWord>(); if (!examTestWords.Any()) { throw new BadRequestException("No words to fetch"); } await _flashcardDbContext.ExamTestWords.AddRangeAsync(examTestWords); _flashcardDbContext.SaveChanges(); } catch { transaction.Rollback(); throw; } } return(examTest); }
public void Insert_AddedElementWithIndexMinus3_Minus3ReturnedIndexAddedElement() { ExamTest student = new ExamTest("Стратила", "Математика", 90, new DateTime(2017, 5, 10)); students.Insert(-5, student); int expected = -5; int actual = students.IndexOf(student); Assert.AreEqual(expected, actual); }
private void Init() { ExamTest exam = _listQuestion[_currentQuestionIndex]; lbl_Question.Text = "Câu số " + (_currentQuestionIndex + 1) + "/ " + _testInfo.listQuestion.Count; txt_QuestionContent.Text = exam.QuestionContent; txt_A.Text = exam.A; txt_B.Text = exam.B; txt_C.Text = exam.C; txt_D.Text = exam.D; btn_Previous.Enabled = false; btn_Submit.Visible = false; lbl_Info.Text = _testInfo.StudentName + "-" + _testInfo.StudentCode + "- Bài thi môn " + _testInfo.CourseName; }
static void Main(string[] args) { ExamTest studValue1 = new ExamTest("Христич", "Математика", 100, new DateTime(2018, 10, 10)); ExamTest studValue2 = new ExamTest("Бартов", "Математика", 70, new DateTime(2017, 4, 12)); ExamTest studValue3 = new ExamTest("Пасечник", "Математика", 80, new DateTime(2016, 2, 3)); ExamTest studValue4 = new ExamTest("Стратила", "Математика", 90, new DateTime(2017, 5, 10)); ExamTest studValue5 = new ExamTest("Черепанцева", "Математика", 85, new DateTime(2018, 10, 1)); BinaryTree <ExamTest> treeExam = new BinaryTree <ExamTest>(studValue3); int numValue1 = 4; int numValue2 = 2; int numValue3 = 5; int numValue4 = 1; int numValue5 = 3; int numValue6 = 7; int numValue7 = 8; int numValue8 = 6; BinaryTree <int> treeInteger = new BinaryTree <int>(numValue1); treeInteger.Added += Message; treeInteger.Add(numValue2); treeInteger.Add(numValue3); treeInteger.Add(numValue4); treeInteger.Add(numValue5); treeInteger.Add(numValue6); treeInteger.Add(numValue7); treeInteger.Add(numValue8); treeExam.Add(studValue1); treeExam.Add(studValue2); treeExam.Add(studValue4); treeExam.Add(studValue5); foreach (var i in treeInteger) { Console.WriteLine(i); } foreach (var i in treeExam.PreOrderTraversal()) { Console.WriteLine(i); } Console.Read(); }
static void Main(string[] args) { MyArray <ExamTest> testArray1 = new MyArray <ExamTest>(-10, -3); ExamTest s1 = new ExamTest("Христич", "Математика", 100, new DateTime(2018, 10, 10)); ExamTest s2 = new ExamTest("Бартов", "Математика", 70, new DateTime(2017, 4, 12)); ExamTest s3 = new ExamTest("Пасечник", "Математика", 80, new DateTime(2016, 2, 3)); ExamTest s4 = new ExamTest("Стратила", "Математика", 90, new DateTime(2017, 5, 10)); ExamTest s5 = new ExamTest("Черепанцева", "Математика", 85, new DateTime(2018, 10, 1)); ExamTest s6 = new ExamTest("Демченко", "Математика", 85, new DateTime(2018, 10, 1)); ExamTest s7 = new ExamTest("Демченко", "Математика", 85, new DateTime(2018, 10, 1)); ExamTest s8 = new ExamTest("Демченко", "Математика", 85, new DateTime(2018, 10, 1)); testArray1.Add(s1); testArray1.Add(s2); testArray1.Add(s3); testArray1.Add(s4); MyArray <int> testArray2 = new MyArray <int>(-5, 2) { 1, 5, 6, 8, 9, 2 }; Console.WriteLine(testArray2[-5]); int[] arr1 = new int[10]; testArray2.CopyTo(arr1, 0); List <int> list1 = new List <int> { 1, 2, 3, 5, 5, 5, 5, 5 }; MyArray <int> testArray3 = new MyArray <int>(list1); foreach (var kek in testArray1) { Console.WriteLine(kek); } Console.WriteLine(); foreach (var kek in testArray2) { Console.WriteLine(kek); } Console.WriteLine(); foreach (var kek in arr1) { Console.WriteLine(kek); } }
private object[] SetupData(int index, ExamTest test) { StringBuilder stringBuilder = new StringBuilder("A. " + test.A); stringBuilder.AppendLine("B. " + test.B); stringBuilder.AppendLine("C. " + test.C); stringBuilder.AppendLine("D. " + test.D); return(new object[] { index , test.QuestionCode , test.QuestionContent , stringBuilder , test.TrueAnswer , test.YourAnswer }); }
private void ShowQuestionByIndex(int questionIndex) { ExamTest exam = _listQuestion[questionIndex]; lbl_Question.Text = "Câu số " + (questionIndex + 1) + "/ " + _testInfo.listQuestion.Count; txt_QuestionContent.Text = exam.QuestionContent; txt_A.Text = exam.A; txt_B.Text = exam.B; txt_C.Text = exam.C; txt_D.Text = exam.D; switch (exam.YourAnswer) { case "A": this.rdb_A.Checked = true; return; case "B": this.rdb_B.Checked = true; return; case "C": this.rdb_C.Checked = true; return; case "D": this.rdb_D.Checked = true; return; default: this.rdb_A.Checked = false; this.rdb_B.Checked = false; this.rdb_C.Checked = false; this.rdb_D.Checked = false; break; } }
public void TestInitialize() { students = new MyArray <ExamTest>(-6, -2); testExam = new ExamTest("Христич", "Математика", 100, new DateTime(2018, 10, 10)); students.Add(testExam); }
public List <ExamTest> StudentReportByStudentAndTerm(Guid studentId, Guid termID, ref List <ExamDto> exams, ref List <TestMarkDto> allTests, ref StringBuilder sbError) { bool dbEror = false; var student = _uofRepository.StudentTermRegisterRepository.GetByStudentIDAndTermId(studentId, termID, ref dbEror); if (student == null) { sbError.Append("Student was not registered for that term"); return(null); } var studentInformation = _uofRepository.StudentTermRegisterRepository.GetByID((Guid)student.StudentTermRegisterID, ref dbEror); var term = _uofRepository.TermRepository.GetByID(termID, ref dbEror); if (studentInformation == null) { sbError.Append("Student was not registered for that term"); return(null); } if (term == null) { sbError.Append("Term does not exist"); return(null); } var studentExam = _uofRepository.ExamRepository.GetListExamByStudentTermRegisterIDAndTermID((Guid)student.StudentTermRegisterID, termID, ref dbEror) ?? new List <ExamDto>(); var studentTest = _uofRepository.TestMarkRepository.GetListTestMarksByStudentTermRegisterIDAndTermID((Guid)student.StudentTermRegisterID, termID, ref dbEror) ?? new List <TestMarkDto>(); allTests = studentTest; exams = studentExam; List <ExamTest> report = new List <ExamTest>(); foreach (var mark in studentExam) { var testList = studentTest.Where(c => c.SubjectCode == mark.SubjectCode); ExamTest row = new ExamTest(); row.SubjectCode = mark.SubjectCode; row.SubjectName = mark.SubjectName; row.Grade = mark.Grade; row.Exam = mark.Mark; row.TestWritten = testList?.Count() ?? 0; var testAverageValue = 0; if (row.TestWritten > 0) { testAverageValue = Convert.ToInt32(testList.Average(c => c.MarkPercentage)); } row.TestAverage = testAverageValue; try { row.TestPassed = testList?.Where(c => c.MarkPercentage >= 50M)?.Count() ?? 0; } catch { } try { row.TestFailed = testList?.Where(c => c.MarkPercentage < 50M)?.Count() ?? 0; } catch { } var examAverage = mark.Mark; var variancePercentage = mark.Mark - testAverageValue; if (variancePercentage <= 0) { variancePercentage = -1 * variancePercentage; } row.VariancePercentage = variancePercentage; report.Add(row); } if (studentTest == null || studentTest.Count() <= 0) { return(report); } var uniqueSubject = studentTest.Select(c => c.SubjectCode).Distinct(); foreach (var subject in uniqueSubject) { var isExistInExam = report?.Where(c => c.SubjectCode == subject)?.FirstOrDefault(); if (isExistInExam != null) { continue; } var testList = studentTest?.Where(c => c.SubjectCode == subject); var mark = testList?.FirstOrDefault(); if (mark == null) { continue; } ExamTest row = new ExamTest(); row.SubjectCode = mark.SubjectCode; row.SubjectName = mark.SubjectName; row.Grade = ""; row.Exam = 0; row.TestWritten = testList?.Count() ?? 0; if (row.TestWritten > 0) { row.TestAverage = Convert.ToInt32(testList.Average(c => c.MarkPercentage)); } try { row.TestPassed = testList?.Where(c => c.MarkPercentage >= 50M)?.Count() ?? 0; } catch { } try { row.TestFailed = testList?.Where(c => c.MarkPercentage < 50M)?.Count() ?? 0; } catch { } row.VariancePercentage = row.TestAverage; report.Add(row); } return(report); }