private static void CreateESQuestion(ESQuestion question, int index, FlowDocument flowDocument, bool showAnswer, bool showResponse, ESQuestionResponse response) { System.Windows.Documents.Section questionSection = new System.Windows.Documents.Section(); flowDocument.Blocks.Add(questionSection); System.Windows.Documents.Section questionContentBlock = CreateContentControl(question.Content, (index + 1).ToString() + ". ", null, showResponse ? response : null); Paragraph lastParagraph = null; if (questionContentBlock.Blocks.LastBlock is Paragraph) { lastParagraph = questionContentBlock.Blocks.LastBlock as Paragraph; } if (lastParagraph == null) { lastParagraph = new Paragraph(); questionContentBlock.Blocks.Add(lastParagraph); } lastParagraph.Inlines.AddRange(new LineBreak[] { new LineBreak(), new LineBreak(), new LineBreak() }); if (showAnswer) { } questionSection.Blocks.Add(questionContentBlock); }
public ESQuestionUserControl(ESQuestion esQuestion, ESQuestionResponse response, int index) { this.esQuestion = esQuestion; this.index = index; this.response = response; InitializeComponent(); }
public ESQuestionUserControl(ESQuestion esQuestion) { InitializeComponent(); this.esQuestion = esQuestion; this.richTextEditor.Text = esQuestion.Content.Content; this.refAnswerRichTextEditor.Text = esQuestion.ReferenceAnswer.Content; }
private void InitQuestions() { List <int> ids = _taskObject.questionsIds; _questions = new List <IQuestion>(); foreach (int qId in ids) { var q = new ESQuestion(qId); if (q == null) { continue; } q.Task = this; _questions.Add(q); } }
internal Question CreateQuestion(QuestionType type) { Question question = null; switch (type) { case QuestionType.MultiChoice: { MCQuestion mcQuestion = new MCQuestion(); for (int i = 0; i < 4; i++) { QuestionOption option = new QuestionOption(); option.Index = i; mcQuestion.QuestionOptionCollection.Add(option); } question = mcQuestion; } break; case QuestionType.MultiResponse: { MRQuestion mrQuestion = new MRQuestion(); for (int i = 0; i < 4; i++) { QuestionOption option = new QuestionOption(); option.Index = i; mrQuestion.QuestionOptionCollection.Add(option); } question = mrQuestion; } break; case QuestionType.Essay: { ESQuestion esQuestion = new ESQuestion(); question = esQuestion; } break; case QuestionType.TrueFalse: { TFQuestion tfQuestion = new TFQuestion(); QuestionOption optionT = new QuestionOption(); optionT.Index = 0; QuestionOption optionF = new QuestionOption(); optionF.Index = 1; tfQuestion.QuestionOptionCollection.Add(optionT); tfQuestion.QuestionOptionCollection.Add(optionF); tfQuestion.RandomOption = true; question = tfQuestion; } break; case QuestionType.Match: { MAQuestion maQuestion = new MAQuestion(); for (int i = 0; i < 4; i++) { MAQuestionOption option = new MAQuestionOption(); option.Index = i; maQuestion.OptionList.Add(option); } question = maQuestion; } break; case QuestionType.FillInBlank: { FIBQuestion fibQuestion = new FIBQuestion(); question = fibQuestion; } break; case QuestionType.Composite: { CPQuestion cpQuestion = new CPQuestion(); question = cpQuestion; } break; } question.DifficultyLevel = 3; question.CreateTime = DateTime.Now.ToUniversalTime(); question.ModifyTime = DateTime.Now.ToUniversalTime(); return(question); }
private IEnumerable <string> GetQuestionImageFiles(Question question) { foreach (string src in GetImageFiles(question.Content.Content)) { yield return(src); } foreach (string src in GetImageFiles(question.Solution.Content)) { yield return(src); } if (question is SelectableQuestion) { SelectableQuestion selectableQuestion = question as SelectableQuestion; foreach (QuestionOption option in selectableQuestion.QuestionOptionCollection) { foreach (string optionImageSrc in GetImageFiles(option.OptionContent.Content)) { yield return(optionImageSrc); } } } else if (question is FIBQuestion) { FIBQuestion fibQuestion = question as FIBQuestion; foreach (QuestionBlank blank in fibQuestion.QuestionBlankCollection) { foreach (QuestionContent refAnswer in blank.ReferenceAnswerList) { foreach (string blankImageSrc in GetImageFiles(refAnswer.Content)) { yield return(blankImageSrc); } } } } else if (question is MAQuestion) { MAQuestion maQuestion = question as MAQuestion; foreach (MAQuestionOption option in maQuestion.OptionList) { foreach (var optionImageSrc in GetImageFiles(option.LeftContent.Content)) { yield return(optionImageSrc); } foreach (var optionImageSrc in GetImageFiles(option.RightContent.Content)) { yield return(optionImageSrc); } } } else if (question is ESQuestion) { ESQuestion esQuestion = question as ESQuestion; foreach (var refAnswerImageSrc in GetImageFiles(esQuestion.ReferenceAnswer.Content)) { yield return(refAnswerImageSrc); } } else if (question is CPQuestion) { CPQuestion cpQuestion = question as CPQuestion; foreach (var subQuestion in cpQuestion.SubQuestions) { foreach (var subQuestionImageSrc in GetQuestionImageFiles(subQuestion as Question)) { yield return(subQuestionImageSrc); } } } }