public CPQuestionUserControl(CPQuestion cpQuestion) { InitializeComponent(); this.cpQuestion = cpQuestion; this.richTextEditor.Text = cpQuestion.Content.Content; foreach (Question q in this.cpQuestion.SubQuestions) { this.subQuestionTempCollection.Add(q.Clone() as Question); } this.questionListView.ItemsSource = this.subQuestionTempCollection; }
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); } } } }