public IActionResult GetSeminarsByCourseId([FromRoute] long courseId) { try { var seminars = _seminarService.ListSeminarByCourseId(courseId); return(Json(seminars.Select(s => new { id = s.Id, name = s.Name, description = s.Description, groupingMethod = (s.IsFixed == true)?"fixed":"random", startTime = s.StartTime, endTime = s.EndTime //个人认为这里不存在查询成绩的问题 }))); } catch (CourseNotFoundException) { return(StatusCode(404, new { msg = "未找到课程" })); } catch (ArgumentException) { return(StatusCode(400, new { msg = "课程ID格式错误" })); } }
public IActionResult GetClassById([FromRoute] long classId) { try { var c = _classService.GetClassByClassId(classId); var se = _seminarService.ListSeminarByCourseId(c.CourseId).FirstOrDefault( s => (_classService.GetCallStatusById(s.Id, c.Id)?.Status ?? 0) == 1); return(Json(new { id = c.Id, name = c.Name, time = c.ClassTime, site = c.Site, courseId = c.CourseId, calling = se?.Id ?? -1, proportions = new { report = c.ReportPercentage, presentation = c.PresentationPercentage, c = c.ThreePointPercentage, b = c.FourPointPercentage, a = c.FivePointPercentage } })); } catch (ClassNotFoundException) { return(StatusCode(404, new { msg = "未找到班级" })); } catch (ArgumentException) { return(StatusCode(400, new { msg = "班级ID输入格式有误" })); } }
public IList <SeminarGroup> ListSeminarGradeByCourseId(long userId, long courseId) { List <SeminarGroup> seminarGroupList = new List <SeminarGroup>(); List <Seminar> seminarList = new List <Seminar>(); try { //调用SeminarService 中 IList<Seminar> ListSeminarByCourseId(long courseId)方法 _iSeminarService.ListSeminarByCourseId(courseId); //调用SeminarGroupService 中 SeminarGroup GetSeminarGroupById(long seminarId, long userId) for (int i = 0; i < seminarList.Count; i++) { seminarGroupList.Add(_iSeminarGroupService.GetSeminarGroupById(seminarList[0].Id, userId)); } } catch (CourseNotFoundException cre) { throw cre; } catch (Exception e) { throw e; } return(seminarGroupList); }
/// <summary> /// 按课程id获取学生该课程所有讨论课 /// 通过课程id获取该课程下学生所有讨论课详细信息(包括成绩) /// </summary> /// <param name="userId">学生id</param> /// <param name="courseId">课程id</param> /// <returns>list 该课程下所有讨论课列表</returns> /// <exception cref="T:System.ArgumentException">id格式错误</exception> /// <seealso cref="M:Xmu.Crms.Shared.Service.ISeminarService.ListSeminarByCourseId(System.Int64)"/> /// <seealso cref="M:Xmu.Crms.Shared.Service.IGradeService.ListSeminarGradeByUserId(System.Int64)"/> /// <seealso cref="M:Xmu.Crms.Shared.Service.ISeminarGroupService.ListSeminarGroupBySeminarId(System.Int64)"/> public IList <SeminarGroup> ListSeminarGradeByCourseId(long userId, long courseId) { if (userId <= 0) { throw new ArgumentException(nameof(userId)); } if (courseId <= 0) { throw new ArgumentException(nameof(courseId)); } /*var usr = _db.UserInfo.Find(userId) ?? throw new UserNotFoundException(); * var cor = _db.Course.Find(courseId) ?? throw new CourseNotFoundException(); * var sem = _db.Seminar.Find(cor) ?? throw new SeminarNotFoundException(); * var sgm = _db.SeminarGroupMember.Include(s => s.Student).ThenInclude(sem => sem.Seminar) * .Where(s => s.Student == usr && sem.Seminar == sem) * ?? throw new InvalidOperationException(); * * return sgm.SeminarGroup.ToList();*/ List <SeminarGroup> seminarGroupList = new List <SeminarGroup>(); List <Seminar> seminarList = new List <Seminar>(); //调用SeminarService 中 IList<Seminar> ListSeminarByCourseId(long courseId)方法 _iSeminarService.ListSeminarByCourseId(courseId); //调用SeminarGroupService 中 SeminarGroup GetSeminarGroupById(long seminarId, long userId) for (int i = 0; i < seminarList.Count; i++) { seminarGroupList.Add(_iSeminarGroupService.GetSeminarGroupById(seminarList[0].Id, userId)); } return(seminarGroupList); }
/// <summary> /// 按课程id获取学生该课程所有讨论课 /// 通过课程id获取该课程下学生所有讨论课详细信息(包括成绩) /// </summary> /// <param name="userId">学生id</param> /// <param name="courseId">课程id</param> /// <returns>list 该课程下所有讨论课列表</returns> /// <exception cref="T:System.ArgumentException">id格式错误</exception> /// <seealso cref="M:Xmu.Crms.Shared.Service.ISeminarService.ListSeminarByCourseId(System.Int64)"/> /// <seealso cref="M:Xmu.Crms.Shared.Service.IGradeService.ListSeminarGradeByUserId(System.Int64)"/> /// <seealso cref="M:Xmu.Crms.Shared.Service.ISeminarGroupService.ListSeminarGroupBySeminarId(System.Int64)"/> public IList <SeminarGroup> ListSeminarGradeByCourseId(long userId, long courseId) { //测试完成 List <SeminarGroup> seminarGroupList = new List <SeminarGroup>(); //调用SeminarService 中 IList<Seminar> ListSeminarByCourseId(long courseId)方法 IList <Seminar> seminarList = _iSeminarService.ListSeminarByCourseId(courseId); //调用SeminarGroupService 中 SeminarGroup GetSeminarGroupById(long seminarId, long userId) for (int i = 0; i < seminarList.Count; i++) { try { seminarGroupList.Add(_iSeminarGroupService.GetSeminarGroupById(seminarList[i].Id, userId)); } catch (FixGroupNotFoundException)//不明白为什么要用这个exception { } } return(seminarGroupList); }
public IActionResult getSeminar(long id) { var type = User.Claims.Single(c => c.Type == "type").Value; var seminars = seminarService.ListSeminarByCourseId(id); if (type == "teacher") { foreach (var s in seminars) { DateTime now = DateTime.Now; TimeSpan d1 = s.StartTime - now; TimeSpan d2 = s.EndTime - now; if (d1.Days < 0 && d2.Days >= 0) { return(Json(s)); } } } else { List <bool> isNow = new List <bool>(); foreach (var s in seminars) { DateTime now = DateTime.Now; TimeSpan d1 = s.StartTime - now; TimeSpan d2 = s.EndTime - now; if (d1.Days < 0 && d2.Days >= 0) { isNow.Add(true); } else { isNow.Add(false); } } return(Json(new { seminars = seminars, isNow = isNow })); } return(Json(seminars)); }
public IActionResult GetSeminarsByCourseId([FromRoute] long courseId, [FromQuery] bool embededGrade) { try { var seminars = _seminarService.ListSeminarByCourseId(courseId); if (!embededGrade) { return(Json(seminars.Select(s => new { id = s.Id, name = s.Name, description = s.Description, groupingMethod = (s.IsFixed == true) ? "fixed" : "random", startTime = s.StartTime.ToString("YYYY-MM-dd"), endTime = s.EndTime.ToString("YYYY-MM-dd") }))); } return(Json(seminars.Select(s => new { id = s.Id, name = s.Name, description = s.Description, groupingMethod = (s.IsFixed == true) ? "fixed" : "random", startTime = s.StartTime.ToString("YYYY-MM-dd"), endTime = s.EndTime.ToString("YYYY-MM-dd"), grade = _seminarGroupService.GetSeminarGroupById(s.Id, User.Id()).FinalGrade }))); } catch (CourseNotFoundException) { return(StatusCode(404, new { msg = "未找到课程" })); } catch (ArgumentException) { return(StatusCode(400, new { msg = "课程ID格式错误" })); } }
public IActionResult GetSeminarList(long courseId, [FromQuery] bool embedGrade = false) { // Authentication // 若教师设置embedGrade为true,返回400 if (User.Type() == Shared.Models.Type.Teacher && embedGrade == true) { return(BadRequest(new { msg = "教师错误的访问!" })); } try { // Fetch data from database IList <Seminar> seminarList = _iSeminarService.ListSeminarByCourseId(courseId); List <SeminarVO> seminars = new List <SeminarVO>(); foreach (Seminar i in seminarList) { if (embedGrade == false) { seminars.Add(i); } } // Success return(Json(seminars)); } // 未找到课程,返回404 catch (CourseNotFoundException) { return(NotFound(new { msg = "未找到该课程!" })); } // 错误的ID格式,返回400 catch (ArgumentException) { return(BadRequest(new { msg = "错误的ID格式!" })); } }
public IActionResult GetSeminarsByCourseId([FromRoute] long courseId) { IList <Seminar> il = _service2.ListSeminarByCourseId(courseId); return(Json(il)); }
public IActionResult getSeminar(long id) { var seminars = seminarService.ListSeminarByCourseId(id); return(Json(seminars)); }
public IActionResult Getcourse([FromRoute] int courseID, [FromQuery] string embedgrade) { //Console.WriteLine("llllllll"); //Console.WriteLine(courseID); IList <Seminar> t = _seminarService.ListSeminarByCourseId(courseID); for (int i = 1; i < t.Count(); i++) { for (int j = 0; j < t.Count() - i; j++) { if (DateTime.Compare(t[j].StartTime, t[j + 1].StartTime) < 0) { Seminar temp2 = new Seminar(); temp2 = t[j]; t[j] = t[j + 1]; t[j + 1] = temp2; } } } List <Dseminar> temp = new List <Dseminar>(); for (int i = 0; i < t.Count(); i++) { Dseminar a = new Dseminar(); a.ID = (int)t[i].Id; a.Starttime = t[i].StartTime.ToString("yyyy-MM-dd"); a.Endtime = t[i].EndTime.ToString("yyyy-MM-dd"); if (t[i].IsFixed == true) { a.Groupingmethod = "固定分组"; } else { a.Groupingmethod = "随机分组"; } a.Grade = 3; //没有此方法啊啊啊啊啊啊啊啊!!! temp.Add(a); } return(Json(new { message1 = temp, message2 = t.Count() })); //this.ViewData["count"] = 4; //int count = 4; //List<Dseminar> temp = new List<Dseminar>(); //Dseminar a = new Dseminar(); //a.ID = 4; //a.Starttime = "11月4日"; //a.Endtime = "11月12日"; //a.Grade = 5; //a.Groupingmethod = "固定分组"; //Dseminar b = new Dseminar(); //b.ID = 3; //b.Starttime = "11月28日"; //b.Endtime = "11月4日"; //b.Grade = 4; //b.Groupingmethod = "随机分组"; //Dseminar c = new Dseminar(); //c.ID = 2; //c.Starttime = "10月20日"; //c.Endtime = "10月28日"; //c.Grade = 4; //c.Groupingmethod = "固定分组"; //Dseminar d = new Dseminar(); //d.ID = 1; //d.Starttime = "10月10日"; //d.Endtime = "10月20日"; //d.Grade = 3; //d.Groupingmethod = "随机分组"; //temp.Add(a); //temp.Add(b); //temp.Add(c); //temp.Add(d); ////return Json(temp); //return Json(new { message1 = temp, message2 = count }); }