public CreateBranchWindowVM(ControlConstructSchemeVM controlConstructScheme, IfThenElse ifThenElse) { this.controlConstructScheme = controlConstructScheme; questionConstructs = new ObservableCollection<QuestionConstructVM>(); questionConstructs.AddRange(controlConstructScheme.QuestionConstructs); thenConstructs = new ObservableCollection<ConstructVM>(); thenConstructs.AddRange(controlConstructScheme.ThenConstructs); if (ifThenElse == null) { //新規作成の場合 TargetQuestionConstruct = controlConstructScheme.SelectedConstruct as QuestionConstructVM; branches = new ObservableCollection<BranchVM>(); //IF~THENを追加 BranchVM ifBranch = new BranchVM(BranchVM.TYPE_IF_CODE) { Parent = this, No = 1, }; ifBranch.Init(); branches.Add(ifBranch); } else { // 編集の場合 TargetQuestionConstruct = EDOUtils.Find(controlConstructScheme.QuestionConstructs, ifThenElse.IfCondition.QuestionId); branches = SequenceUtils.CreateBranches(ifThenElse, this); } }
public CreateBranchWindowVM(ControlConstructSchemeVM controlConstructScheme, IfThenElse ifThenElse) { this.controlConstructScheme = controlConstructScheme; questionConstructs = new ObservableCollection <QuestionConstructVM>(); questionConstructs.AddRange(controlConstructScheme.QuestionConstructs); thenConstructs = new ObservableCollection <ConstructVM>(); thenConstructs.AddRange(controlConstructScheme.ThenConstructs); if (ifThenElse == null) { //In the case of TargetQuestionConstruct = controlConstructScheme.SelectedConstruct as QuestionConstructVM; branches = new ObservableCollection <BranchVM>(); //Add IF ~ THEN BranchVM ifBranch = new BranchVM(BranchVM.TYPE_IF_CODE) { Parent = this, No = 1, }; ifBranch.Init(); branches.Add(ifBranch); } else { // Inthe case of edit TargetQuestionConstruct = EDOUtils.Find(controlConstructScheme.QuestionConstructs, ifThenElse.IfCondition.QuestionId); branches = SequenceUtils.CreateBranches(ifThenElse, this); } }
public static bool RenumberQuestionNumber(ControlConstructSchemeVM controlConstructScheme, QuestionNumberVM questionNumber) { List <QuestionNumberVM> questionNumbers = new List <QuestionNumberVM>(); questionNumbers.Add(questionNumber); return(RenumberQuestionNumbers(controlConstructScheme, questionNumbers)); }
public CreateSentenceWindowVM(ControlConstructSchemeVM controlConstructScheme, Statement statement) { this.controlConstructScheme = controlConstructScheme; this.statement = new Statement() { No = statement.No, Text = statement.Text }; }
public void AddControlConstructScheme() { ControlConstructSchemeVM scheme = new ControlConstructSchemeVM(); scheme.OrderNo = EDOUtils.GetMaxOrderNo <ControlConstructSchemeVM>(controlConstructSchemes) + 1; scheme.OrderPrefix = PREFIX; scheme.Init(); controlConstructSchemes.Add(scheme); SelectedControlConstructScheme = scheme; Memorize(); }
public ChangeMultipleQuestionNumberWindowVM(ControlConstructSchemeVM controlConstructScheme) { this.controlConstructScheme = controlConstructScheme; questionNumbers = new ObservableCollection <QuestionNumberVM>(); foreach (QuestionConstructVM questionConstruct in controlConstructScheme.QuestionConstructs) { QuestionNumberVM questionNumber = new QuestionNumberVM(questionConstruct); questionNumbers.Add(questionNumber); } }
public void EditCurrentRow() { ControlConstructSchemeVM scheme = SelectedControlConstructScheme; if (scheme == null) { return; } if (scheme.CanEditConstruct) { scheme.EditConstruct(); } }
private static void ReplaceIfThenElses(ControlConstructSchemeVM controlConstructScheme, Dictionary <IfThenElseVM, CreateBranchWindowVM> updatingIfThenElseDict) { Dictionary <IfThenElseVM, IfThenElseVM> ifThenElses = new Dictionary <IfThenElseVM, IfThenElseVM>(); foreach (KeyValuePair <IfThenElseVM, CreateBranchWindowVM> pair in updatingIfThenElseDict) { IfThenElseVM ifThenElse = pair.Key; CreateBranchWindowVM vm = pair.Value; vm.Save(); IfThenElseVM newIfThenElse = new IfThenElseVM(vm.IfThenElse); controlConstructScheme.ReplaceIfThenElse(ifThenElse, newIfThenElse); } }
public static bool RenumberQuestionNumbers(ControlConstructSchemeVM controlConstructScheme, ICollection <QuestionNumberVM> questionNumbers) { List <QuestionNumberVM> updatingQuestionNumbers = QuestionNumberVM.FindUpdatingQuestionNumbers(questionNumbers); if (updatingQuestionNumbers.Count == 0) { return(false); } // Change question numbers in the "if condition"s (need before and after question values) on memory Dictionary <IfThenElseVM, CreateBranchWindowVM> updatingIfThenElseDict = UpdateQuestionNumberOfBranches(controlConstructScheme, updatingQuestionNumbers); // Change QuestionConstruct's no QuestionNumberVM.UpdateQuestionNumbers(updatingQuestionNumbers); // replace if then else. ReplaceIfThenElses(controlConstructScheme, updatingIfThenElseDict); return(true); }
private static List <QuestionNumberVM> CreateAllQuestionNumber(ControlConstructSchemeVM controlConstructScheme, QuestionNumberVM questionNumber) { List <QuestionNumberVM> questionNumbers = new List <QuestionNumberVM>(); foreach (QuestionConstructVM questionConstruct in controlConstructScheme.QuestionConstructs) { QuestionNumberVM newQuestionNumber = null; if (questionConstruct == questionNumber.QuestionConstruct) { newQuestionNumber = questionNumber; } else { newQuestionNumber = new QuestionNumberVM(questionConstruct); } questionNumbers.Add(newQuestionNumber); } return(questionNumbers); }
public void CreateConstructs(ICollection <QuestionVM> questions) { //Call when the display of the question editing screen is finished ControlConstructSchemeVM scheme = FindDefaultControlConstructScheme(); if (scheme == null) { return; } foreach (QuestionVM question in questions) { if (question.IsCreatedConstruct) { continue; } question.IsCreatedConstruct = true; scheme.InsertQuestionConstruct(question, false); } }
public SequenceFormVM(StudyUnitVM studyUnit) : base(studyUnit) { controlConstructSchemes = new ObservableCollection<ControlConstructSchemeVM>(); int i = 1; foreach (ControlConstructScheme model in studyUnit.ControlConstructSchemeModels) { ControlConstructSchemeVM controlConstructScheme = new ControlConstructSchemeVM(model) { Parent = this, OrderNo = i++, OrderPrefix = PREFIX }; controlConstructScheme.Init(); controlConstructSchemes.Add(controlConstructScheme); } modelSyncher = new ModelSyncher<ControlConstructSchemeVM, ControlConstructScheme>( this, controlConstructSchemes, studyUnit.ControlConstructSchemeModels); }
public string FindQuestionNo(string questionId) { // find question no ControlConstructSchemeVM scheme = FindDefaultControlConstructScheme(); if (scheme == null) { return(null); } List <QuestionConstructVM> questionConstructs = scheme.QuestionConstructs; foreach (QuestionConstructVM questionConstruct in questionConstructs) { if (questionConstruct.QuestionId == questionId) { return(questionConstruct.No); } } return(null); }
private static readonly string PREFIX = Resources.Sequence; //Sequence public SequenceFormVM(StudyUnitVM studyUnit) : base(studyUnit) { controlConstructSchemes = new ObservableCollection <ControlConstructSchemeVM>(); int i = 1; foreach (ControlConstructScheme model in studyUnit.ControlConstructSchemeModels) { ControlConstructSchemeVM controlConstructScheme = new ControlConstructSchemeVM(model) { Parent = this, OrderNo = i++, OrderPrefix = PREFIX }; controlConstructScheme.Init(); controlConstructSchemes.Add(controlConstructScheme); } modelSyncher = new ModelSyncher <ControlConstructSchemeVM, ControlConstructScheme>( this, controlConstructSchemes, studyUnit.ControlConstructSchemeModels); }
private static Dictionary <string, List <StatementVM> > CreateStatementDict(ControlConstructSchemeVM controlConstructScheme) { var result = new Dictionary <string, List <StatementVM> >(); foreach (StatementVM statement in controlConstructScheme.Statements) { string no = statement.No; List <StatementVM> statements = null; if (result.ContainsKey(no)) { statements = result[no]; } else { statements = new List <StatementVM>(); result[no] = statements; } statements.Add(statement); } return(result); }
public static void ValidateQuestionNumbers(ControlConstructSchemeVM controlConstructScheme, ICollection <QuestionNumberVM> questionNumbers) { QuestionNumberVM.ClearValidationFlags(questionNumbers); Dictionary <string, List <QuestionNumberVM> > questionNumberDict = QuestionNumberVM.CreateQuestionNumberDict(questionNumbers); Dictionary <string, List <StatementVM> > statementDict = CreateStatementDict(controlConstructScheme); foreach (KeyValuePair <string, List <QuestionNumberVM> > pair in questionNumberDict) { List <StatementVM> statements = new List <StatementVM>(); if (statementDict.ContainsKey(pair.Key)) { statements = statementDict[pair.Key]; } QuestionNumberVM.CheckDuplicate(pair.Key, pair.Value, statements); } int errorCount = QuestionNumberVM.CountError(questionNumbers); if (errorCount > 0) { throw new ApplicationException(Resources.DuplicateQuestionNumber); } }
public void AddControlConstructScheme() { ControlConstructSchemeVM scheme = new ControlConstructSchemeVM(); scheme.OrderNo = EDOUtils.GetMaxOrderNo<ControlConstructSchemeVM>(controlConstructSchemes) + 1; scheme.OrderPrefix = PREFIX; scheme.Init(); controlConstructSchemes.Add(scheme); SelectedControlConstructScheme = scheme; Memorize(); }
public CreateBranchWindowVM(ControlConstructSchemeVM controlConstructScheme) : this(controlConstructScheme, null) { }
public bool IsDefaultControlConstructScheme(ControlConstructSchemeVM scheme) { return studyUnit.DefaultControlConstructSchemeId == scheme.Id; }
private static Dictionary <IfThenElseVM, CreateBranchWindowVM> UpdateQuestionNumberOfBranches(ControlConstructSchemeVM controlConstructScheme, ICollection <QuestionNumberVM> updatingQuestionNumbers) { Dictionary <IfThenElseVM, CreateBranchWindowVM> updatingIfThenElseDict = new Dictionary <IfThenElseVM, CreateBranchWindowVM>(); List <IfThenElseVM> ifThenElses = controlConstructScheme.IfThenElses; foreach (IfThenElseVM ifThenElse in ifThenElses) { CreateBranchWindowVM vm = new CreateBranchWindowVM(controlConstructScheme, ifThenElse.IfThenElse); if (UpdateQuestionNumbers(vm.Branches, updatingQuestionNumbers)) { updatingIfThenElseDict[ifThenElse] = vm; } } return(updatingIfThenElseDict); }
public static void ValidateQuestionNumber(ControlConstructSchemeVM controlConstructScheme, QuestionNumberVM questionNumber) { List <QuestionNumberVM> questionNumbers = CreateAllQuestionNumber(controlConstructScheme, questionNumber); // for duplicate check ValidateQuestionNumbers(controlConstructScheme, questionNumbers); }
public QuestionnaireWriter(EDOConfig config, ControlConstructSchemeVM controlConstructScheme) { this.config = config; this.controlConstructScheme = controlConstructScheme; }