zhouj1203@hotmail.com 1 year ago
parent
commit
02aab7d4e0

+ 3 - 1
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -1877,7 +1877,9 @@ namespace TEAMModelOS.FunctionV4
             result.scope = info.scope;
             result.name = info.name;
             result.time = info.startTime;
-            await examRecordCount(info, subject, _dingDing, no, result, examClassResults, _azureCosmos);
+            if (info.qamode != 2) {
+                await examRecordCount(info, subject, _dingDing, no, result, examClassResults, _azureCosmos);
+            }          
             await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").UpsertItemAsync(result, new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}"));
             List<ErrorItems> errorItems = new();
             string code = string.Empty;

+ 5 - 5
TEAMModelOS/Controllers/Analysis/ArtAnalysisController.cs

@@ -194,7 +194,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 (KeyValuePair<string, List<string>> key1, KeyValuePair<string, List<string>> key2, KeyValuePair<string, List<(string name, double score, double average)>> key3,
                     KeyValuePair<string, List<(string name, double score)>> key4, KeyValuePair<string, List<(string name, double score, double point, string cId)>> key5,
                     KeyValuePair<string, List<(string name, double score, double point, string sId)>> key6) = DoKnowledgePoint(examResults[0], info);
-                //KeyValuePair<string, List<(string id, double sta, double pass, string stu)>> key = DoSubjectScatter(examResults[0]);
+                KeyValuePair<string, List<(string id, double sta, double pass, string stu)>> key = DoSubjectScatter(examResults[0]);
                 pointPersent.Add(key3);
                 stuPersent.Add(key6);
                 List<(string name, double score, double av)> blockScore = new();
@@ -328,9 +328,9 @@ namespace TEAMModelOS.Controllers.Analysis
                     classId = s.cd,
                     className = examResults[0].classes.Where(c => c.id.Equals(s.cd)).FirstOrDefault()?.name,
                     examResults[0].classes.Where(c => c.id.Equals(s.cd)).FirstOrDefault()?.gradeId,
-                    //key.Value.Where(c => c.id.Equals(s.sIds))?.FirstOrDefault().sta,
-                    //key.Value.Where(c => c.id.Equals(s.sIds))?.FirstOrDefault().pass,
-                    //key.Value.Where(c => c.id.Equals(s.sIds))?.FirstOrDefault().stu,
+                    key.Value.Where(c => c.id.Equals(s.sIds))?.FirstOrDefault().sta,
+                    key.Value.Where(c => c.id.Equals(s.sIds))?.FirstOrDefault().pass,
+                    key.Value.Where(c => c.id.Equals(s.sIds))?.FirstOrDefault().stu,
                     kno = key6.Value.Where(c => c.sId.Equals(s.sIds))?.Select(z => new
                     {
                         z.name,
@@ -424,7 +424,7 @@ namespace TEAMModelOS.Controllers.Analysis
                     return Ok(new { count = tchList.Count, scount = realCount, max, min, average, excellent, pass, pow, blk, kno, dim, optCount, students, cInfo , gscore });
                 }
                 else {
-                    return Ok(new { count = tchList.Count, scount = realCount, max, min, average, excellent, pass, pow, blk, kno, dim, optCount, students, cInfo , gscore });
+                    return Ok(new { count = tchList.Count, scount = realCount, max, min, average, excellent, pass, pow, blk, kno, dim, optCount, cInfo  });
                 }
                 
             }

+ 45 - 4
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -48,6 +48,7 @@ using Azure.Storage.Blobs.Models;
 using Top.Api;
 using Newtonsoft.Json.Linq;
 using System.IO;
+using DocumentFormat.OpenXml.Office2010.Excel;
 
 namespace TEAMModelOS.Controllers
 {
@@ -218,6 +219,7 @@ namespace TEAMModelOS.Controllers
                     }
                     exam = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                     await BIStats.SetTypeAddStats(client, _dingDing, exam.school, "Exam", 1);//BI统计增/减量
+                    //await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client = "web/hiteach", count = 1, id = "评测id", key = "exam-submit", name = "评测名称", scope = "schoo/teacher", target = "hbcn/tmdid" });
                 }
                 else
                 {
@@ -496,9 +498,15 @@ namespace TEAMModelOS.Controllers
             try
             {
                 if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                var client = _azureCosmos.GetCosmosClient();
+                //if (request.TryGetProperty("period", out JsonElement period)) return BadRequest();
+                    var client = _azureCosmos.GetCosmosClient();
+                //if (!request.TryGetProperty("userId", out JsonElement userId)) return BadRequest();
+                //if (!request.TryGetProperty("school", out JsonElement school)) return BadRequest();
+                var (userId, _, _, school) = HttpContext.GetAuthTokenInfo();
+
+
                 StringBuilder stringBuilder = new($"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime,c.source, c.subjects, c.grades,c.owner, c.scope,c.classes, c.stuLists, c.sRate,c.lostStu,c.sStatus,c.qamode,c.school,c.cloudas from c where (c.status<>404 or IS_DEFINED(c.status) = false) ");
-                if (request.TryGetProperty("classIds", out JsonElement classIds))
+                /*if (request.TryGetProperty("classIds", out JsonElement classIds))
                 {
                     List<string> ids = classIds.ToObject<List<string>>();
                     HashSet<string> strs = new HashSet<string>();
@@ -516,7 +524,7 @@ namespace TEAMModelOS.Controllers
                     }
                     string ss = string.Join(" or ", strs);
                     stringBuilder.Append($" and {ss}");
-                };
+                };*/
                 //开始时间,
                 if (request.TryGetProperty("stime", out JsonElement stime))
                 {
@@ -538,6 +546,39 @@ namespace TEAMModelOS.Controllers
                 {
                     stringBuilder.Append($" and c.period.id = '{period}' ");
                 }
+                if (request.TryGetProperty("opt", out JsonElement opt))
+                {
+                    if (opt.GetString().Equals("private"))
+                    {
+                        //针对于个人活动获取教师 任教或者助教大名单
+                        var groupList = await GroupListService.GetTeacherTeachGroupList(_coreAPIHttpService, client, _dingDing, userId, school, period.GetString());
+                        List<string> ids = new();
+                        foreach (var groups in groupList) {
+                            foreach (var gp in groups.groups) {
+                                ids.Add(gp.id);
+                            }
+                        }
+                        HashSet<string> strs = new HashSet<string>();
+                        if (ids.Count > 1)
+                        {
+                            foreach (string id in ids)
+                            {
+                                strs.Add($"array_contains(c.classes,'{id}') or array_contains(c.stuLists,'{id}')");
+                            }
+                        }
+                        else
+                        {
+                            string ssr = ids.Count > 0 ? ids[0] : "";
+                            strs.Add($"array_contains(c.classes,'{ssr}') or array_contains(c.stuLists,'{ssr}')");
+                        }
+                        string ss = string.Join(" or ", strs);
+                        stringBuilder.Append($" and {ss}");
+                    }
+                    else {
+                        stringBuilder.Append($" and c.code = 'Exam-{code}' ");
+                    }
+                };
+                
                 if (request.TryGetProperty("name", out JsonElement name) && !string.IsNullOrWhiteSpace($"{name}"))
                 {
                     stringBuilder.Append($" and Contains( c.name , '{name}') =  true ");
@@ -578,7 +619,7 @@ namespace TEAMModelOS.Controllers
                     }
                 }
                 List<ExamInfo> examInfo = new List<ExamInfo>();
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Exam-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout }))
                 {
 
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);