|
@@ -59,6 +59,31 @@ namespace HTEX.Test.Controllers
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
+ [HttpPost("read")]
|
|
|
+ public async Task<IActionResult> Read(JsonElement json)
|
|
|
+ {
|
|
|
+ string m = await System.IO.File.ReadAllTextAsync("C:\\Users\\CrazyIter\\Downloads\\m.json");
|
|
|
+ string p = await System.IO.File.ReadAllTextAsync("C:\\Users\\CrazyIter\\Downloads\\p.json");
|
|
|
+ List<ItemInfo> mlist=m.ToObject<List<ItemInfo>>();
|
|
|
+ List<ItemInfo> plist=p.ToObject<List<ItemInfo>>();
|
|
|
+ var km = mlist.Where(x=> x.knowledge.IsNotEmpty()).SelectMany(x => x.knowledge).Distinct();
|
|
|
+ var kp = plist.Where(x=> x.knowledge.IsNotEmpty()).SelectMany(x => x.knowledge).Distinct();
|
|
|
+ List<CodeLong> cp = new List<CodeLong>();
|
|
|
+ foreach (var item in kp)
|
|
|
+ {
|
|
|
+ var count = plist.Where(x => x.knowledge.Contains(item)).Count();
|
|
|
+ cp.Add(new CodeLong() { code = item, value = count });
|
|
|
+ }
|
|
|
+ List<CodeLong> cm = new List<CodeLong>();
|
|
|
+ foreach (var item in km)
|
|
|
+ {
|
|
|
+ var count = mlist.Where(x => x.knowledge.Contains(item)).Count();
|
|
|
+ cm.Add(new CodeLong() { code = item, value = count });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return Ok(new { cm,cp });
|
|
|
+ }
|
|
|
[HttpPost("process-history")]
|
|
|
public async Task<IActionResult> ProcessHistory(JsonElement json)
|
|
|
{
|
|
@@ -185,7 +210,7 @@ namespace HTEX.Test.Controllers
|
|
|
/// <param name="lessonRecord"></param>
|
|
|
/// <param name="lessonBase"></param>
|
|
|
/// <returns></returns>
|
|
|
- public (LessonBase lessonBase, List<StudentLessonData> studentLessonDatas) GetBaseData(LessonRecord lessonRecord, LessonBase lessonBase)
|
|
|
+ private (LessonBase lessonBase, List<StudentLessonData> studentLessonDatas) GetBaseData(LessonRecord lessonRecord, LessonBase lessonBase)
|
|
|
{
|
|
|
//处理学生定位数据
|
|
|
List<StudentLessonData> studentLessonDatas = new List<StudentLessonData>();
|
|
@@ -215,131 +240,39 @@ namespace HTEX.Test.Controllers
|
|
|
/// <param name="lessonBase"></param>
|
|
|
/// <param name="irsDatas"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<List<StudentLessonData>> GetIRSData(LessonRecord lessonRecord, LessonBase lessonBase, TimeLineData timeLineData, List<IRSData> irsDatas, List<StudentLessonData> studentLessonDatas)
|
|
|
+ private async Task<List<StudentLessonData>> GetIRSData(LessonRecord lessonRecord, LessonBase lessonBase, TimeLineData timeLineData, List<IRSData> irsDatas, List<StudentLessonData> studentLessonDatas)
|
|
|
{
|
|
|
List<string> interactTypes = new List<string>() { "PopQuesLoad", "ReAtmpAnsStrt", "BuzrAns", "BuzrLoad", "PickupResult" };
|
|
|
//去重页面
|
|
|
- var enventsInteract = timeLineData.events.Where(x => interactTypes.Contains(x.Event)).GroupBy(x => x.Pgid)
|
|
|
- .Select(x => new { key = x.Key, list = x.ToList() });
|
|
|
- foreach (var item in enventsInteract)
|
|
|
+ var enventsInteract = timeLineData.events.Where(x => interactTypes.Contains(x.Event)).GroupBy(x => x.Pgid) .Select(x => new { key = x.Key, list = x.ToList() });
|
|
|
+
|
|
|
+ if (enventsInteract!= null)
|
|
|
{
|
|
|
- var irsDataPages = irsDatas.Where(y => item.key.Equals(y.pageID));
|
|
|
- foreach (var irsDataPage in irsDataPages)
|
|
|
+ var keys = enventsInteract.Select(x => x.key).ToList();
|
|
|
+
|
|
|
+ foreach (var item in enventsInteract)
|
|
|
{
|
|
|
- //检查是否设置正确答案。
|
|
|
- var answers = irsDataPage.question?["exercise"]?["answer"]?.ToJsonString().ToObject<List<string>>();
|
|
|
- var scoreNode = irsDataPage.question?["exercise"]?["score"];
|
|
|
- double score = 0;
|
|
|
- if (scoreNode!=null)
|
|
|
+ ProcessIRSPageData(irsDatas, studentLessonDatas, item);
|
|
|
+ }
|
|
|
+ //处理其他,评测类型的互动,因为有可能不会记录在TimeLine.json中
|
|
|
+ var envents_other = timeLineData.events.Where(x => !keys.Contains(x.Pgid)).GroupBy(x => x.Pgid) .Select(x => new { key = x.Key, list = x.ToList() });
|
|
|
+ if (envents_other!=null)
|
|
|
+ {
|
|
|
+ foreach (var item in envents_other)
|
|
|
{
|
|
|
- double.TryParse(scoreNode.ToString(), out score);
|
|
|
+ ProcessIRSPageData(irsDatas, studentLessonDatas, item);
|
|
|
}
|
|
|
- string interactType = string.Empty;
|
|
|
-
|
|
|
- if (irsDataPage.clientAnswers.IsNotEmpty())
|
|
|
- {
|
|
|
-
|
|
|
- //第一个list是几轮,一次作答,二次作答, 第二个list是学生的下标, 第三个list是 答案
|
|
|
- List<List<List<string>>> clientAnswers = new List<List<List<string>>>();
|
|
|
- foreach (var key in irsDataPage.clientAnswers.Keys)
|
|
|
- {
|
|
|
- clientAnswers.Add(irsDataPage.clientAnswers[key]);
|
|
|
- }
|
|
|
- // 获取第一个列表的长度作为比较基准
|
|
|
- int firstListLength = clientAnswers.First().Count;
|
|
|
- bool isSameLength = true;
|
|
|
- // 遍历剩余的列表并检查它们的长度是否与第一个列表相同
|
|
|
- foreach (var innerList in clientAnswers.Skip(1))
|
|
|
- {
|
|
|
- if (innerList.Count != firstListLength)
|
|
|
- {
|
|
|
- isSameLength = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //并检查学生集合的长度是否与第一个列表相同
|
|
|
- if (!isSameLength && studentLessonDatas.Count()==firstListLength)
|
|
|
- {
|
|
|
- //有设置答案
|
|
|
- if (answers.IsNotEmpty())
|
|
|
- {
|
|
|
- for (int index = 0; index< clientAnswers[0].Count; index++)
|
|
|
- {
|
|
|
- //index 代表学生下标
|
|
|
- List<InteractRecord> interactRecords = new List<InteractRecord>();
|
|
|
- if (clientAnswers.Count==1)
|
|
|
- {
|
|
|
- //即问即答
|
|
|
- interactType = "PopQuesLoad";
|
|
|
- var ans0 = clientAnswers[0][index];
|
|
|
- var IS0 = GetInteractResultHasAnswer(answers, ans0);
|
|
|
- interactRecords.Add(new InteractRecord()
|
|
|
- {
|
|
|
- status = IS0,
|
|
|
- interactType= interactType
|
|
|
- });
|
|
|
- }
|
|
|
- if (clientAnswers.Count==2)
|
|
|
- {
|
|
|
- //二次作答
|
|
|
- interactType="ReAtmpAnsStrt";
|
|
|
- var ans1 = clientAnswers[1][index];
|
|
|
- var IS1 = GetInteractResultHasAnswer(answers, ans1);
|
|
|
- interactRecords.Add(new InteractRecord()
|
|
|
- {
|
|
|
- status = IS1,
|
|
|
- interactType= interactType
|
|
|
- });
|
|
|
- }
|
|
|
- if (clientAnswers.Count>2)
|
|
|
- {
|
|
|
- //三次作答
|
|
|
- interactType="TeAtmpAnsStrt";
|
|
|
- var ans2 = clientAnswers[2][index];
|
|
|
- var IS2 = GetInteractResultHasAnswer(answers, ans2);
|
|
|
- interactRecords.Add(new InteractRecord()
|
|
|
- {
|
|
|
- status = IS2,
|
|
|
- interactType= interactType
|
|
|
- });
|
|
|
- }
|
|
|
- studentLessonDatas[index].interactRecords.AddRange(interactRecords);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //是否抢权作答的模式
|
|
|
- if (irsDataPage.isBuzz)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //处理其他,评测类型的互动,因为有可能不会记录在TimeLine.json中
|
|
|
+ var envents_other = timeLineData.events.GroupBy(x => x.Pgid) .Select(x => new { key = x.Key, list = x.ToList() });
|
|
|
+ if (envents_other!=null)
|
|
|
+ {
|
|
|
+ foreach (var item in envents_other)
|
|
|
{
|
|
|
- interactType = "BuzrAns";
|
|
|
- //处理参与抢权的
|
|
|
- Dictionary<string, InteractRecord> buzzParticipants = new Dictionary<string, InteractRecord>();
|
|
|
- foreach (var buzzParticipant in irsDataPage.buzzParticipants)
|
|
|
- {
|
|
|
- var studentData = studentLessonDatas.Find(x => x.seatID!.Equals(buzzParticipant));
|
|
|
- if (studentData != null)
|
|
|
- {
|
|
|
- buzzParticipants[buzzParticipant]=new InteractRecord() { status = InteractStatus.T1, interactType= interactType };
|
|
|
- }
|
|
|
- }
|
|
|
- //处理抢权成功的
|
|
|
- foreach (var buzzClient in irsDataPage.buzzClients)
|
|
|
- {
|
|
|
- buzzParticipants[buzzClient]=new InteractRecord() { status = InteractStatus.TT, interactType= interactType };
|
|
|
- }
|
|
|
- foreach (var studentLessonData in studentLessonDatas)
|
|
|
- {
|
|
|
- if (buzzParticipants.ContainsKey(studentLessonData.seatID!))
|
|
|
- {
|
|
|
- //处理已经有抢权结果的数据
|
|
|
- studentLessonData.interactRecords.Add(buzzParticipants[studentLessonData.seatID!]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //处理未参与抢权的
|
|
|
- studentLessonData.interactRecords.Add(new InteractRecord() { status = InteractStatus.T0, interactType = interactType });
|
|
|
- }
|
|
|
- }
|
|
|
+ ProcessIRSPageData(irsDatas, studentLessonDatas, item);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -367,6 +300,134 @@ namespace HTEX.Test.Controllers
|
|
|
return studentLessonDatas;
|
|
|
}
|
|
|
|
|
|
+ private static void ProcessIRSPageData(List<IRSData> irsDatas, List<StudentLessonData> studentLessonDatas, dynamic item)
|
|
|
+ {
|
|
|
+ var irsDataPages = irsDatas.Where(y => item.key.Equals(y.pageID));
|
|
|
+ foreach (var irsDataPage in irsDataPages)
|
|
|
+ {
|
|
|
+ //检查是否设置正确答案。
|
|
|
+ var answers = irsDataPage.question?["exercise"]?["answer"]?.ToJsonString().ToObject<List<string>>();
|
|
|
+ var _objective = irsDataPage.question?["exercise"]?["objective"];
|
|
|
+ var scoreNode = irsDataPage.question?["exercise"]?["score"];
|
|
|
+ double score = 0;
|
|
|
+ bool objective = false;
|
|
|
+ if (_objective!=null) {
|
|
|
+ objective = _objective.GetValue<bool>();
|
|
|
+ }
|
|
|
+ if (scoreNode!=null)
|
|
|
+ {
|
|
|
+ double.TryParse(scoreNode.ToString(), out score);
|
|
|
+ }
|
|
|
+ string interactType = string.Empty;
|
|
|
+
|
|
|
+ if (irsDataPage.clientAnswers.IsNotEmpty())
|
|
|
+ {
|
|
|
+
|
|
|
+ //第一个list是几轮,一次作答,二次作答, 第二个list是学生的下标, 第三个list是 答案
|
|
|
+ List<List<List<string>>> clientAnswers = new List<List<List<string>>>();
|
|
|
+ foreach (var key in irsDataPage.clientAnswers.Keys)
|
|
|
+ {
|
|
|
+ clientAnswers.Add(irsDataPage.clientAnswers[key]);
|
|
|
+ }
|
|
|
+ // 获取第一个列表的长度作为比较基准
|
|
|
+ int firstListLength = clientAnswers.First().Count;
|
|
|
+ bool isSameLength = true;
|
|
|
+ // 遍历剩余的列表并检查它们的长度是否与第一个列表相同
|
|
|
+ foreach (var innerList in clientAnswers.Skip(1))
|
|
|
+ {
|
|
|
+ if (innerList.Count != firstListLength)
|
|
|
+ {
|
|
|
+ isSameLength = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //并检查学生集合的长度是否与第一个列表相同
|
|
|
+ if (!isSameLength && studentLessonDatas.Count()==firstListLength)
|
|
|
+ {
|
|
|
+ //有设置答案
|
|
|
+ if (answers.IsNotEmpty())
|
|
|
+ {
|
|
|
+ for (int index = 0; index< clientAnswers[0].Count; index++)
|
|
|
+ {
|
|
|
+ //index 代表学生下标
|
|
|
+ List<InteractRecord> interactRecords = new List<InteractRecord>();
|
|
|
+ if (clientAnswers.Count==1)
|
|
|
+ {
|
|
|
+ //即问即答
|
|
|
+ interactType = "PopQuesLoad";
|
|
|
+ var ans0 = clientAnswers[0][index];
|
|
|
+ var IS0 = GetInteractResultHasAnswer(answers, ans0);
|
|
|
+ interactRecords.Add(new InteractRecord()
|
|
|
+ {
|
|
|
+ status = IS0,
|
|
|
+ interactType= interactType
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (clientAnswers.Count==2)
|
|
|
+ {
|
|
|
+ //二次作答
|
|
|
+ interactType="ReAtmpAnsStrt";
|
|
|
+ var ans1 = clientAnswers[1][index];
|
|
|
+ var IS1 = GetInteractResultHasAnswer(answers, ans1);
|
|
|
+ interactRecords.Add(new InteractRecord()
|
|
|
+ {
|
|
|
+ status = IS1,
|
|
|
+ interactType= interactType
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (clientAnswers.Count>2)
|
|
|
+ {
|
|
|
+ //三次作答
|
|
|
+ interactType="TeAtmpAnsStrt";
|
|
|
+ var ans2 = clientAnswers[2][index];
|
|
|
+ var IS2 = GetInteractResultHasAnswer(answers, ans2);
|
|
|
+ interactRecords.Add(new InteractRecord()
|
|
|
+ {
|
|
|
+ status = IS2,
|
|
|
+ interactType= interactType
|
|
|
+ });
|
|
|
+ }
|
|
|
+ studentLessonDatas[index].interactRecords.AddRange(interactRecords);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //是否抢权作答的模式
|
|
|
+ if (irsDataPage.isBuzz)
|
|
|
+ {
|
|
|
+ interactType = "BuzrAns";
|
|
|
+ //处理参与抢权的
|
|
|
+ Dictionary<string, InteractRecord> buzzParticipants = new Dictionary<string, InteractRecord>();
|
|
|
+ foreach (var buzzParticipant in irsDataPage.buzzParticipants)
|
|
|
+ {
|
|
|
+ var studentData = studentLessonDatas.Find(x => x.seatID!.Equals(buzzParticipant));
|
|
|
+ if (studentData != null)
|
|
|
+ {
|
|
|
+ buzzParticipants[buzzParticipant]=new InteractRecord() { status = InteractStatus.T1, interactType= interactType };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理抢权成功的
|
|
|
+ foreach (var buzzClient in irsDataPage.buzzClients)
|
|
|
+ {
|
|
|
+ buzzParticipants[buzzClient]=new InteractRecord() { status = InteractStatus.TT, interactType= interactType };
|
|
|
+ }
|
|
|
+ foreach (var studentLessonData in studentLessonDatas)
|
|
|
+ {
|
|
|
+ if (buzzParticipants.ContainsKey(studentLessonData.seatID!))
|
|
|
+ {
|
|
|
+ //处理已经有抢权结果的数据
|
|
|
+ studentLessonData.interactRecords.Add(buzzParticipants[studentLessonData.seatID!]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //处理未参与抢权的
|
|
|
+ studentLessonData.interactRecords.Add(new InteractRecord() { status = InteractStatus.T0, interactType = interactType });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static InteractStatus GetInteractResultHasAnswer(List<string>? answers, List<string> ans0)
|
|
|
{
|
|
|
InteractStatus status = InteractStatus.T0;
|
|
@@ -424,7 +485,7 @@ namespace HTEX.Test.Controllers
|
|
|
/// <param name="coworkDatas"></param>
|
|
|
/// <param name="studentLessonDatas"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<dynamic> GetExamData(LessonRecord lessonRecord, LessonBase lessonBase, TimeLineData timeLineData, List<ExamData> examDatas, List<StudentLessonData> studentLessonDatas)
|
|
|
+ private async Task<dynamic> GetExamData(LessonRecord lessonRecord, LessonBase lessonBase, TimeLineData timeLineData, List<ExamData> examDatas, List<StudentLessonData> studentLessonDatas)
|
|
|
{
|
|
|
foreach (var examData in examDatas)
|
|
|
{
|
|
@@ -468,7 +529,7 @@ namespace HTEX.Test.Controllers
|
|
|
/// <param name="coworkDatas"></param>
|
|
|
/// <param name="studentLessonDatas"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<dynamic> GetCoworkData(LessonRecord lessonRecord, LessonBase lessonBase, TimeLineData timeLineData, List<CoworkData> coworkDatas, List<StudentLessonData> studentLessonDatas)
|
|
|
+ private async Task<dynamic> GetCoworkData(LessonRecord lessonRecord, LessonBase lessonBase, TimeLineData timeLineData, List<CoworkData> coworkDatas, List<StudentLessonData> studentLessonDatas)
|
|
|
{
|
|
|
return Ok(lessonRecord);
|
|
|
}
|
|
@@ -482,7 +543,7 @@ namespace HTEX.Test.Controllers
|
|
|
/// <param name="taskDatas"></param>
|
|
|
/// <param name="studentLessonDatas"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<dynamic> GetTaskData(LessonRecord lessonRecord, LessonBase lessonBase, TimeLineData timeLineData, List<TaskData> taskDatas, List<StudentLessonData> studentLessonDatas)
|
|
|
+ private async Task<dynamic> GetTaskData(LessonRecord lessonRecord, LessonBase lessonBase, TimeLineData timeLineData, List<TaskData> taskDatas, List<StudentLessonData> studentLessonDatas)
|
|
|
{
|
|
|
return Ok(lessonRecord);
|
|
|
}
|
|
@@ -496,7 +557,7 @@ namespace HTEX.Test.Controllers
|
|
|
/// <param name="smartRatingDatas"></param>
|
|
|
/// <param name="studentLessonDatas"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<dynamic> GetSmartRatingData(LessonRecord lessonRecord, LessonBase lessonBase, TimeLineData timeLineData, List<SmartRatingData> smartRatingDatas, List<StudentLessonData> studentLessonDatas)
|
|
|
+ private async Task<dynamic> GetSmartRatingData(LessonRecord lessonRecord, LessonBase lessonBase, TimeLineData timeLineData, List<SmartRatingData> smartRatingDatas, List<StudentLessonData> studentLessonDatas)
|
|
|
{
|
|
|
return Ok(lessonRecord);
|
|
|
}
|