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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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
     };
 }
예제 #5
0
 public CreateSentenceWindowVM(ControlConstructSchemeVM controlConstructScheme, Statement statement)
 {
     this.controlConstructScheme = controlConstructScheme;
     this.statement = new Statement()
     {
         No   = statement.No,
         Text = statement.Text
     };
 }
예제 #6
0
        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);
            }
        }
예제 #8
0
        public void EditCurrentRow()
        {
            ControlConstructSchemeVM scheme = SelectedControlConstructScheme;

            if (scheme == null)
            {
                return;
            }
            if (scheme.CanEditConstruct)
            {
                scheme.EditConstruct();
            }
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        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);
            }
        }
예제 #13
0
 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);
 }
예제 #14
0
        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);
        }
예제 #15
0
        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);
        }
예제 #16
0
        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);
        }
예제 #17
0
        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);
            }
        }
예제 #18
0
 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();
 }
예제 #19
0
 public CreateBranchWindowVM(ControlConstructSchemeVM controlConstructScheme) : this(controlConstructScheme, null)
 {
 }
예제 #20
0
 public bool IsDefaultControlConstructScheme(ControlConstructSchemeVM scheme)
 {
     return studyUnit.DefaultControlConstructSchemeId == scheme.Id;
 }
예제 #21
0
        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);
        }
예제 #22
0
        public static void ValidateQuestionNumber(ControlConstructSchemeVM controlConstructScheme, QuestionNumberVM questionNumber)
        {
            List <QuestionNumberVM> questionNumbers = CreateAllQuestionNumber(controlConstructScheme, questionNumber); // for duplicate check

            ValidateQuestionNumbers(controlConstructScheme, questionNumbers);
        }
예제 #23
0
 public QuestionnaireWriter(EDOConfig config, ControlConstructSchemeVM controlConstructScheme)
 {
     this.config = config;
     this.controlConstructScheme = controlConstructScheme;
 }
예제 #24
0
 public CreateBranchWindowVM(ControlConstructSchemeVM controlConstructScheme)
     : this(controlConstructScheme, null)
 {
 }