|
@@ -18,398 +18,431 @@ 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>();
|
|
|
- if (info.scope.Equals("teacher", StringComparison.OrdinalIgnoreCase) || info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
|
|
|
+ try
|
|
|
{
|
|
|
- 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}") }))
|
|
|
+ if (info.scope.Equals("teacher", StringComparison.OrdinalIgnoreCase) || info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ 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}") }))
|
|
|
{
|
|
|
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
- examClassResults.Add(obj.ToObject<ExamClassResult>());
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ {
|
|
|
+ examClassResults.Add(obj.ToObject<ExamClassResult>());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- 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-{school}") }))
|
|
|
+ else
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ 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-{school}") }))
|
|
|
{
|
|
|
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
- examClassResults.Add(obj.ToObject<ExamClassResult>());
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ {
|
|
|
+ examClassResults.Add(obj.ToObject<ExamClassResult>());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
- List<ChangeRecord> records = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", info.progress } });
|
|
|
- //处理科目信息
|
|
|
- List<string> sub = new List<string>();
|
|
|
- foreach (ExamSubject subject in info.subjects)
|
|
|
- {
|
|
|
- sub.Add(subject.id);
|
|
|
- }
|
|
|
- //ChangeRecord record = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ChangeRecord>(input.Id, new Azure.Cosmos.PartitionKey($"{info.progress}"));
|
|
|
- switch (info.progress)
|
|
|
- {
|
|
|
- case "pending":
|
|
|
- var message = new ServiceBusMessage(new { id = input.Id, progress = "going", code = code }.ToJsonString());
|
|
|
- message.ApplicationProperties.Add("name", "Exam");
|
|
|
- if (records.Count > 0)
|
|
|
- {
|
|
|
- await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), records[0].sequenceNumber);
|
|
|
- long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), message, DateTimeOffset.FromUnixTimeMilliseconds(stime));
|
|
|
- records[0].sequenceNumber = start;
|
|
|
- await _azureStorage.SaveOrUpdate<ChangeRecord>(records[0]);
|
|
|
- //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), message, DateTimeOffset.FromUnixTimeMilliseconds(stime));
|
|
|
- ChangeRecord changeRecord = new ChangeRecord
|
|
|
+ List<ChangeRecord> records = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", info.progress } });
|
|
|
+ //处理科目信息
|
|
|
+ List<string> sub = new List<string>();
|
|
|
+ foreach (ExamSubject subject in info.subjects)
|
|
|
+ {
|
|
|
+ sub.Add(subject.id);
|
|
|
+ }
|
|
|
+ //ChangeRecord record = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ChangeRecord>(input.Id, new Azure.Cosmos.PartitionKey($"{info.progress}"));
|
|
|
+ switch (info.progress)
|
|
|
+ {
|
|
|
+ case "pending":
|
|
|
+ var message = new ServiceBusMessage(new { id = input.Id, progress = "going", code = code }.ToJsonString());
|
|
|
+ message.ApplicationProperties.Add("name", "Exam");
|
|
|
+ if (records.Count > 0)
|
|
|
{
|
|
|
- RowKey = input.Id,
|
|
|
- PartitionKey = "pending",
|
|
|
- sequenceNumber = start,
|
|
|
- msgId = message.MessageId
|
|
|
- };
|
|
|
- await _azureStorage.Save<ChangeRecord>(changeRecord);
|
|
|
- //await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
|
|
|
- }
|
|
|
- break;
|
|
|
- case "going":
|
|
|
- (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>();
|
|
|
- if (tmdids.IsNotEmpty())
|
|
|
- {
|
|
|
- tmdids.ForEach(x =>
|
|
|
+ await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), records[0].sequenceNumber);
|
|
|
+ long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), message, DateTimeOffset.FromUnixTimeMilliseconds(stime));
|
|
|
+ records[0].sequenceNumber = start;
|
|
|
+ await _azureStorage.SaveOrUpdate<ChangeRecord>(records[0]);
|
|
|
+ //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- tmdActivities.Add(new StuActivity
|
|
|
+ long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), message, DateTimeOffset.FromUnixTimeMilliseconds(stime));
|
|
|
+ ChangeRecord changeRecord = new ChangeRecord
|
|
|
{
|
|
|
- pk = "Activity",
|
|
|
- id = info.id,
|
|
|
- code = $"Activity-{x}",
|
|
|
- type = "Exam",
|
|
|
- name = info.name,
|
|
|
- startTime = info.startTime,
|
|
|
- endTime = info.endTime,
|
|
|
- scode = info.code,
|
|
|
- scope = info.scope,
|
|
|
- school = info.school,
|
|
|
- creatorId = info.creatorId,
|
|
|
- subjects = sub,
|
|
|
- blob = null,
|
|
|
- owner = info.owner
|
|
|
-
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
- if (studentss.IsNotEmpty())
|
|
|
- {
|
|
|
- studentss.ForEach(x =>
|
|
|
+ RowKey = input.Id,
|
|
|
+ PartitionKey = "pending",
|
|
|
+ sequenceNumber = start,
|
|
|
+ msgId = message.MessageId
|
|
|
+ };
|
|
|
+ await _azureStorage.Save<ChangeRecord>(changeRecord);
|
|
|
+ //await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "going":
|
|
|
+ (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
|
|
|
{
|
|
|
- stuActivities.Add(new StuActivity
|
|
|
+ if (tmdids.IsNotEmpty())
|
|
|
{
|
|
|
- pk = "Activity",
|
|
|
- id = info.id,
|
|
|
- code = $"Activity-{info.school}-{x.id}",
|
|
|
- type = "Exam",
|
|
|
- name = info.name,
|
|
|
- startTime = info.startTime,
|
|
|
- endTime = info.endTime,
|
|
|
- scode = info.code,
|
|
|
- scope = info.scope,
|
|
|
- school = info.school,
|
|
|
- creatorId = info.creatorId,
|
|
|
- subjects = sub,
|
|
|
- blob = null,
|
|
|
- owner = info.owner
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
- await TriggerStuActivity.SaveStuActivity(client, _dingDing, stuActivities, tmdActivities);
|
|
|
- //向学生或醍摩豆账号发起通知
|
|
|
- #region
|
|
|
- Notice notice = new Notice()
|
|
|
- {
|
|
|
- msgId=info.id,
|
|
|
- creation = info.startTime,
|
|
|
- expire = info.endTime,
|
|
|
- creatorId = info.creatorId,
|
|
|
- stuids = studentss,
|
|
|
- tmdids = tmdids,
|
|
|
- type = "notice",//评测参加通知
|
|
|
- priority = "normal",
|
|
|
- school = info.school,
|
|
|
- scope = info.scope,
|
|
|
- //data = new { }.ToJsonString()
|
|
|
- body = new Body {sid=info.id,scode=info.code,spk=info.pk,biztype= "exam-join" }
|
|
|
+ tmdids.ForEach(x =>
|
|
|
+ {
|
|
|
+ tmdActivities.Add(new StuActivity
|
|
|
+ {
|
|
|
+ pk = "Activity",
|
|
|
+ id = info.id,
|
|
|
+ code = $"Activity-{x}",
|
|
|
+ type = "Exam",
|
|
|
+ name = info.name,
|
|
|
+ startTime = info.startTime,
|
|
|
+ endTime = info.endTime,
|
|
|
+ scode = info.code,
|
|
|
+ scope = info.scope,
|
|
|
+ school = info.school,
|
|
|
+ creatorId = info.creatorId,
|
|
|
+ subjects = sub,
|
|
|
+ blob = null,
|
|
|
+ owner = info.owner
|
|
|
|
|
|
- };
|
|
|
- //var messageBlob = new ServiceBusMessage(notice.ToJsonString());
|
|
|
- //messageBlob.ApplicationProperties.Add("name", "Notice");
|
|
|
- //await _serviceBus.GetServiceBusClient().SendMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageBlob);
|
|
|
- #endregion
|
|
|
- if (examClassResults.Count == 0)
|
|
|
- {
|
|
|
- foreach (string cla in info.classes)
|
|
|
- {
|
|
|
- int m = 0;
|
|
|
- foreach (ExamSubject subject in info.subjects)
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (studentss.IsNotEmpty())
|
|
|
{
|
|
|
- string classCode = "";
|
|
|
- if (string.IsNullOrEmpty(info.school) || !info.scope.Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
+ studentss.ForEach(x =>
|
|
|
{
|
|
|
- classCode = "ExamClassResult-" + info.creatorId;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- classCode = "ExamClassResult-" + info.school;
|
|
|
- }
|
|
|
- ExamClassResult result = new ExamClassResult
|
|
|
- {
|
|
|
- code = classCode,
|
|
|
- examId = info.id,
|
|
|
- id = Guid.NewGuid().ToString(),
|
|
|
- subjectId = subject.id,
|
|
|
- year = info.year,
|
|
|
- scope = info.scope
|
|
|
- };
|
|
|
- result.info.id = cla;
|
|
|
- List<string> ans = new List<string>();
|
|
|
- List<List<string>> anses = new List<List<string>>();
|
|
|
- List<double> ansPoint = new List<double>();
|
|
|
- List<string> ids = new List<string>();
|
|
|
- foreach (double p in info.papers[m].point)
|
|
|
- {
|
|
|
- //ans.Add(new List<string>());
|
|
|
- anses.Add(new List<string>());
|
|
|
- ansPoint.Add(-1);
|
|
|
- }
|
|
|
- var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"Class-{info.school}"));
|
|
|
- if (sresponse.Status == 200)
|
|
|
+ stuActivities.Add(new StuActivity
|
|
|
+ {
|
|
|
+ pk = "Activity",
|
|
|
+ id = info.id,
|
|
|
+ code = $"Activity-{info.school}-{x.id}",
|
|
|
+ type = "Exam",
|
|
|
+ name = info.name,
|
|
|
+ startTime = info.startTime,
|
|
|
+ endTime = info.endTime,
|
|
|
+ scode = info.code,
|
|
|
+ scope = info.scope,
|
|
|
+ school = info.school,
|
|
|
+ creatorId = info.creatorId,
|
|
|
+ subjects = sub,
|
|
|
+ blob = null,
|
|
|
+ owner = info.owner
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ await TriggerStuActivity.SaveStuActivity(client, _dingDing, stuActivities, tmdActivities);
|
|
|
+ //向学生或醍摩豆账号发起通知
|
|
|
+ #region
|
|
|
+ Notice notice = new Notice()
|
|
|
+ {
|
|
|
+ msgId = info.id,
|
|
|
+ creation = info.startTime,
|
|
|
+ expire = info.endTime,
|
|
|
+ creatorId = info.creatorId,
|
|
|
+ stuids = studentss,
|
|
|
+ tmdids = tmdids,
|
|
|
+ type = "notice",//评测参加通知
|
|
|
+ priority = "normal",
|
|
|
+ school = info.school,
|
|
|
+ scope = info.scope,
|
|
|
+ //data = new { }.ToJsonString()
|
|
|
+ body = new Body { sid = info.id, scode = info.code, spk = info.pk, biztype = "exam-join" }
|
|
|
+
|
|
|
+ };
|
|
|
+ //var messageBlob = new ServiceBusMessage(notice.ToJsonString());
|
|
|
+ //messageBlob.ApplicationProperties.Add("name", "Notice");
|
|
|
+ //await _serviceBus.GetServiceBusClient().SendMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageBlob);
|
|
|
+ #endregion
|
|
|
+ if (examClassResults.Count == 0)
|
|
|
+ {
|
|
|
+ foreach (string cla in info.classes)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
|
|
|
- Class classroom = json.ToObject<Class>();
|
|
|
- //result.info.id = classroom.id;
|
|
|
- result.info.name = classroom.name;
|
|
|
- result.gradeId = classroom.gradeId;
|
|
|
- //处理班级人数
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.classId = '{classroom.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{info.school}") }))
|
|
|
+ int m = 0;
|
|
|
+ foreach (ExamSubject subject in info.subjects)
|
|
|
{
|
|
|
- using var json_stu = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json_stu.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ string classCode = "";
|
|
|
+ if (string.IsNullOrEmpty(info.school) || !info.scope.Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ classCode = "ExamClassResult-" + info.creatorId;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ classCode = "ExamClassResult-" + info.school;
|
|
|
+ }
|
|
|
+ ExamClassResult result = new ExamClassResult
|
|
|
{
|
|
|
- var accounts = json_stu.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
+ code = classCode,
|
|
|
+ examId = info.id,
|
|
|
+ id = Guid.NewGuid().ToString(),
|
|
|
+ subjectId = subject.id,
|
|
|
+ year = info.year,
|
|
|
+ scope = info.scope
|
|
|
+ };
|
|
|
+ result.info.id = cla;
|
|
|
+ List<string> ans = new List<string>();
|
|
|
+ List<List<string>> anses = new List<List<string>>();
|
|
|
+ List<double> ansPoint = new List<double>();
|
|
|
+ List<string> ids = new List<string>();
|
|
|
+ foreach (double p in info.papers[m].point)
|
|
|
+ {
|
|
|
+ //ans.Add(new List<string>());
|
|
|
+ anses.Add(new List<string>());
|
|
|
+ ansPoint.Add(-1);
|
|
|
+ }
|
|
|
+ var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"Class-{info.school}"));
|
|
|
+ if (sresponse.Status == 200)
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
|
|
|
+ Class classroom = json.ToObject<Class>();
|
|
|
+ //result.info.id = classroom.id;
|
|
|
+ result.info.name = classroom.name;
|
|
|
+ result.gradeId = classroom.gradeId;
|
|
|
+ //处理班级人数
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.classId = '{classroom.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{info.school}") }))
|
|
|
{
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- ids.Add(account.GetProperty("id").GetString());
|
|
|
+ using var json_stu = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json_stu.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ var accounts = json_stu.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
+ {
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ ids.Add(account.GetProperty("id").GetString());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- if (info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
|
|
|
- {
|
|
|
- var stuResponse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"StuList"));
|
|
|
- if (stuResponse.Status == 200)
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
|
|
|
- StuList stuList = json.ToObject<StuList>();
|
|
|
- //result.info.id = stuList.id;
|
|
|
- result.info.name = stuList.name;
|
|
|
- //处理发布对象为自选名单(个人)
|
|
|
-
|
|
|
- foreach (Students stus in stuList.students)
|
|
|
+ if (info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
+ var stuResponse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"StuList"));
|
|
|
+ if (stuResponse.Status == 200)
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
|
|
|
+ StuList stuList = json.ToObject<StuList>();
|
|
|
+ //result.info.id = stuList.id;
|
|
|
+ result.info.name = stuList.name;
|
|
|
+ //处理发布对象为自选名单(个人)
|
|
|
+
|
|
|
+ foreach (Students stus in stuList.students)
|
|
|
+ {
|
|
|
|
|
|
- ids.Add(stus.id);
|
|
|
+ ids.Add(stus.id);
|
|
|
+ }
|
|
|
+ if (stuList.tmids.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (string tid in stuList.tmids)
|
|
|
+ {
|
|
|
+ ids.Add(tid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- if (stuList.tmids.Count > 0)
|
|
|
+ else
|
|
|
{
|
|
|
- foreach (string tid in stuList.tmids)
|
|
|
+ var stuResponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"StuList-{info.school}"));
|
|
|
+ if (stuResponse.Status == 200)
|
|
|
{
|
|
|
- ids.Add(tid);
|
|
|
+ using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
|
|
|
+ StuList stuList = json.ToObject<StuList>();
|
|
|
+ //result.info.id = stuList.id;
|
|
|
+ result.info.name = stuList.name;
|
|
|
+ //处理发布对象为自选名单(校本)
|
|
|
+ foreach (Students stus in stuList.students)
|
|
|
+ {
|
|
|
+ ids.Add(stus.id);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ foreach (string stu in ids)
|
|
|
+ {
|
|
|
+ result.mark.Add("");
|
|
|
+ result.studentIds.Add(stu);
|
|
|
+ result.studentAnswers.Add(ans);
|
|
|
+ result.studentScores.Add(ansPoint);
|
|
|
+ result.ans.Add(anses);
|
|
|
+ result.sum.Add(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ //result.progress = info.progress;
|
|
|
+ result.school = info.school;
|
|
|
+ m++;
|
|
|
+ await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"{result.code}"));
|
|
|
}
|
|
|
}
|
|
|
+ // 发送信息通知
|
|
|
+ var messageEnd = new ServiceBusMessage(new { id = input.Id, progress = "finish", code = code }.ToJsonString());
|
|
|
+ messageEnd.ApplicationProperties.Add("name", "Exam");
|
|
|
+ if (records.Count > 0)
|
|
|
+ {
|
|
|
+ long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
|
|
|
+ await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), records[0].sequenceNumber);
|
|
|
+ records[0].sequenceNumber = end;
|
|
|
+ await _azureStorage.SaveOrUpdate<ChangeRecord>(records[0]);
|
|
|
+ //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
- var stuResponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"StuList-{info.school}"));
|
|
|
- if (stuResponse.Status == 200)
|
|
|
+ long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
|
|
|
+ ChangeRecord changeRecord = new ChangeRecord
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
|
|
|
- StuList stuList = json.ToObject<StuList>();
|
|
|
- //result.info.id = stuList.id;
|
|
|
- result.info.name = stuList.name;
|
|
|
- //处理发布对象为自选名单(校本)
|
|
|
- foreach (Students stus in stuList.students)
|
|
|
- {
|
|
|
- ids.Add(stus.id);
|
|
|
- }
|
|
|
- }
|
|
|
+ RowKey = input.Id,
|
|
|
+ PartitionKey = "going",
|
|
|
+ sequenceNumber = end,
|
|
|
+ msgId = messageEnd.MessageId
|
|
|
+ };
|
|
|
+ await _azureStorage.Save<ChangeRecord>(changeRecord);
|
|
|
+ //await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
|
|
|
}
|
|
|
- foreach (string stu in ids)
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //处理单科结算时科目与试卷信息匹配的问题
|
|
|
+ int gno = 0;
|
|
|
+ foreach (ExamSubject subject in info.subjects)
|
|
|
{
|
|
|
- result.mark.Add("");
|
|
|
- result.studentIds.Add(stu);
|
|
|
- result.studentAnswers.Add(ans);
|
|
|
- result.studentScores.Add(ansPoint);
|
|
|
- result.ans.Add(anses);
|
|
|
- result.sum.Add(0);
|
|
|
+ if (subject.classCount == info.classes.Count)
|
|
|
+ {
|
|
|
+ await createClassResultAsync(info, examClassResults, subject, gno, _azureCosmos, _dingDing, _azureStorage);
|
|
|
+ }
|
|
|
+ gno++;
|
|
|
}
|
|
|
-
|
|
|
- //result.progress = info.progress;
|
|
|
- result.school = info.school;
|
|
|
- m++;
|
|
|
- await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"{result.code}"));
|
|
|
}
|
|
|
}
|
|
|
- // 发送信息通知
|
|
|
- var messageEnd = new ServiceBusMessage(new { id = input.Id, progress = "finish", code = code }.ToJsonString());
|
|
|
- messageEnd.ApplicationProperties.Add("name", "Exam");
|
|
|
- if (records.Count > 0)
|
|
|
+ catch (Exception e)
|
|
|
{
|
|
|
- long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
|
|
|
- await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), records[0].sequenceNumber);
|
|
|
- records[0].sequenceNumber = end;
|
|
|
- await _azureStorage.SaveOrUpdate<ChangeRecord>(records[0]);
|
|
|
- //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
|
|
|
+ await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-评测going状态异常{e.Message}\n{e.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
}
|
|
|
- else
|
|
|
+ break;
|
|
|
+ case "finish":
|
|
|
+ int fno = 0;
|
|
|
+ try
|
|
|
{
|
|
|
- long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
|
|
|
- ChangeRecord changeRecord = new ChangeRecord
|
|
|
- {
|
|
|
- RowKey = input.Id,
|
|
|
- PartitionKey = "going",
|
|
|
- sequenceNumber = end,
|
|
|
- msgId = messageEnd.MessageId
|
|
|
- };
|
|
|
- await _azureStorage.Save<ChangeRecord>(changeRecord);
|
|
|
- //await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //处理单科结算时科目与试卷信息匹配的问题
|
|
|
- int gno = 0;
|
|
|
- foreach (ExamSubject subject in info.subjects)
|
|
|
- {
|
|
|
- if (subject.classCount == info.classes.Count)
|
|
|
+ foreach (ExamSubject subject in info.subjects)
|
|
|
{
|
|
|
- await createClassResultAsync(info, examClassResults, subject, gno, _azureCosmos, _dingDing, _azureStorage);
|
|
|
+ await createClassResultAsync(info, examClassResults, subject, fno, _azureCosmos, _dingDing, _azureStorage);
|
|
|
+ fno++;
|
|
|
}
|
|
|
- gno++;
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case "finish":
|
|
|
- int fno = 0;
|
|
|
- foreach (ExamSubject subject in info.subjects)
|
|
|
- {
|
|
|
- await createClassResultAsync(info, examClassResults, subject, fno, _azureCosmos, _dingDing, _azureStorage);
|
|
|
- fno++;
|
|
|
- }
|
|
|
|
|
|
- //计算单次考试简易统计信息
|
|
|
- List<ExamResult> examResults = new List<ExamResult>();
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(
|
|
|
- queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}") }))
|
|
|
- {
|
|
|
- examResults.Add(item);
|
|
|
- }
|
|
|
- //结算单科单班的标准差和平均分
|
|
|
- foreach (ExamClassResult classResult in examClassResults)
|
|
|
- {
|
|
|
- //标记单科单班总得分
|
|
|
- double subScore = 0;
|
|
|
- //标准差
|
|
|
- double sPowSum = 0;
|
|
|
- var scount = classResult.studentIds.Count;
|
|
|
- foreach (List<double> sc in classResult.studentScores)
|
|
|
- {
|
|
|
- subScore += sc.Sum();
|
|
|
- }
|
|
|
- foreach (string sid in classResult.studentIds)
|
|
|
- {
|
|
|
- double ssc = classResult.studentScores[classResult.studentIds.IndexOf(sid)].Sum();
|
|
|
- sPowSum += Math.Pow(ssc - scount > 0 ? Math.Round(subScore * 1.0 / scount, 2) : 0, 2);
|
|
|
+ //计算单次考试简易统计信息
|
|
|
+ List<ExamResult> examResults = new List<ExamResult>();
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(
|
|
|
+ queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}") }))
|
|
|
+ {
|
|
|
+ examResults.Add(item);
|
|
|
+ }
|
|
|
+ //结算单科单班的标准差和平均分
|
|
|
+ foreach (ExamClassResult classResult in examClassResults)
|
|
|
+ {
|
|
|
+ //标记单科单班总得分
|
|
|
+ double subScore = 0;
|
|
|
+ //标准差
|
|
|
+ double sPowSum = 0;
|
|
|
+ var scount = classResult.studentIds.Count;
|
|
|
+ foreach (List<double> sc in classResult.studentScores)
|
|
|
+ {
|
|
|
+ List<double> newSc = new List<double>();
|
|
|
+ foreach (double ssc in sc)
|
|
|
+ {
|
|
|
+ if (ssc == -1)
|
|
|
+ {
|
|
|
+ newSc.Add(0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ newSc.Add(ssc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subScore += newSc.Sum();
|
|
|
+ }
|
|
|
+ foreach (string sid in classResult.studentIds)
|
|
|
+ {
|
|
|
+ double ssc = classResult.studentScores[classResult.studentIds.IndexOf(sid)].Sum();
|
|
|
+ sPowSum += Math.Pow(ssc - scount > 0 ? Math.Round(subScore * 1.0 / scount, 2) : 0, 2);
|
|
|
|
|
|
- }
|
|
|
- classResult.standard = Math.Round(scount > 0 ? Math.Pow(sPowSum / scount, 0.5) : 0, 2);
|
|
|
- classResult.average = scount > 0 ? Math.Round(subScore / scount, 2) : 0;
|
|
|
- await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
|
|
|
- }
|
|
|
- //记录某次考试所有学生得分总分
|
|
|
- double score = 0;
|
|
|
- double allScore = 0;
|
|
|
- int stuCount = 0;
|
|
|
- //整体平均分
|
|
|
- double average = 0;
|
|
|
- //标准差
|
|
|
- double powSum = 0;
|
|
|
- List<string> losStu = new List<string>();
|
|
|
- //先与第一个值取并集
|
|
|
- if (examResults.Count > 0)
|
|
|
- {
|
|
|
- losStu.Union(examResults[0].lostStus);
|
|
|
- foreach (ExamResult examResult in examResults)
|
|
|
- {
|
|
|
- if (info.id == examResult.examId)
|
|
|
+ }
|
|
|
+ classResult.standard = Math.Round(scount > 0 ? Math.Pow(sPowSum / scount, 0.5) : 0, 2);
|
|
|
+ classResult.average = scount > 0 ? Math.Round(subScore / scount, 2) : 0;
|
|
|
+ classResult.progress = true;
|
|
|
+ await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
|
|
|
+ }
|
|
|
+ //记录某次考试所有学生得分总分
|
|
|
+ double score = 0;
|
|
|
+ double allScore = 0;
|
|
|
+ int stuCount = 0;
|
|
|
+ //标准差
|
|
|
+ double powSum = 0;
|
|
|
+ List<string> losStu = new List<string>();
|
|
|
+ //先与第一个值取并集
|
|
|
+ if (examResults.Count > 0)
|
|
|
{
|
|
|
- foreach (List<double> sc in examResult.studentScores)
|
|
|
+ losStu = losStu.Union(examResults[0].lostStus).ToList();
|
|
|
+ foreach (ExamResult examResult in examResults)
|
|
|
{
|
|
|
- score += sc.Sum();
|
|
|
+ if (info.id == examResult.examId)
|
|
|
+ {
|
|
|
+ foreach (List<double> sc in examResult.studentScores)
|
|
|
+ {
|
|
|
+ score += sc.Sum();
|
|
|
+ }
|
|
|
+ stuCount = examResult.studentIds.Count;
|
|
|
+ }
|
|
|
+ //powSum += Math.Pow(score - examResult.studentIds.Count > 0 ? Math.Round(score * 1.0 / examResult.studentIds.Count, 2) : 0, 2);
|
|
|
+ //取交集
|
|
|
+ losStu = losStu.Intersect(examResult.lostStus).ToList();
|
|
|
}
|
|
|
- stuCount = examResult.studentIds.Count;
|
|
|
}
|
|
|
- //powSum += Math.Pow(score - examResult.studentIds.Count > 0 ? Math.Round(score * 1.0 / examResult.studentIds.Count, 2) : 0, 2);
|
|
|
- //取交集
|
|
|
- losStu = losStu.Intersect(examResult.lostStus).ToList();
|
|
|
+ double NewsRateScore = stuCount > 0 ? Math.Round(score * 1.0 / stuCount, 2) : 0;
|
|
|
+ foreach (PaperSimple simple in info.papers)
|
|
|
+ {
|
|
|
+ allScore += simple.point.Sum();
|
|
|
+ }
|
|
|
+ //计算全科标准差
|
|
|
+ foreach (string id in examResults[0].studentIds)
|
|
|
+ {
|
|
|
+ double sc = 0;
|
|
|
+ foreach (ExamResult result in examResults)
|
|
|
+ {
|
|
|
+ sc += result.studentScores[result.studentIds.IndexOf(id)].Sum();
|
|
|
+ }
|
|
|
+ powSum += Math.Pow(sc - NewsRateScore, 2);
|
|
|
+ }
|
|
|
+ info.standard = Math.Round(examResults[0].studentIds.Count > 0 ? Math.Pow(powSum / examResults[0].studentIds.Count, 0.5) : 0, 2);
|
|
|
+ double NewsRate = allScore > 0 ? Math.Round(NewsRateScore / allScore * 100, 2) : 0;
|
|
|
+ info.lostStu = losStu;
|
|
|
+ //判断均分是否发生变化,便于实时的更新评测基本信息
|
|
|
+ if (info.sRate != NewsRate || info.average != NewsRateScore)
|
|
|
+ {
|
|
|
+ info.sRate = NewsRate;
|
|
|
+ info.average = NewsRateScore;
|
|
|
+ await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new Azure.Cosmos.PartitionKey(info.code));
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- double NewsRateScore = stuCount > 0 ? Math.Round(score * 1.0 / stuCount, 2) : 0;
|
|
|
- foreach (PaperSimple simple in info.papers)
|
|
|
- {
|
|
|
- allScore += simple.point.Sum();
|
|
|
- }
|
|
|
- //计算全科标准差
|
|
|
- foreach (string id in examResults[0].studentIds)
|
|
|
- {
|
|
|
- double sc = 0;
|
|
|
- foreach (ExamResult result in examResults)
|
|
|
+ catch (Exception e)
|
|
|
{
|
|
|
- sc += result.studentScores[result.studentIds.IndexOf(id)].Sum();
|
|
|
+ await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-评测finish状态异常{e.Message}\n{e.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
}
|
|
|
- powSum += Math.Pow(sc - NewsRateScore, 2);
|
|
|
- }
|
|
|
- info.standard = Math.Round(examResults[0].studentIds.Count > 0 ? Math.Pow(powSum / examResults[0].studentIds.Count, 0.5) : 0, 2);
|
|
|
- double NewsRate = allScore > 0 ? Math.Round(NewsRateScore / allScore * 100, 2) : 0;
|
|
|
- info.lostStu = losStu;
|
|
|
- //判断均分是否发生变化,便于实时的更新评测基本信息
|
|
|
- if (info.sRate != NewsRate || info.average != NewsRateScore)
|
|
|
- {
|
|
|
- info.sRate = NewsRate;
|
|
|
- info.average = NewsRateScore;
|
|
|
- await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new Azure.Cosmos.PartitionKey(info.code));
|
|
|
- }
|
|
|
- break;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ 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)
|
|
@@ -445,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;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -472,7 +510,7 @@ namespace TEAMModelFunction
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"评测作答记录结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-评测作答记录结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -532,32 +570,36 @@ namespace TEAMModelFunction
|
|
|
foreach (string id in classResult.studentIds)
|
|
|
{
|
|
|
int index = classResult.studentIds.IndexOf(id);
|
|
|
- if (classResult.studentScores[index].Count > 0)
|
|
|
+ if (classResult.studentScores.Count > 0)
|
|
|
{
|
|
|
- score += classResult.studentScores[index][n];
|
|
|
- if (classResult.studentScores[index].Sum() >= rhw && phcount < rhwCount)
|
|
|
+ if (classResult.studentScores[index].Count > 0)
|
|
|
{
|
|
|
- if (classResult.studentScores[index][n] == 0)
|
|
|
+ score += classResult.studentScores[index][n] == -1 ? 0 : classResult.studentScores[index][n];
|
|
|
+ if (classResult.studentScores[index].Sum() >= rhw && phcount < rhwCount)
|
|
|
{
|
|
|
- phCount++;
|
|
|
+ if (classResult.studentScores[index][n] <= 0)
|
|
|
+ {
|
|
|
+ phCount++;
|
|
|
+ }
|
|
|
+ phcount++;
|
|
|
+ continue;
|
|
|
}
|
|
|
- phcount++;
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (classResult.studentScores[index].Sum() <= rhl && plcount < (info.stuCount - rhlCount))
|
|
|
- {
|
|
|
- if (classResult.studentScores[index][n] == 0)
|
|
|
+ if (classResult.studentScores[index].Sum() <= rhl && plcount < (info.stuCount - rhlCount))
|
|
|
{
|
|
|
- plCount++;
|
|
|
+ if (classResult.studentScores[index][n] <= 0)
|
|
|
+ {
|
|
|
+ plCount++;
|
|
|
+ }
|
|
|
+ plcount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (classResult.studentScores[index][n] <= 0)
|
|
|
+ {
|
|
|
+ pCount++;
|
|
|
}
|
|
|
- plcount++;
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (classResult.studentScores[index][n] == 0)
|
|
|
- {
|
|
|
- pCount++;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
n++;
|
|
@@ -578,7 +620,7 @@ namespace TEAMModelFunction
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"评测知识点结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-评测知识点结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -624,30 +666,33 @@ namespace TEAMModelFunction
|
|
|
foreach (string id in classResult.studentIds)
|
|
|
{
|
|
|
int index = classResult.studentIds.IndexOf(id);
|
|
|
- if (classResult.studentScores[index].Count > 0)
|
|
|
+ if (classResult.studentScores.Count > 0)
|
|
|
{
|
|
|
- score += classResult.studentScores[index][n];
|
|
|
- if (classResult.studentScores[index].Sum() >= rhw && phcount < rhwCount)
|
|
|
+ if (classResult.studentScores[index].Count > 0)
|
|
|
{
|
|
|
- if (classResult.studentScores[index][n] == 0)
|
|
|
+ score += classResult.studentScores[index][n] == -1 ? 0 : classResult.studentScores[index][n];
|
|
|
+ if (classResult.studentScores[index].Sum() >= rhw && phcount < rhwCount)
|
|
|
{
|
|
|
- phCount++;
|
|
|
+ if (classResult.studentScores[index][n] <= 0)
|
|
|
+ {
|
|
|
+ phCount++;
|
|
|
+ }
|
|
|
+ phcount++;
|
|
|
+ continue;
|
|
|
}
|
|
|
- phcount++;
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (classResult.studentScores[index].Sum() <= rhl && plcount < (info.stuCount - rhlCount))
|
|
|
- {
|
|
|
- if (classResult.studentScores[index][n] == 0)
|
|
|
+ if (classResult.studentScores[index].Sum() <= rhl && plcount < (info.stuCount - rhlCount))
|
|
|
{
|
|
|
- plCount++;
|
|
|
+ if (classResult.studentScores[index][n] <= 0)
|
|
|
+ {
|
|
|
+ plCount++;
|
|
|
+ }
|
|
|
+ plcount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (classResult.studentScores[index][n] <= 0)
|
|
|
+ {
|
|
|
+ pCount++;
|
|
|
}
|
|
|
- plcount++;
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (classResult.studentScores[index][n] == 0)
|
|
|
- {
|
|
|
- pCount++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -670,7 +715,7 @@ namespace TEAMModelFunction
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"评测认知层次结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-评测认知层次结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
}
|
|
|
}
|
|
|
//处理选题计数
|
|
@@ -791,7 +836,12 @@ namespace TEAMModelFunction
|
|
|
{
|
|
|
result.studentIds.Add(id);
|
|
|
}
|
|
|
- csRate.Add(result.studentIds.Count > 0 ? Math.Round(classSrate * 1.0 / classResult.studentIds.Count, 2) : 0 / allScore);
|
|
|
+ if (allScore > 0)
|
|
|
+ {
|
|
|
+ csRate.Add(classResult.studentIds.Count > 0 ? Math.Round(classSrate * 1.0 / classResult.studentIds.Count, 2) : 0 / allScore);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//powSum += Math.Pow(classSrate - result.average, 2);
|
|
|
//处理选项计数内容
|
|
|
}
|
|
@@ -817,7 +867,7 @@ namespace TEAMModelFunction
|
|
|
result.csRate = csRate;
|
|
|
result.lostStus = lostStu;
|
|
|
|
|
|
- result.sRate = Math.Round(result.average / allScore * 100, 2);
|
|
|
+ result.sRate = allScore > 0 ? Math.Round(result.average / allScore * 100, 2) : 0;
|
|
|
result.classes = classRanges;
|
|
|
result.code = "ExamResult-" + info.id;
|
|
|
result.school = info.school;
|