Ver Fonte

高分组 低分组取值调整,优化Function选择计数代码逻辑

zhouj1203@hotmail.com há 2 anos atrás
pai
commit
bae3d99fa1

+ 57 - 27
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -1,19 +1,17 @@
 using Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
-using Microsoft.Azure.Documents;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Text.Json;
-using System.Threading.Tasks;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Service;
 using HTEXLib.COMM.Helpers;
-using System.Net.Http;
+using ClouDASLibx;
+using System.Text.Json;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using System;
+using System.Linq;
 
 namespace TEAMModelOS.FunctionV4
 {
@@ -627,32 +625,64 @@ namespace TEAMModelOS.FunctionV4
         }
 
         //处理全部学生选题计数
-        public static async Task examRecordCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, ExamResult result, List<ExamClassResult> classResults, AzureCosmosFactory _azureCosmos)
+        public static async Task examRecordCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, ExamResult er, List<ExamClassResult> classResults, AzureCosmosFactory _azureCosmos)
         {
             try
             {
                 List<double> scores = new List<double>();
-                foreach (List<double> sc in result.studentScores)
+                foreach (List<double> sc in er.studentScores)
                 {
                     scores.Add(sc.Sum());
                 }
                 //确定高分组 最低分数
                 //var srowallorder = scores.EnumerateIndexed().OrderByDescending(g => g.Item2); //各生總分排序   
                 //var srowallorder =  scores.OrderByDescending(g => g);
+                double[] point = StringHelper.ListTodouble(er.paper.point);
+                double[,] result = StringHelper.ListToDouble(er.studentScores);
+                var cdm = new ClouDASMatrix(result, point);
+
                 scores.Sort((s1, s2) => { return s2.CompareTo(s1); });
-                int rhwCount = Convert.ToInt32(Math.Floor(scores.Count * 0.27));
-                double rhw = rhwCount > 0 ? scores[rhwCount] : 0;
+                int rhwCount = cdm.SH.Count();
+                double rhw = cdm.SH.LastOrDefault().Item2;
+                int rhlCount = cdm.SL.Count();
+                double rhl = cdm.SL.FirstOrDefault().Item2;
+                List<string> phs = new();
+                List<string> pls = new();
+                //分别获取高分组低分组人员
+                foreach (var ph in cdm.SH) {
+                    phs.Add(er.studentIds[ph.Item1]);
+                }
+                foreach (var pl in cdm.SL)
+                {
+                    pls.Add(er.studentIds[pl.Item1]);
+                }
+                /* if (scores.Count > 3)
+                 {
+                     rhwCount = Convert.ToInt32(Math.Floor(scores.Count * 0.27));
+                     rhw = rhwCount > 0 ? scores[rhwCount - 1] : 0;
+                     rhlCount = Convert.ToInt32(Math.Ceiling(scores.Count * 0.73));
+                     rhl = rhlCount > 0 ? scores[rhlCount] : 0;
+                 }
+                 else
+                 {
+                     rhwCount = Convert.ToInt32(Math.Floor(scores.Count * 0.27));
+                     rhw = rhwCount > 0 ? scores[rhwCount] : 0;
+                     rhlCount = Convert.ToInt32(Math.Ceiling(scores.Count * 0.73));
+                     rhl = rhlCount > 0 ? scores[rhlCount - 1] : 0;
+                 }*/
+                /*int rhwCount = Convert.ToInt32(Math.Floor(scores.Count * 0.27));
+                double rhw = rhwCount > 0 ? scores[rhwCount-1] : 0;
                 //var rhww = srowallorder.Take(Convert.ToInt32(Math.Floor(scores.Count * 0.27)));
                 //确定低分组 最高分数
                 //scores.Sort((s1, s2) => { return s1.CompareTo(s2); });
                 int rhlCount = Convert.ToInt32(Math.Ceiling(scores.Count * 0.73));
-                double rhl = rhlCount > 0 ? scores[rhlCount-1] : 0;
+                double rhl = rhlCount > 0 ? scores[rhlCount-1] : 0;*/
                 //var rhll = srowallorder.Skip(Convert.ToInt32(Math.Ceiling(scores.Count * 0.73)));
                 //存放高分组学生ID
-                List<string> phId = new List<string>();
-                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>>>();
+                List<string> phId = new();
+                List<string> plId = new();
+                List<List<List<string>>> opth = new();
+                List<List<List<string>>> optl = new();
                 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;
@@ -666,7 +696,7 @@ namespace TEAMModelOS.FunctionV4
                             int index = classResult.studentIds.IndexOf(id);
                             if (classResult.studentScores.Count > 0)
                             {
-                                if (classResult.studentScores[index].Sum() >= rhw && PHCount < rhwCount)
+                                if (phs.Contains(id))
                                 {
                                     if (classResult.ans.Count > 0)
                                     {
@@ -676,7 +706,7 @@ namespace TEAMModelOS.FunctionV4
                                     }
 
                                 }
-                                if (classResult.studentScores[index].Sum() <= rhl && PLCount < (scores.Count - rhlCount))
+                                if (pls.Contains(id))
                                 {
                                     if (classResult.ans.Count > 0)
                                     {
@@ -691,10 +721,10 @@ namespace TEAMModelOS.FunctionV4
                         }
                     }
                 }
-                result.phc = getMore(info, no, opth);
-                result.plc = getMore(info, no, optl);
-                result.afp = afp;
-                result.akp = akp;
+                er.phc = getMore(info, no, opth);
+                er.plc = getMore(info, no, optl);
+                er.afp = afp;
+                er.akp = akp;
             }
             catch (Exception ex)
             {
@@ -1219,7 +1249,7 @@ namespace TEAMModelOS.FunctionV4
             int m = 0;
             double score = 0;
             //标准差
-            double powSum = 0;
+            //double powSum = 0;
             double allScore = info.papers[no].point.Sum();
             List<ClassRange> classRanges = new List<ClassRange>();
             List<string> lostStu = new List<string>();
@@ -1319,8 +1349,7 @@ namespace TEAMModelOS.FunctionV4
                     }
                 }
             }
-
-            await examRecordCount(info, subject, _dingDing, no, result, examClassResults, _azureCosmos);
+           
             result.record = getMore(info, no, opt);
             result.average = result.studentIds.Count > 0 ? Math.Round(score * 1.0 / result.studentIds.Count, 2) : 0;
             double stand = 0;
@@ -1354,7 +1383,8 @@ namespace TEAMModelOS.FunctionV4
             //result.point = info.papers[j].point;
             result.scope = info.scope;
             result.name = info.name;
-            result.time = info.startTime;            
+            result.time = info.startTime;
+            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}"));
 
         }

+ 36 - 9
TEAMModelOS/Controllers/Analysis/AnalysisController.cs

@@ -1072,10 +1072,23 @@ namespace TEAMModelOS.Controllers.Analysis
             }
             //确定高分组 最低分数
             resultSum.Sort((s1, s2) => { return s2.CompareTo(s1); });
-            int rhwCount = Convert.ToInt32(Math.Floor(resultSum.Count * 0.27));
-            double rhw = rhwCount > 0 ? resultSum[rhwCount] : 0;
-            int rhlCount = Convert.ToInt32(Math.Ceiling(resultSum.Count * 0.73));
-            double rhl = rhlCount > 0 ? resultSum[rhlCount - 1] : 0;
+            int rhwCount = 0;
+            double rhw = 0;
+            int rhlCount = 0;
+            double rhl = 0;
+            if (resultSum.Count > 3)
+            {
+                rhwCount = Convert.ToInt32(Math.Floor(resultSum.Count * 0.27));
+                rhw = rhwCount > 0 ? resultSum[rhwCount - 1] : 0;
+                rhlCount = Convert.ToInt32(Math.Ceiling(resultSum.Count * 0.73));
+                rhl = rhlCount > 0 ? resultSum[rhlCount] : 0;
+            }
+            else {
+                rhwCount = Convert.ToInt32(Math.Floor(resultSum.Count * 0.27));
+                rhw = rhwCount > 0 ? resultSum[rhwCount] : 0;
+                rhlCount = Convert.ToInt32(Math.Ceiling(resultSum.Count * 0.73));
+                rhl = rhlCount > 0 ? resultSum[rhlCount-1] : 0;
+            }           
 
 
 
@@ -1293,11 +1306,25 @@ namespace TEAMModelOS.Controllers.Analysis
                 resultSum.Add(data.Sum());
             }
             //确定高分组 最低分数
-                resultSum.Sort((s1, s2) => { return s2.CompareTo(s1); });
-                int rhwCount = Convert.ToInt32(Math.Floor(resultSum.Count * 0.27));
-                double rhw = rhwCount > 0 ? resultSum[rhwCount] : 0;
-                int rhlCount = Convert.ToInt32(Math.Ceiling(resultSum.Count * 0.73));
-                double rhl = rhlCount > 0 ? resultSum[rhlCount-1] : 0;
+            resultSum.Sort((s1, s2) => { return s2.CompareTo(s1); });
+            int rhwCount = 0;
+            double rhw = 0;
+            int rhlCount = 0;
+            double rhl = 0;
+            if (resultSum.Count > 3)
+            {
+                rhwCount = Convert.ToInt32(Math.Floor(resultSum.Count * 0.27));
+                rhw = rhwCount > 0 ? resultSum[rhwCount - 1] : 0;
+                rhlCount = Convert.ToInt32(Math.Ceiling(resultSum.Count * 0.73));
+                rhl = rhlCount > 0 ? resultSum[rhlCount] : 0;
+            }
+            else
+            {
+                rhwCount = Convert.ToInt32(Math.Floor(resultSum.Count * 0.27));
+                rhw = rhwCount > 0 ? resultSum[rhwCount] : 0;
+                rhlCount = Convert.ToInt32(Math.Ceiling(resultSum.Count * 0.73));
+                rhl = rhlCount > 0 ? resultSum[rhlCount - 1] : 0;
+            }
 
             //初始化年级总分
             double total = 0;