|
@@ -2335,8 +2335,9 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
}
|
|
|
}
|
|
|
//取得有作答的評測班級
|
|
|
+ string sqltest = $"SELECT c.examId, c.info.id as classId, c.studentAnswers FROM c WHERE ARRAY_CONTAINS({JsonSerializer.Serialize(examIdList)}, c.examId) AND c.progress=true AND CONTAINS(c.code, 'ExamClassResult')";
|
|
|
Dictionary<string, List<string>> examClassFinDic = new Dictionary<string, List<string>>();
|
|
|
- await foreach (var exam in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.examId, c.info.id as classId FROM c where (c.status<>404 or IS_DEFINED(c.status) = false ) and ARRAY_CONTAINS({JsonSerializer.Serialize(examIdList)}, c.examId) AND c.progress=true", requestOptions: new QueryRequestOptions() { }))
|
|
|
+ await foreach (var exam in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.examId, c.info.id as classId, c.studentAnswers FROM c WHERE ARRAY_CONTAINS({JsonSerializer.Serialize(examIdList)}, c.examId) AND c.progress=true AND CONTAINS(c.code, 'ExamClassResult')", requestOptions: new QueryRequestOptions() ))
|
|
|
{
|
|
|
var jsonecr = await JsonDocument.ParseAsync(exam.Content);
|
|
|
if (jsonecr.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -2345,15 +2346,24 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
{
|
|
|
string examId = obj.GetProperty("examId").ToString();
|
|
|
string classId = obj.GetProperty("classId").ToString();
|
|
|
- if (examClassFinDic.ContainsKey(examId) && !examClassFinDic[examId].Contains(classId))
|
|
|
+ List<List<string>> studentAnswers = obj.GetProperty("studentAnswers").ToObject<List<List<string>>>();
|
|
|
+ bool isFinish = false; //評量是否已完成 ※有任一學生有作答則視為已完成
|
|
|
+ foreach (List<string> studentAnswer in studentAnswers)
|
|
|
{
|
|
|
- examClassFinDic[examId].Add(classId);
|
|
|
+ if (studentAnswer.Count > 0) { isFinish = true; break; }
|
|
|
}
|
|
|
- else
|
|
|
+ if (isFinish)
|
|
|
{
|
|
|
- List<string> classIdList = new List<string>();
|
|
|
- classIdList.Add(classId);
|
|
|
- examClassFinDic.Add(examId, classIdList);
|
|
|
+ if (examClassFinDic.ContainsKey(examId) && !examClassFinDic[examId].Contains(classId))
|
|
|
+ {
|
|
|
+ examClassFinDic[examId].Add(classId);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ List<string> classIdList = new List<string>();
|
|
|
+ classIdList.Add(classId);
|
|
|
+ examClassFinDic.Add(examId, classIdList);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2875,24 +2885,34 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
}
|
|
|
//取得有作答的評測班級、已完成的 評測ID、班級ID、科目ID 列表製作
|
|
|
List<ExamFinishClassesSubList> examFinClassSubList = new List<ExamFinishClassesSubList>(); //已完成的 評測ID、班級ID、科目ID 列表
|
|
|
- await foreach (var exam in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.examId, c.info.id as classId, c.subjectId FROM c WHERE ARRAY_CONTAINS({JsonSerializer.Serialize(examIdList)}, c.examId) AND c.progress=true", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school_code}") }))
|
|
|
+ await foreach (var exam in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.examId, c.info.id as classId, c.subjectId, c.studentAnswers FROM c WHERE ARRAY_CONTAINS({JsonSerializer.Serialize(examIdList)}, c.examId) AND c.progress=true", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school_code}") }))
|
|
|
{
|
|
|
var jsonecr = await JsonDocument.ParseAsync(exam.Content);
|
|
|
if (jsonecr.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
foreach (var obj in jsonecr.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
{
|
|
|
+ //追加判斷:是否有作答要看 studentAnswers,若其下的array全部都為空array則視為未完成
|
|
|
string examId = obj.GetProperty("examId").ToString();
|
|
|
string classId = obj.GetProperty("classId").ToString();
|
|
|
string subjectId = obj.GetProperty("subjectId").ToString();
|
|
|
- ExamFinishClassesSubList existExamFinishClassesSubRow = examFinClassSubList.Where(e => e.examId == examId && e.classId == classId && e.subjectId == subjectId).FirstOrDefault();
|
|
|
- if (existExamFinishClassesSubRow == null)
|
|
|
+ List<List<string>> studentAnswers = obj.GetProperty("studentAnswers").ToObject<List<List<string>>>();
|
|
|
+ bool isFinish = false; //評量是否已完成 ※有任一學生有作答則視為已完成
|
|
|
+ foreach(List<string> studentAnswer in studentAnswers)
|
|
|
+ {
|
|
|
+ if(studentAnswer.Count > 0) { isFinish = true; break; }
|
|
|
+ }
|
|
|
+ if (isFinish)
|
|
|
{
|
|
|
- ExamFinishClassesSubList ExamFinishClassesSubRow = new ExamFinishClassesSubList();
|
|
|
- ExamFinishClassesSubRow.examId = examId;
|
|
|
- ExamFinishClassesSubRow.classId = classId;
|
|
|
- ExamFinishClassesSubRow.subjectId = subjectId;
|
|
|
- examFinClassSubList.Add(ExamFinishClassesSubRow);
|
|
|
+ ExamFinishClassesSubList existExamFinishClassesSubRow = examFinClassSubList.Where(e => e.examId == examId && e.classId == classId && e.subjectId == subjectId).FirstOrDefault();
|
|
|
+ if (existExamFinishClassesSubRow == null)
|
|
|
+ {
|
|
|
+ ExamFinishClassesSubList ExamFinishClassesSubRow = new ExamFinishClassesSubList();
|
|
|
+ ExamFinishClassesSubRow.examId = examId;
|
|
|
+ ExamFinishClassesSubRow.classId = classId;
|
|
|
+ ExamFinishClassesSubRow.subjectId = subjectId;
|
|
|
+ examFinClassSubList.Add(ExamFinishClassesSubRow);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|