Пример #1
0
        private static bool ReConstructQuestion(Question sq, Question oq)
        {
            bool result;

            if (sq.QID == oq.QID)
            {
                sq.CourseId  = oq.CourseId;
                sq.Text      = oq.Text;
                sq.ImageData = oq.ImageData;
                sq.ImageSize = oq.ImageSize;
                bool flag = false;
                if (sq.QType == QuestionType.FILL_BLANK_ALL)
                {
                    flag = true;
                }
                if (sq.QType == QuestionType.FILL_BLANK_GROUP)
                {
                    flag = true;
                }
                if (sq.QType == QuestionType.FILL_BLANK_EMPTY)
                {
                    flag = true;
                }
                foreach (object obj in sq.QuestionAnswers)
                {
                    QuestionAnswer questionAnswer = (QuestionAnswer)obj;
                    foreach (object obj2 in oq.QuestionAnswers)
                    {
                        QuestionAnswer questionAnswer2 = (QuestionAnswer)obj2;
                        if (questionAnswer.QAID == questionAnswer2.QAID)
                        {
                            if (flag)
                            {
                                string text  = QuestionHelper.RemoveSpaces(questionAnswer.Text).Trim().ToLower();
                                string value = QuestionHelper.RemoveSpaces(questionAnswer2.Text).Trim().ToLower();
                                if (text.Equals(value))
                                {
                                    questionAnswer.Chosen   = true;
                                    questionAnswer.Selected = true;
                                }
                            }
                            else
                            {
                                questionAnswer.Text   = questionAnswer2.Text;
                                questionAnswer.Chosen = questionAnswer2.Chosen;
                            }
                            break;
                        }
                    }
                }
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
Пример #2
0
        public static string WordWrap(string str, int width)
        {
            string          pattern         = QuestionHelper.fillBlank_Pattern;
            Regex           regex           = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);
            MatchCollection matchCollection = regex.Matches(str);

            str = regex.Replace(str, "(###)");
            string[]      array         = QuestionHelper.SplitLines(str);
            StringBuilder stringBuilder = new StringBuilder();

            for (int i = 0; i < array.Length; i++)
            {
                string str2 = array[i];
                if (i < array.Length - 1)
                {
                    str2 = array[i] + Environment.NewLine;
                }
                ArrayList arrayList = QuestionHelper.Explode(str2, QuestionHelper.splitChars);
                int       num       = 0;
                for (int j = 0; j < arrayList.Count; j++)
                {
                    string text = (string)arrayList[j];
                    if (num + text.Length > width)
                    {
                        if (num > 0)
                        {
                            if (!stringBuilder.ToString().EndsWith(Environment.NewLine))
                            {
                                stringBuilder.Append(Environment.NewLine);
                            }
                            num = 0;
                        }
                        while (text.Length > width)
                        {
                            stringBuilder.Append(text.Substring(0, width - 1) + "-");
                            text = text.Substring(width - 1);
                            if (!stringBuilder.ToString().EndsWith(Environment.NewLine))
                            {
                                stringBuilder.Append(Environment.NewLine);
                            }
                            stringBuilder.Append(Environment.NewLine);
                        }
                        text = text.TrimStart(new char[0]);
                    }
                    stringBuilder.Append(text);
                    num += text.Length;
                }
            }
            str     = stringBuilder.ToString();
            pattern = "\\(###\\)";
            regex   = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);
            for (int j = 0; j < matchCollection.Count; j++)
            {
                string replacement = QuestionHelper.RemoveNewLine(matchCollection[j].Value);
                str = regex.Replace(str, replacement, 1);
            }
            return(str);
        }
Пример #3
0
 private static string RemoveNewLine(string s)
 {
     s = s.Replace(Environment.NewLine, "");
     s = QuestionHelper.RemoveSpaces(s);
     return(s);
 }
Пример #4
0
        public static Paper Re_ConstructPaper(Paper oPaper, SubmitPaper submitPaper)
        {
            Paper spaper = submitPaper.SPaper;

            foreach (object obj in spaper.ReadingQuestions)
            {
                Passage passage  = (Passage)obj;
                Passage passage2 = QuestionHelper.GetPassage(oPaper, passage.PID);
                passage.Text     = passage2.Text;
                passage.CourseId = passage2.CourseId;
                foreach (object obj2 in passage.PassageQuestions)
                {
                    Question sq = (Question)obj2;
                    foreach (object obj3 in passage2.PassageQuestions)
                    {
                        Question oq = (Question)obj3;
                        if (QuestionHelper.ReConstructQuestion(sq, oq))
                        {
                            break;
                        }
                    }
                }
            }
            foreach (object obj4 in spaper.MatchQuestions)
            {
                MatchQuestion matchQuestion = (MatchQuestion)obj4;
                foreach (object obj5 in oPaper.MatchQuestions)
                {
                    MatchQuestion matchQuestion2 = (MatchQuestion)obj5;
                    if (matchQuestion.MID == matchQuestion2.MID)
                    {
                        matchQuestion.CourseId = matchQuestion2.CourseId;
                        matchQuestion.ColumnA  = matchQuestion2.ColumnA;
                        matchQuestion.ColumnB  = matchQuestion2.ColumnB;
                        matchQuestion.Solution = matchQuestion2.Solution;
                        break;
                    }
                }
            }
            foreach (object obj6 in spaper.GrammarQuestions)
            {
                Question sq = (Question)obj6;
                foreach (object obj7 in oPaper.GrammarQuestions)
                {
                    Question oq = (Question)obj7;
                    if (QuestionHelper.ReConstructQuestion(sq, oq))
                    {
                        break;
                    }
                }
            }
            foreach (object obj8 in spaper.IndicateMQuestions)
            {
                Question sq = (Question)obj8;
                foreach (object obj9 in oPaper.IndicateMQuestions)
                {
                    Question oq = (Question)obj9;
                    if (QuestionHelper.ReConstructQuestion(sq, oq))
                    {
                        break;
                    }
                }
            }
            foreach (object obj10 in spaper.FillBlankQuestions)
            {
                Question sq = (Question)obj10;
                foreach (object obj11 in oPaper.FillBlankQuestions)
                {
                    Question oq = (Question)obj11;
                    if (QuestionHelper.ReConstructQuestion(sq, oq))
                    {
                        break;
                    }
                }
            }
            if (oPaper.EssayQuestion != null)
            {
                QuestionHelper.ReConstructEssay(spaper.EssayQuestion, oPaper.EssayQuestion);
            }
            spaper.AudioData = oPaper.AudioData;
            return(spaper);
        }