|
@@ -30,6 +30,8 @@ using System.Dynamic;
|
|
|
using Azure.Storage.Blobs.Models;
|
|
|
using Azure.Storage.Sas;
|
|
|
using Lib.AspNetCore.ServerSentEvents;
|
|
|
+using TEAMModelFunction;
|
|
|
+using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers.Core
|
|
|
{
|
|
@@ -121,23 +123,24 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
var schoolPicture = school.RootElement.GetProperty("picture");
|
|
|
//检查学校购买的模组是否包含阅卷模组
|
|
|
int count = 0;
|
|
|
- string sql = $" SELECT value(count(serial)) FROM c join serial in c.serial where c.id ='{schoolId}' and c.pk='Product' and serial.prodCode='YMPCVCIM' ";
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<int>(sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") })) {
|
|
|
+ string sql = $" SELECT value(count(product)) FROM c join product in c.service.product where c.id ='{schoolId}' and c.pk='Product' and product.prodCode='YMPCVCIM' ";
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<int>(sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") })) {
|
|
|
count = item;
|
|
|
}
|
|
|
if (count > 0) {
|
|
|
//生成token
|
|
|
var token = JwtAuthExtension.CreateAuthToken(_option.HostName, id, name?.ToString(), picture?.ToString(), _option.JwtSecretKey, roles: new[] { "teacher" }, schoolID: $"{schoolId}");
|
|
|
- //获取线下阅卷评测
|
|
|
-
|
|
|
- schools.Add(new ScanSchool { name = $"schoolName", picture = $"{schoolPicture}", code = $"{schoolId}", status = $"{schoolStatus}" ,token=token});
|
|
|
+ //获取学校线下阅卷评测
|
|
|
+ var sexams= await GetExam($"{schoolId}", "school", client);
|
|
|
+ schools.Add(new ScanSchool { name = $"schoolName", picture = $"{schoolPicture}", code = $"{schoolId}", status = $"{schoolStatus}" ,token=token, datas = sexams });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ //获取个人线下阅卷评测
|
|
|
+ var datas = await GetExam($"{id}", "private", client);
|
|
|
//換取AuthToken,提供給前端
|
|
|
- var data = new { name, picture, id, schools };
|
|
|
+ var data = new { name, picture, id, schools , datas };
|
|
|
await sseClient.SendEventAsync(data.ToJsonString());
|
|
|
return Ok(data);
|
|
|
}
|
|
@@ -152,18 +155,49 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
}
|
|
|
return Ok();
|
|
|
}
|
|
|
- private void GetExam(string code ,string scope)
|
|
|
+ private async Task<List<ExamData>> GetExam(string code ,string scope, CosmosClient client)
|
|
|
{
|
|
|
+ List<ExamData> corrects = new List<ExamData>();
|
|
|
+ if (scope.Equals("school"))
|
|
|
+ {
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Correct>(queryText: "SELECT * FROM c where c.source='2' and c.progress='going' order by c.createTime ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Correct-{code}") }))
|
|
|
+ {
|
|
|
+ ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(item.id, new PartitionKey($"Exam-{code}"));
|
|
|
+ (List<string> tmdids, List<Students> students)stulist =await TriggerStuActivity.GetStuList(client, _dingDing, exam.classes, code);
|
|
|
+
|
|
|
+ corrects.Add(new ExamData { exam = exam, correct = item,tmdids=stulist.tmdids,stulist=stulist.students });
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(scope.Equals("private")){
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Correct>(queryText: "SELECT * FROM c where c.source='2' and c.progress='going' order by c.createTime ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Correct-{code}") }))
|
|
|
+ {
|
|
|
|
|
|
+ ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(item.id, new PartitionKey($"Exam-{code}"));
|
|
|
+ (List<string> tmdids, List<Students> students) stulist = await TriggerStuActivity.GetStuList(client, _dingDing, exam.classes, code);
|
|
|
+ corrects.Add(new ExamData { exam = exam, correct = item, tmdids = stulist.tmdids, stulist = stulist.students });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return corrects;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public class ScanSchool {
|
|
|
+ public class ScanSchool
|
|
|
+ {
|
|
|
public string name { get; set; }
|
|
|
public string picture { get; set; }
|
|
|
public string code { get; set; }
|
|
|
public string status { get; set; }
|
|
|
public string token { get; set; }
|
|
|
+ // public List<(Correct,ExamInfo, (List<string> tmdids, List<Students> stulist))> exams{ get; set; }
|
|
|
+ public List<ExamData> datas { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
+ public class ExamData
|
|
|
+ {
|
|
|
+ public Correct correct { get; set; }
|
|
|
+ public ExamInfo exam { get; set; }
|
|
|
+ public List<string> tmdids { get; set; }
|
|
|
+ public List<Students> stulist { get; set; }
|
|
|
}
|
|
|
}
|