|
@@ -1912,201 +1912,207 @@ namespace TEAMModelOS.FunctionV4
|
|
|
pk = $"Item-{info.creatorId}";
|
|
|
table = "Teacher";
|
|
|
}
|
|
|
- string sqlqueryText = $"select value(c) from c where c.activityId = '{info.id}'and c.subjectId = '{info.subjects[no].id}' and c.stuId in ({string.Join(",", result.studentIds.Select(x => $"'{x}'"))})";
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<ErrorItems>(queryText: sqlqueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
|
|
|
- {
|
|
|
- errorItems.Add(item);
|
|
|
- }
|
|
|
- try {
|
|
|
- /* bool isError = examClassResults.SelectMany(c => c.status).ToList().Exists(z => z == 1);
|
|
|
- if () {
|
|
|
-
|
|
|
- }*/
|
|
|
- if (errorItems.Count == 0 && info.qamode != 2)
|
|
|
+
|
|
|
+ if (result.studentIds.Any()) {
|
|
|
+ string sqlqueryText = $"select value(c) from c where c.activityId = '{info.id}'and c.subjectId = '{info.subjects[no].id}' and c.stuId in ({string.Join(",", result.studentIds.Select(x => $"'{x}'"))})";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<ErrorItems>(queryText: sqlqueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
|
|
|
{
|
|
|
- // 新增逻辑 收集错题内容
|
|
|
- BlobDownloadResult index_json;
|
|
|
- if (info.scope.Equals("school"))
|
|
|
- {
|
|
|
- index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
|
|
|
- }
|
|
|
- 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();
|
|
|
- JsonElement RecordingJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_json.Content.ToString()))).RootElement;
|
|
|
- RecordingJson.TryGetProperty("slides", out JsonElement slides);
|
|
|
- int qamode = info.qamode;
|
|
|
- if (RecordingJson.TryGetProperty("qamode", out JsonElement element)) {
|
|
|
- qamode = element.GetInt32();
|
|
|
- }
|
|
|
- var sdes = slides.ToObject<List<Slides>>();
|
|
|
- List<string> attachments = new List<string>();
|
|
|
- if (qamode == 1)
|
|
|
- {
|
|
|
- attachments = RecordingJson.GetProperty("attachments").ToObject<List<string>>();
|
|
|
- if (attachments.Count == 0)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- List<string> urls = new();
|
|
|
+ errorItems.Add(item);
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ /* bool isError = examClassResults.SelectMany(c => c.status).ToList().Exists(z => z == 1);
|
|
|
+ if () {
|
|
|
|
|
|
- foreach (var ne in sdes)
|
|
|
- {
|
|
|
- if (!ne.type.Equals("compose"))
|
|
|
- {
|
|
|
- urls.Add(ne.url);
|
|
|
- }
|
|
|
- }
|
|
|
- // 获取整体的题目ID集合
|
|
|
- List<string> ids = new();
|
|
|
- List<(string id, string pid, int level, string type, List<string> knows)> itemInfos = new();
|
|
|
- foreach (string url in urls)
|
|
|
+ }*/
|
|
|
+ if (errorItems.Count == 0 && info.qamode != 2)
|
|
|
{
|
|
|
- string id = url.Replace(".json", "");
|
|
|
- BlobDownloadResult index_item_json;
|
|
|
+ // 新增逻辑 收集错题内容
|
|
|
+ BlobDownloadResult index_json;
|
|
|
if (info.scope.Equals("school"))
|
|
|
{
|
|
|
- index_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
|
|
|
+ index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
|
|
|
+ index_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
|
|
|
}
|
|
|
- JsonElement itemJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_item_json.Content.ToString()))).RootElement;
|
|
|
- itemJson.TryGetProperty("exercise", out JsonElement exercise);
|
|
|
- //itemJson.TryGetProperty("pid", out JsonElement pid);
|
|
|
- var item_json = exercise.ToObject<Exercise>();
|
|
|
- //JObject keys = JObject.Parse(index_item_json.Content.ToString());
|
|
|
- string type = item_json.type;
|
|
|
- int level = item_json.level;
|
|
|
- var knowledge = item_json.knowledges;
|
|
|
- //string pid = keys.Value<string>("pid");
|
|
|
- if (itemJson.TryGetProperty("pid", out JsonElement pid))
|
|
|
+ //BlobDownloadResult index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
|
|
|
+ JsonElement RecordingJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_json.Content.ToString()))).RootElement;
|
|
|
+ RecordingJson.TryGetProperty("slides", out JsonElement slides);
|
|
|
+ int qamode = info.qamode;
|
|
|
+ if (RecordingJson.TryGetProperty("qamode", out JsonElement element))
|
|
|
{
|
|
|
- itemInfos.Add((id, pid.ToString(), level, type, knowledge));
|
|
|
+ qamode = element.GetInt32();
|
|
|
}
|
|
|
- else {
|
|
|
- itemInfos.Add((id, "", level, type, knowledge));
|
|
|
+ var sdes = slides.ToObject<List<Slides>>();
|
|
|
+ List<string> attachments = new List<string>();
|
|
|
+ if (qamode == 1)
|
|
|
+ {
|
|
|
+ attachments = RecordingJson.GetProperty("attachments").ToObject<List<string>>();
|
|
|
+ if (attachments.Count == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
+ List<string> urls = 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)
|
|
|
- {
|
|
|
- ErrorItems error = new()
|
|
|
+ foreach (var ne in sdes)
|
|
|
{
|
|
|
- ttl = -1,
|
|
|
- code = code,
|
|
|
- id = Guid.NewGuid().ToString(),
|
|
|
- stuId = sIds,
|
|
|
- school = info.school,
|
|
|
- activityId = info.id,
|
|
|
- subjectId = result.subjectId,
|
|
|
- time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
- };
|
|
|
- int index_stu = result.studentIds.IndexOf(sIds);
|
|
|
- //顺序学生错题的索引
|
|
|
- var itemScore = result.studentScores[index_stu];
|
|
|
- List<int> index = new();
|
|
|
- int index_item = 0;
|
|
|
- foreach (var sc in itemScore)
|
|
|
- {
|
|
|
- if (sc == 0)
|
|
|
+ if (!ne.type.Equals("compose"))
|
|
|
{
|
|
|
- index.Add(index_item + 1);
|
|
|
+ urls.Add(ne.url);
|
|
|
}
|
|
|
- index_item++;
|
|
|
}
|
|
|
- if (index.Count == 0)
|
|
|
+ // 获取整体的题目ID集合
|
|
|
+ List<string> ids = new();
|
|
|
+ List<(string id, string pid, int level, string type, List<string> knows)> itemInfos = new();
|
|
|
+ foreach (string url in urls)
|
|
|
{
|
|
|
- continue;
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ JsonElement itemJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_item_json.Content.ToString()))).RootElement;
|
|
|
+ itemJson.TryGetProperty("exercise", out JsonElement exercise);
|
|
|
+ //itemJson.TryGetProperty("pid", out JsonElement pid);
|
|
|
+ var item_json = exercise.ToObject<Exercise>();
|
|
|
+ //JObject keys = JObject.Parse(index_item_json.Content.ToString());
|
|
|
+ string type = item_json.type;
|
|
|
+ int level = item_json.level;
|
|
|
+ var knowledge = item_json.knowledges;
|
|
|
+ //string pid = keys.Value<string>("pid");
|
|
|
+ if (itemJson.TryGetProperty("pid", out JsonElement pid))
|
|
|
+ {
|
|
|
+ itemInfos.Add((id, pid.ToString(), level, type, knowledge));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ itemInfos.Add((id, "", level, type, knowledge));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- //int[] item_index = ss[n];
|
|
|
- foreach (var item in index)
|
|
|
+
|
|
|
+ /* 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)
|
|
|
{
|
|
|
- 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;
|
|
|
- items.qamode = qamode;
|
|
|
- error.its.Add(items);
|
|
|
+ int index_stu = result.studentIds.IndexOf(sIds);
|
|
|
+ //顺序学生错题的索引
|
|
|
+ var itemScore = result.studentScores[index_stu];
|
|
|
+ List<int> index = new();
|
|
|
+ int index_item = 0;
|
|
|
+ foreach (var sc in itemScore)
|
|
|
+ {
|
|
|
+ if (sc == 0)
|
|
|
+ {
|
|
|
+ index.Add(index_item + 1);
|
|
|
+ }
|
|
|
+ index_item++;
|
|
|
+ }
|
|
|
+ if (index.Count == 0)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //int[] item_index = ss[n];
|
|
|
+ foreach (var item in 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;
|
|
|
+ items.qamode = qamode;
|
|
|
+ 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;
|
|
|
- string accessKey = string.Empty;
|
|
|
- if (location.Contains("China"))
|
|
|
- {
|
|
|
- if (location.Equals("China")) //大陸正式站
|
|
|
+ //string connect = _configuration.GetValue<string>("HaBookAuth:Crtmabank") + "https://malearnfunction.chinacloudsites.cn/api/crtmabank";
|
|
|
+ string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
|
|
|
+ string urlAction = string.Empty;
|
|
|
+ string accessKey = string.Empty;
|
|
|
+ if (location.Contains("China"))
|
|
|
+ {
|
|
|
+ if (location.Equals("China")) //大陸正式站
|
|
|
+ {
|
|
|
+ urlAction = "https://malearn.teammodel.cn";
|
|
|
+ accessKey = "2BcXFR_hvzG1pZjqIkaM7Dx74Hcu6m0PwwOacFpDpq44AzFuHJBRXA==";
|
|
|
+ }
|
|
|
+ else if (location.Equals("China-Dep") || location.Equals("China-Test")) //大陸測試站
|
|
|
+ {
|
|
|
+ urlAction = "https://malearn-rc.teammodel.cn";
|
|
|
+ accessKey = "lghWhJduNiAlo-e8isqEoROjdR7DAC-50XNtanIwHKYlAzFu1aog_A==";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (location.Contains("Global"))
|
|
|
{
|
|
|
- urlAction = "https://malearn.teammodel.cn";
|
|
|
- accessKey = "2BcXFR_hvzG1pZjqIkaM7Dx74Hcu6m0PwwOacFpDpq44AzFuHJBRXA==";
|
|
|
+ if (location.Equals("Global")) //國際正式站
|
|
|
+ {
|
|
|
+ urlAction = "https://malearn.teammodel.net";
|
|
|
+ accessKey = "I-2lTcdggJkZWSBwOXQIm4oHx-huwX3d0wLe-9pgojThAzFuq_KNFg==";
|
|
|
+ }
|
|
|
+ else if (location.Equals("Global-Test")) //國際測試站
|
|
|
+ {
|
|
|
+ urlAction = "https://malearn-rc.teammodel.net";
|
|
|
+ accessKey = "_l4Cb_tHIRBw_iv3ZuwVqjkMwjg4_HtDaxhAmZ8OwJraAzFu_DAY8A==";
|
|
|
+ }
|
|
|
}
|
|
|
- else if (location.Equals("China-Dep") || location.Equals("China-Test")) //大陸測試站
|
|
|
+ string connect = $"{urlAction}/api/crtmabank";
|
|
|
+ var htc = _httpClient.CreateClient();
|
|
|
+ if (htc.DefaultRequestHeaders.Contains("x-functions-key"))
|
|
|
{
|
|
|
- urlAction = "https://malearn-rc.teammodel.cn";
|
|
|
- accessKey = "lghWhJduNiAlo-e8isqEoROjdR7DAC-50XNtanIwHKYlAzFu1aog_A==";
|
|
|
+ htc.DefaultRequestHeaders.Remove("x-functions-key");
|
|
|
}
|
|
|
- }
|
|
|
- else if (location.Contains("Global"))
|
|
|
- {
|
|
|
- if (location.Equals("Global")) //國際正式站
|
|
|
+ htc.DefaultRequestHeaders.Add("x-functions-key", accessKey);
|
|
|
+ ///智慧題庫school欄位修正
|
|
|
+ foreach (ErrorItems error in errors)
|
|
|
{
|
|
|
- urlAction = "https://malearn.teammodel.net";
|
|
|
- accessKey = "I-2lTcdggJkZWSBwOXQIm4oHx-huwX3d0wLe-9pgojThAzFuq_KNFg==";
|
|
|
+ error.school = (info.scope.Equals("school")) ? info.school : string.Empty;
|
|
|
}
|
|
|
- else if (location.Equals("Global-Test")) //國際測試站
|
|
|
+ string paramJson = JsonConvert.SerializeObject(errors);
|
|
|
+ var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
|
|
|
+ var response = await htc.PostAsync(connect, content);
|
|
|
+ if ((int)response.StatusCode == 200)
|
|
|
{
|
|
|
- urlAction = "https://malearn-rc.teammodel.net";
|
|
|
- accessKey = "_l4Cb_tHIRBw_iv3ZuwVqjkMwjg4_HtDaxhAmZ8OwJraAzFu_DAY8A==";
|
|
|
+ await task_error.TaskPage(10);
|
|
|
}
|
|
|
}
|
|
|
- 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", accessKey);
|
|
|
- ///智慧題庫school欄位修正
|
|
|
- foreach (ErrorItems error in errors)
|
|
|
- {
|
|
|
- error.school = (info.scope.Equals("school")) ? info.school : string.Empty;
|
|
|
- }
|
|
|
- string paramJson = JsonConvert.SerializeObject(errors);
|
|
|
- var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
|
|
|
- var response = await htc.PostAsync(connect, content);
|
|
|
- if ((int)response.StatusCode == 200)
|
|
|
- {
|
|
|
- await task_error.TaskPage(10);
|
|
|
- }
|
|
|
}
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测错题异常{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
|
|
|
- }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测错题异常{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public class Settlement
|