diff --git a/Tsi1.Api/Tsi1.Api/Controllers/CourseController.cs b/Tsi1.Api/Tsi1.Api/Controllers/CourseController.cs index e717886ad5d4c14657b01b6f2ab66413c3b02487..16a4791fabece5e07492b1ddb45b04fad24e2e5e 100644 --- a/Tsi1.Api/Tsi1.Api/Controllers/CourseController.cs +++ b/Tsi1.Api/Tsi1.Api/Controllers/CourseController.cs @@ -305,7 +305,7 @@ namespace Tsi1.Api.Controllers return Ok(result.Data); } - [Authorize(Roles = UserTypes.Professor)] + [Authorize(Roles = UserTypes.FacultyAdmin)] [HttpPost("CloseRecord/{courseId}")] public async Task<IActionResult> CloseRecord(int courseId) { @@ -317,7 +317,7 @@ namespace Tsi1.Api.Controllers return BadRequest(courseResult.Message); } - var studentCourseResult = await _studentCourseResultService.GetLastStudentCourseResults(courseId, userId); + var studentCourseResult = await _studentCourseResultService.GetLastStudentCourseResults(courseId, userId, false); if (studentCourseResult.HasError) { return BadRequest(studentCourseResult.Message); diff --git a/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IStudentCourseResultService.cs b/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IStudentCourseResultService.cs index c590fff1f8b74ed4571a015ce26bb2ce3587389d..1cd93eefe14018f614dbafe82eabfa7a2ce3c2d1 100644 --- a/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IStudentCourseResultService.cs +++ b/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IStudentCourseResultService.cs @@ -17,7 +17,7 @@ namespace Tsi1.BusinessLayer.Interfaces Task<ServiceResult<StudentCourseResultPreviewDto>> GetMyLastResult(int courseId, int userId); - Task<ServiceResult<List<StudentCourseResultPreviewDto>>> GetLastStudentCourseResults(int courseId, int userId); + Task<ServiceResult<List<StudentCourseResultPreviewDto>>> GetLastStudentCourseResults(int courseId, int userId, bool isProfessor = true); Task<ServiceResult<List<StudentCourseResultQuantityDto>>> GetAllLastStudentCourseResults(int tenantId); } } diff --git a/Tsi1.Api/Tsi1.BusinessLayer/Services/StudentCourseResultService.cs b/Tsi1.Api/Tsi1.BusinessLayer/Services/StudentCourseResultService.cs index 9eb5e0cb3a2157efefb6769396daf7b9b102a0cd..2b3b914f17d9cb32134142fbeed90dea22a6886a 100644 --- a/Tsi1.Api/Tsi1.BusinessLayer/Services/StudentCourseResultService.cs +++ b/Tsi1.Api/Tsi1.BusinessLayer/Services/StudentCourseResultService.cs @@ -99,17 +99,20 @@ namespace Tsi1.BusinessLayer.Services return result; } - public async Task<ServiceResult<List<StudentCourseResultPreviewDto>>> GetLastStudentCourseResults(int courseId, int userId) + public async Task<ServiceResult<List<StudentCourseResultPreviewDto>>> GetLastStudentCourseResults(int courseId, int userId, bool isProfessor = true) { var result = new ServiceResult<List<StudentCourseResultPreviewDto>>(); - var professorValidation = await this.ProfessorValidations(courseId, userId); - - if (professorValidation.HasError) + if (isProfessor) { - result.HasError = true; - result.AddMessage(professorValidation.Message); - return result; + var professorValidation = await this.ProfessorValidations(courseId, userId); + + if (professorValidation.HasError) + { + result.HasError = true; + result.AddMessage(professorValidation.Message); + return result; + } } var studentIds = await _context.StudentCourses