CrazyIter_Bin 6 mesi fa
parent
commit
399c2b9d66

+ 80 - 53
TEAMModelOS.Extension/HTEX.Lib/ETL/Lesson/LessonETLService.cs

@@ -35,6 +35,24 @@ namespace HTEX.Lib.ETL.Lesson
 {
     public class LessonETLService
     {
+        public static int GetRandomValueByWeight(List<WeightedItem> items)
+        {
+            Random random = new Random();
+            double randomWeight = random.NextDouble();
+            double cumulativeWeight = 0.0;
+
+            foreach (var item in items)
+            {
+                cumulativeWeight += item.Weight;
+                if (randomWeight <= cumulativeWeight)
+                {
+                    return item.Value;
+                }
+            }
+
+            // This should not happen if all weights sum up to 1
+            return items[items.Count - 1].Value;
+        }
         public static List<CodeBool> GetCodeBools (List<StudentLessonData> studentLessonDatas) {
             List<CodeBool> codeBools = new List<CodeBool>() {
                 new CodeBool { code="hd",value=false },//互动
@@ -2689,67 +2707,70 @@ namespace HTEX.Lib.ETL.Lesson
                                 a = (kw/(10*w))*(w/n)+er/(r*10)*(r/w);
                             }
                         }
-
-
-
-
-                        //c+a= 个人计分指数+ 个人互动成效指数
-                        //互动成效
-                        var f1 = Math.Round(190*1.0/(1+Math.Exp(-(a*m)))-95, 4);
-                        if (f1==0)
-                        {
-                            if (d>0 && c==0)
+                        if (w>0)
+                        {//c+a= 个人计分指数+ 个人互动成效指数
+                         //互动成效
+                            var f1 = Math.Round(80*1.0/(1+Math.Exp(-(a*m)))+20, 4);
+                            if (f1==0)
                             {
-                                f1=d*0.6;
+                                if (d>0 && c==0)
+                                {
+                                    f1=d*0.6;
+                                }
+                                else if (d==0 && c>0)
+                                {
+                                    f1=c*0.6;
+                                }
+                                else
+                                {
+                                    f1=(d*0.6+c*0.6)/2;
+                                }
+
                             }
-                            else if (d==0 && c>0)
+                            else
                             {
-                                f1=c*0.6;
+                                //如果有互动计分,则互动成效指数取0.8 0.2
+                                var dy = (95-f1)/95/2;
+                                if (dy>0.2)
+                                {
+                                    dy=0.2;
+                                }
+                                if (dy<0.1)
+                                {
+                                    dy=0.1;
+                                }
+
+                                f1=f1*(dy>0.1 ? 1-dy : 1-dy*2)+d*dy+c*dy;
+
                             }
-                            else 
+                            if (f1>95)
                             {
-                                f1=(d*0.6+c*0.6)/2;
-                            }
-                           
-                        }
-                        else 
-                        {
-                            //如果有互动计分,则互动成效指数取0.8 0.2
-                            var dy = (95-f1)/95/2;
-                            if (dy>0.2) 
-                            {
-                                dy=0.2;
-                            }
-                            if (dy<0.1) {
-                                dy=0.1;
-                            }
-                            
-                            f1=f1*(dy>0.1? 1-dy : 1-dy*2)+d*dy+c*dy;
+                                f1=95;
 
-                        }
-                        if (f1>95)
-                        {
-                            f1=95;
-                            
-                        }
-                        if (f1>0)
-                        {
-                            //智慧挑人有被挑中的
-                            if (lessonItem.zh_tr>0)
+                            }
+                            if (f1>0)
                             {
-                                f1=(f1+lessonItem.zh_tr)/2;
+                                //智慧挑人有被挑中的
+                                if (lessonItem.zh_tr>0)
+                                {
+                                    f1=f1*0.8+lessonItem.zh_tr*0.2;
+                                }
                             }
-                        }
-                        else
-                        {
-                            //智慧挑人有被挑中的
-                            if (lessonItem.zh_tr>0)
+                            else
                             {
-                                f1=lessonItem.zh_tr*0.8;
+                                //智慧挑人有被挑中的
+                                if (lessonItem.zh_tr>0)
+                                {
+                                    f1=lessonItem.zh_tr*0.5;
+                                }
                             }
+                            //var f1 = Math.Round(a*m);
+                            lessonItem.hd_cx=f1;
                         }
-                        //var f1 = Math.Round(a*m);
-                        lessonItem.hd_cx=f1;
+
+
+
+                        
                         
                         //互动专注指数
                         // var b = ((w*w/n)+(r*r/w))*1.0*m;
@@ -2784,13 +2805,13 @@ namespace HTEX.Lib.ETL.Lesson
                             {
                                 if (lessonItem.zh_tr>0)
                                 {
-                                    f2=(f2+lessonItem.zh_tr)/2;
+                                    f2=f2*0.8+lessonItem.zh_tr*0.2;
                                 }
                             }
                             else{
                                 if (lessonItem.zh_tr>0)
                                 {
-                                    f2=lessonItem.zh_tr*0.8;
+                                    f2=lessonItem.zh_tr*0.5;
                                 }
                             }
                             
@@ -2962,7 +2983,7 @@ namespace HTEX.Lib.ETL.Lesson
                         var po = p.Sum(x => x.optCount);
                         double ps = pc/n* (pg+ po);
                         double h = vs+ps+gs;
-                        double f3 = Math.Round(190*1.0/(1+Math.Exp(-(h)))-95, 4);
+                        double f3 = Math.Round(200*1.0/(1+Math.Exp(-(h)))-100, 4);
                         studentLessonData.appraise=f3;
                         // _logger.LogInformation($"{studentLessonData.id}=>评价能力:{f3}\t评价次数:{n}\t投票次数:{vc}-{vg}-{vo}\t星光次数:{gc}-{gg}-{go}\t互评次数:{pc}-{pg}-{po}");
 
@@ -3453,6 +3474,12 @@ namespace HTEX.Lib.ETL.Lesson
         /// </summary>
         public double xx_cy { get; set; } = 0;
     }
+
+   public class WeightedItem
+    {
+        public int Value { get; set; }
+        public double Weight { get; set; }
+    }
     /// <summary>
     /// 
     /// </summary>

File diff suppressed because it is too large
+ 9 - 0
TEAMModelOS.Extension/HTEX.Lib/summary.xml


+ 59 - 81
TEAMModelOS.Extension/HTEX.Test/Controllers/MockDataController.cs

@@ -1,24 +1,26 @@
-using Microsoft.AspNetCore.Mvc;
-using System.Text.Json;
- 
+ 
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
-using System;
-using OfficeOpenXml;
-using System.Reflection;
+ 
 using System.Xml;
-using System.Text.RegularExpressions;
+
 using HTEX.Lib.ETL.Lesson;
-using OfficeOpenXml.Style;
-using DocumentFormat.OpenXml.Spreadsheet;
-using OpenXmlPowerTools;
+using Microsoft.AspNetCore.Mvc;
+using System.Text.Json;
+
 
 namespace HTEX.Test.Controllers
 {
-    
-    public static class MockDataController 
+    [ApiController]
+    [Route("lesson-record")]
+    public   class MockDataController : ControllerBase
     {
-        public static async Task MockData()
+        public MockDataController()
+        { 
+
+        }
+        [HttpPost("process-local")]
+        public   async Task<IActionResult> MockData(JsonElement json)
         {
             
             #region 数据模拟
@@ -58,16 +60,29 @@ namespace HTEX.Test.Controllers
                     count=xcount;
                     break;
             }
+            List<string> s = new List<string>();
             for (var i = 1; i < count; i++)
             {
-                await StudentLesson(scount,ecount,qcount,i,tcount,pcount,xcount,kcount);
-            }
+               var dd =  await StudentLesson(scount,ecount,qcount,i,tcount,pcount,xcount,kcount);
+                s.Add(dd.ToString());
+            }return Ok(s);
         }
 
-        //[HttpPost("student-lesson")]
-        public static async Task StudentLesson(int scount, int ecount, int qcount, int icount, int tcount, int pcount, int xcount, int kcount) 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="scount"></param>
+        /// <param name="ecount"></param>
+        /// <param name="qcount"></param>
+        /// <param name="icount"></param>
+        /// <param name="tcount"></param>
+        /// <param name="pcount"></param>
+        /// <param name="xcount"></param>
+        /// <param name="kcount"></param>
+        /// <returns></returns>
+        public async Task<string> StudentLesson(int scount, int ecount, int qcount, int icount, int tcount, int pcount, int xcount, int kcount)
         {
-           
+
             List<StudentLessonData> students = new List<StudentLessonData>();
             //个人计分,小组计分
             List<WeightedItem> gpitems = new List<WeightedItem>
@@ -84,8 +99,8 @@ namespace HTEX.Test.Controllers
             //互动积分
             List<WeightedItem> titems = new List<WeightedItem>
             {
-                new WeightedItem { Value = 0, Weight = 0.4 },
-                new WeightedItem { Value = 25, Weight = 0.1 },
+                new  WeightedItem { Value = 0, Weight = 0.4 },
+                new  WeightedItem { Value = 25, Weight = 0.1 },
                 new WeightedItem { Value = 15, Weight = 0.1 },
                 new WeightedItem { Value = 10, Weight = 0.05 },
                 new WeightedItem { Value = 30, Weight = 0.05 },
@@ -144,14 +159,14 @@ namespace HTEX.Test.Controllers
                         types.Add("Voting");
                         break;
                     case bool when i==1:
-                        types.Add("GrandRating"); 
+                        types.Add("GrandRating");
                         break;
                     case bool when i==2:
                         types.Add("PeerAssessment");
                         break;
                 }
             }
-            string[] grouppick = new string[] {  "PickupNthGrp", "PickupGrp", "PickupEachGrp" };
+            string[] grouppick = new string[] { "PickupNthGrp", "PickupGrp", "PickupEachGrp" };
             string[] pickupAll = new string[] { "PickupNameLst", "PickupOption", "PickupNthGrp", "PickupGrp",
                 "PickupRange", "PickupEachGrp", "PickupDiff", "PickupWrong", "PickupNoDiff", "PickupRight",
                 "PickupGener", "PickupWtoW", "PickupWtoR", "PickupLSA_WordFreq", "PickupLSA_Classify", "Pickup0_49" };
@@ -164,9 +179,9 @@ namespace HTEX.Test.Controllers
                     id=$"2024{(s+1).ToString("D3")}",
                     groupId=$"{Random.Shared.Next(1, 5)}",
                     attend=1,
-                    gscore= GetRandomValueByWeight(gpitems),
-                    pscore= GetRandomValueByWeight(gpitems),
-                    tscore= GetRandomValueByWeight(titems),
+                    gscore= LessonETLService.GetRandomValueByWeight(gpitems),
+                    pscore= LessonETLService.GetRandomValueByWeight(gpitems),
+                    tscore= LessonETLService.GetRandomValueByWeight(titems),
                 };
                 for (var p = 0; p<pcount; p++)
                 {
@@ -178,14 +193,15 @@ namespace HTEX.Test.Controllers
             {
                 var student = students[s];
                 //挑人
-                for (var i = 0; i<kcount; i++) 
+                for (var i = 0; i<kcount; i++)
                 {
-                    var rd= Random.Shared.Next(0, 4);
+                    var rd = Random.Shared.Next(0, 4);
                     if (rd==1)
                     {
                         student.pickups.Add($"1--{grouppick[Random.Shared.Next(0, grouppick.Length)]}");
                     }
-                    else {
+                    else
+                    {
                         student.pickups.Add($"0--{pickupAll[Random.Shared.Next(0, pickupAll.Length)]}");
                     }
                 }
@@ -213,7 +229,7 @@ namespace HTEX.Test.Controllers
                         //部分正确
                         case bool when w==2:
                             var score = Random.Shared.Next(1, criterion);
-                            item.resultWeight= MinMaxNormalization(1, criterion, score, InteractWeight.T1, InteractWeight.TT);
+                            item.resultWeight= LessonETLService.MinMaxNormalization(1, criterion, score, InteractWeight.T1, InteractWeight.TT);
                             item.resultType= InteractReultType.TP;
                             item.itemScore=0;
                             break;
@@ -226,7 +242,7 @@ namespace HTEX.Test.Controllers
                     }
                     student.interactRecord.interactRecords.Add(item);
                 }
-                
+
                 //任务
                 for (var t = 0; t<tcount; t++)
                 {
@@ -247,7 +263,7 @@ namespace HTEX.Test.Controllers
                             item.resultType= InteractReultType.TT;
                             item.optCount=  Random.Shared.Next(1, 4);
                             item.itemScore=item.optCount*10;
-                            item.isGroup= Random.Shared.Next(0,4)!=1;
+                            item.isGroup= Random.Shared.Next(0, 4)!=1;
                             break;
                     }
                     student.taskRecord.taskRate= student.taskRecord.itemRecords.Where(x => x.resultWeight>0).Count()*1.0/tcount;
@@ -352,14 +368,14 @@ namespace HTEX.Test.Controllers
                             break;
                         //
                         case bool when w==1:
-                            
+
                             int[] q = new int[] { 10, 5, 5, 20, 30, 10, 25, 10, 15, 15, 30, 5, 10, 20, 15, 25, 10, 5, 15, 20, 20, 25, 5, 5 };
-                            grpcoworkScore= q[Random.Shared.Next(0, q.Count())]* Random.Shared.Next(2,4 );
+                            grpcoworkScore= q[Random.Shared.Next(0, q.Count())]* Random.Shared.Next(2, 4);
                             student.group_coworkScore.Add(grpcoworkScore);
                             break;
                     }
                 }
-              
+
                 //评测
                 for (var e = 0; e<ecount; e++)
                 {
@@ -388,7 +404,7 @@ namespace HTEX.Test.Controllers
                             //部分正确
                             case bool when w==2:
                                 var score = Random.Shared.Next(1, criterion);
-                                item.resultWeight= MinMaxNormalization(1, criterion, score, InteractWeight.T1, InteractWeight.TT); // score * 1.0  / criterion* (InteractWeight.TT-InteractWeight.T1);
+                                item.resultWeight=  LessonETLService.MinMaxNormalization(1, criterion, score, InteractWeight.T1, InteractWeight.TT); // score * 1.0  / criterion* (InteractWeight.TT-InteractWeight.T1);
                                 item.resultType= InteractReultType.TP;
                                 item.itemScore=score;
                                 break;
@@ -422,7 +438,7 @@ namespace HTEX.Test.Controllers
                     if (student.rateingRecord.itemRecords[p].itemScore>0  && student.rateingRecord.itemRecords[p].optCount>0)
                     {
                         student.rateingRecord.itemRecords[p].resultType=InteractReultType.TP;
-                        var data = MinMaxNormalization(min, max, student.rateingRecord.itemRecords[p].itemScore);
+                        var data = LessonETLService.MinMaxNormalization(min, max, student.rateingRecord.itemRecords[p].itemScore);
                         student.rateingRecord.itemRecords[p].resultWeight=Math.Round(InteractWeight.T1+  data * 1.0  / 100 * (InteractWeight.TT-InteractWeight.T1), 4);
                         if (maxItems.Select(x => x.seatID).Contains(student.seatID))
                         {
@@ -445,7 +461,7 @@ namespace HTEX.Test.Controllers
                     if (student.coworkRecord.itemRecords[p].itemScore>0)
                     {
                         student.coworkRecord.itemRecords[p].resultType=InteractReultType.TP;
-                        var data = MinMaxNormalization(min, max, student.coworkRecord.itemRecords[p].itemScore);
+                        var data = LessonETLService.MinMaxNormalization(min, max, student.coworkRecord.itemRecords[p].itemScore);
                         student.coworkRecord.itemRecords[p].resultWeight=Math.Round(InteractWeight.T1+  data * 1.0  / 100 * (InteractWeight.TT-InteractWeight.T1), 4);
                         if (maxItems.Select(x => x.seatID).Contains(student.seatID))
                         {
@@ -455,61 +471,23 @@ namespace HTEX.Test.Controllers
                     }
                 }
             }
-           
+
             #endregion 数据模拟
             string jsons = await System.IO.File.ReadAllTextAsync("F:\\lesson-local\\analysis\\analysis-model.json");
-            long time = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
+            long time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
             LessonDataAnalysisModel lessonDataAnalysis = jsons.ToObject<LessonDataAnalysisModel>();
             var codeBools = LessonETLService.GetCodeBools(students);
-            var studentLessons = LessonETLService. ProcessStudentDataV2(students, lessonDataAnalysis, codeBools);
+            var studentLessons = LessonETLService.ProcessStudentDataV2(students, lessonDataAnalysis, codeBools);
             var excleFile = $"F:\\mock-data\\{time}.xlsx";
             var runtimePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
             XmlDocument xmlDocument = new XmlDocument();
             xmlDocument.Load($"{runtimePath}\\summary.xml");
             List<string> noStujson = new List<string>();
             await LessonETLService.ExportToExcelLocal(studentLessons, excleFile, xmlDocument);
-            try {
-                await System.IO.File.WriteAllTextAsync($"F:\\mock-data\\{time}.json", new { scount, ecount, qcount, icount, tcount, pcount, xcount, students }.ToJsonString());
-            } catch (Exception ex) {
-                Console.WriteLine(scount);
-            }
-            //return Ok(new { scount, ecount, qcount, icount, tcount, pcount, xcount, students });
-        }
-
-        
- 
-        
-        private static int GetRandomValueByWeight(List<WeightedItem> items)
-        {
-            Random random = new Random();
-            double randomWeight = random.NextDouble();
-            double cumulativeWeight = 0.0;
-
-            foreach (var item in items)
-            {
-                cumulativeWeight += item.Weight;
-                if (randomWeight <= cumulativeWeight)
-                {
-                    return item.Value;
-                }
-            }
 
-            // This should not happen if all weights sum up to 1
-            return items[items.Count - 1].Value;
+            await System.IO.File.WriteAllTextAsync($"F:\\mock-data\\{time}.json", new { scount, ecount, qcount, icount, tcount, pcount, xcount, students }.ToJsonString());
+            return $"{time}";
         }
-        private static double MinMaxNormalization(double min, double max, double x, double minRank = 1, double maxRank = 100)
-        {
-            //排名指数计算=( 当前值分数- 298) / (9992 - 298) * (99 - 60) + 60
-            //将每个人的积分转化为60-100
-            //排名 = (积分 - 最低积分) / (最高积分 - 最低积分) * (最大排名 - 最小排名) + 最小排名
-            return Math.Round(x==0 ? 0 : max-min!=0 ? (x - min)*1.0 / (max - min) * (maxRank - minRank) + minRank : (x)*1.0 / (max) * (maxRank - minRank) + minRank,4);
-        }
-        
-    }
-    class WeightedItem
-    {
-        public int Value { get; set; }
-        public double Weight { get; set; }
+        //return Ok(new { scount, ecount, qcount, icount, tcount, pcount, xcount, students });
     }
-    
 }

+ 17 - 17
TEAMModelOS.Extension/HTEX.Test/Program.cs

@@ -30,31 +30,31 @@ namespace HTEX.Test
             //Test2();
 
            
-           await MockDataController.MockData();
-            //var builder = WebApplication.CreateBuilder(args);
+           //await MockDataController.MockData();
+            var builder = WebApplication.CreateBuilder(args);
 
-            //// Add services to the container.
+            // Add services to the container.
 
-            //builder.Services.AddControllers();
-            //builder.Services.AddAzureStorage(builder.Configuration.GetValue<string>("Azure:Storage:ConnectionString"));
-            //builder.Services.AddAzureRedis(builder.Configuration.GetValue<string>("Azure:Redis:ConnectionString"));
-            //builder.Services.AddAzureCosmos(builder.Configuration.GetValue<string>("Azure:Cosmos:ConnectionString"));
-            //builder.Services.AddAzureServiceBus(builder.Configuration.GetValue<string>("Azure:ServiceBus:ConnectionString"));
-            //builder.Services.AddAzureSignalR(builder.Configuration.GetValue<string>("Azure:SignalR:ConnectionString"));
-            //builder.Services.AddSnowflakeId(Convert.ToInt64(builder.Configuration.GetValue<string>("Option:LocationNum")), 1);
-            //builder.Services.AddHttpClient();
-            //var app = builder.Build();
+            builder.Services.AddControllers();
+            builder.Services.AddAzureStorage(builder.Configuration.GetValue<string>("Azure:Storage:ConnectionString"));
+            builder.Services.AddAzureRedis(builder.Configuration.GetValue<string>("Azure:Redis:ConnectionString"));
+            builder.Services.AddAzureCosmos(builder.Configuration.GetValue<string>("Azure:Cosmos:ConnectionString"));
+            builder.Services.AddAzureServiceBus(builder.Configuration.GetValue<string>("Azure:ServiceBus:ConnectionString"));
+            builder.Services.AddAzureSignalR(builder.Configuration.GetValue<string>("Azure:SignalR:ConnectionString"));
+            builder.Services.AddSnowflakeId(Convert.ToInt64(builder.Configuration.GetValue<string>("Option:LocationNum")), 1);
+            builder.Services.AddHttpClient();
+            var app = builder.Build();
 
-            //// Configure the HTTP request pipeline.
+            // Configure the HTTP request pipeline.
 
-            //app.UseHttpsRedirection();
+            app.UseHttpsRedirection();
 
-            //app.UseAuthorization();
+            app.UseAuthorization();
 
 
-            //app.MapControllers();
+            app.MapControllers();
 
-            //app.Run();
+            app.Run();
         }
         
 

+ 14 - 0
TEAMModelOS.Extension/HTEX.Test/x.xml

@@ -4,6 +4,20 @@
         <name>HTEX.Test</name>
     </assembly>
     <members>
+        <member name="M:HTEX.Test.Controllers.MockDataController.StudentLesson(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32)">
+            <summary>
+            
+            </summary>
+            <param name="scount"></param>
+            <param name="ecount"></param>
+            <param name="qcount"></param>
+            <param name="icount"></param>
+            <param name="tcount"></param>
+            <param name="pcount"></param>
+            <param name="xcount"></param>
+            <param name="kcount"></param>
+            <returns></returns>
+        </member>
         <member name="M:HTEX.Test.Service.MLService.KMeans(System.Single[],System.Int32)">
             <summary>
             

+ 1 - 1
TEAMModelOS/Controllers/Common/ArtController.cs

@@ -931,7 +931,7 @@ namespace TEAMModelOS.Controllers.Common
             }
             catch (Exception e)
             {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},art/find-summary-by-student()\n{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"OS,{_option.Location},art/find-summary-by-student()\n{e.Message}\n{e.StackTrace}\n{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                 return Ok(new { code = 500 });
             }
 

+ 1 - 1
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -2779,7 +2779,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception ex)
             {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/find-summary-by-student()\n{ex.Message}\n{ex.StackTrace}\n\n{id.GetString()}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/find-summary-by-student()\n{ex.Message}\n{ex.StackTrace}\n\n{id.GetString()}{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                 return Ok(new { status = 500 });
             }