CrazyIter_Bin před 3 roky
rodič
revize
ea5cdd91f5

+ 6 - 21
TEAMModelOS.SDK/Models/Service/StatisticsService.cs

@@ -376,21 +376,21 @@ namespace TEAMModelOS.SDK
             {
                 studyRecords.Add(item);
             }
+            string rcdsql  = $" where c.id in ({string.Join(",", studies.FindAll(x=>!string.IsNullOrEmpty(x.workId)).Select(o => $"'{o.workId}'"))})";
             List<HomeworkRecord> homeworkRecords = new List<HomeworkRecord>();
             await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher")
-            .GetItemQueryIterator<HomeworkRecord>(queryText: $"select value(c) from c {insql} ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"HomeworkRecord-{_tmdid}") }))
+            .GetItemQueryIterator<HomeworkRecord>(queryText: $"select value(c) from c {rcdsql} ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"HomeworkRecord-{_tmdid}") }))
             {
                 homeworkRecords.Add(item);
             }
             List<OfflineRecord> offlines = new List<OfflineRecord>();
             activities.ForEach(item => {
                 Study study = studies.Find(y=>y.id.Equals(item.id));
-                StudyRecord studyRecord= studyRecords.Find(y => y.id.Equals(item.id));
-                HomeworkRecord homeworkRecord= homeworkRecords.Find(y => y.id.Equals(item.id));
-                Attachment attachment = homeworkRecord!=null ? homeworkRecord.content.Find(x => x.prime):null;
-                if (!string.IsNullOrEmpty(item.owner) && study != null && !item.owner.Equals("area") )
+                if (!string.IsNullOrEmpty(item.owner) && study != null && !string.IsNullOrEmpty(study.workId) && !item.owner.Equals("area") )
                 {
-                    
+                    StudyRecord studyRecord = studyRecords.Find(y => y.id.Equals(item.id));
+                    HomeworkRecord homeworkRecord = homeworkRecords.Find(y => y.id.Equals(study.workId));
+                    Attachment attachment = homeworkRecord != null ? homeworkRecord.content.Find(x => x.prime) : null;
                     OfflineRecord record = new OfflineRecord
                     {
                         id = item.id,
@@ -415,21 +415,6 @@ namespace TEAMModelOS.SDK
                         else {
                             record.score = -1;
                         }
-                        //取消转换
-                        //if (studyRecord.status == 1)
-                        //{
-                        //    record.score = 1;
-                        //    record.done = 1;
-                        //}
-                        //if (studyRecord.status == 0)
-                        //{
-                        //    record.score = -1;
-                        //}
-                        //if (studyRecord.status == 2)
-                        //{
-                        //    record.score = 0;
-                        //    record.done = 1;
-                        //}
                     }
                     if (null != attachment)
                     {