|
@@ -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 });
|
|
|
}
|
|
|
-
|
|
|
}
|