protected void cmbAssessmentItems_SelectedIndexChanged(object sender, EventArgs e) { int _aiId = -1; if (int.TryParse(cmbAssessmentItems.SelectedValue, out _aiId)) { ArrageUIEnableDisable(); if (_aiId == -1) { return; } DataAccess.AssessmentItem obj = gAssessment.GetAssessmentItemByItemIDFromCache(_aiId); Constants.enAssessmentItemType _val_type = (Constants.enAssessmentItemType)Convert.ToInt32(obj.TypeID); if (_val_type == Constants.enAssessmentItemType.TEXT) { divCombo.Visible = false; divText.Visible = true; } else if (_val_type == Constants.enAssessmentItemType.DATETIME) { divCombo.Visible = false; divText.Visible = true; txtControl.TextMode = TextBoxMode.DateTime; } else if (_val_type == Constants.enAssessmentItemType.INTEGER) { divCombo.Visible = false; divText.Visible = true; txtControl.TextMode = TextBoxMode.Number; } else if (_val_type == Constants.enAssessmentItemType.TRUE_FALSE) { divCombo.Visible = true; divText.Visible = false; cmbControl.Items.Add(new ListItem("false", "0")); cmbControl.Items.Add(new ListItem("true", "1")); } else { divCombo.Visible = true; divText.Visible = false; cmbControl.DataTextField = nameof(DataAccess.AssessmentItemXChoice.Value); cmbControl.DataValueField = nameof(DataAccess.AssessmentItemXChoice.ChoiceID); cmbControl.DataSource = gAssessment.GetAssessmentItemChoicesByItemIDFromCache(_aiId, false); cmbControl.DataBind(); } if (cmbControl.Items.FindByValue("-1") == null) { cmbControl.Items.Insert(0, new ListItem("Please select...", "-1")); } } else { ArrageUIEnableDisable(); } }
private void CheckIfTypeIsMultipleChoice() { if (string.IsNullOrEmpty(cmbType.SelectedValue)) { gIsGridChoice = false; gIsMultipleChoice = false; } Constants.enAssessmentItemType _val = (Constants.enAssessmentItemType)Convert.ToInt32(cmbType.SelectedValue); gIsMultipleChoice = (_val == Constants.enAssessmentItemType.MULTIPLE_CHOICE_CHK || _val == Constants.enAssessmentItemType.MULTIPLE_CHOICE_RADIO); gIsGridChoice = (_val == Constants.enAssessmentItemType.GRID_CHK || _val == Constants.enAssessmentItemType.GRID_RADIO); }
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()); }
public string SaveValueX(string pItemID, string pAsseID, string pScore, string pVal, string pType, string pRequired, string pCID, string pKeyRel, string pAsseRespID, string pKeyRelFB) { bool _temp_res = false; bool is_req = false; bool.TryParse(pRequired, out is_req); if (string.IsNullOrEmpty(pVal) && is_req) { throw new Exception("Can not be empty!"); } if (string.IsNullOrEmpty(pVal)) { return("false"); } int _cid = -1; int type_assessment_val; Constants.enAssessmentItemType _type = Constants.enAssessmentItemType.TEXT; if (Int32.TryParse(pType, out type_assessment_val)) { _type = (Constants.enAssessmentItemType)type_assessment_val; if (_type == Constants.enAssessmentItemType.DATETIME) { DateTime _dt; if (DateTime.TryParse(pVal, out _dt) == false) { CommonUtilities.Log("Can not convert value to date! Value : " + pVal + Environment.NewLine + "Assessment_WS.asmx"); throw new Exception("Can not convert value to date!"); } } else if (_type == Constants.enAssessmentItemType.INTEGER) { int _val; if (int.TryParse(pVal, out _val) == false) { CommonUtilities.Log("Can not convert value to number! Value : " + pVal + Environment.NewLine + "Assessment_WS.asmx"); throw new Exception("Can not convert value to number!"); } } else if (_type == Constants.enAssessmentItemType.MULTIPLE_CHOICE_CHK || _type == Constants.enAssessmentItemType.MULTIPLE_CHOICE_RADIO || _type == Constants.enAssessmentItemType.GRID_RADIO || _type == Constants.enAssessmentItemType.GRID_CHK) { if (int.TryParse(pCID, out _cid) == false) { CommonUtilities.Log("Can not convert value to number! Value : " + pVal + Environment.NewLine + "Assessment_WS.asmx"); throw new Exception("Can not convert value to number!"); } } } else { throw new Exception("An error occured!"); } //if(Constants.enAssessmentItemType.TEXT ) BSWSession cses = new BSWSession(HttpContext.Current.Session); if (cses == null && cses.UserID < 0) { CommonUtilities.Log("Session is empty! Assessment.asmx SaveValueX. "); throw new Exception("Please signin again!"); } try { string _valTemp = string.Empty; BusinessRules.OP_Assessment assessment_br = new BusinessRules.OP_Assessment(cses.SessionID, cses.UserID); DataAccess.AssessmentItemResponse objResp = new DataAccess.AssessmentItemResponse(); int _assessment_item_id = Convert.ToInt32(CommonUtilities.GlobalDecrypt(pItemID, cses.SessionKey)); objResp.AssessmentItemID = _assessment_item_id; objResp.ScoreValue = Convert.ToInt32(CommonUtilities.GlobalDecrypt(pScore, cses.SessionKey)); objResp.Value = pVal; if (_cid > 0) { objResp.ChoiceID = _cid; _valTemp = _cid.ToString(); } else { _valTemp = pVal; } int _resp_id = Convert.ToInt32(pAsseRespID); bool res = assessment_br.Save_Assessment_Item_Response(objResp, Convert.ToInt32(pAsseID), ref _resp_id, cses.UserID, _type); if (!res) { return(res.ToString()); } if (!string.IsNullOrEmpty(pKeyRelFB)) { BusinessRules.OP_Feedback feedback_br = new BusinessRules.OP_Feedback(cses.SessionID, cses.UserID); res = feedback_br.UpdateFeedbackRuleFormula(_assessment_item_id, Convert.ToInt32(pAsseID), _valTemp); if (!res) { return(res.ToString()); } } string result_json = string.Empty; if (!string.IsNullOrEmpty(pKeyRel)) { List <AIDDisplayResult> listRes = new List <AIDDisplayResult>(); string[] _arr = pKeyRel.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (string item in _arr) { int _aid = -1; if (int.TryParse(item, out _aid)) { assessment_br.UpdateAIDisplayFormula(_aid, _assessment_item_id, _valTemp); assessment_br.ExecuteFormula(_aid, _valTemp, ref _temp_res); AIDDisplayResult obj = new AIDDisplayResult(); obj.AID = _aid; obj.Result = _temp_res; obj.RespID = _resp_id; listRes.Add(obj); JavaScriptSerializer serializer = new JavaScriptSerializer(); result_json = serializer.Serialize(listRes); } //ExecuteFormula } } else { return(res.ToString() + "#" + _resp_id.ToString()); } return(result_json); } catch (Exception ex) { CommonUtilities.Log(ex); throw new Exception("An error occured during save process!"); } }