Skip to content

Commit cf923f2

Browse files
committed
wip
1 parent 7390382 commit cf923f2

80 files changed

Lines changed: 394 additions & 337 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

HwProj.APIGateway/HwProj.APIGateway.API/Controllers/SolutionsController.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using HwProj.APIGateway.API.Models.Solutions;
88
using HwProj.AuthService.Client;
99
using HwProj.CoursesService.Client;
10-
using HwProj.Models.AuthService.DTO;
1110
using HwProj.Models.CoursesService;
1211
using HwProj.Models.CoursesService.DTO;
1312
using HwProj.Models.CoursesService.ViewModels;
@@ -38,7 +37,7 @@ public SolutionsController(ISolutionsServiceClient solutionsClient, IAuthService
3837
}
3938

4039
[HttpGet("{solutionId}")]
41-
[ProducesResponseType(typeof(Solution), (int)HttpStatusCode.OK)]
40+
[ProducesResponseType(typeof(SolutionDto), (int)HttpStatusCode.OK)]
4241
public async Task<IActionResult> GetSolutionById(long solutionId)
4342
{
4443
var result = await _solutionsClient.GetSolutionById(solutionId);
@@ -78,7 +77,7 @@ public async Task<IActionResult> GetStudentSolution(long taskId, string studentI
7877

7978
var mentorIds = studentSolutions.Values
8079
.SelectMany(t => t.Tasks)
81-
.SelectMany(t => t.Solution)
80+
.SelectMany(t => t.Solutions)
8281
.Select(t => t.LecturerId ?? "")
8382
.Where(x => x != "")
8483
.Distinct()
@@ -88,7 +87,7 @@ public async Task<IActionResult> GetStudentSolution(long taskId, string studentI
8887

8988
var solutionsGroupsIds = studentSolutions.Values
9089
.SelectMany(t => t.Tasks)
91-
.First(x => x.Id == taskId).Solution
90+
.First(x => x.Id == taskId).Solutions
9291
.Select(s => s.GroupId)
9392
.Distinct()
9493
.ToList();
@@ -120,7 +119,7 @@ public async Task<IActionResult> GetStudentSolution(long taskId, string studentI
120119
Title = task.Title,
121120
Tags = task.Tags,
122121
TaskId = task.Id.ToString(),
123-
Solutions = t.Solution.Select(s => new GetSolutionModel(s,
122+
Solutions = t.Solutions.Select(s => new GetSolutionModel(s,
124123
s.TaskId == taskId && s.GroupId is { } groupId
125124
? solutionsGroups[groupId].StudentsIds
126125
.Select(x => accountsCache[x])
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using HwProj.Models.AuthService.DTO;
4-
using HwProj.Models.StatisticsService;
4+
using HwProj.Models.SolutionsService;
55

66
namespace HwProj.APIGateway.API.Models.Statistics;
77

@@ -11,5 +11,5 @@ public class StatisticsCourseMatesModel
1111
public string Name { get; set; }
1212
public string Surname { get; set; }
1313
public AccountDataDto[] Reviewers { get; set; } = Array.Empty<AccountDataDto>();
14-
public List<StatisticsCourseHomeworksModel> Homeworks { get; set; } = new();
14+
public List<StudentSolutionsTableHomeworkDto> Homeworks { get; set; } = new();
1515
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Microsoft.AspNetCore.Http;
2+
3+
namespace HwProj.Common.Net8;
4+
5+
public static class AuthExtensions
6+
{
7+
public static string? GetUserIdFromHeader(this HttpRequest request) =>
8+
request.Headers.TryGetValue("UserId", out var id) ? id.FirstOrDefault() : null;
9+
}

HwProj.Common/HwProj.Models/HwProj.Models.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
<PackageReference Include="File.TypeChecker" Version="3.0.0" />
1111
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="2.2.0" />
1212
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
13-
</ItemGroup>
14-
15-
<ItemGroup>
16-
<ProjectReference Include="..\HwProj.Repositories\HwProj.Repositories.csproj" />
13+
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
1714
</ItemGroup>
1815

1916
</Project>

HwProj.Common/HwProj.Models/SolutionsService/GetSolutionModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace HwProj.Models.SolutionsService
66
{
77
public class GetSolutionModel
88
{
9-
public GetSolutionModel(Solution model, AccountDataDto[]? groupMates, AccountDataDto? lecturer)
9+
public GetSolutionModel(SolutionDto model, AccountDataDto[]? groupMates, AccountDataDto? lecturer)
1010
{
1111
Id = model.Id;
1212
GithubUrl = model.GithubUrl;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
3+
namespace HwProj.Models.SolutionsService
4+
{
5+
public class SolutionDto
6+
{
7+
public long Id { get; set; }
8+
public string GithubUrl { get; set; }
9+
public string Comment { get; set; }
10+
public SolutionState State { get; set; }
11+
public int Rating { get; set; }
12+
public string StudentId { get; set; }
13+
public string? LecturerId { get; set; }
14+
public long? GroupId { get; set; }
15+
public long TaskId { get; set; }
16+
public DateTime PublicationDate { get; set; }
17+
public bool IsModified { get; set; }
18+
public DateTime? RatingDate { get; set; }
19+
public string LecturerComment { get; set; }
20+
}
21+
}

HwProj.Common/HwProj.Models/SolutionsService/StudentSolutions.cs renamed to HwProj.Common/HwProj.Models/SolutionsService/StudentSolutionsDto.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
namespace HwProj.Models.SolutionsService
22
{
3-
public class StudentSolutions
3+
public class StudentSolutionsDto
44
{
55
public string StudentId { get; set; }
6-
public Solution[] Solutions { get; set; }
6+
public SolutionDto[] Solutions { get; set; }
77
}
88
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Collections.Generic;
2+
3+
namespace HwProj.Models.SolutionsService
4+
{
5+
public class StudentSolutionsTableDto
6+
{
7+
public string StudentId { get; set; }
8+
public List<StudentSolutionsTableHomeworkDto> Homeworks { get; set; }
9+
}
10+
11+
public class StudentSolutionsTableHomeworkDto
12+
{
13+
public long Id { get; set; }
14+
public List<StudentSolutionsTableTaskDto> Tasks { get; set; } = new List<StudentSolutionsTableTaskDto>();
15+
}
16+
17+
public class StudentSolutionsTableTaskDto
18+
{
19+
public long Id { get; set; }
20+
public List<SolutionDto> Solutions { get; set; } = new List<SolutionDto>();
21+
}
22+
}

HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseHomeworksModel.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

HwProj.Common/HwProj.Models/StatisticsService/StatisticsCourseMatesDTO.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)