コード例 #1
0
        private void CreateFIBQuestion(SectionBaseInfo info, Section section)
        {
            valuesStruct valueMC = new valuesStruct(20); //题干展示的值

            //随即获得数值
            this.GetRandomValues(info, ref valueMC);

            //生产题干文本
            string questionText = QuestionText(valueMC);

            FIBQuestion fibQuestion = new FIBQuestion();

            fibQuestion.Content.Content     = questionText;
            fibQuestion.Content.ContentType = ContentType.Text;
            section.QuestionCollection.Add(fibQuestion);

            QuestionBlank blank = new QuestionBlank();

            QuestionContent blankContent = new QuestionContent();

            blankContent.Content     = valueMC.answer.ToString();
            blankContent.ContentType = ContentType.Text;
            blank.ReferenceAnswerList.Add(blankContent);

            fibQuestion.QuestionBlankCollection.Add(blank);

            fibQuestion.Content.Content += blank.PlaceHolder;

            StringBuilder strBuilder = new StringBuilder();

            //解题步骤
            string Steps = SolveSteps(valueMC);

            strBuilder.AppendLine(Steps);

            fibQuestion.Solution.Content = strBuilder.ToString();
        }
コード例 #2
0
        private void CreateFIBQuestion(SectionBaseInfo info, Section section)
        {
            int minValue = 10;
            int maxValue = 100;

            if (info is SectionValueRangeInfo)
            {
                SectionValueRangeInfo rangeInfo = info as SectionValueRangeInfo;
                minValue = decimal.ToInt32(rangeInfo.MinValue);
                maxValue = decimal.ToInt32(rangeInfo.MaxValue);
            }

            Random rand = new Random((int)DateTime.Now.Ticks);

            decimal valueA = rand.Next(minValue, maxValue + 1);

            Thread.Sleep(10);
            decimal valueB = rand.Next(minValue, maxValue + 1);

            Thread.Sleep(10);
            decimal valueC = rand.Next(minValue, maxValue + 1);

            decimal result = valueA + valueB + valueC;

            this.questionValueList.Add(result);

            string questionText = string.Format("({0} + {1}) + {2} = ", valueA, valueB, valueC);

            FIBQuestion fibQuestion = new FIBQuestion();

            fibQuestion.Content.Content     = questionText;
            fibQuestion.Content.ContentType = ContentType.Text;
            fibQuestion.ShowBlankInContent  = true;

            QuestionBlank blankA = new QuestionBlank();

            blankA.MatchOwnRefAnswer = true;
            QuestionContent blankContentA = new QuestionContent();

            blankContentA.Content     = valueB.ToString();
            blankContentA.ContentType = ContentType.Text;
            blankA.ReferenceAnswerList.Add(blankContentA);
            fibQuestion.QuestionBlankCollection.Add(blankA);
            fibQuestion.Content.Content += blankA.PlaceHolder;

            fibQuestion.Content.Content += " + ";

            QuestionBlank blankB = new QuestionBlank();

            blankB.MatchOwnRefAnswer = true;
            QuestionContent blankContentB = new QuestionContent();

            blankContentB.Content     = valueA.ToString();
            blankContentB.ContentType = ContentType.Text;
            blankB.ReferenceAnswerList.Add(blankContentB);
            fibQuestion.QuestionBlankCollection.Add(blankB);
            fibQuestion.Content.Content += blankB.PlaceHolder;

            fibQuestion.Solution.Content = string.Format("交换两个因数{0}和{1}的位置, 结果是{1}和{0}。", valueA, valueB);

            section.QuestionCollection.Add(fibQuestion);
        }
コード例 #3
0
        private void CreateFIBQuestion(SectionBaseInfo sectionInfo, Section section)
        {
            int minValue = 10;
            int maxValue = 100;

            if (sectionInfo is SectionValueRangeInfo)
            {
                SectionValueRangeInfo rangeInfo = sectionInfo as SectionValueRangeInfo;
                minValue = decimal.ToInt32(rangeInfo.MinValue);
                maxValue = decimal.ToInt32(rangeInfo.MaxValue);
            }

            if (section.QuestionCollection.Count == 0)
            {
                this.questionValueList.Clear();
            }

            Random rand = new Random((int)DateTime.Now.Ticks);

            int value = 0;
            int j = 0, k, iFlag1 = 0, iFlag2 = 0, j2 = 0, k2;
            int flag = 0;

            while (true)
            {
                flag = 0;
                for (int i2 = 0; i2 < maxValue; i2++)
                {
                    value = rand.Next(minValue, maxValue);
                    for (j = 2; j < value / 2 + 1; j++)
                    {
                        if (value % j == 0)
                        {
                            iFlag1 = 0;
                            iFlag2 = 0;
                            for (k = 2; k < j / 2 + 1; k++)
                            {
                                if (j % k == 0)
                                {
                                    iFlag1 = 1;
                                    break;
                                }
                            }
                            j2 = (int)(value / j);
                            for (k2 = 2; k2 < j2 / 2 + 1; k2++)
                            {
                                if (j2 % k2 == 0)
                                {
                                    iFlag2 = 1;
                                    break;
                                }
                            }
                            if (iFlag1 == 0 && iFlag2 == 0)
                            {
                                flag = 1;
                                break;
                            }
                        }
                    }
                    if (flag == 1)
                    {
                        break;
                    }
                }

                if (Enumerable.Where <int>(questionValueList, (c => (c == value))).Count <int>() > 0)
                {
                    Thread.Sleep(10);
                    continue;
                }
                break;
            }

            questionValueList.Add(value);

            string questionText = string.Format("分解质因数 {0}=", value);

            FIBQuestion fibQuestion = new FIBQuestion();

            fibQuestion.Content.Content     = questionText;
            fibQuestion.Content.ContentType = ContentType.Text;
            section.QuestionCollection.Add(fibQuestion);

            QuestionBlank   blank1        = new QuestionBlank();
            QuestionContent blankContent1 = new QuestionContent();

            blankContent1.Content     = j.ToString();
            blankContent1.ContentType = ContentType.Text;
            blank1.ReferenceAnswerList.Add(blankContent1);
            fibQuestion.QuestionBlankCollection.Add(blank1);

            QuestionBlank   blank2        = new QuestionBlank();
            QuestionContent blankContent2 = new QuestionContent();

            blankContent2.Content     = j2.ToString();
            blankContent2.ContentType = ContentType.Text;
            blank2.ReferenceAnswerList.Add(blankContent2);
            fibQuestion.QuestionBlankCollection.Add(blank2);

            fibQuestion.Content.Content += string.Format("{0}×{1}", blank1.PlaceHolder, blank2.PlaceHolder);
        }
コード例 #4
0
        private void CreateFIBQuestion(SectionBaseInfo info, Section section)
        {
            if (section.QuestionCollection.Count == 0)
            {
                this.questionValueList.Clear();
            }

            int minValue = 10;
            int maxValue = 100;

            if (info is SectionValueRangeInfo)
            {
                SectionValueRangeInfo rangeInfo = info as SectionValueRangeInfo;
                minValue = decimal.ToInt32(rangeInfo.MinValue);
                maxValue = decimal.ToInt32(rangeInfo.MaxValue);
            }

            Random rand = new Random((int)DateTime.Now.Ticks);

            int minValueA = 1;

            if (minValue > 0)
            {
                minValueA = minValue;
            }
            decimal valueA = rand.Next(minValueA, maxValue);

            Thread.Sleep(10);
            decimal valueB = rand.Next(minValue, maxValue);

            bool exist = true;

            for (int i = 0; i < 50; i++)
            {
                if (Enumerable.Where <decimal>(this.questionValueList, (c => (c == valueA * valueB))).Count <decimal>() == 0)
                {
                    exist = false;
                    break;
                }

                valueA = rand.Next(minValueA, maxValue);
                Thread.Sleep(10);
                valueB = rand.Next(minValue, maxValue);
            }

            if (exist)
            {
                return;
            }

            decimal result = valueA * valueB;

            this.questionValueList.Add(result);

            string questionText = string.Format("{0} ÷ {1} = {2}。", result, valueA, valueB);

            FIBQuestion fibQuestion = new FIBQuestion();

            fibQuestion.Content.Content     = questionText;
            fibQuestion.Content.ContentType = ContentType.Text;
            fibQuestion.ShowBlankInContent  = true;

            fibQuestion.Content.Content += "被除数";

            QuestionBlank   blankA        = new QuestionBlank();
            QuestionContent blankContentA = new QuestionContent();

            blankContentA.Content     = valueA.ToString();
            blankContentA.ContentType = ContentType.Text;
            blankA.ReferenceAnswerList.Add(blankContentA);
            fibQuestion.QuestionBlankCollection.Add(blankA);
            fibQuestion.Content.Content += blankA.PlaceHolder;

            fibQuestion.Content.Content += "除数";

            QuestionBlank   blankB        = new QuestionBlank();
            QuestionContent blankContentB = new QuestionContent();

            blankContentB.Content     = valueB.ToString();
            blankContentB.ContentType = ContentType.Text;
            blankB.ReferenceAnswerList.Add(blankContentB);
            fibQuestion.QuestionBlankCollection.Add(blankB);
            fibQuestion.Content.Content += blankB.PlaceHolder;

            fibQuestion.Content.Content += "商";

            QuestionBlank blankResult = new QuestionBlank();

            blankResult.MatchOwnRefAnswer = true;
            QuestionContent blankContentResult = new QuestionContent();

            blankContentResult.Content     = result.ToString();
            blankContentResult.ContentType = ContentType.Text;
            blankResult.ReferenceAnswerList.Add(blankContentResult);
            fibQuestion.QuestionBlankCollection.Add(blankResult);
            fibQuestion.Content.Content += blankResult.PlaceHolder;

            fibQuestion.Solution.Content = string.Format("被除数是{0}, 除数是{1}, 商是{2}。", result, valueA, valueB);

            section.QuestionCollection.Add(fibQuestion);
        }
コード例 #5
0
        private void CreateFIBQuestion(SectionBaseInfo info, Section section)
        {
            int minValue = 10;
            int maxValue = 100;

            if (info is SectionValueRangeInfo)
            {
                SectionValueRangeInfo rangeInfo = info as SectionValueRangeInfo;
                minValue = decimal.ToInt32(rangeInfo.MinValue);
                maxValue = decimal.ToInt32(rangeInfo.MaxValue);
            }

            if (section.QuestionCollection.Count == 0)
            {
                questionValueList.Clear();
            }

            Random rand = new Random((int)DateTime.Now.Ticks);

            int valueA = 0, valueB = 0;

            int value = 0;

            while (true)
            {
                int sumCommonDivisor = 0;
                valueA = rand.Next(minValue, maxValue);
                valueB = rand.Next(minValue, maxValue);

                if (valueA < valueB)
                {
                    value = valueA;
                }
                else if (valueA > valueB)
                {
                    value = valueB;
                }
                else
                {
                    continue;
                }

                for (int j2 = 1; j2 < value; j2++)
                {
                    if (valueA % j2 == 0 && valueB % j2 == 0)
                    {
                        sumCommonDivisor++;
                    }
                }

                if (sumCommonDivisor > 1)
                {
                    break;
                }
            }

            string questionText = string.Format("写出{0}和{1}的所有公约数", valueA, valueB);

            FIBQuestion fibQuestion = new FIBQuestion();

            fibQuestion.Content.Content     = questionText;
            fibQuestion.Content.ContentType = ContentType.Text;
            section.QuestionCollection.Add(fibQuestion);

            if (valueA < valueB)
            {
                value = valueA;
            }
            else
            {
                value = valueB;
            }

            for (int j2 = 1; j2 <= value; j2++)
            {
                if (valueA % j2 == 0 && valueB % j2 == 0)
                {
                    QuestionBlank blank = new QuestionBlank();

                    QuestionContent blankContent = new QuestionContent();
                    blankContent.Content     = j2.ToString();
                    blankContent.ContentType = ContentType.Text;
                    blank.ReferenceAnswerList.Add(blankContent);

                    fibQuestion.QuestionBlankCollection.Add(blank);

                    fibQuestion.Content.Content += blank.PlaceHolder;
                }
            }
        }
コード例 #6
0
        private void CreateFIBQuestion(SectionBaseInfo info, Section section)
        {
            int minValue = 10;
            int maxValue = 100;

            if (info is SectionValueRangeInfo)
            {
                SectionValueRangeInfo rangeInfo = info as SectionValueRangeInfo;
                minValue = decimal.ToInt32(rangeInfo.MinValue);
                maxValue = decimal.ToInt32(rangeInfo.MaxValue);
            }

            Random rand = new Random((int)DateTime.Now.Ticks);

            int tmpValue = maxValue / 10;

            decimal valueA = rand.Next(minValue, maxValue / 5 + 1);

            Thread.Sleep(10);
            decimal valueB = rand.Next(minValue, maxValue / 5 + 1);

            Thread.Sleep(10);
            decimal valueC = rand.Next(minValue, maxValue + 1);

            decimal coeff  = rand.Next(2, tmpValue + 1);
            decimal symbol = rand.Next(0, 2);
            //    if (symbol == 0) // "+"
            {
                decimal result = coeff * valueA + valueB;
                this.questionValueList.Add(result);

                string questionText = string.Format("{0}×x+{1}={2};\n第一步, ", coeff, valueB, result);

                //第一步,移项 {0}×x = {2} - {1}
                FIBQuestion fibQuestion = new FIBQuestion();
                fibQuestion.Content.Content     = questionText;
                fibQuestion.Content.ContentType = ContentType.Text;
                fibQuestion.ShowBlankInContent  = true;

                QuestionBlank blankA = new QuestionBlank();
                blankA.MatchOwnRefAnswer = true;
                QuestionContent blankContentA = new QuestionContent();
                blankContentA.Content     = coeff.ToString();
                blankContentA.ContentType = ContentType.Text;
                blankA.ReferenceAnswerList.Add(blankContentA);
                fibQuestion.QuestionBlankCollection.Add(blankA);
                fibQuestion.Content.Content += blankA.PlaceHolder;

                fibQuestion.Content.Content += " ×x= ";

                QuestionBlank blankB = new QuestionBlank();
                blankB.MatchOwnRefAnswer = true;
                QuestionContent blankContentB = new QuestionContent();
                blankContentB.Content     = result.ToString();
                blankContentB.ContentType = ContentType.Text;
                blankB.ReferenceAnswerList.Add(blankContentB);
                fibQuestion.QuestionBlankCollection.Add(blankB);
                fibQuestion.Content.Content += blankB.PlaceHolder;

                fibQuestion.Content.Content += " - ";

                QuestionBlank blankC = new QuestionBlank();
                blankC.MatchOwnRefAnswer = true;
                QuestionContent blankContentC = new QuestionContent();
                blankContentC.Content     = valueB.ToString();
                blankContentC.ContentType = ContentType.Text;
                blankC.ReferenceAnswerList.Add(blankContentC);
                fibQuestion.QuestionBlankCollection.Add(blankC);
                fibQuestion.Content.Content += blankC.PlaceHolder;

                //第二步{0}×x = {3}
                fibQuestion.Content.Content += " \n第二步, ";
                QuestionBlank blankA1 = new QuestionBlank();
                blankA1.MatchOwnRefAnswer = true;
                QuestionContent blankContentA1 = new QuestionContent();
                blankContentA1.Content     = coeff.ToString();
                blankContentA1.ContentType = ContentType.Text;
                blankA1.ReferenceAnswerList.Add(blankContentA1);
                fibQuestion.QuestionBlankCollection.Add(blankA1);
                fibQuestion.Content.Content += blankA1.PlaceHolder;

                fibQuestion.Content.Content += " ×x= ";

                decimal       valueB1 = result - valueB;
                QuestionBlank blankB1 = new QuestionBlank();
                blankB1.MatchOwnRefAnswer = true;
                QuestionContent blankContentB1 = new QuestionContent();
                blankContentB1.Content     = valueB1.ToString();
                blankContentB1.ContentType = ContentType.Text;
                blankB1.ReferenceAnswerList.Add(blankContentB1);
                fibQuestion.QuestionBlankCollection.Add(blankB1);
                fibQuestion.Content.Content += blankB1.PlaceHolder;

                //第三步,两边除以系数{0},{0}÷{0}×x = {3}÷{0}
                fibQuestion.Content.Content += " \n第三步, ";
                QuestionBlank blankA2 = new QuestionBlank();
                blankA2.MatchOwnRefAnswer = true;
                QuestionContent blankContentA2 = new QuestionContent();
                blankContentA2.Content     = coeff.ToString();
                blankContentA2.ContentType = ContentType.Text;
                blankA2.ReferenceAnswerList.Add(blankContentA2);
                fibQuestion.QuestionBlankCollection.Add(blankA2);
                fibQuestion.Content.Content += blankA2.PlaceHolder;

                fibQuestion.Content.Content += " ÷ ";

                QuestionBlank blankB2 = new QuestionBlank();
                blankB2.MatchOwnRefAnswer = true;
                QuestionContent blankContentB2 = new QuestionContent();
                blankContentB2.Content     = coeff.ToString();
                blankContentB2.ContentType = ContentType.Text;
                blankB2.ReferenceAnswerList.Add(blankContentB2);
                fibQuestion.QuestionBlankCollection.Add(blankB2);
                fibQuestion.Content.Content += blankB2.PlaceHolder;

                fibQuestion.Content.Content += " ×x= ";

                QuestionBlank blankC2 = new QuestionBlank();
                blankC2.MatchOwnRefAnswer = true;
                QuestionContent blankContentC2 = new QuestionContent();
                blankContentC2.Content     = valueB1.ToString();
                blankContentC2.ContentType = ContentType.Text;
                blankC2.ReferenceAnswerList.Add(blankContentC2);
                fibQuestion.QuestionBlankCollection.Add(blankC2);
                fibQuestion.Content.Content += blankC2.PlaceHolder;

                fibQuestion.Content.Content += " ÷ ";

                QuestionBlank blankD2 = new QuestionBlank();
                blankD2.MatchOwnRefAnswer = true;
                QuestionContent blankContentD2 = new QuestionContent();
                blankContentD2.Content     = coeff.ToString();
                blankContentD2.ContentType = ContentType.Text;
                blankD2.ReferenceAnswerList.Add(blankContentD2);
                fibQuestion.QuestionBlankCollection.Add(blankD2);
                fibQuestion.Content.Content += blankD2.PlaceHolder;

                //第四步,x={4}
                fibQuestion.Content.Content += " \n第四步, ";
                fibQuestion.Content.Content += " x= ";

                decimal       valueA3 = valueB1 / coeff;
                QuestionBlank blankA3 = new QuestionBlank();
                blankA3.MatchOwnRefAnswer = true;
                QuestionContent blankContentA3 = new QuestionContent();
                blankContentA3.Content     = valueA3.ToString();
                blankContentA3.ContentType = ContentType.Text;
                blankA3.ReferenceAnswerList.Add(blankContentA3);
                fibQuestion.QuestionBlankCollection.Add(blankA3);
                fibQuestion.Content.Content += blankA3.PlaceHolder;
                //∴x={4}是方程的解
                fibQuestion.Content.Content += string.Format(" \n∴ x=");
                QuestionBlank blankA4 = new QuestionBlank();
                blankA4.MatchOwnRefAnswer = true;
                QuestionContent blankContentA4 = new QuestionContent();
                blankContentA4.Content     = valueA3.ToString();
                blankContentA4.ContentType = ContentType.Text;
                blankA4.ReferenceAnswerList.Add(blankContentA4);
                fibQuestion.QuestionBlankCollection.Add(blankA4);
                fibQuestion.Content.Content += blankA4.PlaceHolder;
                fibQuestion.Content.Content += "是方程的解。";

                fibQuestion.Solution.Content = string.Format(
                    "第一步,移项 {0}×x={2}-{1};第二步{0}×x={3};第三步,两边除以系数{0},{0}÷{0}×x={3}÷{0};第四步,x={4};答案,∴x={4}是方程的解。",
                    coeff, valueB, result, result - valueB, (result - valueB) / coeff);

                section.QuestionCollection.Add(fibQuestion);
            }
            //   else // "-"
            {
            }
        }
コード例 #7
0
        internal Question CreateQuestion(QuestionType type)
        {
            Question question = null;

            switch (type)
            {
            case QuestionType.MultiChoice:
            {
                MCQuestion mcQuestion = new MCQuestion();
                for (int i = 0; i < 4; i++)
                {
                    QuestionOption option = new QuestionOption();
                    option.Index = i;
                    mcQuestion.QuestionOptionCollection.Add(option);
                }
                question = mcQuestion;
            }
            break;

            case QuestionType.MultiResponse:
            {
                MRQuestion mrQuestion = new MRQuestion();
                for (int i = 0; i < 4; i++)
                {
                    QuestionOption option = new QuestionOption();
                    option.Index = i;
                    mrQuestion.QuestionOptionCollection.Add(option);
                }
                question = mrQuestion;
            }
            break;

            case QuestionType.Essay:
            {
                ESQuestion esQuestion = new ESQuestion();
                question = esQuestion;
            }
            break;

            case QuestionType.TrueFalse:
            {
                TFQuestion     tfQuestion = new TFQuestion();
                QuestionOption optionT    = new QuestionOption();
                optionT.Index = 0;
                QuestionOption optionF = new QuestionOption();
                optionF.Index = 1;
                tfQuestion.QuestionOptionCollection.Add(optionT);
                tfQuestion.QuestionOptionCollection.Add(optionF);
                tfQuestion.RandomOption = true;

                question = tfQuestion;
            }
            break;

            case QuestionType.Match:
            {
                MAQuestion maQuestion = new MAQuestion();
                for (int i = 0; i < 4; i++)
                {
                    MAQuestionOption option = new MAQuestionOption();
                    option.Index = i;
                    maQuestion.OptionList.Add(option);
                }
                question = maQuestion;
            }
            break;

            case QuestionType.FillInBlank:
            {
                FIBQuestion fibQuestion = new FIBQuestion();
                question = fibQuestion;
            }
            break;

            case QuestionType.Composite:
            {
                CPQuestion cpQuestion = new CPQuestion();
                question = cpQuestion;
            }
            break;
            }

            question.DifficultyLevel = 3;
            question.CreateTime      = DateTime.Now.ToUniversalTime();
            question.ModifyTime      = DateTime.Now.ToUniversalTime();

            return(question);
        }
コード例 #8
0
        private IEnumerable <string> GetQuestionImageFiles(Question question)
        {
            foreach (string src in GetImageFiles(question.Content.Content))
            {
                yield return(src);
            }

            foreach (string src in GetImageFiles(question.Solution.Content))
            {
                yield return(src);
            }

            if (question is SelectableQuestion)
            {
                SelectableQuestion selectableQuestion = question as SelectableQuestion;
                foreach (QuestionOption option in selectableQuestion.QuestionOptionCollection)
                {
                    foreach (string optionImageSrc in GetImageFiles(option.OptionContent.Content))
                    {
                        yield return(optionImageSrc);
                    }
                }
            }
            else if (question is FIBQuestion)
            {
                FIBQuestion fibQuestion = question as FIBQuestion;
                foreach (QuestionBlank blank in fibQuestion.QuestionBlankCollection)
                {
                    foreach (QuestionContent refAnswer in blank.ReferenceAnswerList)
                    {
                        foreach (string blankImageSrc in GetImageFiles(refAnswer.Content))
                        {
                            yield return(blankImageSrc);
                        }
                    }
                }
            }
            else if (question is MAQuestion)
            {
                MAQuestion maQuestion = question as MAQuestion;
                foreach (MAQuestionOption option in maQuestion.OptionList)
                {
                    foreach (var optionImageSrc in GetImageFiles(option.LeftContent.Content))
                    {
                        yield return(optionImageSrc);
                    }

                    foreach (var optionImageSrc in GetImageFiles(option.RightContent.Content))
                    {
                        yield return(optionImageSrc);
                    }
                }
            }
            else if (question is ESQuestion)
            {
                ESQuestion esQuestion = question as ESQuestion;
                foreach (var refAnswerImageSrc in GetImageFiles(esQuestion.ReferenceAnswer.Content))
                {
                    yield return(refAnswerImageSrc);
                }
            }
            else if (question is CPQuestion)
            {
                CPQuestion cpQuestion = question as CPQuestion;
                foreach (var subQuestion in cpQuestion.SubQuestions)
                {
                    foreach (var subQuestionImageSrc in GetQuestionImageFiles(subQuestion as Question))
                    {
                        yield return(subQuestionImageSrc);
                    }
                }
            }
        }
コード例 #9
0
        private void CreeateFIBQuestion(SectionBaseInfo info, Section section)
        {
            int minValue = 10;
            int maxValue = 100;

            if (info is SectionValueRangeInfo)
            {
                SectionValueRangeInfo rangeInfo = info as SectionValueRangeInfo;
                minValue = decimal.ToInt32(rangeInfo.MinValue);
                maxValue = decimal.ToInt32(rangeInfo.MaxValue);
            }

            List <int> questionValueList = new List <int>();
            Random     rand = new Random((int)DateTime.Now.Ticks);

            int valueA = 0, valueB = 0, valueC = 0;

            int value = 0;

            while (true)
            {
                int j2 = 0;
                valueA = rand.Next(minValue, maxValue);
                valueB = rand.Next(minValue, maxValue);

                if (valueA > valueB)
                {
                    value = valueA;
                }
                else if (valueA < valueB)
                {
                    value = valueB;
                }
                else
                {
                    continue;
                }

                j2 = value;
                while (true)
                {
                    if (j2 % valueA == 0 && j2 % valueB == 0)
                    {
                        valueC = j2;
                        break;
                    }
                    j2++;
                }
                break;
            }

            string questionText = string.Format("写出{0}和{1}的最小公倍数", valueA, valueB);

            FIBQuestion fibQuestion = new FIBQuestion();

            fibQuestion.Content.Content     = questionText;
            fibQuestion.Content.ContentType = ContentType.Text;
            section.QuestionCollection.Add(fibQuestion);

            QuestionBlank blank = new QuestionBlank();

            QuestionContent blankContent = new QuestionContent();

            blankContent.Content     = valueC.ToString();
            blankContent.ContentType = ContentType.Text;
            blank.ReferenceAnswerList.Add(blankContent);

            fibQuestion.QuestionBlankCollection.Add(blank);

            fibQuestion.Content.Content += blank.PlaceHolder;
        }
コード例 #10
0
        private void CreateFIBQuestion(SectionBaseInfo info, Section section)
        {
            int minValue = 10;
            int maxValue = 100;

            if (info is SectionValueRangeInfo)
            {
                SectionValueRangeInfo rangeInfo = info as SectionValueRangeInfo;
                minValue = decimal.ToInt32(rangeInfo.MinValue);
                maxValue = decimal.ToInt32(rangeInfo.MaxValue);
            }

            Random rand = new Random((int)DateTime.Now.Ticks);

            int tmpValue = maxValue;

            decimal valueA = rand.Next(minValue, maxValue + 1);

            Thread.Sleep(10);
            decimal valueB = rand.Next(minValue, maxValue + 1);

            Thread.Sleep(10);
            decimal valueC = rand.Next(minValue, maxValue + 1);

            decimal coeff  = rand.Next(2, tmpValue + 1);
            decimal symbol = rand.Next(0, 2);
            //    if (symbol == 0) // "+"
            {
                decimal result = coeff * valueA + valueB;
                this.questionValueList.Add(result);

                //string questionText = string.Format("已知");

                //QuestionContent amn = new QuestionContent();
                //QuestionPowerExponentPart an = new QuestionPowerExponentPart();
                //an.BaseNumber.Content = "a";
                //an.Power.Power.Content = "n";
                //amn.QuestionPartCollection.Add(an);

                //QuestionPowerPart mn = new QuestionPowerPart;
                //QuestionPowerExponentPart mnpart = new QuestionPowerExponentPart();
                //mnpart.BaseNumber.Content = "m";
                //mnpart.Power.Power.Content = "n";
                //mn.Power.QuestionPartCollection.Add(mnpart);

                //amn.QuestionPartCollection.Add(mn);

                //已知a^m=2,a^n=8,求:a^(m+n);\n第一步, ", coeff, valueB, result);
                QuestionPowerExponentPart am = new QuestionPowerExponentPart();
                am.BaseNumber.Content  = "a";
                am.Power.Power.Content = "m";

                QuestionPowerExponentPart an = new QuestionPowerExponentPart();
                an.BaseNumber.Content  = "a";
                an.Power.Power.Content = "n";

                QuestionPowerExponentPart a_m_add_n = new QuestionPowerExponentPart();
                a_m_add_n.BaseNumber.Content  = "a";
                a_m_add_n.Power.Power.Content = "m+n";

                //第一步,移项 {0}×x = {2} - {1}
                FIBQuestion fibQuestion = new FIBQuestion();
                fibQuestion.QuestionBlankCollection.Add(am);
                fibQuestion.QuestionBlankCollection.Add(an);
                fibQuestion.QuestionBlankCollection.Add(a_m_add_n);

                fibQuestion.Content.Content = string.Format("已知{0}={1},{2}={3},求:{4}。",
                                                            am.PlaceHolder, valueA, an.PlaceHolder, valueB, a_m_add_n.PlaceHolder);

                //fibQuestion.Content.Content = questionText;
                //fibQuestion.Content.ContentType = ContentType.Text;
                //fibQuestion.ShowBlankInContent = true;

                QuestionBlank blankA = new QuestionBlank();
                blankA.MatchOwnRefAnswer = true;
                QuestionContent blankContentA = new QuestionContent();
                blankContentA.Content     = coeff.ToString();
                blankContentA.ContentType = ContentType.Text;
                blankA.ReferenceAnswerList.Add(blankContentA);
                fibQuestion.QuestionBlankCollection.Add(blankA);
                fibQuestion.Content.Content += blankA.PlaceHolder;

                fibQuestion.Content.Content += " ×x= ";

                QuestionBlank blankB = new QuestionBlank();
                blankB.MatchOwnRefAnswer = true;
                QuestionContent blankContentB = new QuestionContent();
                blankContentB.Content     = result.ToString();
                blankContentB.ContentType = ContentType.Text;
                blankB.ReferenceAnswerList.Add(blankContentB);
                fibQuestion.QuestionBlankCollection.Add(blankB);
                fibQuestion.Content.Content += blankB.PlaceHolder;

                fibQuestion.Content.Content += " - ";

                QuestionBlank blankC = new QuestionBlank();
                blankC.MatchOwnRefAnswer = true;
                QuestionContent blankContentC = new QuestionContent();
                blankContentC.Content     = valueB.ToString();
                blankContentC.ContentType = ContentType.Text;
                blankC.ReferenceAnswerList.Add(blankContentC);
                fibQuestion.QuestionBlankCollection.Add(blankC);
                fibQuestion.Content.Content += blankC.PlaceHolder;

                //第二步{0}×x = {3}
                fibQuestion.Content.Content += " \n第二步, ";
                QuestionBlank blankA1 = new QuestionBlank();
                blankA1.MatchOwnRefAnswer = true;
                QuestionContent blankContentA1 = new QuestionContent();
                blankContentA1.Content     = coeff.ToString();
                blankContentA1.ContentType = ContentType.Text;
                blankA1.ReferenceAnswerList.Add(blankContentA1);
                fibQuestion.QuestionBlankCollection.Add(blankA1);
                fibQuestion.Content.Content += blankA1.PlaceHolder;

                fibQuestion.Content.Content += " ×x= ";

                decimal       valueB1 = result - valueB;
                QuestionBlank blankB1 = new QuestionBlank();
                blankB1.MatchOwnRefAnswer = true;
                QuestionContent blankContentB1 = new QuestionContent();
                blankContentB1.Content     = valueB1.ToString();
                blankContentB1.ContentType = ContentType.Text;
                blankB1.ReferenceAnswerList.Add(blankContentB1);
                fibQuestion.QuestionBlankCollection.Add(blankB1);
                fibQuestion.Content.Content += blankB1.PlaceHolder;

                //第三步,两边除以系数{0},{0}÷{0}×x = {3}÷{0}
                fibQuestion.Content.Content += " \n第三步, ";
                QuestionBlank blankA2 = new QuestionBlank();
                blankA2.MatchOwnRefAnswer = true;
                QuestionContent blankContentA2 = new QuestionContent();
                blankContentA2.Content     = coeff.ToString();
                blankContentA2.ContentType = ContentType.Text;
                blankA2.ReferenceAnswerList.Add(blankContentA2);
                fibQuestion.QuestionBlankCollection.Add(blankA2);
                fibQuestion.Content.Content += blankA2.PlaceHolder;

                fibQuestion.Content.Content += " ÷ ";

                QuestionBlank blankB2 = new QuestionBlank();
                blankB2.MatchOwnRefAnswer = true;
                QuestionContent blankContentB2 = new QuestionContent();
                blankContentB2.Content     = coeff.ToString();
                blankContentB2.ContentType = ContentType.Text;
                blankB2.ReferenceAnswerList.Add(blankContentB2);
                fibQuestion.QuestionBlankCollection.Add(blankB2);
                fibQuestion.Content.Content += blankB2.PlaceHolder;

                fibQuestion.Content.Content += " ×x= ";

                QuestionBlank blankC2 = new QuestionBlank();
                blankC2.MatchOwnRefAnswer = true;
                QuestionContent blankContentC2 = new QuestionContent();
                blankContentC2.Content     = valueB1.ToString();
                blankContentC2.ContentType = ContentType.Text;
                blankC2.ReferenceAnswerList.Add(blankContentC2);
                fibQuestion.QuestionBlankCollection.Add(blankC2);
                fibQuestion.Content.Content += blankC2.PlaceHolder;

                fibQuestion.Content.Content += " ÷ ";

                QuestionBlank blankD2 = new QuestionBlank();
                blankD2.MatchOwnRefAnswer = true;
                QuestionContent blankContentD2 = new QuestionContent();
                blankContentD2.Content     = coeff.ToString();
                blankContentD2.ContentType = ContentType.Text;
                blankD2.ReferenceAnswerList.Add(blankContentD2);
                fibQuestion.QuestionBlankCollection.Add(blankD2);
                fibQuestion.Content.Content += blankD2.PlaceHolder;

                //第四步,x={4}
                fibQuestion.Content.Content += " \n第四步, ";
                fibQuestion.Content.Content += " x= ";

                decimal       valueA3 = valueB1 / coeff;
                QuestionBlank blankA3 = new QuestionBlank();
                blankA3.MatchOwnRefAnswer = true;
                QuestionContent blankContentA3 = new QuestionContent();
                blankContentA3.Content     = valueA3.ToString();
                blankContentA3.ContentType = ContentType.Text;
                blankA3.ReferenceAnswerList.Add(blankContentA3);
                fibQuestion.QuestionBlankCollection.Add(blankA3);
                fibQuestion.Content.Content += blankA3.PlaceHolder;
                //∴x={4}是方程的解
                fibQuestion.Content.Content += string.Format(" \n∴ x=");
                QuestionBlank blankA4 = new QuestionBlank();
                blankA4.MatchOwnRefAnswer = true;
                QuestionContent blankContentA4 = new QuestionContent();
                blankContentA4.Content     = valueA3.ToString();
                blankContentA4.ContentType = ContentType.Text;
                blankA4.ReferenceAnswerList.Add(blankContentA4);
                fibQuestion.QuestionBlankCollection.Add(blankA4);
                fibQuestion.Content.Content += blankA4.PlaceHolder;
                fibQuestion.Content.Content += "是方程的解。";

                fibQuestion.Solution.Content = string.Format(
                    "公式逆运用,第一步,移项 {0}×x={2}-{1};第二步{0}×x={3};第三步,两边除以系数{0},{0}÷{0}×x={3}÷{0};第四步,x={4};答案,∴x={4}是方程的解。",
                    coeff, valueB, result, result - valueB, (result - valueB) / coeff);

                section.QuestionCollection.Add(fibQuestion);
            }
            //   else // "-"
            {
            }
        }