Browse Source

处理知识点和认知层次结算内容

zhouj1203@hotmail.com 4 years ago
parent
commit
0d79680f4f

+ 134 - 29
TEAMModelFunction/TriggerExam.cs

@@ -447,10 +447,57 @@ namespace TEAMModelFunction
                 //存放高分组学生ID
                 //存放高分组学生ID
                 List<string> phId = new List<string>();
                 List<string> phId = new List<string>();
                 List<string> plId = new List<string>();
                 List<string> plId = new List<string>();
-                int phcount = 0;
-                int plcount = 0;
                 List<List<List<string>>> opth = new List<List<List<string>>>();
                 List<List<List<string>>> opth = new List<List<List<string>>>();
                 List<List<List<string>>> optl = 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);
+                int PHCount = 0;
+                int PLCount = 0;
+                foreach (ExamClassResult classResult in classResults)
+                {
+                    if (classResult.subjectId.Equals(subject.id))
+                    {
+                        foreach (string id in classResult.studentIds)
+                        {
+                            int index = classResult.studentIds.IndexOf(id);
+                            if (classResult.studentScores[index].Sum() >= rhw && PHCount < rhwCount)
+                            {
+                                if (classResult.ans.Count > 0)
+                                {
+                                    opth.Add(classResult.ans[index]);
+                                    PHCount++;
+                                    continue;
+                                }
+
+                            }
+                            if (classResult.studentScores[index].Sum() <= rhl && PLCount < (scores.Count - rhlCount))
+                            {
+                                if (classResult.ans.Count > 0)
+                                {
+                                    optl.Add(classResult.ans[index]);
+                                    PLCount++;
+                                    continue;
+                                }
+                            }
+                        }
+                    }
+                }
+                result.phc = getMore(info, no, opth);
+                result.plc = getMore(info, no, optl);
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"评测作答记录结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+            }
+        }
+
+        public static async Task knowledgeCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, List<ExamClassResult> classResults,
+            double rhwCount, double rhw, double rhlCount, double rhl, AzureCosmosFactory _azureCosmos)
+        {
+            try
+            {
+                int phcount = 0;
+                int plcount = 0;
                 //存放并去重知识点
                 //存放并去重知识点
                 HashSet<string> kname = new HashSet<string>();
                 HashSet<string> kname = new HashSet<string>();
                 info.papers[no].knowledge.ForEach(kno =>
                 info.papers[no].knowledge.ForEach(kno =>
@@ -475,7 +522,8 @@ namespace TEAMModelFunction
 
 
                 foreach (ExamClassResult classResult in classResults)
                 foreach (ExamClassResult classResult in classResults)
                 {
                 {
-                    if (classResult.subjectId.Equals(subject.id)) {
+                    if (classResult.subjectId.Equals(subject.id))
+                    {
                         //List<int> phc = new List<int>();
                         //List<int> phc = new List<int>();
                         List<int> ph = new List<int>();
                         List<int> ph = new List<int>();
                         List<int> pl = new List<int>();
                         List<int> pl = new List<int>();
@@ -511,7 +559,7 @@ namespace TEAMModelFunction
                                                 phcount++;
                                                 phcount++;
                                                 continue;
                                                 continue;
                                             }
                                             }
-                                            if (classResult.studentScores[index].Sum() <= rhl && plcount < (scores.Count - rhlCount))
+                                            if (classResult.studentScores[index].Sum() <= rhl && plcount < (info.stuCount - rhlCount))
                                             {
                                             {
                                                 if (classResult.studentScores[index][n] == 0)
                                                 if (classResult.studentScores[index][n] == 0)
                                                 {
                                                 {
@@ -539,50 +587,107 @@ namespace TEAMModelFunction
                         classResult.plc = pl;
                         classResult.plc = pl;
                         classResult.pc = pc;
                         classResult.pc = pc;
                         classResult.krate = persent;
                         classResult.krate = persent;
-                    }                    
+                    }
                     await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
                     await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
                 }
                 }
-                //
-                int PHCount = 0;
-                int PLCount = 0;
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"评测知识点结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+            }
+        }
+
+        public static async Task fieldCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, List<ExamClassResult> classResults,
+            double rhwCount, double rhw, double rhlCount, double rhl, AzureCosmosFactory _azureCosmos)
+        {
+            try
+            {
+                int phcount = 0;
+                int plcount = 0;
+                //存放并去重知识点
+                List<int> knowledgeName = new List<int>();
+                knowledgeName.Add(1);
+                knowledgeName.Add(2);
+                knowledgeName.Add(3);
+                knowledgeName.Add(4);
+                knowledgeName.Add(5);
+                knowledgeName.Add(6);
                 foreach (ExamClassResult classResult in classResults)
                 foreach (ExamClassResult classResult in classResults)
                 {
                 {
                     if (classResult.subjectId.Equals(subject.id))
                     if (classResult.subjectId.Equals(subject.id))
                     {
                     {
-                        foreach (string id in classResult.studentIds)
+                        //List<int> phc = new List<int>();
+                        List<int> ph = new List<int>();
+                        List<int> pl = new List<int>();
+                        List<int> pc = new List<int>();
+                        List<double> persent = new List<double>();
+                        for (int i = 0; i < knowledgeName.Count; i++)
                         {
                         {
-                            int index = classResult.studentIds.IndexOf(id);
-                            if (classResult.studentScores[index].Sum() >= rhw && PHCount < rhwCount)
-                            {
-                                if (classResult.ans.Count > 0)
-                                {
-                                    opth.Add(classResult.ans[index]);
-                                    PHCount++;
-                                    continue;
-                                }
-
-                            }
-                            if (classResult.studentScores[index].Sum() <= rhl && PLCount < (scores.Count - rhlCount))
+                            //初始化单个知识点得分
+                            double score = 0;
+                            double allScore = 0;
+                            int n = 0;
+                            int phCount = 0;
+                            int plCount = 0;
+                            int pCount = 0;
+                            foreach (int str in info.papers[no].field)
                             {
                             {
-                                if (classResult.ans.Count > 0)
+                                if (str == knowledgeName[i])
                                 {
                                 {
-                                    optl.Add(classResult.ans[index]);
-                                    PLCount++;
-                                    continue;
+                                    var itemPersent = 1;
+                                    allScore += info.papers[no].point[n] * itemPersent;
+                                    foreach (string id in classResult.studentIds)
+                                    {
+                                        int index = classResult.studentIds.IndexOf(id);
+                                        if (classResult.studentScores[index].Count > 0)
+                                        {
+                                            score += classResult.studentScores[index][n];
+                                            if (classResult.studentScores[index].Sum() >= rhw && phcount < rhwCount)
+                                            {
+                                                if (classResult.studentScores[index][n] == 0)
+                                                {
+                                                    phCount++;
+                                                }
+                                                phcount++;
+                                                continue;
+                                            }
+                                            if (classResult.studentScores[index].Sum() <= rhl && plcount < (info.stuCount - rhlCount))
+                                            {
+                                                if (classResult.studentScores[index][n] == 0)
+                                                {
+                                                    plCount++;
+                                                }
+                                                plcount++;
+                                                continue;
+                                            }
+                                            if (classResult.studentScores[index][n] == 0)
+                                            {
+                                                pCount++;
+                                            }
+                                        }
+                                    }
                                 }
                                 }
+                                n++;
                             }
                             }
+                            pc.Add(pCount);
+                            ph.Add(phCount);
+                            pl.Add(plCount);
+                            double per = classResult.studentIds.Count > 0 ? Math.Round(score / classResult.studentIds.Count, 2) : 0;
+                            persent.Add(per / allScore);
                         }
                         }
+                        classResult.fphc = ph;
+                        classResult.fplc = pl;
+                        classResult.fpc = pc;
+                        classResult.frate = persent;
                     }
                     }
+                    await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
                 }
                 }
-                result.phc = getMore(info, no, opth);
-                result.plc = getMore(info, no, optl);
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                await _dingDing.SendBotMsg($"评测作答记录结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"评测认知层次结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
             }
             }
         }
         }
-
         //处理选题计数
         //处理选题计数
         public static List<Dictionary<string, int>> getMore(ExamInfo info, int no, List<List<List<string>>> list)
         public static List<Dictionary<string, int>> getMore(ExamInfo info, int no, List<List<List<string>>> list)
         {
         {

+ 6 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/ExamClassResult.cs

@@ -43,10 +43,16 @@ namespace TEAMModelOS.SDK.Models
         public double srate { get; set; }
         public double srate { get; set; }
         //单科单班标准差
         //单科单班标准差
         public double standard { get; set; }
         public double standard { get; set; }
+        //知识点结算内容
         public List<double> krate { get; set; } = new List<double>();
         public List<double> krate { get; set; } = new List<double>();
         public List<int> phc { get; set; } = new List<int>();
         public List<int> phc { get; set; } = new List<int>();
         public List<int> plc { get; set; } = new List<int>();
         public List<int> plc { get; set; } = new List<int>();
         public List<int> pc { get; set; } = new List<int>();
         public List<int> pc { get; set; } = new List<int>();
+        //认知层次结算内容
+        public List<double> frate { get; set; } = new List<double>();
+        public List<int> fphc { get; set; } = new List<int>();
+        public List<int> fplc { get; set; } = new List<int>();
+        public List<int> fpc { get; set; } = new List<int>();
     }
     }
 /*    public class PaperSimple {
 /*    public class PaperSimple {
         public string id { get; set; }
         public string id { get; set; }