Esempio n. 1
0
        public IActionResult UpdateGradeByGroupId([FromRoute] long groupId, [FromBody] StudentScoreGroup updated)
        {
            try
            {
                if (User.Type() != Type.Teacher)
                {
                    return(StatusCode(403, new { msg = "权限不足" }));
                }

                if (updated.Grade != null)
                {
                    _gradeService.UpdateGroupByGroupId(groupId, (int)updated.Grade);
                }

                return(NoContent());
            }
            catch (GroupNotFoundException)
            {
                return(StatusCode(404, new { msg = "没有找到该课程" }));
            }
            catch (ArgumentException)
            {
                return(StatusCode(400, new { msg = "组号格式错误" }));
            }
        }
Esempio n. 2
0
        public IActionResult SubmitStudentGradeByGroupId([FromBody] long groupId, [FromBody] long studentId,
                                                         [FromBody] StudentScoreGroup updated)
        {
            try
            {
                if (User.Type() != Type.Student)
                {
                    return(StatusCode(403, new { msg = "权限不足" }));
                }

                if (updated.Grade == null)
                {
                    return(NoContent());
                }

                _gradeService.InsertGroupGradeByUserId(updated.SeminarGroupTopic.Topic.Id, updated.Student.Id,
                                                       groupId, (int)updated.Grade);
                return(NoContent());
            }
            catch (GroupNotFoundException)
            {
                return(StatusCode(404, new { msg = "没有找到该课程" }));
            }
            catch (ArgumentException)
            {
                return(StatusCode(400, new { msg = "组号格式错误" }));
            }
        }
        //<summary>提交对其他小组的打分</summary>
        //<param name="topicId">话题Id</param>
        //<param name="userId">用户Id</param>
        //<param name="seminarId">讨论课Id</param>
        //<param name="groupId">小组Id</param>
        //<param name="grade">成绩</param>
        //<returns></returns>
        public void InsertGroupGradeByUserId(long topicId, long userId, long groupId, int grade)
        {
            //测试成功
            //数据库标准内Topic表中没有serial列,故在Xmu.Crms.Shared/Models/Topic.cs
            //和Xmu.Crms.Shared/Models/CrmsContext.cs中暂时删除serial实体

            if (topicId <= 0)
            {
                throw new ArgumentException(nameof(topicId));
            }
            if (userId <= 0)
            {
                throw new ArgumentException(nameof(userId));
            }
            if (groupId <= 0)
            {
                throw new ArgumentException(nameof(groupId));
            }

            var usr = _db.UserInfo.Find(userId) ?? throw new UserNotFoundException();
            var tpc = _iTopicService.GetSeminarGroupTopicById(topicId, groupId) ?? throw new TopicNotFoundException();

            StudentScoreGroup ssg = new StudentScoreGroup {
                Student = usr, SeminarGroupTopic = tpc, Grade = grade
            };

            _db.StudentScoreGroup.Add(ssg);
            _db.SaveChanges();
        }
 public IActionResult UpdateGradeByGroupId([FromRoute] long groupId, [FromBody] StudentScoreGroup updated)
 {
     try
     {
         //按ID设置小组打分
         //其中grade是reportgrade
         _gradeService.UpdateGroupByGroupId(groupId, (int)updated.Grade);
         return(NoContent());
     }
     catch (GroupNotFoundException)
     {
         return(StatusCode(404, new { msg = "该小组不存在" }));
     }
     catch (ArgumentException)
     {
         return(StatusCode(400, new { msg = "组号格式错误" }));
     }
 }
Esempio n. 5
0
 //先在seminarGroupTopic 和userinfo service查好,在这里传入实体对象seminarGroupTopic,userInfo
 public void InsertGroupGradeByUserId(SeminarGroupTopic seminarGroupTopic, UserInfo userInfo, int grade)
 {
     using (var scope = _db.Database.BeginTransaction())
     {
         try
         {
             StudentScoreGroup ssg = new StudentScoreGroup {
                 Student = userInfo, SeminarGroupTopic = seminarGroupTopic, Grade = grade
             };
             _db.StudentScoreGroup.Add(ssg);
             _db.SaveChanges();
         }
         catch
         {
             scope.Rollback();
             throw;
         }
     }
 }
Esempio n. 6
0
 public IActionResult SubmitStudentGradeByGroupId([FromBody] long groupId, [FromBody] long studentId,
                                                  [FromBody] StudentScoreGroup updated)
 {
     return(NoContent());
 }
Esempio n. 7
0
 public IActionResult UpdateGradeByGroupId([FromRoute] long groupId, [FromBody] StudentScoreGroup updated)
 {
     return(NoContent());
 }