示例#1
0
 private int CalculateTrueOfPart1(ReadingTestPaper paper)
 {
     if (ReadingPartOnes.ReadingPart != null &&
         ReadingPartOnes.ReadingPart.Count > 0 &&
         paper.ReadingPartOnes.ReadingPart != null &&
         ReadingPartOnes.ReadingPart.Count == paper.ReadingPartOnes.ReadingPart.Count)
     {
         int count = 0;
         for (int i = 0; i < ReadingPartOnes.ReadingPart.Count; i++)
         {
             try
             {
                 string trueAnswerOfCurrent     = ReadingPartOnes.ReadingPart[i].AnswerList.First(x => x.IsCorrect).AnswerContent;
                 string trueAnswerOfDestination = paper.ReadingPartOnes.ReadingPart[i].AnswerList.First(x => x.IsCorrect).AnswerContent;
                 if (trueAnswerOfCurrent.ToLower().Trim() == trueAnswerOfDestination.ToLower().Trim())
                 {
                     count++;
                 }
             }
             catch (Exception)
             {
                 // Bỏ qua
             }
         }
         return(count);
     }
     else
     {
         return(-1);
     }
 }
示例#2
0
        /// <summary>
        /// Phương thức kiểm tra xem dã đầy đủ câu trả lời chưa, nếu chưa trả về lỗi, còn không bỏ trống
        /// </summary>
        public string IsFullAnswers()
        {
            if (!Config.IsCheckFullTestPaper)
            {
                return(string.Empty);
            }

            if (!ListeningTestPaper.IsPaperFullSelection())
            {
                return("You have not yet answered all the questions of the Listening test");
            }

            if (!ReadingTestPaper.IsPaperFullSelection())
            {
                return("You have not yet answered all the questions of the Reading test");
            }

            if (!WritingTestPaper.IsPaperFullSelection())
            {
                return("You have not written the Writing Part 2 section");
            }

            if (string.IsNullOrEmpty(WritingTestPaper.WritingPartTwos.UserParagraph))
            {
                return("You have not yet answered all the questions of the Writing test");
            }

            // Đã đầy đủ thì trả về rỗng
            return(string.Empty);
        }
示例#3
0
 public void ClearTrueAnswers()
 {
     ReadingTestPaper.RemoveCorrectAnswers();
     ListeningTestPaper.RemoveCorrectAnswers();
     // Xóa answers writing
     for (int i = 0; i < WritingTestPaper.WritingPartOnes.WritingPart.Count; i++)
     {
         WritingTestPaper.WritingPartOnes.WritingPart[i].Answers = string.Empty;
     }
 }
示例#4
0
        public void ScoreCalculate(GeneralTestPaper resultPaper)
        {
            // Tính điểm cho Listening
            ListeningTestPaper.ScoreCalculate(resultPaper.ListeningTestPaper);

            // Tính điểm cho READING
            ReadingTestPaper.ScoresCalculate(resultPaper.ReadingTestPaper);

            // Tính điểm cho Writin Part 1
            WritingTestPaper.ScoreCalculate(resultPaper.WritingTestPaper);

            // Điểm tổng phải là -1 kèm WRITING PART 2 và SPEAKING
            WritingTestPaper.WritingPartTwos.Scores = -1;
            SpeakingTestPaper.SpeakingPart.Scores   = -1;
        }
示例#5
0
 public int CalculateTrueOfPart(int partId, ReadingTestPaper paper)
 {
     if (partId == 1)
     {
         return(CalculateTrueOfPart1(paper));
     }
     else if (partId > 1 && partId <= 4)
     {
         List <ReadingPartTwo> current = new[] { ReadingPartTwos, ReadingPartThrees, ReadingPartFours }[partId - 2].ReadingPart;
         List <ReadingPartTwo> dest    = new[] { paper.ReadingPartTwos, paper.ReadingPartThrees, paper.ReadingPartFours }[partId - 2].ReadingPart;
         if (current != null &&
             current.Count > 0 &&
             dest != null &&
             current.Count == dest.Count)
         {
             int count = 0;
             for (int i = 0; i < current.Count; i++)
             {
                 try
                 {
                     string trueAnswerOfCurrent     = current[i].AnswerList.First(x => x.IsCorrect).AnswerContent;
                     string trueAnswerOfDestination = dest[i].AnswerList.First(x => x.IsCorrect).AnswerContent;
                     if (trueAnswerOfCurrent.ToLower().Trim() == trueAnswerOfDestination.ToLower().Trim())
                     {
                         count++;
                     }
                 }
                 catch (Exception)
                 {
                     // Bỏ qua
                 }
             }
             return(count);
         }
         else
         {
             return(-1);
         }
     }
     else
     {
         throw new Exception("Reading không có quá 4 PART!");
     }
 }
示例#6
0
        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);
            }
        }
示例#7
0
        public ReadingTestPaper CopySelectedAnswers(ReadingTestPaper paper)
        {
            if (ReadingPartOnes.ReadingPart != null &&
                paper.ReadingPartOnes.ReadingPart != null &&
                ReadingPartOnes.ReadingPart.Count == paper.ReadingPartOnes.ReadingPart.Count)
            {
                for (int i = 0; i < ReadingPartOnes.ReadingPart.Count; i++)
                {
                    var correctIndex = paper.ReadingPartOnes.ReadingPart[i].AnswerList.FindIndex(0,
                                                                                                 paper.ReadingPartOnes.ReadingPart[i].AnswerList.Count, x => x.IsCorrect);
                    if (correctIndex >= 0)
                    {
                        ReadingPartOnes.ReadingPart[i].AnswerList[correctIndex].IsCorrect = true;
                    }
                }
            }

            if (ReadingPartTwos.ReadingPart != null &&
                paper.ReadingPartTwos.ReadingPart != null &&
                ReadingPartTwos.ReadingPart.Count == paper.ReadingPartTwos.ReadingPart.Count)
            {
                for (int i = 0; i < ReadingPartTwos.ReadingPart.Count; i++)
                {
                    var correctIndex = paper.ReadingPartTwos.ReadingPart[i].AnswerList.FindIndex(0,
                                                                                                 paper.ReadingPartTwos.ReadingPart[i].AnswerList.Count, x => x.IsCorrect);
                    if (correctIndex >= 0)
                    {
                        ReadingPartTwos.ReadingPart[i].AnswerList[correctIndex].IsCorrect = true;
                    }
                }
            }

            if (ReadingPartThrees.ReadingPart != null &&
                paper.ReadingPartThrees.ReadingPart != null &&
                ReadingPartThrees.ReadingPart.Count == paper.ReadingPartThrees.ReadingPart.Count)
            {
                for (int i = 0; i < ReadingPartThrees.ReadingPart.Count; i++)
                {
                    var correctIndex = paper.ReadingPartThrees.ReadingPart[i].AnswerList.FindIndex(0,
                                                                                                   paper.ReadingPartThrees.ReadingPart[i].AnswerList.Count, x => x.IsCorrect);
                    if (correctIndex >= 0)
                    {
                        ReadingPartThrees.ReadingPart[i].AnswerList[correctIndex].IsCorrect = true;
                    }
                }
            }

            if (ReadingPartFours.ReadingPart != null &&
                paper.ReadingPartFours.ReadingPart != null &&
                ReadingPartFours.ReadingPart.Count == paper.ReadingPartFours.ReadingPart.Count)
            {
                for (int i = 0; i < ReadingPartFours.ReadingPart.Count; i++)
                {
                    var correctIndex = paper.ReadingPartFours.ReadingPart[i].AnswerList.FindIndex(0,
                                                                                                  paper.ReadingPartFours.ReadingPart[i].AnswerList.Count, x => x.IsCorrect);
                    if (correctIndex >= 0)
                    {
                        ReadingPartFours.ReadingPart[i].AnswerList[correctIndex].IsCorrect = true;
                    }
                }
            }
            return(this);
        }
示例#8
0
        public float ScoresCalculate(string readingTestPaperJson)
        {
            ReadingTestPaper paper = JsonConvert.DeserializeObject <ReadingTestPaper>(readingTestPaperJson);

            return(ScoresCalculate(paper));
        }