public bool IsPassed() { double l = ScoresUtils.GetMaxScores(TestCategory.LISTENING) * 0.3; double r = ScoresUtils.GetMaxScores(TestCategory.READING) * 0.3; double s = ScoresUtils.GetMaxScores(TestCategory.SPEAKING) * 0.3; double w = ScoresUtils.GetMaxScores(TestCategory.WRITING) * 0.3; if (ListeningTestPaper.Part1Scores + ListeningTestPaper.Part1Scores < l) { return(false); } if (ReadingTestPaper.ReadingPartOnes.Scores + ReadingTestPaper.ReadingPartTwos.Scores + ReadingTestPaper.ReadingPartThrees.Scores + ReadingTestPaper.ReadingPartFours.Scores < r) { return(false); } if (SpeakingTestPaper.SpeakingPart.Scores < s) { return(false); } if (WritingTestPaper.WritingPartOnes.Scores + WritingTestPaper.WritingPartTwos.Scores < w) { return(false); } return(true); }
/// <summary> /// Tính toán số điểm /// </summary> public float ScoreCalculate(ListeningTestPaper paper) { // Tính điểm cho part 1 var totalTrue1 = CalculateTrueOfPart(1, paper); if (totalTrue1 >= 0) { Part1Scores = ScoresUtils.ScoresCalculate(totalTrue1, ListeningPartOnes.Count, Config.SCORES_FULL_LISTENING_PART_1); } // Tính điểm cho part 2 var totalTrue2 = CalculateTrueOfPart(2, paper); if (totalTrue2 >= 0) { Part2Scores = ScoresUtils.ScoresCalculate(totalTrue2, ListeningPartTwos.Sum(x => x.ListeningBaseQuestions.Count) * ListeningPartTwos.Count, Config.SCORES_FULL_LISTENING_PART_2); } if (Part1Scores >= 0 && Part2Scores >= 0) { return(Part1Scores + Part2Scores); } else { return(-1); } }
public float ScoresCalculate(ReadingTestPaper paper) { // Tính điểm cho part 1 var totalTrue1 = CalculateTrueOfPart(1, paper); if (totalTrue1 >= 0) { ReadingPartOnes.Scores = ScoresUtils.ScoresCalculate(totalTrue1, ReadingPartOnes.ReadingPart.Count, Config.SCORES_FULL_READING_PART_1); } // Tính điểm cho part 2 var totalTrue2 = CalculateTrueOfPart(2, paper); if (totalTrue2 >= 0) { ReadingPartTwos.Scores = ScoresUtils.ScoresCalculate(totalTrue2, ReadingPartTwos.ReadingPart.Count, Config.SCORES_FULL_READING_PART_2); } // Tính điểm cho part 3 var totalTrue3 = CalculateTrueOfPart(3, paper); if (totalTrue3 >= 0) { ReadingPartThrees.Scores = ScoresUtils.ScoresCalculate(totalTrue3, ReadingPartThrees.ReadingPart.Count, Config.SCORES_FULL_READING_PART_3); } // Tính điểm cho part 4 var totalTrue4 = CalculateTrueOfPart(4, paper); if (totalTrue4 >= 0) { ReadingPartFours.Scores = ScoresUtils.ScoresCalculate(totalTrue4, ReadingPartFours.ReadingPart.Count, Config.SCORES_FULL_READING_PART_4); } if (ReadingPartOnes.Scores >= 0 && ReadingPartTwos.Scores >= 0 && ReadingPartThrees.Scores >= 0 && ReadingPartFours.Scores >= 0) { return(ReadingPartOnes.Scores + ReadingPartTwos.Scores + ReadingPartThrees.Scores + ReadingPartFours.Scores); } else { return(-1); } }
public float ScoreCalculate(WritingTestPaper resultPaper) { if (WritingPartOnes.WritingPart != null && WritingPartOnes.WritingPart.Count > 0 && resultPaper.WritingPartOnes.WritingPart != null && WritingPartOnes.WritingPart.Count == resultPaper.WritingPartOnes.WritingPart.Count) { // Tính số câu đúng int count = 0; for (int i = 0; i < WritingPartOnes.WritingPart.Count; i++) { try { // Lấy câu trả lời mà học viên đã nhập vào string answerInputed = WritingPartOnes.WritingPart[i].Answers; // Nếu câu trả lời khớp với bất kỳ đáp án nào, tiến hành cho điểm if (resultPaper.WritingPartOnes .WritingPart[i] .BaseAnswers .Any(x => x.AnswerContent != null && x.AnswerContent.ToLower().Trim() == answerInputed.ToLower().Trim())) { count++; } } catch (Exception) { // Bỏ qua } } // Tính điểm luôn cho part 1 WritingPartOnes.Scores = ScoresUtils.ScoresCalculate(count, TotalQuestions(), Config.SCORES_FULL_WRITING_PART_1); return(WritingPartOnes.Scores); } else { return(-1); } }
public IActionResult Result(int id, params float[] scoresPart) { if (id <= 0) { return(BadRequest()); } var piece = _PieceOfTestManager.Get(id); if (piece == null) { return(NotFoundTest()); } if (piece.InstructorId != User.Id() && piece.UserId != User.Id()) { this.NotifyError("You are not authorized to view or manipulate this test"); return(RedirectToAction(nameof(HomeController.Index), NameUtils.ControllerName <HomeController>())); } ViewBag.Title = $"{piece.TypeCode.ToUpper()} TESTING RESULT"; if (piece.Scores >= 0) { ViewBag.Scores = piece.Scores; } else { ViewBag.Scores = 0; } ViewBag.MaxScores = ScoresUtils.GetMaxScores(piece.TypeCode); // Nếu đây là bài thi viết if (piece.TypeCode == TestCategory.WRITING) { // Cập nhật điểm mới của phần cho đúng ViewBag.Scores = scoresPart[0]; // Cập nhật điểm gới hạn cho đúng ViewBag.MaxScores = Config.SCORES_FULL_WRITING_PART_1; // Gắn cờ xác minh ViewBag.IsWriting = true; // Đổi tin nhắn thông báo thành công ViewBag.Msg = "Congratulations, you finished the test, with <span class=\"font-weight-bold text-danger\">PART 1</span> score is"; } if (piece.TypeCode == TestCategory.SPEAKING) { ViewBag.IsSpeaking = true; // Đổi tin nhắn thông báo thành công ViewBag.Msg = "<i class=\"\">Congratulations, you finished the test, your teacher will review your test and mark for you later.</i>"; } if (piece.TypeCode == TestCategory.TEST_ALL) { //ViewBag.Title = "GENERAL TESTING RESULT"; //ViewBag.IsGeneral = true; //// Đổi tin nhắn thông báo thành công //ViewBag.Msg = "<i class=\"\">Congratulations, you finished the test, your teacher will review your test and mark for you later.</i>"; this.NotifySuccess("Here are the results of your test"); return(RedirectToAction(nameof(GeneralReview), new { piece.Id })); } this.NotifySuccess("Your test is completed!"); return(View(piece)); }
public bool IsPassed() { return(Scores >= ScoresUtils.GetThresholdPoint(TypeCode)); }
public long FaildTestsCount(long userId, string typeCode = "") { float threshold = 0; // Lấy các bài thi đã hoàn thành của user để xét var query = instantce.PieceOfTests .Where(x => x.UserId == userId && !string.IsNullOrEmpty(x.ResultOfUserJson)); // Nếu không có thì bỏ qua if (query.Count() <= 0) { return(0); } // Lấy tiếp các bài thuộc kiểu nếu có if (!string.IsNullOrEmpty(typeCode)) { query = query.Where(x => x.TypeCode == typeCode); } // Nếu không có thì bỏ qua if (query.Count() <= 0) { return(0); } // Nếu thuộc LISTENTING if (TestCategory.LISTENING == typeCode) { threshold = ScoresUtils.GetThresholdPoint(TestCategory.LISTENING); } // Nếu thuộc READING if (TestCategory.READING == typeCode) { threshold = ScoresUtils.GetThresholdPoint(TestCategory.READING); } // Nếu thuộc SPEAKING if (TestCategory.SPEAKING == typeCode) { threshold = ScoresUtils.GetThresholdPoint(TestCategory.SPEAKING); } // Nếu thuộc WRITING if (TestCategory.WRITING == typeCode) { threshold = ScoresUtils.GetThresholdPoint(TestCategory.WRITING); } // Nếu thuộc GENERAL if (TestCategory.TEST_ALL == typeCode) { threshold = ScoresUtils.GetThresholdPoint(TestCategory.TEST_ALL); // Đếm các bài thi không đạt chuẩn int resNo = query.Where(x => x.Scores < threshold).Count(); // Trả về số lượng các bài thi dạt chuẩn để tìm các bài dính điểm liệt trong các phần query = query.Where(x => x.Scores >= threshold); List <string> gpJson = query.Select(x => x.ResultOfUserJson).ToList(); int res = 0; foreach (string s in gpJson) { var gp = JsonConvert.DeserializeObject <GeneralTestPaper>(s); if (gp != null && !gp.IsPassed()) { res++; } } return(res + resNo); } // Trả về số lượng các bài thi dạt chuẩn return(query.Where(x => x.Scores < threshold).Count()); }