|
@@ -129,20 +129,26 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
}
|
|
|
if (count > 0) {
|
|
|
//生成token
|
|
|
- var token = JwtAuthExtension.CreateAuthToken(_option.HostName, id, name?.ToString(), picture?.ToString(), _option.JwtSecretKey, roles: new[] { "teacher" }, schoolID: $"{schoolId}");
|
|
|
+ var stoken = JwtAuthExtension.CreateAuthToken(_option.HostName, id, name?.ToString(), picture?.ToString(), _option.JwtSecretKey, roles: new[] { "teacher" }, schoolID: $"{schoolId}");
|
|
|
//获取学校线下阅卷评测
|
|
|
var sexams= await GetExam($"{schoolId}", "school", client);
|
|
|
- schools.Add(new ScanSchool { name = $"schoolName", picture = $"{schoolPicture}", code = $"{schoolId}", status = $"{schoolStatus}" ,token=token, datas = sexams });
|
|
|
+ var container = _azureStorage.GetBlobContainerClient($"{schoolId}");
|
|
|
+ await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建School容器,如存在則不做任何事,保障容器一定存在
|
|
|
+ var (sblob_uri, sblob_sas) = _azureStorage.GetBlobContainerSAS($"{schoolId}", BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List | BlobContainerSasPermissions.Write);
|
|
|
+ schools.Add(new ScanSchool { name = $"schoolName", picture = $"{schoolPicture}", code = $"{schoolId}", status = $"{schoolStatus}" ,token= stoken, exams = sexams, bloburl=sblob_uri ,blobsas=sblob_sas});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ var ttoken = JwtAuthExtension.CreateAuthToken(_option.HostName, id, name?.ToString(), picture?.ToString(), _option.JwtSecretKey, roles: new[] { "teacher" });
|
|
|
+ var (tblob_uri, tblob_sas) = _azureStorage.GetBlobContainerSAS(id, BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List | BlobContainerSasPermissions.Delete);
|
|
|
//获取个人线下阅卷评测
|
|
|
- var datas = await GetExam($"{id}", "private", client);
|
|
|
+ var exams = await GetExam($"{id}", "private", client);
|
|
|
//換取AuthToken,提供給前端
|
|
|
- var data = new { name, picture, id, schools , datas };
|
|
|
+ var data = new { name, picture, id, schools , exams, bloburl= tblob_uri, blobsas = tblob_sas, token= ttoken };
|
|
|
await sseClient.SendEventAsync(data.ToJsonString());
|
|
|
return Ok(data);
|
|
|
+ /////////////////////////////TODO 返回TMDID和学生的头像 名字 id
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -160,43 +166,59 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
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}") }))
|
|
|
+ //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}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Correct>(queryText: "SELECT * FROM c 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 });
|
|
|
+ List<ExamClass> classes = new List<ExamClass>();
|
|
|
+ foreach (var cls in exam.classes) {
|
|
|
+ (List<string> tmdids, List<Students> students) stulist = await TriggerStuActivity.GetStuList(client, _dingDing, new List<string> { cls }, code);
|
|
|
+ classes.Add(new ExamClass { classId = cls, tmdids = stulist.tmdids, stulist = stulist.students });
|
|
|
+ }
|
|
|
+ corrects.Add(new ExamData { exam = exam, correct = item, classes= classes });
|
|
|
|
|
|
}
|
|
|
}
|
|
|
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}") }))
|
|
|
+ // 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}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Correct>(queryText: "SELECT * FROM c 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 });
|
|
|
+ List<ExamClass> classes = new List<ExamClass>();
|
|
|
+ foreach (var cls in exam.classes)
|
|
|
+ {
|
|
|
+ (List<string> tmdids, List<Students> students) stulist = await TriggerStuActivity.GetStuList(client, _dingDing, new List<string> { cls }, code);
|
|
|
+ classes.Add(new ExamClass { classId = cls, tmdids = stulist.tmdids, stulist = stulist.students });
|
|
|
+ }
|
|
|
+ corrects.Add(new ExamData { exam = exam, correct = item, classes = classes });
|
|
|
}
|
|
|
}
|
|
|
return corrects;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public class ScanSchool
|
|
|
- {
|
|
|
+ public class ScanSchool
|
|
|
+ {
|
|
|
+ public string blobsas { get; set; }
|
|
|
+ public string bloburl { get; set; }
|
|
|
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 List<ExamData> exams { get; set; }
|
|
|
}
|
|
|
|
|
|
public class ExamData
|
|
|
{
|
|
|
public Correct correct { get; set; }
|
|
|
public ExamInfo exam { get; set; }
|
|
|
+ public List<ExamClass> classes { get; set; }
|
|
|
+ }
|
|
|
+ public class ExamClass {
|
|
|
+ public string classId { get; set; }
|
|
|
public List<string> tmdids { get; set; }
|
|
|
public List<Students> stulist { get; set; }
|
|
|
}
|