|
@@ -6,6 +6,7 @@ using System.Text;
|
|
using System.Text.Json;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using TEAMModelOS.SDK.DI;
|
|
using TEAMModelOS.SDK.DI;
|
|
|
|
+using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
using TEAMModelOS.SDK.Models.Cosmos.Normal;
|
|
using TEAMModelOS.SDK.Models.Cosmos.Normal;
|
|
|
|
|
|
|
|
|
|
@@ -23,9 +24,14 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
/// <param name="type"></param>
|
|
/// <param name="type"></param>
|
|
/// <param name="azureCosmos"></param>
|
|
/// <param name="azureCosmos"></param>
|
|
/// <param name="azureStorage"></param>
|
|
/// <param name="azureStorage"></param>
|
|
- public static async Task PackageEvaluation( string id,string scope, string owner, string type, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage)
|
|
|
|
|
|
+ public static async Task PackageEvaluation( string id,string scope, string owner, string type, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage,CoreAPIHttpService _coreAPIHttpService, DingDing _dingDing)
|
|
{
|
|
{
|
|
EvaluationSyncInfo evaluationSyncInfo= null;
|
|
EvaluationSyncInfo evaluationSyncInfo= null;
|
|
|
|
+ string schoolCode = null;
|
|
|
|
+ if (scope.Equals("school"))
|
|
|
|
+ {
|
|
|
|
+ schoolCode= owner;
|
|
|
|
+ }
|
|
var responseEvaluationSyncInfo = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync(id, new PartitionKey("EvaluationSyncInfo"));
|
|
var responseEvaluationSyncInfo = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync(id, new PartitionKey("EvaluationSyncInfo"));
|
|
if (responseEvaluationSyncInfo.IsSuccessStatusCode)
|
|
if (responseEvaluationSyncInfo.IsSuccessStatusCode)
|
|
{
|
|
{
|
|
@@ -39,18 +45,89 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
type = type,
|
|
type = type,
|
|
pk="EvaluationSyncInfo",
|
|
pk="EvaluationSyncInfo",
|
|
code="ActivitySyncInfo",
|
|
code="ActivitySyncInfo",
|
|
-
|
|
|
|
};
|
|
};
|
|
}
|
|
}
|
|
switch (true)
|
|
switch (true)
|
|
{
|
|
{
|
|
case bool when (type == "Exam"):
|
|
case bool when (type == "Exam"):
|
|
- break;
|
|
|
|
|
|
+ {
|
|
|
|
+ string code = $"Exam-{owner}";
|
|
|
|
+ var response = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(id, new PartitionKey(code));
|
|
|
|
+ if (response.IsSuccessStatusCode)
|
|
|
|
+ {
|
|
|
|
+ ExamInfo exam= JsonDocument.Parse(response.Content).RootElement.Deserialize<ExamInfo>();
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(evaluationSyncInfo.shortCode))
|
|
|
|
+ {
|
|
|
|
+ evaluationSyncInfo.shortCode = $"{MurmurHash3.Hash32(exam.id)}";
|
|
|
|
+ }
|
|
|
|
+ evaluationSyncInfo.name=exam.name;
|
|
|
|
+ evaluationSyncInfo.subjects = exam.subjects?.Select(x=>new IES.ExamServer.Models.SubjectExam { id=x.id,name=x.name,examId=id}).ToList();
|
|
|
|
+ evaluationSyncInfo.dataTime= DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
|
|
|
+
|
|
|
|
+ HashSet<string> grouplist = new HashSet<string>();
|
|
|
|
+ if (exam.classes.IsNotEmpty()) {
|
|
|
|
+ exam.classes.ForEach(x => { grouplist.Add(x); });
|
|
|
|
+ }
|
|
|
|
+ if (exam.stuLists.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ exam.stuLists.ForEach(x => { grouplist.Add(x); });
|
|
|
|
+ }
|
|
|
|
+ evaluationSyncInfo.grouplist=grouplist.ToList() ;
|
|
|
|
+ evaluationSyncInfo.paperCount=exam.papers.IsNotEmpty()? exam.papers.Count():0;
|
|
|
|
+ foreach (var group in exam.papers.GroupBy(x=>x.subjectId).Select(x=>new { key = x.Key,list= x.ToList()}))
|
|
|
|
+ {
|
|
|
|
+ var subject= exam.subjects.Find(x => x.id.Equals(group.key));
|
|
|
|
+ if (subject!=null)
|
|
|
|
+ {
|
|
|
|
+ evaluationSyncInfo.subjects.Add(new IES.ExamServer.Models.SubjectExam {
|
|
|
|
+ id=subject.id,
|
|
|
|
+ name=subject.name,
|
|
|
|
+ examId=id,
|
|
|
|
+ paperCount= group.list.Count,
|
|
|
|
+ paperIds= group.list.Select(x => x.id).ToList()
|
|
|
|
+ } );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
case bool when (type == "Art"):
|
|
case bool when (type == "Art"):
|
|
|
|
+ {
|
|
|
|
+ string code = $"Art-{owner}";
|
|
|
|
+ var response = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(id, new PartitionKey(code));
|
|
|
|
+ if (response.IsSuccessStatusCode)
|
|
|
|
+ {
|
|
|
|
+ ArtEvaluation art = JsonDocument.Parse(response.Content).RootElement.Deserialize<ArtEvaluation>();
|
|
|
|
+ evaluationSyncInfo.subjects = art.subjects?.Select(x => new IES.ExamServer.Models.SubjectExam { id=x.id, name=x.name, examId=id }).ToList();
|
|
|
|
+ evaluationSyncInfo.name = art.name;
|
|
|
|
+ evaluationSyncInfo.dataTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
|
|
|
+ HashSet<string> grouplist = new HashSet<string>();
|
|
|
|
+ if (art.classes.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ art.classes.ForEach(x => { grouplist.Add(x); });
|
|
|
|
+ }
|
|
|
|
+ if (art.stuLists.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ art.stuLists.ForEach(x => { grouplist.Add(x); });
|
|
|
|
+ }
|
|
|
|
+ if (art.tchLists.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ art.tchLists.ForEach(x => { grouplist.Add(x); });
|
|
|
|
+ }
|
|
|
|
+ evaluationSyncInfo.grouplist=grouplist.ToList();
|
|
|
|
+ var quota_22 = art.settings.Find(x => x.id.Equals("quota_22"));
|
|
|
|
+ foreach (var item in quota_22.task)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+ var listInfo= await GroupListService.GetMemberByListids(_coreAPIHttpService, azureCosmos.GetCosmosClient(), _dingDing, evaluationSyncInfo.grouplist, schoolCode);
|
|
|
|
+ evaluationSyncInfo.studentCount = listInfo.rmembers.Count();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|