private void CreateFIBQuestion(SectionBaseInfo info, Section section) { valuesStruct valueMC = new valuesStruct(20); //题干展示的值 //随即获得数值 this.GetRandomValues(info, ref valueMC); //生产题干文本 string questionText = QuestionText(valueMC); 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 = valueMC.answer.ToString(); blankContent.ContentType = ContentType.Text; blank.ReferenceAnswerList.Add(blankContent); fibQuestion.QuestionBlankCollection.Add(blank); fibQuestion.Content.Content += blank.PlaceHolder; StringBuilder strBuilder = new StringBuilder(); //解题步骤 string Steps = SolveSteps(valueMC); strBuilder.AppendLine(Steps); fibQuestion.Solution.Content = strBuilder.ToString(); }
private void GetRandomValues(SectionBaseInfo info, ref valuesStruct valueABC) { 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 (minValue < 16) { minValue = 16; } if (maxValue < 100) { maxValue = 100; } Random rand = new Random((int)DateTime.Now.Ticks); valueABC.number = 2;// rand.Next(10, 100 + 1); valueABC.answer = 0; int tmpMaxValue = rand.Next(minValue, maxValue + 1); decimal B = rand.Next(minValue, maxValue + 1); decimal A = rand.Next(decimal.ToInt32(B) + 11, maxValue + decimal.ToInt32(B) + 12); //把被减数A和减数B存入数组 valueABC.values[0] = A; valueABC.values[1] = B; valueABC.answer = A - B; }
private void GetRandomValues(SectionBaseInfo info, ref valuesStruct valueABC) { 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 (minValue < 10) { minValue = 10; } if (maxValue > 100000000) { maxValue = 100000000; } Random rand = new Random((int)DateTime.Now.Ticks); valueABC.number = 2;// rand.Next(3, 6); valueABC.answer = 0; //decimal A1, A2 = 0; //int times = rand.Next(1, 10); int a1 = 0; // rand.Next(0, 5); //百位数 int b1 = rand.Next(0, 5); //十位数 int c1 = 5; // rand.Next(7, 10); //个位数 int a2 = rand.Next(4, 10); //百位数 int b2 = rand.Next(7, 10); //十位数 int c2 = rand.Next(1, 10); //个位数 int d1 = 0; int d2 = 0; decimal A1 = 0, A2 = 0; int posRand = 0;// rand.Next(0, 2); valueABC.posMul = posRand; int n = rand.Next(2, 11); int baseNum = (int)System.Math.Pow(2, n); //a1 * 100 + b1 * 10 + c1; valueABC.baseNum = n; // a1 * 100 + b1 * 10 + c1; if (posRand == 0) { A1 = (rand.Next(baseNum * 2, maxValue + 1) / baseNum) * baseNum; //1000 * d1 + 100 * a1 + 10 * b1 + c1; A2 = baseNum; // *(rand.Next(minValue + 1, maxValue + 1) / 5);// (decimal)System.Math.Pow(5, n);// 1000 * d2 + 100 * a2 + 10 * b2 + c2; } else { //A2 = (decimal)System.Math.Pow(5, n); //1000 * d1 + 100 * a1 + 10 * b1 + c1; //A1 = (decimal)System.Math.Pow(2, n); ;// 1000 * d2 + 100 * a2 + 10 * b2 + c2; A2 = (rand.Next(minValue, maxValue + 1) / 3) * 3; //1000 * d1 + 100 * a1 + 10 * b1 + c1; A1 = 667; // *(rand.Next(minValue + 1, maxValue + 1) / 5);// (decimal)System.Math.Pow(5, n);// 1000 * d2 + 100 * a2 + 10 * b2 + c2; } valueABC.values[0] = A1; valueABC.values[1] = A2; valueABC.answer = A1 / A2; }
private void GetRandomValues(SectionBaseInfo info, ref valuesStruct valueABC) { int minValue = 1; 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); valueABC.number = rand.Next(10, 100 + 1); ////只能偶数个加数 //if (valueABC.number % 2 != 0) //{ // valueABC.number++; //} int i = 0; valueABC.answer = 0; valueABC.valueStart = rand.Next(minValue, maxValue + 1); if (valueABC.valueStart % 2 != 0) { valueABC.valueStart++; } valueABC.values[i] = valueABC.valueStart; valueABC.answer += valueABC.values[i]; valueABC.valueOffset = 2;// rand.Next(1, 15 + 1); //等差值 decimal curValue = valueABC.values[i]; //前3个数 for (i = 1; i < 3; i++) { valueABC.values[i] = valueABC.values[i - 1] + valueABC.valueOffset; curValue += 2; valueABC.answer += valueABC.values[i];// valueABC.values[i]; } decimal first = valueABC.values[i - 1], second = 0; for (i = 3; i < valueABC.number - 3; i++) { second = first + valueABC.valueOffset; first = second; curValue += 2; valueABC.answer += second;// valueABC.values[i]; } //最后3个数 valueABC.values[3] = second + valueABC.valueOffset; curValue += 2; valueABC.answer += valueABC.values[3]; for (i = 4; i < 6; i++) { valueABC.values[i] = valueABC.values[i - 1] + valueABC.valueOffset; curValue += 2; valueABC.answer += valueABC.values[i]; } valueABC.valueLast = curValue; }
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); 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 result = valueA + valueB + valueC; this.questionValueList.Add(result); string questionText = string.Format("({0} + {1}) + {2} = ", valueA, valueB, valueC); FIBQuestion fibQuestion = new FIBQuestion(); 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 = valueB.ToString(); blankContentA.ContentType = ContentType.Text; blankA.ReferenceAnswerList.Add(blankContentA); fibQuestion.QuestionBlankCollection.Add(blankA); fibQuestion.Content.Content += blankA.PlaceHolder; fibQuestion.Content.Content += " + "; QuestionBlank blankB = new QuestionBlank(); blankB.MatchOwnRefAnswer = true; QuestionContent blankContentB = new QuestionContent(); blankContentB.Content = valueA.ToString(); blankContentB.ContentType = ContentType.Text; blankB.ReferenceAnswerList.Add(blankContentB); fibQuestion.QuestionBlankCollection.Add(blankB); fibQuestion.Content.Content += blankB.PlaceHolder; fibQuestion.Solution.Content = string.Format("交换两个因数{0}和{1}的位置, 结果是{1}和{0}。", valueA, valueB); section.QuestionCollection.Add(fibQuestion); }
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 CreateTableQuestion(SectionBaseInfo info, Section section) { if (section.QuestionCollection.Count == 0) { this.questionValueList.Clear(); } 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); decimal result = rand.Next(minValue, maxValue); bool exist = true; for (int i = 0; i < 50; i++) { if (Enumerable.Where <decimal>(this.questionValueList, (c => (c == result))).Count <decimal>() == 0) { exist = false; break; } Thread.Sleep(10); result = rand.Next(minValue, maxValue); } if (exist) { return; } this.questionValueList.Add(result); string questionText = string.Format("从下面选项中选出两个数的商是{0}", result); TableQuestion tableQuestion = ObjectCreator.CreateTableQuestion((content) => { content.Content = questionText; content.ContentType = ContentType.Text; return; }, () => { List <QuestionOption> optionList = new List <QuestionOption>(); for (int j = 0; j < 36; j++) { if (rand.Next() % 2 == 0) // Create correct Option { int tmpvalue = 1; if (minValue > 0) { tmpvalue = minValue; } decimal valueB = rand.Next(tmpvalue, maxValue); decimal valueA = result * valueB; QuestionOption option = new QuestionOption(); option.IsCorrect = true; option.OptionContent.Content = string.Format("{0} ÷ {1}", valueA, valueB); optionList.Add(option); } else { int tmpvalue = 1; if (minValue > 0) { tmpvalue = minValue; } decimal valueB = rand.Next(tmpvalue, maxValue); decimal valueA = rand.Next(minValue, maxValue); QuestionOption option = new QuestionOption(); option.IsCorrect = (valueA / valueB == result) ? true : false; option.OptionContent.Content = string.Format("{0} ÷ {1}", valueA, valueB); optionList.Add(option); } } return(optionList); } ); // tableQuestion.Solution.Content = string.Format("加数{0}与加数{1}的和是{2},所以正确答案是{2}。", valueA, valueB, result); section.QuestionCollection.Add(tableQuestion); }
protected override void AppendQuestion(SectionBaseInfo info, Section section) { throw new NotImplementedException(); }
private void CreateMCQuestion(SectionBaseInfo sectionInfo, Section section) { int minValue = 10; int maxValue = 10000; if (sectionInfo is SectionValueRangeInfo) { SectionValueRangeInfo rangeInfo = sectionInfo 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; int minRand = 0, maxRand = 0; int minValueTmp = minValue, maxValueTmp = maxValue; while (true) { if (minValueTmp / 10 >= 1) { minRand++; minValueTmp /= 10; } else { break; } } while (true) { if (maxValueTmp / 10 >= 1) { maxRand++; maxValueTmp /= 10; } else { break; } } valueB = rand.Next(minRand, maxRand + 1); valueA = (int)(System.Math.Pow(10, valueB)); questionValueList.Add(valueA); string questionText = string.Format("把1分成{0}份,请问可以用几位小数表示。", valueA); MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) => { content.Content = questionText; content.ContentType = ContentType.Text; return; }, () => { List <QuestionOption> optionList = new List <QuestionOption>(); int valueLst = valueB - 2, valueMst = valueB + 3; if (minRand - 20 <= 1) { valueLst = 1; } foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions( 4, valueLst, valueMst, false, (c => (c == valueB)), valueB)) { optionList.Add(option); } return(optionList); } ); section.QuestionCollection.Add(mcQuestion); StringBuilder strBuilder = new StringBuilder(); foreach (QuestionOption option in mcQuestion.QuestionOptionCollection) { QuestionContent content = option.OptionContent; decimal value = System.Convert.ToDecimal(content.Content); if (value == valueB) { strBuilder.AppendLine(string.Format("把1分成{0}份,可以用{1}位小数表示,是正确答案。", valueA, value)); } else { strBuilder.AppendLine(string.Format("把1分成{0}份,不可以用{1}位小数表示。", valueA, value)); } } mcQuestion.Solution.Content = strBuilder.ToString(); }
private void GetRandomValues(SectionBaseInfo info, ref valuesStruct valueABC) { int minValue = 100; int maxValue = 1000; if (info is SectionValueRangeInfo) { SectionValueRangeInfo rangeInfo = info as SectionValueRangeInfo; minValue = decimal.ToInt32(rangeInfo.MinValue); maxValue = decimal.ToInt32(rangeInfo.MaxValue); } if (minValue < 100) { minValue = 100; } if (maxValue < 1000) { maxValue = 1000; } Random rand = new Random((int)DateTime.Now.Ticks); valueABC.number = 2;// rand.Next(10, 100 + 1); valueABC.answer = 0; int bits = 0; int i = 0; int tmpMaxValue = decimal.ToInt32(maxValue);// / 10; //根据输入的最大值计算几位数运算 while (true) { if (tmpMaxValue >= 10) { bits++; tmpMaxValue /= 10; } else { break; } } //分配位数,存放位数值,从低到高依次存放个位、百位、千位...... int[] numsB = new int[bits]; decimal B1 = 0, B = 0; //随机得到减数B for (i = bits - 2; i >= 0; i--) { numsB[i] = rand.Next(1, 10); B1 = B1 * 10 + numsB[i]; } numsB[bits - 1] = rand.Next(1, 10); decimal BH = numsB[bits - 1]; for (i = bits - 1; i > 0; i--) { BH = BH * 10; } B = BH + B1; int b1 = decimal.ToInt32(B1); //随机取被减数A //除了最高位的A’的值要大于B‘(除了最高位) decimal A1 = rand.Next(b1 + 2, b1 + 16); int ah = rand.Next(numsB[bits - 1], 10); decimal A = ah;// rand.Next(numsB[bits - 1], 10); for (i = 0; i < bits - 1; i++) { A *= 10; } A += A1; //把被减数A和减数B存入数组 valueABC.values[0] = A; valueABC.values[1] = B; valueABC.answer = A - B; //记录取值情况 valueABC.A = A; valueABC.A1 = A1; valueABC.B = B; valueABC.B1 = B1; }
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(); }
private void GetRandomValues(SectionBaseInfo info, ref valuesStruct valueABC) { int minValue = 100; int maxValue = 1000; if (info is SectionValueRangeInfo) { SectionValueRangeInfo rangeInfo = info as SectionValueRangeInfo; minValue = decimal.ToInt32(rangeInfo.MinValue); maxValue = decimal.ToInt32(rangeInfo.MaxValue); } if (minValue < 100) { minValue = 100; } if (maxValue < 1000) { maxValue = 1000; } Random rand = new Random((int)DateTime.Now.Ticks); valueABC.number = 2;// rand.Next(10, 100 + 1); valueABC.answer = 0; int bits = 0; int i = 0; int tmpMaxValue = decimal.ToInt32(maxValue);// / 10; //根据输入的最大值计算几位数运算 while (true) { if (tmpMaxValue >= 10) { bits++; tmpMaxValue /= 10; } else { break; } } //分配位数,存放位数值,从低到高依次存放个位、百位、千位...... int[] numsA = new int[bits]; decimal A1 = 0, A = 0; //随机得到减数A for (i = bits - 2; i >= 0; i--) { numsA[i] = rand.Next(1, 10); A1 = A1 * 10 + numsA[i]; } //除了最高位的A’的值要小于B‘(除了最高位) int a1 = decimal.ToInt32(A1); decimal b1 = rand.Next(a1 + 2, a1 + 16); numsA[bits - 1] = rand.Next(2, 10); //取减数的最高位不能小于等于1 decimal AH = numsA[bits - 1]; for (i = bits - 1; i > 0; i--) { AH = AH * 10; } A = AH + A1; //随机取被减数B int bh = rand.Next(1, numsA[bits - 1]); decimal B = bh;// rand.Next(numsB[bits - 1], 10); for (i = 0; i < bits - 1; i++) { B *= 10; } B += b1; //把被减数A和减数B存入数组 valueABC.values[0] = A; valueABC.values[1] = B; valueABC.answer = A - B; //记录取值情况 valueABC.A = A; valueABC.A1 = A1; valueABC.B = B; valueABC.B1 = b1; }
private void CreateMCQuestion(SectionBaseInfo sectionInfo, Section section) { int minValue = 0; int maxValue = 10000; if (sectionInfo is SectionValueRangeInfo) { SectionValueRangeInfo rangeInfo = sectionInfo 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; int minRand = 0, maxRand = 0; int minValueTmp = minValue, maxValueTmp = maxValue; while (true) { if (minValueTmp / 10 >= 1) { minRand++; minValueTmp /= 10; } else { break; } } while (true) { if (maxValueTmp / 10 >= 1) { maxRand++; maxValueTmp /= 10; } else { break; } } while (true) { valueA = rand.Next(minRand, maxRand + 1); valueB = rand.Next(minRand + 1, maxRand + 1); if (valueA != valueB) { break; } } double valueP1 = System.Math.Pow(10, valueA); double valueP2 = System.Math.Pow(10, valueB); double valueD1 = 1 / valueP1, valueD2 = 1 / valueP2; questionValueList.Add(valueA); string questionText; //int valueC1, valueC2; int multipleD; if (valueD1 > valueD2) { //valueC1 = valueB; //valueC2 = valueA; multipleD = (int)(valueD1 / valueD2); questionText = string.Format("{0}是{1}的几倍。", valueD1, valueD2); } else { //valueC1 = valueA; //valueC2 = valueB; multipleD = (int)(valueD2 / valueD1); questionText = string.Format("{1}是{0}的几倍。", valueD1, valueD2); } MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) => { content.Content = questionText; content.ContentType = ContentType.Text; return; }, () => { List <QuestionOption> optionList = new List <QuestionOption>(); int valueLst = (int)(System.Math.Pow(10, minRand)), valueMst = (int)(System.Math.Pow(10, maxRand)); if (minRand - 20 <= 0) { valueLst = 0; } foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions( 4, valueLst, valueMst, false, (c => (c == multipleD)), multipleD)) { optionList.Add(option); } return(optionList); } ); section.QuestionCollection.Add(mcQuestion); StringBuilder strBuilder = new StringBuilder(); foreach (QuestionOption option in mcQuestion.QuestionOptionCollection) { QuestionContent content = option.OptionContent; decimal value = System.Convert.ToDecimal(content.Content); if (value == multipleD) { strBuilder.AppendLine(string.Format("{0}和{1}是{2}倍的关系,是正确答案。", valueD1, valueD2, value)); } else { strBuilder.AppendLine(string.Format("{0}和{1}不是{2}倍的关系。", valueD1, valueD2, value)); } } mcQuestion.Solution.Content = strBuilder.ToString(); }
private void CreateMCQuestion(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); decimal valueA = rand.Next(minValue, maxValue + 1); Thread.Sleep(10); decimal valueB = rand.Next(minValue, maxValue + 1); decimal result = valueA + valueB; string questionText = "从下面选项中选出符合加法交换律的等式。"; MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) => { content.Content = questionText; content.ContentType = ContentType.Text; return; }, () => { List <QuestionOption> optionList = new List <QuestionOption>(); for (int i = 0; i < 3; i++) { decimal a = rand.Next(minValue, maxValue + 1); decimal b = rand.Next(minValue, maxValue + 1); decimal c = rand.Next(minValue, decimal.ToInt32(a + b + 1)); decimal d = a + b - c; if (d == a || d == b) { d = d == 0 ? d + 1 : d - 1; c = a + b - d; } QuestionOption option = new QuestionOption(); option.OptionContent.Content = string.Format("{0} + {1} = {2} + {3}", a, b, c, d); optionList.Add(option); } QuestionOption correctOption = new QuestionOption(); correctOption.OptionContent.Content = string.Format("{0} + {1} = {1} + {0}", valueA, valueB); correctOption.IsCorrect = true; int correctIndex = rand.Next(100) % 4; if (correctIndex == optionList.Count) { optionList.Add(correctOption); } else { optionList.Insert(correctIndex, correctOption); } return(optionList); } ); mcQuestion.Solution.Content = string.Format("{0}+{1}={1}+{0},在这个等式中,交换两个加数{0}和{1}的位置,和不变,都是{2}。\n是符合加法交换律的,是正确答案。", valueA, valueB, result); section.QuestionCollection.Add(mcQuestion); }
private void GetRandomValues(SectionBaseInfo info, ref valuesStruct valueABC) { 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 (minValue < 10) { minValue = 10; } if (maxValue < 100) { maxValue = 100; } Random rand = new Random((int)DateTime.Now.Ticks); valueABC.number = 3;// rand.Next(10, 100 + 1); valueABC.answer = 0; int bits = 1; decimal A, B, C; //随机选择多项式运算中第一个是加号还是减号 int sign = rand.Next(0, 2); if (sign == 0) //减号 { valueABC.signs[0] = 0; //减号 valueABC.signs[1] = 1; //加号 B = rand.Next(minValue, maxValue + 1); C = rand.Next(minValue + 1, maxValue + 1); int c = decimal.ToInt32(C) % 100; int a = 100 - c; A = rand.Next(decimal.ToInt32(B) + 1, maxValue + decimal.ToInt32(B) + 2); A -= decimal.ToInt32(A) % 100; A += 100; A += a; valueABC.values[0] = A; valueABC.values[1] = B; valueABC.values[2] = C; valueABC.answer = A - B + C; } else { valueABC.signs[0] = 1; //加号 valueABC.signs[1] = 0; //减号 B = rand.Next(minValue, maxValue + 1); C = rand.Next(minValue + 1, maxValue + 1); int c = decimal.ToInt32(C) % 100; A = rand.Next(decimal.ToInt32(C) + 1, maxValue + decimal.ToInt32(C) + 2); A -= decimal.ToInt32(A) % 100; A += 100; A += c; valueABC.values[0] = A; valueABC.values[1] = B; valueABC.values[2] = C; valueABC.answer = A + B - C; } }
private MCQuestion CreateMCQuestion(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) { this.questionValueList.Clear(); } Random rand = new Random((int)DateTime.Now.Ticks); int valueA = 0, valueB = 0, valueC = 0; int j = 0; int flag = 0; valueC = rand.Next(minValue / 3, maxValue / 3); while (true) { flag = 0; //for (int i2 = 0; i2 < maxValue + minValue; i2++) while (true) { valueA = rand.Next(valueC, maxValue); valueB = rand.Next(valueC, maxValue); if (valueA % valueC == 0 && valueC >= valueA / valueC && valueB % valueC == 0 && valueC >= valueB / valueC && valueA != valueB && valueC != valueA && valueC != valueB && ((valueA > valueB && valueA % valueB != 0) || (valueB > valueA && valueB % valueA != 0))) { flag = 1; break; } //int lop = 0; //if (valueA > valueB) // lop = valueB; //else // lop = valueA; //for (j = lop; j > 1; j--) //{ // if (valueA % j == 0 && valueB % j == 0) // { // flag = 1; // break; // } //} } //if (Enumerable.Where<int>(questionValueList, (c => (c == valueA))).Count<int>() > 0) //{ // Thread.Sleep(10); // continue; //} break; } questionValueList.Add(valueA); string questionText = string.Format("请找出{0}和{1}的最大公约数。", valueA, valueB); MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) => { content.Content = questionText; content.ContentType = ContentType.Text; return; }, () => { List <QuestionOption> optionList = new List <QuestionOption>(); int valueLst = valueC - 20, valueMst = valueC + 20; if (j - 20 <= 1) { valueLst = 1; } foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions( 4, valueLst, valueMst, false, (c => (c == valueC)), valueC)) { optionList.Add(option); } return(optionList); } ); StringBuilder strBuilder = new StringBuilder(); foreach (QuestionOption option in mcQuestion.QuestionOptionCollection) { QuestionContent content = option.OptionContent; decimal value = System.Convert.ToDecimal(content.Content); if (value == valueC) { strBuilder.AppendLine(string.Format( "{0}除以{1}等于{2},没有余数,并且{3}除以{4}等于{5},没有余数,{1}是最大公约数,是正确答案。", valueA, value, valueA / value, valueB, value, valueB / value)); } else { strBuilder.AppendLine(string.Format("{0}不是{1}和{2}的最大公约数。", value, valueA, valueB)); } } mcQuestion.Solution.Content = strBuilder.ToString(); section.QuestionCollection.Add(mcQuestion); return(mcQuestion); }
private void GetRandomValues(SectionBaseInfo info, ref valuesStruct valueABC) { 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 (minValue < 10) { minValue = 10; } if (maxValue > 10000000) { maxValue = 10000000; } Random rand = new Random((int)DateTime.Now.Ticks); valueABC.number = 2;// rand.Next(3, 6); valueABC.answer = 0; //decimal A1, A2 = 0; //int times = rand.Next(1, 10); int a1 = 0; // rand.Next(1, 9); //百位数 int b1 = rand.Next(5, 10); //十位数 int c1 = rand.Next(7, 10); //个位数 int a2 = rand.Next(1, 9); //百位数 int b2 = 9; // rand.Next(0, 10); //十位数 int c2 = 9 - a2; // rand.Next(1, 10); //个位数 int d1 = 0; int d2 = 0; decimal A1 = 0, A2 = 0; int posRand = 0;// rand.Next(0, 2); valueABC.posMul = posRand; int n = rand.Next(0, 4); valueABC.baseNum = 9; if (posRand == 0) { A1 = 123456789; // rand.Next(minValue, maxValue); //1000 * d1 + 100 * a1 + 10 * b1 + c1; A2 = 9 * rand.Next(1, 10); //(1000 * d2 + 100 * a2 + 10 * b2 + c2); } else { A2 = rand.Next(minValue, maxValue); //1000 * d1 + 100 * a1 + 10 * b1 + c1; A1 = 9 * (1000 * d2 + 100 * a2 + 10 * b2 + c2); } valueABC.values[0] = A1; valueABC.values[1] = A2; valueABC.answer = A1 * A2; }
private void GetRandomValues(SectionBaseInfo info, ref valuesStruct valueABC) { 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 (minValue < 10) { minValue = 10; } if (maxValue > 1000000) { maxValue = 1000000; } Random rand = new Random((int)DateTime.Now.Ticks); valueABC.number = 2;// rand.Next(3, 6); valueABC.answer = 0; //decimal A1, A2 = 0; //int times = rand.Next(1, 10); int d1 = rand.Next(1, 9); //千位数; int a1 = rand.Next(d1, 10); //百位数 int b1 = a1; // 9;// rand.Next(0, 3); //十位数 int c1 = a1 - d1; // rand.Next(5, 10); //个位数 int d2 = 0; int a2 = rand.Next(4, 10); //百位数 int b2 = rand.Next(7, 10); //十位数 int c2 = rand.Next(1, 10); //个位数 decimal A1 = 0, A2 = 0, A3 = 0, A4 = 0; int posRand = rand.Next(0, 2); valueABC.posMul = posRand; int n = rand.Next(2, 11); int baseNum = 37; // a1 * 100 + b1 * 10 + c1; valueABC.baseNum = n; // a1 * 100 + b1 * 10 + c1; if (posRand == 0) { A4 = rand.Next(minValue + 1, maxValue); // / baseNum) * baseNum; //1000 * d1 + 100 * a1 + 10 * b1 + c1; A3 = rand.Next(minValue + 1, maxValue); // / baseNum) * baseNum; //1000 * d1 + 100 * a1 + 10 * b1 + c1; A1 = A3 * rand.Next(1, 12); A2 = A4 * rand.Next(1, 12);; // *(rand.Next(minValue + 1, maxValue + 1) / 5);// (decimal)System.Math.Pow(5, n);// 1000 * d2 + 100 * a2 + 10 * b2 + c2; } else { A4 = rand.Next(minValue + 1, maxValue); // / baseNum) * baseNum; //1000 * d1 + 100 * a1 + 10 * b1 + c1; A3 = rand.Next(minValue + 1, maxValue); // / baseNum) * baseNum; //1000 * d1 + 100 * a1 + 10 * b1 + c1; A2 = A3 * rand.Next(1, 12); A1 = A4 * rand.Next(1, 12);; // *(rand.Next(minValue + 1, maxValue + 1) / 5);// (decimal)System.Math.Pow(5, n);// 1000 * d2 + 100 * a2 + 10 * b2 + c2; } valueABC.values[0] = A1; valueABC.values[1] = A2; valueABC.values[2] = A3; valueABC.values[3] = A4; valueABC.answer = (A1 * A2) / (A3 * A4); }
private void CreateFIBQuestion(SectionBaseInfo info, Section section) { if (section.QuestionCollection.Count == 0) { this.questionValueList.Clear(); } 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 minValueA = 1; if (minValue > 0) { minValueA = minValue; } decimal valueA = rand.Next(minValueA, maxValue); Thread.Sleep(10); decimal valueB = rand.Next(minValue, maxValue); bool exist = true; for (int i = 0; i < 50; i++) { if (Enumerable.Where <decimal>(this.questionValueList, (c => (c == valueA * valueB))).Count <decimal>() == 0) { exist = false; break; } valueA = rand.Next(minValueA, maxValue); Thread.Sleep(10); valueB = rand.Next(minValue, maxValue); } if (exist) { return; } decimal result = valueA * valueB; this.questionValueList.Add(result); string questionText = string.Format("{0} ÷ {1} = {2}。", result, valueA, valueB); FIBQuestion fibQuestion = new FIBQuestion(); fibQuestion.Content.Content = questionText; fibQuestion.Content.ContentType = ContentType.Text; fibQuestion.ShowBlankInContent = true; fibQuestion.Content.Content += "被除数"; QuestionBlank blankA = new QuestionBlank(); QuestionContent blankContentA = new QuestionContent(); blankContentA.Content = valueA.ToString(); blankContentA.ContentType = ContentType.Text; blankA.ReferenceAnswerList.Add(blankContentA); fibQuestion.QuestionBlankCollection.Add(blankA); fibQuestion.Content.Content += blankA.PlaceHolder; fibQuestion.Content.Content += "除数"; QuestionBlank blankB = new QuestionBlank(); QuestionContent blankContentB = new QuestionContent(); blankContentB.Content = valueB.ToString(); blankContentB.ContentType = ContentType.Text; blankB.ReferenceAnswerList.Add(blankContentB); fibQuestion.QuestionBlankCollection.Add(blankB); fibQuestion.Content.Content += blankB.PlaceHolder; fibQuestion.Content.Content += "商"; QuestionBlank blankResult = new QuestionBlank(); blankResult.MatchOwnRefAnswer = true; QuestionContent blankContentResult = new QuestionContent(); blankContentResult.Content = result.ToString(); blankContentResult.ContentType = ContentType.Text; blankResult.ReferenceAnswerList.Add(blankContentResult); fibQuestion.QuestionBlankCollection.Add(blankResult); fibQuestion.Content.Content += blankResult.PlaceHolder; fibQuestion.Solution.Content = string.Format("被除数是{0}, 除数是{1}, 商是{2}。", result, valueA, valueB); section.QuestionCollection.Add(fibQuestion); }
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(); }
private void CreateMCQuestion(SectionBaseInfo info, Section section) { if (section.QuestionCollection.Count == 0) { this.questionValueList.Clear(); } 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 minValueA = 1; if (minValue > 0) { minValueA = minValue; } decimal valueA = rand.Next(minValueA, maxValue); Thread.Sleep(10); decimal valueB = rand.Next(minValue, maxValue); bool exist = true; for (int i = 0; i < 50; i++) { if (Enumerable.Where <decimal>(this.questionValueList, (c => (c == valueA * valueB))).Count <decimal>() == 0) { exist = false; break; } valueA = rand.Next(minValueA, maxValue); Thread.Sleep(10); valueB = rand.Next(minValue, maxValue); } if (exist) { return; } decimal result = valueA * valueB; this.questionValueList.Add(result); string questionText = string.Format("从下面选项中选出{0}除以{1}的商。", result, valueA); MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) => { content.Content = questionText; content.ContentType = ContentType.Text; return; }, () => { List <QuestionOption> optionList = new List <QuestionOption>(); foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions( 4, minValue, maxValue, false, (c => ((c == valueB))), valueB)) { optionList.Add(option); } return(optionList); } ); mcQuestion.Solution.Content = string.Format("被除数{0}除以除数{1}的商是{2},所以正确答案是{2}。", result, valueA, valueB); section.QuestionCollection.Add(mcQuestion); }
protected override void AppendQuestion(SectionBaseInfo info, SoonLearning.Math.Data.Section section) { throw new NotImplementedException(); }
private void CreateMCQuestion(SectionBaseInfo sectionInfo, Section section) { Random rand = new Random((int)DateTime.Now.Ticks); //int divValue = rand.Next(2, 9); string questionText = string.Format("请选出只能分解出两个质因数相乘的数。"); MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) => { content.Content = questionText; content.ContentType = ContentType.Text; return; }, () => { List <QuestionOption> optionList = new List <QuestionOption>(); 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); } foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions( 4, minValue, maxValue, false, (c) => { int j, k, iFlag1 = 0, iFlag2 = 0, j2, k2; for (j = 2; j < c / 2 + 1; j++) { if (c % j == 0) { iFlag1 = 0; iFlag2 = 0; for (k = 2; k < j / 2 + 1; k++) { if (j % k == 0) { iFlag1 = 1; break; } } j2 = (int)(c / j); for (k2 = 2; k2 < j2 / 2 + 1; k2++) { if (j2 % k2 == 0) { iFlag2 = 1; break; } } if (iFlag1 == 0 && iFlag2 == 0) { return(true); } } } return(false); })) { optionList.Add(option); } return(optionList); } ); section.QuestionCollection.Add(mcQuestion); StringBuilder strBuilder = new StringBuilder(); foreach (QuestionOption option in mcQuestion.QuestionOptionCollection) { QuestionContent content = option.OptionContent; decimal value = System.Convert.ToDecimal(content.Content); int j, k, iFlag1 = 0, iFlag2 = 0, j2 = 0, k2; int flag = -1; flag = 0; 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) { strBuilder.AppendLine(string.Format("{0}可分解成质因数{1},{2}相乘,是正确答案。", value, j, j2)); } else { strBuilder.AppendLine(string.Format("{0}不能分解质因数。", value)); } } }
private void GetRandomValues(SectionBaseInfo info, ref valuesStruct valueABC) { 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 (minValue < 1000) { minValue = 100; } //if (maxValue < 10000) { maxValue = 1000; } Random rand = new Random((int)DateTime.Now.Ticks); valueABC.number = 2; valueABC.answer = 0; decimal A1, A2; int bitNum = 2; // rand.Next(3, 5); int a1 = 0; // rand.Next(1, 10); //百位数 int b1 = rand.Next(1, 10); //十位数 int c1 = rand.Next(1, 10); //个位数 int a2 = 0; // rand.Next(1, 10); //百位数 int b2 = 1; // rand.Next(1, 10); //十位数 int c2 = rand.Next(1, 10); //个位数 int d1 = 0; int d2 = 0; if (bitNum == 2) // { A1 = 100 * a1 + 10 * b1 + c1; A2 = 100 * a2 + 10 * b2 + c2; } else if (bitNum == 3) // { A1 = 100 * a1 + 10 * b1 + c1; A2 = 100 * a2 + 10 * b2 + c2; } else { A1 = 1000 * a1 + 100 * b1 + 10 * c1 + d1; A2 = 1000 * a2 + 100 * b2 + 10 * c2 + d2; } //int posRand = rand.Next(0, 2); //if (posRand == 0) //{ // A = 10 * a + b; // B = 10 * c + d; //} //else //{ // B = 10 * a + b; // A = 10 * c + d; //} valueABC.values[0] = A1; valueABC.values[1] = A2; valueABC.answer = A1 * A2; }
private void CreateMCQuestion(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); if (minValue < 1) { minValue = 1; } decimal valueC = rand.Next(minValue, maxValue / 2 + 1); Thread.Sleep(10); decimal valueB = rand.Next(minValue, maxValue - decimal.ToInt32(valueC) + 1); Thread.Sleep(10); decimal valueA = rand.Next(decimal.ToInt32(valueB + valueC), maxValue + 1); decimal result = valueA - valueB - valueC; string questionText = "从下面选项中选出符合减法的性质的等式。"; MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) => { content.Content = questionText; content.ContentType = ContentType.Text; return; }, () => { List <QuestionOption> optionList = new List <QuestionOption>(); for (int i = 0; i < 2; i++) { decimal a = rand.Next(minValue, maxValue + 1); decimal b = rand.Next(minValue, maxValue + 1); decimal c = rand.Next(minValue, maxValue + 1); decimal d = rand.Next(minValue, maxValue + 1); if (d == c) { d = d == 0 ? d + 1 : d - 1; } QuestionOption option = new QuestionOption(); option.OptionContent.Content = string.Format("{0} - {1} - {2} = {0} - ({1} + {3})", a, b, c, d); optionList.Add(option); } QuestionOption option2 = new QuestionOption(); option2.OptionContent.Content = string.Format("{0} - {1} - {2} = {0} - ({1} - {2})", valueA, valueB, valueC); optionList.Add(option2); QuestionOption correctOption = new QuestionOption(); correctOption.OptionContent.Content = string.Format("{0} - {1} - {2} = {0} - ({1} + {2})", valueA, valueB, valueC); correctOption.IsCorrect = true; int correctIndex = rand.Next(100) % 4; if (correctIndex == optionList.Count) { optionList.Add(correctOption); } else { optionList.Insert(correctIndex, correctOption); } return(optionList); } ); mcQuestion.Solution.Content = string.Format("{0} - {1} - {2} = {0} - ({1} + {2}),在这个等式中,两边结果一样,都是{3}。\n是符合减法的性质的,是正确答案。", valueA, valueB, valueC, result); section.QuestionCollection.Add(mcQuestion); }
private void CreateTableQuestion(SectionBaseInfo sectionInfo, Section section) { Random rand = new Random((int)DateTime.Now.Ticks); string questionText = string.Format("请下表中选出是合数的数。"); StringBuilder strBuilder = new StringBuilder(); TableQuestion tableQuestion = ObjectCreator.CreateTableQuestion((content) => { content.Content = questionText; content.ContentType = ContentType.Text; return; }, () => { List <QuestionOption> optionList = new List <QuestionOption>(); 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); } foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions( 36, minValue, maxValue, true, (c) => { for (int j = 2; j < c / 2 + 1; j++) { if (c % j == 0) { return(true); } } return(false); })) { optionList.Add(option); decimal optionValue = Convert.ToDecimal(option.OptionContent.Content); if (optionValue == 0) { strBuilder.AppendLine(string.Format("0 不是合数。")); } else if (!option.IsCorrect) { strBuilder.AppendLine(string.Format("{0}只有两个约数{1},{2}。", optionValue, 1, optionValue)); } else { decimal thirdValue = 0; for (int j = 2; j < optionValue / 2 + 1; j++) { if (optionValue % j == 0) { thirdValue = j; break; } } strBuilder.AppendLine(string.Format("{0}有约数{1},{2},{3}...,大于2个,是正确答案。", optionValue, 1, optionValue, thirdValue)); } } return(optionList); }); tableQuestion.Solution.Content = strBuilder.ToString(); tableQuestion.Tip = "合数至少有3个约数。"; section.QuestionCollection.Add(tableQuestion); }
private void GetRandomValues(SectionBaseInfo info, ref valuesStruct valueABC) { 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 (minValue < 1) { minValue = 1; } if (maxValue > 1000) { maxValue = 1000; } Random rand = new Random((int)DateTime.Now.Ticks); valueABC.number = rand.Next(3, 6); valueABC.answer = 0; //decimal A1, A2 = 0; int times = rand.Next(1, 10); int a1 = 0; // rand.Next(1, 10); //百位数 int b1 = rand.Next(1, 10); //十位数 int c1 = rand.Next(1, 10); //个位数 int a2 = 0; // rand.Next(1, 10); //百位数 int b2 = 0; // rand.Next(1, 10); //十位数 int c2 = rand.Next(1, 10); //个位数 int d1 = 0; int d2 = 0; decimal[] As = new decimal[10]; int posRand = rand.Next(0, 3); if (posRand == 0) { As[1] = rand.Next(1, 10) * 5; As[0] = rand.Next(minValue, maxValue + 1); As[2] = rand.Next(1, 10) * 2; } else if (posRand == 1) { As[0] = rand.Next(minValue, maxValue + 1); As[1] = rand.Next(1, 10) * 5; As[2] = rand.Next(1, 10) * 2; } else { As[0] = rand.Next(minValue, maxValue + 1); As[2] = rand.Next(1, 10) * 2; As[1] = rand.Next(1, 10) * 5; } for (int i = 3; i < valueABC.number; i++) { int rand52 = rand.Next(0, 3);// if (rand52 == 0) { As[i] = rand.Next(1, 10) * 5; } else if (rand52 == 1) { As[i] = rand.Next(minValue, maxValue + 1); } else { As[i] = rand.Next(1, 10) * 2; } } valueABC.answer = 1; for (int j = 0; j < valueABC.number; j++) { valueABC.values[j] = As[j]; valueABC.answer *= As[j]; } }
private void CreateMCQuestion(SectionBaseInfo info, Section section) { Random rand = new Random((int)DateTime.Now.Ticks); int divValue = rand.Next(2, 9); string questionText = string.Format("请选出是合数的数。"); MCQuestion mcQuestion = ObjectCreator.CreateMCQuestion((content) => { content.Content = questionText; content.ContentType = ContentType.Text; return; }, () => { List <QuestionOption> optionList = new List <QuestionOption>(); 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); } foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions( 4, minValue, maxValue, false, (c) => { for (int j = 2; j < c / 2 + 1; j++) { if (c % j == 0) { return(true); } } return(false); })) { optionList.Add(option); } return(optionList); } ); section.QuestionCollection.Add(mcQuestion); StringBuilder strBuilder = new StringBuilder(); foreach (QuestionOption option in mcQuestion.QuestionOptionCollection) { QuestionContent content = option.OptionContent; decimal value = System.Convert.ToDecimal(content.Content); int flag = 1; int j = 1; if (value == 0) { flag = 0; } for (j = 2; j < value / 2 + 1; j++) { if (value % j == 0) { flag = 2; break; } } if (flag == 0) { strBuilder.AppendLine(string.Format("0 不是合数。")); } else if (flag == 1) { strBuilder.AppendLine(string.Format("{0}只有两个约数{1},{2}。", value, 1, value)); } else { strBuilder.AppendLine(string.Format("{0}有约数{1},{2},{3}...,大于2个,是正确答案。", value, 1, value, j)); } } mcQuestion.Solution.Content = strBuilder.ToString(); }
private void GetRandomValues(SectionBaseInfo info, ref valuesStruct valueABC) { 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 (minValue < 10) { minValue = 10; } if (maxValue < 100) { maxValue = 100; } Random rand = new Random((int)DateTime.Now.Ticks); valueABC.number = 3; // rand.Next(10, 100 + 1); valueABC.answer = 0; int mode = rand.Next(0, 4); //三项加减混合式,0是两个加,1是一加一减,2是一减一加,3是两个减 valueABC.mode = mode; decimal A, B, C; if (mode == 0) //两个加号 { B = rand.Next(minValue, maxValue + 1); C = rand.Next(minValue + 1, maxValue + 1); int c = decimal.ToInt32(C) % 100; int a = 100 - c; A = rand.Next(minValue, maxValue + 1); A -= decimal.ToInt32(A) % 100; A += a; valueABC.values[0] = A; valueABC.values[1] = B; valueABC.values[2] = C; valueABC.answer = A + (B + C); } else if (mode == 1) //一加一减 { C = rand.Next(minValue, maxValue + 1); int cInt = decimal.ToInt32(C); B = rand.Next(cInt + 1, maxValue + cInt + 2); int c = decimal.ToInt32(C) % 100; int a = c; A = rand.Next(cInt + 1, maxValue + cInt + 2); A -= decimal.ToInt32(A) % 100; A += 100; A += a; valueABC.values[0] = A; valueABC.values[1] = B; valueABC.values[2] = C; valueABC.answer = A + (B - C); } else if (mode == 2) //一减一加 { C = rand.Next(minValue, maxValue + 1); int cInt = decimal.ToInt32(C); B = rand.Next(minValue + 1, maxValue + 1); int bInt = decimal.ToInt32(B); int c = decimal.ToInt32(C) % 100; int a = c; A = rand.Next(cInt + bInt + 1, maxValue + cInt + bInt + 2); A -= decimal.ToInt32(A) % 100; A += 100; A += a; valueABC.values[0] = A; valueABC.values[1] = B; valueABC.values[2] = C; valueABC.answer = A - (B + C); } else if (mode == 3) //两个减 { C = rand.Next(minValue, maxValue + 1); int cInt = decimal.ToInt32(C); B = rand.Next(cInt + 1, maxValue + cInt + 2); int bInt = decimal.ToInt32(B); int c = decimal.ToInt32(C) % 100; int a = 100 - c; A = rand.Next(bInt + 1, maxValue + bInt + 2); A -= decimal.ToInt32(A) % 100; A += 100; A += a; valueABC.values[0] = A; valueABC.values[1] = B; valueABC.values[2] = C; valueABC.answer = A - (B - C); } }
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; } } }