Example #1
0
        /// <summary>
        /// 获取问卷详情
        /// </summary>
        /// <param name="qid"></param>
        /// <returns></returns>
        public mQuestionaire.QuestionaireStatVM GetQuestionaireDetailStat(int qid)
        {
            mQuestionaire.QuestionaireStatVM statVM = new mQuestionaire.QuestionaireStatVM();

            try
            {
                using (EFContext context = new EFContext())
                {
                    var questionaire = context.Questionaires.Where(q => q.ID == qid).FirstOrDefault();
                    statVM.QuestionaireCount = 1;
                    var detail = Newtonsoft.Json.JsonConvert.DeserializeObject <mQuestionaire.QuestionaireDetail>(questionaire.QuestionaireDetail);
                    // 项目组织安排
                    mQuestionaire.QuestionaireTypes qtype = (mQuestionaire.QuestionaireTypes)Enum.ToObject(typeof(mQuestionaire.QuestionaireTypes), questionaire.QuestionaireType);
                    if (qtype == mQuestionaire.QuestionaireTypes.店长D2 || qtype == mQuestionaire.QuestionaireTypes.品牌经理兼督导D2 || qtype == mQuestionaire.QuestionaireTypes.陈列D2 || qtype == mQuestionaire.QuestionaireTypes.培训D2)
                    {
                        detail.Q01 = true; detail.Q02 = true; detail.Q03 = true;
                    }
                    statVM.Q01Num = detail.Q01 ? 1 : 0;
                    statVM.Q02Num = detail.Q02 ? 1 : 0;
                    statVM.Q03Num = detail.Q03 ? 1 : 0;
                    // 课程及讲师反馈
                    statVM.QuestionStats = InitQStat(new List <mQuestionaire.QuestionaireDetail> {
                        detail
                    }, qtype);                                                                                            // 智能插入子问题数量

                    // 根据问卷类型设置每个问题的名字
                    for (int i = 0; i < statVM.QuestionStats.Count; i++)
                    {
                        statVM.QuestionStats[i].QuestionName = GetQName(qtype, i);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }

            return(statVM);
        }
Example #2
0
        /// <summary>
        /// 获取每个问卷的统计信息
        /// </summary>
        /// <param name="qtype"></param>
        /// <returns></returns>
        public mQuestionaire.QuestionaireStatVM GetQuestionaireStat(mQuestionaire.QuestionaireTypes qtype)
        {
            mQuestionaire.QuestionaireStatVM statVM = new mQuestionaire.QuestionaireStatVM();

            try
            {
                using (EFContext context = new EFContext())
                {
                    var qList = context.Questionaires.Where(q => q.QuestionaireType == (int)qtype).ToList();
                    statVM.QuestionaireCount = qList.Count;
                    var detailList = qList.Select(q => Newtonsoft.Json.JsonConvert.DeserializeObject <mQuestionaire.QuestionaireDetail>(q.QuestionaireDetail)).ToList();
                    // 项目组织安排
                    if (qtype == mQuestionaire.QuestionaireTypes.店长D2 || qtype == mQuestionaire.QuestionaireTypes.品牌经理兼督导D2 || qtype == mQuestionaire.QuestionaireTypes.陈列D2 || qtype == mQuestionaire.QuestionaireTypes.培训D2)
                    {
                        detailList.ForEach(d => { d.Q01 = true; d.Q02 = true; d.Q03 = true; });
                    }
                    statVM.Q01Num = detailList.Count(d => d.Q01);
                    statVM.Q02Num = detailList.Count(d => d.Q02);
                    statVM.Q03Num = detailList.Count(d => d.Q03);
                    // 课程及讲师反馈
                    statVM.QuestionStats = InitQStat(detailList, qtype);       // 智能插入子问题数量

                    // 根据问卷类型设置每个问题的名字
                    for (int i = 0; i < statVM.QuestionStats.Count; i++)
                    {
                        statVM.QuestionStats[i].QuestionName = GetQName(qtype, i);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }

            return(statVM);
        }