zhouj1203@hotmail.com 11 месяцев назад
Родитель
Сommit
85e3c04df8

+ 168 - 162
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -1912,201 +1912,207 @@ namespace TEAMModelOS.FunctionV4
                 pk = $"Item-{info.creatorId}";
                 table = "Teacher";
             }
-            string sqlqueryText = $"select value(c) from c where c.activityId = '{info.id}'and c.subjectId = '{info.subjects[no].id}' and c.stuId in ({string.Join(",", result.studentIds.Select(x => $"'{x}'"))})";
-            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<ErrorItems>(queryText: sqlqueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
-            {
-                errorItems.Add(item);
-            }
-            try {
-               /* bool isError =  examClassResults.SelectMany(c => c.status).ToList().Exists(z => z == 1);
-                if () { 
-                
-                }*/
-                if (errorItems.Count == 0 && info.qamode != 2)
+
+            if (result.studentIds.Any()) {
+                string sqlqueryText = $"select value(c) from c where c.activityId = '{info.id}'and c.subjectId = '{info.subjects[no].id}' and c.stuId in ({string.Join(",", result.studentIds.Select(x => $"'{x}'"))})";
+                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<ErrorItems>(queryText: sqlqueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
-                    // 新增逻辑 收集错题内容
-                    BlobDownloadResult index_json;
-                    if (info.scope.Equals("school"))
-                    {
-                        index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
-                    }
-                    else
-                    {
-                        index_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
-                    }
-                    //BlobDownloadResult index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
-                    JsonElement RecordingJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_json.Content.ToString()))).RootElement;
-                    RecordingJson.TryGetProperty("slides", out JsonElement slides);
-                    int qamode = info.qamode;
-                    if (RecordingJson.TryGetProperty("qamode", out JsonElement element)) {
-                        qamode = element.GetInt32();
-                    }
-                    var sdes = slides.ToObject<List<Slides>>();
-                    List<string> attachments = new List<string>();
-                    if (qamode == 1)
-                    {
-                        attachments = RecordingJson.GetProperty("attachments").ToObject<List<string>>();
-                        if (attachments.Count == 0)
-                        {
-                            return;
-                        }
-                    }
-                    List<string> urls = new();
+                    errorItems.Add(item);
+                }
+                try
+                {
+                    /* bool isError =  examClassResults.SelectMany(c => c.status).ToList().Exists(z => z == 1);
+                     if () { 
 
-                    foreach (var ne in sdes)
-                    {
-                        if (!ne.type.Equals("compose"))
-                        {
-                            urls.Add(ne.url);
-                        }
-                    }
-                    // 获取整体的题目ID集合
-                    List<string> ids = new();
-                    List<(string id, string pid, int level, string type, List<string> knows)> itemInfos = new();
-                    foreach (string url in urls)
+                     }*/
+                    if (errorItems.Count == 0 && info.qamode != 2)
                     {
-                        string id = url.Replace(".json", "");
-                        BlobDownloadResult index_item_json;
+                        // 新增逻辑 收集错题内容
+                        BlobDownloadResult index_json;
                         if (info.scope.Equals("school"))
                         {
-                            index_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
+                            index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
                         }
                         else
                         {
-                            index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
+                            index_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
                         }
-                        JsonElement itemJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_item_json.Content.ToString()))).RootElement;
-                        itemJson.TryGetProperty("exercise", out JsonElement exercise);
-                        //itemJson.TryGetProperty("pid", out JsonElement pid);
-                        var item_json = exercise.ToObject<Exercise>();
-                        //JObject keys = JObject.Parse(index_item_json.Content.ToString());
-                        string type = item_json.type;
-                        int level = item_json.level;
-                        var knowledge = item_json.knowledges;
-                        //string pid = keys.Value<string>("pid");
-                        if (itemJson.TryGetProperty("pid", out JsonElement pid))
+                        //BlobDownloadResult index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
+                        JsonElement RecordingJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_json.Content.ToString()))).RootElement;
+                        RecordingJson.TryGetProperty("slides", out JsonElement slides);
+                        int qamode = info.qamode;
+                        if (RecordingJson.TryGetProperty("qamode", out JsonElement element))
                         {
-                            itemInfos.Add((id, pid.ToString(), level, type, knowledge));
+                            qamode = element.GetInt32();
                         }
-                        else {
-                            itemInfos.Add((id, "", level, type, knowledge));
+                        var sdes = slides.ToObject<List<Slides>>();
+                        List<string> attachments = new List<string>();
+                        if (qamode == 1)
+                        {
+                            attachments = RecordingJson.GetProperty("attachments").ToObject<List<string>>();
+                            if (attachments.Count == 0)
+                            {
+                                return;
+                            }
                         }
-                        
-                    }
+                        List<string> urls = new();
 
-                    /* double[] point = StringHelper.ListTodouble(result.paper.point);
-                     double[,] res = StringHelper.ListToDouble(result.studentScores);
-                     var cdm = new ClouDASMatrix(res, point);*/
-                    //需要努力的题目
-                    //var ss = cdm.StriveTopic;
-                    int n = 0;
-                    List<Task<ItemResponse<ErrorItems>>> task_error = new();
-                    List<ErrorItems> errors = new();
-                    foreach (var sIds in result.studentIds)
-                    {
-                        ErrorItems error = new()
+                        foreach (var ne in sdes)
                         {
-                            ttl = -1,
-                            code = code,
-                            id = Guid.NewGuid().ToString(),
-                            stuId = sIds,
-                            school = info.school,
-                            activityId = info.id,
-                            subjectId = result.subjectId,
-                            time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
-                        };
-                        int index_stu = result.studentIds.IndexOf(sIds);
-                        //顺序学生错题的索引
-                        var itemScore = result.studentScores[index_stu];
-                        List<int> index = new();
-                        int index_item = 0;
-                        foreach (var sc in itemScore)
-                        {
-                            if (sc == 0)
+                            if (!ne.type.Equals("compose"))
                             {
-                                index.Add(index_item + 1);
+                                urls.Add(ne.url);
                             }
-                            index_item++;
                         }
-                        if (index.Count == 0)
+                        // 获取整体的题目ID集合
+                        List<string> ids = new();
+                        List<(string id, string pid, int level, string type, List<string> knows)> itemInfos = new();
+                        foreach (string url in urls)
                         {
-                            continue;
+                            string id = url.Replace(".json", "");
+                            BlobDownloadResult index_item_json;
+                            if (info.scope.Equals("school"))
+                            {
+                                index_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
+                            }
+                            else
+                            {
+                                index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
+                            }
+                            JsonElement itemJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_item_json.Content.ToString()))).RootElement;
+                            itemJson.TryGetProperty("exercise", out JsonElement exercise);
+                            //itemJson.TryGetProperty("pid", out JsonElement pid);
+                            var item_json = exercise.ToObject<Exercise>();
+                            //JObject keys = JObject.Parse(index_item_json.Content.ToString());
+                            string type = item_json.type;
+                            int level = item_json.level;
+                            var knowledge = item_json.knowledges;
+                            //string pid = keys.Value<string>("pid");
+                            if (itemJson.TryGetProperty("pid", out JsonElement pid))
+                            {
+                                itemInfos.Add((id, pid.ToString(), level, type, knowledge));
+                            }
+                            else
+                            {
+                                itemInfos.Add((id, "", level, type, knowledge));
+                            }
+
                         }
-                        //int[] item_index = ss[n];
-                        foreach (var item in index)
+
+                        /* double[] point = StringHelper.ListTodouble(result.paper.point);
+                         double[,] res = StringHelper.ListToDouble(result.studentScores);
+                         var cdm = new ClouDASMatrix(res, point);*/
+                        //需要努力的题目
+                        //var ss = cdm.StriveTopic;
+                        int n = 0;
+                        List<Task<ItemResponse<ErrorItems>>> task_error = new();
+                        List<ErrorItems> errors = new();
+                        foreach (var sIds in result.studentIds)
                         {
-                            Items items = new()
+                            ErrorItems error = new()
                             {
-                                id = urls[item - 1].Replace(".json", ""),
-                                blob = info.papers[no].blob
-
+                                ttl = -1,
+                                code = code,
+                                id = Guid.NewGuid().ToString(),
+                                stuId = sIds,
+                                school = info.school,
+                                activityId = info.id,
+                                subjectId = result.subjectId,
+                                time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                             };
-                            items.level = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().level;
-                            items.type = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().type;
-                            items.pId = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().pid;
-                            items.knowledge = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().knows;
-                            items.qamode = qamode;
-                            error.its.Add(items);
+                            int index_stu = result.studentIds.IndexOf(sIds);
+                            //顺序学生错题的索引
+                            var itemScore = result.studentScores[index_stu];
+                            List<int> index = new();
+                            int index_item = 0;
+                            foreach (var sc in itemScore)
+                            {
+                                if (sc == 0)
+                                {
+                                    index.Add(index_item + 1);
+                                }
+                                index_item++;
+                            }
+                            if (index.Count == 0)
+                            {
+                                continue;
+                            }
+                            //int[] item_index = ss[n];
+                            foreach (var item in index)
+                            {
+                                Items items = new()
+                                {
+                                    id = urls[item - 1].Replace(".json", ""),
+                                    blob = info.papers[no].blob
+
+                                };
+                                items.level = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().level;
+                                items.type = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().type;
+                                items.pId = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().pid;
+                                items.knowledge = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().knows;
+                                items.qamode = qamode;
+                                error.its.Add(items);
+                            }
+                            errors.Add(error);
+                            n++;
+                            task_error.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(error, new PartitionKey($"{error.code}")));
                         }
-                        errors.Add(error);
-                        n++;
-                        task_error.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(error, new PartitionKey($"{error.code}")));
-                    }
-                    //string connect = _configuration.GetValue<string>("HaBookAuth:Crtmabank") + "https://malearnfunction.chinacloudsites.cn/api/crtmabank";
-                    string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
-                    string urlAction = string.Empty;
-                    string accessKey = string.Empty;
-                    if (location.Contains("China"))
-                    {
-                        if (location.Equals("China")) //大陸正式站
+                        //string connect = _configuration.GetValue<string>("HaBookAuth:Crtmabank") + "https://malearnfunction.chinacloudsites.cn/api/crtmabank";
+                        string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
+                        string urlAction = string.Empty;
+                        string accessKey = string.Empty;
+                        if (location.Contains("China"))
+                        {
+                            if (location.Equals("China")) //大陸正式站
+                            {
+                                urlAction = "https://malearn.teammodel.cn";
+                                accessKey = "2BcXFR_hvzG1pZjqIkaM7Dx74Hcu6m0PwwOacFpDpq44AzFuHJBRXA==";
+                            }
+                            else if (location.Equals("China-Dep") || location.Equals("China-Test")) //大陸測試站
+                            {
+                                urlAction = "https://malearn-rc.teammodel.cn";
+                                accessKey = "lghWhJduNiAlo-e8isqEoROjdR7DAC-50XNtanIwHKYlAzFu1aog_A==";
+                            }
+                        }
+                        else if (location.Contains("Global"))
                         {
-                            urlAction = "https://malearn.teammodel.cn";
-                            accessKey = "2BcXFR_hvzG1pZjqIkaM7Dx74Hcu6m0PwwOacFpDpq44AzFuHJBRXA==";
+                            if (location.Equals("Global")) //國際正式站
+                            {
+                                urlAction = "https://malearn.teammodel.net";
+                                accessKey = "I-2lTcdggJkZWSBwOXQIm4oHx-huwX3d0wLe-9pgojThAzFuq_KNFg==";
+                            }
+                            else if (location.Equals("Global-Test")) //國際測試站
+                            {
+                                urlAction = "https://malearn-rc.teammodel.net";
+                                accessKey = "_l4Cb_tHIRBw_iv3ZuwVqjkMwjg4_HtDaxhAmZ8OwJraAzFu_DAY8A==";
+                            }
                         }
-                        else if (location.Equals("China-Dep") || location.Equals("China-Test")) //大陸測試站
+                        string connect = $"{urlAction}/api/crtmabank";
+                        var htc = _httpClient.CreateClient();
+                        if (htc.DefaultRequestHeaders.Contains("x-functions-key"))
                         {
-                            urlAction = "https://malearn-rc.teammodel.cn";
-                            accessKey = "lghWhJduNiAlo-e8isqEoROjdR7DAC-50XNtanIwHKYlAzFu1aog_A==";
+                            htc.DefaultRequestHeaders.Remove("x-functions-key");
                         }
-                    }
-                    else if (location.Contains("Global"))
-                    {
-                        if (location.Equals("Global")) //國際正式站
+                        htc.DefaultRequestHeaders.Add("x-functions-key", accessKey);
+                        ///智慧題庫school欄位修正
+                        foreach (ErrorItems error in errors)
                         {
-                            urlAction = "https://malearn.teammodel.net";
-                            accessKey = "I-2lTcdggJkZWSBwOXQIm4oHx-huwX3d0wLe-9pgojThAzFuq_KNFg==";
+                            error.school = (info.scope.Equals("school")) ? info.school : string.Empty;
                         }
-                        else if (location.Equals("Global-Test")) //國際測試站
+                        string paramJson = JsonConvert.SerializeObject(errors);
+                        var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
+                        var response = await htc.PostAsync(connect, content);
+                        if ((int)response.StatusCode == 200)
                         {
-                            urlAction = "https://malearn-rc.teammodel.net";
-                            accessKey = "_l4Cb_tHIRBw_iv3ZuwVqjkMwjg4_HtDaxhAmZ8OwJraAzFu_DAY8A==";
+                            await task_error.TaskPage(10);
                         }
                     }
-                    string connect = $"{urlAction}/api/crtmabank";
-                    var htc = _httpClient.CreateClient();
-                    if (htc.DefaultRequestHeaders.Contains("x-functions-key"))
-                    {
-                        htc.DefaultRequestHeaders.Remove("x-functions-key");
-                    }
-                    htc.DefaultRequestHeaders.Add("x-functions-key", accessKey);
-                    ///智慧題庫school欄位修正
-                    foreach (ErrorItems error in errors)
-                    {
-                        error.school = (info.scope.Equals("school")) ? info.school : string.Empty;
-                    }
-                    string paramJson = JsonConvert.SerializeObject(errors);
-                    var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
-                    var response = await htc.PostAsync(connect, content);
-                    if ((int)response.StatusCode == 200)
-                    {
-                        await task_error.TaskPage(10);
-                    }
                 }
-            }
-            catch (Exception e)
-            {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测错题异常{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
-            }
+                catch (Exception e)
+                {
+                    await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测错题异常{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
+                }
+            }                      
         }
 
         public class Settlement

+ 3 - 3
TEAMModelOS.FunctionV4/CosmosDB/TriggerVote.cs

@@ -345,6 +345,8 @@ namespace TEAMModelOS.FunctionV4
                             await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}投票活动{tdata.id}开始结算{tdata.endTime}!", GroupNames.醍摩豆服務運維群組);
 #endif
                             //获取投票活动的所有投票记录
+                            string pkey = string.Format("{0}{1}{2}", vote.code, "-", "going");
+                            await table.DeleteSingle<ChangeRecord>(pkey, tdata.id);
                             var records = await _azureRedis.GetRedisClient(8).HashGetAllAsync($"Vote:Record:{vote.id}");
                             //获取投票活动的选项及投票数
                             var counts = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Vote:Count:{vote.id}");
@@ -401,9 +403,7 @@ namespace TEAMModelOS.FunctionV4
                                 _azureRedis.GetRedisClient(8).KeyDelete($"Vote:Count:{vote.id}");
                                 break;
                             }
-                            await Task.WhenAll(tasks);
-                            string pkey = string.Format("{0}{1}{2}", vote.code, "-", "going");
-                            await table.DeleteSingle<ChangeRecord>(pkey, tdata.id);
+                            await Task.WhenAll(tasks);                         
                             break;
                     }
                 }

+ 2 - 1
TEAMModelOS.SDK/Models/Cosmos/School/ExamInfo.cs

@@ -67,7 +67,7 @@ namespace TEAMModelOS.SDK.Models
         /// </summary>
         public string source { get; set; }
         /// <summary>
-        /// 書面問答類型 0:書面問答 1:紙本測驗 2:艺术评测
+        /// 書面問答類型 0:書面問答 1:紙本測驗 2:艺术评测3:多分同步活动
         /// </summary>
         public int qamode { get; set; }
         
@@ -129,6 +129,7 @@ namespace TEAMModelOS.SDK.Models
         public List<FMember> staffIds { get; set; } = new List<FMember>();
         //是否啟動cloudas計算 true:啟動
         public bool cloudas { get; set;}
+        public string moofenCode { get; set; }
     }
     public class Custom {
         public string id { get; set; }

+ 5 - 4
TEAMModelOS.SDK/Models/Service/Third/ThirdService.cs

@@ -957,7 +957,7 @@ namespace TEAMModelOS.SDK.Models
 
                     var data = content.ToObject<JsonElement>();
                     if (data.TryGetProperty("data", out JsonElement _data)) {
-                        return _data.GetString();
+                        return _data.ToString();
                     }
 
                 }
@@ -976,7 +976,7 @@ namespace TEAMModelOS.SDK.Models
                 Dictionary<string, string> dict = new Dictionary<string, string>();
                 if (json.TryGetProperty("examCode", out JsonElement examCode) && !string.IsNullOrWhiteSpace($"{examCode}"))
                 {
-                    dict.Add("examName", $"{examCode}");
+                    dict.Add("examCode", $"{examCode}");
                 }                
                 if (json.TryGetProperty("subjects", out JsonElement subjects) && subjects.ValueKind.Equals(JsonValueKind.Array))
                 {
@@ -1050,12 +1050,13 @@ namespace TEAMModelOS.SDK.Models
             public double value { get; set; }
         }
         public class stuAns { 
-            public string stuId { get; set; }
+            public string stuNo { get; set; }
             public List<moofenAns> scoreData { get; set; } = new List<moofenAns>();
+            public string subject { get; set; }
         }
         public class moofenAns
         {
-            public double questionNo { get; set; }
+            public string questionNo { get; set; }
             public double score  { get; set; }
             public string answer { get; set; }
         }

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

@@ -189,12 +189,13 @@ namespace TEAMModelOS.Controllers
                     }
                     stuCount += ids.Count;
                 }*/
-                /*var (grade, per) = await ThirdService.GetGradeAsync(client, request);
-                var data = new
+                //var (grade, per) = await ThirdService.GetGradeAsync(client, request);
+                /*var data = new
                 {
                     examName = request.name,
                     examCategory = 1,
-                    grade = int.Parse(grade),
+                    //grade = int.Parse(grade),
+                    grade = 7,
                     term = 2,
                     examType = "单元测试",
                     examDate = request.startTime,
@@ -234,7 +235,8 @@ namespace TEAMModelOS.Controllers
                     }
                    
 
-                    //string moofenCode = await ThirdService.CreateMoofenExam(_httpClient, data.ToJsonString().ToObject<JsonElement>());
+                    //string moofenCode = await ThirdService.CreateMoofenExam(_httpClient, data.ToJsonString().ToObject<JsonElement>(),_dingDing);
+                    //request.moofenCode = moofenCode;
                     exam = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                     
                     await BIStats.SetTypeAddStats(client, _dingDing, exam.school, "Exam", 1);//BI统计增/减量
@@ -1308,6 +1310,210 @@ namespace TEAMModelOS.Controllers
                 return BadRequest();
             }
         }
+
+
+
+        [ProducesDefaultResponseType]
+        [Authorize(Roles = "IES")]
+        [AuthToken(Roles = "student,teacher")]
+        [HttpPost("update-ans")]
+        public async Task<IActionResult> updateAns(JsonElement request)
+        {
+
+            if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
+            if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
+            if (!request.TryGetProperty("paperId", out JsonElement paperId)) return BadRequest();
+            if (!request.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
+            if (!request.TryGetProperty("paperAns", out JsonElement paperAns)) return BadRequest();
+            if (!request.TryGetProperty("point", out JsonElement point)) return BadRequest();
+            if (!request.TryGetProperty("multipleRule", out JsonElement multipleRule)) return BadRequest();
+            //根据不同评测的类型返回对应的编码
+            if (!request.TryGetProperty("scode", out JsonElement scode)) return BadRequest();
+            //var (userId, name, picture, school) = HttpContext.GetAuthTokenInfo();
+            try
+            {
+                var client = _azureCosmos.GetCosmosClient();
+                ExamInfo info = new();
+                var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"{scode}"));
+                if (response.Status == 200)
+                {
+                    using var cJson = await JsonDocument.ParseAsync(response.ContentStream);
+                    info = cJson.ToObject<ExamInfo>();
+                }
+                else
+                {
+                    return Ok(new { code = 404, msg = "该活动未被找到" });
+                }
+                
+                //if (string.IsNullOrEmpty(userId)) return Ok(new { code = 404, msg = "当前用户信息未找到" });
+                
+                List<ExamClassResult> examClassResults = new List<ExamClassResult>();
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(
+                    queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
+                    requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+                {
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                    {
+                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                        {
+                            examClassResults.Add(obj.ToObject<ExamClassResult>());
+                        }
+                    }
+                }
+                //examClassResults = examClassResults.Where(c => c.studentIds.Contains(userId)).ToList(); wo
+                ExamClassResult classResult = new ExamClassResult();                
+                List<List<string>> standard = paperAns.ToObject<List<List<string>>>();
+                int rule = int.Parse(multipleRule.ToString());
+                List<double> points = point.ToObject<List<double>>();
+                List<Task<string>> tasks = new List<Task<string>>();
+                info.papers.ForEach(c => {
+                    if (c.id.Equals(paperId.GetString())) {
+                        c.answers = standard;
+                    }
+                });
+                foreach (ExamClassResult result in examClassResults)
+                {
+                    int index = 0;
+                    foreach (var ans in result.ans) {
+                        if (ans.Count == 0) continue;
+                        for (int i = 0; i < ans.Count; i++)
+                        {
+                            var sc = standard[i].Count;
+                            var ac =ans[i].Where(a => a.Trim().Length > 0).ToList().Count;
+                            //算分处理
+                            if (sc > 0)
+                            {
+                                if (ac == sc && sc == 1)
+                                {
+                                    foreach (string right in ans[i])
+                                    {
+                                        if (standard[i].Contains(right.Trim()))
+                                        {
+                                            result.studentScores[index][i] = points[i];
+                                        }
+                                        else
+                                        {
+                                            result.studentScores[index][i] = 0;
+                                        }
+                                    }
+
+                                }
+                                else
+                                {
+                                    if (rule > 0)
+                                    {
+                                        int falseCount = 0;
+                                        if (ac > 0)
+                                        {
+                                            foreach (string obj in ans[i])
+                                            {
+                                                if (!standard[i].Contains(obj))
+                                                {
+                                                    falseCount++;
+                                                }
+                                            }
+                                            switch (rule)
+                                            {
+                                                case 1:
+                                                    if (ac == sc)
+                                                    {
+                                                        if (falseCount == 0)
+                                                        {
+                                                            result.studentScores[index][i] = points[i];
+                                                        }
+                                                        else
+                                                        {
+                                                            result.studentScores[index][i] = 0;
+                                                        }
+                                                    }
+                                                    else
+                                                    {
+                                                        result.studentScores[index][i] = 0;
+                                                    }
+                                                    break;
+                                                case 2:
+                                                    if (falseCount > 0)
+                                                    {
+                                                        result.studentScores[index][i] = 0;
+                                                    }
+                                                    else
+                                                    {
+                                                        if (ac == sc)
+                                                        {
+                                                            result.studentScores[index][i] = points[i];
+                                                        }
+                                                        else
+                                                        {
+                                                            result.studentScores[index][i] = points[i] / 2;
+                                                        }
+
+                                                    }
+                                                    break;
+                                                case 3:
+                                                    if (falseCount > 0)
+                                                    {
+                                                        result.studentScores[index][i] = 0;
+                                                    }
+                                                    else
+                                                    {
+                                                        if (ac == sc)
+                                                        {
+                                                            result.studentScores[index][i] = points[i];
+                                                        }
+                                                        else
+                                                        {
+                                                            result.studentScores[index][i] = System.Math.Round((double)ac / sc * points[i], 1);
+                                                        }
+
+                                                    }
+                                                    break;
+                                                case 4:
+                                                    if (ac == sc)
+                                                    {
+                                                        result.studentScores[index][i] = points[i];
+                                                    }
+                                                    else
+                                                    {
+                                                        double persent = (double)(sc - 2 * falseCount) / sc;
+                                                        if (persent <= 0)
+                                                        {
+                                                            result.studentScores[index][i] = 0;
+                                                        }
+                                                        else
+                                                        {
+                                                            result.studentScores[index][i] = System.Math.Round(persent * points[i], 1);
+                                                        }
+                                                    }
+                                                    break;
+                                            }
+                                        }
+                                        else
+                                        {
+                                            result.studentScores[index][i] = 0;
+                                        }
+
+                                    }
+                                }
+                            }
+                        }
+                        result.sum[index] = result.studentScores[index].Sum();
+                        index++;
+                    }                                      
+                    classResult = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
+                    
+                }
+
+              await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"{scode}"));
+                
+                return Ok(new { classResult });
+            }
+            catch (Exception e)
+            {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/updateAns()\n{e.Message}\n{e.StackTrace}\n\n{id.GetString()}\n{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+        }
         private async Task getArtInfoAsync(CosmosClient client, string artId, string school, double score, string acId, string subject, string quotaId, string userid, string picture, string name, int userType, List<string> cIds)
         {
             var aresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(artId, new PartitionKey($"Art-{school}"));
@@ -1620,6 +1826,14 @@ namespace TEAMModelOS.Controllers
             if (!request.TryGetProperty("startTime", out JsonElement startTime)) return BadRequest();
             try
             {
+
+               /* var data = new
+                {
+                    examCode = 2001717656163218,
+                    subjects = new List<string> {"语文"}
+                };
+                var info = await ThirdService.CreateMoofenExamResult(_httpClient, data.ToJsonString().ToObject<JsonElement>(), _dingDing);*/
+
                 // 如果只有学生id则返回学生参加过的考试 只返回相关摘要信息
                 var client = _azureCosmos.GetCosmosClient();
                 var (_, _, _, school) = HttpContext.GetAuthTokenInfo();
@@ -1642,6 +1856,8 @@ namespace TEAMModelOS.Controllers
                 {
                     classId.GetString()
                 };
+
+
                 (List<RMember> members, List<RGroupList> groups) = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, cid, $"{school}", null, -1, startTime.GetInt64());
                 //await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<GroupList>(classId.GetString, new PartitionKey($"Exam-{code}"));
                 ///获取真实的名称