Exemplo n.º 1
0
        public RowAnalized(RowAnalized rowAnalized, int position, CoreFile coreFile)
        {
            List <string> alphabet = new List <string> {
                "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
            };
            int    z         = 0;
            string rowIdtemp = rowAnalized.rowId;

            while (coreFile.rowsIdsOrdered.Contains(rowIdtemp + alphabet[z]))
            {
                z++;
            }
            rowId                = rowIdtemp + alphabet[z];
            hiddenContent        = "";
            visibleEditedContent = "";
            int index = coreFile.rowsIdsOrdered !.FindIndex(x => x == rowAnalized.rowId);

            if (index < coreFile.rowsIdsOrdered !.Count - 1)
            {
                coreFile.rowsIdsOrdered !.Insert(index + 1, rowId);
            }
Exemplo n.º 2
0
        public string GetEncodedTest(ParseType parseType, CoreFile coreFile)
        {
            switch (parseType)
            {
            case ParseType.LINEAR:
                if (formed)
                {
                    string test = "?\n";
                    foreach (string task1 in task)
                    {
                        RowAnalized rowAnalized = coreFile.analizedRowsList.Find(x => x.rowId == task1) !;
                        if (rowAnalized.includedToAnalysis)
                        {
                            test += rowAnalized.visibleEditedContent + " ";
                        }
                    }
                    foreach (string true1 in correctAnswers)
                    {
                        RowAnalized rowAnalized = coreFile.analizedRowsList.Find(x => x.rowId == true1) !;
                        if (rowAnalized.includedToAnalysis)
                        {
                            test += "\n+" + rowAnalized.visibleEditedContent;
                        }
                    }
                    foreach (string false1 in wrongAnswers)
                    {
                        RowAnalized rowAnalized = coreFile.analizedRowsList.Find(x => x.rowId == false1) !;
                        if (rowAnalized.includedToAnalysis)
                        {
                            test += "\n-" + rowAnalized.visibleEditedContent;
                        }
                    }
                    if (CountVisible(comments, coreFile) > 0)
                    {
                        test += "\n!\n";
                        foreach (string comment1 in comments)
                        {
                            RowAnalized rowAnalized = coreFile.analizedRowsList.Find(x => x.rowId == comment1) !;
                            if (rowAnalized.includedToAnalysis)
                            {
                                test += rowAnalized.visibleEditedContent + " ";
                            }
                        }
                    }
                    return(test + "\n");
                }
                break;

            case ParseType.PREMIUM:
                if (formed)
                {
                    string test = "::" + number + "::\n";
                    foreach (string task1 in task)
                    {
                        RowAnalized rowAnalized = coreFile.analizedRowsList.Find(x => x.rowId == task1) !;
                        if (rowAnalized.includedToAnalysis)
                        {
                            test += rowAnalized.visibleEditedContent + " ";
                        }
                    }
                    test += "\n{";
                    foreach (string true1 in correctAnswers)
                    {
                        RowAnalized rowAnalized = coreFile.analizedRowsList.Find(x => x.rowId == true1) !;
                        if (rowAnalized.includedToAnalysis)
                        {
                            test += "\n=" + rowAnalized.visibleEditedContent;
                        }
                    }
                    foreach (string false1 in wrongAnswers)
                    {
                        RowAnalized rowAnalized = coreFile.analizedRowsList.Find(x => x.rowId == false1) !;
                        if (rowAnalized.includedToAnalysis)
                        {
                            test += "\n~" + rowAnalized.visibleEditedContent;
                        }
                    }
                    if (CountVisible(comments, coreFile) > 0)
                    {
                        test += "\n#\n";
                        foreach (string comment1 in comments)
                        {
                            RowAnalized rowAnalized = coreFile.analizedRowsList.Find(x => x.rowId == comment1) !;
                            if (rowAnalized.includedToAnalysis)
                            {
                                test += rowAnalized.visibleEditedContent + " ";
                            }
                        }
                    }
                    return(test + "\n}\n");
                }

                break;
            }
            return("");
        }
Exemplo n.º 3
0
 public int CountVisible(List <string> ids, CoreFile coreFile)
 {
     return(ids.Count(id => coreFile.analizedRowsList.Find(x => x.rowId == id) !.includedToAnalysis));
 }
Exemplo n.º 4
0
        public RowAnalized(RowNative rowNative, FilterPatterns filterPatterns, CoreFile coreFile)
        {
            bool analized = false;

            content       = rowNative.content;
            nativeNumbers = new List <int> {
                rowNative.rowNumber
            };
            rowId = "row" + rowNative.rowNumber;
            includedToAnalysis = true;
            if (content.Trim() == "")
            {
                includedToAnalysis = false;
                if (filterPatterns.tasksDividedByNewRow)
                {
                    coreFile.OnNextTestDetected();
                }
            }
            else
            {
                int i = 0;
                while (!analized && i < filterPatterns.correctAnswerRegexes.Count)
                {
                    if (filterPatterns.correctAnswerRegexes[i].IsMatch(content))
                    {
                        analized = true;
                        MatchCollection match = filterPatterns.correctAnswerRegexes[i].Matches(content);
                        hiddenContent        = match[0].Value;
                        visibleEditedContent = content.Replace(hiddenContent, "").Trim();
                        testId = coreFile.tempTest.testId;
                        coreFile.tempTest.project.Add(rowId);
                        coreFile.tempTest.correctAnswers.Add(rowId);
                        rowType = RowType.CORRECT_ANSWER;
                    }
                    i++;
                }
                i = 0;
                while (!analized && i < filterPatterns.wrongAnswerRegexes.Count)
                {
                    if (filterPatterns.wrongAnswerRegexes[i].IsMatch(content))
                    {
                        analized = true;
                        MatchCollection match = filterPatterns.wrongAnswerRegexes[i].Matches(content);
                        hiddenContent        = match[0].Value;
                        visibleEditedContent = content.Replace(hiddenContent, "").Trim();
                        testId = coreFile.tempTest.testId;
                        coreFile.tempTest.project.Add(rowId);
                        coreFile.tempTest.wrongAnswers.Add(rowId);
                        rowType = RowType.WRONG_ANSWER;
                    }
                    i++;
                }
                if (coreFile.tempTest.correctAnswers.Count == 0)
                {
                    if (filterPatterns.taskRegexes[0].IsMatch(content))
                    {
                        MatchCollection match = filterPatterns.taskRegexes[0].Matches(content);
                        hiddenContent        = match[0].Value;
                        visibleEditedContent = content.Replace(hiddenContent, "").Trim();
                    }
                    else
                    {
                        visibleEditedContent = content.Trim();
                        hiddenContent        = "";
                    }
                    testId = coreFile.tempTest.testId;
                    coreFile.tempTest.project.Add(rowId);
                    coreFile.tempTest.task.Add(rowId);
                    rowType = RowType.TASK;
                }
                else
                {
                    if (!analized && !filterPatterns.tasksDividedByNewRow && coreFile.tempTest.wrongAnswers.Count > 0)
                    {
                        i = 0;
                        while (!analized && i < filterPatterns.taskRegexes.Count)
                        {
                            if (filterPatterns.taskRegexes[i].IsMatch(content))
                            {
                                coreFile.OnNextTestDetected();
                                MatchCollection match = filterPatterns.taskRegexes[i].Matches(content);
                                hiddenContent        = match[0].Value;
                                visibleEditedContent = content.Replace(hiddenContent, "").Trim();
                                testId = coreFile.tempTest.testId;
                                coreFile.tempTest.project.Add(rowId);
                                coreFile.tempTest.task.Add(rowId);
                                rowType = RowType.TASK;
                                return;
                            }
                            i++;
                        }
                    }
                    if ((!analized || coreFile.tempTest.wrongAnswers.Count == 0) && rowType != RowType.CORRECT_ANSWER)
                    {
                        hiddenContent        = "";
                        visibleEditedContent = content.Trim();
                        rowType = RowType.WRONG_ANSWER;
                        coreFile.tempTest.project.Add(rowId);
                        coreFile.tempTest.wrongAnswers.Add(rowId);
                        testId = coreFile.tempTest.testId;
                    }
                }
            }
        }
Exemplo n.º 5
0
        public ObjectMemento FindAndRestore(CoreFile coreFile)
        {
            RowAnalized?rowAnalized = coreFile.analizedRowsList.Find(x => x.rowId == rowId);

            return(rowAnalized?.RestoreState(this) !);
        }
Exemplo n.º 6
0
        public ObjectMemento FindAndRestore(CoreFile coreFile)
        {
            TestAnalized?testAnalized = coreFile.analizedTestsList.Find(x => x.testId == testId);

            return(testAnalized?.RestoreState(this) !);
        }