|
@@ -792,7 +792,7 @@ namespace TEAMModelOS.Controllers
|
|
|
List<Task<string>> tasks = new List<Task<string>>();
|
|
|
foreach (ExamClassResult result in examClassResults)
|
|
|
{
|
|
|
- int index = result.studentIds.IndexOf(userId.ToString());
|
|
|
+ //int index = result.studentIds.IndexOf(userId.ToString());
|
|
|
//存放客观题作答详情
|
|
|
if (result.ans.Count == 0)
|
|
|
{
|
|
@@ -806,46 +806,11 @@ namespace TEAMModelOS.Controllers
|
|
|
result.ans.Add(anc);
|
|
|
}
|
|
|
}
|
|
|
- //处理新增学生作答信息
|
|
|
- //List<List<string>> oq = new List<List<string>>();
|
|
|
- //classResult.studentAnswers[index] = ans;
|
|
|
- if (index == -1)
|
|
|
- {
|
|
|
- List<double> ansPoint = new List<double>();
|
|
|
- List<List<string>> anc = new List<List<string>>();
|
|
|
- List<List<Details>> mark = new List<List<Details>>();
|
|
|
- foreach (List<string> num in standard)
|
|
|
- {
|
|
|
- List<string> newAns = new List<string>();
|
|
|
- foreach (string san in num)
|
|
|
- {
|
|
|
- newAns.Add(san);
|
|
|
- }
|
|
|
- anc.Add(newAns);
|
|
|
- ansPoint.Add(-1);
|
|
|
- mark.Add(new List<Details>());
|
|
|
- }
|
|
|
- result.mark.Add(mark);
|
|
|
- result.ans.Add(anc);
|
|
|
- result.studentIds.Add(userId.ToString());
|
|
|
- result.studentScores.Add(ansPoint);
|
|
|
- result.studentAnswers.Add(new List<string>());
|
|
|
- result.sum.Add(0);
|
|
|
- }
|
|
|
- //int flagCount = 0;
|
|
|
- /*foreach (List<string> str in ans) {
|
|
|
-
|
|
|
- if (str.Count == 0) {
|
|
|
- flagCount++;
|
|
|
- }
|
|
|
- } */
|
|
|
int newIndex = result.studentIds.IndexOf(userId.ToString());
|
|
|
- /* if (flagCount != standard.Count)
|
|
|
- {*/
|
|
|
- StringBuilder builder = new StringBuilder();
|
|
|
- builder.Append(result.examId).Append("/");
|
|
|
- builder.Append(result.subjectId).Append("/");
|
|
|
- builder.Append(userId).Append("/");
|
|
|
+ StringBuilder builder = new();
|
|
|
+ builder.Append(result.examId).Append('/');
|
|
|
+ builder.Append(result.subjectId).Append('/');
|
|
|
+ builder.Append(userId).Append('/');
|
|
|
builder.Append("ans.json");
|
|
|
/*string FileName = result.examId + "/" + result.subjectId + "/" + studentId;
|
|
|
string blob = FileName + "/" + "ans.json";*/
|
|
@@ -1295,46 +1260,25 @@ namespace TEAMModelOS.Controllers
|
|
|
ids.AddRange(result.studentIds);
|
|
|
//codes.AddRange(result.scIds);
|
|
|
}
|
|
|
+ List<string> cid = new()
|
|
|
+ {
|
|
|
+ classId.GetString()
|
|
|
+ };
|
|
|
+ (List<RMember> members, List<RGroupList> groups) = await GroupListService.GetStutmdidListids(_coreAPIHttpService, client, _dingDing, cid, $"{school}");
|
|
|
+ //await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<GroupList>(classId.GetString, new PartitionKey($"Exam-{code}"));
|
|
|
///获取真实的名称
|
|
|
List<ufo> ufos = new();
|
|
|
List<string> delIds = new();
|
|
|
- //List<ufo> students = new List<ufo>();
|
|
|
- if (ids.Count > 0)
|
|
|
- {
|
|
|
- List<string> sIds = new();
|
|
|
- List<string> tIds = new();
|
|
|
- List<ufo> students = new List<ufo>();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select distinct c.id,c.name from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))}) and c.pk = 'Base'",requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
|
|
|
+ if (groups.Count > 0) {
|
|
|
+ string scode = groups[0].school;
|
|
|
+ if (ids.Count > 0)
|
|
|
{
|
|
|
- using var stuJson = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (stuJson.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = stuJson.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- ufo fo = new()
|
|
|
- {
|
|
|
- id = account.GetProperty("id").GetString(),
|
|
|
- name = account.GetProperty("name").GetString(),
|
|
|
- //schoolId = account.GetProperty("schoolId").GetString(),
|
|
|
- type = 2
|
|
|
- };
|
|
|
- students.Add(fo);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (students.Count > 0)
|
|
|
- {
|
|
|
- ufos.AddRange(students);
|
|
|
- foreach (ufo f in students)
|
|
|
- {
|
|
|
- sIds.Add(f.id);
|
|
|
- }
|
|
|
- if (ids.Count > sIds.Count)
|
|
|
+ List<string> sIds = new();
|
|
|
+ List<string> tIds = new();
|
|
|
+ List<ufo> students = new List<ufo>();
|
|
|
+ if (string.IsNullOrEmpty(scode))
|
|
|
{
|
|
|
- tIds = ids.Except(sIds).ToList();
|
|
|
- var content = new StringContent(tIds.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
+ var content = new StringContent(ids.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(json))
|
|
@@ -1350,6 +1294,7 @@ namespace TEAMModelOS.Controllers
|
|
|
tIds.Add(fo.id);
|
|
|
}
|
|
|
ufos.AddRange(tmdInfos);
|
|
|
+ delIds = ids.Except(tIds).ToList();
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -1358,36 +1303,70 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- delIds = ids.Except(sIds.Union(tIds)).ToList();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var content = new StringContent(ids.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
- string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
-
|
|
|
- if (!string.IsNullOrWhiteSpace(json))
|
|
|
+ else
|
|
|
{
|
|
|
- try
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select distinct c.id,c.name from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))}) and c.pk = 'Base'",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{scode}") }))
|
|
|
{
|
|
|
- List<ufo> tmdInfos = json.ToObject<List<ufo>>();
|
|
|
- if (tmdInfos.IsNotEmpty())
|
|
|
+ using var stuJson = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (stuJson.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
- foreach (ufo fo in tmdInfos)
|
|
|
+ var accounts = stuJson.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
{
|
|
|
- fo.type = 1;
|
|
|
- tIds.Add(fo.id);
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ ufo fo = new()
|
|
|
+ {
|
|
|
+ id = account.GetProperty("id").GetString(),
|
|
|
+ name = account.GetProperty("name").GetString(),
|
|
|
+ //schoolId = account.GetProperty("schoolId").GetString(),
|
|
|
+ type = 2
|
|
|
+ };
|
|
|
+ students.Add(fo);
|
|
|
}
|
|
|
- ufos.AddRange(tmdInfos);
|
|
|
- delIds = ids.Except(tIds).ToList();
|
|
|
}
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ if (students.Count > 0)
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.Get("Default").location}用户转换失败:{_coreAPIHttpService.options.Get("Default").url}{json}\n {ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ ufos.AddRange(students);
|
|
|
+ foreach (ufo f in students)
|
|
|
+ {
|
|
|
+ sIds.Add(f.id);
|
|
|
+ }
|
|
|
+ if (ids.Count > sIds.Count)
|
|
|
+ {
|
|
|
+ tIds = ids.Except(sIds).ToList();
|
|
|
+ var content = new StringContent(tIds.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
+ string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
+
|
|
|
+ if (!string.IsNullOrWhiteSpace(json))
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ List<ufo> tmdInfos = json.ToObject<List<ufo>>();
|
|
|
+ if (tmdInfos.IsNotEmpty())
|
|
|
+ {
|
|
|
+ foreach (ufo fo in tmdInfos)
|
|
|
+ {
|
|
|
+ fo.type = 1;
|
|
|
+ tIds.Add(fo.id);
|
|
|
+ }
|
|
|
+ ufos.AddRange(tmdInfos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.Get("Default").location}用户转换失败:{_coreAPIHttpService.options.Get("Default").url}{json}\n {ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ delIds = ids.Except(sIds.Union(tIds)).ToList();
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ //List<ufo> students = new List<ufo>();
|
|
|
+
|
|
|
|
|
|
/*if (StringHelper.getKeyCount(requert) == 1 && requert.TryGetProperty("code", out JsonElement code))
|
|
|
{
|