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); }
public void CompleteResponse(ResponseVM response) { if (!response.IsTypeChoices) { return; } CodeSchemeVM codeScheme = response.CodeScheme; if (!codeForm.CodeSchemes.Contains(codeScheme)) { //If newly added in the question window //Set the title(if the code is not added and the title of response is blank, "Untitled" or "Unnamed" title will be set by adding null codeScheme.Title = string.IsNullOrEmpty(response.Title) ? CodeVM.JoinLabels(codeScheme.Codes) : response.Title; //Add CodeScheme codeForm.CodeSchemes.Add(codeScheme); } List <CodeVM> orphanCodes = new List <CodeVM>(); foreach (CodeVM code in codeScheme.Codes) { if (!categoryForm.Contains(code.CategoryId)) { //remember the code isolated if the category scheme corresponding to the question does not exist orphanCodes.Add(code); } } if (orphanCodes.Count > 0) { //isolated code(Category is not included in the existent category set) //Create Category scheme and then add Category in it 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; //Create from isolated code categoryForm.CategorySchemes.Add(categoryScheme); } //Add Category here(since categories are not added automatically, while the code is added automatically) foreach (CodeVM code in orphanCodes) { //Add CategoryVM included in CodeVM to CategoryScheme categoryScheme.Categories.Add(code.Category); } } }
private ResponseEntityVM ValidateBusinessRule(PolicyModel entity, CodeVM highRiskTypeCode) { var result = new ResponseEntityVM() { StatusCode = System.Net.HttpStatusCode.OK }; if (entity.RiskTypeID == highRiskTypeCode.CodeID && entity.CoveragePercentage > RiskTypeEnum.High.GetHashCode()) { result.StatusCode = System.Net.HttpStatusCode.Forbidden; result.Message = $"The coverage percentage cannot be over {RiskTypeEnum.High.GetHashCode()}% for High risk type."; } return(result); }
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); }
private string ToChoiceString(CodeVM code) { string text = code.Value + ". " + code.Label; return(text); }
public static CategoryInfo CreateMultipleAnswerCategoryInfo(string multipleAnswerSelectedValue, ICollection <object> values, string variableName, CodeVM code) { CategoryInfo categoryInfo = new CategoryInfo(); categoryInfo.Frequency = CountValidCases(multipleAnswerSelectedValue, values); categoryInfo.CategoryType = CategoryHelper.ToCategoryType(code.IsMissingValue); categoryInfo.VariableTitle = variableName; categoryInfo.CodeValue = code.Value; categoryInfo.CategoryTitle = code.Label; return(categoryInfo); }
public void code_EndEdit(CodeVM code) { StudyUnit.CompleteResponse(SelectedQuestion.Response); }
public CodeVM FindCodeByValue(string codeValue) { return(CodeVM.FindByValue(response.Codes, codeValue)); }
private Paragraph CreateCodeParagraph(CodeVM code) { Paragraph paragraph1 = new Paragraph(); ParagraphProperties paragraphProperties1 = new ParagraphProperties(); Indentation indentation1 = new Indentation() { FirstLine = "210", FirstLineChars = 100 }; paragraphProperties1.Append(indentation1); Run run1 = new Run(); RunProperties runProperties1 = new RunProperties(); RunFonts runFonts1 = new RunFonts() { Hint = FontTypeHintValues.EastAsia }; runProperties1.Append(runFonts1); Text text1 = new Text(); text1.Text = code.Value; run1.Append(runProperties1); run1.Append(text1); Run run2 = new Run(); RunProperties runProperties2 = new RunProperties(); RunFonts runFonts2 = new RunFonts() { Hint = FontTypeHintValues.EastAsia }; runProperties2.Append(runFonts2); TabChar tabChar1 = new TabChar(); run2.Append(runProperties2); run2.Append(tabChar1); Run run3 = new Run(); RunProperties runProperties3 = new RunProperties(); RunFonts runFonts3 = new RunFonts() { Hint = FontTypeHintValues.EastAsia }; runProperties3.Append(runFonts3); Text text2 = new Text(); text2.Text = code.Label; run3.Append(runProperties3); run3.Append(text2); paragraph1.Append(paragraphProperties1); paragraph1.Append(run1); paragraph1.Append(run2); paragraph1.Append(run3); return(paragraph1); }