Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
9f10167
wip
DedSec256 Oct 22, 2022
7a94bca
wip
DedSec256 Oct 22, 2022
00d26c7
wip
DedSec256 Oct 22, 2022
2be37ee
wip
DedSec256 Oct 22, 2022
b0e4360
wip
DedSec256 Oct 22, 2022
2323eff
wip
DedSec256 Nov 1, 2022
f8c8635
StudentSolutionsPage: support students navigation
DedSec256 May 7, 2023
8ff0ea0
StudentSolutionsPage: optimize requests (#246)
DedSec256 May 7, 2023
7fc0f18
Revert "StudentSolutionsPage: optimize requests (#246)"
DedSec256 May 7, 2023
defc69c
StudentSolutionsPage: optimize requests
DedSec256 May 9, 2023
605b740
Revert "StudentSolutionsPage: optimize requests"
DedSec256 May 9, 2023
864ab1d
StudentSolutionsPage: optimize requests
DedSec256 May 13, 2023
80328f4
Cleanup
DedSec256 May 13, 2023
c0f8253
Solutions: optimize requests
DedSec256 May 13, 2023
4162715
Добавить возможность оценки задач без решения (#247)
Drein211 May 13, 2023
046ca17
refactor
YuriUfimtsev May 30, 2023
22cc4c9
fix: fix the occurred errors
YuriUfimtsev May 31, 2023
ab270f1
refactor
YuriUfimtsev May 31, 2023
361620a
refactor
YuriUfimtsev Jul 23, 2023
0525a43
refactor
YuriUfimtsev Jul 24, 2023
99cfc06
fix: correct export to google frontend bug
YuriUfimtsev Aug 17, 2023
a961e45
Fix 'range exceeds grid limits' bug
YuriUfimtsev Feb 25, 2024
5b4aeb3
fix: change min rating finding algorithm
YuriUfimtsev Feb 26, 2024
7bfabc8
rebase; change Date to PublicationDate
YuriUfimtsev Mar 2, 2024
f8e67d0
refactor; improve on-page search
YuriUfimtsev Mar 3, 2024
cd0b98f
update backend
bygu4 Apr 30, 2025
a23ffc2
update api client
bygu4 Apr 30, 2025
75290fb
update front
bygu4 Apr 30, 2025
49f277d
extend worksheet on insufficient column number
bygu4 Apr 30, 2025
fde1c21
correct typo in Startup
bygu4 May 2, 2025
aaf76e3
add sheets credentials, skip homeworks without tasks during generation
bygu4 May 2, 2025
4ff5ea6
correct table generation on empty homeworks
bygu4 May 2, 2025
c3103c3
specify sheetId on extending spreadsheet
bygu4 May 2, 2025
c99f053
debug empty table generation, update credentials
bygu4 May 3, 2025
bf14baa
add stats menu
bygu4 May 3, 2025
988beaf
add summary generation on backend
bygu4 May 3, 2025
335f0fa
correct worksheet formatting
bygu4 May 4, 2025
b532fb8
update yandex application credentials
bygu4 May 4, 2025
2c6a3e8
correct redirection from yandex auth
bygu4 May 4, 2025
9aa9169
refactor coloring font in GoogleService
bygu4 May 4, 2025
bf2ca09
add save stats action menu, refactor
bygu4 May 8, 2025
9243342
update action dialogs
bygu4 May 9, 2025
4ed022b
update error handling
bygu4 May 9, 2025
095b301
update dialog rendering
bygu4 May 9, 2025
2b79029
correct margins in dialog
bygu4 May 9, 2025
09b4d41
skip test tags on table generation
bygu4 May 9, 2025
a30e797
rebase, use DialogActions on front, correct style
bygu4 May 10, 2025
13bd4cc
correct spacing in dialog, use TextField with sheet select
bygu4 May 10, 2025
4c59b32
add CircularProgress on sheet titles fetching
bygu4 May 10, 2025
988f913
cleanup
bygu4 May 10, 2025
b18e668
improve error message displaying
bygu4 May 14, 2025
a8dec3f
update dialog labels on front, expand text fields
bygu4 May 14, 2025
b99186a
remove file name field for stats downloading, generate file name instead
bygu4 May 14, 2025
c19eea9
update google docs dialog rendering
bygu4 May 16, 2025
72eaa2d
remove redundant download table dialog, refactor, use snackbar to sho…
bygu4 May 25, 2025
44bf2c2
correct sheets service configuration on missing google credentials
bygu4 May 26, 2025
debc4b9
update api client
bygu4 Jun 8, 2025
483c0e6
use validatedCourseId
bygu4 Jun 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using AutoMapper;
using HwProj.Models.AuthService.DTO;
using HwProj.Models.AuthService.ViewModels;
using HwProj.Models.CoursesService;
using HwProj.Models.CoursesService.DTO;
using HwProj.Models.CoursesService.ViewModels;

namespace HwProj.APIGateway.API
{
Expand All @@ -15,4 +12,4 @@ public ApplicationProfile()
CreateMap<EditMentorWorkspaceDTO, CreateCourseFilterDTO>();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using HwProj.APIGateway.API.ExportServices;
using HwProj.APIGateway.API.Models.Statistics;
using HwProj.APIGateway.API.TableGenerators;
using HwProj.AuthService.Client;
using HwProj.CoursesService.Client;
using HwProj.Models.AuthService.DTO;
using HwProj.Models.CoursesService.DTO;
using HwProj.Models.CoursesService.ViewModels;
using HwProj.Models.Roles;
using HwProj.Models.Result;
using HwProj.SolutionsService.Client;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -22,13 +25,18 @@ public class StatisticsController : AggregationController
{
private readonly ISolutionsServiceClient _solutionClient;
private readonly ICoursesServiceClient _coursesClient;

public StatisticsController(ISolutionsServiceClient solutionClient, IAuthServiceClient authServiceClient,
ICoursesServiceClient coursesServiceClient) :
base(authServiceClient)
private readonly GoogleService _googleService;

public StatisticsController(
ISolutionsServiceClient solutionClient,
ICoursesServiceClient coursesServiceClient,
IAuthServiceClient authServiceClient,
GoogleService googleService)
: base(authServiceClient)
{
_solutionClient = solutionClient;
_coursesClient = coursesServiceClient;
_googleService = googleService;
}

[HttpGet("{courseId}/lecturers")]
Expand All @@ -55,9 +63,20 @@ public async Task<IActionResult> GetLecturersStatistics(long courseId)
[HttpGet("{courseId}")]
[ProducesResponseType(typeof(StatisticsCourseMatesModel[]), (int)HttpStatusCode.OK)]
public async Task<IActionResult> GetCourseStatistics(long courseId)
{
var result = await GetStatistics(courseId);
if (result == null)
{
return Forbid();
}

return Ok(result);
}

private async Task<IOrderedEnumerable<StatisticsCourseMatesModel>?> GetStatistics(long courseId)
{
var statistics = await _solutionClient.GetCourseStatistics(courseId, UserId);
if (statistics == null) return Forbid();
if (statistics == null) return null;

var studentIds = statistics.Select(t => t.StudentId).ToArray();
var getStudentsTask = AuthServiceClient.GetAccountsData(studentIds);
Expand All @@ -81,7 +100,7 @@ public async Task<IActionResult> GetCourseStatistics(long courseId)
};
}).OrderBy(t => t.Surname).ThenBy(t => t.Name);

return Ok(result);
return result;
}

[HttpGet("{courseId}/charts")]
Expand Down Expand Up @@ -123,7 +142,55 @@ public async Task<IActionResult> GetChartStatistics(long courseId)

return Ok(result);
}


/// <summary>
/// Implements file download.
/// </summary>
/// <param name="courseId">The course Id the report is based on.</param>
/// <param name="sheetName">Name of the sheet on which the report will be generated.</param>
/// <returns>File download process.</returns>
[HttpGet("getFile")]
public async Task<IActionResult> GetFile(long courseId, string sheetName)
{
var course = await _coursesClient.GetCourseById(courseId);
var statistics = await GetStatistics(courseId);
if (statistics == null || course == null) return Forbid();

var statisticStream =
await ExcelGenerator.Generate(statistics.ToList(), course, sheetName).GetAsByteArrayAsync();
return new FileContentResult(statisticStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
}

[HttpGet("getSheetTitles")]
public async Task<Result<string[]>> GetSheetTitles(string sheetUrl)
=> await _googleService.GetSheetTitles(sheetUrl);

[HttpPost("processLink")]
public Result ProcessLink(string? sheetUrl)
{
if (sheetUrl == null) return Result.Failed("Некорректная ссылка");
if (GoogleService.ParseLink(sheetUrl).Succeeded) return Result.Success();
return Result.Failed("Некорректная ссылка");
}

/// <summary>
/// Implements sending a report to the Google Sheets.
/// </summary>
/// <param name="courseId">The course Id the report is based on.</param>
/// <param name="sheetUrl">Sheet Url parameter, required to make requests to the Google Sheets.</param>
/// <param name="sheetName">Sheet Name parameter, required to make requests to the Google Sheets.</param>
/// <returns>Operation status.</returns>
[HttpGet("exportToSheet")]
public async Task<Result> ExportToGoogleSheets(
long courseId, string sheetUrl, string sheetName)
{
var course = await _coursesClient.GetCourseById(courseId);
var statistics = await GetStatistics(courseId);
if (course == null || statistics == null) return Result.Failed("Ошибка при получении статистики");
var result = await _googleService.Export(course, statistics, sheetUrl, sheetName);
return result;
}

private async Task<Dictionary<string, AccountDataDto[]>> GetStudentsToMentorsDictionary(
MentorToAssignedStudentsDTO[] mentorsToStudents)
{
Expand Down Expand Up @@ -153,4 +220,4 @@ private async Task<Dictionary<string, AccountDataDto[]>> GetStudentsToMentorsDic
);
}
}
}
}
Loading