Parcourir la source

收集學生評量資料架構修正

jeff il y a 1 an
Parent
commit
19d5e9be44

+ 5 - 5
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -429,7 +429,7 @@ namespace TEAMModelOS.FunctionV4
                             int fno = 0;
                             try
                             {
-                                SetLearnRecordContent(info, data, _azureStorage, _azureCosmos);
+                                //await SetLearnRecordContent(info, data, _azureStorage, _azureCosmos);
                                 //用来判定是否完成评分
                                 //bool isScore = true;
                                 await resultStatus(client, examClassResults);
@@ -540,7 +540,7 @@ namespace TEAMModelOS.FunctionV4
 
                                     await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new Azure.Cosmos.PartitionKey(info.code));
                                 }
-                                //SetLearnRecordContent(info, data, _azureStorage);
+                                await SetLearnRecordContent(info, data, _azureStorage, _azureCosmos);
                             }
                             catch (Exception e)
                             {
@@ -641,13 +641,13 @@ namespace TEAMModelOS.FunctionV4
                                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<StudentAnswers>(queryText: sbsql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{rootName}") }))
                                 {
                                     studentAnswersList.Add(item);
-                                    stuListForSql.Union(item.studentIds);
+                                    stuListForSql = stuListForSql.Union(item.studentIds).ToList();
                                 }
                                 //取得學校的學生名單
                                 if(!string.IsNullOrWhiteSpace(info.school))
                                 {
-                                    StringBuilder stusql = new StringBuilder($" SELECT c.id FROM c WHERE c.pk = 'Base' AND ARRAY_CONTAINS({System.Text.Json.JsonSerializer.Serialize(stuListForSql)}, c.id)");
-                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<string>(queryText: stusql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{info.school}") }))
+                                    StringBuilder stusql = new StringBuilder($"SELECT VALUE c.id FROM c WHERE c.pk = 'Base' AND ARRAY_CONTAINS({System.Text.Json.JsonSerializer.Serialize(stuListForSql)}, c.id)");
+                                    await foreach (string item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<string>(queryText: stusql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{info.school}") }))
                                     {
                                         stuDic[info.school].Add(item);
                                     }

+ 2 - 2
TEAMModelOS/Controllers/Client/HiTeachController.cs

@@ -145,7 +145,7 @@ namespace TEAMModelOS.Controllers.Client
                 messageChange.ApplicationProperties.Add("name", "LessonRecordEvent");
                 //await _dingDing.SendBotMsg($"{_option.Location},课堂id:{_lessonId} 更新事件,{msg}", GroupNames.醍摩豆服務運維群組);
                 await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
-                SetLearnRecordContent(_school, _tmdid, _lessonId, _scope);
+                await SetLearnRecordContent(_school, _tmdid, _lessonId, _scope);
                 return Ok(new { status = 200 });
             }
             catch (CosmosException ex) when (ex.Status == 404)
@@ -179,7 +179,7 @@ namespace TEAMModelOS.Controllers.Client
                 if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
                 request.TryGetProperty("school", out JsonElement _school);
 
-                SetLearnRecordContent(_school, _tmdid, _lessonId, _scope);
+                await SetLearnRecordContent(_school, _tmdid, _lessonId, _scope);
 
                 return Ok(new { status = 200, learnRecordItems });
             }