Ejemplo n.º 1
0
        public object Clone()
        {
            QuestionOption newOption = new QuestionOption();

            newOption.Id            = this.Id;
            newOption.index         = this.Index;
            newOption.IsCorrect     = this.IsCorrect;
            newOption.OptionContent = this.OptionContent.Clone() as QuestionContent;

            return(newOption);
        }
Ejemplo n.º 2
0
        internal static IEnumerable <QuestionOption> CreateFractionOption(QuestionContent numerator, QuestionContent denominator)
        {
            QuestionOption       option       = new QuestionOption();
            QuestionFractionPart fractionPart = new QuestionFractionPart();

            fractionPart.Denominator     = denominator;
            fractionPart.Numerator       = numerator;
            option.OptionContent.Content = fractionPart.PlaceHolder;
            option.OptionContent.QuestionPartCollection.Add(fractionPart);

            yield return(option);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        internal static IEnumerable <QuestionOption> CreateArithmeticFractionOption(int minNumeratorValue, int maxNumeratorValue, int minDenominatorValue, int maxDenominatorValue)
        {
            ArithmeticFractionValuePart fractionValue = null;

            foreach (ArithmeticFractionValuePart value in CreateFractionValue(minNumeratorValue, maxNumeratorValue, minDenominatorValue, maxDenominatorValue))
            {
                fractionValue = value;
            }

            QuestionOption option = new QuestionOption();

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

            yield return(option);
        }
Ejemplo n.º 5
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);
        }
 public void Add(QuestionOption item)
 {
     base.InnerList.Add(item);
 }
 public void Remove(QuestionOption item)
 {
     base.InnerList.Remove(item);
 }
 public void Insert(int index, QuestionOption item)
 {
     base.InnerList.Insert(index, item);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Append Options to Selectable question
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="optionCount"></param>
        /// <param name="isMR">If the option is multi response</param>
        internal static IEnumerable <QuestionOption> CreateDecimalOptions(int optionCount,
                                                                          int minValue,
                                                                          int maxValue,
                                                                          bool isMR,
                                                                          Func <decimal, bool> validationFun,
                                                                          decimal?correctDecemal = null)
        {
            Random rand = new Random((int)DateTime.Now.Ticks);

            List <QuestionOption> optionList      = new List <QuestionOption>();
            List <int>            optionValueList = new List <int>();
            decimal correctValue = 0;

            if (correctDecemal != null)
            {
                correctValue = correctDecemal.Value;
            }
            for (int j = 0; j < optionCount - 1; j++)
            {
                while (true)
                {
                    int optionValue = rand.Next(minValue, maxValue + 1);
                    if (!isMR && validationFun(optionValue))
                    {
                        correctValue = optionValue;
                        Thread.Sleep(10);
                        continue;
                    }

                    IEnumerable <int> queryResult = optionValueList.Where <int>(c => c == optionValue);
                    if (queryResult.Count <int>() > 0)
                    {
                        Thread.Sleep(10);
                        continue;
                    }

                    QuestionOption option = new QuestionOption();
                    option.OptionContent.Content     = optionValue.ToString();
                    option.OptionContent.ContentType = ContentType.Text;
                    if (isMR)
                    {
                        option.IsCorrect = validationFun(optionValue);
                    }

                    optionList.Add(option);

                    optionValueList.Add(optionValue);
                    break;
                }
            }

            if (correctValue == 0)
            {
                while (true)
                {
                    int optionValue = rand.Next(minValue, maxValue);
                    if (validationFun(optionValue))
                    {
                        correctValue = optionValue;
                        break;
                    }
                    Thread.Sleep(10);
                }
            }

            QuestionOption correctOption = new QuestionOption();

            correctOption.OptionContent.Content = correctValue.ToString();
            correctOption.IsCorrect             = true;
            int correctOptionIndex = rand.Next(0, optionCount * 8) % optionCount;

            if (correctOptionIndex == optionCount - 1)
            {
                optionList.Add(correctOption);
            }
            else
            {
                optionList.Insert(correctOptionIndex, correctOption);
            }

            Thread.Sleep(50);

            return(optionList);
        }
Ejemplo n.º 10
0
        internal static IEnumerable <QuestionOption> CreateFractionOptions(int optionCount,
                                                                           int minValue,
                                                                           int maxValue,
                                                                           bool isMR,
                                                                           Func <ArithmeticFractionValuePart, bool> validationFun,
                                                                           ArithmeticFractionValuePart correctFraction = null)
        {
            Random rand = new Random((int)DateTime.Now.Ticks);

            List <QuestionOption> optionList = new List <QuestionOption>();
            List <ArithmeticFractionValuePart> optionValueList = new List <ArithmeticFractionValuePart>();
            ArithmeticFractionValuePart        correctValue    = null;

            if (correctFraction != null)
            {
                correctValue = correctFraction;
            }
            for (int j = 0; j < optionCount - 1; j++)
            {
                while (true)
                {
                    ArithmeticFractionValuePart fractionValue = null;
                    foreach (ArithmeticFractionValuePart value in CreateFractionValue(minValue, maxValue, minValue == 0 ? 1: minValue, maxValue))
                    {
                        fractionValue = value;
                    }

                    if (!isMR && validationFun(fractionValue))
                    {
                        correctValue = fractionValue;
                        Thread.Sleep(10);
                        continue;
                    }

                    IEnumerable <ArithmeticFractionValuePart> queryResult = optionValueList.Where <ArithmeticFractionValuePart>(c => c.Equals(fractionValue));
                    if (queryResult.Count <ArithmeticFractionValuePart>() > 0)
                    {
                        Thread.Sleep(10);
                        continue;
                    }

                    QuestionOption option = new QuestionOption();
                    option.OptionContent.Content     = fractionValue.PlaceHolder;
                    option.OptionContent.ContentType = ContentType.Text;
                    option.OptionContent.QuestionPartCollection.Add(fractionValue);
                    if (isMR)
                    {
                        option.IsCorrect = validationFun(fractionValue);
                    }

                    optionList.Add(option);

                    optionValueList.Add(fractionValue);
                    break;
                }
            }

            if (correctValue == null)
            {
                while (true)
                {
                    ArithmeticFractionValuePart fractionValue = null;
                    foreach (ArithmeticFractionValuePart value in CreateFractionValue(minValue, maxValue, minValue == 0 ? 1 : minValue, maxValue))
                    {
                        fractionValue = value;
                    }

                    if (validationFun(fractionValue))
                    {
                        correctValue = fractionValue;
                        break;
                    }
                    Thread.Sleep(10);
                }
            }

            QuestionOption correctOption = new QuestionOption();

            correctOption.OptionContent.Content = correctValue.PlaceHolder;
            correctOption.OptionContent.QuestionPartCollection.Add(correctValue);
            correctOption.IsCorrect = true;
            int correctOptionIndex = rand.Next(0, optionCount * 8) % optionCount;

            if (correctOptionIndex == optionCount - 1)
            {
                optionList.Add(correctOption);
            }
            else
            {
                optionList.Insert(correctOptionIndex, correctOption);
            }

            Thread.Sleep(50);

            return(optionList);
        }