From 6899df595a22296f5ac8c8751f8188d9cf3d7e84 Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Sun, 22 Mar 2026 04:47:22 +0300 Subject: [PATCH 1/3] wip --- .../Controllers/SolutionsController.cs | 9 +- .../Statistics/StatisticsCourseMatesModel.cs | 4 +- .../HwProj.Common.Net8/AuthExtensions.cs | 9 + .../HwProj.Models/HwProj.Models.csproj | 5 +- .../SolutionsService/GetSolutionModel.cs | 2 +- .../SolutionsService/SolutionDto.cs | 21 ++ ...entSolutions.cs => StudentSolutionsDto.cs} | 4 +- .../StudentSolutionsTableDto.cs | 22 ++ .../StatisticsCourseHomeworksModel.cs | 10 - .../StatisticsCourseMatesDTO.cs | 10 - .../StatisticsCourseTasksModel.cs | 11 - .../Models/Database/FileRecord.cs | 1 - ...icationProfile.cs => AutomapperProfile.cs} | 4 +- .../Controllers/CoursesController.cs | 3 +- .../Controllers/TasksController.cs | 2 +- .../HwProj.CoursesService.API/Dockerfile | 8 +- .../Domains/MappingExtensions.cs | 3 +- .../Filters/CourseDataFilterAttribute.cs | 2 +- .../HwProj.CoursesService.API.csproj | 24 +-- .../Models/Assignment.cs | 2 +- .../Models/Course.cs | 2 +- .../Models/CourseFilter.cs | 2 +- .../Models/CourseMate.cs | 2 +- .../Models/Criterion.cs | 2 +- .../HwProj.CoursesService.API/Models/Group.cs | 2 +- .../Models/GroupMate.cs | 2 +- .../Models/Homework.cs | 2 +- .../Models/HomeworkTask.cs | 2 +- .../Models/TaskModel.cs | 4 +- .../Models/TaskQuestion.cs | 2 +- .../Repositories/CourseFilterRepository.cs | 2 +- .../Repositories/CourseMatesRepository.cs | 4 +- .../Repositories/CoursesRepository.cs | 2 +- .../Groups/GroupMatesRepository.cs | 4 +- .../Repositories/Groups/GroupsRepository.cs | 2 +- .../Groups/IGroupMatesRepository.cs | 4 +- .../Repositories/Groups/IGroupsRepository.cs | 2 +- .../Groups/ITaskModelsRepository.cs | 2 +- .../Groups/TaskModelsRepository.cs | 2 +- .../Repositories/HomeworksRepository.cs | 2 +- .../Repositories/ICourseFilterRepository.cs | 2 +- .../Repositories/ICourseMatesRepository.cs | 4 +- .../Repositories/ICoursesRepository.cs | 2 +- .../Repositories/IHomeworksRepository.cs | 2 +- .../Repositories/ITaskQuestionsRepository.cs | 2 +- .../Repositories/ITasksRepository.cs | 2 +- .../Repositories/TaskQuestionsRepository.cs | 2 +- .../Repositories/TasksRepository.cs | 2 +- .../Services/CoursesService.cs | 3 +- .../HwProj.CoursesService.API/Startup.cs | 32 ++- .../appsettings.json | 2 +- .../CoursesServiceTests.cs | 2 +- .../HwProj.CoursesService.Tests.csproj | 2 +- .../Dockerfile | 1 - .../AutomapperProfile.cs | 2 + .../Controllers/SolutionsController.cs | 52 +++-- ...tionsStatsDomain.cs => SolutionsDomain.cs} | 51 ++++- .../HwProj.SolutionsService.API.csproj | 1 + .../Models}/Solution.cs | 7 +- .../Models/SolutionsContext.cs | 3 +- .../Models/StatisticsAggregateModel.cs | 14 -- .../Repositories/ISolutionsRepository.cs | 1 + .../Services/ISolutionsService.cs | 1 + .../Services/SolutionsService.cs | 3 +- .../ISolutionsServiceClient.cs | 14 +- .../SolutionsServiceClient.cs | 32 +-- ...DomainTests.cs => SolutionsDomainTests.cs} | 14 +- .../SolutionsServiceTests.cs | 4 +- hwproj.front/src/api/api.ts | 200 +++++++++--------- .../src/components/Courses/Course.tsx | 2 +- .../components/Courses/CourseExperimental.tsx | 6 +- .../Statistics/StudentProgressChart.tsx | 16 +- .../Statistics/StudentPunctualityChart.tsx | 10 +- .../Courses/Statistics/StudentStatsChart.tsx | 6 +- .../Courses/Statistics/StudentsRadarChart.tsx | 2 +- .../src/components/Courses/StudentStats.tsx | 8 +- .../Solutions/StudentSolutionsPage.tsx | 4 +- .../Solutions/TaskSolutionsPage.tsx | 4 +- .../src/components/Tasks/StudentStatsCell.tsx | 4 +- .../src/services/StudentStatsUtils.ts | 6 +- 80 files changed, 394 insertions(+), 337 deletions(-) create mode 100644 HwProj.Common/HwProj.Common.Net8/AuthExtensions.cs create mode 100644 HwProj.Common/HwProj.Models/SolutionsService/SolutionDto.cs rename HwProj.Common/HwProj.Models/SolutionsService/{StudentSolutions.cs => StudentSolutionsDto.cs} (54%) create mode 100644 HwProj.Common/HwProj.Models/SolutionsService/StudentSolutionsTableDto.cs delete mode 100644 HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseHomeworksModel.cs delete mode 100644 HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseMatesDTO.cs delete mode 100644 HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseTasksModel.cs rename HwProj.CoursesService/HwProj.CoursesService.API/{ApplicationProfile.cs => AutomapperProfile.cs} (90%) rename HwProj.SolutionsService/HwProj.SolutionsService.API/Domains/{SolutionsStatsDomain.cs => SolutionsDomain.cs} (63%) rename {HwProj.Common/HwProj.Models/SolutionsService => HwProj.SolutionsService/HwProj.SolutionsService.API/Models}/Solution.cs (84%) delete mode 100644 HwProj.SolutionsService/HwProj.SolutionsService.API/Models/StatisticsAggregateModel.cs rename HwProj.SolutionsService/HwProj.SolutionsService.IntegrationTests/{SolutionsStatsDomainTests.cs => SolutionsDomainTests.cs} (95%) diff --git a/HwProj.APIGateway/HwProj.APIGateway.API/Controllers/SolutionsController.cs b/HwProj.APIGateway/HwProj.APIGateway.API/Controllers/SolutionsController.cs index 1ab2fe869..67554eddd 100644 --- a/HwProj.APIGateway/HwProj.APIGateway.API/Controllers/SolutionsController.cs +++ b/HwProj.APIGateway/HwProj.APIGateway.API/Controllers/SolutionsController.cs @@ -7,7 +7,6 @@ using HwProj.APIGateway.API.Models.Solutions; using HwProj.AuthService.Client; using HwProj.CoursesService.Client; -using HwProj.Models.AuthService.DTO; using HwProj.Models.CoursesService; using HwProj.Models.CoursesService.DTO; using HwProj.Models.CoursesService.ViewModels; @@ -38,7 +37,7 @@ public SolutionsController(ISolutionsServiceClient solutionsClient, IAuthService } [HttpGet("{solutionId}")] - [ProducesResponseType(typeof(Solution), (int)HttpStatusCode.OK)] + [ProducesResponseType(typeof(SolutionDto), (int)HttpStatusCode.OK)] public async Task GetSolutionById(long solutionId) { var result = await _solutionsClient.GetSolutionById(solutionId); @@ -78,7 +77,7 @@ public async Task GetStudentSolution(long taskId, string studentI var mentorIds = studentSolutions.Values .SelectMany(t => t.Tasks) - .SelectMany(t => t.Solution) + .SelectMany(t => t.Solutions) .Select(t => t.LecturerId ?? "") .Where(x => x != "") .Distinct() @@ -88,7 +87,7 @@ public async Task GetStudentSolution(long taskId, string studentI var solutionsGroupsIds = studentSolutions.Values .SelectMany(t => t.Tasks) - .First(x => x.Id == taskId).Solution + .First(x => x.Id == taskId).Solutions .Select(s => s.GroupId) .Distinct() .ToList(); @@ -120,7 +119,7 @@ public async Task GetStudentSolution(long taskId, string studentI Title = task.Title, Tags = task.Tags, TaskId = task.Id.ToString(), - Solutions = t.Solution.Select(s => new GetSolutionModel(s, + Solutions = t.Solutions.Select(s => new GetSolutionModel(s, s.TaskId == taskId && s.GroupId is { } groupId ? solutionsGroups[groupId].StudentsIds .Select(x => accountsCache[x]) diff --git a/HwProj.APIGateway/HwProj.APIGateway.API/Models/Statistics/StatisticsCourseMatesModel.cs b/HwProj.APIGateway/HwProj.APIGateway.API/Models/Statistics/StatisticsCourseMatesModel.cs index 5bc6f4609..4696db082 100644 --- a/HwProj.APIGateway/HwProj.APIGateway.API/Models/Statistics/StatisticsCourseMatesModel.cs +++ b/HwProj.APIGateway/HwProj.APIGateway.API/Models/Statistics/StatisticsCourseMatesModel.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using HwProj.Models.AuthService.DTO; -using HwProj.Models.StatisticsService; +using HwProj.Models.SolutionsService; namespace HwProj.APIGateway.API.Models.Statistics; @@ -11,5 +11,5 @@ public class StatisticsCourseMatesModel public string Name { get; set; } public string Surname { get; set; } public AccountDataDto[] Reviewers { get; set; } = Array.Empty(); - public List Homeworks { get; set; } = new(); + public List Homeworks { get; set; } = new(); } diff --git a/HwProj.Common/HwProj.Common.Net8/AuthExtensions.cs b/HwProj.Common/HwProj.Common.Net8/AuthExtensions.cs new file mode 100644 index 000000000..cfc18b1dd --- /dev/null +++ b/HwProj.Common/HwProj.Common.Net8/AuthExtensions.cs @@ -0,0 +1,9 @@ +using Microsoft.AspNetCore.Http; + +namespace HwProj.Common.Net8; + +public static class AuthExtensions +{ + public static string? GetUserIdFromHeader(this HttpRequest request) => + request.Headers.TryGetValue("UserId", out var id) ? id.FirstOrDefault() : null; +} diff --git a/HwProj.Common/HwProj.Models/HwProj.Models.csproj b/HwProj.Common/HwProj.Models/HwProj.Models.csproj index f1514f75f..73bde3b40 100644 --- a/HwProj.Common/HwProj.Models/HwProj.Models.csproj +++ b/HwProj.Common/HwProj.Models/HwProj.Models.csproj @@ -10,10 +10,7 @@ - - - - + diff --git a/HwProj.Common/HwProj.Models/SolutionsService/GetSolutionModel.cs b/HwProj.Common/HwProj.Models/SolutionsService/GetSolutionModel.cs index 5e1b09a58..a06a96380 100644 --- a/HwProj.Common/HwProj.Models/SolutionsService/GetSolutionModel.cs +++ b/HwProj.Common/HwProj.Models/SolutionsService/GetSolutionModel.cs @@ -6,7 +6,7 @@ namespace HwProj.Models.SolutionsService { public class GetSolutionModel { - public GetSolutionModel(Solution model, AccountDataDto[]? groupMates, AccountDataDto? lecturer) + public GetSolutionModel(SolutionDto model, AccountDataDto[]? groupMates, AccountDataDto? lecturer) { Id = model.Id; GithubUrl = model.GithubUrl; diff --git a/HwProj.Common/HwProj.Models/SolutionsService/SolutionDto.cs b/HwProj.Common/HwProj.Models/SolutionsService/SolutionDto.cs new file mode 100644 index 000000000..6817cc970 --- /dev/null +++ b/HwProj.Common/HwProj.Models/SolutionsService/SolutionDto.cs @@ -0,0 +1,21 @@ +using System; + +namespace HwProj.Models.SolutionsService +{ + public class SolutionDto + { + public long Id { get; set; } + public string GithubUrl { get; set; } + public string Comment { get; set; } + public SolutionState State { get; set; } + public int Rating { get; set; } + public string StudentId { get; set; } + public string? LecturerId { get; set; } + public long? GroupId { get; set; } + public long TaskId { get; set; } + public DateTime PublicationDate { get; set; } + public bool IsModified { get; set; } + public DateTime? RatingDate { get; set; } + public string LecturerComment { get; set; } + } +} diff --git a/HwProj.Common/HwProj.Models/SolutionsService/StudentSolutions.cs b/HwProj.Common/HwProj.Models/SolutionsService/StudentSolutionsDto.cs similarity index 54% rename from HwProj.Common/HwProj.Models/SolutionsService/StudentSolutions.cs rename to HwProj.Common/HwProj.Models/SolutionsService/StudentSolutionsDto.cs index 29b466125..5a5f979c5 100644 --- a/HwProj.Common/HwProj.Models/SolutionsService/StudentSolutions.cs +++ b/HwProj.Common/HwProj.Models/SolutionsService/StudentSolutionsDto.cs @@ -1,8 +1,8 @@ namespace HwProj.Models.SolutionsService { - public class StudentSolutions + public class StudentSolutionsDto { public string StudentId { get; set; } - public Solution[] Solutions { get; set; } + public SolutionDto[] Solutions { get; set; } } } diff --git a/HwProj.Common/HwProj.Models/SolutionsService/StudentSolutionsTableDto.cs b/HwProj.Common/HwProj.Models/SolutionsService/StudentSolutionsTableDto.cs new file mode 100644 index 000000000..658b1bdbb --- /dev/null +++ b/HwProj.Common/HwProj.Models/SolutionsService/StudentSolutionsTableDto.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; + +namespace HwProj.Models.SolutionsService +{ + public class StudentSolutionsTableDto + { + public string StudentId { get; set; } + public List Homeworks { get; set; } + } + + public class StudentSolutionsTableHomeworkDto + { + public long Id { get; set; } + public List Tasks { get; set; } = new List(); + } + + public class StudentSolutionsTableTaskDto + { + public long Id { get; set; } + public List Solutions { get; set; } = new List(); + } +} diff --git a/HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseHomeworksModel.cs b/HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseHomeworksModel.cs deleted file mode 100644 index ef4238da2..000000000 --- a/HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseHomeworksModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace HwProj.Models.StatisticsService -{ - public class StatisticsCourseHomeworksModel - { - public long Id { get; set; } - public List Tasks { get; set; } = new List(); - } -} diff --git a/HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseMatesDTO.cs b/HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseMatesDTO.cs deleted file mode 100644 index 716f70db3..000000000 --- a/HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseMatesDTO.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace HwProj.Models.StatisticsService -{ - public class StatisticsCourseMatesDto - { - public string StudentId { get; set; } - public List Homeworks { get; set; } - } -} diff --git a/HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseTasksModel.cs b/HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseTasksModel.cs deleted file mode 100644 index 6f3cb5b3d..000000000 --- a/HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseTasksModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using HwProj.Models.SolutionsService; - -namespace HwProj.Models.StatisticsService -{ - public class StatisticsCourseTasksModel - { - public long Id { get; set; } - public List Solution { get; set; } = new List(); - } -} diff --git a/HwProj.ContentService/HwProj.ContentService.API/Models/Database/FileRecord.cs b/HwProj.ContentService/HwProj.ContentService.API/Models/Database/FileRecord.cs index 6d3ac46d8..61cf0b6c0 100644 --- a/HwProj.ContentService/HwProj.ContentService.API/Models/Database/FileRecord.cs +++ b/HwProj.ContentService/HwProj.ContentService.API/Models/Database/FileRecord.cs @@ -1,5 +1,4 @@ using HwProj.ContentService.API.Models.Enums; -using HwProj.Repositories; namespace HwProj.ContentService.API.Models.Database; diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/ApplicationProfile.cs b/HwProj.CoursesService/HwProj.CoursesService.API/AutomapperProfile.cs similarity index 90% rename from HwProj.CoursesService/HwProj.CoursesService.API/ApplicationProfile.cs rename to HwProj.CoursesService/HwProj.CoursesService.API/AutomapperProfile.cs index c57a959e1..845b0e146 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/ApplicationProfile.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/AutomapperProfile.cs @@ -6,9 +6,9 @@ namespace HwProj.CoursesService.API { - public class ApplicationProfile : Profile + public class AutomapperProfile : Profile { - public ApplicationProfile() + public AutomapperProfile() { CreateMap().ReverseMap(); CreateMap().ReverseMap(); diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Controllers/CoursesController.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Controllers/CoursesController.cs index 022aad42c..97b6eef64 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Controllers/CoursesController.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Controllers/CoursesController.cs @@ -1,14 +1,13 @@ using System; using System.Threading.Tasks; -using AutoMapper; using HwProj.CoursesService.API.Filters; using HwProj.CoursesService.API.Models; using HwProj.CoursesService.API.Services; using HwProj.Models.CoursesService.ViewModels; -using HwProj.Utils.Authorization; using Microsoft.AspNetCore.Mvc; using System.Linq; using System.Net; +using HwProj.Common.Net8; using HwProj.CoursesService.API.Repositories; using HwProj.Models.CoursesService.DTO; using Microsoft.EntityFrameworkCore; diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Controllers/TasksController.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Controllers/TasksController.cs index e8b8ec613..6d59f1b13 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Controllers/TasksController.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Controllers/TasksController.cs @@ -5,11 +5,11 @@ using HwProj.Models; using HwProj.Models.CoursesService.ViewModels; using HwProj.Models.Roles; -using HwProj.Utils.Authorization; using Microsoft.AspNetCore.Mvc; using System; using System.Linq; using System.Threading.Tasks; +using HwProj.Common.Net8; namespace HwProj.CoursesService.API.Controllers { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Dockerfile b/HwProj.CoursesService/HwProj.CoursesService.API/Dockerfile index d73027449..f4e295506 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Dockerfile +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src COPY ["Directory.Build.props", "Directory.Build.props"] @@ -7,8 +7,8 @@ COPY ["HwProj.CoursesService/HwProj.CoursesService.API/", "HwProj.CoursesService COPY ["HwProj.Common/HwProj.Utils/", "HwProj.Common/HwProj.Utils/"] COPY ["HwProj.Common/HwProj.Exceptions/", "HwProj.Common/HwProj.Exceptions/"] COPY ["HwProj.EventBus/HwProj.EventBus.Client/", "HwProj.EventBus/HwProj.EventBus.Client/"] -COPY ["HwProj.Common/HwProj.Models/", "HwProj.Common/HwProj.Models/"] -COPY ["HwProj.Common/HwProj.Repositories/", "HwProj.Common/HwProj.Repositories/"] +COPY ["HwProj.Common/HwProj.Common.Net8/", "HwProj.Common/HwProj.Common.Net8/"] +COPY ["HwProj.Common/HwProj.Repositories.Net8/", "HwProj.Common/HwProj.Repositories.Net8/"] COPY ["HwProj.AuthService/HwProj.AuthService.Client/", "HwProj.AuthService/HwProj.AuthService.Client/"] COPY ["HwProj.ContentService/HwProj.ContentService.Client/", "HwProj.ContentService/HwProj.ContentService.Client/"] COPY ["HwProj.Common/HwProj.HttpUtils/", "HwProj.Common/HwProj.HttpUtils/"] @@ -17,7 +17,7 @@ COPY ["HwProj.NotificationsService/HwProj.NotificationService.Events/", "HwProj. WORKDIR "/src/HwProj.CoursesService/HwProj.CoursesService.API" RUN dotnet publish "HwProj.CoursesService.API.csproj" -c Release -o /app/publish -FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS final +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final WORKDIR /app COPY --from=build /app/publish . diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Domains/MappingExtensions.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Domains/MappingExtensions.cs index 1ff471f2f..a6c321f66 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Domains/MappingExtensions.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Domains/MappingExtensions.cs @@ -4,7 +4,6 @@ using System; using HwProj.Models.CoursesService; using HwProj.Models.CoursesService.DTO; -using Microsoft.EntityFrameworkCore.Internal; using CriterionType = HwProj.Models.CoursesService.ViewModels.CriterionType; namespace HwProj.CoursesService.API.Domains @@ -147,7 +146,7 @@ public static Homework ToHomework(this CreateHomeworkViewModel homework) IsDeadlineStrict = homework.IsDeadlineStrict, PublicationDate = homework.PublicationDate, Tasks = homework.Tasks.Select(t => t.ToHomeworkTask()).ToList(), - Tags = homework.Tags.Join(";"), + Tags = string.Join(";", homework.Tags), }; public static CourseTemplate ToCourseTemplate(this CreateCourseViewModel createCourseViewModel) diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Filters/CourseDataFilterAttribute.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Filters/CourseDataFilterAttribute.cs index 91fadeba9..60b98c838 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Filters/CourseDataFilterAttribute.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Filters/CourseDataFilterAttribute.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using HwProj.Common.Net8; using HwProj.Models.CoursesService; using HwProj.Models.CoursesService.ViewModels; -using HwProj.Utils.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/HwProj.CoursesService.API.csproj b/HwProj.CoursesService/HwProj.CoursesService.API/HwProj.CoursesService.API.csproj index 763208ee7..395606a44 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/HwProj.CoursesService.API.csproj +++ b/HwProj.CoursesService/HwProj.CoursesService.API/HwProj.CoursesService.API.csproj @@ -1,33 +1,23 @@  - netcoreapp2.2 - ..\..\docker-compose.dcproj - Linux - ..\.. + net8.0 $(CSharpLanguageVersion) $(NullableReferenceTypes) - - - - - - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + + - - - - \ No newline at end of file diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Models/Assignment.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Models/Assignment.cs index 68c5979ad..0d3cacdc5 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Models/Assignment.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Models/Assignment.cs @@ -1,5 +1,5 @@ using System.ComponentModel.DataAnnotations; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Models { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Models/Course.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Models/Course.cs index e5f6af8a3..255241668 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Models/Course.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Models/Course.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Models { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Models/CourseFilter.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Models/CourseFilter.cs index d6a2e7aa5..61087906b 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Models/CourseFilter.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Models/CourseFilter.cs @@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using HwProj.CoursesService.API.Services; -using HwProj.Repositories; +using HwProj.Repositories.Net8; using Newtonsoft.Json; namespace HwProj.CoursesService.API.Models diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Models/CourseMate.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Models/CourseMate.cs index 544fbc9d1..57c47f2fd 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Models/CourseMate.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Models/CourseMate.cs @@ -1,5 +1,5 @@ using System.ComponentModel.DataAnnotations; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Models { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Models/Criterion.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Models/Criterion.cs index 3d67a0984..debc0b99b 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Models/Criterion.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Models/Criterion.cs @@ -1,5 +1,5 @@ using System.ComponentModel.DataAnnotations.Schema; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Models { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Models/Group.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Models/Group.cs index 624f8fc69..7aa8229a2 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Models/Group.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Models/Group.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Models { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Models/GroupMate.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Models/GroupMate.cs index 1e4841a13..0e904f0f5 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Models/GroupMate.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Models/GroupMate.cs @@ -1,5 +1,5 @@ using System.ComponentModel.DataAnnotations; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Models { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Models/Homework.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Models/Homework.cs index 6f92df5d3..455c411a8 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Models/Homework.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Models/Homework.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Models { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Models/HomeworkTask.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Models/HomeworkTask.cs index dc6003c6f..2a6cce72d 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Models/HomeworkTask.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Models/HomeworkTask.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Models { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Models/TaskModel.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Models/TaskModel.cs index c275e590a..b997f4d20 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Models/TaskModel.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Models/TaskModel.cs @@ -1,5 +1,5 @@ -using HwProj.Repositories; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Models { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Models/TaskQuestion.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Models/TaskQuestion.cs index 7f42ce148..ac8169105 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Models/TaskQuestion.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Models/TaskQuestion.cs @@ -1,5 +1,5 @@ using System.ComponentModel.DataAnnotations; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Models { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/CourseFilterRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/CourseFilterRepository.cs index ed237ae64..0ed63aa38 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/CourseFilterRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/CourseFilterRepository.cs @@ -2,7 +2,7 @@ using System.Linq; using System.Threading.Tasks; using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; using Microsoft.EntityFrameworkCore; namespace HwProj.CoursesService.API.Repositories diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/CourseMatesRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/CourseMatesRepository.cs index 9bf439ce8..16996084b 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/CourseMatesRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/CourseMatesRepository.cs @@ -1,5 +1,5 @@ -using HwProj.Repositories; -using HwProj.CoursesService.API.Models; +using HwProj.CoursesService.API.Models; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/CoursesRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/CoursesRepository.cs index 048cb81a5..18c8286de 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/CoursesRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/CoursesRepository.cs @@ -1,7 +1,7 @@ using System.Linq; using System.Threading.Tasks; using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; using Microsoft.EntityFrameworkCore; namespace HwProj.CoursesService.API.Repositories diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/GroupMatesRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/GroupMatesRepository.cs index 160b20ea0..85eba2000 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/GroupMatesRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/GroupMatesRepository.cs @@ -1,5 +1,5 @@ -using HwProj.Repositories; -using HwProj.CoursesService.API.Models; +using HwProj.CoursesService.API.Models; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories.Groups { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/GroupsRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/GroupsRepository.cs index 225d4b7ec..6b0c8df45 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/GroupsRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/GroupsRepository.cs @@ -1,7 +1,7 @@ using System.Linq; using System.Threading.Tasks; using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; using Microsoft.EntityFrameworkCore; namespace HwProj.CoursesService.API.Repositories.Groups diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/IGroupMatesRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/IGroupMatesRepository.cs index 3d507966c..b162ce695 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/IGroupMatesRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/IGroupMatesRepository.cs @@ -1,5 +1,5 @@ -using HwProj.Repositories; -using HwProj.CoursesService.API.Models; +using HwProj.CoursesService.API.Models; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories.Groups { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/IGroupsRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/IGroupsRepository.cs index a83faccba..d25c28238 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/IGroupsRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/IGroupsRepository.cs @@ -1,7 +1,7 @@ using System.Linq; using System.Threading.Tasks; using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories.Groups { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/ITaskModelsRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/ITaskModelsRepository.cs index 3a179fd4b..3d5813b2d 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/ITaskModelsRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/ITaskModelsRepository.cs @@ -1,5 +1,5 @@ using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories.Groups { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/TaskModelsRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/TaskModelsRepository.cs index 102e1dead..28609be69 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/TaskModelsRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/Groups/TaskModelsRepository.cs @@ -1,5 +1,5 @@ using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories.Groups { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/HomeworksRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/HomeworksRepository.cs index 693706635..aa663be58 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/HomeworksRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/HomeworksRepository.cs @@ -1,7 +1,7 @@ using System.Linq; using System.Threading.Tasks; using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; using Microsoft.EntityFrameworkCore; namespace HwProj.CoursesService.API.Repositories diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ICourseFilterRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ICourseFilterRepository.cs index 81df0f3b6..084f7c471 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ICourseFilterRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ICourseFilterRepository.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ICourseMatesRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ICourseMatesRepository.cs index 374bd62e0..2da90077b 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ICourseMatesRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ICourseMatesRepository.cs @@ -1,5 +1,5 @@ -using HwProj.Repositories; -using HwProj.CoursesService.API.Models; +using HwProj.CoursesService.API.Models; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ICoursesRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ICoursesRepository.cs index f56c8c638..a8059f5e6 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ICoursesRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ICoursesRepository.cs @@ -1,7 +1,7 @@ using HwProj.CoursesService.API.Models; -using HwProj.Repositories; using System.Linq; using System.Threading.Tasks; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/IHomeworksRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/IHomeworksRepository.cs index f621269b3..4c05afdaf 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/IHomeworksRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/IHomeworksRepository.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ITaskQuestionsRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ITaskQuestionsRepository.cs index 0a0d1cb9c..5bbf6a6dd 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ITaskQuestionsRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ITaskQuestionsRepository.cs @@ -1,5 +1,5 @@ using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ITasksRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ITasksRepository.cs index 5d43ba77c..e6fe97e7d 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ITasksRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ITasksRepository.cs @@ -3,7 +3,7 @@ using System.Linq.Expressions; using System.Threading.Tasks; using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/TaskQuestionsRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/TaskQuestionsRepository.cs index 3b1f89aeb..1d42a26e2 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/TaskQuestionsRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/TaskQuestionsRepository.cs @@ -1,5 +1,5 @@ using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; namespace HwProj.CoursesService.API.Repositories { diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/TasksRepository.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/TasksRepository.cs index f998be609..769a23be6 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/TasksRepository.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Repositories/TasksRepository.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using System.Transactions; using HwProj.CoursesService.API.Models; -using HwProj.Repositories; +using HwProj.Repositories.Net8; using Microsoft.EntityFrameworkCore; namespace HwProj.CoursesService.API.Repositories diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Services/CoursesService.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Services/CoursesService.cs index 69ef5e6c8..9293160d4 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Services/CoursesService.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Services/CoursesService.cs @@ -16,7 +16,6 @@ using HwProj.Models.Roles; using HwProj.NotificationService.Events.CoursesService; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Internal; namespace HwProj.CoursesService.API.Services { @@ -137,7 +136,7 @@ public async Task AddAsync(CreateCourseViewModel courseViewModel, string m HomeworksMapping = homeworksMapping }); - if (!result.Succeeded) throw new TransactionAbortedException(result.Errors.Join("\n")); + if (!result.Succeeded) throw new TransactionAbortedException(string.Join("\n", result.Errors)); } } diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/Startup.cs b/HwProj.CoursesService/HwProj.CoursesService.API/Startup.cs index ae4454029..f6bb3f1d1 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/Startup.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.API/Startup.cs @@ -1,4 +1,6 @@ -using HwProj.AuthService.Client; +using System.Text.Json.Serialization; +using HwProj.AuthService.Client; +using HwProj.Common.Net8; using HwProj.ContentService.Client; using HwProj.CoursesService.API.Filters; using HwProj.CoursesService.API.Models; @@ -6,12 +8,11 @@ using HwProj.CoursesService.API.Repositories.Groups; using HwProj.CoursesService.API.Services; using HwProj.EventBus.Client; -using HwProj.Utils.Configuration; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace HwProj.CoursesService.API { @@ -50,13 +51,32 @@ public void ConfigureServices(IServiceCollection services) services.AddHttpClient(); services.AddAuthServiceClient(); services.AddContentServiceClient(); + services.AddHttpContextAccessor(); - services.ConfigureHwProjServices("Courses API"); + services + .AddCors() + .AddControllers() + .AddJsonOptions(options => + options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles); + + services.AddAutoMapper(x => x.AddProfile()); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env, CourseContext context) + public void Configure(IApplicationBuilder app, IHostEnvironment env, CourseContext context) { - app.ConfigureHwProj(env, "Courses API", context); + if (env.IsDevelopment()) app.UseDeveloperExceptionPage(); + else app.UseHsts(); + + app.UseRouting(); + app.UseCors(x => x + .AllowAnyMethod() + .AllowAnyHeader() + .SetIsOriginAllowed(_ => true) + .AllowCredentials()); + + app.UseEndpoints(x => x.MapControllers()); + + app.UseDatabase(env, context); } } } diff --git a/HwProj.CoursesService/HwProj.CoursesService.API/appsettings.json b/HwProj.CoursesService/HwProj.CoursesService.API/appsettings.json index 4f4452b1b..b8f8a2600 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.API/appsettings.json +++ b/HwProj.CoursesService/HwProj.CoursesService.API/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnectionForWindows": "Server=(localdb)\\mssqllocaldb;Database=CoursesServiceDB;Trusted_Connection=True;", + "DefaultConnectionForWindows": "Server=(localdb)\\mssqllocaldb;Database=CoursesServiceDB;Trusted_Connection=True;TrustServerCertificate=true;", "DefaultConnectionForLinux": "Server=localhost,1433;Database=CoursesServiceDB;User ID=SA;Password=password_1234;" }, "Logging": { diff --git a/HwProj.CoursesService/HwProj.CoursesService.Tests/CoursesServiceTests.cs b/HwProj.CoursesService/HwProj.CoursesService.Tests/CoursesServiceTests.cs index 7bc48943d..98ebc1e93 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.Tests/CoursesServiceTests.cs +++ b/HwProj.CoursesService/HwProj.CoursesService.Tests/CoursesServiceTests.cs @@ -5,7 +5,6 @@ using System.Security.Claims; using System.Threading.Tasks; using AutoFixture; -using HwProj.AuthService.Client; using HwProj.Models.AuthService.ViewModels; using HwProj.Models.CoursesService.ViewModels; using Microsoft.AspNetCore.Http; @@ -14,6 +13,7 @@ using Moq; using NUnit.Framework; using FluentAssertions; +using HwProj.AuthService.Client; using HwProj.CoursesService.Client; using HwProj.Models.Result; diff --git a/HwProj.CoursesService/HwProj.CoursesService.Tests/HwProj.CoursesService.Tests.csproj b/HwProj.CoursesService/HwProj.CoursesService.Tests/HwProj.CoursesService.Tests.csproj index 132db37b2..bbbfe359a 100644 --- a/HwProj.CoursesService/HwProj.CoursesService.Tests/HwProj.CoursesService.Tests.csproj +++ b/HwProj.CoursesService/HwProj.CoursesService.Tests/HwProj.CoursesService.Tests.csproj @@ -26,7 +26,7 @@ - + diff --git a/HwProj.NotificationsService/HwProj.NotificationsService.API/Dockerfile b/HwProj.NotificationsService/HwProj.NotificationsService.API/Dockerfile index 72caa8fe9..2eb9b0a51 100644 --- a/HwProj.NotificationsService/HwProj.NotificationsService.API/Dockerfile +++ b/HwProj.NotificationsService/HwProj.NotificationsService.API/Dockerfile @@ -8,7 +8,6 @@ COPY ["HwProj.NotificationsService/HwProj.NotificationService.Events/", "HwProj. COPY ["HwProj.Common/HwProj.Common.Net8/", "HwProj.Common/HwProj.Common.Net8/"] COPY ["HwProj.EventBus/HwProj.EventBus.Client/", "HwProj.EventBus/HwProj.EventBus.Client/"] COPY ["HwProj.Common/HwProj.Models/", "HwProj.Common/HwProj.Models/"] -COPY ["HwProj.Common/HwProj.Repositories/", "HwProj.Common/HwProj.Repositories/"] COPY ["HwProj.Common/HwProj.Repositories.Net8/", "HwProj.Common/HwProj.Repositories.Net8/"] COPY ["HwProj.SolutionsService/HwProj.SolutionsService.Client/", "HwProj.SolutionsService/HwProj.SolutionsService.Client/"] COPY ["HwProj.Common/HwProj.Exceptions/", "HwProj.Common/HwProj.Exceptions/"] diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.API/AutomapperProfile.cs b/HwProj.SolutionsService/HwProj.SolutionsService.API/AutomapperProfile.cs index 93c854c81..8f973d106 100644 --- a/HwProj.SolutionsService/HwProj.SolutionsService.API/AutomapperProfile.cs +++ b/HwProj.SolutionsService/HwProj.SolutionsService.API/AutomapperProfile.cs @@ -1,5 +1,6 @@ using AutoMapper; using HwProj.Models.SolutionsService; +using Solution = HwProj.SolutionsService.API.Models.Solution; namespace HwProj.SolutionsService.API { @@ -8,6 +9,7 @@ public class AutomapperProfile : Profile public AutomapperProfile() { CreateMap().ReverseMap(); + CreateMap(); CreateMap(); } } diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.API/Controllers/SolutionsController.cs b/HwProj.SolutionsService/HwProj.SolutionsService.API/Controllers/SolutionsController.cs index 0cd2215a7..9c4e0554b 100644 --- a/HwProj.SolutionsService/HwProj.SolutionsService.API/Controllers/SolutionsController.cs +++ b/HwProj.SolutionsService/HwProj.SolutionsService.API/Controllers/SolutionsController.cs @@ -6,7 +6,6 @@ using AutoMapper; using HwProj.CoursesService.Client; using HwProj.Models.CoursesService; -using HwProj.Models.CoursesService.ViewModels; using HwProj.Models.SolutionsService; using HwProj.Models.StatisticsService; using HwProj.SolutionsService.API.Domains; @@ -43,12 +42,6 @@ public SolutionsController( _mapper = mapper; } - [HttpGet] - public async Task GetAllSolutions() - { - return await _solutionsService.GetAllSolutionsAsync(); - } - [HttpGet("{solutionId}")] public async Task GetSolution(long solutionId) { @@ -59,15 +52,17 @@ public async Task GetSolution(long solutionId) } [HttpGet("taskSolutions/{taskId}/{studentId}")] - public async Task GetTaskSolutionsFromStudent(long taskId, string studentId) + public async Task GetTaskSolutionsFromStudent(long taskId, string studentId) { - return await _solutionsService.GetTaskSolutionsFromStudentAsync(taskId, studentId); + var solutions = await _solutionsService.GetTaskSolutionsFromStudentAsync(taskId, studentId); + return _mapper.Map(solutions); } [HttpPost("taskSolutions/{studentId}")] - public async Task GetLastTaskSolutions([FromBody] long[] taskIds, string studentId) + public async Task GetLastTaskSolutions([FromBody] long[] taskIds, string studentId) { - return await _solutionsService.GetLastTaskSolutions(taskIds, studentId); + var solutions = await _solutionsService.GetLastTaskSolutions(taskIds, studentId); + return _mapper.Map(solutions); } [HttpPost("{taskId}")] @@ -139,9 +134,10 @@ public async Task PostSolution(long groupId, long taskId, [FromBody] Solut } [HttpGet("{groupId}/taskSolutions/{taskId}")] - public async Task GetTaskSolutionsFromGroup(long groupId, long taskId) + public async Task GetTaskSolutionsFromGroup(long groupId, long taskId) { - return await _solutionsService.GetTaskSolutionsFromGroupAsync(taskId, groupId); + var solutions = await _solutionsService.GetTaskSolutionsFromGroupAsync(taskId, groupId); + return _mapper.Map(solutions); } [HttpGet("getLecturersStat/{courseId}")] @@ -197,7 +193,7 @@ public async Task GetLecturersStat(long courseId) } [HttpGet("getCourseStat/{courseId}")] - [ProducesResponseType(typeof(StatisticsCourseMatesDto[]), (int)HttpStatusCode.OK)] + [ProducesResponseType(typeof(StudentSolutionsTableDto[]), (int)HttpStatusCode.OK)] public async Task GetCourseStat(long courseId) { var course = await _coursesClient.GetCourseById(courseId); @@ -215,15 +211,29 @@ public async Task GetCourseStat(long courseId) : course.CourseMates.Where(t => t.StudentId == userId); var courseGroups = course.Groups; - var solutionsStatsContext = new StatisticsAggregateModel + var context = new StudentsSolutionsTableContext() { CourseMates = courseMates, Homeworks = course.Homeworks.Where(t => t.Tasks.Any()).ToList(), Solutions = solutions, Groups = courseGroups }; + var table = SolutionsDomain.GetCourseSolutionsTable(context); + + var result = table.Select(x => new StudentSolutionsTableDto + { + StudentId = x.StudentId, + Homeworks = x.Homeworks.Select(h => new StudentSolutionsTableHomeworkDto + { + Id = h.Id, + Tasks = h.Tasks.Select(t => new StudentSolutionsTableTaskDto + { + Id = t.Id, + Solutions = _mapper.Map>(t.Solutions) + }).ToList() + }).ToList() + }).ToList(); - var result = SolutionsStatsDomain.GetCourseStatistics(solutionsStatsContext); return Ok(result); } @@ -279,7 +289,7 @@ public async Task GetBenchmarkStats(long courseId) } [HttpGet("getTaskStats/{courseId}/{taskId}")] - [ProducesResponseType(typeof(StudentSolutions[]), (int)HttpStatusCode.OK)] + [ProducesResponseType(typeof(StudentSolutionsDto[]), (int)HttpStatusCode.OK)] public async Task GetTaskStats(long courseId, long taskId) { var groups = await _coursesClient.GetAllCourseGroups(courseId); @@ -288,7 +298,13 @@ public async Task GetTaskStats(long courseId, long taskId) var solutionsGroups = solutions.Select(s => s.GroupId).Distinct(); var taskGroups = groups.Where(g => solutionsGroups.Contains(g.Id)); - var result = SolutionsStatsDomain.GetCourseTaskStatistics(solutions, taskGroups); + var studentsSolutions = SolutionsDomain.GetStudentsSolutions(solutions, taskGroups); + var result = studentsSolutions.Select(x => new StudentSolutionsDto + { + StudentId = x.StudentId, + Solutions = _mapper.Map(x.Solutions) + }).ToArray(); + return Ok(result); } diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.API/Domains/SolutionsStatsDomain.cs b/HwProj.SolutionsService/HwProj.SolutionsService.API/Domains/SolutionsDomain.cs similarity index 63% rename from HwProj.SolutionsService/HwProj.SolutionsService.API/Domains/SolutionsStatsDomain.cs rename to HwProj.SolutionsService/HwProj.SolutionsService.API/Domains/SolutionsDomain.cs index 47500ae1b..a77313f3e 100644 --- a/HwProj.SolutionsService/HwProj.SolutionsService.API/Domains/SolutionsStatsDomain.cs +++ b/HwProj.SolutionsService/HwProj.SolutionsService.API/Domains/SolutionsDomain.cs @@ -1,16 +1,14 @@ using System.Collections.Generic; using System.Linq; using HwProj.Models.CoursesService.ViewModels; -using HwProj.Models.SolutionsService; -using HwProj.Models.StatisticsService; using HwProj.SolutionsService.API.Models; namespace HwProj.SolutionsService.API.Domains { - public static class SolutionsStatsDomain + public static class SolutionsDomain { //TODO: rewrite - public static StatisticsCourseMatesDto[] GetCourseStatistics(StatisticsAggregateModel model) => + public static StudentSolutionsTable[] GetCourseSolutionsTable(StudentsSolutionsTableContext model) => model.CourseMates .Select(m => { @@ -19,14 +17,14 @@ public static StatisticsCourseMatesDto[] GetCourseStatistics(StatisticsAggregate .Select(g => g.Id) .ToArray(); - return new StatisticsCourseMatesDto + return new StudentSolutionsTable { StudentId = m.StudentId, - Homeworks = new List(model.Homeworks.Select(h => - new StatisticsCourseHomeworksModel + Homeworks = new List(model.Homeworks.Select(h => + new StudentSolutionsTable.Homework { Id = h.Id, - Tasks = new List(h.Tasks.Select(t => + Tasks = new List(h.Tasks.Select(t => { var solutions = model.Solutions @@ -36,17 +34,17 @@ public static StatisticsCourseMatesDto[] GetCourseStatistics(StatisticsAggregate studentGroupIds.Contains(s.GroupId.GetValueOrDefault()) )) .OrderBy(s => s.PublicationDate); - return new StatisticsCourseTasksModel + return new StudentSolutionsTable.Task { Id = t.Id, - Solution = solutions.ToList() + Solutions = solutions.ToList() }; })) })) }; }).ToArray(); - public static StudentSolutions[] GetCourseTaskStatistics(List solutions, + public static StudentSolutions[] GetStudentsSolutions(List solutions, IEnumerable groups) { return solutions @@ -77,4 +75,35 @@ public static StudentSolutions[] GetCourseTaskStatistics(List solution .ToArray(); } } + + public class StudentsSolutionsTableContext + { + public IEnumerable CourseMates { get; set; } + public List Homeworks { get; set; } + public List Solutions { get; set; } + public GroupViewModel[] Groups { get; set; } + } + + public class StudentSolutionsTable + { + public string StudentId { get; set; } + public List Homeworks { get; set; } + + public class Homework + { + public long Id { get; set; } + public List Tasks { get; set; } = new List(); + } + public class Task + { + public long Id { get; set; } + public List Solutions { get; set; } = new List(); + } + } + + public class StudentSolutions + { + public string StudentId { get; set; } + public Solution[] Solutions { get; set; } + } } diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.API/HwProj.SolutionsService.API.csproj b/HwProj.SolutionsService/HwProj.SolutionsService.API/HwProj.SolutionsService.API.csproj index 482ecfca2..fe78204a2 100644 --- a/HwProj.SolutionsService/HwProj.SolutionsService.API/HwProj.SolutionsService.API.csproj +++ b/HwProj.SolutionsService/HwProj.SolutionsService.API/HwProj.SolutionsService.API.csproj @@ -15,6 +15,7 @@ + diff --git a/HwProj.Common/HwProj.Models/SolutionsService/Solution.cs b/HwProj.SolutionsService/HwProj.SolutionsService.API/Models/Solution.cs similarity index 84% rename from HwProj.Common/HwProj.Models/SolutionsService/Solution.cs rename to HwProj.SolutionsService/HwProj.SolutionsService.API/Models/Solution.cs index a8c720032..064a5c083 100644 --- a/HwProj.Common/HwProj.Models/SolutionsService/Solution.cs +++ b/HwProj.SolutionsService/HwProj.SolutionsService.API/Models/Solution.cs @@ -1,7 +1,8 @@ -using HwProj.Repositories; -using System; +using System; +using HwProj.Models.SolutionsService; +using HwProj.Repositories; -namespace HwProj.Models.SolutionsService +namespace HwProj.SolutionsService.API.Models { public class Solution : IEntity { diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.API/Models/SolutionsContext.cs b/HwProj.SolutionsService/HwProj.SolutionsService.API/Models/SolutionsContext.cs index d1d895aa6..f4600335b 100644 --- a/HwProj.SolutionsService/HwProj.SolutionsService.API/Models/SolutionsContext.cs +++ b/HwProj.SolutionsService/HwProj.SolutionsService.API/Models/SolutionsContext.cs @@ -1,5 +1,4 @@ -using HwProj.Models.SolutionsService; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; namespace HwProj.SolutionsService.API.Models { diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.API/Models/StatisticsAggregateModel.cs b/HwProj.SolutionsService/HwProj.SolutionsService.API/Models/StatisticsAggregateModel.cs deleted file mode 100644 index 1ad5fbf76..000000000 --- a/HwProj.SolutionsService/HwProj.SolutionsService.API/Models/StatisticsAggregateModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; -using HwProj.Models.CoursesService.ViewModels; -using HwProj.Models.SolutionsService; - -namespace HwProj.SolutionsService.API.Models -{ - public class StatisticsAggregateModel - { - public IEnumerable CourseMates { get; set; } - public List Homeworks { get; set; } - public List Solutions { get; set; } - public GroupViewModel[] Groups { get; set; } - } -} diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.API/Repositories/ISolutionsRepository.cs b/HwProj.SolutionsService/HwProj.SolutionsService.API/Repositories/ISolutionsRepository.cs index 73348a091..907a19f23 100644 --- a/HwProj.SolutionsService/HwProj.SolutionsService.API/Repositories/ISolutionsRepository.cs +++ b/HwProj.SolutionsService/HwProj.SolutionsService.API/Repositories/ISolutionsRepository.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using HwProj.Models.SolutionsService; using HwProj.Repositories; +using HwProj.SolutionsService.API.Models; namespace HwProj.SolutionsService.API.Repositories { diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.API/Services/ISolutionsService.cs b/HwProj.SolutionsService/HwProj.SolutionsService.API/Services/ISolutionsService.cs index 441a6433c..9f284b30f 100644 --- a/HwProj.SolutionsService/HwProj.SolutionsService.API/Services/ISolutionsService.cs +++ b/HwProj.SolutionsService/HwProj.SolutionsService.API/Services/ISolutionsService.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using HwProj.Models.SolutionsService; using HwProj.Models.StatisticsService; +using HwProj.SolutionsService.API.Models; namespace HwProj.SolutionsService.API.Services { diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.API/Services/SolutionsService.cs b/HwProj.SolutionsService/HwProj.SolutionsService.API/Services/SolutionsService.cs index d10941c24..402c68944 100644 --- a/HwProj.SolutionsService/HwProj.SolutionsService.API/Services/SolutionsService.cs +++ b/HwProj.SolutionsService/HwProj.SolutionsService.API/Services/SolutionsService.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using AutoMapper; @@ -212,7 +211,7 @@ public async Task GetAllUnratedSolutions(GetTasksSolutions return (await getSolutionsQuery.ToListAsync()) .GroupBy(t => t.TaskId) .Select(t => - (t.Key, TaskSolutions: SolutionsStatsDomain.GetCourseTaskStatistics(t.ToList(), groups))) + (t.Key, TaskSolutions: SolutionsDomain.GetStudentsSolutions(t.ToList(), groups))) .SelectMany(grouped => grouped.TaskSolutions.Select(studentSolutions => { var lastSolution = studentSolutions.Solutions.Last(); diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.Client/ISolutionsServiceClient.cs b/HwProj.SolutionsService/HwProj.SolutionsService.Client/ISolutionsServiceClient.cs index 6a73f271a..4529e539c 100644 --- a/HwProj.SolutionsService/HwProj.SolutionsService.Client/ISolutionsServiceClient.cs +++ b/HwProj.SolutionsService/HwProj.SolutionsService.Client/ISolutionsServiceClient.cs @@ -6,21 +6,21 @@ namespace HwProj.SolutionsService.Client { public interface ISolutionsServiceClient { - Task GetAllSolutions(); - Task GetSolutionById(long solutionId); - Task GetUserSolutions(long taskId, string studentId); + Task GetAllSolutions(); + Task GetSolutionById(long solutionId); + Task GetUserSolutions(long taskId, string studentId); Task PostSolution(long taskId, PostSolutionModel model); Task PostEmptySolutionWithRate(long taskId, SolutionViewModel solution); Task RateSolution(long solutionId, RateSolutionModel rateSolutionModel); Task MarkSolution(long solutionId); Task DeleteSolution(long solutionId); Task PostGroupSolution(SolutionViewModel model, long taskId, long groupId); - Task GetTaskSolutions(long groupId, long taskId); - Task GetCourseStatistics(long courseId, string userId); + Task GetTaskSolutions(long groupId, long taskId); + Task GetCourseStatistics(long courseId, string userId); Task GetLecturersStatistics(long courseId); Task GetBenchmarkStatistics(long courseId); - Task GetTaskSolutionStatistics(long courseId, long taskId); - Task GetLastTaskSolutions(long[] taskIds, string userId); + Task GetTaskSolutionStatistics(long courseId, long taskId); + Task GetLastTaskSolutions(long[] taskIds, string userId); Task GetAllUnratedSolutionsForTasks(GetTasksSolutionsModel model); Task GetTaskSolutionsStats(GetTasksSolutionsModel tasksSolutionsDTO); Task GetSolutionActuality(long solutionId); diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.Client/SolutionsServiceClient.cs b/HwProj.SolutionsService/HwProj.SolutionsService.Client/SolutionsServiceClient.cs index da26f52a9..e6ecdcd93 100644 --- a/HwProj.SolutionsService/HwProj.SolutionsService.Client/SolutionsServiceClient.cs +++ b/HwProj.SolutionsService/HwProj.SolutionsService.Client/SolutionsServiceClient.cs @@ -26,7 +26,7 @@ public SolutionsServiceClient(IHttpClientFactory clientFactory, IHttpContextAcce _solutionServiceUri = new Uri(configuration.GetSection("Services")["Solutions"]); } - public async Task GetAllSolutions() + public async Task GetAllSolutions() { using var httpRequest = new HttpRequestMessage( HttpMethod.Get, @@ -34,10 +34,10 @@ public async Task GetAllSolutions() httpRequest.TryAddUserId(_httpContextAccessor); var response = await _httpClient.SendAsync(httpRequest); - return await response.DeserializeAsync(); + return await response.DeserializeAsync(); } - public async Task GetAllTaskSolutions(long taskId) + public async Task GetAllTaskSolutions(long taskId) { using var httpRequest = new HttpRequestMessage( HttpMethod.Get, @@ -45,10 +45,10 @@ public async Task GetAllTaskSolutions(long taskId) httpRequest.TryAddUserId(_httpContextAccessor); var response = await _httpClient.SendAsync(httpRequest); - return await response.DeserializeAsync(); + return await response.DeserializeAsync(); } - public async Task GetSolutionById(long solutionId) + public async Task GetSolutionById(long solutionId) { using var httpRequest = new HttpRequestMessage( HttpMethod.Get, @@ -56,10 +56,10 @@ public async Task GetSolutionById(long solutionId) httpRequest.TryAddUserId(_httpContextAccessor); var response = await _httpClient.SendAsync(httpRequest); - return await response.DeserializeAsync(); + return await response.DeserializeAsync(); } - public async Task GetUserSolutions(long taskId, string studentId) + public async Task GetUserSolutions(long taskId, string studentId) { using var httpRequest = new HttpRequestMessage( HttpMethod.Get, @@ -67,7 +67,7 @@ public async Task GetUserSolutions(long taskId, string studentId) httpRequest.TryAddUserId(_httpContextAccessor); var response = await _httpClient.SendAsync(httpRequest); - return await response.DeserializeAsync(); + return await response.DeserializeAsync(); } public async Task PostSolution(long taskId, PostSolutionModel model) @@ -168,7 +168,7 @@ public async Task PostGroupSolution(SolutionViewModel model, long taskId, return await response.DeserializeAsync(); } - public async Task GetTaskSolutions(long groupId, long taskId) + public async Task GetTaskSolutions(long groupId, long taskId) { using var httpRequest = new HttpRequestMessage( HttpMethod.Get, @@ -176,7 +176,7 @@ public async Task GetTaskSolutions(long groupId, long taskId) httpRequest.TryAddUserId(_httpContextAccessor); var response = await _httpClient.SendAsync(httpRequest); - return await response.DeserializeAsync(); + return await response.DeserializeAsync(); } public async Task GetLecturersStatistics(long courseId) @@ -190,7 +190,7 @@ public async Task GetLecturersStatistics(long courseId) return await response.DeserializeAsync(); } - public async Task GetCourseStatistics(long courseId, string userId) + public async Task GetCourseStatistics(long courseId, string userId) { using var httpRequest = new HttpRequestMessage( HttpMethod.Get, @@ -198,7 +198,7 @@ public async Task GetCourseStatistics(long courseId, httpRequest.TryAddUserId(_httpContextAccessor); var response = await _httpClient.SendAsync(httpRequest); - return await response.DeserializeAsync(); + return await response.DeserializeAsync(); } public async Task GetBenchmarkStatistics(long courseId) @@ -212,7 +212,7 @@ public async Task GetBenchmarkStatistics(l return await response.DeserializeAsync(); } - public async Task GetTaskSolutionStatistics(long courseId, long taskId) + public async Task GetTaskSolutionStatistics(long courseId, long taskId) { using var httpRequest = new HttpRequestMessage( HttpMethod.Get, @@ -220,10 +220,10 @@ public async Task GetTaskSolutionStatistics(long courseId, l httpRequest.TryAddUserId(_httpContextAccessor); var response = await _httpClient.SendAsync(httpRequest); - return await response.DeserializeAsync(); + return await response.DeserializeAsync(); } - public async Task GetLastTaskSolutions(long[] taskIds, string userId) + public async Task GetLastTaskSolutions(long[] taskIds, string userId) { using var httpRequest = new HttpRequestMessage( HttpMethod.Post, @@ -237,7 +237,7 @@ public async Task GetTaskSolutionStatistics(long courseId, l httpRequest.TryAddUserId(_httpContextAccessor); var response = await _httpClient.SendAsync(httpRequest); - return await response.DeserializeAsync(); + return await response.DeserializeAsync(); } public async Task GetAllUnratedSolutionsForTasks(GetTasksSolutionsModel model) diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.IntegrationTests/SolutionsStatsDomainTests.cs b/HwProj.SolutionsService/HwProj.SolutionsService.IntegrationTests/SolutionsDomainTests.cs similarity index 95% rename from HwProj.SolutionsService/HwProj.SolutionsService.IntegrationTests/SolutionsStatsDomainTests.cs rename to HwProj.SolutionsService/HwProj.SolutionsService.IntegrationTests/SolutionsDomainTests.cs index 3637e03ec..dafca0d5c 100644 --- a/HwProj.SolutionsService/HwProj.SolutionsService.IntegrationTests/SolutionsStatsDomainTests.cs +++ b/HwProj.SolutionsService/HwProj.SolutionsService.IntegrationTests/SolutionsDomainTests.cs @@ -12,7 +12,7 @@ namespace HwProj.SolutionsService.IntegrationTests { [TestFixture] - public class SolutionsStatsDomainTests + public class SolutionsDomainTests { private IEnumerable GenerateUserIds(int amount) { @@ -101,7 +101,7 @@ public async Task GetCourseStatisticsTest() var solutions = MakeTestSolutions(courseMates, groups); - var solutionsStatsContext = new StatisticsAggregateModel + var solutionsStatsContext = new StudentsSolutionsTableContext() { CourseMates = courseMates, Homeworks = new List(new[] { homework }), @@ -109,16 +109,16 @@ public async Task GetCourseStatisticsTest() Groups = groups }; - var result = SolutionsStatsDomain.GetCourseStatistics(solutionsStatsContext); + var result = SolutionsDomain.GetCourseSolutionsTable(solutionsStatsContext); var firstStudentSolutions = result .First(t => t.StudentId == courseMates[0].StudentId).Homeworks - .SelectMany(s => s.Tasks).SelectMany(t => t.Solution).ToArray(); + .SelectMany(s => s.Tasks).SelectMany(t => t.Solutions).ToArray(); var secondStudentSolutions = result .First(t => t.StudentId == courseMates[1].StudentId).Homeworks - .SelectMany(s => s.Tasks).SelectMany(t => t.Solution).ToArray(); + .SelectMany(s => s.Tasks).SelectMany(t => t.Solutions).ToArray(); var thirdStudentSolutions = result .First(t => t.StudentId == courseMates[2].StudentId).Homeworks - .SelectMany(s => s.Tasks).SelectMany(t => t.Solution).ToArray(); + .SelectMany(s => s.Tasks).SelectMany(t => t.Solutions).ToArray(); firstStudentSolutions.Should().HaveCount(2); firstStudentSolutions[0].Id.Should().Be(1); @@ -146,7 +146,7 @@ public async Task GetCourseTaskStatisticsTest() solutions[2].StudentId = courseMates[1].StudentId; solutions[2].GroupId = group2.Id; - var result = SolutionsStatsDomain.GetCourseTaskStatistics(solutions, groups); + var result = SolutionsDomain.GetStudentsSolutions(solutions, groups); var firstStudentSolutions = result.First(t => t.StudentId == courseMates[0].StudentId) .Solutions.ToArray(); var secondStudentSolutions = result.First(t => t.StudentId == courseMates[1].StudentId) diff --git a/HwProj.SolutionsService/HwProj.SolutionsService.IntegrationTests/SolutionsServiceTests.cs b/HwProj.SolutionsService/HwProj.SolutionsService.IntegrationTests/SolutionsServiceTests.cs index be58f45aa..1d0b5a7a8 100644 --- a/HwProj.SolutionsService/HwProj.SolutionsService.IntegrationTests/SolutionsServiceTests.cs +++ b/HwProj.SolutionsService/HwProj.SolutionsService.IntegrationTests/SolutionsServiceTests.cs @@ -392,8 +392,8 @@ public async Task GetCourseStatisticsTest() statisticsFromLecture.Should().HaveCount(1); statisticsFromLecture[0].Homeworks.Should().HaveCount(1); statisticsFromLecture[0].Homeworks[0].Tasks.Should().HaveCount(1); - statisticsFromLecture[0].Homeworks[0].Tasks[0].Solution.Should().HaveCount(1); - statisticsFromLecture[0].Homeworks[0].Tasks[0].Solution[0].Rating.Should().Be(2); + statisticsFromLecture[0].Homeworks[0].Tasks[0].Solutions.Should().HaveCount(1); + statisticsFromLecture[0].Homeworks[0].Tasks[0].Solutions[0].Rating.Should().Be(2); } [Test] diff --git a/hwproj.front/src/api/api.ts b/hwproj.front/src/api/api.ts index 10fb0302d..e198db7c5 100644 --- a/hwproj.front/src/api/api.ts +++ b/hwproj.front/src/api/api.ts @@ -1929,132 +1929,132 @@ export interface ScopeDTO { /** * * @export - * @interface Solution + * @interface SolutionActualityDto + */ +export interface SolutionActualityDto { + /** + * + * @type {SolutionActualityPart} + * @memberof SolutionActualityDto + */ + commitsActuality?: SolutionActualityPart; + /** + * + * @type {SolutionActualityPart} + * @memberof SolutionActualityDto + */ + testsActuality?: SolutionActualityPart; +} +/** + * + * @export + * @interface SolutionActualityPart + */ +export interface SolutionActualityPart { + /** + * + * @type {boolean} + * @memberof SolutionActualityPart + */ + isActual?: boolean; + /** + * + * @type {string} + * @memberof SolutionActualityPart + */ + comment?: string; + /** + * + * @type {string} + * @memberof SolutionActualityPart + */ + additionalData?: string; +} +/** + * + * @export + * @interface SolutionDto */ -export interface Solution { +export interface SolutionDto { /** * * @type {number} - * @memberof Solution + * @memberof SolutionDto */ id?: number; /** * * @type {string} - * @memberof Solution + * @memberof SolutionDto */ githubUrl?: string; /** * * @type {string} - * @memberof Solution + * @memberof SolutionDto */ comment?: string; /** * * @type {SolutionState} - * @memberof Solution + * @memberof SolutionDto */ state?: SolutionState; /** * * @type {number} - * @memberof Solution + * @memberof SolutionDto */ rating?: number; /** * * @type {string} - * @memberof Solution + * @memberof SolutionDto */ studentId?: string; /** * * @type {string} - * @memberof Solution + * @memberof SolutionDto */ lecturerId?: string; /** * * @type {number} - * @memberof Solution + * @memberof SolutionDto */ groupId?: number; /** * * @type {number} - * @memberof Solution + * @memberof SolutionDto */ taskId?: number; /** * * @type {Date} - * @memberof Solution + * @memberof SolutionDto */ publicationDate?: Date; /** * * @type {boolean} - * @memberof Solution + * @memberof SolutionDto */ isModified?: boolean; /** * * @type {Date} - * @memberof Solution + * @memberof SolutionDto */ ratingDate?: Date; /** * * @type {string} - * @memberof Solution + * @memberof SolutionDto */ lecturerComment?: string; } -/** - * - * @export - * @interface SolutionActualityDto - */ -export interface SolutionActualityDto { - /** - * - * @type {SolutionActualityPart} - * @memberof SolutionActualityDto - */ - commitsActuality?: SolutionActualityPart; - /** - * - * @type {SolutionActualityPart} - * @memberof SolutionActualityDto - */ - testsActuality?: SolutionActualityPart; -} -/** - * - * @export - * @interface SolutionActualityPart - */ -export interface SolutionActualityPart { - /** - * - * @type {boolean} - * @memberof SolutionActualityPart - */ - isActual?: boolean; - /** - * - * @type {string} - * @memberof SolutionActualityPart - */ - comment?: string; - /** - * - * @type {string} - * @memberof SolutionActualityPart - */ - additionalData?: string; -} /** * * @export @@ -2205,25 +2205,6 @@ export interface SolutionViewModel { */ ratingDate?: Date; } -/** - * - * @export - * @interface StatisticsCourseHomeworksModel - */ -export interface StatisticsCourseHomeworksModel { - /** - * - * @type {number} - * @memberof StatisticsCourseHomeworksModel - */ - id?: number; - /** - * - * @type {Array} - * @memberof StatisticsCourseHomeworksModel - */ - tasks?: Array; -} /** * * @export @@ -2256,10 +2237,10 @@ export interface StatisticsCourseMatesModel { reviewers?: Array; /** * - * @type {Array} + * @type {Array} * @memberof StatisticsCourseMatesModel */ - homeworks?: Array; + homeworks?: Array; } /** * @@ -2286,25 +2267,6 @@ export interface StatisticsCourseMeasureSolutionModel { */ publicationDate?: Date; } -/** - * - * @export - * @interface StatisticsCourseTasksModel - */ -export interface StatisticsCourseTasksModel { - /** - * - * @type {number} - * @memberof StatisticsCourseTasksModel - */ - id?: number; - /** - * - * @type {Array} - * @memberof StatisticsCourseTasksModel - */ - solution?: Array; -} /** * * @export @@ -2432,6 +2394,44 @@ export enum StudentIdType { NUMBER_1 = 1, NUMBER_2 = 2 } +/** + * + * @export + * @interface StudentSolutionsTableHomeworkDto + */ +export interface StudentSolutionsTableHomeworkDto { + /** + * + * @type {number} + * @memberof StudentSolutionsTableHomeworkDto + */ + id?: number; + /** + * + * @type {Array} + * @memberof StudentSolutionsTableHomeworkDto + */ + tasks?: Array; +} +/** + * + * @export + * @interface StudentSolutionsTableTaskDto + */ +export interface StudentSolutionsTableTaskDto { + /** + * + * @type {number} + * @memberof StudentSolutionsTableTaskDto + */ + id?: number; + /** + * + * @type {Array} + * @memberof StudentSolutionsTableTaskDto + */ + solutions?: Array; +} /** * * @export @@ -8336,7 +8336,7 @@ export const SolutionsApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - solutionsGetSolutionById(solutionId: number, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + solutionsGetSolutionById(solutionId: number, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = SolutionsApiFetchParamCreator(configuration).solutionsGetSolutionById(solutionId, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { diff --git a/hwproj.front/src/components/Courses/Course.tsx b/hwproj.front/src/components/Courses/Course.tsx index a8744fee3..5440ded7c 100644 --- a/hwproj.front/src/components/Courses/Course.tsx +++ b/hwproj.front/src/components/Courses/Course.tsx @@ -165,7 +165,7 @@ const Course: React.FC = () => { const unratedSolutionsCount = (studentSolutions || []) .flatMap(x => x.homeworks) .flatMap(x => x!.tasks) - .filter(t => t!.solution!.slice(-1)[0]?.state === 0) //last solution + .filter(t => t!.solutions!.slice(-1)[0]?.state === 0) //last solution .length const [lecturerStatsState, setLecturerStatsState] = useState(false); diff --git a/hwproj.front/src/components/Courses/CourseExperimental.tsx b/hwproj.front/src/components/Courses/CourseExperimental.tsx index a14a8fe5e..138b4f225 100644 --- a/hwproj.front/src/components/Courses/CourseExperimental.tsx +++ b/hwproj.front/src/components/Courses/CourseExperimental.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import { FileInfoDTO, HomeworkTaskViewModel, - HomeworkViewModel, Solution, StatisticsCourseMatesModel, + HomeworkViewModel, SolutionDto, StatisticsCourseMatesModel, } from "@/api"; import { AlertTitle, @@ -165,14 +165,14 @@ export const CourseExperimental: FC = (props) => { const getStyle = (itemIsHomework: boolean, itemId: number) => itemIsHomework === isHomework && itemId === id ? clickedItemStyle : {borderRadius: 9} - const taskSolutionsMap = new Map() + const taskSolutionsMap = new Map() if (!isMentor && isStudentAccepted) { studentSolutions .filter(t => t.id === userId) .flatMap(t => t.homeworks!) .flatMap(t => t.tasks!) - .forEach(x => taskSolutionsMap.set(x.id!, x.solution!)) + .forEach(x => taskSolutionsMap.set(x.id!, x.solutions!)) } const showWarningsForEntity = (entity: HomeworkViewModel | HomeworkTaskViewModel, isHomework: boolean) => { diff --git a/hwproj.front/src/components/Courses/Statistics/StudentProgressChart.tsx b/hwproj.front/src/components/Courses/Statistics/StudentProgressChart.tsx index d298f762a..e0c17bc40 100644 --- a/hwproj.front/src/components/Courses/Statistics/StudentProgressChart.tsx +++ b/hwproj.front/src/components/Courses/Statistics/StudentProgressChart.tsx @@ -5,7 +5,7 @@ import { HomeworkViewModel, StatisticsCourseMatesModel, StatisticsCourseMeasureSolutionModel, - StatisticsCourseTasksModel + StudentSolutionsTableTaskDto } from "../../../api/"; import StudentStatsTooltip, { ITaskChartView } from './StudentStatsTooltip'; import Utils from "../../../services/Utils"; @@ -112,17 +112,17 @@ const StudentProgressChart: React.FC = (props) => { const tasks = cm.homeworks! .filter(hw => hw.tasks && hw.tasks.length > 0) .flatMap(hw => hw.tasks!) - .filter(t => t.solution && StudentStatsUtils.calculateLastRatedSolution(t.solution) != undefined) + .filter(t => t.solutions && StudentStatsUtils.calculateLastRatedSolution(t.solutions) != undefined) tasks.sort((x, y) => { - const xLastSolutionDate = x.solution!.slice(-1)[0].publicationDate!; - const yLastSolutionDate = y.solution!.slice(-1)[0].publicationDate!; + const xLastSolutionDate = x.solutions!.slice(-1)[0].publicationDate!; + const yLastSolutionDate = y.solutions!.slice(-1)[0].publicationDate!; return compareDates(xLastSolutionDate, yLastSolutionDate); }) - const tasksGroupedByLastSolution = new Map() + const tasksGroupedByLastSolution = new Map() tasks.forEach(task => { - const lastSolution = task.solution!.filter(s => s.state != SolutionState.NUMBER_0).slice(-1)[0]; + const lastSolution = task.solutions!.filter(s => s.state != SolutionState.NUMBER_0).slice(-1)[0]; const publicationDate = new Date(lastSolution.publicationDate!); publicationDate.setHours(0, 0, 0, 0); const publicationDateTime = publicationDate.getTime(); @@ -148,10 +148,10 @@ const StudentProgressChart: React.FC = (props) => { let totalStudentRating = 0; const points : IChartPoint[] = taskGroups.map(tasks => { - const date = new Date(tasks[0].solution!.slice(-1)[0].publicationDate!); + const date = new Date(tasks[0].solutions!.slice(-1)[0].publicationDate!); date.setHours(0, 0, 0, 0); const tasksChartView : ITaskChartView[] = tasks.map(task => { - const lastSolution = task.solution!.filter(s => s.state != SolutionState.NUMBER_0).slice(-1)[0]; + const lastSolution = task.solutions!.filter(s => s.state != SolutionState.NUMBER_0).slice(-1)[0]; totalStudentRating += lastSolution.rating ? lastSolution.rating : 0; const taskView = courseTasks.find(t => t.id === task.id)!; diff --git a/hwproj.front/src/components/Courses/Statistics/StudentPunctualityChart.tsx b/hwproj.front/src/components/Courses/Statistics/StudentPunctualityChart.tsx index ae6e72be2..5db9dfc04 100644 --- a/hwproj.front/src/components/Courses/Statistics/StudentPunctualityChart.tsx +++ b/hwproj.front/src/components/Courses/Statistics/StudentPunctualityChart.tsx @@ -192,7 +192,7 @@ const StudentPunctualityChart : React.FC = (props ([deadlines, prev], task, i) => { const courseTask = tasks.find(t => t.id === task.id)!; const deadlineDate = courseTask.deadlineDate!; - const dates = [...task.solution!.map(s => s.publicationDate!), deadlineDate]; + const dates = [...task.solutions!.map(s => s.publicationDate!), deadlineDate]; const deadlineOrder = dates.sort((x, y) => new Date(x).getTime() - new Date(y).getTime()) .findIndex(d => new Date(d).getTime() == new Date(deadlineDate).getTime()); @@ -206,7 +206,7 @@ const StudentPunctualityChart : React.FC = (props const deadlineTick = taskDeadlines.get(task.id!)!; const deadlineDate = tasks.find(t => t.id === task.id)!.deadlineDate!; acc.set(deadlineTick, new Date(deadlineDate).getTime()); - task.solution!.forEach((solution, index) => { + task.solutions!.forEach((solution, index) => { const tick = leftBorder + index + 1; const actualTick = tick >= deadlineTick ? tick + 1 : tick; acc.set(actualTick, new Date(solution.publicationDate!).getTime()) @@ -224,7 +224,7 @@ const StudentPunctualityChart : React.FC = (props const courseTask = tasks.find(t => t.id === task.id)!; const deadlineDate = courseTask.deadlineDate!; const maxRating = courseTask.maxRating!; - const taskSolutions = task.solution!; + const taskSolutions = task.solutions!; const attempts = taskSolutions.reduce((currentAcc : IStudentAttempt[], solution, index) => { const tick = leftBorder + index + 1; @@ -252,10 +252,10 @@ const StudentPunctualityChart : React.FC = (props const sectorItems = [...attempts, deadlineFill] .sort((a, b) => a.xAxisPosition - b.xAxisPosition); - const diff = props.sectorSizes[i]-task.solution!.length + const diff = props.sectorSizes[i]-task.solutions!.length const trailingFill : IStudentAttempt[] = new Array(Math.max(diff, 0)).fill(0) .reduce((acc, _, i) => { - const x = leftBorder + task.solution!.length + 2 + i + const x = leftBorder + task.solutions!.length + 2 + i return [...acc, {xAxisPosition: x, yAxisPosition: null}] }, []) diff --git a/hwproj.front/src/components/Courses/Statistics/StudentStatsChart.tsx b/hwproj.front/src/components/Courses/Statistics/StudentStatsChart.tsx index 10b7720ea..30b703bbb 100644 --- a/hwproj.front/src/components/Courses/Statistics/StudentStatsChart.tsx +++ b/hwproj.front/src/components/Courses/Statistics/StudentStatsChart.tsx @@ -3,7 +3,7 @@ import {Link, useParams} from 'react-router-dom'; import {Grid, Box, Typography, Paper} from "@mui/material"; import { CourseViewModel, HomeworkTaskViewModel, - HomeworkViewModel, StatisticsCourseHomeworksModel, + HomeworkViewModel, StudentSolutionsTableHomeworkDto, StatisticsCourseMatesModel, StatisticsCourseMeasureSolutionModel } from "@/api"; @@ -43,10 +43,10 @@ const StudentStatsChart: React.FC = () => { averageStudent: [] }) const [sectorSizes, setSectorSizes] = useState([]); - const tasksSolutionLength = (hw: StatisticsCourseHomeworksModel[], tasksWithDeadline: HomeworkTaskViewModel[]) => + const tasksSolutionLength = (hw: StudentSolutionsTableHomeworkDto[], tasksWithDeadline: HomeworkTaskViewModel[]) => hw.flatMap(h => h.tasks! .filter(task => tasksWithDeadline.find(t => t.id === task.id)) - .map(t => t.solution!.length)) + .map(t => t.solutions!.length)) const handleStudentSelection = (studentIds: string[]) => { const newSectorSizes = sectorSizes.map((_, i) => { const taskSectorSizes = studentIds.map(id => { diff --git a/hwproj.front/src/components/Courses/Statistics/StudentsRadarChart.tsx b/hwproj.front/src/components/Courses/Statistics/StudentsRadarChart.tsx index 566bad926..5edbd126c 100644 --- a/hwproj.front/src/components/Courses/Statistics/StudentsRadarChart.tsx +++ b/hwproj.front/src/components/Courses/Statistics/StudentsRadarChart.tsx @@ -29,7 +29,7 @@ export const StudentsRadarChart: FC<{ data: metrics .map(m => x.homeworks!.find(t => t.id === m.id)) .map(x => x!.tasks! - .flatMap(y => StudentStatsUtils.calculateLastRatedSolution(y.solution!)?.rating || 0) + .flatMap(y => StudentStatsUtils.calculateLastRatedSolution(y.solutions!)?.rating || 0) .reduce((a, b) => a + b)) })) diff --git a/hwproj.front/src/components/Courses/StudentStats.tsx b/hwproj.front/src/components/Courses/StudentStats.tsx index 978f921d4..61e38becb 100644 --- a/hwproj.front/src/components/Courses/StudentStats.tsx +++ b/hwproj.front/src/components/Courses/StudentStats.tsx @@ -136,7 +136,7 @@ const StudentStats: React.FC = (props) => { .map(t => props.solutions! .map(s => s.homeworks! .flatMap(h1 => h1.tasks!) - .find(t1 => t1.id === t.id)?.solution || []) + .find(t1 => t1.id === t.id)?.solutions || []) .map(s => StudentStatsUtils.calculateLastRatedSolution(s)) .filter(x => x != undefined && x.rating! > 0)) .filter(x => x.length > 0) @@ -256,7 +256,7 @@ const StudentStats: React.FC = (props) => { solutions .find(s => s.id === cm.id)?.homeworks! .find(h => h.id === homework.id)?.tasks! - .flatMap(t => StudentStatsUtils.calculateLastRatedSolution(t.solution || [])?.rating || 0) || 0 + .flatMap(t => StudentStatsUtils.calculateLastRatedSolution(t.solutions || [])?.rating || 0) || 0 ) .reduce((sum, rating) => sum + rating, 0) @@ -267,7 +267,7 @@ const StudentStats: React.FC = (props) => { solutions .find(s => s.id === cm.id)?.homeworks! .find(h => h.id === homework.id)?.tasks! - .flatMap(t => StudentStatsUtils.calculateLastRatedSolution(t.solution || [])?.rating || 0) + .flatMap(t => StudentStatsUtils.calculateLastRatedSolution(t.solutions || [])?.rating || 0) || [] ) return testRatings[0]! @@ -360,7 +360,7 @@ const StudentStats: React.FC = (props) => { key={`${cm.id}-${homework.id}-${task.id}`} solutions={cm.homeworks ?.find(h => h.id === homework.id)?.tasks - ?.find(t => t.id === task.id)?.solution || []} + ?.find(t => t.id === task.id)?.solutions || []} userId={props.userId} forMentor={props.isMentor} studentId={String(cm.id)} diff --git a/hwproj.front/src/components/Solutions/StudentSolutionsPage.tsx b/hwproj.front/src/components/Solutions/StudentSolutionsPage.tsx index 57a5d7c14..a8beb199e 100644 --- a/hwproj.front/src/components/Solutions/StudentSolutionsPage.tsx +++ b/hwproj.front/src/components/Solutions/StudentSolutionsPage.tsx @@ -5,7 +5,7 @@ import { GetSolutionModel, HomeworksGroupSolutionStats, HomeworkTaskViewModel, - Solution, + SolutionDto, SolutionState, StudentDataDto, TaskSolutionsStats @@ -59,7 +59,7 @@ interface IStudentSolutionsPageState { student: StudentDataDto, solutions: GetSolutionModel[] lastSolution: GetSolutionModel, - lastRatedSolution: Solution, + lastRatedSolution: SolutionDto, color: string, ratedSolutionsCount: number, solutionsDescription: string diff --git a/hwproj.front/src/components/Solutions/TaskSolutionsPage.tsx b/hwproj.front/src/components/Solutions/TaskSolutionsPage.tsx index 865ebe999..97973d38f 100644 --- a/hwproj.front/src/components/Solutions/TaskSolutionsPage.tsx +++ b/hwproj.front/src/components/Solutions/TaskSolutionsPage.tsx @@ -5,7 +5,7 @@ import Typography from "@material-ui/core/Typography"; import AddOrEditSolution from "./AddOrEditSolution"; import Button from "@material-ui/core/Button"; import TaskSolutions from "./TaskSolutions"; -import {AccountDataDto, HomeworksGroupUserTaskSolutions, HomeworkTaskViewModel, Solution, SolutionState} from "@/api"; +import {AccountDataDto, HomeworksGroupUserTaskSolutions, HomeworkTaskViewModel, SolutionDto, SolutionState} from "@/api"; import ApiSingleton from "../../api/ApiSingleton"; import {Grid, Tab, Tabs} from "@material-ui/core"; import {Checkbox, Chip, SelectChangeEvent, Stack, Tooltip} from "@mui/material"; @@ -164,7 +164,7 @@ const TaskSolutionsPage: FC = () => { })) } - const renderRatingChip = (solutionsDescription: string, color: string, lastRatedSolution: Solution) => { + const renderRatingChip = (solutionsDescription: string, color: string, lastRatedSolution: SolutionDto) => { return {solutionsDescription}}> = (props) => { diff --git a/hwproj.front/src/services/StudentStatsUtils.ts b/hwproj.front/src/services/StudentStatsUtils.ts index bcb6708ad..3597c9948 100644 --- a/hwproj.front/src/services/StudentStatsUtils.ts +++ b/hwproj.front/src/services/StudentStatsUtils.ts @@ -1,4 +1,4 @@ -import {Solution, SolutionState} from "../api"; +import {SolutionDto, SolutionState} from "@/api"; import {colorBetween} from "./JsUtils"; import Utils from "./Utils"; @@ -17,12 +17,12 @@ export default class StudentStatsUtils { : "#ffffff" } - static calculateLastRatedSolution(solutions: Solution[]){ + static calculateLastRatedSolution(solutions: SolutionDto[]){ const ratedSolutions = solutions!.filter(x => x.state !== SolutionState.NUMBER_0) return ratedSolutions.slice(-1)[0] } - static calculateLastRatedSolutionInfo(solutions: Solution[], taskMaxRating: number) { + static calculateLastRatedSolutionInfo(solutions: SolutionDto[], taskMaxRating: number) { const ratedSolutions = solutions!.filter(x => x.state !== SolutionState.NUMBER_0) const ratedSolutionsCount = ratedSolutions.length const isFirstUnratedTry = ratedSolutionsCount === 0 From 2738f1a7dd18ba8cb048ec4c6dc9123f4315a36f Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Sun, 22 Mar 2026 04:49:47 +0300 Subject: [PATCH 2/3] docker-compose --- docker-compose.override.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 175487bd7..10e1ecfee 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -65,9 +65,9 @@ services: hwproj.coursesservice.api: environment: - - ConnectionStrings:DefaultConnectionForLinux=Server=mssqllocaldb;Database=CourseWorksServiceDB;MultipleActiveResultSets=True;User=sa;Password=Your_password123; + - ConnectionStrings:DefaultConnectionForLinux=Server=mssqllocaldb;Database=CourseWorksServiceDB;MultipleActiveResultSets=True;User=sa;Password=Your_password123;TrustServerCertificate=true; - ASPNETCORE_ENVIRONMENT=Production - - ASPNETCORE_HTTP_PORTS=80 + - ASPNETCORE_URLS=http://+:80 - EventBus:EventBusHostName=rabbitmq - Services:Auth=http://hwproj.authservice.api - Services:Content=http://hwproj.contentservice.api From a27772a897ddafc0038b1eaed8f828249970f5f4 Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Sun, 22 Mar 2026 04:53:57 +0300 Subject: [PATCH 3/3] dockerfiles --- HwProj.APIGateway/HwProj.APIGateway.API/Dockerfile | 1 - HwProj.AuthService/HwProj.AuthService.API/Dockerfile | 1 - HwProj.ContentService/HwProj.ContentService.API/Dockerfile | 1 - 3 files changed, 3 deletions(-) diff --git a/HwProj.APIGateway/HwProj.APIGateway.API/Dockerfile b/HwProj.APIGateway/HwProj.APIGateway.API/Dockerfile index dc0142c63..c288fdbd0 100644 --- a/HwProj.APIGateway/HwProj.APIGateway.API/Dockerfile +++ b/HwProj.APIGateway/HwProj.APIGateway.API/Dockerfile @@ -6,7 +6,6 @@ COPY ["Directory.Build.props", "Directory.Build.props"] COPY ["HwProj.APIGateway/HwProj.APIGateway.API/", "HwProj.APIGateway/HwProj.APIGateway.API/"] COPY ["HwProj.NotificationsService/HwProj.NotificationsService.Client/", "HwProj.NotificationsService/HwProj.NotificationsService.Client/"] COPY ["HwProj.Common/HwProj.Models/", "HwProj.Common/HwProj.Models/"] -COPY ["HwProj.Common/HwProj.Repositories/", "HwProj.Common/HwProj.Repositories/"] COPY ["HwProj.Common/HwProj.HttpUtils/", "HwProj.Common/HwProj.HttpUtils/"] COPY ["HwProj.Common/HwProj.Utils/", "HwProj.Common/HwProj.Utils/"] COPY ["HwProj.EventBus/HwProj.EventBus.Client/", "HwProj.EventBus/HwProj.EventBus.Client/"] diff --git a/HwProj.AuthService/HwProj.AuthService.API/Dockerfile b/HwProj.AuthService/HwProj.AuthService.API/Dockerfile index a54124dd0..1847054b3 100644 --- a/HwProj.AuthService/HwProj.AuthService.API/Dockerfile +++ b/HwProj.AuthService/HwProj.AuthService.API/Dockerfile @@ -6,7 +6,6 @@ COPY ["Directory.Build.props", "Directory.Build.props"] COPY ["HwProj.AuthService/HwProj.AuthService.API/", "HwProj.AuthService/HwProj.AuthService.API/"] COPY ["HwProj.Common/HwProj.Common.Net8/", "HwProj.Common/HwProj.Common.Net8/"] COPY ["HwProj.Common/HwProj.Models/", "HwProj.Common/HwProj.Models/"] -COPY ["HwProj.Common/HwProj.Repositories/", "HwProj.Common/HwProj.Repositories/"] COPY ["HwProj.Common/HwProj.Repositories.Net8/", "HwProj.Common/HwProj.Repositories.Net8/"] COPY ["HwProj.EventBus/HwProj.EventBus.Client/", "HwProj.EventBus/HwProj.EventBus.Client/"] COPY ["HwProj.NotificationsService/HwProj.NotificationService.Events/", "HwProj.NotificationsService/HwProj.NotificationService.Events/"] diff --git a/HwProj.ContentService/HwProj.ContentService.API/Dockerfile b/HwProj.ContentService/HwProj.ContentService.API/Dockerfile index bacb8e022..6f1c713c7 100644 --- a/HwProj.ContentService/HwProj.ContentService.API/Dockerfile +++ b/HwProj.ContentService/HwProj.ContentService.API/Dockerfile @@ -7,7 +7,6 @@ COPY ["HwProj.ContentService/HwProj.ContentService.API/", "HwProj.ContentService COPY ["HwProj.Common/HwProj.Utils/", "HwProj.Common/HwProj.Utils/"] COPY ["HwProj.EventBus/HwProj.EventBus.Client/", "HwProj.EventBus/HwProj.EventBus.Client/"] COPY ["HwProj.Common/HwProj.Models/", "HwProj.Common/HwProj.Models/"] -COPY ["HwProj.Common/HwProj.Repositories/", "HwProj.Common/HwProj.Repositories/"] WORKDIR "/src/HwProj.ContentService/HwProj.ContentService.API" RUN dotnet publish "HwProj.ContentService.API.csproj" -c Release -o /app/publish