Ejemplo n.º 1
0
 public HttpResponseMessage EndCourse([FromBody] JObject Newcourse)
 {
     try
     {
         string signature = HttpUtil.GetAuthorization(Request);
         if (signature == null || !redis.IsSet(signature))
         {
             return(new Response(2001, "未登录账户").Convert());
         }
         Course course = new Course();
         QuickCopy.Copy <Course>(Newcourse, ref course);
         bool login = redis.IsSet(signature);
         if (!login)
         {
             return(new Response(2001, "未登录账户").Convert());
         }
         string targetId  = redis.Get <string>(signature);
         Course oldCourse = CourseDao.GetCourseInfoById(course.id);
         if (oldCourse == null || oldCourse.teacher_id != targetId)
         {
             return(new Response(2002, "无权限修改该课程的信息").Convert());
         }
         CourseDao.ChangeCourseInfo(course);
         LogUtil.Log(Request, "修改课程", course.id.ToString(), targetId, UserDao.GetUserById(targetId).role);
         return(new Response(1001, "修改课程信息成功").Convert());
     }
     catch (Exception e)
     {
         ErrorLogUtil.WriteLogToFile(e, Request);
         return(new Response(4001).Convert());;
     }
 }
Ejemplo n.º 2
0
 public HttpResponseMessage GetCourse()
 {
     Console.WriteLine("11");
     try
     {
         Console.WriteLine("22");
         string signature = HttpUtil.GetAuthorization(Request);
         if (signature == null || !redis.IsSet(signature))
         {
             return(new Response(2001, "未登录账户").Convert());
         }
         var jsonParams = Request.GetQueryNameValuePairs().ToDictionary(k => k.Key, v => v.Value);
         int id         = Convert.ToInt32(jsonParams["courseID"]);
         Console.WriteLine(id);
         bool isLogin = redis.IsSet(signature);
         if (!isLogin)
         {
             return(new Response(2001, "未登录账户").Convert());
         }
         Course course = CourseDao.GetCourseInfoById(id);
         return(new Response(1001, "获取成功", course).Convert());
     }
     catch (Exception e)
     {
         ErrorLogUtil.WriteLogToFile(e, Request);
         return(Response.Error());
     }
 }
Ejemplo n.º 3
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());
            }
        }
Ejemplo n.º 4
0
        public HttpResponseMessage ExportPeerScore([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 (CourseDao.GetAssistantsByCourseId(course.id).Where(a => a.student_id == id).Count() == 1 || id == course.teacher_id)
                {
                    List <Assignment> assignments = AssignmentDao.GetAssignmentsByExpId(expid);
                    List <PeerResult> prResults   = new List <PeerResult>();
                    foreach (var hw in assignments)
                    {
                        PeerAssessmentDao.CorrectScore(hw.student_id, expid);
                        PeerAssessmentDao.ComputeFinalScore(hw.student_id, expid);
                        try
                        {
                            prResults.Add(new PeerResult
                            {
                                id    = hw.student_id,
                                name  = UserDao.GetUserById(hw.student_id).name,
                                score = hw.score
                            });
                        }catch (Exception e) {}
                    }
                    return(new Response(1001, "导出成功", prResults).Convert());
                }
                else
                {
                    return(new Response(2002, "无权进行操作").Convert());
                }
            }
            catch (Exception e)
            {
                ErrorLogUtil.WriteLogToFile(e, Request);
                return(Response.Error());
            }
        }
Ejemplo n.º 5
0
 public HttpResponseMessage getStusWithoutVMByExpId([FromBody] JObject expInfo)
 {
     try
     {
         List <Dictionary <string, string> > retData = new List <Dictionary <string, string> >();
         Dictionary <string, string>         stuidInfo;
         string signature = HttpUtil.GetAuthorization(Request);
         if (signature == null || !redis.IsSet(signature))
         {
             return(new Response(2001, "未登录账户").Convert());
         }
         var  jsonParams = Request.GetQueryNameValuePairs().ToDictionary(k => k.Key, v => v.Value);
         bool isLogin    = redis.IsSet(signature);
         if (!isLogin)
         {
             return(new Response(2001, "未登录账户").Convert());
         }
         string     userid = redis.Get <string>(signature);
         int        expid  = Convert.ToInt32(jsonParams["expid"]);
         Experiment exp    = ExperimentDao.GetExperimentById(expid);
         if (exp.course_id == null)
         {
             return(new Response(1001, "该实验没有所属课程").Convert());
         }
         int  courseId = (int)ExperimentDao.GetExperimentById(expid).course_id;
         User user     = UserDao.GetUserById(userid);
         if ((user.role == 2 && CourseDao.GetCourseInfoById(courseId).teacher_id == user.id) || (user.role == 1 && CourseDao.GetAssistantsByCourseId(courseId).Where(a => a.student_id == user.id).Count() != 0))
         {
             List <User>     stulist = CourseDao.GetStudentsById(courseId);
             List <VMConfig> vmlist  = VMDao.GetVMsByVmName(exp.vm_name);
             foreach (User stu in stulist)
             {
                 if (vmlist.Find(vm => vm.student_id.Equals(stu.id)) == null)
                 {
                     stuidInfo = new Dictionary <string, string>
                     {
                         { "id", stu.id },
                     };
                     retData.Add(stuidInfo);
                 }
             }
             return(new Response(1001, "Success", retData).Convert());
         }
         else
         {
             return(new Response(2001, "没有权限获取信息").Convert());
         }
     }
     catch (Exception e)
     {
         ErrorLogUtil.WriteLogToFile(e, Request);
         return(Response.Error());
     }
 }
Ejemplo n.º 6
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());
            }
        }
Ejemplo n.º 7
0
        public HttpResponseMessage GetAssignments()
        {
            try
            {
                var jsonParams = Request.GetQueryNameValuePairs().ToDictionary(k => k.Key, v => v.Value);
                int expid      = Convert.ToInt32(jsonParams["experiment_id"]);

                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);

                User       user   = UserDao.GetUserById(id);
                Experiment exp    = ExperimentDao.GetExperimentById(expid);
                Course     course = CourseDao.GetCourseInfoById((int)exp.course_id);

                if (user.role < 2 && CourseDao.GetAssistantsByCourseId(course.id).Where(a => a.student_id == id).Count() == 0)
                {
                    return(new Response(2002, "无权访问").Convert());
                }
                if (user.role == 2 && id != course.teacher_id)
                {
                    return(new Response(2002, "无权访问").Convert());
                }
                if (user.role == 3 && user.department_id != course.department_id)
                {
                    return(new Response(2002, "无权访问").Convert());
                }

                List <Assignment> assignments = AssignmentDao.GetAssignmentsByExpId(expid);
                return(new Response(1001, "成功", assignments).Convert());
            }
            catch (Exception e)
            {
                ErrorLogUtil.WriteLogToFile(e, Request);
                return(Response.Error());
            }
        }
Ejemplo n.º 8
0
        public HttpResponseMessage MarkAssignment([FromBody] JObject hw)
        {
            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(hw);
                // string id = jsonParams.id;
                int        hwid       = Convert.ToInt32(jsonParams.hwid);
                float      grade      = Convert.ToSingle(jsonParams.grade);
                User       user       = UserDao.GetUserById(id);
                Assignment assignment = AssignmentDao.GetAssignmentById(hwid);
                Experiment exp        = ExperimentDao.GetExperimentById((int)assignment.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)
                {
                    AssignmentDao.ModifyScore(hwid, grade);

                    return(new Response(1001, "评分成功").Convert());
                }
                else
                {
                    return(new Response(2002, "无权打分").Convert());
                }
            }
            catch (Exception e)
            {
                ErrorLogUtil.WriteLogToFile(e, Request);
                return(Response.Error());
            }
        }
Ejemplo n.º 9
0
        public HttpResponseMessage GetstandardHW([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 = Request.GetQueryNameValuePairs().ToDictionary(k => k.Key, v => v.Value);
                //string id = jsonParams["id"];
                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 (CourseDao.GetAssistantsByCourseId(course.id).Where(a => a.student_id == id).Count() == 1 || id == course.teacher_id)
                {
                    List <Assignment> assignments = AssignmentDao.GetAssignmentsToMarkByExpId(expid);

                    if (assignments.Count() < 6)
                    {
                        assignments = AssignmentDao.GenAssignmentsToMark(expid);
                        if (assignments == null)
                        {
                            return(new Response(3001, "作业数量不足6份,无法抽取").Convert());
                        }
                    }

                    List <Dictionary <string, string> > retData = new List <Dictionary <string, string> >();
                    Dictionary <string, string>         temp;
                    var props = assignments.First().GetType().GetProperties();
                    int cnt   = 0;
                    foreach (Assignment hw in assignments)
                    {
                        temp = new Dictionary <string, string>();
                        foreach (var pi in props)
                        {
                            var    v = hw.GetType().GetProperty(pi.Name).GetValue(hw, null);
                            string value;
                            if (v != null)
                            {
                                value = v.ToString();
                            }
                            else
                            {
                                value = "";
                            }
                            temp.Add(pi.Name, value);
                        }
                        User student = UserDao.GetUserById(hw.student_id);
                        temp.Add("student_name", student.name.ToString());
                        if (hw.score != null)
                        {
                            cnt++;
                        }
                        retData.Add(temp);
                    }
                    if (cnt == 6)
                    {
                        if (exp.peer_assessment_start == true)
                        {
                            return(new Response(1001, "互评已开始", retData).Convert());
                        }
                        else
                        {
                            return(new Response(1001, "评分已完成,请开始互评", retData).Convert());
                        }
                    }
                    return(new Response(1001, "success", retData).Convert());
                }
                else
                {
                    return(new Response(2002, "无权抽取作业").Convert());
                }
            }
            catch (Exception e)
            {
                ErrorLogUtil.WriteLogToFile(e, Request);
                return(Response.Error());
            }
        }
Ejemplo n.º 10
0
        public HttpResponseMessage GetHomeworkStatus([FromBody] JObject expInfo)
        {
            try
            {
                var jsonParams   = Request.GetQueryNameValuePairs().ToDictionary(k => k.Key, v => v.Value);
                int experimentId = Convert.ToInt32(jsonParams["id"]);

                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);

                //string id = "16211084";
                User       user       = UserDao.GetUserById(id);
                Experiment experiment = ExperimentDao.GetExperimentById(experimentId);
                Course     course     = CourseDao.GetCourseInfoById((int)experiment.course_id);

                //if (user.role < 2 && CourseDao.GetAssistantsByCourseId(course.id).Where(a => a.student_id == id).ToList().Count() == 0)
                //{
                //    return new Response(2002, "无权限查看助教").Convert();
                //}
                //if (user.role == 3 && user.department_id != course.department_id)
                //{
                //    return new Response(2002, "无权限查看助教").Convert();
                //}

                List <Dictionary <string, string> > ret = new List <Dictionary <string, string> >();
                Dictionary <string, string>         retData;

                List <User>       students       = CourseDao.GetStudentsById(course.id);
                List <Assignment> assignments    = AssignmentDao.GetAssignmentsByExpId(experiment.id);
                string            fileId         = "";
                string            homeworkStatus = "";
                string            uploadTime     = "";

                foreach (User stu in students)
                {
                    retData = new Dictionary <string, string>();
                    Assignment assignment = assignments.Where(a => a.student_id == stu.id).SingleOrDefault();
                    if (assignment == null)
                    {
                        fileId         = "";
                        homeworkStatus = "未提交";
                        uploadTime     = "";
                    }
                    else
                    {
                        fileId         = assignment.file;
                        homeworkStatus = "已提交";
                        uploadTime     = assignment.submit_time;
                    }
                    retData.Add("stuId", stu.id);
                    retData.Add("stuName", stu.name);
                    retData.Add("fileID", fileId == null?  "" : fileId);
                    retData.Add("homeworkStatus", homeworkStatus);
                    retData.Add("uploadTime", uploadTime);
                    retData.Add("score", assignment == null ? "" : assignment.score.ToString());
                    ret.Add(retData);
                }
                return(new Response(1001, "成功", ret).Convert());
            }
            catch (Exception e)
            {
                ErrorLogUtil.WriteLogToFile(e, Request);
                return(Response.Error());
            }
        }
Ejemplo n.º 11
0
        public HttpResponseMessage GetStuListNoVM([FromBody] JObject account)
        {
            List <Dictionary <string, string> > retData = new List <Dictionary <string, string> >();
            Dictionary <string, string>         stuInfo;

            try
            {
                string signature = HttpUtil.GetAuthorization(Request);
                if (signature == null || !redis.IsSet(signature))
                {
                    return(new Response(2001, "未登录账户").Convert());
                }
                var  jsonParams = Request.GetQueryNameValuePairs().ToDictionary(k => k.Key, v => v.Value);
                int  courseId   = Convert.ToInt32(jsonParams["courseId"]);
                int  expid      = Convert.ToInt32(jsonParams["expId"]);
                bool isLogin    = redis.IsSet(signature);
                if (!isLogin)
                {
                    return(new Response(2001, "未登录账户").Convert());
                }
                string targetId  = redis.Get <string>(signature);
                Course course    = CourseDao.GetCourseInfoById(courseId);
                User   user      = UserDao.GetUserById(targetId);
                User   professor = UserDao.GetUserById(course.teacher_id);

                Dictionary <string, string> department = new Dictionary <string, string>();
                string depart = null;
                if (user.role == 4 || (user.role == 3 && user.department_id == professor.department_id) || user.id == professor.id ||
                    (CourseDao.GetAssistantsByCourseId((courseId)).Where(a => a.student_id == user.id).Count() == 1))
                {
                    //如果是管理员、负责这个学院的部门管理员、课程对应的老师、课程对应的助教才有资格访问
                    List <User>     stuList  = CourseDao.GetStudentsById(courseId);
                    string          temp     = null;
                    Experiment      exp      = ExperimentDao.GetExperimentById(expid);
                    List <VMConfig> virtuals = VMDao.GetVMsByVmName(exp.vm_name);

                    foreach (User stu in stuList)
                    {
                        bool flag = true;
                        if (department.ContainsKey(stu.department_id))
                        {
                            depart = department[stu.department_id];
                        }
                        else
                        {
                            temp = CourseDao.GetDepartmentById(stu.department_id).name;
                            department.Add(stu.department_id, temp);
                            depart = temp;
                        }
                        foreach (VMConfig vm in virtuals)
                        {
                            if (vm.student_id == stu.id)
                            {
                                flag = false;
                            }
                        }
                        if (flag == false)
                        {
                            continue;
                        }



                        stuInfo = new Dictionary <string, string>
                        {
                            { "id", stu.id.ToString() },
                            { "name", stu.name }
                        };
                        retData.Add(stuInfo);
                    }
                    return(new Response(1001, "获取成功", retData).Convert());
                }
                else
                {
                    return(new Response(2002, "没有权限访问该信息").Convert());
                }
            }
            catch (Exception e)
            {
                ErrorLogUtil.WriteLogToFile(e, Request);
                return(Response.Error());
            }
        }
Ejemplo n.º 12
0
        public HttpResponseMessage getAllPeerAssessmentInfo([FromBody] JObject peerInfo)
        {
            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 userid     = redis.Get <string>(signature);
                var    jsonParams = Request.GetQueryNameValuePairs().ToDictionary(k => k.Key, v => v.Value);
                List <Dictionary <string, string> > retData = new List <Dictionary <string, string> >();
                Dictionary <string, string>         temp;
                // string userid = jsonParams["id"];
                int expid = Convert.ToInt32(jsonParams["expid"]);

                Experiment exp    = ExperimentDao.GetExperimentById(expid);
                Course     course = CourseDao.GetCourseInfoById((int)exp.course_id);
                ///权限控制,该课程助教与老师可以访问
                if (CourseDao.GetAssistantsByCourseId(course.id).Where(a => a.student_id == userid).Count() == 1 || userid == course.teacher_id)
                {
                    List <Peer_assessment> peer_Assessments = PeerAssessmentDao.getPeerAssessmentByExpId(expid);

                    var props = peer_Assessments.First().GetType().GetProperties();
                    int cnt   = 0;
                    foreach (Peer_assessment pr in peer_Assessments)
                    {
                        temp = new Dictionary <string, string>();
                        foreach (var pi in props)
                        {
                            var    v = pr.GetType().GetProperty(pi.Name).GetValue(pr, null);
                            string value;
                            if (v != null)
                            {
                                value = v.ToString();
                            }
                            else
                            {
                                value = "";
                            }
                            temp.Add(pi.Name, value);
                        }
                        User student  = UserDao.GetUserById(pr.student_id);
                        User assessor = UserDao.GetUserById(pr.assessor_id);
                        temp.Add("student_name", student.name.ToString());
                        temp.Add("assessor_name", assessor.name.ToString());

                        retData.Add(temp);
                    }
                    return(new Response(1001, "Success", retData).Convert());
                }
                else
                {
                    return(new Response(2002, "无权限访问该实验相关信息").Convert());
                }
            }
            catch (Exception e)
            {
                ErrorLogUtil.WriteLogToFile(e, Request);
                return(Response.Error());
            }
        }
Ejemplo n.º 13
0
        public HttpResponseMessage GetExperimentDetail([FromBody] JObject account)
        {
            try
            {
                var jsonParams = Request.GetQueryNameValuePairs().ToDictionary(k => k.Key, v => v.Value);
                int id         = Convert.ToInt32(jsonParams["id"]); //experimentid

                string signature = HttpUtil.GetAuthorization(Request);
                if (signature == null || !redis.IsSet(signature))
                {
                    return(new Response(2001, "未登录账户").Convert());
                }
                //var jsonParams = HttpUtil.Deserialize(account);


                bool isLogin = redis.IsSet(signature);
                if (!isLogin)
                {
                    return(new Response(2001, "未登录账户").Convert());
                }

                string userId = redis.Get <string>(signature);

                //string userId = "16211084";
                User              user       = UserDao.GetUserById(userId);
                Experiment        experiment = ExperimentDao.GetExperimentById(id);
                Course            course     = CourseDao.GetCourseInfoById(experiment.id);
                List <Assignment> assignment = AssignmentDao.GetAssignmentsByStuId(userId);
                bool              flag       = false;
                foreach (var ass in assignment)
                {
                    if (ass.experiment_id == id)
                    {
                        flag = true;
                        break;
                    }
                }

                tmpRetExpDetail ret = new tmpRetExpDetail();
                ret.name   = experiment.name;
                ret.type   = experiment.type.GetValueOrDefault();
                ret.score  = Convert.ToInt32(experiment.vm_status);
                ret.score2 = Convert.ToInt32(experiment.vm_apply_id);
                ret.reason = experiment.vm_name;
                if (experiment.course_id != null)
                {
                    //找出其他任课老师
                    List <Assistant> AssistantTeas = CourseDao.GetAssistantsByCourseId((int)experiment.course_id).ToList();
                    List <string>    teachers      = UserDao.GetUserByRole(2).Where(a => AssistantTeas.Exists(t => t.student_id == a.id)).Select(a => a.name).ToList();

                    ret.course     = CourseDao.GetCourseInfoById((int)experiment.course_id).name;
                    ret.course_id  = (int)experiment.course_id;
                    ret.teacher    = UserDao.GetUserById(CourseDao.GetCourseInfoById((int)experiment.course_id).teacher_id).name;
                    ret.teacher_id = CourseDao.GetCourseInfoById((int)experiment.course_id).teacher_id;
                    if (teachers.Count != 0)
                    {
                        foreach (string t in teachers)
                        {
                            ret.teacher = ret.teacher + "," + t;
                        }
                    }
                }
                else
                {
                    ret.course  = "";
                    ret.teacher = "";
                }
                ret.deadline     = experiment.deadline;
                ret.peerDeadline = experiment.peer_assessment_deadline;
                ret.details      = experiment.detail;

                /**
                 * ret.sourcelist = new List<Dictionary<string, string>>();
                 * ret.sourcelist.Add(new Dictionary<string, string> {
                 *  { "source", experiment.resource },
                 *  { "name","" }//TODO:这啥属性?
                 * });
                 **/
                ret.resource           = experiment.resource;
                ret.appealDeadline     = experiment.appeal_deadline;
                ret.peerAssessmentRule = experiment.peer_assessment_rules;
                ret.peerStarted        = experiment.peer_assessment_start == true ? true:false;
                ret.startTime          = experiment.start_time;
                ret.endTime            = experiment.end_time;
                if (user.role == 1)
                {
                    ret.status = flag ? "1" : "0";
                }
                else
                {
                    ret.status = AssignmentDao.GetAssignmentsByExpId(experiment.id).Count().ToString() + "/" + CourseDao.GetMapByCourseId((int)experiment.course_id).Count().ToString();
                }

                return(new Response(1001, "获取成功", ret).Convert());
            }
            catch (Exception e)
            {
                ErrorLogUtil.WriteLogToFile(e, Request);
                return(Response.Error());
            }
        }