예제 #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
        /// <summary>
        /// Check if the content correct
        /// </summary>
        /// <param name="blankId"></param>
        /// <param name="anyBlank">The content match any blank's ref answer is OK</param>
        /// <returns></returns>
        public bool IsContentCorrect(string blankId, QuestionContent content)
        {
            foreach (QuestionContentPart part in this.QuestionBlankCollection)
            {
                if (part is QuestionBlank)
                {
                    QuestionBlank blank = part as QuestionBlank;
                    if (blank.MatchOwnRefAnswer)
                    {
                        if (blankId != blank.Id)
                        {
                            continue;
                        }
                    }

                    foreach (QuestionContent answer in blank.ReferenceAnswerList)
                    {
                        if (answer.Content == content.Content)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
예제 #3
0
        public override object Clone()
        {
            QuestionBlank newBlank = new QuestionBlank();

            newBlank.Id = this.Id;
            newBlank.MatchOwnRefAnswer = this.MatchOwnRefAnswer;
            foreach (QuestionContent content in newBlank.ReferenceAnswerList)
            {
                QuestionContent newContent = content.Clone() as QuestionContent;
                newBlank.ReferenceAnswerList.Add(newContent);
            }

            return(newBlank);
        }
예제 #4
0
        public QuestionBlank GetBlank(string blankId)
        {
            foreach (QuestionContentPart part in this.QuestionBlankCollection)
            {
                if (part is QuestionBlank)
                {
                    QuestionBlank blank = part as QuestionBlank;
                    if (blank.Id == blankId)
                    {
                        return(blank);
                    }
                }
            }

            return(null);
        }
 /// <summary>
 /// 删除一个QuestionBlank实例。
 /// </summary>
 /// <param name="item">要删除的QuestionBlank实例</param>
 public void Remove(QuestionBlank item)
 {
     base.InnerList.Remove(item);
 }
 /// <summary>
 /// 插入一个QuestionBlank实例到列表。
 /// </summary>
 /// <param name="index">插入的位置</param>
 /// <param name="item">QuestionBlank实例</param>
 public void Insert(int index, QuestionBlank item)
 {
     base.InnerList.Insert(index, item);
 }
 /// <summary>
 /// 添加一个QuestionBlank实例到列表。
 /// </summary>
 /// <param name="item">QuestionBlank实例</param>
 public void Add(QuestionBlank item)
 {
     base.InnerList.Add(item);
 }
예제 #8
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);
        }
        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;
                }
            }
        }
예제 #10
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;
        }