Example #1
0
        public HttpResponseMessage dealAppeal([FromBody] JObject paInfo)
        {
            try
            {
                string signature = HttpUtil.GetAuthorization(Request);
                if (signature == null || !redis.IsSet(signature))
                {
                    return(new Response(2001, "未登录账户").Convert());
                }
                bool isLogin = redis.IsSet(signature);
                if (!isLogin)
                {
                    return(new Response(2001, "未登录账户").Convert());
                }
                string id         = redis.Get <string>(signature);
                var    jsonParams = HttpUtil.Deserialize(paInfo);
                //string id = jsonParams.id;
                string student_id    = jsonParams.student_id;
                string assessor_id   = jsonParams.assessor_id;
                int    experiment_id = jsonParams.experiment_id;
                float  score         = Convert.ToSingle(jsonParams.score);

                User       user   = UserDao.GetUserById(id);
                Experiment exp    = ExperimentDao.GetExperimentById(experiment_id);
                Course     course = CourseDao.GetCourseInfoById((int)exp.course_id);
                ///权限控制,该课程助教与老师可以访问
                if (CourseDao.GetAssistantsByCourseId(course.id).Where(a => a.student_id == id).Count() == 1 || id == course.teacher_id)
                {
                    Peer_assessment peer_Assessment = new Peer_assessment();
                    QuickCopy.Copy(paInfo, ref peer_Assessment);
                    peer_Assessment.appeal_status = 2;
                    Peer_assessment OldPa = PeerAssessmentDao.getPeerAssessment(student_id, assessor_id, experiment_id);
                    if (OldPa == null)
                    {
                        return(new Response(3001, "参数无效").Convert());
                    }
                    if (PeerAssessmentDao.ChangePeerAssessmentInfo(peer_Assessment) == 1)
                    {
                        return(new Response(1001, "Success").Convert());
                    }
                    else
                    {
                        throw new Exception("数据库操作异常");
                    }
                }
                else
                {
                    return(new Response(2002, "无权访问").Convert());
                }
            }
            catch (Exception e)
            {
                ErrorLogUtil.WriteLogToFile(e, Request);
                return(Response.Error());
            }
        }
Example #2
0
        public HttpResponseMessage AddPeerAssessment([FromBody] JObject peerAssessment)
        {
            try
            {
                string signature = HttpUtil.GetAuthorization(Request);
                if (signature == null || !redis.IsSet(signature))
                {
                    return(new Response(2001, "未登录账户").Convert());
                }
                var  jsonParams = HttpUtil.Deserialize(peerAssessment);
                bool isLogin    = redis.IsSet(signature);
                if (!isLogin)
                {
                    return(new Response(2001, "未登录账户").Convert());
                }
                string          id              = redis.Get <string>(signature);
                string          stuid           = jsonParams.student_id;
                int             expid           = jsonParams.experiment_id;
                Peer_assessment peerAssessment2 = new Peer_assessment();
                peerAssessment2.assessor_id = id;
                QuickCopy.Copy(peerAssessment, ref peerAssessment2);
                Peer_assessment OldPa = PeerAssessmentDao.getPeerAssessment(stuid, id, expid);
                if (OldPa != null)
                {
                    if (PeerAssessmentDao.ChangePeerAssessmentInfo(peerAssessment2) == 1)
                    {
                        return(new Response(1001, "Success").Convert());
                    }
                    else
                    {
                        return(new Response(1001, "数据未变").Convert());
                    }
                }

                Peer_assessment peer_Assessment = new Peer_assessment();
                peer_Assessment.assessor_id = id;
                QuickCopy.Copy(peerAssessment, ref peer_Assessment);
                Experiment exp = ExperimentDao.GetExperimentById(peer_Assessment.experiment_id);
                //if (!HttpUtil.IsTimeLater(exp.peer_assessment_deadline))
                //return new Response(2002, "互评已结束").Convert();
                PeerAssessmentDao.AddPeerAssessment(peer_Assessment);
                LogUtil.Log(Request, "作业评分", peer_Assessment.student_id, peer_Assessment.assessor_id, 1, "", "", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                return(new Response(1001, "Success").Convert());
            }
            catch (Exception e)
            {
                ErrorLogUtil.WriteLogToFile(e, Request);
                return(Response.Error());
            }
        }
Example #3
0
 public HttpResponseMessage ChangePeerAssessmentInfo([FromBody] JObject paInfo)
 {
     try
     {
         string signature = HttpUtil.GetAuthorization(Request);
         if (signature == null || !redis.IsSet(signature))
         {
             return(new Response(2001, "未登录账户").Convert());
         }
         var  jsonParams = HttpUtil.Deserialize(paInfo);
         bool isLogin    = redis.IsSet(signature);
         if (!isLogin)
         {
             return(new Response(2001, "未登录账户").Convert());
         }
         string          stuid           = jsonParams.student_id;
         string          userid          = redis.Get <string>(signature);
         int             expid           = jsonParams.experiment_id;
         Peer_assessment peer_Assessment = new Peer_assessment();
         QuickCopy.Copy(paInfo, ref peer_Assessment);
         Peer_assessment OldPa = PeerAssessmentDao.getPeerAssessment(stuid, userid, expid);
         if (OldPa == null)
         {
             return(new Response(2002, "无权访问").Convert());
         }
         if (PeerAssessmentDao.ChangePeerAssessmentInfo(peer_Assessment) == 1)
         {
             return(new Response(1001, "Success").Convert());
         }
         else
         {
             throw new Exception("数据库操作异常");
         }
     }
     catch (Exception e)
     {
         ErrorLogUtil.WriteLogToFile(e, Request);
         return(Response.Error());
     }
 }