|
@@ -1472,11 +1472,12 @@ namespace TEAMModelOS.FunctionV4
|
|
|
}*/
|
|
|
//处理人员变更时被移除的人员
|
|
|
result.lostStus = lostStu;
|
|
|
+ List<string> stuIds = examClassResults.SelectMany(x => x.studentIds).ToList();
|
|
|
if (result.lostStus.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < result.lostStus.Count; i++)
|
|
|
{
|
|
|
- if (!examClassResults[0].studentIds.Contains(result.lostStus[i]))
|
|
|
+ if (!stuIds.Contains(result.lostStus[i]))
|
|
|
{
|
|
|
result.lostStus.RemoveAt(i);
|
|
|
}
|
|
@@ -1518,154 +1519,158 @@ namespace TEAMModelOS.FunctionV4
|
|
|
{
|
|
|
errorItems.Add(item);
|
|
|
}
|
|
|
- if (errorItems.Count == 0)
|
|
|
- {
|
|
|
- // 新增逻辑 收集错题内容
|
|
|
- BlobDownloadResult index_json;
|
|
|
- if (info.scope.Equals("school"))
|
|
|
- {
|
|
|
- index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
|
|
|
- }
|
|
|
- else
|
|
|
+ try {
|
|
|
+ if (errorItems.Count == 0)
|
|
|
{
|
|
|
- index_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
|
|
|
- }
|
|
|
- //BlobDownloadResult index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
|
|
|
- JObject jo = JObject.Parse(index_json.Content.ToString());
|
|
|
- JArray array = jo.Value<JArray>("slides");
|
|
|
- List<string> urls = new();
|
|
|
- foreach (var ne in array)
|
|
|
- {
|
|
|
- if (!ne["type"].ToString().Equals("compose"))
|
|
|
+ // 新增逻辑 收集错题内容
|
|
|
+ BlobDownloadResult index_json;
|
|
|
+ if (info.scope.Equals("school"))
|
|
|
{
|
|
|
- urls.Add(ne["url"].ToString());
|
|
|
+ index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
|
|
|
}
|
|
|
- }
|
|
|
- string code = string.Empty;
|
|
|
- string pk = string.Empty;
|
|
|
- string table = "School";
|
|
|
- if (info.scope.Equals("school"))
|
|
|
- {
|
|
|
- code = $"ErrorItems-{info.school}";
|
|
|
- pk = $"Item-{info.school}";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- code = "ErrorItems";
|
|
|
- pk = $"Item-{info.creatorId}";
|
|
|
- table = "Teacher";
|
|
|
- }
|
|
|
- // 获取整体的题目ID集合
|
|
|
- List<string> ids = new();
|
|
|
- List<(string id, string pid, int level, string type, List<string> knows)> itemInfos = new();
|
|
|
- foreach (string url in urls)
|
|
|
- {
|
|
|
- string id = url.Replace(".json", "");
|
|
|
- BlobDownloadResult index_item_json;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ index_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
|
|
|
+ }
|
|
|
+ //BlobDownloadResult index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
|
|
|
+ JObject jo = JObject.Parse(index_json.Content.ToString());
|
|
|
+ JArray array = jo.Value<JArray>("slides");
|
|
|
+ List<string> urls = new();
|
|
|
+ foreach (var ne in array)
|
|
|
+ {
|
|
|
+ if (!ne["type"].ToString().Equals("compose"))
|
|
|
+ {
|
|
|
+ urls.Add(ne["url"].ToString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ string code = string.Empty;
|
|
|
+ string pk = string.Empty;
|
|
|
+ string table = "School";
|
|
|
if (info.scope.Equals("school"))
|
|
|
{
|
|
|
- index_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
|
|
|
+ code = $"ErrorItems-{info.school}";
|
|
|
+ pk = $"Item-{info.school}";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
|
|
|
+ code = "ErrorItems";
|
|
|
+ pk = $"Item-{info.creatorId}";
|
|
|
+ table = "Teacher";
|
|
|
+ }
|
|
|
+ // 获取整体的题目ID集合
|
|
|
+ List<string> ids = new();
|
|
|
+ List<(string id, string pid, int level, string type, List<string> knows)> itemInfos = new();
|
|
|
+ foreach (string url in urls)
|
|
|
+ {
|
|
|
+ string id = url.Replace(".json", "");
|
|
|
+ BlobDownloadResult index_item_json;
|
|
|
+ if (info.scope.Equals("school"))
|
|
|
+ {
|
|
|
+ index_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
|
|
|
+ }
|
|
|
+ JObject keys = JObject.Parse(index_item_json.Content.ToString());
|
|
|
+ string type = keys["exercise"].Value<string>("type");
|
|
|
+ int level = keys["exercise"].Value<int>("level");
|
|
|
+ var knowledge = keys["exercise"].Value<JArray>("knowledge")?.ToObject<List<string>>();
|
|
|
+ string pid = keys.Value<string>("pid");
|
|
|
+ itemInfos.Add((id, pid, level, type, knowledge));
|
|
|
}
|
|
|
- JObject keys = JObject.Parse(index_item_json.Content.ToString());
|
|
|
- string type = keys["exercise"].Value<string>("type");
|
|
|
- int level = keys["exercise"].Value<int>("level");
|
|
|
- var knowledge = keys["exercise"].Value<JArray>("knowledge")?.ToObject<List<string>>();
|
|
|
- string pid = keys.Value<string>("pid");
|
|
|
- itemInfos.Add((id, pid, level, type, knowledge));
|
|
|
- }
|
|
|
|
|
|
|
|
|
- /*await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, table).GetItemQueryStreamIterator(
|
|
|
- queryText: $"select c.id,c.pid,c.level,c.type from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{pk}") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ /*await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, table).GetItemQueryStreamIterator(
|
|
|
+ queryText: $"select c.id,c.pid,c.level,c.type from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{pk}") }))
|
|
|
{
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- string pid = "";
|
|
|
- if (account.TryGetProperty("pid",out JsonElement element)) {
|
|
|
- pid = element.GetString();
|
|
|
+ var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
+ {
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ string pid = "";
|
|
|
+ if (account.TryGetProperty("pid",out JsonElement element)) {
|
|
|
+ pid = element.GetString();
|
|
|
+ }
|
|
|
+ itemInfos.Add((account.GetProperty("id").GetString(), pid, account.GetProperty("level").GetInt32(), account.GetProperty("type").GetString()));
|
|
|
}
|
|
|
- itemInfos.Add((account.GetProperty("id").GetString(), pid, account.GetProperty("level").GetInt32(), account.GetProperty("type").GetString()));
|
|
|
}
|
|
|
- }
|
|
|
- }*/
|
|
|
+ }*/
|
|
|
|
|
|
- double[] point = StringHelper.ListTodouble(result.paper.point);
|
|
|
- double[,] res = StringHelper.ListToDouble(result.studentScores);
|
|
|
- var cdm = new ClouDASMatrix(res, point);
|
|
|
- //需要努力的题目
|
|
|
- var ss = cdm.StriveTopic;
|
|
|
- int n = 0;
|
|
|
- List<Task<ItemResponse<ErrorItems>>> task_error = new();
|
|
|
- List<ErrorItems> errors = new();
|
|
|
- foreach (var sIds in result.studentIds)
|
|
|
- {
|
|
|
- ErrorItems error = new()
|
|
|
+ double[] point = StringHelper.ListTodouble(result.paper.point);
|
|
|
+ double[,] res = StringHelper.ListToDouble(result.studentScores);
|
|
|
+ var cdm = new ClouDASMatrix(res, point);
|
|
|
+ //需要努力的题目
|
|
|
+ var ss = cdm.StriveTopic;
|
|
|
+ int n = 0;
|
|
|
+ List<Task<ItemResponse<ErrorItems>>> task_error = new();
|
|
|
+ List<ErrorItems> errors = new();
|
|
|
+ foreach (var sIds in result.studentIds)
|
|
|
{
|
|
|
- ttl = -1,
|
|
|
- code = code,
|
|
|
- id = Guid.NewGuid().ToString(),
|
|
|
- stuId = sIds,
|
|
|
- school = info.school,
|
|
|
- activityId = info.id,
|
|
|
- subjectId = result.subjectId,
|
|
|
- time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
- };
|
|
|
- //顺序学生错题的索引
|
|
|
- int[] item_index = ss[n];
|
|
|
- foreach (var item in item_index)
|
|
|
- {
|
|
|
- Items items = new()
|
|
|
+ ErrorItems error = new()
|
|
|
{
|
|
|
- id = urls[item - 1].Replace(".json", ""),
|
|
|
- blob = info.papers[no].blob
|
|
|
-
|
|
|
+ ttl = -1,
|
|
|
+ code = code,
|
|
|
+ id = Guid.NewGuid().ToString(),
|
|
|
+ stuId = sIds,
|
|
|
+ school = info.school,
|
|
|
+ activityId = info.id,
|
|
|
+ subjectId = result.subjectId,
|
|
|
+ time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
};
|
|
|
- items.level = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().level;
|
|
|
- items.type = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().type;
|
|
|
- items.pId = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().pid;
|
|
|
- items.knowledge = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().knows;
|
|
|
- error.its.Add(items);
|
|
|
+ //顺序学生错题的索引
|
|
|
+ int[] item_index = ss[n];
|
|
|
+ foreach (var item in item_index)
|
|
|
+ {
|
|
|
+ Items items = new()
|
|
|
+ {
|
|
|
+ id = urls[item - 1].Replace(".json", ""),
|
|
|
+ blob = info.papers[no].blob
|
|
|
+
|
|
|
+ };
|
|
|
+ items.level = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().level;
|
|
|
+ items.type = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().type;
|
|
|
+ items.pId = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().pid;
|
|
|
+ items.knowledge = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().knows;
|
|
|
+ error.its.Add(items);
|
|
|
+ }
|
|
|
+ errors.Add(error);
|
|
|
+ n++;
|
|
|
+ task_error.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(error, new PartitionKey($"{error.code}")));
|
|
|
}
|
|
|
- errors.Add(error);
|
|
|
- n++;
|
|
|
- task_error.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(error, new PartitionKey($"{error.code}")));
|
|
|
- }
|
|
|
- //string connect = _configuration.GetValue<string>("HaBookAuth:Crtmabank") + "https://malearnfunction.chinacloudsites.cn/api/crtmabank";
|
|
|
- string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
|
|
|
- string urlAction = string.Empty;
|
|
|
- if (location.Contains("China") || location.Contains("China-Dep"))
|
|
|
- {
|
|
|
- urlAction = "https://malearnfunction.chinacloudsites.cn";
|
|
|
- }
|
|
|
- else if (location.Contains("Global"))
|
|
|
- {
|
|
|
- urlAction = "https://malearnfunction.azurewebsites.net";
|
|
|
- }
|
|
|
- else if (location.Contains("Global-Test"))
|
|
|
- {
|
|
|
- urlAction = "https://malearn-test.azurewebsites.net";
|
|
|
- }
|
|
|
- string connect = $"{urlAction}/api/crtmabank";
|
|
|
- var htc = _httpClient.CreateClient();
|
|
|
- if (htc.DefaultRequestHeaders.Contains("x-functions-key"))
|
|
|
- {
|
|
|
- htc.DefaultRequestHeaders.Remove("x-functions-key");
|
|
|
+ //string connect = _configuration.GetValue<string>("HaBookAuth:Crtmabank") + "https://malearnfunction.chinacloudsites.cn/api/crtmabank";
|
|
|
+ string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
|
|
|
+ string urlAction = string.Empty;
|
|
|
+ if (location.Contains("China") || location.Contains("China-Dep") || location.Contains("China-Test"))
|
|
|
+ {
|
|
|
+ urlAction = "https://malearnfunction.chinacloudsites.cn";
|
|
|
+ }
|
|
|
+ else if (location.Contains("Global"))
|
|
|
+ {
|
|
|
+ urlAction = "https://malearnfunction.azurewebsites.net";
|
|
|
+ }
|
|
|
+ else if (location.Contains("Global-Test"))
|
|
|
+ {
|
|
|
+ urlAction = "https://malearn-test.azurewebsites.net";
|
|
|
+ }
|
|
|
+ string connect = $"{urlAction}/api/crtmabank";
|
|
|
+ var htc = _httpClient.CreateClient();
|
|
|
+ if (htc.DefaultRequestHeaders.Contains("x-functions-key"))
|
|
|
+ {
|
|
|
+ htc.DefaultRequestHeaders.Remove("x-functions-key");
|
|
|
+ }
|
|
|
+ htc.DefaultRequestHeaders.Add("x-functions-key", "QUzQqbqbnLsTDTeaJy4Br6wUuqPoAlKpzRK2S6PGImRHAzFuySGAeA==");
|
|
|
+ string paramJson = JsonConvert.SerializeObject(errors);
|
|
|
+ var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
|
|
|
+ await htc.PostAsync(connect, content);
|
|
|
+ await task_error.TaskPage(10);
|
|
|
}
|
|
|
- htc.DefaultRequestHeaders.Add("x-functions-key", "QUzQqbqbnLsTDTeaJy4Br6wUuqPoAlKpzRK2S6PGImRHAzFuySGAeA==");
|
|
|
- string paramJson = JsonConvert.SerializeObject(errors);
|
|
|
- var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
|
|
|
- await htc.PostAsync(connect, content);
|
|
|
- await task_error.TaskPage(10);
|
|
|
- }
|
|
|
+ } catch (Exception e) {
|
|
|
+ await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测错题异常{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public class Settlement
|