예제 #1
0
        protected override void BeforePostback()
        {
            base.BeforePostback();
            lblAssessmentName.Text = gAssessment.GetAssessmentName(gAssessmentID);
            if (cmbAssessmentItems.DataSource == null)
            {
                cmbAssessmentItems.DataTextField  = nameof(ClsListAssessmentItem.Text);
                cmbAssessmentItems.DataValueField = nameof(ClsListAssessmentItem.ItemID);
                List <ClsListAssessmentItem> listAI = gAssessment.GetAssessmentItemListFromCache(gAssessmentID, true);
                if (listAI != null && listAI.Count > 0)
                {
                    listAI = listAI.FindAll(o => o.TypeID != Convert.ToInt32(Constants.enAssessmentItemType.PAGE_BREAK));
                }
                cmbAssessmentItems.DataSource = listAI;
                cmbAssessmentItems.DataBind();
                if (cmbAssessmentItems.Items.FindByValue("-1") == null)
                {
                    cmbAssessmentItems.Items.Insert(0, new ListItem("Please select...", "-1"));
                }

                cmbAssessmentItems.Enabled = true;
            }
            BindControlsToDataSources();
            if (gPageMode == Constants.enPageMode.UPDATE_DATA)
            {
                //fill the question information
                DataAccess.AssessmentItem objAssessment = gAssessment.GetAssessmentItemByItemIDFromCache(AssessmentItemID);
                FillControls(objAssessment);
                CheckIfTypeIsMultipleChoice();
                //fill choices
                ListChoice = gAssessment.GetAssessmentItemChoicesByItemIDFromCache(AssessmentItemID, true);
                ListSubAI  = gAssessment.GetSubAssessmentItemsByParentID(AssessmentItemID);
                Prepare_Choice_Section();
            }
        }
예제 #2
0
        private string CreateAssessmentItemXChoice(int pAssessmentItemID, int pTypeID, string pIDPostFix, string pRelAIDs, string pRelFBIDs, ClsListAssessmentItem pObjAI = null)
        {
            //GetItemResponsesByAssessmentID
            StringBuilder sb = new StringBuilder();
            List <DataAccess.AssessmentItemXChoice> listXChoices = gAssessment_br.GetAssessmentItemChoicesByItemIDFromCache(pAssessmentItemID, false);

            Constants.enAssessmentItemType _type = (Constants.enAssessmentItemType)pTypeID;
            bool is_multiple_choice_category     = (_type == Constants.enAssessmentItemType.MULTIPLE_CHOICE_CHK || _type == Constants.enAssessmentItemType.MULTIPLE_CHOICE_RADIO || _type == Constants.enAssessmentItemType.GRID_CHK || _type == Constants.enAssessmentItemType.GRID_RADIO);


            if (listXChoices == null || listXChoices.Count == 0)
            {
                return(string.Empty);
            }

            string _value = string.Empty;

            if (listResponses != null && listResponses.Count > 0 && !is_multiple_choice_category)
            {
                AssessmentItemResponse objResp = listResponses.Find(o => o.AssessmentItemID == pAssessmentItemID);
                if (objResp != null)
                {
                    _value = objResp.Value;
                    string scr = string.Empty;
                    if (gIsAssessmentClosed == false)
                    {
                        scr = "$(function () { $('#img" + pIDPostFix + "').attr('class', 'fa fa-check text-success'); });";
                        ScriptManager.RegisterClientScriptBlock(pnl, pnl.GetType(), "CreateAssessmentItemXChoice" + Guid.NewGuid().ToString(), scr, true);
                    }
                }
            }
            string _rel_id_tag    = string.Format("data-rel-con='{0}'", pRelAIDs);
            string _rel_fb_id_tag = string.Format("data-rel-con-fb='{0}'", pRelFBIDs);


            if (!is_multiple_choice_category)
            {
                DataAccess.AssessmentItemXChoice objXChoice = listXChoices[0];
                string _id_xchoice         = objXChoice.ID.ToString();
                string _score_val          = CommonUtilities.GlobalEncrypt(objXChoice.ScoreValue.ToString(), BSWSession.SessionKey);
                string _assessment_item_id = CommonUtilities.GlobalEncrypt(objXChoice.AssessmentItemID.ToString(), BSWSession.SessionKey);

                sb.Append("<div class='col-lg-12'>");

                if (gIsAssessmentClosed)
                {
                    //printer friendly
                    if (_type == Constants.enAssessmentItemType.TRUE_FALSE)
                    {
                        sb.AppendFormat("<i class='fa fa-arrow-circle-right {2}'></i> <span class='{2}' style='{1}'>{0}</span>", _value.Equals("1") ? "True" : "False", "font-weight: bold;", "text-primary");
                    }
                    else
                    {
                        sb.AppendFormat("<i class='fa fa-arrow-circle-right {2}'> </i> <span class='{2}' style='{1}'>{0}</span>", _value, "font-weight: bold;", "text-primary");
                    }
                }
                else
                {
                    sb.Append("<div class='form-group row'>");
                    sb.AppendFormat("<label class='form-control-label col-md-3' for='txt_choice_{1}'>{0} </label>", objXChoice.Value, _id_xchoice);

                    sb.Append("<div class='col-md-9'>");
                    if (_type == Constants.enAssessmentItemType.TEXT)
                    {
                        sb.AppendFormat("<textarea id='txt_choice_{0}' type='text' class='form-control' rows='4' data-attr1='{1}' onchange='SaveValue(this);' data-img='{2}' data-attr2='{4}' data-attr3='1' {5} {6} >{3} </textarea>", _id_xchoice, _score_val, pIDPostFix, _value, _assessment_item_id, _rel_id_tag, _rel_fb_id_tag);
                    }
                    else if (_type == Constants.enAssessmentItemType.INTEGER)
                    {
                        sb.AppendFormat("<input id='txt_choice_{0}' type='number' class='form-control' data-attr1='{1}' data-img='{2}' onchange='SaveValue(this);' data-attr2='{4}' value='{3}' data-attr3='2' {5} {6} > </input>", _id_xchoice, _score_val, pIDPostFix, _value, _assessment_item_id, _rel_id_tag, _rel_fb_id_tag);
                    }
                    else if (_type == Constants.enAssessmentItemType.DATETIME)
                    {
                        sb.AppendFormat("<div class='input-group date' id='datetimepicker{0}'>", _id_xchoice);
                        sb.AppendFormat("<input id='txt_choice_{0}' type='text' class='form-control' data-attr1='{1}' data-img='{2}' onchange='SaveValue(this);' data-attr2='{4}' value='{3}' data-attr3='3' {5} {6}></input>", _id_xchoice, _score_val, pIDPostFix, _value, _assessment_item_id, _rel_id_tag, _rel_fb_id_tag);
                        sb.Append("<span class='input-group-addon'><span class='fa fa-calendar'></span></span>");
                        sb.Append("</div>");
                    }
                    else if (_type == Constants.enAssessmentItemType.TRUE_FALSE)
                    {
                        sb.AppendFormat(@"<div class='form-check'>
                        <label class='form-check-label'>
                            <input class='form-check-input' type='radio' name='exampleRadios_{4}' id='chk_choice_{0}' data-attr1='{1}' data-img='{2}' value='1' onchange='SaveValue(this);' data-attr2='{4}' data-attr3='4' {3} {5} {6} >
                            True
                        </label>
                    </div>", _id_xchoice, _score_val, pIDPostFix, (_value.Equals("1") ? "checked=checked" : ""), _assessment_item_id, _rel_id_tag, _rel_fb_id_tag);
                        sb.AppendFormat(@"<div class='form-check'>
                        <label class='form-check-label'>
                            <input class='form-check-input' type='radio' name='exampleRadios_{4}' data-attr1='{1}' id='chk_choice_{0}_1' data-img='{2}' value='0' onchange='SaveValue(this);' data-attr2='{4}' {3} data-attr3='4' {5} {6} > 
                            False
                        </label>
                    </div>", _id_xchoice, _score_val, pIDPostFix, (_value.Equals("0") ? "checked=checked" : ""), _assessment_item_id, _rel_id_tag, _rel_fb_id_tag);
                    }
                    sb.Append("</div>");
                    sb.Append("</div>");
                }

                sb.Append("</div>");
            }
            else
            {
                List <AssessmentItemResponse> listResp = new List <AssessmentItemResponse>();
                if (listResponses != null)
                {
                    listResp = listResponses.FindAll(o => o.AssessmentItemID == pAssessmentItemID);
                }


                //grid, multiple choice
                if (_type == Constants.enAssessmentItemType.MULTIPLE_CHOICE_CHK || _type == Constants.enAssessmentItemType.MULTIPLE_CHOICE_RADIO)
                {
                    string _type_id    = "6";
                    string _input_type = "radio";
                    if (_type == Constants.enAssessmentItemType.MULTIPLE_CHOICE_CHK)
                    {
                        _input_type = "checkbox";
                        _type_id    = "5";
                    }

                    foreach (DataAccess.AssessmentItemXChoice item in listXChoices)
                    {
                        int    _choice_id            = item.ChoiceID.Value;
                        string _value_m              = string.Empty;
                        string _assessment_item_id_m = CommonUtilities.GlobalEncrypt(item.AssessmentItemID.ToString(), BSWSession.SessionKey);
                        bool   is_answered           = false;
                        if (listResp != null && listResp.Count > 0 && _choice_id > 0)
                        {
                            AssessmentItemResponse _objResp = listResp.Find(o => o.ChoiceID == _choice_id);
                            if (_objResp != null)
                            {
                                if (gIsAssessmentClosed == false)
                                {
                                    string scr = "$(function () { $('#img" + pIDPostFix + "').attr('class', 'fa fa-check text-success'); });";
                                    ScriptManager.RegisterClientScriptBlock(pnl, pnl.GetType(), "CreateAssessmentItemXChoice" + Guid.NewGuid().ToString(), scr, true);
                                }
                                _value_m    = _objResp.Value;
                                is_answered = true;
                            }
                        }
                        string _score_val = CommonUtilities.GlobalEncrypt(item.ScoreValue.ToString(), BSWSession.SessionKey);
                        if (gIsAssessmentClosed)
                        {
                            if (is_answered)
                            {
                                sb.AppendFormat("<i class='fa fa-arrow-circle-right {2}'></i> <span class='{2}' style='{1}'>{0}</span>", item.Value, "font-weight: bold;", "text-primary");
                            }

                            continue;
                        }
                        sb.AppendFormat(@"<div class='form-check'>
                        <label class='form-check-label'>
                            <input class='form-check-input' type='{6}' name='exampleRadios_{4}' id='chk_choice_{0}' data-attr1='{1}' data-img='{2}' value='1' onchange='SaveValue(this);' data-attr2='{4}' data-attr3='{8}' data-attr4='{7}' {3}  {9}>
                            {5} 
                        </label>
                    </div>", item.ID.ToString(), _score_val, pIDPostFix, (_value_m.Equals("1") ? "checked=checked" : ""), _assessment_item_id_m, item.Value, _input_type, _choice_id.ToString(), _type_id, _rel_id_tag, _rel_fb_id_tag);
                    }
                }
                else
                {
                    string _input_type = "radio";
                    string _type_val   = "8";
                    if (_type == Constants.enAssessmentItemType.GRID_CHK)
                    {
                        _type_val   = "7";
                        _input_type = "checkbox";
                    }


                    List <DataAccess.AssessmentItem> listParentOfItem = gAssessment_br.GetSubAssessmentItemsByParentID(pObjAI.ParentID.Value);
                    listParentOfItem = listParentOfItem.OrderBy(x => x.Order).ToList();
                    sb.Append("<table class='table'>");
                    foreach (DataAccess.AssessmentItem item in listParentOfItem)
                    {
                        listXChoices = gAssessment_br.GetAssessmentItemChoicesByItemIDFromCache(item.AssessmentItemID, false);
                        if (item.Equals(listParentOfItem.First()))
                        {
                            sb.Append("<thead>");
                            sb.Append("<tr>");
                            sb.AppendFormat("<th style='border-top:none;'></th>");
                            foreach (DataAccess.AssessmentItemXChoice item_sub in listXChoices)
                            {
                                sb.AppendFormat("<th class='Item-Centered'>{0}</th>", item_sub.Value);
                            }
                            sb.Append("</tr>");
                        }
                        pIDPostFix += "_" + item.Order.ToString();
                        string _display = string.Empty;
                        if (!string.IsNullOrEmpty(item.DisplayCondition))
                        {
                            bool formula_result = false;
                            gAssessment_br.ExecuteFormula(item.AssessmentItemID, "", ref formula_result);
                            if (!formula_result)
                            {
                                _display = " display: none !important; ";
                            }
                        }
                        sb.AppendFormat("<tr data-key='{0}'>", item.AssessmentItemID.ToString());
                        sb.AppendFormat("<th id='thAI_{0}' scope='row' style='font-weight: normal; {2}'  data-rel-con='{1}' data-rel-con-fb='{3}' >", pIDPostFix, HttpUtility.JavaScriptStringEncode(item.RelatedDCIds), _display, HttpUtility.JavaScriptStringEncode(item.RelatedFBIds));
                        sb.Append(item.Text.ToString());
                        sb.AppendFormat("<a id='divStatus_{0}' class='pull-right'> <i id='img{0}' data-required='{1}' class='' style='font-size:20px;' ></i> </a>", pIDPostFix, "0");
                        sb.Append("</th>");
                        foreach (DataAccess.AssessmentItemXChoice item_sub in listXChoices)
                        {
                            if (listResponses != null)
                            {
                                listResp = listResponses.FindAll(o => o.AssessmentItemID == item.AssessmentItemID);
                            }

                            int    _choice_id            = item_sub.ChoiceID.Value;
                            string _assessment_item_id_m = CommonUtilities.GlobalEncrypt(item.AssessmentItemID.ToString(), BSWSession.SessionKey);
                            string _score_val            = CommonUtilities.GlobalEncrypt(item_sub.ScoreValue.ToString(), BSWSession.SessionKey);
                            string _value_g = string.Empty;

                            if (listResp != null && listResp.Count > 0 && _choice_id > 0)
                            {
                                AssessmentItemResponse _objResp = listResp.Find(o => o.ChoiceID == _choice_id);
                                if (_objResp != null)
                                {
                                    if (gIsAssessmentClosed == false)
                                    {
                                        string scr = "$(function () { $('#img" + pIDPostFix + "').attr('class', 'fa fa-check text-success'); });";
                                        ScriptManager.RegisterClientScriptBlock(pnl, pnl.GetType(), "CreateAssessmentItemXChoice" + Guid.NewGuid().ToString(), scr, true);
                                    }
                                    _value_g = _objResp.Value;
                                }
                            }
                            sb.Append("<td class='Item-Centered'>");
                            if (gIsAssessmentClosed == false)
                            {
                                sb.AppendFormat(@"<input type='{6}' name='exampleRadios_{9}' id='chk_choice_{0}' data-attr1='{1}' data-img='{2}' value='1' onchange='SaveValue(this);' data-attr2='{4}' data-attr3='{8}' data-attr4='{7}' {3}>", item_sub.ID.ToString(), _score_val, pIDPostFix, (_value_g.Equals("1") ? "checked=checked" : ""), _assessment_item_id_m, item_sub.Value, _input_type, _choice_id.ToString(), _type_val, item.AssessmentItemID.ToString());
                            }
                            else
                            {
                                sb.AppendFormat("{0}", (_value_g.Equals("1") ? "<i class='fa fa-check text-primary' style='font-size:20px;' ></i>" : "-"));
                            }
                            sb.Append("</td>");
                        }
                        sb.Append("</tr>");
                    }
                    sb.Append("</table>");
                }
            }
            return(sb.ToString());
        }