Example #1
0
        public static StatisticsInfo CreateDummyChoicesMultiAnswerStatisticsInfo(CodebookVariable codebookVariable)
        {
            Debug.Assert(codebookVariable.IsTypeChoicesMultipleAnswer);
            Debug.Assert(codebookVariable.Question != null);

            QuestionVM question = codebookVariable.Question;
            ObservableCollection <CodeVM> codes     = question.Response.Codes;
            List <VariableVM>             variables = codebookVariable.Variables;

            List <CategoryInfo> categoryInfos = new List <CategoryInfo>();

            for (int i = 0; i < variables.Count; i++)
            {
                if (i >= codes.Count)
                {
                    break;
                }
                VariableVM variable = variables[i];
                CodeVM     code     = codes[i];

                CategoryInfo categoryInfo = new CategoryInfo();
                categoryInfo.VariableTitle = variable.Title;
                categoryInfo.CodeValue     = code.Value;
                categoryInfo.CategoryTitle = code.Label;
                categoryInfos.Add(categoryInfo);
            }

            StatisticsInfo statisticsInfo = new StatisticsInfo();

            statisticsInfo.QuestionId     = question.Id;
            statisticsInfo.StatisticsType = StatisticsTypes.ChoicesMultipleAnswer;
            statisticsInfo.CategoryInfos  = categoryInfos;
            return(statisticsInfo);
        }
Example #2
0
        public static DataTemplate SelectTemplate(VariableVM variable)
        {
            string typeCode     = variable != null ? variable.ResponseTypeCode : null;
            string resourceName = GetResponseResourceName(typeCode);

            return((DataTemplate)Application.Current.Resources[resourceName]);
        }
Example #3
0
 private string VariableType(VariableVM variable)
 {
     ResponseVM response = variable.Response;
     string type = "";
     if (response.IsTypeChoices)
     {
         if (response.ValidCodes.Count > 0)
         {
             type = "F";
         }
         else
         {
             type = "A";
         }
     } else if (response.IsTypeNumber)
     {
         type = "F";
     }
     else if (response.IsTypeFree)
     {
         type = "A";
     }
     else if (response.IsTypeDateTime)
     {
         type = "F";
     }
     return type;
 }
Example #4
0
 public void RemoveVariable(VariableVM variable)
 {
     foreach (DataSetVM dataSet in dataSets)
     {
         dataSet.RemoveVariable(variable.Id);
     }
 }
Example #5
0
        private DataSetVariableVM createDataSetVariable(string variableId)
        {
            VariableVM variable = StudyUnit.FindVariable(variableId);

            if (variable == null)
            {
                return(null);
            }
            return(createDataSetVariable(variable));
        }
Example #6
0
 private static StatisticsInfo CreateNumberStatisticsInfo(RawData data, VariableVM variable)
 {
     return(CreateSimpleStatisticsInfo(data, variable,
                                       (values, info) => {
         info.StatisticsType = StatisticsTypes.Number;
         NumberHelper numericHelper = NumberHelper.Create(variable);
         SummaryInfo summaryInfo = CreateSummaryInfo(values, numericHelper);
         info.SummaryInfo = summaryInfo;
     }));
 }
Example #7
0
 private static StatisticsInfo CreateSingleAnswerStatisticsInfo(RawData data, VariableVM variable)
 {
     return(CreateSimpleStatisticsInfo(data, variable,
                                       (values, info) =>
     {
         info.StatisticsType = StatisticsTypes.ChoicesSingleAnswer;
         SingleAnswerHelper helper = SingleAnswerHelper.Create(variable.Response.Codes);
         List <CategoryInfo> categoryInfos = CreateSingleAnswerOrDateTimeCategoryInfos(values, helper);
         info.CategoryInfos = categoryInfos;
     }));
 }
Example #8
0
        public static NumberHelper Create(VariableVM variable)
        {
            NumberHelper result = new NumberHelper();

            result.Scale = variable.Response.Scale;
            result.Min   = variable.Response.Min;
            result.Max   = variable.Response.Max;
            foreach (MissingValueVM missingValue in variable.Response.MissingValues)
            {
                result.AddMissingValue(missingValue.Content);
            }
            return(result);
        }
Example #9
0
        private void WriteVariableInfo(Body body, VariableVM variable)
        {
            StringBuilder buf = new StringBuilder();

            buf.Append(variable.Title);
            buf.Append(" ");
            buf.Append(variable.Label);
            buf.Append(" (");
            buf.Append(variable.Response.TypeName);
            buf.Append(" )");
            Paragraph p = CreateParagraph(buf.ToString());

            body.Append(p);
        }
Example #10
0
        private DataSetVariableVM createDataSetVariable(VariableVM variable)
        {
            ConceptVM concept = StudyUnit.FindConcept(variable.ConceptId);
            //if (concept == null)
            //{
            //    return null;
            //}
            DataSetVariableVM v = new DataSetVariableVM();

            v.Id           = variable.Variable.Id;
            v.Title        = variable.Title;
            v.Label        = variable.Label;
            v.ConceptTitle = concept == null ? null : concept.Title;
            return(v);
        }
Example #11
0
        private static int CalcEmptyRowCount(RawData data, List <VariableVM> variables)
        {
            List <string> variableTitles = VariableVM.GetTitles(variables);
            List <int>    indexes        = data.GetVariableIndexes(variableTitles);
            int           emptyRowCount  = 0;

            foreach (RawRecord record in data.Records)
            {
                if (IsEmptyRecord(record, indexes))
                {
                    emptyRowCount++;
                }
            }
            return(emptyRowCount);
        }
Example #12
0
        private static StatisticsInfo CreateSimpleStatisticsInfo(RawData data, VariableVM variable, Action <List <object>, StatisticsInfo> initializer)
        {
            RawVariable rawVariable = data.GetVariable(variable.Title);

            if (rawVariable == null)
            {
                return(null);
            }
            List <object>  values         = data.GetColumnValues(rawVariable.Index);
            StatisticsInfo statisticsInfo = new StatisticsInfo();

            statisticsInfo.Scale      = variable.Response.Scale;
            statisticsInfo.VariableId = variable.Id;
            initializer(values, statisticsInfo);
            return(statisticsInfo);
        }
Example #13
0
        private void CommandRemoveVariable_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            VariableVM variable = (VariableVM)e.Parameter;

            if (viewerTabControl.SelectedIndex == 1 && variableViewer.Variable == variable)
            {
                variableViewer.Variable        = null;
                viewerTabControl.SelectedIndex = 0;
            }

            if (methodEditor.Method == variable.GetterMethod || methodEditor.Method == variable.SetterMethod)
            {
                methodEditor.Method = null;
            }

            Class.Class.Variables.Remove(variable.Variable);
        }
Example #14
0
        public static StatisticsInfo CreateDummyChoicesSingleAnswerStatisticsInfo(CodebookVariable codebookVariable)
        {
            VariableVM variable = codebookVariable.FirstVariable;
            ObservableCollection <CodeVM> codes         = variable.Response.Codes;
            List <CategoryInfo>           categoryInfos = new List <CategoryInfo>();

            foreach (CodeVM code in codes)
            {
                CategoryInfo categoryInfo = new CategoryInfo();
                categoryInfo.CategoryType  = CategoryHelper.ToCategoryType(code.IsMissingValue);
                categoryInfo.CodeValue     = code.Value;
                categoryInfo.CategoryTitle = code.Label;
                categoryInfos.Add(categoryInfo);
            }
            StatisticsInfo statisticsInfo = new StatisticsInfo();

            statisticsInfo.VariableId     = variable.Id;
            statisticsInfo.StatisticsType = StatisticsTypes.ChoicesSingleAnswer;
            statisticsInfo.CategoryInfos  = categoryInfos;
            return(statisticsInfo);
        }
Example #15
0
        public static List <CategoryInfo> CreateMultipleAnswerCategoryInfos(RawData data, QuestionVM question, List <VariableVM> variables)
        {
            List <CategoryInfo>           categoryInfos = new List <CategoryInfo>();
            ObservableCollection <CodeVM> codes         = question.Response.Codes;
            string multipleAnswerSelectedValue          = question.MultipleAnswerSelectedValue;

            for (int i = 0; i < variables.Count; i++)
            {
                if (i >= codes.Count)
                {
                    break;
                }
                VariableVM    variable    = variables[i];
                CodeVM        code        = codes[i];
                RawVariable   rawVariable = data.GetVariable(variable.Title);
                List <object> values      = rawVariable != null?data.GetColumnValues(rawVariable.Index) : new List <object>();

                CategoryInfo categoryInfo = CreateMultipleAnswerCategoryInfo(multipleAnswerSelectedValue, values, variable.Title, code);
                categoryInfos.Add(categoryInfo);
            }
            return(categoryInfos);
        }
Example #16
0
        public StatisticsTypes GetStatisticsType(VariableVM variable)
        {
            StatisticsTypes statisticsType = StatisticsTypes.Unknown;

            if (variable.IsResponseTypeDateTime)
            {
                statisticsType = StatisticsTypes.DateTime;
            }
            else if (variable.IsResponseTypeFree)
            {
                statisticsType = StatisticsTypes.Free;
            }
            else if (variable.IsResponseTypeNumber)
            {
                statisticsType = StatisticsTypes.Number;
            }
            else if (variable.IsResponseTypeChoices)
            {
                QuestionVM question = FindQuestion(variable.QuestionId);
                if (question != null && question.VariableGenerationInfo != null)
                {
                    VariableGenerationInfo generationInfo = question.VariableGenerationInfo;
                    if (generationInfo.VariableGenerationType == VariableGenerationType.MultipleVariable)
                    {
                        statisticsType = StatisticsTypes.ChoicesMultipleAnswer;
                    }
                    else if (generationInfo.VariableGenerationType == VariableGenerationType.SingleVariable)
                    {
                        statisticsType = StatisticsTypes.ChoicesSingleAnswer;
                    }
                }
                else
                {
                    statisticsType = StatisticsTypes.ChoicesSingleAnswer;
                }
            }
            return(statisticsType);
        }
Example #17
0
 public void OnRemoveVariable(VariableVM variable)
 {
     dataSetForm.RemoveVariable(variable);
     bookForm.OnRemoveVariable(variable);
 }
Example #18
0
 public StatisticsInfo FindStatisticsInfoModel(VariableVM variable)
 {
     return(StatisticsInfo.FindByQuestionIdOrVariableId(studyUnit.StatisticsInfos, variable.QuestionId, variable.Id));
 }
Example #19
0
 public void OnRemoveVariable(VariableVM variable)
 {
     RemoveBookRelationOfMetaData(variable.Id);
 }