Esempio n. 1
0
        private static void CreateCondGroups(string code, BranchVM branch, ObservableCollection <QuestionConstructVM> questionConstructs)
        {
            CondParser       parser         = new CondParser(code);
            List <CondGroup> condGroupElems = parser.Parse();

            foreach (CondGroup condGroupElem in condGroupElems)
            {
                CondGroupVM condGroup = new CondGroupVM()
                {
                    Parent = branch
                };
                condGroup.SelectedConnectionCode = Option.FindCodeByLabel(Options.Connections, condGroupElem.Connector);
                branch.CondGroups.Add(condGroup);

                foreach (Cond condElem in condGroupElem.Conds)
                {
                    CondVM cond = new CondVM()
                    {
                        Parent = condGroup
                    };
                    condGroup.Conds.Add(cond);
                    cond.SelectedQuestionConstruct = QuestionConstructVM.FindQuestionConstructByNo(questionConstructs, condElem.LeftValue);
                    cond.SelectedOperatorCode      = Option.FindCodeByLabel(Options.Operators, condElem.Operator);
                    cond.CondValue = condElem.RightValue;
                }
            }
        }
Esempio n. 2
0
 public override string this[string columnName]
 {
     get
     {
         if (IsIgnoreValidation)
         {
             return(null);
         }
         if (columnName == "SelectedQuestionConstructNo")
         {
             if (string.IsNullOrEmpty(SelectedQuestionConstructNo))
             {
                 return(Resources.InputQuestionNumber); //Enter question number
             }
         }
         else if (columnName == "CondValue")
         {
             if (string.IsNullOrEmpty(CondValue))
             {
                 return(Resources.InputValue); //Enter value
             }
             QuestionConstructVM questionConstruct = SelectedQuestionConstruct;
             if (questionConstruct == null)
             {
                 return(Resources.InputQuestionNumber); //Enter question number
             }
         }
         return(null);
     }
 }
Esempio n. 3
0
        public void Init()
        {
            List <string> ids = controlConstructScheme.Sequence.ControlConstructIds;

            foreach (string id in ids)
            {
                QuestionConstruct questionConstructModel = controlConstructScheme.FindQuestionConstruct(id);
                if (questionConstructModel != null)
                {
                    QuestionVM question = StudyUnit.FindQuestion(questionConstructModel.QuestionId);
                    Debug.Assert(question != null, "Question not found id=" + questionConstructModel.QuestionId);
                    QuestionConstructVM questionConstruct = new QuestionConstructVM(questionConstructModel, question);
                    InitConstruct(questionConstruct);
                    constructModels.Add(questionConstructModel);
                    constructs.Add(questionConstruct);
                    continue;
                }
                QuestionGroupConstruct questionGroupConstructModel = controlConstructScheme.FindQuestionGroupConstruct(id);
                if (questionGroupConstructModel != null)
                {
                    QuestionGroupVM          questionGroup          = StudyUnit.FindQuestionGroup(questionGroupConstructModel.QuestionGroupId);
                    QuestionGroupConstructVM questionGroupConstruct = new QuestionGroupConstructVM(questionGroupConstructModel, questionGroup);
                    InitConstruct(questionGroupConstruct);
                    constructModels.Add(questionGroupConstructModel);
                    constructs.Add(questionGroupConstruct);
                    continue;
                }
                Statement statementModel = controlConstructScheme.FindStatement(id);
                if (statementModel != null)
                {
                    StatementVM statement = new StatementVM(statementModel);
                    InitConstruct(statement);
                    constructModels.Add(statementModel);
                    constructs.Add(statement);
                    continue;
                }
                IfThenElse ifThenElseModel = controlConstructScheme.FindIfThenElse(id);
                if (ifThenElseModel != null)
                {
                    IfThenElseVM ifThenElse = new IfThenElseVM(ifThenElseModel);
                    InitConstruct(ifThenElse);
                    constructModels.Add(ifThenElseModel);
                    constructs.Add(ifThenElse);
                }
            }

            List <QuestionConstructVM> questionConstructs = QuestionConstructs;

            foreach (ConstructVM construct in constructs)
            {
                if (construct is IfThenElseVM)
                {
                    IfThenElseVM ifThenElse = (IfThenElseVM)construct;
                    ifThenElse.ThenConstructs = ThenConstructs;
                }
            }
            modelSyncher = new ModelSyncher <ConstructVM, IConstruct>(this, constructs, constructModels);
            InitTitle();
        }
Esempio n. 4
0
        public void InsertQuestionConstruct(QuestionVM question, bool manualOperation)
        {
            ConstructVM construct = ConstructVM.FindByQuestionId(constructs, question.Id);

            if (construct != null)
            {
                if (manualOperation)
                {
                    //show error message if added by screen
                    MessageBox.Show(Resources.AlreadySelectedQuestion); //This question is already selected
                }
                return;
            }
            QuestionConstruct questionConstructModel = new QuestionConstruct();

            questionConstructModel.QuestionId = question.Id;
            questionConstructModel.No         = ControlConstructScheme.QUESTION_NO_PREFIX + (ConstructUtils.QuestionConstructCount(constructs) + 1);
            QuestionConstructVM questionConstruct = new QuestionConstructVM(questionConstructModel, question);

            InsertConstruct(questionConstruct, manualOperation);
        }
Esempio n. 5
0
        public void RemoveQuestion(QuestionVM question)
        {
            bool removed = false;

            for (int i = constructs.Count - 1; i >= 0; i--)
            {
                ConstructVM construct = constructs[i];
                if (construct is QuestionConstructVM)
                {
                    QuestionConstructVM questionConstruct = (QuestionConstructVM)construct;
                    if (questionConstruct.Question == question)
                    {
                        constructs.RemoveAt(i);
                        removed = true;
                    }
                }
            }
            if (removed)
            {
                UpdateModel(false);
            }
        }
Esempio n. 6
0
        //private QuestionConstructVM selectedQuestionConstruct;
        //public QuestionConstructVM SelectedQuestionConstruct
        //{
        //    get
        //    {
        //        return selectedQuestionConstruct;
        //    }
        //    set
        //    {
        //        if (selectedQuestionConstruct != value)
        //        {
        //            selectedQuestionConstruct = value;
        //            NotifyPropertyChanged("SelectedQuestionConstruct");
        //        }
        //    }
        //}

        private bool IsValidQuestionConstructNo(string no)
        {
            QuestionConstructVM questin = QuestionConstructVM.FindQuestionConstructByNo(QuestionConstructs, no);

            return(questin != null);
        }
 public void InsertQuestionConstruct(QuestionVM question, bool manualOperation)
 {
     ConstructVM construct = ConstructVM.FindByQuestionId(constructs, question.Id);
     if (construct != null)
     {
         if (manualOperation)
         {
             //画面から追加した場合エラーメッセージを表示する
             MessageBox.Show(Resources.AlreadySelectedQuestion); //選択済みの質問です
         }
         return;
     }
     QuestionConstruct questionConstructModel = new QuestionConstruct();
     questionConstructModel.QuestionId = question.Id;
     questionConstructModel.No = ControlConstructScheme.QUESTION_NO_PREFIX + (ConstructUtils.QuestionConstructCount(constructs) + 1);
     QuestionConstructVM questionConstruct = new QuestionConstructVM(questionConstructModel, question);
     InsertConstruct(questionConstruct, manualOperation);
 }
        public void Init()
        {
            List<string> ids = controlConstructScheme.Sequence.ControlConstructIds;
            foreach (string id in ids)
            {
                QuestionConstruct questionConstructModel = controlConstructScheme.FindQuestionConstruct(id);
                if (questionConstructModel != null)
                {
                    QuestionVM question = StudyUnit.FindQuestion(questionConstructModel.QuestionId);
                      Debug.Assert(question != null, "Question not found id=" + questionConstructModel.QuestionId);
                    QuestionConstructVM questionConstruct = new QuestionConstructVM(questionConstructModel, question);
                    InitConstruct(questionConstruct);
                    constructModels.Add(questionConstructModel);
                    constructs.Add(questionConstruct);
                    continue;
                }
                QuestionGroupConstruct questionGroupConstructModel = controlConstructScheme.FindQuestionGroupConstruct(id);
                if (questionGroupConstructModel != null)
                {
                    QuestionGroupVM questionGroup = StudyUnit.FindQuestionGroup(questionGroupConstructModel.QuestionGroupId);
                    QuestionGroupConstructVM questionGroupConstruct = new QuestionGroupConstructVM(questionGroupConstructModel, questionGroup);
                    InitConstruct(questionGroupConstruct);
                    constructModels.Add(questionGroupConstructModel);
                    constructs.Add(questionGroupConstruct);
                    continue;
                }
                Statement statementModel = controlConstructScheme.FindStatement(id);
                if (statementModel != null)
                {
                    StatementVM statement = new StatementVM(statementModel);
                    InitConstruct(statement);
                    constructModels.Add(statementModel);
                    constructs.Add(statement);
                    continue;
                }
                IfThenElse ifThenElseModel = controlConstructScheme.FindIfThenElse(id);
                if (ifThenElseModel != null)
                {
                    IfThenElseVM ifThenElse = new IfThenElseVM(ifThenElseModel);
                    InitConstruct(ifThenElse);
                    constructModels.Add(ifThenElseModel);
                    constructs.Add(ifThenElse);
                }
            }

            List<QuestionConstructVM> questionConstructs = QuestionConstructs;
            foreach (ConstructVM construct in constructs)
            {
                if (construct is IfThenElseVM)
                {
                    IfThenElseVM ifThenElse = (IfThenElseVM)construct;
                    ifThenElse.ThenConstructs = ThenConstructs;
                }
            }
            modelSyncher = new ModelSyncher<ConstructVM, IConstruct>(this, constructs, constructModels);
            InitTitle();
        }
Esempio n. 9
0
 public QuestionNumberVM(QuestionConstructVM questionConstruct)
 {
     this.questionConstruct = questionConstruct;
     IsValid = true;
 }
 public ChangeSingleQuestionNumberWindowVM(QuestionConstructVM questionConstruct)
 {
     this.questionConstruct      = questionConstruct;
     this.controlConstructScheme = (ControlConstructSchemeVM)questionConstruct.Parent;
     this.questionNumber         = new QuestionNumberVM(questionConstruct);
 }