|
@@ -48,6 +48,7 @@ using Azure.Storage.Blobs.Models;
|
|
|
using Top.Api;
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
using System.IO;
|
|
|
+using DocumentFormat.OpenXml.Office2010.Excel;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
|
{
|
|
@@ -218,6 +219,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
exam = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
|
|
|
await BIStats.SetTypeAddStats(client, _dingDing, exam.school, "Exam", 1);//BI统计增/减量
|
|
|
+ //await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client = "web/hiteach", count = 1, id = "评测id", key = "exam-submit", name = "评测名称", scope = "schoo/teacher", target = "hbcn/tmdid" });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -496,9 +498,15 @@ namespace TEAMModelOS.Controllers
|
|
|
try
|
|
|
{
|
|
|
if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
- var client = _azureCosmos.GetCosmosClient();
|
|
|
+ //if (request.TryGetProperty("period", out JsonElement period)) return BadRequest();
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ //if (!request.TryGetProperty("userId", out JsonElement userId)) return BadRequest();
|
|
|
+ //if (!request.TryGetProperty("school", out JsonElement school)) return BadRequest();
|
|
|
+ var (userId, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
+
|
|
|
+
|
|
|
StringBuilder stringBuilder = new($"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime,c.source, c.subjects, c.grades,c.owner, c.scope,c.classes, c.stuLists, c.sRate,c.lostStu,c.sStatus,c.qamode,c.school,c.cloudas from c where (c.status<>404 or IS_DEFINED(c.status) = false) ");
|
|
|
- if (request.TryGetProperty("classIds", out JsonElement classIds))
|
|
|
+ /*if (request.TryGetProperty("classIds", out JsonElement classIds))
|
|
|
{
|
|
|
List<string> ids = classIds.ToObject<List<string>>();
|
|
|
HashSet<string> strs = new HashSet<string>();
|
|
@@ -516,7 +524,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
string ss = string.Join(" or ", strs);
|
|
|
stringBuilder.Append($" and {ss}");
|
|
|
- };
|
|
|
+ };*/
|
|
|
//开始时间,
|
|
|
if (request.TryGetProperty("stime", out JsonElement stime))
|
|
|
{
|
|
@@ -538,6 +546,39 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
stringBuilder.Append($" and c.period.id = '{period}' ");
|
|
|
}
|
|
|
+ if (request.TryGetProperty("opt", out JsonElement opt))
|
|
|
+ {
|
|
|
+ if (opt.GetString().Equals("private"))
|
|
|
+ {
|
|
|
+ //针对于个人活动获取教师 任教或者助教大名单
|
|
|
+ var groupList = await GroupListService.GetTeacherTeachGroupList(_coreAPIHttpService, client, _dingDing, userId, school, period.GetString());
|
|
|
+ List<string> ids = new();
|
|
|
+ foreach (var groups in groupList) {
|
|
|
+ foreach (var gp in groups.groups) {
|
|
|
+ ids.Add(gp.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ HashSet<string> strs = new HashSet<string>();
|
|
|
+ if (ids.Count > 1)
|
|
|
+ {
|
|
|
+ foreach (string id in ids)
|
|
|
+ {
|
|
|
+ strs.Add($"array_contains(c.classes,'{id}') or array_contains(c.stuLists,'{id}')");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string ssr = ids.Count > 0 ? ids[0] : "";
|
|
|
+ strs.Add($"array_contains(c.classes,'{ssr}') or array_contains(c.stuLists,'{ssr}')");
|
|
|
+ }
|
|
|
+ string ss = string.Join(" or ", strs);
|
|
|
+ stringBuilder.Append($" and {ss}");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ stringBuilder.Append($" and c.code = 'Exam-{code}' ");
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
if (request.TryGetProperty("name", out JsonElement name) && !string.IsNullOrWhiteSpace($"{name}"))
|
|
|
{
|
|
|
stringBuilder.Append($" and Contains( c.name , '{name}') = true ");
|
|
@@ -578,7 +619,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
List<ExamInfo> examInfo = new List<ExamInfo>();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Exam-{code}") }))
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout }))
|
|
|
{
|
|
|
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|