Esempio n. 1
0
        public static UIElement CreateUIPart(QuestionContentPart part)
        {
            if (part is QuestionBlank)
            {
                NumberOnlyTextBox blankTextBox = new NumberOnlyTextBox();
                blankTextBox.Tag               = part;
                blankTextBox.Width             = 80;
                blankTextBox.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                blankTextBox.FontSize          = 20;
                blankTextBox.Margin            = new Thickness(1);
                return(blankTextBox);
            }
            else if (part is ArithmeticDecimalValuePart)
            {
                ArithmeticDecimalValuePart decimalPart = part as ArithmeticDecimalValuePart;

                if (decimalPart.Value == null)
                {
                    return(CreateText(string.Empty));
                }

                return(CreateText(decimalPart.Value.ToString()));
            }
            else if (part is ArithmeticFractionValuePart)
            {
                ArithmeticFractionValuePart fractionPart = part as ArithmeticFractionValuePart;

                FractionControl fractionControl = new FractionControl(20, FontWeights.Medium, 2, new SolidColorBrush(Colors.Black));
                fractionControl.Numerator         = fractionPart.Numerator;
                fractionControl.Denominator       = fractionPart.Denominator;
                fractionControl.FontSize          = 20;
                fractionControl.FontWeight        = FontWeights.Medium;
                fractionControl.VerticalAlignment = VerticalAlignment.Center;
                return(fractionControl);
            }
            else if (part is ArithmeticSignPart)
            {
            }
            else if (part is QuestionTextPart)
            {
                QuestionTextPart textPart = part as QuestionTextPart;

                return(CreateText(textPart.Text));
            }
            else if (part is QuestionPowerExponentPart)
            {
                PowerExponentControl powerExponentControl = new PowerExponentControl(20, FontWeights.Medium, new SolidColorBrush(Colors.Black));
                powerExponentControl.PowerExponentPart = part as QuestionPowerExponentPart;

                return(powerExponentControl);
            }
            else if (part is QuestionPowerPart)
            {
            }
            else if (part is QuestionFlowDocumentPart)
            {
            }

            throw new NotSupportedException();
        }
Esempio n. 2
0
        internal static IEnumerable <ArithmeticDecimalValuePart> CreateIntergetValue(int minValue, int maxValue)
        {
            Random rand  = new Random((int)DateTime.Now.Ticks);
            int    value = rand.Next(minValue, maxValue + 1);
            ArithmeticDecimalValuePart valuePart = new ArithmeticDecimalValuePart(value);

            yield return(valuePart);
        }
Esempio n. 3
0
        public static IEnumerable <ArithmeticDecimalValuePart> CreateIntergetValue(int minValue, int maxValue)
        {
            Random rand  = new Random(Environment.TickCount);
            int    value = rand.Next(minValue, maxValue + 1);
            ArithmeticDecimalValuePart valuePart = new ArithmeticDecimalValuePart(value);

            yield return(valuePart);
        }
        public static Inline CreateUIPart(QuestionContentPart part, Response response)
        {
            if (part is QuestionBlank)
            {
                if (response is QuestionBlankResponse)
                {
                    QuestionBlankResponse blankResponse = response as QuestionBlankResponse;

                    Paragraph blankPara = CreateContentControl(blankResponse.BlankContent, string.Empty, null, null);
                    Span      span      = new Span();
                    span.Inlines.Add("( ");
                    List <Inline> inlineList = new List <Inline>();
                    inlineList.AddRange(blankPara.Inlines);
                    foreach (Inline inline in inlineList)
                    {
                        span.Inlines.Add(inline);
                    }
                    span.Inlines.Add(" )");
                    span.BaselineAlignment = BaselineAlignment.Center;
                    return(span);
                }

                Run blankRun = new Run("(    )");
                blankRun.BaselineAlignment = BaselineAlignment.Center;
                return(blankRun);
            }
            else if (part is ArithmeticDecimalValuePart)
            {
                ArithmeticDecimalValuePart decimalPart = part as ArithmeticDecimalValuePart;

                if (decimalPart.Value == null)
                {
                    return(CreateText(string.Empty));
                }

                return(CreateText(decimalPart.Value.ToString()));
            }
            else if (part is ArithmeticFractionValuePart)
            {
                ArithmeticFractionValuePart fractionPart = part as ArithmeticFractionValuePart;

                return(CreateFraction(fractionPart));
            }
            else if (part is ArithmeticSignPart)
            {
            }
            else if (part is QuestionTextPart)
            {
                QuestionTextPart textPart = part as QuestionTextPart;

                return(CreateText(textPart.Text));
            }
            else if (part is QuestionFlowDocumentPart)
            {
            }

            throw new NotSupportedException();
        }
        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);
            }
        }
Esempio n. 6
0
        private static IEnumerable <ArithmeticDecimalValuePart> CreateDoubleValue(int leftMinValue, int leftMaxValue, int rightMinValue, int rightMaxValue)
        {
            Random rand     = new Random((int)DateTime.Now.Ticks);
            int    partLeft = rand.Next(leftMinValue, leftMaxValue + 1);

            Thread.Sleep(50);
            int    partRight = rand.Next(rightMinValue, rightMaxValue + 1);
            double value     = Convert.ToDouble(string.Format("{0}.{1}", partLeft, partRight));
            ArithmeticDecimalValuePart valuePart = new ArithmeticDecimalValuePart(new decimal(value));

            yield return(valuePart);
        }
Esempio n. 7
0
        internal static IEnumerable <QuestionOption> CreateDoubleOption(int leftMinValue, int leftMaxValue, int rightMinValue, int rightMaxValue)
        {
            ArithmeticDecimalValuePart decimalValue = null;

            foreach (ArithmeticDecimalValuePart value in CreateDoubleValue(leftMinValue, leftMaxValue, rightMinValue, rightMaxValue))
            {
                decimalValue = value;
            }

            QuestionOption option = new QuestionOption();

            option.OptionContent.Content     = decimalValue.PlaceHolder;
            option.OptionContent.ContentType = ContentType.Text;
            option.OptionContent.QuestionPartCollection.Add(decimalValue);

            yield return(option);
        }
Esempio n. 8
0
        public static IEnumerable <QuestionOption> CreateIntegerOption(int minValue, int maxValue)
        {
            ArithmeticDecimalValuePart decimalValue = null;

            foreach (ArithmeticDecimalValuePart value in CreateIntergetValue(minValue, maxValue))
            {
                decimalValue = value;
            }

            QuestionOption option = new QuestionOption();

            option.OptionContent.Content     = decimalValue.PlaceHolder;
            option.OptionContent.ContentType = ContentType.Text;
            option.OptionContent.QuestionPartCollection.Add(decimalValue);

            yield return(option);
        }
Esempio n. 9
0
        private void CreateSolution(StringBuilder strBuilder, QuestionOption option)
        {
            ArithmeticDecimalValuePart decimalPart = option.OptionContent.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));
            }
        }
        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();
        }