public void CheckForSimilarityOfQuestionsTest()
        {
            List <ExamEntity> exams = DataGenerator.Initialize(null);

            ExamEntity theExam = exams.FirstOrDefault(e => e.Code.Equals("az-900", StringComparison.CurrentCultureIgnoreCase));

            List <QuestionEntity> allquestions = theExam.Questions;

            List <double> distances = new List <double>();

            List <Tuple <QuestionEntity, QuestionEntity, string> > duplicatesLists =
                new List <Tuple <QuestionEntity, QuestionEntity, string> >();

            List <Tuple <QuestionEntity, QuestionEntity, double> > distanceListAllQuestions =
                new List <Tuple <QuestionEntity, QuestionEntity, double> >();

            for (int i = 0; i < allquestions.Count; i++)
            {
                for (int j = i + 1; j < allquestions.Count; j++)
                {
                    QuestionEntity q1 = allquestions[i];
                    QuestionEntity q2 = allquestions[j];

                    string text1 = q1.ContentText.Replace(" ", string.Empty) + q1.AnswerText.Replace(" ", string.Empty);

                    string text2 = q2.ContentText.Replace(" ", string.Empty) + q2.AnswerText.Replace(" ", string.Empty);

                    string helperTextForDebug = $"{q1.Id + 1}{text1}{Environment.NewLine}{Environment.NewLine}{Environment.NewLine}{q2.Id + 1}{text2}";

                    double distance = LevenshteinDistance.CalculateSimilarity(text1, text2);
                    distances.Add(Math.Round(distance, 2));
                    if (distance > 0.81)
                    {
                        duplicatesLists.Add(new Tuple <QuestionEntity, QuestionEntity, string>(
                                                q1, q2, distance.ToString()));

                        string textToSee = $"{text1} {Environment.NewLine}{Environment.NewLine} {text2}";
                    }

                    distanceListAllQuestions.Add(new Tuple <QuestionEntity, QuestionEntity, double>(
                                                     q1, q2, distance));
                }
            }
            string duplicateResultHelper = string.Join("\r\n\r\n\r\n", duplicatesLists.Select(s => s.Item1.ContentText + " ----- " + s.Item2.ContentText).ToList());

            distances = distances.OrderByDescending(d => d).ToList();

            distanceListAllQuestions = distanceListAllQuestions.OrderByDescending(d => d.Item3).ToList();
        }
        public void CheckForSimilarityOfCustomTextTest()
        {
            List <ExamEntity> exams = DataGenerator.Initialize(null);

            ExamEntity theExam = exams.FirstOrDefault(e => e.Code.Equals("AZ-900"));

            List <QuestionEntity> allquestions = theExam.Questions;

            List <double> distances = new List <double>();

            List <Tuple <QuestionEntity, QuestionEntity, string> > duplicatesLists =
                new List <Tuple <QuestionEntity, QuestionEntity, string> >();

            for (int i = 0; i < allquestions.Count; i++)
            {
                QuestionEntity q1 = allquestions[i];

                string text1 = q1.ContentText.Replace(" ", string.Empty) + q1.AnswerText.Replace(" ", string.Empty);

                string questionText = @"This question requires that you evaluate the underlined text to determine if it is correct.
When you are implementing a software as a service (SaaS) solution, you are responsible for configuring high availability.
Instructions: Review the underlined text. If it makes the statement correct, select If the statement is incorrect, select the answer choice that makes the statement correct.
A.No change is needed.
B.defining scalability rules
C.installing the SaaS solution
D.configuring the SaaS solution


";
                string answerText   = string.Empty;

                string text2 = questionText.Replace(" ", string.Empty); // + answerText.Replace(" ", string.Empty);

                string helperTextForDebug = $"{q1.Id + 1}{text1}{Environment.NewLine}{Environment.NewLine}{Environment.NewLine}{q1.Id + 1}{text2}";

                double distance = LevenshteinDistance.CalculateSimilarity(text1, text2);
                distances.Add(Math.Round(distance, 2));
                if (distance > 0.81)
                {
                    duplicatesLists.Add(new Tuple <QuestionEntity, QuestionEntity, string>(
                                            q1, q1, distance.ToString()));

                    string textToSee = $"{text1} {Environment.NewLine}{Environment.NewLine} {text2}";
                }
            }
            distances = distances.OrderByDescending(d => d).ToList();
        }
Ejemplo n.º 3
0
        public void PreloadSiteTest()
        {
            var ExamsToCheck = DataGenerator.Initialize(null);


            Parallel.ForEach(ExamsToCheck, (exam) =>
            {
                ChromeOptions chromeOptions = new ChromeOptions();
                chromeOptions.SetLoggingPreference(LogType.Browser, LogLevel.All);
                chromeOptions.AcceptInsecureCertificates = true;

                string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                using (ChromeDriver driver = new ChromeDriver(path, chromeOptions))
                {
                    for (int i = 1; i <= exam.Questions.Count; i++)
                    {
                        driver.Navigate().GoToUrl($"https://www.exam-answer.com/{exam.Provider}/{exam.Code}/question{i}");
                    }
                }
            });



            //ChromeOptions chromeOptions = new ChromeOptions();
            //chromeOptions.SetLoggingPreference(LogType.Browser, LogLevel.All);
            //chromeOptions.AcceptInsecureCertificates = true;

            //string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            //using (ChromeDriver driver = new ChromeDriver(path, chromeOptions))
            //{
            //    for (int i = 1; i <= 340; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/amazon/saa-c01/question{i}");
            //    }
            //    for (int i = 1; i <= 130; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/microsoft/az-900/question{i}");
            //    }

            //    for (int i = 1; i <= 60; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/salesforce/salesforce-certified-field-service-lightning-consultant/question{i}");
            //    }

            //    for (int i = 1; i <= 100; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/salesforce/crt-251/question{i}");
            //    }

            //    for (int i = 1; i <= 112; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/microsoft/az-100/question{i}");
            //    }

            //    for (int i = 1; i <= 243; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/microsoft/az-300/question{i}");
            //    }

            //    for (int i = 1; i <= 73; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/microsoft/az-400/question{i}");
            //    }
            //}
        }
 public ValidateQuestionsTests()
 {
     ExamsToCheck = DataGenerator.Initialize(null);
     //ExamsToCheck = ExamsToCheck.Where(e => !e.Code.Equals("AZ-100", StringComparison.CurrentCultureIgnoreCase)).ToList();
 }
Ejemplo n.º 5
0
        public void CreateExportForUdemyTest()
        {
            List <ExamEntity> exams = DataGenerator.Initialize(null);

            ExamEntity theExamToExportToUdemy = exams.FirstOrDefault(f => f.Code == "AZ-900");

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Question,Question Type (multiple-choice or multi-select),Answer Option 1,Answer Option 2,Answer Option 3,Answer Option 4,Answer Option 5,Answer Option 6,Correct Response,Explanation,Knowledge Area");

            List <QuestionEntity> theQuestions = theExamToExportToUdemy.Questions.Skip(50).Take(50).ToList();

            foreach (QuestionEntity question in theQuestions)
            {
                if (!question.Answers.Any(a => a.IsCorrect == true))
                {
                    continue;
                }

                sb.Append(question.ContentTextUdemy.Replace("\"", "\"\"").Replace(",", ""));
                sb.Append(",");

                if (question.QuestionType == QuestionType.RadioButon)
                {
                    sb.Append("multiple-choice");
                    sb.Append(",");
                }
                else if (question.QuestionType == QuestionType.CheckBox)
                {
                    sb.Append("multi-select");
                    sb.Append(",");
                }

                for (int i = 0; i < 6; i++)
                {
                    if (i < question.Answers?.Count)
                    {
                        AnswerEntity answer = question.Answers[i];
                        sb.Append(answer.Text.Replace("\"", "\"\"").Replace(",", ""));
                        sb.Append(",");
                    }
                    else
                    {
                        //sb.Append(string.Empty);
                        sb.Append(",");
                    }
                }
                if (question.QuestionType == QuestionType.CheckBox)
                {
                    sb.Append("\"");
                }
                for (int i = 0; i < 6; i++)
                {
                    if (i < question.Answers?.Count)
                    {
                        AnswerEntity answer = question.Answers[i];

                        if (answer.IsCorrect == true)
                        {
                            int indexToInsert = question.Answers.IndexOf(answer) + 1;
                            sb.Append(indexToInsert);
                            if (question.QuestionType == QuestionType.CheckBox)
                            {
                                sb.Append(",");
                            }
                        }
                    }
                }

                sb = new StringBuilder(sb.ToString().Trim(','));

                if (question.QuestionType == QuestionType.CheckBox)
                {
                    sb.Append("\"");
                }
                sb.Append(",");
                if (!string.IsNullOrEmpty(question.ExplanationText))
                {
                    sb.Append(question.ExplanationTextUdemy.Replace(",", ""));
                    sb.Append("References: ");
                    sb.Append(question.ReferenceTextUdemy.Replace(",", ""));
                }

                sb.Append(",");

                string knowledgeArea = question.Section.Replace(",", "");

                sb.Append(knowledgeArea);

                sb.Append(Environment.NewLine);
            }

            string result = sb.ToString();

            File.WriteAllText($"BulkImportUdemy{theExamToExportToUdemy.Code}.csv", result);
        }