예제 #1
0
 public SelectResponseWindowVM(StudyUnitVM studyUnit, ResponseVM excludeResponse)
     : base(studyUnit)
 {
     this.excludeResponse = excludeResponse;
     this.responses       = new ObservableCollection <ResponseVM>();
     Filter("");
 }
 public SelectResponseWindowVM(StudyUnitVM studyUnit, ResponseVM excludeResponse)
     : base(studyUnit)
 {
     this.excludeResponse = excludeResponse;
     this.responses = new ObservableCollection<ResponseVM>();
     Filter("");
 }
예제 #3
0
        public ResponseVM SelectAndCreateResponse(ResponseVM sourceResponse)
        {
            ResponseVM newResponse = null;

            if (sourceResponse.IsTypeChoices)
            {
                StudyUnit.CompleteResponse(sourceResponse);
                CodeSchemeVM sourceCodeScheme = sourceResponse.CodeScheme;

                ObservableCollection <CodeSchemeVM> codeSchemes = new ObservableCollection <CodeSchemeVM>(StudyUnit.CodeSchemes);

                SelectObjectWindowVM <CodeSchemeVM> vm = new SelectObjectWindowVM <CodeSchemeVM>(codeSchemes);
                CodeSchemeVM codeScheme = SelectObjectWindow.Select(Resources.SelectResponse, vm) as CodeSchemeVM; //Select Response Style
                if (codeScheme != null && sourceCodeScheme != codeScheme)
                {
                    Response responseModel = new Response();
                    responseModel.TypeCode = Options.RESPONSE_TYPE_CHOICES_CODE;
                    responseModel.Title    = codeScheme.Title;
                    newResponse            = new ResponseVM(responseModel, codeScheme);
                }
            }
            else
            {
                ObservableCollection <ResponseVM> responses = GetCandidateResponses();
                SelectObjectWindowVM <ResponseVM> vm        = new SelectObjectWindowVM <ResponseVM>(responses);
                ResponseVM selectedResponse = SelectObjectWindow.Select(Resources.SelectResponse, vm) as ResponseVM;
                if (selectedResponse != null && sourceResponse != selectedResponse)
                {
                    newResponse = selectedResponse.Dup();
                }
            }
            return(newResponse);
        }
예제 #4
0
        public ResponseVM Dup()
        {
            //put a different name.
            Response newResponseModel = response.Dup();
            //Category scheme and code scheme to reuse
            ResponseVM newResponse = new ResponseVM(newResponseModel, codeScheme);

            newResponse.Parent = Parent; //necessary to set Parent so access to StudyUnit in Init
            return(newResponse);
        }
예제 #5
0
파일: QuestionVM.cs 프로젝트: ssjda-ddi/EDO
 public static QuestionVM QuestionFor(ICollection <QuestionVM> questions, ResponseVM response)
 {
     foreach (QuestionVM question in questions)
     {
         if (question.Response == response)
         {
             return(question);
         }
     }
     return(null);
 }
예제 #6
0
        public ResponseVM CreateResponse(Response responseModel)
        {
            CodeSchemeVM codeScheme = null;

            if (responseModel.IsTypeChoices)
            {
                codeScheme = StudyUnit.FindCodeScheme(responseModel);
            }
            ResponseVM response = new ResponseVM(responseModel, codeScheme);

            return(response);
        }
예제 #7
0
        public void SelectResponse()
        {
            ResponseVM newResponse = SelectAndCreateResponse(SelectedQuestion.Response);

            if (newResponse != null)
            {
                SelectedQuestion.Response = newResponse;
                //When the question is selected, the following notification is needed for Response Style name to be reflected in the name of Response Style the question grid
                SelectedQuestion.NotifyPropertyChanged("ResponseTitle");
                Window.UpdateTemplate();
            }
        }
예제 #8
0
        public override VMState SaveState()
        {
            if (SelectedConcept == null)
            {
                //Impossible, but check may be necessary just to make sure.
                return(null);
            }
            VMState state = new VMState();

            state.State1 = SelectedConcept.Id;
            if (SelectedQuestion != null)
            {
                state.State2 = SelectedQuestion.Id;
                ResponseVM response = SelectedQuestion.Response;
                state.State3 = response.SelectedIndex;
            }
            return(state);
        }
예제 #9
0
        public bool ConfirmChangeType(ResponseVM response)
        {
            if (!response.IsTypeChoices)
            {
                return true;
            }

            bool containsInQuestionGroup = false;
            foreach (QuestionGroupVM questionGroup in QuestionGroups)
            {
                foreach (QuestionVM question in questionGroup.Questions)
                {
                    if (question.Response == response)
                    {
                        containsInQuestionGroup = true;
                        break;
                    }
                }
            }
            if (!containsInQuestionGroup)
            {
                return true;
            }
            // 質問グループから外れますがよろしいですか? 確認
            MessageBoxResult result = MessageBox.Show(Resources.ConfirmRemoveFromQuestionGroup, Resources.Confirmation, MessageBoxButton.YesNo);
            if (result == MessageBoxResult.No)
            {
                return false;
            }
            return true;
        }
예제 #10
0
 public ResponseVM SelectAndCreateResponse(ResponseVM sourceResponse)
 {
     return questionForm.SelectAndCreateResponse(sourceResponse);
 }
예제 #11
0
        public void CompleteResponse(ResponseVM response)
        {
            if (!response.IsTypeChoices)
            {
                return;
            }

            CodeSchemeVM codeScheme = response.CodeScheme;
            if (!codeForm.CodeSchemes.Contains(codeScheme))
            {
                //設問設計画面で全く新規に追加された場合
                //タイトルを設定する(コードが全く追加されておらずかつレスポンスのタイトルも空白の場合、null代入により「無題の」が設定される。
                codeScheme.Title = string.IsNullOrEmpty(response.Title) ? CodeVM.JoinLabels(codeScheme.Codes) : response.Title;
                //CodeSchemeを追加する
                codeForm.CodeSchemes.Add(codeScheme);
            }

            List<CodeVM> orphanCodes = new List<CodeVM>();
            foreach (CodeVM code in codeScheme.Codes)
            {
                if (!categoryForm.Contains(code.CategoryId))
                {
                    //設問に対応したカテゴリースキームが存在しない場合、孤立したコードは覚えておく。
                    orphanCodes.Add(code);
                }
            }

            if (orphanCodes.Count > 0) {
                //孤立したコード(カテゴリーが存在既存のカテゴリ集合に含まれていない場合)
                //カテゴリスキームを新規生成してそこにカテゴリを追加する。
                CategorySchemeVM categoryScheme = categoryForm.FindCategorySchemeByResponseId(response.Id);
                if (categoryScheme == null)
                {
                    categoryScheme = new CategorySchemeVM();
                    categoryScheme.ResponseId = response.Id;
                    categoryScheme.Title = string.IsNullOrEmpty(response.Title) ? CodeVM.JoinLabels(orphanCodes) : response.Title; //全体からではなく孤立したコードから生成する
                    categoryForm.CategorySchemes.Add(categoryScheme);
                }
                //カテゴリを追加していく(コードは自動的に追加されるがカテゴリは自動では追加されないため)
                foreach (CodeVM code in orphanCodes)
                {
                    //それぞれのCodeVMにはCategoryVMが含まれているのでそれをCategorySchemeに追加していく。
                    categoryScheme.Categories.Add(code.Category);
                }
            }
        }
예제 #12
0
        public ResponseVM SelectAndCreateResponse(ResponseVM sourceResponse)
        {
            ResponseVM newResponse = null;
            if (sourceResponse.IsTypeChoices)
            {
                StudyUnit.CompleteResponse(sourceResponse);
                CodeSchemeVM sourceCodeScheme = sourceResponse.CodeScheme;

                ObservableCollection<CodeSchemeVM> codeSchemes = new ObservableCollection<CodeSchemeVM>(StudyUnit.CodeSchemes);

                SelectObjectWindowVM<CodeSchemeVM> vm = new SelectObjectWindowVM<CodeSchemeVM>(codeSchemes);
                CodeSchemeVM codeScheme = SelectObjectWindow.Select(Resources.SelectResponse, vm) as CodeSchemeVM; //回答の選択
                if (codeScheme != null && sourceCodeScheme != codeScheme)
                {
                    Response responseModel = new Response();
                    responseModel.TypeCode = Options.RESPONSE_TYPE_CHOICES_CODE;
                    responseModel.Title = codeScheme.Title;
                    newResponse = new ResponseVM(responseModel, codeScheme);
                }
            }
            else
            {
                ObservableCollection<ResponseVM> responses = GetCandidateResponses();
                SelectObjectWindowVM<ResponseVM> vm = new SelectObjectWindowVM<ResponseVM>(responses);
                ResponseVM selectedResponse = SelectObjectWindow.Select(Resources.SelectResponse, vm) as ResponseVM;
                if (selectedResponse != null && sourceResponse != selectedResponse)
                {
                    newResponse = selectedResponse.Dup();
                }
            }
            return newResponse;
        }
예제 #13
0
 public ResponseVM Dup()
 {
     //新しいIDを割り当るなど通常のCloneと意味合いが違うので別の名前をつける。
     Response newResponseModel = response.Dup();
     //カテゴリースキーム・コードスキームは再利用
     ResponseVM newResponse = new ResponseVM(newResponseModel, codeScheme);
     newResponse.Parent = Parent; //InitでStudyUnitにアクセスするのでParentの設定が必要
     return newResponse;
 }
예제 #14
0
 public SelectResponseWindow(StudyUnitVM studyUnit, ResponseVM excludeResponse)
 {
     InitializeComponent();
     this.viewModel   = new SelectResponseWindowVM(studyUnit, excludeResponse);
     this.DataContext = this.viewModel;
 }
예제 #15
0
 public ResponseVM CreateResponse(Response responseModel)
 {
     CodeSchemeVM codeScheme = null;
     if (responseModel.IsTypeChoices)
     {
         codeScheme = StudyUnit.FindCodeScheme(responseModel);
     }
     ResponseVM response = new ResponseVM(responseModel, codeScheme);
     return response;
 }
예제 #16
0
 private bool HasMonth(ResponseVM response)
 {
     string code = response.DetailTypeCode;
     if (Options.IsDateTimeTypeDateTime(code) ||
         Options.IsDateTimeTypeDate(code) ||
         Options.IsDateTimeTypeYearMonth(code) ||
         Options.IsDateTimeTypeDuration(code)
         )
     {
         return true;
     }
     return false;
 }
예제 #17
0
 public CategorySchemeVM FindCategorySchemeByResponse(ResponseVM response)
 {
     return categoryForm.FindCategorySchemeByResponseId(response.Id);
 }
 public SelectResponseWindow(StudyUnitVM studyUnit, ResponseVM excludeResponse)
 {
     InitializeComponent();
     this.viewModel = new SelectResponseWindowVM(studyUnit, excludeResponse);
     this.DataContext = this.viewModel;
 }
예제 #19
0
 private int CalcNumericColumnCount(ResponseVM response)
 {
     decimal? max = response.Max;
     if (max == null || !max.HasValue)
     {
         return 3;
     }
     return max.ToString().Length;
 }
예제 #20
0
 public static QuestionVM QuestionFor(ICollection<QuestionVM> questions, ResponseVM response)
 {
     foreach (QuestionVM question in questions)
     {
         if (question.Response == response)
         {
             return question;
         }
     }
     return null;
 }
예제 #21
0
 private bool HasTime(ResponseVM response)
 {
     string code = response.DetailTypeCode;
     if (Options.IsDateTimeTypeDateTime(code)
         )
     {
         return true;
     }
     return false;
 }
예제 #22
0
        private void AppendResponseElelems(XElement varElem, string parentConvertId, ResponseVM response)
        {
            if (response.IsTypeChoices)
            {
                List<XElement> catgryGrps = new List<XElement>();
                List<XElement> catgries = new List<XElement>();

                CodeSchemeVM codeScheme = response.CodeScheme;
                ObservableCollection<CodeVM> codes = codeScheme.Codes;

                if (codes.Count > 0)
                {
                    XElement catgryGrp = new XElement(cb + TAG_CATGRY_GRP,
                        CreateIDAttribute(ConvertChildId(codeScheme.Id, parentConvertId)),
                        new XAttribute(ATTR_CATGRY, JoinCodeIds(codes, parentConvertId)),
                        new XElement(cb + TAG_LABL, codeScheme.Title),
                        new XElement(cb + TAG_TXT, codeScheme.Memo));
                    varElem.Add(catgryGrp);

                    foreach (CodeVM code in codes)
                    {
                        XElement catgry = new XElement(cb + TAG_CATGRY,
                            CreateIDAttribute(ConvertChildId(code.CodeId, parentConvertId)),
                            new XElement(cb + TAG_CAT_VALU, code.Value),
                            new XElement(cb + TAG_LABL, code.Label),
                            new XElement(cb + TAG_TXT, code.Category.Memo)
                            );
                        varElem.Add(catgry);
                    }
                }

                XElement varFormat = new XElement(cb + TAG_VAR_FORMAT,
                    new XAttribute(ATTR_TYPE, "numeric"),
                    new XAttribute(ATTR_SCHEMA, "other"));
                varElem.Add(varFormat);
            }
            else if (response.IsTypeNumber)
            {
                XElement valrng = new XElement(cb + TAG_VALRNG,
                    new XElement(cb + TAG_RANGE,
                        CreateNullableAttr(ATTR_MIN, response.Min),
                        CreateNullableAttr(ATTR_MAX, response.Max)));
                varElem.Add(valrng);

                XElement varFormat = new XElement(cb + TAG_VAR_FORMAT);
                varElem.Add(varFormat);
            }
            else if (response.IsTypeFree)
            {
                XElement varlng = new XElement(cb + TAG_VALRNG,
                    new XElement(cb + TAG_RANGE,
                        CreateNullableAttr(ATTR_MIN, response.Min),
                        CreateNullableAttr(ATTR_MAX, response.Max)));
                varElem.Add(varlng);

                XElement varFormat = new XElement(cb + TAG_VAR_FORMAT,
                    new XAttribute(ATTR_TYPE, "character"),
                    new XAttribute(ATTR_SCHEMA, "other"));
                varElem.Add(varFormat);
            }
            else if (response.IsTypeDateTime)
            {
                XElement varFormat = new XElement(cb + TAG_VAR_FORMAT,
                    new XAttribute(ATTR_TYPE, "numeric"),
                    new XAttribute(ATTR_SCHEMA, "other"),
                    new XAttribute(ATTR_CATEGORY, "date"));
                varElem.Add(varFormat);
            }
        }