Example #1
0
        private void CreateMCQuestion(SectionBaseInfo sectionInfo, Section section)
        {
            Random rand = new Random((int)DateTime.Now.Ticks);

            //int divValue = rand.Next(2, 9);
            string questionText = string.Format("请选出只能分解出两个质因数相乘的数。");

            MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) =>
            {
                content.Content     = questionText;
                content.ContentType = ContentType.Text;
                return;
            },
                                                                   () =>
            {
                List <QuestionOption> optionList = new List <QuestionOption>();
                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);
                }
                foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions(
                             4, minValue, maxValue, false,
                             (c) =>
                {
                    int j, k, iFlag1 = 0, iFlag2 = 0, j2, k2;
                    for (j = 2; j < c / 2 + 1; j++)
                    {
                        if (c % j == 0)
                        {
                            iFlag1 = 0;
                            iFlag2 = 0;
                            for (k = 2; k < j / 2 + 1; k++)
                            {
                                if (j % k == 0)
                                {
                                    iFlag1 = 1;
                                    break;
                                }
                            }

                            j2 = (int)(c / j);
                            for (k2 = 2; k2 < j2 / 2 + 1; k2++)
                            {
                                if (j2 % k2 == 0)
                                {
                                    iFlag2 = 1;
                                    break;
                                }
                            }

                            if (iFlag1 == 0 && iFlag2 == 0)
                            {
                                return(true);
                            }
                        }
                    }
                    return(false);
                }))
                {
                    optionList.Add(option);
                }

                return(optionList);
            }
                                                                   );

            section.QuestionCollection.Add(mcQuestion);

            StringBuilder strBuilder = new StringBuilder();

            foreach (QuestionOption option in mcQuestion.QuestionOptionCollection)
            {
                QuestionContent content = option.OptionContent;
                decimal         value = System.Convert.ToDecimal(content.Content);
                int             j, k, iFlag1 = 0, iFlag2 = 0, j2 = 0, k2;
                int             flag = -1;

                flag = 0;
                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)
                {
                    strBuilder.AppendLine(string.Format("{0}可分解成质因数{1},{2}相乘,是正确答案。", value, j, j2));
                }
                else
                {
                    strBuilder.AppendLine(string.Format("{0}不能分解质因数。", value));
                }
            }
        }
        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);
        }
        private void CreateMCQuestion(SectionBaseInfo sectionInfo, Section section)
        {
            Random rand = new Random((int)DateTime.Now.Ticks);

            int minValue = 0;
            int maxValue = 10 + 1;

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

            string questionText = string.Format("选出是无限小数的数。");

            MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) =>
            {
                content.Content     = questionText;
                content.ContentType = ContentType.Text;
                return;
            },
                                                                   () =>
            {
                List <QuestionOption> optionList = new List <QuestionOption>();

                foreach (QuestionOption temp in ObjectCreator.CreateDoubleTextOption(0, 0, minValue + 1, maxValue, ""))
                {
                    optionList.Add(temp);
                }

                foreach (QuestionOption temp in ObjectCreator.CreateDoubleTextOption(0, 0, minValue + 1, maxValue, ""))
                {
                    optionList.Add(temp);
                }

                foreach (QuestionOption temp in ObjectCreator.CreateDoubleTextOption(0, 0, minValue + 1, maxValue, "……"))
                {
                    temp.IsCorrect = true;
                    optionList.Add(temp);
                }

                foreach (QuestionOption temp in ObjectCreator.CreateDoubleTextOption(minValue, maxValue + 1, minValue + 1, maxValue, ""))
                {
                    optionList.Add(temp);
                }

                return(optionList);
            }
                                                                   );

            mcQuestion.RandomOption = true;

            section.QuestionCollection.Add(mcQuestion);

            StringBuilder strBuilder = new StringBuilder();

            foreach (QuestionOption option in mcQuestion.QuestionOptionCollection)
            {
                QuestionContent content = option.OptionContent;
                if (content.QuestionPartCollection[0] is QuestionTextPart)
                {
                    QuestionTextPart decimalPart = content.QuestionPartCollection[0] as QuestionTextPart;
                    if (decimalPart.Text.IndexOf("……") >= 0)
                    {
                        strBuilder.AppendLine(string.Format("{0}是无限小数,是正确答案。", decimalPart.Text));
                    }
                }
            }

            mcQuestion.Solution.Content = strBuilder.ToString();
        }
Example #4
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);
        }
Example #5
0
        private void CreateMCQuestion(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    valueA = 0, valueC = 0;

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

                //if (valueA < valueB)
                //    valueC = valueA;
                //else if (valueA > valueB)
                //    valueC = valueB;
                //else
                //    continue;

                for (int j2 = 1; j2 < valueA; j2++)
                {
                    if (valueA % j2 == 0)
                    {
                        sumCommonDivisor++;
                    }
                }
                if (sumCommonDivisor >= 4)
                {
                    break;
                }
            }

            string questionText = string.Format("请选出与{0}互质的数。", valueA);

            MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) =>
            {
                content.Content     = questionText;
                content.ContentType = ContentType.Text;
                return;
            },
                                                                   () =>
            {
                List <QuestionOption> optionList = new List <QuestionOption>();

                foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions(
                             4, minValue, maxValue, false,
                             (c) =>
                {
                    int sumCommonDivisor = 0;
                    if (valueA < c)
                    {
                        valueC = valueA;
                    }
                    else if (valueA > c)
                    {
                        valueC = decimal.ToInt32(c);
                    }
                    else
                    {
                        return(false);
                    }

                    for (int j2 = 1; j2 < valueC; j2++)
                    {
                        if (valueA % j2 == 0 && c % j2 == 0)
                        {
                            sumCommonDivisor++;
                        }
                    }
                    if (sumCommonDivisor == 1)
                    {
                        return(true);
                    }
                    return(false);
                }
                             ))
                {
                    optionList.Add(option);
                }

                return(optionList);
            }
                                                                   );

            section.QuestionCollection.Add(mcQuestion);

            StringBuilder strBuilder = new StringBuilder();

            foreach (QuestionOption option in mcQuestion.QuestionOptionCollection)
            {
                QuestionContent content          = option.OptionContent;
                decimal         value            = System.Convert.ToDecimal(content.Content);
                int             sumCommonDivisor = 0;

                if (valueA < value)
                {
                    valueC = valueA;
                }
                else
                {
                    valueC = decimal.ToInt32(value);
                }

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

                if (sumCommonDivisor == 1)
                {
                    strBuilder.AppendLine(string.Format("{0}和{1}只有公约数1,是正确答案。", valueA, value));
                }
                else
                {
                    strBuilder.AppendLine(string.Format("{0}和{1}有{2}个公约数。", valueA, value, sumCommonDivisor));
                }
            }
            mcQuestion.Solution.Content = strBuilder.ToString();
        }
        private void CreateMCQuestion(SectionBaseInfo sectionInfo, Section section)
        {
            int minValue = 10;
            int maxValue = 10000;

            if (sectionInfo is SectionValueRangeInfo)
            {
                SectionValueRangeInfo rangeInfo = sectionInfo 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;
            int        minRand = 0, maxRand = 0;
            int        minValueTmp = minValue, maxValueTmp = maxValue;

            while (true)
            {
                if (minValueTmp / 10 >= 1)
                {
                    minRand++;
                    minValueTmp /= 10;
                }
                else
                {
                    break;
                }
            }

            while (true)
            {
                if (maxValueTmp / 10 >= 1)
                {
                    maxRand++;
                    maxValueTmp /= 10;
                }
                else
                {
                    break;
                }
            }

            valueB = rand.Next(minRand, maxRand + 1);
            valueA = (int)(System.Math.Pow(10, valueB));

            questionValueList.Add(valueA);

            string questionText = string.Format("把1分成{0}份,请问可以用几位小数表示。", valueA);

            MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) =>
            {
                content.Content     = questionText;
                content.ContentType = ContentType.Text;
                return;
            },
                                                                   () =>
            {
                List <QuestionOption> optionList = new List <QuestionOption>();

                int valueLst = valueB - 2, valueMst = valueB + 3;
                if (minRand - 20 <= 1)
                {
                    valueLst = 1;
                }

                foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions(
                             4, valueLst, valueMst, false, (c => (c == valueB)), valueB))
                {
                    optionList.Add(option);
                }

                return(optionList);
            }
                                                                   );

            section.QuestionCollection.Add(mcQuestion);

            StringBuilder strBuilder = new StringBuilder();

            foreach (QuestionOption option in mcQuestion.QuestionOptionCollection)
            {
                QuestionContent content = option.OptionContent;
                decimal         value   = System.Convert.ToDecimal(content.Content);
                if (value == valueB)
                {
                    strBuilder.AppendLine(string.Format("把1分成{0}份,可以用{1}位小数表示,是正确答案。", valueA, value));
                }
                else
                {
                    strBuilder.AppendLine(string.Format("把1分成{0}份,不可以用{1}位小数表示。", valueA, value));
                }
            }
            mcQuestion.Solution.Content = strBuilder.ToString();
        }
        protected void AppendIntegerOption(int minValue, int maxValue, List <QuestionOption> optionList, QuestionContent solution)
        {
            foreach (QuestionOption temp in ObjectCreator.CreateIntegerOption(minValue, maxValue))
            {
                optionList.Add(temp);

                ArithmeticDecimalValuePart decimalValuePart = temp.OptionContent.QuestionPartCollection[0] as ArithmeticDecimalValuePart;
                solution.Content += string.Format("{0}是整数,不是正确答案。\n", decimalValuePart.Value);
            }
        }
        protected void AppendFractionOption(int minValue, int maxValue, List <QuestionOption> optionList, QuestionContent solution)
        {
            foreach (QuestionOption temp in ObjectCreator.CreateArithmeticFractionOption(minValue, maxValue, minValue, maxValue))
            {
                optionList.Add(temp);

                ArithmeticFractionValuePart fractionValuePart = temp.OptionContent.QuestionPartCollection[0] as ArithmeticFractionValuePart;
                solution.Content += string.Format("{0}是分数,是正确答案。\n", fractionValuePart.PlaceHolder);
                solution.QuestionPartCollection.Add(fractionValuePart);
            }
        }
        private void CreateMCQuestion(SectionBaseInfo sectionInfo, Section section)
        {
            Random rand = new Random((int)DateTime.Now.Ticks);

            int minValue = 0;
            int maxValue = 10 + 1;

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

            string questionText = string.Format("选出是带小数的数。");

            MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) =>
            {
                content.Content     = questionText;
                content.ContentType = ContentType.Text;
                return;
            },
                                                                   () =>
            {
                List <QuestionOption> optionList = new List <QuestionOption>();

                foreach (QuestionOption temp in ObjectCreator.CreateDoubleOption(0, 0, minValue, maxValue))
                {
                    optionList.Add(temp);
                }

                foreach (QuestionOption temp in ObjectCreator.CreateIntegerOption(minValue, maxValue))
                {
                    optionList.Add(temp);
                }

                foreach (QuestionOption temp in ObjectCreator.CreateDoubleOption(minValue + 1, maxValue + 1, minValue + 1, maxValue))
                {
                    temp.IsCorrect = true;
                    optionList.Add(temp);
                }

                foreach (QuestionOption temp in ObjectCreator.CreateDoubleOption(0, 0, minValue + 1, maxValue))
                {
                    optionList.Add(temp);
                }

                return(optionList);
            }
                                                                   );

            mcQuestion.RandomOption = true;

            section.QuestionCollection.Add(mcQuestion);

            StringBuilder strBuilder = new StringBuilder();

            foreach (QuestionOption option in mcQuestion.QuestionOptionCollection)
            {
                QuestionContent content = option.OptionContent;
                if (content.QuestionPartCollection[0] is ArithmeticDecimalValuePart)
                {
                    ArithmeticDecimalValuePart decimalPart = content.QuestionPartCollection[0] as ArithmeticDecimalValuePart;
                    decimal value = decimalPart.Value.Value;
                    if (value < 1 && value != 0)
                    {
                        strBuilder.AppendLine(string.Format("{0}是整数部分为零的小数,是纯小数。", value));
                    }
                    else if (value % 1 != 0)
                    {
                        strBuilder.AppendLine(string.Format("{0}整数部分不为零的小数,是带小数,是正确答案。", value));
                    }
                    else
                    {
                        strBuilder.AppendLine(string.Format("{0}是整数。", value));
                    }
                }
            }

            mcQuestion.Solution.Content = strBuilder.ToString();
        }
        private void CreateMCQuestion(SectionBaseInfo sectionInfo, Section section)
        {
            Random rand = new Random((int)DateTime.Now.Ticks);

            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);
            }

            int    divValue     = rand.Next(minValue, maxValue);
            string questionText = string.Format("请选出至少有两个质因数的数。");

            MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) =>
            {
                content.Content     = questionText;
                content.ContentType = ContentType.Text;
                return;
            },
                                                                   () =>
            {
                List <QuestionOption> optionList = new List <QuestionOption>();

                foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions(
                             4, minValue, maxValue, false,
                             (c) =>
                {
                    int j, k, iFlag = 0;
                    for (j = 2; j < c / 2 + 1; j++)
                    {
                        if (c % j == 0)
                        {
                            iFlag = 0;
                            for (k = 2; k < j / 2 + 1; k++)
                            {
                                if (j % k == 0)
                                {
                                    iFlag = 1;
                                    break;
                                }
                            }

                            if (iFlag == 0)
                            {
                                return(true);
                            }
                        }
                    }
                    return(false);
                }))
                {
                    optionList.Add(option);
                }

                return(optionList);
            }
                                                                   );

            section.QuestionCollection.Add(mcQuestion);

            StringBuilder strBuilder = new StringBuilder();

            foreach (QuestionOption option in mcQuestion.QuestionOptionCollection)
            {
                QuestionContent content = option.OptionContent;
                decimal         value = System.Convert.ToDecimal(content.Content);
                int             j, k, iFlag = 0, flag = -1;

                if (value == 0 || value == 1)
                {
                    flag = 0;
                }

                for (j = 2; j < value / 2 + 1; j++)
                {
                    if (value % j == 0)
                    {
                        if (j == 2)
                        {
                            flag = 1;
                            break;
                        }

                        iFlag = 0;
                        for (k = 2; k < j / 2 + 1; k++)
                        {
                            if (j % k == 0)
                            {
                                iFlag = 1;
                                break;
                            }
                        }

                        if (iFlag == 0)
                        {
                            flag = 1;
                            break;
                        }
                    }
                }

                if (flag == 0)
                {
                    strBuilder.AppendLine(string.Format("0和1都不是质因数。"));
                }
                else if (flag == 1)
                {
                    strBuilder.AppendLine(string.Format("{0}有两个质因数,是正确答案。", value));
                }
                else
                {
                    strBuilder.AppendLine(string.Format("{0}没有质因数。", value));
                }
            }
            mcQuestion.Solution.Content = strBuilder.ToString();
        }
Example #11
0
        private void CreateMCQuestion(SectionBaseInfo sectionInfo, Section section)
        {
            int minValue = 0;
            int maxValue = 10000;

            if (sectionInfo is SectionValueRangeInfo)
            {
                SectionValueRangeInfo rangeInfo = sectionInfo 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;
            int        minRand = 0, maxRand = 0;
            int        minValueTmp = minValue, maxValueTmp = maxValue;

            while (true)
            {
                if (minValueTmp / 10 >= 1)
                {
                    minRand++;
                    minValueTmp /= 10;
                }
                else
                {
                    break;
                }
            }

            while (true)
            {
                if (maxValueTmp / 10 >= 1)
                {
                    maxRand++;
                    maxValueTmp /= 10;
                }
                else
                {
                    break;
                }
            }

            while (true)
            {
                valueA = rand.Next(minRand, maxRand + 1);
                valueB = rand.Next(minRand + 1, maxRand + 1);

                if (valueA != valueB)
                {
                    break;
                }
            }

            double valueP1 = System.Math.Pow(10, valueA);
            double valueP2 = System.Math.Pow(10, valueB);
            double valueD1 = 1 / valueP1, valueD2 = 1 / valueP2;

            questionValueList.Add(valueA);
            string questionText;

            //int valueC1, valueC2;
            int multipleD;

            if (valueD1 > valueD2)
            {
                //valueC1 = valueB;
                //valueC2 = valueA;
                multipleD    = (int)(valueD1 / valueD2);
                questionText = string.Format("{0}是{1}的几倍。", valueD1, valueD2);
            }
            else
            {
                //valueC1 = valueA;
                //valueC2 = valueB;
                multipleD    = (int)(valueD2 / valueD1);
                questionText = string.Format("{1}是{0}的几倍。", valueD1, valueD2);
            }

            MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) =>
            {
                content.Content     = questionText;
                content.ContentType = ContentType.Text;
                return;
            },
                                                                   () =>
            {
                List <QuestionOption> optionList = new List <QuestionOption>();

                int valueLst = (int)(System.Math.Pow(10, minRand)), valueMst = (int)(System.Math.Pow(10, maxRand));
                if (minRand - 20 <= 0)
                {
                    valueLst = 0;
                }

                foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions(
                             4, valueLst, valueMst, false, (c => (c == multipleD)), multipleD))
                {
                    optionList.Add(option);
                }

                return(optionList);
            }
                                                                   );

            section.QuestionCollection.Add(mcQuestion);

            StringBuilder strBuilder = new StringBuilder();

            foreach (QuestionOption option in mcQuestion.QuestionOptionCollection)
            {
                QuestionContent content = option.OptionContent;
                decimal         value   = System.Convert.ToDecimal(content.Content);
                if (value == multipleD)
                {
                    strBuilder.AppendLine(string.Format("{0}和{1}是{2}倍的关系,是正确答案。", valueD1, valueD2, value));
                }
                else
                {
                    strBuilder.AppendLine(string.Format("{0}和{1}不是{2}倍的关系。", valueD1, valueD2, value));
                }
            }
            mcQuestion.Solution.Content = strBuilder.ToString();
        }
        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 // "-"
            {
            }
        }
Example #13
0
        private void CreateMCQuestion(SectionBaseInfo sectionInfo, Section section)
        {
            Random rand     = new Random((int)DateTime.Now.Ticks);
            int    tryCount = 100;

            while (true)
            {
                int minValue = 10;
                int maxValue = 100;
                int j        = 2;
                if (sectionInfo is SectionValueRangeInfo)
                {
                    SectionValueRangeInfo rangeInfo = sectionInfo as SectionValueRangeInfo;
                    minValue = decimal.ToInt32(rangeInfo.MinValue);
                    maxValue = decimal.ToInt32(rangeInfo.MaxValue);
                }

                int divValue = rand.Next(minValue, maxValue);

                bool validValue = false;
                for (j = 3; j <= divValue / 2 + 1; j++)
                {
                    if (divValue % j == 0)
                    {
                        validValue = true;
                        break;
                    }
                }

                tryCount--;

                if (tryCount == 0)
                {
                    break;
                }

                if (!validValue)
                {
                    continue;
                }

                string questionText = string.Format("请选出自然数{0}的约数。", divValue);

                int inMinValue = 2, inMaxValue = 10;
                if (j / 2 > 2)
                {
                    inMinValue = j / 2;
                }
                if (j * 3 > 10)
                {
                    inMaxValue = j * 3;
                }

                MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) =>
                {
                    content.Content     = questionText;
                    content.ContentType = ContentType.Text;
                    return;
                },
                                                                       () =>
                {
                    List <QuestionOption> optionList = new List <QuestionOption>();

                    foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions(
                                 4, inMinValue, inMaxValue, false, (c => ((divValue % c) == 0))))
                    {
                        optionList.Add(option);
                    }

                    return(optionList);
                }
                                                                       );

                section.QuestionCollection.Add(mcQuestion);

                StringBuilder strBuilder = new StringBuilder();
                foreach (QuestionOption option in mcQuestion.QuestionOptionCollection)
                {
                    QuestionContent content = option.OptionContent;
                    decimal         value   = System.Convert.ToDecimal(content.Content);
                    if (divValue % value == 0)
                    {
                        strBuilder.AppendLine(string.Format("{0}除以{1}等于{2},没有余数,是正确答案。", divValue, value, divValue / value));
                    }
                    else
                    {
                        strBuilder.AppendLine(string.Format("{0}除以{1}等于{2},余数是{3}。", divValue, value, divValue / (int)(value), divValue % value));
                    }
                }
                mcQuestion.Solution.Content = strBuilder.ToString();

                break;
            }
        }