internal static Inline CreatePowerExponent(QuestionPowerExponentPart powerExponentPart)
        {
            InlineUIContainer uiContainer = new InlineUIContainer();

            uiContainer.BaselineAlignment = BaselineAlignment.Center;
            PowerExponentControl powerExponentControl = new PowerExponentControl(20, FontWeights.Medium, new SolidColorBrush(Colors.Black));

            powerExponentControl.PowerExponentPart = powerExponentPart;
            uiContainer.Child             = powerExponentControl;
            uiContainer.BaselineAlignment = BaselineAlignment.Center;
            return(uiContainer);
        }
Example #2
0
        private void CreateFIBQuestion(SectionBaseInfo info, Section section)
        {
            int minValue = 10;
            int maxValue = 100;

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

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

            int tmpValue = maxValue;

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

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

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

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

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

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

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

                //amn.QuestionPartCollection.Add(mn);

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

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

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

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

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

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

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

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

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

                fibQuestion.Content.Content += " - ";

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

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

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

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

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

                fibQuestion.Content.Content += " ÷ ";

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

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

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

                fibQuestion.Content.Content += " ÷ ";

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

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

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

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

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