/// <summary> /// Raturns a collapsable panel group for a list of questions. /// </summary> /// <param name="questions"></param> /// <returns></returns> private HtmlGenericControl _collapsableQuestionsPanelGroup() { HtmlGenericControl control = _collapsablePanelGroup(); HtmlGenericControl heading; HtmlGenericControl radioGroup; HtmlGenericControl radioPanel = new HtmlGenericControl(); ItemDisplayStyle style = ItemDisplayStyle.DEFAULT; string strScore = ""; string id = ""; for (int i = 0; i < AssociatedQuestionnaire.Questions.Count; i++) { if (DisplayMode == DisplayMode.CORRECTION) { if (AssociatedQuestionnaire.Questions[i].SelectedAnswer == null) { style = ItemDisplayStyle.UNANSWERED; strScore = AssociatedQuestionnaire.Options.EmptyAnswerScore.ToString(); } else if (AssociatedQuestionnaire.Questions[i].SelectedAnswer.Correct) { style = ItemDisplayStyle.CORRECT; strScore = "+" + AssociatedQuestionnaire.Options.CorrectAnswerScore.ToString(); } else { style = ItemDisplayStyle.WRONG; strScore = AssociatedQuestionnaire.Options.WrongAnswerScore.ToString(); } } id = "collapse" + i.ToString(); heading = _collapsbalePanelHeading(AssociatedQuestionnaire.Questions[i].Description, id, Convert.ToBoolean((int)DisplayMode), style, strScore); //ricontrolla qui, forse dovrai aggiungere un populate() radioGroup = _collapsableRadioGroup(AssociatedQuestionnaire.Questions[i], id); if (i == 0) { radioPanel = _collapsablePanel(heading, radioGroup, style); control.Controls.Add(radioPanel); } else { HtmlGenericControl newRadioPanel = _collapsablePanel(heading, radioGroup, style); radioPanel.Controls.Add(newRadioPanel); radioPanel = newRadioPanel; } } return(control); }
/// <summary> /// Returns a collapsable radio panel from an heading and a radioGroup. /// </summary> /// <param name="heading"></param> /// <param name="radioGroup"></param> /// <returns></returns> private HtmlGenericControl _collapsablePanel(HtmlGenericControl heading, HtmlGenericControl body, ItemDisplayStyle style = ItemDisplayStyle.DEFAULT) { HtmlGenericControl control = new HtmlGenericControl("div"); control.Attributes.Add("class", "panel panel-default " + _questionCssClasses[style]); control.Controls.Add(heading); control.Controls.Add(body); return(control); }
/// <summary> /// Raturns a panel heading. /// </summary> /// <param name="title"></param> /// <param name="ID"></param> /// <returns></returns> private HtmlGenericControl _collapsbalePanelHeading(string title, string ID, bool collapsed, ItemDisplayStyle style = ItemDisplayStyle.DEFAULT, string optionalStyleText = "") { HtmlGenericControl control = new HtmlGenericControl("div"); HtmlGenericControl titleControl = new HtmlGenericControl("h4"); HtmlAnchor linkControl = new HtmlAnchor(); control.Attributes.Add("class", "panel-heading"); titleControl.Attributes.Add("class", "panel-title"); linkControl.Attributes.Add("data-toggle", "collapse"); linkControl.Attributes.Add("data-target", "#" + ID); if (collapsed) { linkControl.Attributes.Add("class", "collapsed"); } linkControl.HRef = "#" + ID; linkControl.InnerText = title; titleControl.Controls.Add(linkControl); if (style != ItemDisplayStyle.DEFAULT) { HtmlGenericControl span = new HtmlGenericControl("span"); span.InnerText = " " + optionalStyleText; span.Attributes.Add("class", _answerCssClasses[style]); titleControl.Controls.Add(span); } control.Controls.Add(titleControl); return(control); }