zhouj1203@hotmail.com 3 лет назад
Родитель
Сommit
2acc736eec

+ 75 - 5
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -595,8 +595,8 @@ namespace TEAMModelOS.FunctionV4
                 List<string> plId = new List<string>();
                 List<List<List<string>>> opth = new List<List<List<string>>>();
                 List<List<List<string>>> optl = new List<List<List<string>>>();
-                await knowledgeCount(info, subject, _dingDing, no, classResults, rhwCount, rhw, rhlCount, rhl, _azureCosmos);
-                await fieldCount(info, subject, _dingDing, no, classResults, rhwCount, rhw, rhlCount, rhl, _azureCosmos);
+                List<double> akp  =  await knowledgeCount(info, subject, _dingDing, no, classResults, rhwCount, rhw, rhlCount, rhl, _azureCosmos);
+                List<double> afp  = await fieldCount(info, subject, _dingDing, no, classResults, rhwCount, rhw, rhlCount, rhl, _azureCosmos);
                 int PHCount = 0;
                 int PLCount = 0;
                 foreach (ExamClassResult classResult in classResults)
@@ -635,6 +635,8 @@ namespace TEAMModelOS.FunctionV4
                 }
                 result.phc = getMore(info, no, opth);
                 result.plc = getMore(info, no, optl);
+                result.afp = afp;
+                result.akp = akp;
             }
             catch (Exception ex)
             {
@@ -817,14 +819,16 @@ namespace TEAMModelOS.FunctionV4
             return classLists;
         }
 
-        public static async Task knowledgeCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, List<ExamClassResult> classResults,
+        public static async Task<List<double>> knowledgeCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, List<ExamClassResult> classResults,
             double rhwCount, double rhw, double rhlCount, double rhl, AzureCosmosFactory _azureCosmos)
         {
+            List<double> akp = new();
             try
             {
                 int phcount = 0;
                 int plcount = 0;
                 //存放并去重知识点
+
                 HashSet<string> kname = new HashSet<string>();
                 if (info.papers[no].knowledge.Count > 0)
                 {
@@ -922,18 +926,51 @@ namespace TEAMModelOS.FunctionV4
                         }
                         //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
                     }
-                }
+                    foreach (string k in knowledgeName)
+                    {
+                        double score = 0;
+                        double allScore = 0;
+                        int n = 0;
+                        int count = 0;
+                        foreach (ExamClassResult result in classResults)
+                        {
+                            if (result.subjectId.Equals(subject.id))
+                            {
+                                foreach (List<string> str in info.papers[no].knowledge)
+                                {
+                                    if (str.Contains(k))
+                                    {
+                                        var itemPersent = str.Count > 0 ? 1 / Convert.ToDouble(str.Count) : 0;
+                                        allScore += info.papers[no].point.Count > 0 ? info.papers[no].point[n] * itemPersent : 0;
+
+                                        if (result.studentScores.Count > 0)
+                                        {
+                                            score += result.studentScores.Sum(r => r.Sum()) * itemPersent;
+                                        }
+                                    }
+                                    n++;
+                                }
 
+                                count += result.studentIds.Count;
+                            }
+                        }
+                        double per = count > 0 ? Math.Round(score / count, 2) : 0;
+                        akp.Add(allScore > 0 ? Math.Round(per / allScore, 2) : 0);
+                    }
+                }
+                return akp;
             }
             catch (Exception ex)
             {
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测知识点结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                return null;
             }
         }
 
-        public static async Task fieldCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, List<ExamClassResult> classResults,
+        public static async Task<List<double>> fieldCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, List<ExamClassResult> classResults,
             double rhwCount, double rhw, double rhlCount, double rhl, AzureCosmosFactory _azureCosmos)
         {
+            List<double> afp = new();
             try
             {
                 int phcount = 0;
@@ -1022,10 +1059,43 @@ namespace TEAMModelOS.FunctionV4
                     }
                     //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
                 }
+                for (int i = 0; i < knowledgeName.Count; i++)
+                {
+                    double score = 0;
+                    double allScore = 0;
+                    int n = 0;
+                    int count = 0;
+                    foreach (ExamClassResult result in classResults)
+                    {
+                        if (result.subjectId.Equals(subject.id))
+                        {
+                            foreach (int str in info.papers[no].field)
+                            {
+                                if (str == knowledgeName[i])
+                                {
+                                    var itemPersent = 1;
+                                    allScore += info.papers[no].point.Count > 0 ? info.papers[no].point[n] * itemPersent : 0;
+
+                                    if (result.studentScores.Count > 0)
+                                    {
+                                        score += result.studentScores.Sum(r => r.Sum()) * itemPersent;
+                                    }
+                                }
+                                n++;
+                            }
+
+                            count += result.studentIds.Count;
+                        }
+                    }
+                    double per = count > 0 ? Math.Round(score / count, 2) : 0;
+                    afp.Add(allScore > 0 ? Math.Round(per / allScore, 2) : 0);
+                }
+                return afp;
             }
             catch (Exception ex)
             {
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测认知层次结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                return null;
             }
         }
         //处理选题计数

+ 3 - 0
TEAMModelOS.SDK/Models/Cosmos/School/ExamResult.cs

@@ -44,6 +44,9 @@ namespace TEAMModelOS.SDK.Models
         public List<Dictionary<string, int>> record { get; set; } = new List<Dictionary<string, int>>();
         public List<Dictionary<string, int>> phc { get; set; } = new List<Dictionary<string, int>>();
         public List<Dictionary<string, int>> plc { get; set; } = new List<Dictionary<string, int>>();
+        public List<double> akp { get; set; } = new List<double>();
+        public List<double> afp { get; set; } = new List<double>();
+
     }
     public class ClassRange {
 

+ 34 - 0
TEAMModelOS.SDK/Models/Service/ExamService.cs

@@ -1,6 +1,7 @@
 using Azure.Cosmos;
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
@@ -101,5 +102,38 @@ namespace TEAMModelOS.SDK.Models.Service
 
             }
         }
+/*
+        public static async Task<string> getKnowledges(List<string> knowledges,List<ExamClassResult> answers ,string sub,List<List<string>> kones,List<double> point) {
+            foreach (string k in knowledges)
+            {
+                double score = 0;
+                double allScore = 0;
+                int n = 0;
+                int count = 0;
+                foreach (ExamClassResult result in answers)
+                {
+                    if (result.subjectId.Equals(sub))
+                    {
+                        foreach (List<string> str in kones)
+                        {
+                            if (str.Contains(k))
+                            {
+                                var itemPersent = str.Count > 0 ? 1 / Convert.ToDouble(str.Count) : 0;
+                                allScore += point.Count > 0 ? point[n] * itemPersent : 0;
+
+                                if (result.studentScores.Count > 0)
+                                {
+                                    score += result.studentScores.Sum(r => r.Sum()) * itemPersent;
+                                }
+                            }
+                            n++;
+                        }
+
+                        count += result.studentIds.Count;
+                    }
+                }
+                double per = count > 0 ? Math.Round(score / count, 2) : 0;
+            }
+        }*/
     }
 }

+ 2 - 0
TEAMModelOS/Controllers/Analysis/AnalysisController.cs

@@ -1478,6 +1478,8 @@ namespace TEAMModelOS.Controllers.Analysis
                     mapSubject.Add("subjectId", result.subjectId);
                     mapSubject.Add("total", SubjectTotal);
                     mapSubject.Add("wrongNum", wn);
+                    mapSubject.Add("akp", result.akp);
+                    mapSubject.Add("afp", result.afp);
                     averageTotal.Add(mapSubject);
                 }
                 return Ok(new { averageMap, averageTotal });

+ 15 - 10
TEAMModelOS/Controllers/Common/StudyController.cs

@@ -164,7 +164,7 @@ namespace TEAMModelOS.Controllers.Common
                     return Ok(new { code = HttpStatusCode.NotFound, msg = "账号不存在!" });
                 }
                 var client = _azureCosmos.GetCosmosClient();
-               
+                long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                 var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(id.ToString(), new PartitionKey($"StudyRecord-{tmdid}"));
                 var sresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Study-{code}"));
                 if (sresponse.Status == (int)HttpStatusCode.OK)
@@ -172,17 +172,22 @@ namespace TEAMModelOS.Controllers.Common
                     var sJson = await JsonDocument.ParseAsync(sresponse.ContentStream);
                     Study study = sJson.ToObject<Study>();
                     if (response.Status == (int)HttpStatusCode.OK)
-                    {
-                        return Ok(new { code = 200, msg = "已经签到" });
-                        /*var json = await JsonDocument.ParseAsync(response.ContentStream);
-                        StudyRecord record = json.ToObject<StudyRecord>();
-                        record.sign = study.startTime < now ? "2" : "1";
-                        record.signTime = now;
-                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(record, record.id, new PartitionKey($"{record.code}"));*/
+                    {                       
+                        var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        StudyRecord record = json.ToObject<StudyRecord>();                        
+                        if (!string.IsNullOrEmpty(record.sign))
+                        {
+                            return Ok(new { code = 200, msg = "已经签到" });
+                        }
+                        else {
+                            record.sign = study.startTime < now ? "2" : "1";
+                            record.signTime = now;
+                        }
+                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(record, record.id, new PartitionKey($"{record.code}"));
+
                     }
                     else
-                    {
-                        long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                    {                       
                         StudyRecord setting = new();
                         setting.id = id.GetString();
                         setting.tId = tmdid;