Beispiel #1
0
        protected void btnSaveChoice_Click(object sender, EventArgs e)
        {
            DataAccess.AssessmentItemXChoice objXChoice = new DataAccess.AssessmentItemXChoice();
            objXChoice.AssessmentItemID = AssessmentItemID;
            objXChoice.IsDefault        = chk_ChoiceIsDefault.Checked;
            objXChoice.Order            = Convert.ToInt32(txtChoiceOrder.Text);
            objXChoice.ScoreValue       = Convert.ToInt32(txtScoreValue.Text);
            objXChoice.Value            = txtChoicevalue.Text;

            DataAccess.AssessmentItemChoice objChoice = null;
            if (gIsMultipleChoice)
            {
                objChoice = new AssessmentItemChoice()
                {
                    Text = txtChoicevalue.Text
                };
            }
            bool res = gAssessment.Save_Assessment_Item_X_Choice(objXChoice, objChoice);

            if (res == false)
            {
                Set_Error_Message("An error occured during assessment item X choice save process");
            }
            else
            {
                ListChoice.Add(objXChoice);
                Prepare_Choice_Section();
            }
        }
Beispiel #2
0
 protected void btnAddGridChoice_Click(object sender, EventArgs e)
 {
     foreach (var item in ListSubAI)
     {
         DataAccess.AssessmentItemXChoice objXChoice = new DataAccess.AssessmentItemXChoice()
         {
             AssessmentItemID = item.AssessmentItemID,
             IsDefault        = chk_ChoiceIsDefault.Checked,
             Order            = Convert.ToInt32(txtChoiceOrder.Text),
             ScoreValue       = Convert.ToInt32(txtScoreValue.Text),
             Value            = txtChoicevalue.Text
         };
         DataAccess.AssessmentItemChoice objChoice = new AssessmentItemChoice()
         {
             Text = txtChoicevalue.Text
         };
         objXChoice.AssessmentItemChoice = objChoice;
         ListChoice.Add(objXChoice);
     }
     divSaveAll.Visible = true;
     Prepare_Choice_Section();
 }
Beispiel #3
0
        private void Create_Choice_Grid()
        {
            StringBuilder sb = new StringBuilder();
            List <DataAccess.AssessmentItemXChoice> listAdded = new List <DataAccess.AssessmentItemXChoice>();

            foreach (DataAccess.AssessmentItemXChoice item in ListChoice)
            {
                DataAccess.AssessmentItemXChoice        added_obj = listAdded.Find(o => o.Value == item.Value && o.ScoreValue == item.ScoreValue);
                List <DataAccess.AssessmentItemXChoice> listFound = ListChoice.FindAll(o => o.Value == item.Value && o.ScoreValue == item.ScoreValue);

                if (added_obj != null && listFound != null && listFound.Count > 1)
                {
                    continue;
                }

                sb.Append("<tr>");
                sb.Append("<th scope='row'>");
                sb.Append(item.Order.ToString());
                sb.Append("</th>");
                sb.Append("<td>");
                sb.Append(CommonUtilities.EditGridText(item.Value));
                sb.Append("</td>");
                sb.Append("<td>");
                sb.Append(item.ScoreValue.ToString());
                sb.Append("</td>");
                sb.Append("<td>");
                sb.Append(item.IsDefault.ToString());
                sb.Append("</td>");
                sb.Append("<td>");
                sb.Append(@"<a href=javascript:DeleteItem('" + CommonUtilities.GlobalEncrypt(item.ID.ToString(), BSWSession.SessionKey) + "'); class='fa fa-remove' style='color:red;' ></a>");
                sb.Append("</td>");
                sb.Append("</tr>");
                listAdded.Add(item);
            }
            grdChoiceBody.InnerHtml = sb.ToString();
        }
Beispiel #4
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());
        }