|
@@ -50,8 +50,46 @@ namespace IES.ExamServer.Controllers
|
|
|
_connectionService=connectionService;
|
|
|
_signalRExamServerHub=signalRExamServerHub;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 导出数据
|
|
|
+ ///通过线上回传数据需要鉴权验证等操作。
|
|
|
+ ///通过离线包回传数据需要加密操作
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="json"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("export-evaluation-result")]
|
|
|
+ [AuthToken("admin", "teacher", "visitor")]
|
|
|
+ public async Task<IActionResult> ExportEvaluationResult(JsonNode json)
|
|
|
+ {
|
|
|
+ string id = $"{json["evaluationId"]}";
|
|
|
+ string shortCode = $"{json["shortCode"]}";
|
|
|
+ string openCode = $"{json["openCode"]}";
|
|
|
+ string deviceId = $"{json["deviceId"]}";
|
|
|
+ EvaluationClient? evaluationClient = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>()
|
|
|
+ .FindOne(x => x.id!.Equals(id) && x.openCode!.Equals(openCode)&& x.shortCode!.Equals(shortCode));
|
|
|
+ return Ok();
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 手动推送
|
|
|
///通过线上回传数据需要鉴权验证等操作。
|
|
|
///通过离线包回传数据需要加密操作
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="json"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("manual-push")]
|
|
|
+ [AuthToken("admin", "teacher", "visitor")]
|
|
|
+ public async Task<IActionResult> ManualPush(JsonNode json)
|
|
|
+ {
|
|
|
+ string id = $"{json["evaluationId"]}";
|
|
|
+ string shortCode = $"{json["shortCode"]}";
|
|
|
+ string openCode = $"{json["openCode"]}";
|
|
|
+ string deviceId = $"{json["deviceId"]}";
|
|
|
+ EvaluationClient? evaluationClient = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>()
|
|
|
+ .FindOne(x => x.id!.Equals(id) && x.openCode!.Equals(openCode)&& x.shortCode!.Equals(shortCode));
|
|
|
+ return Ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/// <summary>
|
|
|
/// 清理缓存,列出缓存占用空间,type =list列出,type=clear清理,不能清理近期及正在激活的数据,并且提示清理中暂未上传或者导出的数据。
|
|
@@ -62,6 +100,8 @@ namespace IES.ExamServer.Controllers
|
|
|
[AuthToken("admin", "teacher", "visitor")]
|
|
|
public async Task<IActionResult> CleanCache(JsonNode json)
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
return Ok();
|
|
|
}
|
|
|
|
|
@@ -108,8 +148,8 @@ namespace IES.ExamServer.Controllers
|
|
|
EvaluationClient? evaluationClient = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().FindOne(x => x.id!.Equals(id) && x.shortCode!.Equals(shortCode));
|
|
|
if (teacher != null && evaluationClient!= null)
|
|
|
{
|
|
|
- var dataInfo= await GetEvaluationFromCenter(teacher, _configuration, _httpClientFactory, shortCode, evaluationClient.id!);
|
|
|
- if (dataInfo.centerCode.Equals("200"))
|
|
|
+ var dataInfo= await GetEvaluationFromCenter(GetXAuthToken(), _configuration, _httpClientFactory, shortCode, evaluationClient.id!);
|
|
|
+ if (dataInfo.centerCode.Equals("200")&& dataInfo.evaluationCloud!=null)
|
|
|
{
|
|
|
string? CenterUrl = _configuration.GetValue<string>("ExamServer:CenterUrl");
|
|
|
var client = _httpClientFactory.CreateClient();
|
|
@@ -255,7 +295,9 @@ namespace IES.ExamServer.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- (successMsgs, errorMsgs) = await ManageService.CheckFile(evaluationClient, successMsgs, errorMsgs, _signalRExamServerHub, _memoryCache, _logger, deviceId, evaluationPath);
|
|
|
+ _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().Upsert(dataInfo.evaluationCloud!);
|
|
|
+
|
|
|
+ (successMsgs, errorMsgs) = await ManageService.CheckFile(dataInfo.evaluationCloud!, successMsgs, errorMsgs, _signalRExamServerHub, _memoryCache, _logger, deviceId, evaluationPath);
|
|
|
//下载完成后,对数据进行检查,然后在加密压缩。
|
|
|
string zipPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "zip");
|
|
|
if (!Directory.Exists(zipPath))
|
|
@@ -264,6 +306,7 @@ namespace IES.ExamServer.Controllers
|
|
|
}
|
|
|
string zipFilePath = Path.Combine(zipPath, $"{evaluationClient.id}-{evaluationClient.blobHash}.zip");
|
|
|
var zipInfo = ZipHelper.CreatePasswordProtectedZip(evaluationPath, zipFilePath, evaluationClient.openCode!);
|
|
|
+
|
|
|
if (zipInfo.res)
|
|
|
{
|
|
|
successMsgs.Add("评测数据压缩包创建成功!");
|
|
@@ -451,7 +494,7 @@ namespace IES.ExamServer.Controllers
|
|
|
Teacher? teacher = _liteDBFactory.GetLiteDatabase().GetCollection<Teacher>().FindOne(x => x.id!.Equals(token.id));
|
|
|
if (teacher != null)
|
|
|
{
|
|
|
- (evaluationCloud, centerCode, centerMsg)= await ManageService.GetEvaluationFromCenter(teacher, _configuration,_httpClientFactory,shortCode,evaluationId);
|
|
|
+ (evaluationCloud, centerCode, centerMsg)= await ManageService.GetEvaluationFromCenter(GetXAuthToken(), _configuration,_httpClientFactory,shortCode,evaluationId);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -788,6 +831,7 @@ namespace IES.ExamServer.Controllers
|
|
|
subjectName=subject.subjectName,
|
|
|
paperId=studentPaper.paperId,
|
|
|
paperName=studentPaper.paperName,
|
|
|
+ questionCount=studentPaper.questionCount,
|
|
|
id=id,
|
|
|
});
|
|
|
// 移动到下一个试卷
|
|
@@ -834,9 +878,8 @@ namespace IES.ExamServer.Controllers
|
|
|
type= evaluationClient.type,
|
|
|
pid= evaluationClient.pid,
|
|
|
};
|
|
|
- var studentPapers = roundStudentPapers.FindAll(x => !string.IsNullOrWhiteSpace(x.studentId) && x.studentId.Equals(member.id)
|
|
|
- &&!string.IsNullOrWhiteSpace(x.evaluationId) && x.evaluationId.Equals(evaluationClient.id));
|
|
|
-
|
|
|
+ var studentPapers = roundStudentPapers.FindAll(x => !string.IsNullOrWhiteSpace(x.studentId)
|
|
|
+ && x.studentId.Equals(member.id) &&!string.IsNullOrWhiteSpace(x.evaluationId) && x.evaluationId.Equals(evaluationClient.id));
|
|
|
if (studentPapers.IsNotEmpty())
|
|
|
{
|
|
|
foreach (var studentPaper in studentPapers)
|
|
@@ -851,6 +894,7 @@ namespace IES.ExamServer.Controllers
|
|
|
subjectName = studentPaper.subjectName,
|
|
|
paperId = studentPaper.paperId,
|
|
|
paperName = studentPaper.paperName,
|
|
|
+ questionCount=studentPaper.questionCount,
|
|
|
createTime=now
|
|
|
});
|
|
|
}
|
|
@@ -863,8 +907,8 @@ namespace IES.ExamServer.Controllers
|
|
|
studentResult.studentName = member.name;
|
|
|
studentResult.classId = member.classId;
|
|
|
studentResult.className = member.className;
|
|
|
- var studentPapers = roundStudentPapers.FindAll(x => !string.IsNullOrWhiteSpace(x.studentId) && x.studentId.Equals(member.id)
|
|
|
- &&!string.IsNullOrWhiteSpace(x.evaluationId) && x.evaluationId.Equals(evaluationClient.id));
|
|
|
+ var studentPapers = roundStudentPapers.FindAll(x => !string.IsNullOrWhiteSpace(x.studentId)
|
|
|
+ && x.studentId.Equals(member.id) &&!string.IsNullOrWhiteSpace(x.evaluationId) && x.evaluationId.Equals(evaluationClient.id));
|
|
|
if (studentPapers.IsNotEmpty())
|
|
|
{
|
|
|
foreach (var studentPaper in studentPapers)
|
|
@@ -883,24 +927,13 @@ namespace IES.ExamServer.Controllers
|
|
|
subjectName = studentPaper.subjectName,
|
|
|
paperId = studentPaper.paperId,
|
|
|
paperName = studentPaper.paperName,
|
|
|
+ questionCount= studentPaper.questionCount,
|
|
|
createTime=now
|
|
|
};
|
|
|
- //studentResult.subjectResults.Add();
|
|
|
}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // subjectResult.evaluationId = studentPaper.evaluationId;
|
|
|
- // subjectResult.examId = studentPaper.examId;
|
|
|
- // subjectResult.examName = studentPaper.examName;
|
|
|
- // subjectResult.subjectId = studentPaper.subjectId;
|
|
|
- // subjectResult.subjectName = studentPaper.subjectName;
|
|
|
- // subjectResult.paperId = studentPaper.paperId;
|
|
|
- // subjectResult.paperName = studentPaper.paperName;
|
|
|
- //}
|
|
|
studentResult.subjectResults.Add(subjectResult);
|
|
|
}
|
|
|
}
|
|
|
- //_liteDBFactory.GetLiteDatabase().GetCollection<EvaluationStudentResult>().Upsert(studentResult);
|
|
|
}
|
|
|
if (studentResult!=null)
|
|
|
{
|
|
@@ -909,10 +942,6 @@ namespace IES.ExamServer.Controllers
|
|
|
}
|
|
|
if (results.Count>0)
|
|
|
{
|
|
|
- //foreach (var item in results)
|
|
|
- //{
|
|
|
- // item.subjectResults= item.subjectResults.DistinctBy(x => x.id).ToList();
|
|
|
- //}
|
|
|
_liteDBFactory.GetLiteDatabase().GetCollection<EvaluationStudentResult>().Upsert(results);
|
|
|
}
|
|
|
}
|