|
@@ -18,13 +18,14 @@ namespace TEAMModelFunction
|
|
|
{
|
|
|
public class TriggerExam
|
|
|
{
|
|
|
- public static async void Trigger( AzureCosmosFactory _azureCosmos, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, DingDing _dingDing,
|
|
|
+ public static async void Trigger(AzureCosmosFactory _azureCosmos, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, DingDing _dingDing,
|
|
|
CosmosClient client, Document input, string code, long stime, long etime, string school)
|
|
|
{
|
|
|
ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(input.Id, new Azure.Cosmos.PartitionKey($"{code}"));
|
|
|
List<ExamClassResult> examClassResults = new List<ExamClassResult>();
|
|
|
List<ExamSubject> examSubjects = new List<ExamSubject>();
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
if (info.scope.Equals("teacher", StringComparison.OrdinalIgnoreCase) || info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{info.creatorId}") }))
|
|
@@ -94,7 +95,8 @@ namespace TEAMModelFunction
|
|
|
(List<string> tmdids, List<Students> studentss) = await TriggerStuActivity.GetStuList(client, _dingDing, info.classes, info.school);
|
|
|
List<StuActivity> stuActivities = new List<StuActivity>();
|
|
|
List<StuActivity> tmdActivities = new List<StuActivity>();
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
if (tmdids.IsNotEmpty())
|
|
|
{
|
|
|
tmdids.ForEach(x =>
|
|
@@ -319,13 +321,16 @@ namespace TEAMModelFunction
|
|
|
gno++;
|
|
|
}
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-评测going状态异常{e.Message}\n{e.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
- }
|
|
|
+ }
|
|
|
break;
|
|
|
case "finish":
|
|
|
int fno = 0;
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
foreach (ExamSubject subject in info.subjects)
|
|
|
{
|
|
|
await createClassResultAsync(info, examClassResults, subject, fno, _azureCosmos, _dingDing, _azureStorage);
|
|
@@ -426,9 +431,10 @@ namespace TEAMModelFunction
|
|
|
await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new Azure.Cosmos.PartitionKey(info.code));
|
|
|
}
|
|
|
}
|
|
|
- catch(Exception e) {
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-评测finish状态异常{e.Message}\n{e.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
- }
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -436,7 +442,7 @@ namespace TEAMModelFunction
|
|
|
{
|
|
|
await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-评测结算异常{e.Message}\n{e.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
//处理全部学生选题计数
|
|
|
public static async Task examRecordCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, ExamResult result, List<ExamClassResult> classResults, AzureCosmosFactory _azureCosmos)
|
|
@@ -472,25 +478,30 @@ namespace TEAMModelFunction
|
|
|
foreach (string id in classResult.studentIds)
|
|
|
{
|
|
|
int index = classResult.studentIds.IndexOf(id);
|
|
|
- if (classResult.studentScores[index].Sum() >= rhw && PHCount < rhwCount)
|
|
|
+ if (classResult.studentScores.Count > 0)
|
|
|
{
|
|
|
- if (classResult.ans.Count > 0)
|
|
|
+ if (classResult.studentScores[index].Sum() >= rhw && PHCount < rhwCount)
|
|
|
{
|
|
|
- opth.Add(classResult.ans[index]);
|
|
|
- PHCount++;
|
|
|
- continue;
|
|
|
- }
|
|
|
+ if (classResult.ans.Count > 0)
|
|
|
+ {
|
|
|
+ opth.Add(classResult.ans[index]);
|
|
|
+ PHCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- if (classResult.studentScores[index].Sum() <= rhl && PLCount < (scores.Count - rhlCount))
|
|
|
- {
|
|
|
- if (classResult.ans.Count > 0)
|
|
|
+ }
|
|
|
+ if (classResult.studentScores[index].Sum() <= rhl && PLCount < (scores.Count - rhlCount))
|
|
|
{
|
|
|
- optl.Add(classResult.ans[index]);
|
|
|
- PLCount++;
|
|
|
- continue;
|
|
|
+ if (classResult.ans.Count > 0)
|
|
|
+ {
|
|
|
+ optl.Add(classResult.ans[index]);
|
|
|
+ PLCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -588,7 +599,7 @@ namespace TEAMModelFunction
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
n++;
|
|
@@ -655,7 +666,8 @@ namespace TEAMModelFunction
|
|
|
foreach (string id in classResult.studentIds)
|
|
|
{
|
|
|
int index = classResult.studentIds.IndexOf(id);
|
|
|
- if (classResult.studentScores.Count > 0) {
|
|
|
+ if (classResult.studentScores.Count > 0)
|
|
|
+ {
|
|
|
if (classResult.studentScores[index].Count > 0)
|
|
|
{
|
|
|
score += classResult.studentScores[index][n] == -1 ? 0 : classResult.studentScores[index][n];
|
|
@@ -682,7 +694,7 @@ namespace TEAMModelFunction
|
|
|
pCount++;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
n++;
|