|
@@ -177,11 +177,11 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
{
|
|
|
int year = DateTimeOffset.UtcNow.Year;
|
|
|
string hs = lessonBase?.report?.clientSummaryList.ToJsonString();
|
|
|
- var clientSummaryList = lessonBase?.report?.clientSummaryList?.Where(x => x.groupTaskCompleteCount != 0 || x.groupScore != 0 || x.score != 0 || x.tnteractScore != 0 || x.taskCompleteCount != 0);
|
|
|
+ var clientSummaryLists = 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())
|
|
|
+ if (clientSummaryLists.Any())
|
|
|
{
|
|
|
- var ids = clientSummaryList.Select(x => x.seatID);
|
|
|
+ var ids = clientSummaryLists.Select(x => x.seatID);
|
|
|
students = lessonBase.student.Where(x => ids.Contains(x.seatID));
|
|
|
}
|
|
|
List<Student> studentsBase = new List<Student>();
|
|
@@ -223,18 +223,21 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
if (!string.IsNullOrWhiteSpace(school)) {
|
|
|
schoolBase = await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
period = schoolBase.period.Find(x => x.id.Equals($"{lessonRecord.periodId}"));
|
|
|
- dataSemester= SchoolService.GetSemester(period);
|
|
|
+ if (period!= null) {
|
|
|
+ dataSemester= SchoolService.GetSemester(period);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
List <Task<ItemResponse<StudentScoreRecord>>> records = new List<Task<ItemResponse<StudentScoreRecord>>>();
|
|
|
HashSet <OverallEducation> overallEducations = new HashSet<OverallEducation>();
|
|
|
- stuids.ToList().ForEach(async x => {
|
|
|
+ foreach (var x in stuids) {
|
|
|
var record = lessonStudentRecords.Find(l => l.stuid.Equals(x.id) && l.code.Equals($"StudentScoreRecord") && l.school.Equals(x.school));
|
|
|
ClientSummaryList clientSummaryList = lessonBase.report.clientSummaryList.Find(c => c.seatID == x.seatID);
|
|
|
if (record != null)
|
|
|
{
|
|
|
if (clientSummaryList != null)
|
|
|
{
|
|
|
- var hasrecord= record.lessonRecords.Find(x => x.lessonId.Equals(lessonRecord.id));
|
|
|
+ var hasrecord = record.lessonRecords.Find(x => x.lessonId.Equals(lessonRecord.id));
|
|
|
if (hasrecord != null)
|
|
|
{
|
|
|
hasrecord.gscore = clientSummaryList.groupScore;
|
|
@@ -249,7 +252,8 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
hasrecord.subjectId = lessonRecord.subjectId;
|
|
|
hasrecord.time = lessonRecord.startTime;
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
record.lessonRecords.Add(
|
|
|
new StudentLessonRecord
|
|
|
{
|
|
@@ -266,7 +270,7 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
time = lessonRecord.startTime
|
|
|
}
|
|
|
);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -302,13 +306,15 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
record.gscore = record.lessonRecords.Select(x => x.gscore).Sum();
|
|
|
record.pscore = record.lessonRecords.Select(x => x.pscore).Sum();
|
|
|
record.tscore = record.lessonRecords.Select(x => x.tscore).Sum();
|
|
|
- if (dataSemester.currSemester != null && (clientSummaryList.groupScore>0 || clientSummaryList.score > 0 || clientSummaryList.tnteractScore > 0)) {
|
|
|
- string oid = $"{dataSemester.studyYear}-{dataSemester.currSemester.id}-{record.stuid}";
|
|
|
+ if (dataSemester.currSemester != null && (clientSummaryList.groupScore>0 || clientSummaryList.score > 0 || clientSummaryList.tnteractScore > 0))
|
|
|
+ {
|
|
|
+ string oid = $"{dataSemester.studyYear}-{dataSemester.currSemester.id}-{record.stuid}";
|
|
|
string ocode = $"OverallEducation-{school}";
|
|
|
- var student= studentsBase.Find(stu => stu.id.Equals(x.id));
|
|
|
+ var student = studentsBase.Find(stu => stu.id.Equals(x.id));
|
|
|
Azure.Response response = await client.GetContainer(Constant.TEAMModelOS, Constant.Student).ReadItemStreamAsync(oid, new PartitionKey(ocode));
|
|
|
OverallEducation overallEducation = null;
|
|
|
- if (response.Status != 200) {
|
|
|
+ if (response.Status != 200)
|
|
|
+ {
|
|
|
overallEducation = new OverallEducation
|
|
|
{
|
|
|
id =oid,
|
|
@@ -339,7 +345,8 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
}}
|
|
|
};
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
overallEducation=JsonDocument.Parse(response.Content).RootElement.ToObject<OverallEducation>();
|
|
|
var hasrecord = overallEducation.lessonScore.Find(x => x.lessonId.Equals(lessonRecord.id));
|
|
|
if (hasrecord != null)
|
|
@@ -379,14 +386,17 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
overallEducations.Add(overallEducation);
|
|
|
}
|
|
|
records.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(record, partitionKey: new PartitionKey(record.code)));
|
|
|
- });
|
|
|
- tmdids.ToList().ForEach(x => {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ foreach (var x in tmdids) {
|
|
|
var record = lessonStudentRecords.Find(l => l.tmdid.Equals(x.id) && l.code.Equals($"StudentScoreRecord"));
|
|
|
ClientSummaryList clientSummaryList = lessonBase.report.clientSummaryList.Find(c => c.seatID == x.seatID);
|
|
|
if (record != null)
|
|
|
{
|
|
|
if (clientSummaryList != null)
|
|
|
- {
|
|
|
+ {
|
|
|
var hasrecord = record.lessonRecords.Find(x => x.lessonId.Equals(lessonRecord.id));
|
|
|
if (hasrecord != null)
|
|
|
{
|
|
@@ -424,7 +434,7 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
+ {
|
|
|
record = new StudentScoreRecord
|
|
|
{
|
|
|
userType = Constant.ScopeTmdUser,
|
|
@@ -434,7 +444,7 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
ttl = -1,
|
|
|
year = year,
|
|
|
tmdid = x.id,
|
|
|
- lessonRecords = new List<StudentLessonRecord>
|
|
|
+ lessonRecords = new List<StudentLessonRecord>
|
|
|
{
|
|
|
new StudentLessonRecord
|
|
|
{
|
|
@@ -458,8 +468,7 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
record.pscore = record.lessonRecords.Select(x => x.pscore).Sum();
|
|
|
record.tscore = record.lessonRecords.Select(x => x.tscore).Sum();
|
|
|
records.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(record, partitionKey: new PartitionKey(record.code)));
|
|
|
-
|
|
|
- });
|
|
|
+ }
|
|
|
if (records.Any())
|
|
|
{
|
|
|
await Task.WhenAll(records);
|