using System;
using System.Data;
using System.Text.RegularExpressions;

namespace teacher_exam_server.publicClass
{
    // Token: 0x0200001D RID: 29
    internal class examinationPaperEntry
    {
        // Token: 0x17000020 RID: 32
        // (get) Token: 0x06000165 RID: 357 RVA: 0x00016396 File Offset: 0x00014596
        // (set) Token: 0x06000166 RID: 358 RVA: 0x0001639E File Offset: 0x0001459E
        public string question { get; set; }

        // Token: 0x17000021 RID: 33
        // (get) Token: 0x06000167 RID: 359 RVA: 0x000163A7 File Offset: 0x000145A7
        // (set) Token: 0x06000168 RID: 360 RVA: 0x000163AF File Offset: 0x000145AF
        public string answerA { get; set; }

        // Token: 0x17000022 RID: 34
        // (get) Token: 0x06000169 RID: 361 RVA: 0x000163B8 File Offset: 0x000145B8
        // (set) Token: 0x0600016A RID: 362 RVA: 0x000163C0 File Offset: 0x000145C0
        public string answerB { get; set; }

        // Token: 0x17000023 RID: 35
        // (get) Token: 0x0600016B RID: 363 RVA: 0x000163C9 File Offset: 0x000145C9
        // (set) Token: 0x0600016C RID: 364 RVA: 0x000163D1 File Offset: 0x000145D1
        public string answerC { get; set; }

        // Token: 0x17000024 RID: 36
        // (get) Token: 0x0600016D RID: 365 RVA: 0x000163DA File Offset: 0x000145DA
        // (set) Token: 0x0600016E RID: 366 RVA: 0x000163E2 File Offset: 0x000145E2
        public string answerD { get; set; }

        // Token: 0x17000025 RID: 37
        // (get) Token: 0x0600016F RID: 367 RVA: 0x000163EB File Offset: 0x000145EB
        // (set) Token: 0x06000170 RID: 368 RVA: 0x000163F3 File Offset: 0x000145F3
        public string TheoryPaperTextStr { get; set; }

        // Token: 0x06000171 RID: 369 RVA: 0x000163FC File Offset: 0x000145FC
        public examinationPaperEntry()
        {
            this.TheoryPaperTableSqlDt.Columns.Add("question", Type.GetType("System.String"));
            this.TheoryPaperTableSqlDt.Columns.Add("optionsA", Type.GetType("System.String"));
            this.TheoryPaperTableSqlDt.Columns.Add("optionsB", Type.GetType("System.String"));
            this.TheoryPaperTableSqlDt.Columns.Add("optionsC", Type.GetType("System.String"));
            this.TheoryPaperTableSqlDt.Columns.Add("optionsD", Type.GetType("System.String"));
            this.TheoryPaperTableSqlDt.Columns.Add("answer", Type.GetType("System.String"));
        }

        // Token: 0x06000172 RID: 370 RVA: 0x000164DC File Offset: 0x000146DC
        public bool TheoryPaperPreview(string textboxStr)
        {
            bool result;
            try
            {
                textboxStr = textboxStr.Replace("（", "(");
                textboxStr = textboxStr.Replace("）", ")");
                textboxStr = textboxStr.Replace("．", ".");
                textboxStr = textboxStr.Replace("［", "[");
                textboxStr = textboxStr.Replace("］", "]");
                textboxStr = textboxStr.Replace("\r\n", "");
                Regex textboxStrRegex = new Regex("[Q].");
                if (!textboxStrRegex.IsMatch(textboxStr))
                {
                    result = false;
                }
                else
                {
                    string[] TheoryPaper = textboxStr.Split(new string[]
                    {
                        "[Q]."
                    }, StringSplitOptions.RemoveEmptyEntries);
                    Regex textboxStrRegexA = new Regex("(A).");
                    Regex textboxStrRegexB = new Regex("(B).");
                    Regex textboxStrRegexC = new Regex("(C).");
                    Regex textboxStrRegexD = new Regex("(D).");
                    Regex textboxStrRegexAnswer = new Regex("(answer).");
                    foreach (string abcstr in TheoryPaper)
                    {
                        if (!textboxStrRegexA.IsMatch(abcstr))
                        {
                            return false;
                        }
                        if (!textboxStrRegexB.IsMatch(abcstr))
                        {
                            return false;
                        }
                        if (!textboxStrRegexC.IsMatch(abcstr))
                        {
                            return false;
                        }
                        if (!textboxStrRegexD.IsMatch(abcstr))
                        {
                            return false;
                        }
                        if (!textboxStrRegexAnswer.IsMatch(abcstr))
                        {
                            return false;
                        }
                    }
                    int index = 0;
                    foreach (string text in TheoryPaper)
                    {
                        DataRow dataRow = this.TheoryPaperTableSqlDt.NewRow();
                        int endIndex = TheoryPaper[index].IndexOf("(A).");
                        dataRow["question"] = TheoryPaper[index].Substring(0, endIndex);
                        int startIndex = TheoryPaper[index].IndexOf("(A).");
                        endIndex = TheoryPaper[index].IndexOf("(B).");
                        dataRow["optionsA"] = TheoryPaper[index].Substring(startIndex + 4, endIndex - startIndex - 4).Trim();
                        startIndex = TheoryPaper[index].IndexOf("(B).");
                        endIndex = TheoryPaper[index].IndexOf("(C).");
                        dataRow["optionsB"] = TheoryPaper[index].Substring(startIndex + 4, endIndex - startIndex - 4).Trim();
                        startIndex = TheoryPaper[index].IndexOf("(C).");
                        endIndex = TheoryPaper[index].IndexOf("(D).");
                        dataRow["optionsC"] = TheoryPaper[index].Substring(startIndex + 4, endIndex - startIndex - 4).Trim();
                        startIndex = TheoryPaper[index].IndexOf("(D).");
                        endIndex = TheoryPaper[index].IndexOf("(answer).");
                        dataRow["optionsD"] = TheoryPaper[index].Substring(startIndex + 4, endIndex - startIndex - 4).Trim();
                        endIndex = TheoryPaper[index].IndexOf("(answer).");
                        dataRow["answer"] = (dataRow["answer"] = TheoryPaper[index].Substring(endIndex + 9, 1));
                        this.TheoryPaperTableSqlDt.Rows.Add(dataRow);
                        index++;
                    }
                    result = true;
                }
            }
            catch
            {
                result = false;
            }
            return result;
        }

        // Token: 0x06000173 RID: 371 RVA: 0x00016824 File Offset: 0x00014A24
        public bool setTheoryPaperTableSqlDt(string questiondtable1, string optionsAdtable1, string optionsBdtable1, string optionsCdtable1, string optionsDdtable1, string answer)
        {
            bool result;
            try
            {
                DataRow dataRow = this.TheoryPaperTableSqlDt.NewRow();
                dataRow["question"] = questiondtable1;
                dataRow["optionsA"] = optionsAdtable1;
                dataRow["optionsB"] = optionsBdtable1;
                dataRow["optionsC"] = optionsCdtable1;
                dataRow["optionsD"] = optionsDdtable1;
                dataRow["answer"] = answer;
                this.TheoryPaperTableSqlDt.Rows.Add(dataRow);
                result = true;
            }
            catch
            {
                result = false;
            }
            return result;
        }

        // Token: 0x0400036B RID: 875
        public DataTable TheoryPaperTableSqlDt = new DataTable();
    }
}
