|
@@ -10,6 +10,7 @@ using Microsoft.Extensions.Hosting;
|
|
|
using Microsoft.VisualBasic;
|
|
|
using System;
|
|
|
using System.Text.Json.Nodes;
|
|
|
+using System.Threading.Tasks;
|
|
|
|
|
|
namespace IES.ExamServer.Controllers
|
|
|
{
|
|
@@ -23,8 +24,9 @@ namespace IES.ExamServer.Controllers
|
|
|
private readonly ILogger<IndexController> _logger;
|
|
|
private readonly CenterServiceConnectionService _connectionService;
|
|
|
private readonly LiteDBFactory _liteDBFactory;
|
|
|
+ private readonly DataQueue _dataQueue;
|
|
|
public StudentController(ILogger<IndexController> logger, IConfiguration configuration, IHttpClientFactory httpClientFactory,
|
|
|
- IMemoryCache memoryCache, CenterServiceConnectionService connectionService, LiteDBFactory liteDBFactory)
|
|
|
+ IMemoryCache memoryCache, CenterServiceConnectionService connectionService, LiteDBFactory liteDBFactory, DataQueue dataQueue)
|
|
|
{
|
|
|
_logger = logger;
|
|
|
_configuration=configuration;
|
|
@@ -32,6 +34,7 @@ namespace IES.ExamServer.Controllers
|
|
|
_memoryCache=memoryCache;
|
|
|
_connectionService=connectionService;
|
|
|
_liteDBFactory=liteDBFactory;
|
|
|
+ _dataQueue=dataQueue;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 学生提交音乐作答
|
|
@@ -131,7 +134,7 @@ namespace IES.ExamServer.Controllers
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("submit-subject-result")]
|
|
|
[AuthToken("student")]
|
|
|
- public IActionResult SubmitSubjectResult(JsonNode json)
|
|
|
+ public async Task<IActionResult> SubmitSubjectResult(JsonNode json)
|
|
|
{
|
|
|
List<List<string>>? answers = json["answer"]?.ToObject<List<List<string>>>();
|
|
|
string evaluationId = $"{json["evaluationId"]}";
|
|
@@ -232,7 +235,7 @@ namespace IES.ExamServer.Controllers
|
|
|
{
|
|
|
subjectResult!.pushed=1;
|
|
|
}
|
|
|
- new SubjectPushData(result, studentResult);
|
|
|
+ await _dataQueue.TryAddAsync(new SubjectPushData(result, studentResult));
|
|
|
}
|
|
|
_liteDBFactory.GetLiteDatabase().GetCollection<EvaluationSubjectResult>().Upsert(result);
|
|
|
_liteDBFactory.GetLiteDatabase().GetCollection<EvaluationStudentResult>().Upsert(studentResult);
|