Beispiel #1
0
        public HttpResponseMessage StartPeerAssessment([FromBody] JObject expId)
        {
            try
            {
                string signature = HttpUtil.GetAuthorization(Request);
                if (signature == null || !redis.IsSet(signature))
                {
                    return(new Response(2001, "未登录账户").Convert());
                }
                bool login = redis.IsSet(signature);
                if (!login)
                {
                    return(new Response(2001, "未登录账户").Convert());
                }
                string id = redis.Get <string>(signature);

                var jsonParams = HttpUtil.Deserialize(expId);
                //string id = "16211084";
                int        expid  = Convert.ToInt32(jsonParams.expid);
                User       user   = UserDao.GetUserById(id);
                Experiment exp    = ExperimentDao.GetExperimentById(expid);
                Course     course = CourseDao.GetCourseInfoById((int)exp.course_id);
                if (exp.peer_assessment_start == true)
                {
                    return(new Response(3001, "互评已开启,请勿重复操作").Convert());
                }
                ///权限控制,该课程助教与老师可以访问
                if (CourseDao.GetAssistantsByCourseId(course.id).Where(a => a.student_id == id).Count() == 1 || id == course.teacher_id)
                {
                    AssignmentDao.SetStandardAssignment(expid, 4);
                    AssignmentDao.AssignPeerAsssessment(expid);
                    exp.peer_assessment_start = true;
                    ExperimentDao.ChangeExperimentInfo(exp);
                    return(new Response(1001, "开启成功").Convert());
                }
                else
                {
                    return(new Response(2002, "无权开启互评").Convert());
                }
            }
            catch (Exception e)
            {
                ErrorLogUtil.WriteLogToFile(e, Request);
                return(Response.Error());
            }
        }