Пример #1
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)
            {
                questionValueList.Clear();
            }

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

            int value = 0;

            while (true)
            {
                value = rand.Next(minValue, maxValue);
                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;
            fibQuestion.ShowBlankInContent  = false;
            section.QuestionCollection.Add(fibQuestion);

            for (int j = 1; j <= value; j++)
            {
                if (value % j == 0)
                {
                    QuestionBlank blank = new QuestionBlank();

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

                    fibQuestion.QuestionBlankCollection.Add(blank);

                    fibQuestion.Content.Content += blank.PlaceHolder;
                }
            }
        }
Пример #2
0
        private void CreateMCQuestion(SectionBaseInfo sectionInfo, Section section)
        {
            Random rand = new Random((int)DateTime.Now.Ticks);

            int    divValue     = 2;//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 => ((c % divValue) == 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 (value == 0)
                {
                    strBuilder.AppendLine(string.Format("0 不是奇数,也不是偶数。"));
                }
                else if (value % divValue == 0)
                {
                    strBuilder.AppendLine(string.Format("{0}除以{1}等于{2},没有余数,是正确答案。", value, divValue, value / divValue));
                }
                else
                {
                    strBuilder.AppendLine(string.Format("{0}除以{1}等于{2},余数是{3}。", value, divValue, (int)(value) / divValue, value % divValue));
                }
            }
            mcQuestion.Solution.Content = strBuilder.ToString();
        }
Пример #3
0
        private void CreateTableQuestion(SectionBaseInfo sectionInfo, Section section)
        {
            // Table Question

            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 inMinValue = 2, inMaxValue = 2;

            if (minValue / 10 > inMinValue)
            {
                inMinValue = minValue / 10;
            }
            inMaxValue = maxValue / 10;

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

            int divValue = rand.Next(2, 10);
            //int divValue = rand.Next(inMinValue, inMaxValue);
            string questionText = string.Format("请下表中选出是{0}倍数的数。", divValue);

            TableQuestion tableQuestion = ObjectCreator.CreateTableQuestion((content) =>
            {
                content.Content     = questionText;
                content.ContentType = ContentType.Text;
                return;
            },
                                                                            () =>
            {
                List <QuestionOption> optionList = new List <QuestionOption>();

                foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions(
                             36, minValue, maxValue, true, (c => ((c % divValue) == 0))))
                {
                    optionList.Add(option);
                }

                return(optionList);
            });

            tableQuestion.Solution.Content = this.CreateSolution(divValue);

            section.QuestionCollection.Add(tableQuestion);
        }
Пример #4
0
        private void CreateTableQuestion(SectionBaseInfo sectionInfo, Section section)
        {
            // Table Question
            Random rand = new Random((int)DateTime.Now.Ticks);

            string questionText = string.Format("请下表中选出是质数的数。");

            TableQuestion tableQuestion = ObjectCreator.CreateTableQuestion((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(
                             36, minValue, maxValue, true,
                             (c) =>
                {
                    for (int j = 2; j < c / 2 + 1; j++)
                    {
                        if (c % j == 0)
                        {
                            return(false);
                        }
                    }
                    return(true);
                }))
                {
                    optionList.Add(option);
                }

                return(optionList);
            });

            tableQuestion.Tip = this.CreateTip();

            section.QuestionCollection.Add(tableQuestion);
        }
Пример #5
0
        private Section CreateTableSection(SectionBaseInfo sectionInfo, BackgroundWorker worker)
        {
            // Table Question
            Section sectionTable = ObjectCreator.CreateSection(sectionInfo.Name, sectionInfo.Description);

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

            for (int i = 2; i < sectionInfo.QuestionCount + 2; i++)
            {
                int    divValue     = i;
                string questionText = string.Format("请下表中选出能被{0}公倍数的数。", divValue);

                TableQuestion tableQuestion = ObjectCreator.CreateTableQuestion((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(
                                 36, minValue, maxValue, true, (c => ((c % divValue) == 0))))
                    {
                        optionList.Add(option);
                    }

                    return(optionList);
                });

                tableQuestion.Solution.Content = this.CreateSolution(divValue);

                sectionTable.QuestionCollection.Add(tableQuestion);

                worker.ReportProgress(0, tableQuestion);
            }

            return(sectionTable);
        }
        private void CreateTableQuestion(SectionBaseInfo info, Section section)
        {
            Random rand = new Random((int)DateTime.Now.Ticks);

            if (section.QuestionCollection.Count == 0)
            {
                this.currentIndex = 2;
            }

            int    divValue     = this.currentIndex;
            string questionText = string.Format("请下表中选出能被{0}公约数的数。", divValue);

            TableQuestion tableQuestion = ObjectCreator.CreateTableQuestion((content) =>
            {
                content.Content     = questionText;
                content.ContentType = ContentType.Text;
                return;
            },
                                                                            () =>
            {
                List <QuestionOption> optionList = new List <QuestionOption>();
                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);
                }
                foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions(
                             36, minValue, maxValue, true, (c => ((c % divValue) == 0))))
                {
                    optionList.Add(option);
                }

                return(optionList);
            });

            this.currentIndex++;

            tableQuestion.Solution.Content = this.CreateSolution(divValue);

            section.QuestionCollection.Add(tableQuestion);
        }
Пример #7
0
        private void CreateMCQuestion(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    valueA = 0, valueB = 0, valueC = 0;

            int value;

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

            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, valueC / 2, valueC * 2, false,
                             (c => (c == valueC)), valueC))
                {
                    optionList.Add(option);
                }

                return(optionList);
            }
                                                                   );

            section.QuestionCollection.Add(mcQuestion);

            StringBuilder strBuilder = new StringBuilder();

            foreach (QuestionOption option in mcQuestion.QuestionOptionCollection)
            {
                QuestionContent content = option.OptionContent;
                decimal         valueO  = System.Convert.ToDecimal(content.Content);
                if (valueC == valueO)
                {
                    strBuilder.AppendLine(string.Format("{0}能同时被{1}和{2}整除,且是所有能被整除的数里面最小的数,是正确答案。", valueO, valueA, valueB));
                }
                else
                {
                    if (valueO % valueA == 0 && valueO % valueB == 0)
                    {
                        strBuilder.AppendLine(string.Format("{0}能同时被{1}和{2}整除,但不是所有能被整除的数里面最小的数。", valueO, valueA, valueB));
                    }
                    else
                    {
                        strBuilder.AppendLine(string.Format("{0}不能同时被{1}和{2}整除。", valueO, valueA, valueB));
                    }
                }
            }
            mcQuestion.Solution.Content = strBuilder.ToString();
        }
Пример #8
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;
        }
Пример #9
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 info, 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 (info is SectionValueRangeInfo)
                {
                    SectionValueRangeInfo rangeInfo = info as SectionValueRangeInfo;
                    minValue = decimal.ToInt32(rangeInfo.MinValue);
                    maxValue = decimal.ToInt32(rangeInfo.MaxValue);
                }
                foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions(
                             4, minValue, maxValue, false,
                             (c) =>
                {
                    for (int j = 2; j < c / 2 + 1; j++)
                    {
                        if (c % j == 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             flag    = 1;
                int             j       = 1;

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

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

                if (flag == 0)
                {
                    strBuilder.AppendLine(string.Format("0 不是合数。"));
                }
                else if (flag == 1)
                {
                    strBuilder.AppendLine(string.Format("{0}只有两个约数{1},{2}。", value, 1, value));
                }
                else
                {
                    strBuilder.AppendLine(string.Format("{0}有约数{1},{2},{3}...,大于2个,是正确答案。", value, 1, value, j));
                }
            }

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

            string questionText = string.Format("请下表中选出是合数的数。");

            StringBuilder strBuilder    = new StringBuilder();
            TableQuestion tableQuestion = ObjectCreator.CreateTableQuestion((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(
                             36, minValue, maxValue, true,
                             (c) =>
                {
                    for (int j = 2; j < c / 2 + 1; j++)
                    {
                        if (c % j == 0)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }))
                {
                    optionList.Add(option);

                    decimal optionValue = Convert.ToDecimal(option.OptionContent.Content);
                    if (optionValue == 0)
                    {
                        strBuilder.AppendLine(string.Format("0 不是合数。"));
                    }
                    else if (!option.IsCorrect)
                    {
                        strBuilder.AppendLine(string.Format("{0}只有两个约数{1},{2}。", optionValue, 1, optionValue));
                    }
                    else
                    {
                        decimal thirdValue = 0;
                        for (int j = 2; j < optionValue / 2 + 1; j++)
                        {
                            if (optionValue % j == 0)
                            {
                                thirdValue = j;
                                break;
                            }
                        }
                        strBuilder.AppendLine(string.Format("{0}有约数{1},{2},{3}...,大于2个,是正确答案。", optionValue, 1, optionValue, thirdValue));
                    }
                }

                return(optionList);
            });

            tableQuestion.Solution.Content = strBuilder.ToString();
            tableQuestion.Tip = "合数至少有3个约数。";

            section.QuestionCollection.Add(tableQuestion);
        }
        private MCQuestion CreateMCQuestion(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)
            {
                this.questionValueList.Clear();
            }

            Random rand = new Random((int)DateTime.Now.Ticks);
            int    valueA = 0, valueB = 0, valueC = 0;

            int j    = 0;
            int flag = 0;

            valueC = rand.Next(minValue / 3, maxValue / 3);
            while (true)
            {
                flag = 0;
                //for (int i2 = 0; i2 < maxValue + minValue; i2++)
                while (true)
                {
                    valueA = rand.Next(valueC, maxValue);
                    valueB = rand.Next(valueC, maxValue);

                    if (valueA % valueC == 0 && valueC >= valueA / valueC &&
                        valueB % valueC == 0 && valueC >= valueB / valueC &&
                        valueA != valueB && valueC != valueA && valueC != valueB &&
                        ((valueA > valueB && valueA % valueB != 0) || (valueB > valueA && valueB % valueA != 0)))
                    {
                        flag = 1;
                        break;
                    }

                    //int lop = 0;
                    //if (valueA > valueB)
                    //    lop = valueB;
                    //else
                    //    lop = valueA;

                    //for (j = lop; j > 1; j--)
                    //{
                    //    if (valueA % j == 0 && valueB % j == 0)
                    //    {
                    //        flag = 1;
                    //        break;
                    //    }
                    //}
                }

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

            questionValueList.Add(valueA);

            string questionText = string.Format("请找出{0}和{1}的最大公约数。", valueA, valueB);

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

                int valueLst = valueC - 20, valueMst = valueC + 20;
                if (j - 20 <= 1)
                {
                    valueLst = 1;
                }

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

                return(optionList);
            }
                                                                   );

            StringBuilder strBuilder = new StringBuilder();

            foreach (QuestionOption option in mcQuestion.QuestionOptionCollection)
            {
                QuestionContent content = option.OptionContent;
                decimal         value   = System.Convert.ToDecimal(content.Content);
                if (value == valueC)
                {
                    strBuilder.AppendLine(string.Format(
                                              "{0}除以{1}等于{2},没有余数,并且{3}除以{4}等于{5},没有余数,{1}是最大公约数,是正确答案。",
                                              valueA, value, valueA / value, valueB, value, valueB / value));
                }
                else
                {
                    strBuilder.AppendLine(string.Format("{0}不是{1}和{2}的最大公约数。", value, valueA, valueB));
                }
            }
            mcQuestion.Solution.Content = strBuilder.ToString();

            section.QuestionCollection.Add(mcQuestion);

            return(mcQuestion);
        }
        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;
                }
            }
        }
Пример #14
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));
                }
            }
        }
Пример #15
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);
        }
Пример #16
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;
            }
        }
Пример #17
0
        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();
        }
Пример #18
0
        private void CreateTableQuestion(SectionBaseInfo sectionInfo, Section section)
        {
            // Table Question
            Section sectionTable = ObjectCreator.CreateSection(sectionInfo.Name, sectionInfo.Description);

            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    valueA       = rand.Next(minValue, maxValue);
            string questionText = string.Format("请在下表中选出与{0}互质的数。", valueA);

            TableQuestion tableQuestion = ObjectCreator.CreateTableQuestion((content) =>
            {
                content.Content     = questionText;
                content.ContentType = ContentType.Text;
                return;
            },
                                                                            () =>
            {
                List <QuestionOption> optionList = new List <QuestionOption>();
                foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions(
                             36, minValue, maxValue, true,
                             (c) =>
                {
                    int sumCommonDivisor = 0;
                    int valueC;
                    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);
            });

            tableQuestion.Tip = this.CreateTip();

            section.QuestionCollection.Add(tableQuestion);
        }