public void AddQuestionGroup() { InputDialog dlg = new InputDialog(); dlg.Title = Resources.InputQuestionGroupName; //Enter the question group name dlg.Owner = Application.Current.MainWindow; dlg.ShowDialog(); if (dlg.DialogResult == true) { QuestionGroup questionGroupModel = new QuestionGroup() { Title = dlg.textBox.Text }; QuestionGroupVM questionGroup = new QuestionGroupVM(questionGroupModel) { Parent = this }; questionGroups.Add(questionGroup); if (SelectedQuestionGroup == null) { SelectedQuestionGroup = questionGroup; } Memorize(); } }
public QuestionGroupConstructVM(QuestionGroupConstruct questionGroupConstruct, QuestionGroupVM questionGroup) : base(questionGroupConstruct) { Debug.Assert(questionGroupConstruct != null); Debug.Assert(questionGroup != null); this.questionGroupConstruct = questionGroupConstruct; this.questionGroup = questionGroup; }
public QuestionGroupFormVM(StudyUnitVM studyUnit) : base(studyUnit) { ObservableCollection<QuestionVM> allQuestions = studyUnit.AllQuestions; questionGroups = new ObservableCollection<QuestionGroupVM>(); foreach (QuestionGroup questionGroupModel in studyUnit.QuestionGroupModels) { QuestionGroupVM questionGroup = new QuestionGroupVM(questionGroupModel, allQuestions) { Parent = this }; questionGroups.Add(questionGroup); } modelSyncher = new ModelSyncher<QuestionGroupVM, QuestionGroup>(this, questionGroups, studyUnit.QuestionGroupModels); }
public QuestionGroupFormVM(StudyUnitVM studyUnit) : base(studyUnit) { ObservableCollection <QuestionVM> allQuestions = studyUnit.AllQuestions; questionGroups = new ObservableCollection <QuestionGroupVM>(); foreach (QuestionGroup questionGroupModel in studyUnit.QuestionGroupModels) { QuestionGroupVM questionGroup = new QuestionGroupVM(questionGroupModel, allQuestions) { Parent = this }; questionGroups.Add(questionGroup); } modelSyncher = new ModelSyncher <QuestionGroupVM, QuestionGroup>(this, questionGroups, studyUnit.QuestionGroupModels); }
private void WriteQuestionGroupResponse(Body body, QuestionGroupVM questionGroup) { ICollection<QuestionVM> questions = questionGroup.Questions; if (questions.Count == 0) { return; } Table table = CreateFilledTable(true, true); if (questionGroup.Orientation == QuestionGroupOrientation.Row) { //行方向の場合(選択肢が横に並んでいる) QuestionVM firstQuestion = questions.First(); List<CodeVM> codes = GetValidCodes(firstQuestion.Response.Codes); int firstQuestionCount = codes.Count; TableRow tableRow = null; if (questionGroup.Sentence == QuestionGroupSentence.Top) { //ヘッダー行 tableRow = new TableRow(); table.Append(tableRow); tableRow.Append(CreateBorderCell(0)); foreach (CodeVM code in codes) { tableRow.Append(CreateBorderCell(code.Label)); } } foreach (QuestionVM question in questions) { tableRow = new TableRow(); table.Append(tableRow); //最初に質問文 tableRow.Append(CreateBorderCell(question.Title)); //その後にセル codes = GetValidCodes(question.Response.Codes); foreach (CodeVM code in codes) { List<string> contents = new List<string>(); contents.Add(code.Value); if (questionGroup.Sentence == QuestionGroupSentence.EachCell) { contents.Add(code.Label); } tableRow.Append(CreateCenterCell(contents)); } int diff = firstQuestionCount - codes.Count; if (diff > 0) { for (int i = 0; i < diff; i++) { tableRow.Append(CreateBorderCell(0)); } } } } else { //列方向の場合 //ヘッダー行 TableRow tableRow = new TableRow(); table.Append(tableRow); if (questionGroup.Sentence == QuestionGroupSentence.Top) { tableRow.Append(CreateBorderCell(0)); } //質問文 foreach (QuestionVM question in questions) { tableRow.Append(CreateBorderCell(question.Title)); } QuestionVM firstQuestion = questions.First(); List<CodeVM> codes = GetValidCodes(firstQuestion.Response.Codes); int firstQuestionCount = codes.Count; int codeIndex = 0; foreach (CodeVM code in codes) { tableRow = new TableRow(); table.Append(tableRow); //選択肢 if (questionGroup.Sentence == QuestionGroupSentence.Top) { tableRow.Append(CreateBorderCell(code.Label)); } foreach (QuestionVM question in questions) { List<CodeVM> questionCodes = GetValidCodes(question.Response.Codes); if (codeIndex < questionCodes.Count) { List<string> contents = new List<string>(); contents.Add(questionCodes[codeIndex].Value); if (questionGroup.Sentence == QuestionGroupSentence.EachCell) { contents.Add(questionCodes[codeIndex].Label); } tableRow.Append(CreateCenterCell(contents)); } else { tableRow.Append(CreateBorderCell(0)); } } codeIndex++; } } body.Append(table); }
public void InsertQuestionGroupConstruct(QuestionGroupVM questionGroup, bool manualOperation) { ConstructVM construct = ConstructVM.FindByQuestionGroupId(constructs, questionGroup.Id); if (construct != null) { if (manualOperation) { MessageBox.Show(Resources.AlreadySelectedQuestionGroup); //選択済みの質問グループです } return; } QuestionGroupConstruct questionGroupConstructModel = new QuestionGroupConstruct(); questionGroupConstructModel.QuestionGroupId = questionGroup.Id; questionGroupConstructModel.No = ControlConstructScheme.QUESTION_GROUP_NO_PREFIX + (ConstructUtils.QuestionGroupConstructCount(constructs) + 1); QuestionGroupConstructVM questionGroupConstruct = new QuestionGroupConstructVM(questionGroupConstructModel, questionGroup); InsertConstruct(questionGroupConstruct, manualOperation); }
public void AddQuestionGroup() { InputDialog dlg = new InputDialog(); dlg.Title = Resources.InputQuestionGroupName; //質問グループの名前を入力してください dlg.Owner = Application.Current.MainWindow; dlg.ShowDialog(); if (dlg.DialogResult == true) { QuestionGroup questionGroupModel = new QuestionGroup() { Title = dlg.textBox.Text }; QuestionGroupVM questionGroup = new QuestionGroupVM(questionGroupModel) { Parent = this }; questionGroups.Add(questionGroup); if (SelectedQuestionGroup == null) { SelectedQuestionGroup = questionGroup; } Memorize(); } }