Ejemplo n.º 1
0
        public List <ReplyUserList> GetSubmitUserStatus(int surveyId, int tenantId)
        {
            var survey  = GetSurveyInfoById(surveyId);
            var submits = _dataAccess.GetList <ResParticipateSurvey>("Res_ParticipateSurvey.Path = 0 And Res_ParticipateSurvey.SurveyId=" + surveyId);
            var result  = new List <ReplyUserList>();
            IEnumerable <SysUser> users;

            if (survey.RelUserType == 0)
            {
                //全部用户
                users = new UserManager().GetAllUsers(tenantId);
            }
            else
            {
                //按部门,先找出关联部门下所有用户
                var userIds = _dataAccess.GetList <Res_SurveyToUser>("Res_SurveyToUser.SurveyId=" + surveyId).Select(p => p.UserId);
                users = _dataAccess.GetList <SysUser>(" Sys_Users.UserId IN (" + userIds.GetString() + ")");
            }


            foreach (var user in users)
            {
                var replyUser = new ReplyUserList();
                replyUser.UserId   = user.UserId;
                replyUser.Realname = user.Realname;
                replyUser.DeptName = user.DeptName;
                replyUser.PostName = user.PostName;
                replyUser.Photo    = user.Photo;
                if (submits.Exists(p => p.UserId == user.UserId))
                {
                    replyUser.SubmitStatus = RetechWing.LanguageResources.Survey.SurveyLanguage.Submitted;
                    replyUser.IsSubmited   = true;
                }
                else
                {
                    replyUser.IsSubmited   = false;
                    replyUser.SubmitStatus = RetechWing.LanguageResources.Common.NoSubmit;
                }
                result.Add(replyUser);
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取回答问卷的详情
        /// </summary>
        /// <param name="surveyId">课程ID or 培训ID</param>
        /// <param name="path">
        /// 路径
        /// <para>1:课程</para>
        /// <para>2:培训</para>
        /// </param>
        /// <param name="exampaperId">问卷ID</param>
        /// <returns></returns>
        public List <ReplyUserList> GetOtherExampaperSubmitUserStatus(int surveyId, int path, int exampaperId)
        {
            var submits = _dataAccess.GetList <ResParticipateSurvey>(string.Format("Res_ParticipateSurvey.SurveyId = {0} And Res_ParticipateSurvey.Path = {1} and Res_ParticipateSurvey.ExampaperId = {2}", surveyId, path, exampaperId));
            var result  = new List <ReplyUserList>();
            IEnumerable <SysUser> users;

            if (path == 1)
            {
                users = _dataAccess.GetListBySql <SysUser>(string.Format(@"
select Sys_Users.UserId,Sys_Users.Username,Sys_Users.Realname,Sys_Users.Photo,Sys_Posts.PostName,Sys_Department.DeptName 
from Sys_Users 
left join Sys_Posts on Sys_Posts.PostId = Sys_Users.PostId
left join Sys_Department on Sys_Department.DeptId = Sys_Users.DeptId
where Sys_Users.UserId in (
	select distinct UserId from Len_LearningRecord where CourseId = {0}
)
And Sys_Users.Status = 0
", surveyId));
            }
            else if (path == 2)
            {
                //modified by ltc at 2015-7-23 for changing sql for new tranClass
//                users = _dataAccess.GetListBySql<SysUser>(string.Format(@"
//select Sys_Users.UserId,Sys_Users.Username,Sys_Users.Realname,Sys_Users.Photo,Sys_Posts.PostName,Sys_Department.DeptName
//from Sys_Users
//left join Sys_Posts on Sys_Posts.PostId = Sys_Users.PostId
//left join Sys_Department on Sys_Department.DeptId = Sys_Users.DeptId
//where Sys_Users.UserId in (
//	select UserId from Tr_TrainUser where trainId = ( select trainId from Tr_TrainDetail where DetailId = {0} )
//	union
//	select UserId from Tr_TrainRegister where trainId = ( select trainId from Tr_TrainDetail where DetailId = {0} )
//)
//And Sys_Users.Status = 0
//", surveyId));
                users = _dataAccess.GetListBySql <SysUser>(string.Format(@"
select Sys_Users.UserId,Sys_Users.Username,Sys_Users.Realname,Sys_Users.Photo,Sys_Posts.PostName,Sys_Department.DeptName 
from Sys_Users 
left join Sys_Posts on Sys_Posts.PostId = Sys_Users.PostId
left join Sys_Department on Sys_Department.DeptId = Sys_Users.DeptId
where Sys_Users.UserId in (
	select distinct UserID from Res_SurveyReplyAnswer where SurveyID = {0}
)
And Sys_Users.Status = 0
", surveyId));
            }
            else
            {
                users = new List <SysUser>();
            }

            var answerlist = _dataAccess.GetList <SurveyReplyAnswer>(string.Format(" Res_SurveyReplyAnswer.SurveyId = {0} And Res_SurveyReplyAnswer.Path = {1} And Res_SurveyReplyAnswer.ExampaperId = {2}", surveyId, path, exampaperId));

            if (answerlist.Any(p => p.QuestionType == 0))
            {
                var questionanswerlist = _dataAccess.GetList <ResSurveyQuestionAnswer>("Res_SurveyQuestionAnswer.QuestionId in (" + answerlist.Where(p => p.QuestionType == 0).Select(p => p.QuestionId).GetString() + ")");
                foreach (var item in answerlist.Where(p => p.QuestionType == 0))
                {
                    if (string.IsNullOrWhiteSpace(item.ObjectiveAnswer))
                    {
                        continue;
                    }
                    var tmp = questionanswerlist.FirstOrDefault(p => p.AnswerId == Convert.ToInt32(item.ObjectiveAnswer));
                    if (tmp == null)
                    {
                        continue;
                    }
                    item.Score = tmp.Score;
                }
            }

            foreach (var user in users)
            {
                var replyUser = new ReplyUserList();
                replyUser.UserId   = user.UserId;
                replyUser.Realname = user.Realname;
                replyUser.DeptName = user.DeptName;
                replyUser.PostName = user.PostName;
                replyUser.Photo    = user.Photo;
                if (submits.Exists(p => p.UserId == user.UserId))
                {
                    replyUser.SubmitStatus = RetechWing.LanguageResources.Survey.SurveyLanguage.Submitted;
                    replyUser.IsSubmited   = true;
                }
                else
                {
                    replyUser.IsSubmited   = false;
                    replyUser.SubmitStatus = RetechWing.LanguageResources.Common.NoSubmit;
                }
                replyUser.Score = answerlist.Where(p => p.UserID == user.UserId && p.QuestionType == 0).Sum(p => p.Score);
                result.Add(replyUser);
            }
            return(result);
        }