Пример #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();
        }
        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();
        }
Пример #3
0
        private static IEnumerable <QuestionTextPart> CreateDoubleTextValue(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));
            QuestionTextPart valuePart = new QuestionTextPart(value.ToString());

            yield return(valuePart);
        }
Пример #4
0
        internal static IEnumerable <QuestionOption> CreateDoubleTextOption(int leftMinValue, int leftMaxValue, int rightMinValue, int rightMaxValue, string suffix)
        {
            QuestionTextPart textValue = null;

            foreach (QuestionTextPart value in CreateDoubleTextValue(leftMinValue, leftMaxValue, rightMinValue, rightMaxValue))
            {
                textValue = value;
            }

            textValue.Text += suffix;

            QuestionOption option = new QuestionOption();

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

            yield return(option);
        }
Пример #5
0
        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();
        }