|
@@ -42,18 +42,80 @@ namespace IES.ExamServer.Controllers
|
|
|
_signalRExamServerHub=signalRExamServerHub;
|
|
|
}
|
|
|
[HttpPost("download-package")]
|
|
|
- // [AuthToken("admin","teacher")]
|
|
|
+ [AuthToken("admin","teacher")]
|
|
|
public async Task<IActionResult> DownloadPackage(JsonNode json)
|
|
|
{
|
|
|
-
|
|
|
//C#.NET 6 后端与前端流式通信
|
|
|
//https://www.doubao.com/chat/collection/687687510791426?type=Thread
|
|
|
//下载日志记录:1.步骤,检查,2.获取描述信息,3.分类型,4下载文件,5.前端处理,6.返回结果 , 正在下载...==> [INFO]https://www.doubao.com/chat/collection/687687510791426?type=Thread [Size=180kb] Ok...
|
|
|
//进度条 展示下载文件总大小和已下载,末尾展示 文件总个数和已下载个数
|
|
|
//https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/8.0.7/signalr.min.js
|
|
|
- return Ok();
|
|
|
+ /* int data = 0,blob=0,webview=0, groupList=0
|
|
|
+ {
|
|
|
+ "evaluationId":"idssss",
|
|
|
+ "shortCode":"1234567890",
|
|
|
+ "ownerId":"hbcn/tmdid",
|
|
|
+ "data":1,
|
|
|
+ "blob":1,
|
|
|
+ "webview":1,
|
|
|
+ "groupList":1
|
|
|
+ }
|
|
|
+ */
|
|
|
+ //如果要访问中心,则需要教师登录联网。
|
|
|
+ var token = GetAuthTokenInfo();
|
|
|
+ if (token.scope.Equals(ExamConstant.ScopeTeacher))
|
|
|
+ {
|
|
|
+ if (_connectionService.dataCenterIsConnected)
|
|
|
+ {
|
|
|
+ Teacher? teacher = _liteDBFactory.GetLiteDatabase().GetCollection<Teacher>().FindOne(x => x.id!.Equals(token.id));
|
|
|
+ if (teacher != null)
|
|
|
+ {
|
|
|
+ string? CenterUrl = _configuration.GetValue<string>("ExamServer:CenterUrl");
|
|
|
+ var client = _httpClientFactory.CreateClient();
|
|
|
+ if (client.DefaultRequestHeaders.Contains(Constant._X_Auth_AuthToken))
|
|
|
+ {
|
|
|
+ client.DefaultRequestHeaders.Remove(Constant._X_Auth_AuthToken);
|
|
|
+ }
|
|
|
+ client.DefaultRequestHeaders.Add(Constant._X_Auth_AuthToken, teacher.x_auth_token);
|
|
|
+ HttpResponseMessage message = await client.PostAsJsonAsync($"{CenterUrl}/blob/sas-read", new { containerName = $"{json["ownerId"]}" });
|
|
|
+ string sas = string.Empty;
|
|
|
+ string url = string.Empty;
|
|
|
+ string cnt = string.Empty;
|
|
|
+ if (message.IsSuccessStatusCode)
|
|
|
+ {
|
|
|
+ //url sas timeout name
|
|
|
+ string content = await message.Content.ReadAsStringAsync();
|
|
|
+ JsonNode? jsonNode = content.ToObject<JsonNode>();
|
|
|
+ if (jsonNode != null)
|
|
|
+ {
|
|
|
+ sas = $"{jsonNode["sas"]}";
|
|
|
+ cnt = $"{jsonNode["name"]}";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var httpClient= _httpClientFactory.CreateClient();
|
|
|
+ if ($"{json["data"]}".Equals("1"))
|
|
|
+ {
|
|
|
+ await httpClient.GetAsync($"{url}/{cnt}/exam/{json["evaluationId"]}/package/evaluation.json");
|
|
|
+ }
|
|
|
+ if ($"{json["groupList"]}".Equals("1"))
|
|
|
+ {
|
|
|
+ await httpClient.GetAsync($"{url}/{cnt}/exam/{json["evaluationId"]}/package/grouplist.json");
|
|
|
+ }
|
|
|
+ if ($"{json["blob"]}".Equals("1"))
|
|
|
+ {
|
|
|
+ await httpClient.GetAsync($"{url}/{cnt}/exam/{json["evaluationId"]}/paper");
|
|
|
+ }
|
|
|
+ if ($"{json["webview"]}".Equals("1"))
|
|
|
+ {
|
|
|
+ //await httpClient.GetAsync($"{url}/{cnt}/exam/{json["evaluationId"]}/evaluation.json");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Ok();
|
|
|
}
|
|
|
[HttpPost("check-short-code")]
|
|
|
+ [AuthToken("admin", "teacher", "visitor")]
|
|
|
public async Task<IActionResult> CheckShortCode(JsonNode json)
|
|
|
{
|
|
|
|
|
@@ -452,7 +514,23 @@ namespace IES.ExamServer.Controllers
|
|
|
status=Constant._Message_status_warning,
|
|
|
content=$"最终检测结果:总数({checkTotal}),成功({checkSuccess}),警告({checkWarning}),异常({checkError})。"
|
|
|
});
|
|
|
- return Ok(new {code=200, evaluation= evaluationLocal,data,blob,webview,dataSize,blobSize,webviewSize,status ,groupList,studentCount});
|
|
|
+ return Ok(new {
|
|
|
+ code = 200,
|
|
|
+ evaluation = evaluationLocal,
|
|
|
+ data,
|
|
|
+ blob,
|
|
|
+ webview,
|
|
|
+ dataSize,
|
|
|
+ blobSize,
|
|
|
+ webviewSize,
|
|
|
+ status,
|
|
|
+ groupList,
|
|
|
+ studentCount,
|
|
|
+ checkTotal,
|
|
|
+ checkSuccess,
|
|
|
+ checkError,
|
|
|
+ checkWarning
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -461,6 +539,7 @@ namespace IES.ExamServer.Controllers
|
|
|
/// <param name="json"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("activate-evaluation")]
|
|
|
+ [AuthToken("admin", "teacher", "visitor")]
|
|
|
public IActionResult ActivateEvaluation(JsonNode json)
|
|
|
{
|
|
|
string id = $"{json["id"]}";
|
|
@@ -481,6 +560,7 @@ namespace IES.ExamServer.Controllers
|
|
|
/// <param name="json"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("list-local-evaluation")]
|
|
|
+ [AuthToken("admin", "teacher", "visitor")]
|
|
|
public IActionResult ListLocalEvaluation(JsonNode json)
|
|
|
{
|
|
|
|