/// <summary> /// 根据ID获取问题信息 /// </summary> public string GetQuestionById() { var quesQuestionsBLL = new QuesQuestionsBLL(this.CurrentUserInfo); string content = string.Empty; string key = string.Empty; if (FormatParamValue(Request("QuestionID")) != null && FormatParamValue(Request("QuestionID")) != string.Empty) { key = FormatParamValue(Request("QuestionID")).ToString().Trim(); } var condition = new List <IWhereCondition>(); if (!key.Equals(string.Empty)) { condition.Add(new EqualsCondition() { FieldName = "QuestionID", Value = key }); } var data = quesQuestionsBLL.Query(condition.ToArray(), null).ToList().FirstOrDefault(); var jsonData = new JsonData(); jsonData.totalCount = (data == null) ? "0" : "1"; jsonData.data = data; content = string.Format("{{\"totalCount\":{1},\"topics\":{0}}}", data.ToJSON(), (data == null) ? "0" : "1"); return(content); }
public string GetTestPaper(string pRequest) { var rd = new APIResponse <GetTestPaperRD>(); var rdData = new GetTestPaperRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <GetTestPaperRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); try { //获取考题 QuesQuestionsBLL queBll = new QuesQuestionsBLL(loggingSessionInfo); DataTable dTbl = queBll.GetQuesQuestions(rp.Parameters.SurveyTestId); List <QuesQuestionItem> quesList = new List <QuesQuestionItem>(); if (dTbl != null) { quesList = DataTableToObject.ConvertToList <QuesQuestionItem>(dTbl); } //循环获取考题选项 QuesOptionBLL quesOpBll = new QuesOptionBLL(loggingSessionInfo); List <QuesOptionItem> quesOptionList = new List <QuesOptionItem>(); DataTable dTblOption = null; foreach (var qItem in quesList) { quesOptionList = new List <QuesOptionItem>(); dTblOption = quesOpBll.GetQuesOptions(qItem.QuestionID); if (dTblOption != null && dTblOption.Rows.Count > 0) { quesOptionList = DataTableToObject.ConvertToList <QuesOptionItem>(dTblOption); } qItem.QuesOptionList = quesOptionList; } rdData.QuesQuestionList = quesList; rd.ResultCode = 0; } catch (Exception ex) { rd.ResultCode = 103; rd.Message = ex.Message; } rd.Data = rdData; return(rd.ToJSON()); }
/// <summary> /// 保存试题信息 /// </summary> public string SaveQuestion() { var quesQuestionsBLL = new QuesQuestionsBLL(this.CurrentUserInfo); string content = string.Empty; string error = ""; var responseData = new ResponseData(); string key = string.Empty; string QuestionID = string.Empty; var question = Request("Question"); if (FormatParamValue(question) != null && FormatParamValue(question) != string.Empty) { key = FormatParamValue(question).ToString().Trim(); } if (FormatParamValue(Request("QuestionID")) != null && FormatParamValue(Request("QuestionID")) != string.Empty) { QuestionID = FormatParamValue(Request("QuestionID")).ToString().Trim(); } var questionEntity = key.DeserializeJSONTo <QuesQuestionsEntity>(); if (QuestionID.Trim().Length == 0) { questionEntity.QuestionID = Utils.NewGuid(); //questionnairesEntity.Status = 0; //questionnairesEntity.ApplyCount = 0; //questionnairesEntity.CheckInCount = 0; //questionnairesEntity.PostCount = 0; quesQuestionsBLL.Create(questionEntity); } else { questionEntity.QuestionID = QuestionID; quesQuestionsBLL.Update(questionEntity, false); } responseData.success = true; responseData.msg = error; content = responseData.ToJSON(); return(content); }
/// <summary> /// 问题查询 /// </summary> public string GetQuestionListData() { var quesQuestionsBLL = new QuesQuestionsBLL(this.CurrentUserInfo); string content = string.Empty; string QuestionnaireId = FormatParamValue(Request("QuestionnaireId")); int pageIndex = Utils.GetIntVal(FormatParamValue(Request("page"))) - 1; var queryEntity = new QuesQuestionsEntity(); queryEntity.QuestionnaireID = QuestionnaireId; var data = quesQuestionsBLL.GetWebQuesQuestions(queryEntity, pageIndex, PageSize); int dataTotalCount = data.Count; content = string.Format("{{\"totalCount\":{1},\"topics\":{0}}}", data.ToJSON(), dataTotalCount); return(content); }
private string ExportStock() { try { var para = HttpContext.Current.Request.Params; string EventId = FormatParamValue(para["eventId"]); string searchSql = FormatParamValue(para["SearchOptionValue"]).Trim(); DataTable dataExport = new DataTable(); WEventUserMappingBLL wEventUserMappingBLL = new WEventUserMappingBLL(this.CurrentUserInfo); QuesQuestionsBLL quesQuestionsBLL = new QuesQuestionsBLL(this.CurrentUserInfo); dataExport = wEventUserMappingBLL.SearchEventUserList(EventId, searchSql).Tables[0]; //var service = new LEventSignUpBLL(loggingSessionInfo); //GetResponseParams<LEventSignUpEntity> dataList = service.GetEventApplies(para["eventId"] ?? "", 0, 10000); //IList<LEventSignUpEntity> data2 = new List<LEventSignUpEntity>(); int dataTotalCount = 0; var data2 = dataExport.Rows; dataTotalCount = dataExport.Rows.Count; IList <List <string> > source = new List <List <string> >(); for (var i = 0; i < dataExport.Rows.Count; i++) { var tmpHt = new List <string>(); var dr = dataExport.Rows[i]; for (var c = 1; c < dataExport.Columns.Count; c++) { tmpHt.Add(dr[c] == null ? "" : dr[c].ToString()); } source.Add(tmpHt); } if (source == null || source.Count == 0) { return(string.Empty); } var fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + _random.Next(1, 100).ToString() + ".xls"; var full_path = ExportDir + fileName; var sw = new FileStream(full_path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); var Writer = new StreamWriter(sw, System.Text.Encoding.UTF8); System.Collections.Generic.List <string> headers = new List <string>(); string[] header_nex = new string[] { }; for (var i = 1; i < dataExport.Columns.Count; i++) { var col = dataExport.Columns[i]; string colName = wEventUserMappingBLL.GetQuestionsDesc(EventId, col.ColumnName); headers.Add(colName); } var data = source; ExportHtmlExcel <List <string> >(Writer, headers.ToArray(), data, obj => { return(obj); }, null); Writer.Close(); sw.Close(); return(fileName); } catch (Exception ex) { PageLog.Current.Write(ex); return(null); } }
public string GetSingleAnswer(string pQuestionId, string pAnswer) { string ret = "-1"; QuesQuestionsBLL quesBll = new QuesQuestionsBLL(_loggingSessionInfo); QuesQuestionsEntity entity = quesBll.GetByID(pQuestionId); if (entity != null) { QuesOptionBLL quesOpBll = new QuesOptionBLL(_loggingSessionInfo); DataTable dTblOption = quesOpBll.GetQuesOptions(pQuestionId); //1单选,2多选,3主观选择题,4填空题,5标准打分题 int questionType = (int)entity.QuestionType; DataRow[] drs = null; if (questionType == 1)//1单选 { if (dTblOption != null && dTblOption.Rows.Count > 0) { drs = dTblOption.Select("IsAnswer=1"); if (drs != null && drs.Length > 0) { if (drs[0]["OptionIndex"].ToString().ToLower().Equals(pAnswer.ToLower())) { ret = "1"; } else { ret = "0"; } } } } else if (questionType == 2) //2多选 { string[] answerArr = pAnswer.ToLower().Split(','); if (dTblOption != null && dTblOption.Rows.Count > 0) { drs = dTblOption.Select("IsAnswer=1"); int index = 0; foreach (DataRow row in drs) { for (int i = 0; i < answerArr.Length; i++) { if (row["OptionIndex"].ToString().ToLower().Equals(answerArr[i])) { index++; } } } if (index != answerArr.Length) { ret = "1"; } else { ret = "0"; } } } else { ret = "-1"; } ret += "|" + entity.QuestionValue; } else { ret += "|题不存在"; } return(ret); }