public async Task <dynamic> OnAddExamAsync([FromForm] Exam exam, [FromForm] List <Question> questions, [FromForm] string token) { try { var t = await tokenService.GetTokenAsync(token); if (t == null) { throw new Exception("请先登录"); } if (t.Role != UserRole.Admin) { var courseRole = await examService.GetCourseRoleAsync(exam.CourseId, t.UserID); if (courseRole == UserRole.Student) { throw new Exception("权限不足"); } } await examService.AddExamAsync(exam, questions); await eventService.AddExamCreatedEventAsync(exam.ExamId, exam.Title, t.UserID, exam.CourseId); return(new { Res = true }); } catch (Exception e) { return(new { Res = false, Error = e.Message }); } }