private void CreateTableQuestion(SectionBaseInfo sectionInfo, Section section) { // Table Question 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); } int inMinValue = 2, inMaxValue = 2; if (minValue / 10 > inMinValue) { inMinValue = minValue / 10; } inMaxValue = maxValue / 10; Random rand = new Random((int)DateTime.Now.Ticks); int divValue = rand.Next(2, 10); //int divValue = rand.Next(inMinValue, inMaxValue); string questionText = string.Format("请下表中选出是{0}倍数的数。", divValue); TableQuestion tableQuestion = ObjectCreator.CreateTableQuestion((content) => { content.Content = questionText; content.ContentType = ContentType.Text; return; }, () => { List <QuestionOption> optionList = new List <QuestionOption>(); foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions( 36, minValue, maxValue, true, (c => ((c % divValue) == 0)))) { optionList.Add(option); } return(optionList); }); tableQuestion.Solution.Content = this.CreateSolution(divValue); section.QuestionCollection.Add(tableQuestion); }
private void CreateTableQuestion(SectionBaseInfo sectionInfo, Section section) { // Table Question Random rand = new Random((int)DateTime.Now.Ticks); string questionText = string.Format("请下表中选出是质数的数。"); 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(false); } } return(true); })) { optionList.Add(option); } return(optionList); }); tableQuestion.Tip = this.CreateTip(); section.QuestionCollection.Add(tableQuestion); }
private Section CreateTableSection(SectionBaseInfo sectionInfo, BackgroundWorker worker) { // Table Question Section sectionTable = ObjectCreator.CreateSection(sectionInfo.Name, sectionInfo.Description); Random rand = new Random((int)DateTime.Now.Ticks); for (int i = 2; i < sectionInfo.QuestionCount + 2; i++) { int divValue = i; string questionText = string.Format("请下表中选出能被{0}公倍数的数。", divValue); 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 => ((c % divValue) == 0)))) { optionList.Add(option); } return(optionList); }); tableQuestion.Solution.Content = this.CreateSolution(divValue); sectionTable.QuestionCollection.Add(tableQuestion); worker.ReportProgress(0, tableQuestion); } return(sectionTable); }
private void CreateTableQuestion(SectionBaseInfo info, Section section) { Random rand = new Random((int)DateTime.Now.Ticks); if (section.QuestionCollection.Count == 0) { this.currentIndex = 2; } int divValue = this.currentIndex; string questionText = string.Format("请下表中选出能被{0}公约数的数。", divValue); 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 (info is SectionValueRangeInfo) { SectionValueRangeInfo rangeInfo = info as SectionValueRangeInfo; minValue = decimal.ToInt32(rangeInfo.MinValue); maxValue = decimal.ToInt32(rangeInfo.MaxValue); } foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions( 36, minValue, maxValue, true, (c => ((c % divValue) == 0)))) { optionList.Add(option); } return(optionList); }); this.currentIndex++; tableQuestion.Solution.Content = this.CreateSolution(divValue); section.QuestionCollection.Add(tableQuestion); }
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 CreateTableQuestion(SectionBaseInfo sectionInfo, Section section) { // Table Question Section sectionTable = ObjectCreator.CreateSection(sectionInfo.Name, sectionInfo.Description); Random rand = new Random((int)DateTime.Now.Ticks); 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); } int valueA = rand.Next(minValue, maxValue); string questionText = string.Format("请在下表中选出与{0}互质的数。", valueA); TableQuestion tableQuestion = ObjectCreator.CreateTableQuestion((content) => { content.Content = questionText; content.ContentType = ContentType.Text; return; }, () => { List <QuestionOption> optionList = new List <QuestionOption>(); foreach (QuestionOption option in ObjectCreator.CreateDecimalOptions( 36, minValue, maxValue, true, (c) => { int sumCommonDivisor = 0; int valueC; if (valueA < c) { valueC = valueA; } else if (valueA > c) { valueC = decimal.ToInt32(c); } else { return(false); } for (int j2 = 1; j2 < valueC; j2++) { if (valueA % j2 == 0 && c % j2 == 0) { sumCommonDivisor++; } } if (sumCommonDivisor == 1) { return(true); } return(false); } )) { optionList.Add(option); } return(optionList); }); tableQuestion.Tip = this.CreateTip(); section.QuestionCollection.Add(tableQuestion); }