|
@@ -20,7 +20,12 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
public static async void DoLessonStudentRecord(LessonRecord lessonRecord, string scope, CosmosClient client, string school, string tmdid,
|
|
|
Teacher teacher, NotificationService _notificationService, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, IConfiguration _configuration, LessonBase lessonBase)
|
|
|
{
|
|
|
- var stuids = lessonBase.student.Where(x => x.type == 2);
|
|
|
+ var clientSummaryList =lessonBase.report.clientSummaryList.Where(x => x.groupTaskCompleteCount!=0 || x.groupScore != 0 || x.score != 0 || x.tnteractScore != 0 || x.taskCompleteCount!=0);
|
|
|
+ IEnumerable<LessonStudent> students = new List<LessonStudent>();
|
|
|
+ if (clientSummaryList.Any()) {
|
|
|
+ students= lessonBase.student.Where(x => clientSummaryList.Select(x => x.seatID).Contains(x.seatID));
|
|
|
+ }
|
|
|
+ var stuids = students.Where(x => x.type == 2);
|
|
|
if (stuids.Any()) {
|
|
|
stuids.ToList().ForEach(x => {
|
|
|
x.school = string.IsNullOrWhiteSpace(x.school) ? school : x.school;
|
|
@@ -36,7 +41,7 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- var tmdids = lessonBase.student.Where(x => x.type == 1);
|
|
|
+ var tmdids = students.Where(x => x.type == 1);
|
|
|
if (tmdids.Any()) {
|
|
|
string tmdsql = $"select value(c) from c where c.id in({string.Join(",", tmdids.Select(x => $"'{x}'"))})";
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<LessonStudentRecord>(queryText: tmdsql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"LessonStudentRecord") }))
|
|
@@ -47,31 +52,60 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
List<Task<ItemResponse<LessonStudentRecord>>> records = new List<Task<ItemResponse<LessonStudentRecord>>>();
|
|
|
stuids.ToList().ForEach(x => {
|
|
|
var record = lessonStudentRecords.Find(l => l.id.Equals(x.id) && l.code.Equals($"LessonStudentRecord-{x.school}"));
|
|
|
+ ClientSummaryList clientSummaryList = lessonBase.report.clientSummaryList.Find(c => c.seatID == x.seatID);
|
|
|
if (record != null)
|
|
|
{
|
|
|
- ClientSummaryList? clientSummaryList= lessonBase.report.clientSummaryList.Find(c => c.seatID == x.seatID);
|
|
|
- record.records.Add(new StudentRecord
|
|
|
- {
|
|
|
- tmdid = teacher.id,
|
|
|
- tmdname = teacher.name,
|
|
|
- name = lessonRecord.name,
|
|
|
- school = lessonRecord.school,
|
|
|
- scope = lessonRecord.scope,
|
|
|
- lessonId = lessonRecord.id,
|
|
|
- courseId = lessonRecord.courseId,
|
|
|
- periodId = lessonRecord.periodId,
|
|
|
- subjectId = lessonRecord.subjectId,
|
|
|
- report = clientSummaryList
|
|
|
-
|
|
|
- }) ;
|
|
|
+ if (clientSummaryList != null) {
|
|
|
+ if (clientSummaryList.groupScore > 0)
|
|
|
+ { record.groupScore.Add(clientSummaryList.groupScore); }
|
|
|
+ if (clientSummaryList.score > 0)
|
|
|
+ { record.personScore.Add(clientSummaryList.score); }
|
|
|
+ if (clientSummaryList.tnteractScore > 0)
|
|
|
+ { record.tnteractScore.Add(clientSummaryList.tnteractScore); }
|
|
|
+ }
|
|
|
}
|
|
|
- else {
|
|
|
+ else {
|
|
|
|
|
|
+ record = new LessonStudentRecord {id=x.id,code=$"LessonStudentRecord-{x.school}",pk= "LessonStudentRecord",ttl=-1 };
|
|
|
+ if (clientSummaryList.groupScore > 0)
|
|
|
+ { record.groupScore.Add(clientSummaryList.groupScore); }
|
|
|
+ if (clientSummaryList.score > 0)
|
|
|
+ { record.personScore.Add(clientSummaryList.score); }
|
|
|
+ if (clientSummaryList.tnteractScore > 0)
|
|
|
+ { record.tnteractScore.Add(clientSummaryList.tnteractScore); }
|
|
|
}
|
|
|
+ records.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(record, partitionKey: new PartitionKey(record.code)));
|
|
|
});
|
|
|
tmdids.ToList().ForEach(x => {
|
|
|
var record = lessonStudentRecords.Find(l => l.id.Equals(x.id) && l.code.Equals($"LessonStudentRecord"));
|
|
|
+ ClientSummaryList clientSummaryList = lessonBase.report.clientSummaryList.Find(c => c.seatID == x.seatID);
|
|
|
+ if (record != null)
|
|
|
+ {
|
|
|
+ if (clientSummaryList != null)
|
|
|
+ {
|
|
|
+ if (clientSummaryList.groupScore > 0)
|
|
|
+ { record.groupScore.Add(clientSummaryList.groupScore); }
|
|
|
+ if (clientSummaryList.score > 0)
|
|
|
+ { record.personScore.Add(clientSummaryList.score); }
|
|
|
+ if (clientSummaryList.tnteractScore > 0)
|
|
|
+ { record.tnteractScore.Add(clientSummaryList.tnteractScore); }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ record = new LessonStudentRecord { id = x.id, code = $"LessonStudentRecord", pk = "LessonStudentRecord", ttl = -1 };
|
|
|
+ if (clientSummaryList.groupScore > 0)
|
|
|
+ { record.groupScore.Add(clientSummaryList.groupScore); }
|
|
|
+ if (clientSummaryList.score > 0)
|
|
|
+ { record.personScore.Add(clientSummaryList.score); }
|
|
|
+ if (clientSummaryList.tnteractScore > 0)
|
|
|
+ { record.tnteractScore.Add(clientSummaryList.tnteractScore); }
|
|
|
+ }
|
|
|
+ records.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(record, partitionKey: new PartitionKey(record.code)));
|
|
|
});
|
|
|
+ if (records.Any()) {
|
|
|
+ await Task.WhenAll(records);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static async void DoAutoDeleteSchoolLessonRecord(LessonRecord lessonRecord,string scope ,CosmosClient client,string school,string tmdid,
|