LessonETLService.cs 157 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009
  1. using Azure;
  2. using Azure.Storage.Blobs.Models;
  3. using DocumentFormat.OpenXml.Drawing.Charts;
  4. using DocumentFormat.OpenXml.Office2010.Excel;
  5. using DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle;
  6. using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
  7. using MathNet.Numerics;
  8. using MathNet.Numerics.Distributions;
  9. using Microsoft.Azure.Cosmos;
  10. using Microsoft.Azure.Cosmos.Linq;
  11. using Microsoft.Extensions.Configuration;
  12. using Microsoft.Extensions.Logging;
  13. using OfficeOpenXml;
  14. using OpenXmlPowerTools;
  15. using System;
  16. using System.Collections.Generic;
  17. using System.IO;
  18. using System.Linq;
  19. using System.Reflection;
  20. using System.Text;
  21. using System.Text.Json;
  22. using System.Text.RegularExpressions;
  23. using System.Threading.Tasks;
  24. using System.Xml;
  25. using TEAMModelOS.SDK;
  26. using TEAMModelOS.SDK.DI;
  27. using TEAMModelOS.SDK.Extension;
  28. using TEAMModelOS.SDK.Models;
  29. using TEAMModelOS.SDK.Models.Cosmos.Common;
  30. using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
  31. using TEAMModelOS.SDK.Models.Dtos;
  32. using static TEAMModelOS.SDK.Models.ThirdService;
  33. namespace HTEX.Lib.ETL.Lesson
  34. {
  35. public class LessonETLService
  36. {
  37. /// <summary>
  38. /// 生成学生student-analysis.json
  39. /// </summary>
  40. /// <param name="objectiveTypes"></param>
  41. /// <param name="azureStorage"></param>
  42. /// <param name="lessonLocal"></param>
  43. /// <returns></returns>
  44. public static async Task<(List<StudentLessonData> studentLessonDatas, List<StudentLessonItem> lessonItems)>
  45. DoStudentLessonData(List<string> objectiveTypes, AzureStorageFactory azureStorage, LessonLocal lessonLocal,DingDing _dingDing,
  46. CosmosClient client,string location ,AzureRedisFactory azureRedis
  47. )
  48. {
  49. List<StudentLessonData> studentLessonDatas = lessonLocal.studentLessonDatas.ToJsonString().ToObject<List<StudentLessonData>>();
  50. studentLessonDatas = LessonETLService.GetBaseInfo(lessonLocal.lessonBase!, studentLessonDatas, lessonLocal?.lessonRecord?.id);
  51. studentLessonDatas = LessonETLService.GetIRSData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.irsDatas, studentLessonDatas, lessonLocal.examDatas, lessonLocal?.lessonRecord?.id);
  52. studentLessonDatas = LessonETLService.GetCoworkData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.coworkDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
  53. studentLessonDatas = LessonETLService.GetExamData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.examDatas, studentLessonDatas, objectiveTypes, lessonLocal.lessonRecord.id);
  54. studentLessonDatas = LessonETLService.GetSmartRatingData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.smartRatingDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
  55. studentLessonDatas = LessonETLService.GetTaskData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.taskDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
  56. var pickupData = LessonETLService.GetPickupData(lessonLocal.lessonBase!, lessonLocal. timeLineData!, studentLessonDatas, lessonLocal.lessonRecord.id);
  57. studentLessonDatas= pickupData.studentLessonDatas;
  58. List<StudentLessonItem> lessonItems = new List<StudentLessonItem>();
  59. LessonDataAnalysisCluster lessonDataAnalysis = null ;
  60. string owner = lessonLocal.lessonRecord.scope.Equals("school") ? lessonLocal.lessonRecord.school : lessonLocal.lessonRecord.tmdid;
  61. try
  62. {
  63. bool exists= await azureStorage.GetBlobContainerClient("0-public").GetBlobClient($"/lesson/analysis/analysis.json").ExistsAsync();
  64. if (exists)
  65. {
  66. BlobDownloadResult blobDownload = await azureStorage.GetBlobContainerClient("0-public").GetBlobClient($"/lesson/analysis/analysis.json").DownloadContentAsync();
  67. lessonDataAnalysis = blobDownload.Content.ToObjectFromJson<LessonDataAnalysisCluster>();
  68. lessonItems = LessonETLService.ProcessStudentDataV2(studentLessonDatas, lessonDataAnalysis);
  69. XmlDocument xmlDocument = new XmlDocument();
  70. var runtimePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
  71. xmlDocument.Load($"{runtimePath}\\summary.xml");
  72. await LessonETLService.ExportToExcelAzureBlob(lessonItems,azureStorage, owner,$"{lessonLocal.lessonRecord.id}/student-analysis.xlsx", xmlDocument);
  73. await _dingDing.SendBotMsg($"学生课中报告已经生成:{owner},records/{lessonLocal.lessonRecord.id}/student-analysis.xlsx",GroupNames.成都开发測試群組);
  74. }
  75. }
  76. catch (Exception ex)
  77. {
  78. if (!ex.Message.Contains("The specified blob does not exist"))
  79. {
  80. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},lesson/analysis/analysis.json转换异常,{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  81. }
  82. }
  83. await azureStorage.GetBlobContainerClient(owner).UploadFileByContainer(studentLessonDatas.ToJsonString(), "records", $"{lessonLocal.lessonRecord.id}/student-analysis.json");
  84. if (lessonLocal.lessonRecord.scope.Equals("school")&& !string.IsNullOrWhiteSpace(lessonLocal.lessonRecord.school) && location.Equals("China",StringComparison.OrdinalIgnoreCase))
  85. {
  86. School school = null;
  87. ResponseMessage response = await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemStreamAsync(lessonLocal.lessonRecord.school, new PartitionKey("Base"));
  88. if (response.IsSuccessStatusCode)
  89. {
  90. school = JsonDocument.Parse(response.Content).RootElement.ToObject<School>();
  91. }
  92. if (school!=null)
  93. {
  94. List<Student> studentsBase = new List<Student>();
  95. var result = await client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<Student>($"select value c from c where c.id in ({string.Join(",", studentLessonDatas.Select(d => $"'{d.id}'"))})", $"Base-{school.id}");
  96. if (result.list.Any())
  97. {
  98. studentsBase = result.list;
  99. }
  100. string? periodId = !string.IsNullOrWhiteSpace(lessonLocal.lessonRecord.periodId) ? lessonLocal.lessonRecord.periodId : school.period.FirstOrDefault()?.id;
  101. var period = school.period.Find(x => x.id.Equals(periodId));
  102. if (period!=null)
  103. {
  104. var semester = SchoolService.GetSemester(period, lessonLocal.lessonRecord.startTime);
  105. string pre_id = $"{semester.studyYear}-{semester.currSemester.id}";
  106. string code = $"StudentSemesterRecord-{school.id}";
  107. foreach (var studentLessonData in studentLessonDatas)
  108. {
  109. StudentSemesterRecord studentSemester = null;
  110. ResponseMessage responseMessage = await client.GetContainer(Constant.TEAMModelOS, Constant.Student).ReadItemStreamAsync($"{pre_id}-{studentLessonData.id}", new PartitionKey(code));
  111. if (responseMessage.IsSuccessStatusCode)
  112. {
  113. studentSemester= JsonDocument.Parse(responseMessage.Content).ToObject<StudentSemesterRecord>();
  114. }
  115. else
  116. {
  117. studentSemester= new StudentSemesterRecord
  118. {
  119. id= $"{pre_id}-{studentLessonData.id}",
  120. code=code,
  121. stuid= studentLessonData.id,
  122. userType=Constant.ScopeStudent,
  123. school=school.id,
  124. studyYear=semester.studyYear,
  125. semesterId=semester.currSemester.id,
  126. period= period?.id,
  127. pk="StudentSemesterRecord"
  128. };
  129. }
  130. var les = studentSemester.les.Find(x => x.id.Equals(lessonLocal.lessonRecord.id));
  131. if (les==null)
  132. {
  133. les = new StuLesson()
  134. {
  135. id= lessonLocal.lessonRecord.id,
  136. time= lessonLocal.lessonRecord.startTime,
  137. attend=0
  138. };
  139. studentSemester.les.Add(les);
  140. }
  141. else {
  142. les.time= lessonLocal.lessonRecord.startTime;
  143. }
  144. var lesson = studentSemester.lessons.Find(x => x.id.Equals(lessonLocal.lessonRecord.id));
  145. if (lesson!=null)
  146. {
  147. if (studentLessonData.cooperation>0 || studentLessonData.achieve>0|| studentLessonData.attitude>0 || studentLessonData.cowork>0 || studentLessonData.appraise>0)
  148. {
  149. les.attend=1;
  150. lesson.tmdid = lessonLocal.lessonRecord.tmdid;
  151. lesson.sid = lessonLocal.lessonRecord.subjectId;
  152. lesson.cid = lessonLocal.lessonRecord.courseId;
  153. lesson.hrate = studentLessonData.cooperation;
  154. lesson.crate = studentLessonData.achieve;
  155. lesson.trate = studentLessonData.attitude;
  156. lesson.xrate = studentLessonData.cowork;
  157. lesson.prate = studentLessonData.appraise;
  158. }
  159. else
  160. {
  161. if (studentLessonData.attend==1)
  162. {
  163. les.attend=1;
  164. }
  165. else
  166. {
  167. les.attend=0;
  168. }
  169. }
  170. }
  171. else
  172. {
  173. if (studentLessonData.cooperation>0 || studentLessonData.achieve>0|| studentLessonData.attitude>0 || studentLessonData.cowork>0 || studentLessonData.appraise>0)
  174. {
  175. les.attend=1;
  176. lesson = new StuLessonLite
  177. {
  178. id=lessonLocal.lessonRecord.id,
  179. tmdid=lessonLocal.lessonRecord.tmdid,
  180. sid= lessonLocal.lessonRecord.subjectId,
  181. cid= lessonLocal.lessonRecord.courseId,
  182. hrate=studentLessonData.cooperation,
  183. crate=studentLessonData.achieve,
  184. trate=studentLessonData.attitude,
  185. xrate=studentLessonData.cowork,
  186. prate=studentLessonData.appraise
  187. };
  188. studentSemester.lessons.Add(lesson);
  189. }
  190. else
  191. {
  192. if (studentLessonData.attend==1)
  193. {
  194. les.attend=1;
  195. }
  196. else
  197. {
  198. les.attend=0;
  199. }
  200. }
  201. }
  202. await client.GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(studentSemester, new PartitionKey(studentSemester.code));
  203. string oid = $"{semester.studyYear}-{semester.currSemester.id}-{studentSemester.stuid}";
  204. string ocode = $"OverallEducation-{school.id}";
  205. ResponseMessage oresponse = await client.GetContainer(Constant.TEAMModelOS, Constant.Student).ReadItemStreamAsync(oid, new PartitionKey(ocode));
  206. OverallEducation overallEducation = null;
  207. var student= studentsBase.Find(x => x.id.Equals(studentSemester.stuid));
  208. if (student!=null)
  209. {
  210. if (!oresponse.IsSuccessStatusCode)
  211. {
  212. overallEducation = new OverallEducation
  213. {
  214. id =oid,
  215. code = $"OverallEducation-{school}",
  216. pk = "OverallEducation",
  217. ttl = -1,
  218. name = student.name,
  219. classId = student?.classId,
  220. schoolCode = $"{school}",
  221. semesterId = semester.currSemester.id,
  222. year = semester.studyYear,
  223. periodId = $"{period.id}",
  224. stuYear = student.year,
  225. studentId = student.id,
  226. lessonScore= new List<StudentLessonRecord>()
  227. };
  228. }
  229. else
  230. {
  231. overallEducation = JsonDocument.Parse(oresponse.Content).RootElement.ToObject<OverallEducation>();
  232. }
  233. var hasrecord = overallEducation.lessonScore.Find(x => x.lessonId.Equals(lessonLocal.lessonRecord.id));
  234. if (hasrecord==null)
  235. {
  236. hasrecord= new StudentLessonRecord();
  237. overallEducation.lessonScore.Add(hasrecord);
  238. }
  239. hasrecord.gscore = studentLessonData.gscore;
  240. hasrecord.pscore = studentLessonData.pscore;
  241. hasrecord.tscore = studentLessonData.tscore;
  242. hasrecord.tmdid = lessonLocal.lessonRecord.tmdid;
  243. hasrecord.school = school.id;
  244. hasrecord.scope = lessonLocal.lessonRecord.scope;
  245. hasrecord.lessonId = lessonLocal.lessonRecord.id;
  246. hasrecord.courseId = lessonLocal.lessonRecord.courseId;
  247. periodId = period?.id;
  248. hasrecord.subjectId = lessonLocal.lessonRecord.subjectId;
  249. hasrecord.time= lessonLocal.lessonRecord.startTime;
  250. hasrecord.attend=les.attend;
  251. if (lesson!=null)
  252. {
  253. hasrecord.hrate=lesson.hrate;
  254. hasrecord.crate=lesson.crate;
  255. hasrecord.trate=lesson.trate;
  256. hasrecord.xrate=lesson.xrate;
  257. hasrecord.prate=lesson.prate;
  258. }
  259. if (overallEducation!=null)
  260. {
  261. await client.GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(overallEducation, partitionKey: new PartitionKey(overallEducation.code));
  262. string key = $"OverallEducation:{school.id}:{period.id}:{semester.studyYear}:{semester.currSemester.id}:{student?.classId}";
  263. await azureRedis.GetRedisClient(8).HashSetAsync(key, studentLessonData.id, overallEducation.ToJsonString());
  264. await azureRedis.GetRedisClient(8).KeyExpireAsync(key, new TimeSpan(180 *24, 0, 0));
  265. }
  266. }
  267. }
  268. }
  269. }
  270. }
  271. return (studentLessonDatas, lessonItems);
  272. }
  273. public static void GenAnalysisData(string pathAnalysis, long newest, List<TechCount> techCounts)
  274. {
  275. var yearMonthDatas = techCounts.GroupBy(x => x.yearMonth).Select(x => new { key = x.Key, list = x.ToList() });
  276. // lessonDataAnalysisMonths = new List<LessonDataAnalysisMonth>();
  277. LessonDataAnalysisCluster lessonDataAnalysisCluster = new LessonDataAnalysisCluster();
  278. foreach (var yearMonthData in yearMonthDatas)
  279. {
  280. if (string.IsNullOrWhiteSpace(yearMonthData.key))
  281. {
  282. Console.WriteLine(yearMonthData.list.Select(x => x.lessonId).ToJsonString());
  283. }
  284. LessonDataAnalysisMonth lessonDataAnalysisMonth = new LessonDataAnalysisMonth() { updateTime= newest, yearMonth= yearMonthData.key };
  285. lessonDataAnalysisMonth.pscore = yearMonthData.list.SelectMany(x => x.pscore).ToList();
  286. lessonDataAnalysisMonth.tscore = yearMonthData.list.SelectMany(x => x.tscore).ToList();
  287. lessonDataAnalysisMonth.gscore = yearMonthData.list.SelectMany(x => x.gscore).ToList();
  288. lessonDataAnalysisMonth.irs= yearMonthData.list.Where(x => x.irsCount>0).Select(x => (double)x.irsCount).ToList();
  289. lessonDataAnalysisMonth.interactNormal= yearMonthData.list.Where(x => x.interactNormalCount > 0).Select(x => (double)x.interactNormalCount).ToList();
  290. lessonDataAnalysisMonth.task = yearMonthData.list.Where(x => x.taskCount > 0).Select(x => (double)x.taskCount).ToList();
  291. lessonDataAnalysisMonth.stuCowork=yearMonthData.list.SelectMany(x => x.stuCowork).ToList();
  292. lessonDataAnalysisMonth.groupCowork=yearMonthData.list.SelectMany(x => x.groupCowork).ToList();
  293. lessonDataAnalysisMonth.pickup= yearMonthData.list.Where(x => x.pickup.Count()>0).Select(x=>x.pickup).ToList();
  294. System.IO.File.WriteAllText(Path.Combine(pathAnalysis, $"{yearMonthData.key}-m-analysis.json"), lessonDataAnalysisMonth.ToJsonString());
  295. // lessonDataAnalysisMonths.Add( lessonDataAnalysisMonth);
  296. if (lessonDataAnalysisMonth.task.IsNotEmpty())
  297. {
  298. lessonDataAnalysisCluster.task.AddRange(lessonDataAnalysisMonth.task);
  299. }
  300. if (lessonDataAnalysisMonth.irs.IsNotEmpty())
  301. {
  302. lessonDataAnalysisCluster.irs.AddRange(lessonDataAnalysisMonth.irs);
  303. }
  304. if (lessonDataAnalysisMonth.interactNormal.IsNotEmpty())
  305. {
  306. lessonDataAnalysisCluster.interactNormal.AddRange(lessonDataAnalysisMonth.interactNormal);
  307. }
  308. if (lessonDataAnalysisMonth.pscore.IsNotEmpty())
  309. {
  310. lessonDataAnalysisCluster.pscore.AddRange(lessonDataAnalysisMonth.pscore);
  311. }
  312. if (lessonDataAnalysisMonth.gscore.IsNotEmpty())
  313. {
  314. lessonDataAnalysisCluster.gscore.AddRange(lessonDataAnalysisMonth.gscore);
  315. }
  316. if (lessonDataAnalysisMonth.tscore.IsNotEmpty())
  317. {
  318. lessonDataAnalysisCluster.tscore.AddRange(lessonDataAnalysisMonth.tscore);
  319. }
  320. if (lessonDataAnalysisMonth.stuCowork.IsNotEmpty())
  321. {
  322. lessonDataAnalysisCluster.stuCowork.AddRange(lessonDataAnalysisMonth.stuCowork);
  323. }
  324. if (lessonDataAnalysisMonth.groupCowork.IsNotEmpty())
  325. {
  326. lessonDataAnalysisCluster.groupCowork.AddRange(lessonDataAnalysisMonth.groupCowork);
  327. }
  328. lessonDataAnalysisCluster.pickup.AddRange(lessonDataAnalysisMonth.pickup);
  329. }
  330. //标准差偏差N倍,视为异常数据
  331. int thresholdMultiplier = 2;
  332. lessonDataAnalysisCluster.task= LessonETLService.CleanDataBySDThreshold(lessonDataAnalysisCluster.task.OrderBy(x => x), thresholdMultiplier);
  333. lessonDataAnalysisCluster.pscore= LessonETLService.CleanDataBySDThreshold(lessonDataAnalysisCluster.pscore.OrderBy(x => x), thresholdMultiplier);
  334. lessonDataAnalysisCluster.gscore= LessonETLService.CleanDataBySDThreshold(lessonDataAnalysisCluster.gscore.OrderBy(x => x), thresholdMultiplier);
  335. lessonDataAnalysisCluster.tscore= LessonETLService.CleanDataBySDThreshold(lessonDataAnalysisCluster.tscore.OrderBy(x => x), thresholdMultiplier);
  336. lessonDataAnalysisCluster.irs = LessonETLService.CleanDataBySDThreshold(lessonDataAnalysisCluster.irs.OrderBy(x => x), thresholdMultiplier);
  337. lessonDataAnalysisCluster.interactNormal=LessonETLService.CleanDataBySDThreshold(lessonDataAnalysisCluster.interactNormal.OrderBy(x => x), thresholdMultiplier);
  338. lessonDataAnalysisCluster.stuCowork=LessonETLService.CleanDataBySDThreshold(lessonDataAnalysisCluster.stuCowork.OrderBy(x => x), thresholdMultiplier);
  339. lessonDataAnalysisCluster.groupCowork=LessonETLService.CleanDataBySDThreshold(lessonDataAnalysisCluster.groupCowork.OrderBy(x => x), thresholdMultiplier);
  340. var all = lessonDataAnalysisCluster.interactNormal.OrderBy(x => x).ToArray();
  341. //超过60 80的
  342. double n = all.Max()+1;
  343. //var clusterInteract = HTEX.Lib.ETL.KMeansService.KMeansOptimized(d, 3);
  344. //foreach (var item in clusterInteract.OrderBy(x => x.Key))
  345. //{
  346. // lessonDataAnalysisCluster.clustersInteract.Add(new KeyValuePair<double, List<double>>(item.Value.Average(), item.Value));
  347. // Console.WriteLine($"dp:{item.Key} ,avg: {item.Value.Average()}, count: {item.Value.Count}, min:{item.Value.Min()}, max:{item.Value.Max()},weight:{item.Value.Count*1.0/d.Count()}");
  348. //}
  349. //IEnumerable<double> all = lessonDataAnalysisCluster.clustersInteract.SelectMany(x => x.Value);
  350. int pass = 0;
  351. for (var i = 1; i<n; i++)
  352. {
  353. var p = LessonETLService.GetPersent(all, i);
  354. if (p.persent>=60)
  355. {
  356. pass = i;
  357. break;
  358. }
  359. }
  360. var low = all.Where(x => x<pass).Average();
  361. int good = 0;
  362. for (var i = 1; i<n; i++)
  363. {
  364. var p = LessonETLService.GetPersent(all, i);
  365. if (p.persent>=80)
  366. {
  367. good = i;
  368. break;
  369. }
  370. }
  371. var medium = all.Where(x => x>=pass &&x<good).Average();
  372. var high = all.Where(x => x>=good).Average();
  373. lessonDataAnalysisCluster.interactGood=good;
  374. lessonDataAnalysisCluster.interactPass=pass;
  375. lessonDataAnalysisCluster.interactHigh=high;
  376. lessonDataAnalysisCluster.interactMedium=medium;
  377. lessonDataAnalysisCluster.interactLow=low;
  378. List<KeyValuePair<double, List<double>>> levelInteract = new List<KeyValuePair<double, List<double>>>()
  379. {
  380. new KeyValuePair<double, List<double>>(low, new List<double> { all.Where(x => x<pass).Min(), all.Where(x => x<pass).Max() }),
  381. new KeyValuePair<double, List<double>>(low, new List<double> { all.Where(x => x>=pass &&x<good).Min(), all.Where(x => x>=pass &&x<good).Max() }),
  382. new KeyValuePair<double, List<double>>(low, new List<double> { all.Where(x => x>=good).Min(), all.Where(x => x>=good).Max() })
  383. };
  384. lessonDataAnalysisCluster.levelInteract= levelInteract;
  385. //// 设置0 为自动规划聚类,11 则为自动规划后得到的数字。
  386. //var clusterInteract = KMeansService.KMeansOptimized(d,11,10);
  387. ////foreach (var item in clusterInteract)
  388. ////{
  389. //// Console.WriteLine($"dp:{item.Key} ,avg: {item.Value.Average()}, count: {item.Value.Count}, min:{item.Value.Min()}, max:{item.Value.Max()}");
  390. ////}
  391. //foreach (var item in clusterInteract.OrderBy(x => x.Key))
  392. //{
  393. // lessonDataAnalysisCluster.clustersInteract.Add(new KeyValuePair<double, List<double>>(item.Value.Average(), item.Value));
  394. // //Console.WriteLine($"dp:{item.Key} ,avg: {item.Value.Average()}, count: {item.Value.Count}, min:{item.Value.Min()}, max:{item.Value.Max()},weight:{item.Value.Count*1.0/d.Count()}");
  395. //}
  396. System.IO.File.WriteAllText(Path.Combine(pathAnalysis, "analysis.json"), lessonDataAnalysisCluster.ToJsonString());
  397. }
  398. public static async IAsyncEnumerable<TechCount> GetTeachCount(List<LessonRecord> lessonRecords, List<string> filesLessons, string pathLessons, List<string> ignore, List<string> objectiveTypes, AzureStorageFactory azureStorage,bool force)
  399. {
  400. foreach (var item in filesLessons)
  401. {
  402. if (item.EndsWith("-local.json"))
  403. {
  404. TechCount count = null;
  405. string lessonId = item.Split("\\").Last().Replace("-local.json", "");
  406. string countFile = item.Replace("-local.json", "-count.json");
  407. if (System.IO.File.Exists(countFile))
  408. {
  409. if (System.IO.File.Exists(countFile))
  410. {
  411. string contjson = await System.IO.File.ReadAllTextAsync(countFile);
  412. count = contjson.ToObject<TechCount>();
  413. }
  414. }
  415. if (string.IsNullOrWhiteSpace(count?.yearMonth)|| force)
  416. {
  417. string localjson = await System.IO.File.ReadAllTextAsync(item);
  418. var lessonLocal = localjson.ToObject<LessonLocal>();
  419. count = new TechCount();
  420. count.lessonId=item.Split("\\").Last().Replace("-local.json", "");
  421. count.examCount= lessonLocal.examDatas.Count;
  422. count.taskCount= lessonLocal.taskDatas.Count;
  423. count.irsCount= lessonLocal.irsDatas.Count;
  424. count.interactNormalCount=count.irsCount;
  425. count.coworkCount= lessonLocal.coworkDatas.Count;
  426. count.smartRatingCount= lessonLocal.smartRatingDatas.Count;
  427. count.timeCount=lessonLocal.sokratesDatas.Where(x => !ignore.Contains(x.Event) && !x.Event.Contains("End", StringComparison.OrdinalIgnoreCase)).GroupBy(x => x.Event).Select(x => new CodeLong() { code=x.Key, value= x.ToList().Count }).ToList();
  428. if (lessonLocal.lessonRecord!=null)
  429. {
  430. count.yearMonth=DateTimeOffset.FromUnixTimeMilliseconds(lessonLocal.lessonRecord.startTime).ToString("yyyyMM");
  431. if (lessonLocal?.lessonBase?.summary!=null)
  432. {
  433. count.smartRatingCountBase=lessonLocal.lessonBase.summary.smartRatingCount;
  434. count.irsCountBase=lessonLocal.lessonBase.summary.interactionCount;
  435. count.taskCountBase=lessonLocal.lessonBase.summary.collateTaskCount;
  436. count.coworkCountBase=lessonLocal.lessonBase.summary.coworkTaskCount;
  437. count.examCountBase=lessonLocal.lessonBase.summary.examCount;
  438. count.interactNormalCountBase= count.interactNormalCount;
  439. }
  440. if (lessonLocal?.lessonBase?.report?.clientSummaryList!=null)
  441. {
  442. count.pscore= lessonLocal.lessonBase.report.clientSummaryList.Where(x => x.score>0).Select(x => x.score);
  443. count.gscore= lessonLocal.lessonBase.report.clientSummaryList.Where(x => x.groupScore>0).Select(x => x.groupScore);
  444. count.tscore= lessonLocal.lessonBase.report.clientSummaryList.Where(x => x.interactScore>0).Select(x => x.interactScore);
  445. }
  446. ///处理学生数据
  447. {
  448. List<StudentLessonData> studentLessonDatas = lessonLocal.studentLessonDatas.ToJsonString().ToObject<List<StudentLessonData>>();
  449. studentLessonDatas = LessonETLService.GetBaseInfo(lessonLocal.lessonBase!, studentLessonDatas, lessonLocal?.lessonRecord?.id);
  450. studentLessonDatas = LessonETLService.GetIRSData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.irsDatas, studentLessonDatas, lessonLocal.examDatas, lessonLocal.lessonRecord.id);
  451. studentLessonDatas = LessonETLService.GetCoworkData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.coworkDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
  452. studentLessonDatas = LessonETLService.GetExamData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.examDatas, studentLessonDatas, objectiveTypes, lessonLocal.lessonRecord.id);
  453. studentLessonDatas = LessonETLService.GetSmartRatingData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.smartRatingDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
  454. studentLessonDatas = LessonETLService.GetTaskData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.taskDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
  455. var pickupData = LessonETLService.GetPickupData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, studentLessonDatas, lessonLocal.lessonRecord.id);
  456. studentLessonDatas= pickupData.studentLessonDatas;
  457. count.pickup= pickupData.pickup ;
  458. // var techCount = techCounts.Find(x => !string.IsNullOrWhiteSpace(x.lessonId) && !string.IsNullOrWhiteSpace(lessonLocal?.lessonRecord?.id) && x.lessonId.Equals(lessonLocal.lessonRecord.id));
  459. int sumUpload = 0;
  460. int taskCount = 0;
  461. int maxUpload = 0;
  462. HashSet<string> pickUp = new HashSet<string>();
  463. foreach (var stu in studentLessonDatas)
  464. {
  465. var countS = stu.taskRecord.itemRecords.Where(x => x.optCount>0);
  466. if (countS.Count()>0)
  467. {
  468. int stuUploadmax = stu.taskRecord.itemRecords.Where(x => x.optCount>0).Max(x => x.optCount);
  469. if (stuUploadmax> maxUpload)
  470. {
  471. maxUpload=stuUploadmax;
  472. }
  473. }
  474. int stuUpload = stu.taskRecord.itemRecords.Where(x => x.optCount>0).Sum(x => x.optCount);
  475. sumUpload+=stuUpload;
  476. if (stu.taskRecord.itemRecords.Count()> taskCount)
  477. {
  478. taskCount=stu.taskRecord.itemRecords.Count();
  479. }
  480. var stu_scores = stu.coworkRecord.itemRecords.Where(x => x.itemScore>0).Select(x => x.itemScore);
  481. if (stu_scores!=null && stu_scores.Count()>0)
  482. {
  483. count.stuCowork.AddRange(stu_scores);
  484. }
  485. var grp_scores = stu.group_coworkScore.Where(x => x>0);
  486. if (grp_scores!=null && grp_scores.Count()>0)
  487. {
  488. count.groupCowork.AddRange(grp_scores);
  489. }
  490. //if (stu.pickups.IsNotEmpty())
  491. //{
  492. // foreach (var pickup in stu.pickups)
  493. // {
  494. // pickUp.Add(pickup);
  495. // }
  496. //}
  497. }
  498. if (studentLessonDatas.Count>0&& taskCount>0 && maxUpload>0)
  499. {
  500. var avgUpload = sumUpload*1.0/(studentLessonDatas.Count *taskCount);
  501. count.upload.Add(new List<double>() { avgUpload, maxUpload });
  502. }
  503. //if (pickUp.Count>0)
  504. //{
  505. // count.pickup.AddRange(pickUp.ToList());
  506. //}
  507. string owner = lessonLocal.lessonRecord.scope.Equals("school") ? lessonLocal.lessonRecord.school : lessonLocal.lessonRecord.tmdid;
  508. // if (!azureStorage.GetBlobContainerClient(owner).GetBlobClient($"records/{lessonLocal.lessonRecord.id}/student-analysis.json").Exists())
  509. {
  510. }
  511. // if (!System.IO.File.Exists($"{pathLessons}\\MM{count.yearMonth}\\{lessonLocal.lessonRecord.id}-stu.json"))
  512. {
  513. }
  514. if (force)
  515. {
  516. await System.IO.File.WriteAllTextAsync($"{pathLessons}\\MM{count.yearMonth}\\{lessonLocal.lessonRecord.id}-count.json", count.ToJsonString());
  517. }
  518. else
  519. {
  520. if (lessonRecords.FindAll(x => x.id.Equals(lessonLocal.lessonRecord.id)).IsNotEmpty())
  521. {
  522. // await System.IO.File.WriteAllTextAsync($"{pathLessons}\\MM{count.yearMonth}\\{lessonLocal.lessonRecord.id}-stu.json", studentLessonDatas.ToJsonString());
  523. //只有不是强制更新的时候再去刷新线上的json文件。
  524. await azureStorage.GetBlobContainerClient(owner).UploadFileByContainer(studentLessonDatas.ToJsonString(), "records", $"{lessonLocal.lessonRecord.id}/student-analysis.json");
  525. await System.IO.File.WriteAllTextAsync($"{pathLessons}\\MM{count.yearMonth}\\{lessonLocal.lessonRecord.id}-count.json", count.ToJsonString());
  526. }
  527. }
  528. }
  529. }
  530. }
  531. if (count!=null)
  532. {
  533. yield return count;
  534. }
  535. }
  536. }
  537. }
  538. public static List<StudentLessonData> GetBaseInfo(LessonBase lessonBase, List<StudentLessonData> studentLessonDatas, string? id)
  539. {
  540. if (lessonBase?.report?.clientSummaryList !=null && lessonBase.report.clientSummaryList.IsNotEmpty())
  541. {
  542. foreach (var item in lessonBase.report.clientSummaryList)
  543. {
  544. var student = studentLessonDatas.Find(x => x.seatID!=null && x.seatID.Equals($"{item.seatID}"));
  545. if (student!= null)
  546. {
  547. student.gscore= item.groupScore;
  548. student.tscore= item.interactScore;
  549. student.pscore= item.score;
  550. }
  551. }
  552. }
  553. return studentLessonDatas;
  554. }
  555. public static async IAsyncEnumerable<LessonLocal> GetLessonLocal(List<LessonRecord> lessonRecords, List<string> localIds, AzureStorageFactory _azureStorage, string pathLessons)
  556. {
  557. foreach (var lessonRecord in lessonRecords)
  558. {
  559. string scope = lessonRecord.scope;
  560. string owner = lessonRecord.scope.Equals("school") ? lessonRecord.school : lessonRecord.tmdid;
  561. if (localIds.Contains(lessonRecord.id))
  562. {
  563. continue;
  564. }
  565. string yearMonthPath = DateTimeOffset.FromUnixTimeMilliseconds(lessonRecord.startTime).ToString("yyyyMM");
  566. LessonLocal lessonLocal = new LessonLocal { lessonRecord=lessonRecord };
  567. if (System.IO.File.Exists($"{pathLessons}\\MM{yearMonthPath}\\{lessonRecord.id}-local.json"))
  568. {
  569. string jsonp = await System.IO.File.ReadAllTextAsync($"{pathLessons}\\MM{yearMonthPath}\\{lessonRecord.id}-local.json");
  570. lessonLocal = jsonp.ToObject<LessonLocal>();
  571. }
  572. else
  573. {
  574. List<string> files = new List<string>()
  575. {
  576. $"/records/{lessonRecord.id}/IES/TimeLine.json",
  577. $"/records/{lessonRecord.id}/IES/base.json",
  578. $"/records/{lessonRecord.id}/IES/Task.json",
  579. $"/records/{lessonRecord.id}/IES/SmartRating.json",
  580. $"/records/{lessonRecord.id}/IES/IRS.json",
  581. $"/records/{lessonRecord.id}/IES/Cowork.json",
  582. $"/records/{lessonRecord.id}/Sokrates/SokratesRecords.json",
  583. };
  584. lessonLocal = new LessonLocal { lessonRecord=lessonRecord };
  585. lessonLocal = await GetLessonFiles(lessonLocal, files, owner, _azureStorage);
  586. }
  587. if (lessonLocal.lessonBase!=null && lessonLocal.lessonBase.student!=null)
  588. {
  589. var baseData = GetBaseData(lessonLocal.lessonBase!);
  590. lessonLocal.studentLessonDatas= baseData.studentLessonDatas;
  591. List<ExamData> examDatas = await GetExamInfo(lessonRecord, lessonLocal.timeLineData, _azureStorage, owner);
  592. lessonLocal.examDatas = examDatas;
  593. lessonLocal.sokratesDatas= lessonLocal.sokratesDatas.IsNotEmpty() ? lessonLocal.sokratesDatas : lessonLocal.timeLineData!=null ? lessonLocal.timeLineData.events : new List<TimeLineEvent>();
  594. }
  595. yield return lessonLocal;
  596. }
  597. }
  598. private static async Task<LessonLocal> GetLessonFiles(LessonLocal lessonLocal, List<string> files, string owner, AzureStorageFactory _azureStorage)
  599. {
  600. await Parallel.ForEachAsync(files, async (file, _) =>
  601. {
  602. try
  603. {
  604. var exists = _azureStorage.GetBlobContainerClient(owner).GetBlobClient(file).Exists();
  605. if (exists)
  606. {
  607. BlobDownloadResult blobDownloadResult = await _azureStorage.GetBlobContainerClient(owner).GetBlobClient(file).DownloadContentAsync();
  608. switch (true)
  609. {
  610. case bool when file.Contains("IES/TimeLine.json"):
  611. lessonLocal.timeLineData= blobDownloadResult.Content.ToObjectFromJson<TimeLineData>();
  612. break;
  613. case bool when file.Contains("IES/base.json"):
  614. lessonLocal.lessonBase= blobDownloadResult.Content.ToObjectFromJson<LessonBase>();
  615. break;
  616. case bool when file.Contains("IES/Task.json"):
  617. lessonLocal.taskDatas= blobDownloadResult.Content.ToObjectFromJson<List<TaskData>>();
  618. break;
  619. case bool when file.Contains("IES/SmartRating.json"):
  620. lessonLocal.smartRatingDatas= blobDownloadResult.Content.ToObjectFromJson<List<SmartRatingData>>();
  621. break;
  622. case bool when file.Contains("IES/IRS.json"):
  623. lessonLocal.irsDatas= blobDownloadResult.Content.ToObjectFromJson<List<IRSData>>();
  624. break;
  625. case bool when file.Contains("IES/Cowork.json"):
  626. lessonLocal.coworkDatas= blobDownloadResult.Content.ToObjectFromJson<List<CoworkData>>();
  627. break;
  628. case bool when file.Contains("Sokrates/SokratesRecords.json"):
  629. lessonLocal.sokratesDatas= blobDownloadResult.Content.ToObjectFromJson<List<TimeLineEvent>>();
  630. break;
  631. }
  632. }
  633. }
  634. catch (RequestFailedException ex)
  635. {
  636. Console.WriteLine($"{file},{ex.Message},{ex.StackTrace}");
  637. }
  638. catch (Exception ex)
  639. {
  640. Console.WriteLine($"{file},{ex.Message},{ex.StackTrace}");
  641. }
  642. });
  643. return lessonLocal;
  644. }
  645. /// <summary>
  646. /// 处理base.json的数据
  647. /// </summary>
  648. /// <param name="lessonRecord"></param>
  649. /// <param name="lessonBase"></param>
  650. /// <returns></returns>
  651. public static (LessonBase lessonBase, List<LocalStudent> studentLessonDatas) GetBaseData(LessonBase lessonBase)
  652. {
  653. //处理学生定位数据
  654. List<LocalStudent> studentLessonDatas = new List<LocalStudent>();
  655. int index = 0;
  656. try
  657. {
  658. if (lessonBase!=null)
  659. {
  660. lessonBase.student.ForEach(x =>
  661. {
  662. int attend = 0;
  663. var client = lessonBase.report.clientSummaryList.Find(y => y.seatID == x.seatID);
  664. if (client!=null)
  665. {
  666. attend=client.attendState;
  667. }
  668. studentLessonDatas.Add(new LocalStudent()
  669. {
  670. id = x.id,
  671. index = index,
  672. seatID =$"{x.seatID}",
  673. groupId = x.groupId,
  674. attend= attend
  675. });
  676. index++;
  677. });
  678. }
  679. }
  680. catch (Exception ex)
  681. {
  682. Console.WriteLine(lessonBase.ToJsonString());
  683. }
  684. return (lessonBase, studentLessonDatas);
  685. }
  686. /// <summary>
  687. ///单独处理挑人的逻辑
  688. ///是否从小组里面挑人。
  689. ///不需要去重页面,直接获取挑人大类 PickupResult
  690. ///小类处理:PickupRight , PickupOption , PickupNthGrp ,PickupEachGrp ,PickupDiff , PickupResult 挑人算不算互动?? 读取PickupMemberId "[\r\n 35\r\n]"
  691. /// </summary>
  692. /// <param name="lessonBase"></param>
  693. /// <param name="timeLineData"></param>
  694. /// <param name="studentLessonDatas"></param>
  695. /// <param name="lessonId"></param>
  696. /// <returns></returns>
  697. public static (List<StudentLessonData> studentLessonDatas, List<string> pickup) GetPickupData(LessonBase lessonBase, TimeLineData timeLineData, List<StudentLessonData> studentLessonDatas, string lessonId)
  698. {
  699. var enventsPickup = timeLineData?.events.Where(x => !string.IsNullOrWhiteSpace(x.Pgid) && x.Event.Equals("PickupResult"));
  700. List<string> pickup = new List<string>();
  701. if (enventsPickup.IsNotEmpty())
  702. {
  703. foreach (var item in enventsPickup)
  704. {
  705. List<int> mbrs = item.PickupMemberId.ToObject<List<int>>();
  706. // 挑人挑中 TT ,没有挑中 T1
  707. foreach (var studentLessonData in studentLessonDatas)
  708. {
  709. var mbr = mbrs.FindAll(x => studentLessonData.seatID!.Equals($"{x}"));
  710. if (mbr.IsNotEmpty())
  711. {
  712. foreach (var m in mbr)
  713. {
  714. studentLessonData.attend=1;
  715. //studentLessonData.interactRecord.interactRecords.Add(new ItemRecord()
  716. //{
  717. // resultWeight = InteractWeight.TT,
  718. // resultType=InteractReultType.TT,
  719. // itemType = string.IsNullOrWhiteSpace(item.PickupType) ? "PickupResult" : item.PickupType
  720. //});
  721. studentLessonData.pickups.Add(string.IsNullOrWhiteSpace(item.PickupType) ? "1--PickupResult" : $"1--{item.PickupType}");
  722. }
  723. }
  724. else
  725. {
  726. //处理未挑中的
  727. if (studentLessonData.attend==1)
  728. {
  729. studentLessonData.pickups.Add(string.IsNullOrWhiteSpace(item.PickupType) ? "0--PickupResult" : $"0--{item.PickupType}");
  730. }
  731. }
  732. }
  733. pickup.Add(item.PickupType);
  734. }
  735. }
  736. return (studentLessonDatas, pickup);
  737. }
  738. /// <summary>
  739. ///读取互动信息
  740. ///Event 过滤类型 'PopQuesLoad', 'ReAtmpAnsStrt', 'BuzrAns','BuzrLoad'
  741. /// 在IRS.json处理 'PopQuesLoad'互动问答 , 'ReAtmpAnsStrt' 二次作答 , 'BuzrAns' 抢权(新), 'BuzrLoad'抢权(旧)
  742. ///TimeLine.json 中找到对应类型,根据Pgid 去 IRS.json 中找到对应数据,从clientAnswers 的下标对应 base.json 中的 student 找到对应学生信息 clientAnswers.length > 1 则表示有二次作答
  743. ///读取IRS.json
  744. /// </summary>
  745. /// <param name="lessonBase"></param>
  746. /// <param name="timeLineData"></param>
  747. /// <param name="irsDatas"></param>
  748. /// <param name="studentLessonDatas"></param>
  749. /// <param name="examDatas"></param>
  750. /// <param name="itemFiles"></param>
  751. /// <returns></returns>
  752. public static List<StudentLessonData> GetIRSData(LessonBase lessonBase, TimeLineData timeLineData, List<IRSData> irsDatas, List<StudentLessonData> studentLessonDatas, List<ExamData> examDatas, string lessonId)
  753. {
  754. List<string> interactTypes = new List<string>() { "PopQuesLoad", "ReAtmpAnsStrt", "BuzrAns", "BuzrLoad" };
  755. //去重页面
  756. var enventsInteract = timeLineData?.events?.Where(x => !string.IsNullOrWhiteSpace(x.Pgid) && interactTypes.Contains(x.Event)).GroupBy(x => x.Pgid).Select(x => new { key = x.Key, list = x.ToList() });
  757. if (enventsInteract!= null && enventsInteract.Count()>0)
  758. {
  759. var keys = enventsInteract.Select(x => x.key).ToList();
  760. foreach (var item in enventsInteract)
  761. {
  762. ProcessIRSPageData(irsDatas, studentLessonDatas, examDatas, item);
  763. }
  764. //处理其他,评测类型的互动,因为有可能不会记录在TimeLine.json中
  765. var envents_other = timeLineData.events.Where(x => !string.IsNullOrWhiteSpace(x.Pgid) && !keys.Contains(x.Pgid)).GroupBy(x => x.Pgid).Select(x => new { key = x.Key, list = x.ToList() });
  766. if (envents_other!=null && envents_other.Count()>0)
  767. {
  768. foreach (var item in envents_other)
  769. {
  770. ProcessIRSPageData(irsDatas, studentLessonDatas, examDatas, item);
  771. }
  772. }
  773. }
  774. else
  775. {
  776. //处理其他,评测类型的互动,因为有可能不会记录在TimeLine.json中
  777. if (timeLineData!=null)
  778. {
  779. var envents_other = timeLineData.events.Where(x => !string.IsNullOrWhiteSpace(x.Pgid)).GroupBy(x => x.Pgid).Select(x => new { key = x.Key, list = x.ToList() });
  780. if (envents_other!=null && envents_other.Count()>0)
  781. {
  782. foreach (var item in envents_other)
  783. {
  784. ProcessIRSPageData(irsDatas, studentLessonDatas, examDatas, item);
  785. }
  786. }
  787. }
  788. else
  789. {
  790. foreach (var item in irsDatas.Select(x => x.pageID))
  791. {
  792. ProcessIRSPageData(irsDatas, studentLessonDatas, examDatas, new { key = item });
  793. }
  794. }
  795. }
  796. return studentLessonDatas;
  797. }
  798. private static List<StudentLessonData> ProcessIRSPageData(List<IRSData> irsDatas, List<StudentLessonData> studentLessonDatas, List<ExamData> examDatas, dynamic item)
  799. {
  800. var irsDataPages = irsDatas.Where(y => item.key.Equals(y.pageID));
  801. foreach (var irsDataPage in irsDataPages)
  802. {
  803. //检查是否设置正确答案。
  804. var answers_q = irsDataPage.question?["exercise"]?["answer"]?.ToJsonString().ToObject<List<string>>();
  805. //根据题去找对应的试卷和评测信息
  806. var question_id = $"{irsDataPage.question?["id"]}";
  807. var examData = examDatas.Where(x => x.paper!=null && x.paper.slides.Exists(x => !string.IsNullOrWhiteSpace(x.url) && x.url.Equals($"{question_id}.json"))).FirstOrDefault();
  808. List<string> answers = new List<string>();
  809. answers_q?.ForEach(x => {
  810. if (!string.IsNullOrWhiteSpace(x))
  811. {
  812. answers.Add(x);
  813. }
  814. });
  815. var _objective = irsDataPage.question?["exercise"]?["objective"];
  816. var scoreNode = irsDataPage.question?["exercise"]?["score"];
  817. var _type = irsDataPage.question?["exercise"]?["type"];
  818. var _answerType = irsDataPage.question?["exercise"]?["answerType"];//file,audio,text,image
  819. var qitem = irsDataPage.question?["item"]?.AsArray();
  820. if (qitem!=null && qitem.Count()>0)
  821. {
  822. for (var i = 0; i<qitem.Count(); i++)
  823. {
  824. qitem[i]!["question"]="";
  825. }
  826. }
  827. double questionScore = 0;
  828. bool objective = false;
  829. if (_objective!=null)
  830. {
  831. objective = _objective.GetValue<bool>();
  832. }
  833. //题型
  834. string type = string.Empty;
  835. if (_type!=null)
  836. {
  837. //题型
  838. type = _type.GetValue<string>();
  839. List<string> types = new List<string>() { "single", "multiple", "judge", "sortmultiple" };
  840. if (types.Contains(type))
  841. {
  842. objective = true;
  843. }
  844. else
  845. {
  846. objective = false;
  847. }
  848. }
  849. if (_answerType!=null)
  850. {
  851. _answerType.GetValue<string>();
  852. //暂不处理,可能存在依然传文字的情况
  853. //不是文本作答的处理,题目不是客观题,答案不记录
  854. //if (!_answerType.Equals("text"))
  855. //{
  856. // objective=false;
  857. // answers=new List<string>();
  858. //}
  859. }
  860. if (scoreNode!=null)
  861. {
  862. double.TryParse(scoreNode.ToString(), out questionScore);
  863. }
  864. string interactType = string.Empty;
  865. if (irsDataPage.clientAnswers.IsNotEmpty())
  866. {
  867. //第一个list是几轮,一次作答,二次作答, 第二个list是学生的下标, 第三个list是 答案
  868. List<List<List<string>>> clientAnswers = new List<List<List<string>>>();
  869. foreach (var key in irsDataPage.clientAnswers.Keys)
  870. {
  871. clientAnswers.Add(irsDataPage.clientAnswers[key]);
  872. }
  873. // 获取第一个列表的长度作为比较基准
  874. int firstListLength = clientAnswers.First().Count;
  875. bool isSameLength = true;
  876. // 遍历剩余的列表并检查它们的长度是否与第一个列表相同
  877. foreach (var innerList in clientAnswers.Skip(1))
  878. {
  879. if (innerList.Count != firstListLength)
  880. {
  881. isSameLength = false;
  882. break;
  883. }
  884. }
  885. //并检查学生集合的长度是否与第一个列表相同
  886. if (isSameLength && studentLessonDatas.Count()==firstListLength)
  887. {
  888. for (int index = 0; index< clientAnswers[0].Count; index++)
  889. {
  890. var student = studentLessonDatas[index];
  891. double studentScore = 0;
  892. if (examData!=null && examData.examClassResult.IsNotEmpty())
  893. {
  894. var examResultIndex = examData.examClassResult.First().studentIds.IndexOf(student.id);
  895. var questionIndex = examData.paper.slides.Select(x => x.url).ToList().IndexOf($"{question_id}.json");
  896. if (examResultIndex>=0
  897. && examData.examClassResult.First().studentScores.Count>=(examResultIndex+1) //防止索引越界
  898. && examData.examClassResult.First().studentScores[examResultIndex].Count>=(questionIndex+1)) //防止索引越界
  899. {
  900. //获取index学生在questionIndex题的分数
  901. studentScore = examData.examClassResult.First().studentScores[examResultIndex][questionIndex];
  902. }
  903. }
  904. //index 代表学生下标
  905. List<ItemRecord> interactRecords = new List<ItemRecord>();
  906. if (clientAnswers.Count==1)
  907. {
  908. //即问即答
  909. interactType = "PopQuesLoad";
  910. var ans0 = clientAnswers[0][index];
  911. var IS0 = GetInteractResultHasAnswer(answers, ans0, objective, type, questionScore, studentScore);
  912. interactRecords.Add(new ItemRecord()
  913. {
  914. resultWeight = IS0.weight,
  915. resultType=IS0.reultType,
  916. itemType= interactType,
  917. criterion= questionScore,
  918. itemScore= IS0.interactScore
  919. });
  920. }
  921. if (clientAnswers.Count==2)
  922. {
  923. //二次作答
  924. interactType="ReAtmpAnsStrt";
  925. var ans1 = clientAnswers[1][index];
  926. var IS1 = GetInteractResultHasAnswer(answers, ans1, objective, type, questionScore, studentScore);
  927. interactRecords.Add(new ItemRecord()
  928. {
  929. resultWeight = IS1.weight,
  930. resultType=IS1.reultType,
  931. itemType= interactType,
  932. criterion= questionScore,
  933. itemScore= IS1.interactScore
  934. });
  935. }
  936. if (clientAnswers.Count>2)
  937. {
  938. //三次作答
  939. interactType="TeAtmpAnsStrt";
  940. var ans2 = clientAnswers[2][index];
  941. var IS2 = GetInteractResultHasAnswer(answers, ans2, objective, type, questionScore, studentScore);
  942. interactRecords.Add(new ItemRecord()
  943. {
  944. resultWeight = IS2.weight,
  945. resultType=IS2.reultType,
  946. itemType= interactType,
  947. criterion= questionScore,
  948. itemScore= IS2.interactScore
  949. });
  950. }
  951. if (studentLessonDatas[index].attend==1)
  952. {
  953. studentLessonDatas[index].interactRecord.interactRecords.AddRange(interactRecords);
  954. }
  955. }
  956. }
  957. }
  958. //是否抢权作答的模式
  959. if (irsDataPage.isBuzz)
  960. {
  961. interactType = "BuzrAns";
  962. //处理参与抢权的
  963. Dictionary<string, ItemRecord> buzzParticipants = new Dictionary<string, ItemRecord>();
  964. foreach (var buzzParticipant in irsDataPage.buzzParticipants)
  965. {
  966. var studentData = studentLessonDatas.Find(x => x.seatID!.Equals(buzzParticipant));
  967. if (studentData != null)
  968. {
  969. buzzParticipants[buzzParticipant]=new ItemRecord() { resultWeight = InteractWeight.T1, itemType= interactType, resultType= InteractReultType.T1 };
  970. }
  971. }
  972. //处理抢权成功的
  973. foreach (var buzzClient in irsDataPage.buzzClients)
  974. {
  975. buzzParticipants[buzzClient]=new ItemRecord() { resultWeight = InteractWeight.TT, itemType= interactType, resultType= InteractReultType.TT };
  976. }
  977. foreach (var studentLessonData in studentLessonDatas)
  978. {
  979. if (buzzParticipants.ContainsKey(studentLessonData.seatID!))
  980. {
  981. //处理已经有抢权结果的数据
  982. studentLessonData.attend=1;
  983. studentLessonData.interactRecord.interactRecords.Add(buzzParticipants[studentLessonData.seatID!]);
  984. }
  985. else
  986. {
  987. if (studentLessonData.attend==1)
  988. {
  989. //处理未参与抢权的
  990. studentLessonData.interactRecord.interactRecords.Add(new ItemRecord() { resultWeight = InteractWeight.T0, itemType = interactType, resultType= InteractReultType.T0 });
  991. }
  992. }
  993. }
  994. }
  995. }
  996. return studentLessonDatas;
  997. }
  998. private static (double weight, string reultType, double interactScore) GetInteractResultHasAnswer(List<string>? answers, List<string> ans0, bool objective, string type, double questionScore, double studentScore)
  999. {
  1000. //List<string> ans0 = new List<string>();
  1001. //ans?.ForEach(x => {
  1002. // if (!string.IsNullOrWhiteSpace(x))
  1003. // {
  1004. // ans0.Add(x);
  1005. // }
  1006. // else { ans.Add("");}
  1007. //});
  1008. double weight = InteractWeight.T0;
  1009. string reultType = InteractReultType.T0;
  1010. double interactScore = 0;
  1011. if (answers.IsNotEmpty())
  1012. {
  1013. if (ans0.IsNotEmpty())
  1014. {
  1015. if (objective) //客观题
  1016. {
  1017. //标准答案等于作答的结果
  1018. if (answers!.Count == ans0.Count)
  1019. {
  1020. if (answers.All(item => ans0.Contains(item)))
  1021. {
  1022. //完全正确
  1023. weight= InteractWeight.TT;
  1024. reultType= InteractReultType.TT;
  1025. interactScore= studentScore==0 ? questionScore : studentScore;
  1026. }
  1027. else
  1028. {
  1029. //作答错误
  1030. weight= InteractWeight.T1;
  1031. reultType = InteractReultType.T1;
  1032. interactScore= studentScore;
  1033. }
  1034. }
  1035. //标准答案比作答的结果多
  1036. else if (answers!.Count > ans0.Count)
  1037. {
  1038. if (ans0.All(item => answers.Contains(item)))
  1039. {
  1040. //部分正确
  1041. weight= InteractWeight.TP;
  1042. reultType = InteractReultType.TP;
  1043. // 2 * 0.3 * 10= 6
  1044. interactScore= studentScore==0 ? 1/(InteractWeight.TT-InteractWeight.T1) * (InteractWeight.TP-InteractWeight.T1) * questionScore : studentScore;
  1045. }
  1046. else
  1047. {
  1048. //作答错误
  1049. weight= InteractWeight.T1;
  1050. reultType = InteractReultType.T1;
  1051. interactScore= studentScore;
  1052. }
  1053. }
  1054. //标准答案比作答结果少
  1055. else
  1056. {
  1057. //作答错误
  1058. weight= InteractWeight.T1;
  1059. reultType = InteractReultType.T1;
  1060. interactScore= studentScore;
  1061. }
  1062. }
  1063. else
  1064. {
  1065. //填空题
  1066. if ("complete".Equals(type) && answers!.Count==ans0.Count)
  1067. {
  1068. bool hasT = false;
  1069. bool hasF = false;
  1070. for (int i = 0; i < answers!.Count; i++)
  1071. {
  1072. if (answers[i].Equals(ans0[i]))
  1073. {
  1074. hasT=true;
  1075. }
  1076. else
  1077. {
  1078. hasF=true;
  1079. }
  1080. }
  1081. if (hasT && !hasF)
  1082. {
  1083. //完全正确
  1084. weight= InteractWeight.TT;
  1085. reultType = InteractReultType.TT;
  1086. interactScore= studentScore==0 ? questionScore : studentScore;
  1087. }
  1088. else if (hasT && hasF)
  1089. {
  1090. //部分正确
  1091. weight= InteractWeight.TP;
  1092. reultType = InteractReultType.TP;
  1093. // 2 * 0.3 * 10= 6
  1094. interactScore= studentScore==0 ? 1/(InteractWeight.TT-InteractWeight.T1) * (InteractWeight.TP-InteractWeight.T1) * questionScore : studentScore;
  1095. }
  1096. else if (!hasT && hasF)
  1097. {
  1098. //没有正确的,但有错误的,代表参与了
  1099. weight= InteractWeight.T1;
  1100. reultType = InteractReultType.T1;
  1101. interactScore= studentScore;
  1102. }
  1103. else if (!hasT && !hasF)
  1104. {
  1105. //没有正确的,也没有错误的,代表没有作答
  1106. weight= InteractWeight.T0;
  1107. reultType = InteractReultType.T0;
  1108. interactScore= studentScore;
  1109. }
  1110. }
  1111. else
  1112. {
  1113. //主观题,完全匹配的
  1114. if (answers!.All(item => ans0.Contains(item)))
  1115. {
  1116. //完全正确
  1117. weight= InteractWeight.TT;
  1118. reultType = InteractReultType.TT;
  1119. interactScore= studentScore==0 ? questionScore : studentScore;
  1120. }
  1121. else
  1122. { // 使用LINQ查询来判断是否有匹配的答案
  1123. bool hasMatchingAnswer = answers!.Intersect(ans0).Any();
  1124. if (hasMatchingAnswer)
  1125. {
  1126. //主观题回答正确即为完全正确
  1127. weight= InteractWeight.TT;
  1128. reultType = InteractReultType.TT;
  1129. interactScore= studentScore==0 ? questionScore : studentScore;
  1130. }
  1131. else
  1132. {
  1133. //优先根据得分与标准分的占比算出得分率,如果没有得分率,如果是直接从互动,不知道是评测的 需要先去评测找作答得分。,则采用Levenshtein距离来评估两个字符串的相似度
  1134. //没有匹配上答案,则采用Levenshtein距离来评估两个字符串的相似度
  1135. if (questionScore>0)
  1136. {
  1137. if (studentScore>0)
  1138. {
  1139. weight = studentScore * 1.0 / questionScore* (InteractWeight.TT-InteractWeight.T1);
  1140. if (weight==InteractWeight.T1)
  1141. {
  1142. reultType = InteractReultType.T1;
  1143. interactScore=studentScore;
  1144. }
  1145. else if (weight>InteractWeight.TT)
  1146. {
  1147. reultType = InteractReultType.TT;
  1148. interactScore=studentScore==0 ? questionScore : studentScore;
  1149. }
  1150. else
  1151. {
  1152. reultType = InteractReultType.TP;
  1153. // 2 * 0.3 * 10= 6
  1154. interactScore= studentScore==0 ? 1/(InteractWeight.TT-InteractWeight.T1) * (InteractWeight.TP-InteractWeight.T1) * questionScore : studentScore;
  1155. }
  1156. }
  1157. else
  1158. {
  1159. weight=InteractWeight.T1+(CalculateSimilarity(answers![0], ans0[0]) *(InteractWeight.TT-InteractWeight.T1));
  1160. if (weight==InteractWeight.T1)
  1161. {
  1162. reultType = InteractReultType.T1;
  1163. interactScore=studentScore;
  1164. }
  1165. else if (weight>InteractWeight.TT)
  1166. {
  1167. reultType = InteractReultType.TT;
  1168. interactScore=studentScore==0 ? questionScore : studentScore;
  1169. }
  1170. else
  1171. {
  1172. reultType = InteractReultType.TP;
  1173. // 2 * 0.3 * 10= 6
  1174. interactScore= studentScore==0 ? 1/(InteractWeight.TT-InteractWeight.T1) * (InteractWeight.TP-InteractWeight.T1) * questionScore : studentScore;
  1175. }
  1176. }
  1177. }
  1178. else
  1179. {
  1180. weight=InteractWeight.T1+(CalculateSimilarity(answers![0], ans0[0]) *(InteractWeight.TT-InteractWeight.T1));
  1181. if (weight==InteractWeight.T1)
  1182. {
  1183. reultType = InteractReultType.T1;
  1184. interactScore=studentScore;
  1185. }
  1186. else if (weight>InteractWeight.TT)
  1187. {
  1188. reultType = InteractReultType.TT;
  1189. interactScore=studentScore==0 ? questionScore : studentScore;
  1190. }
  1191. else
  1192. {
  1193. reultType = InteractReultType.TP;
  1194. // 2 * 0.3 * 10= 6
  1195. interactScore= studentScore==0 ? 1/(InteractWeight.TT-InteractWeight.T1) * (InteractWeight.TP-InteractWeight.T1) * questionScore : studentScore;
  1196. }
  1197. }
  1198. }
  1199. }
  1200. }
  1201. }
  1202. }
  1203. else
  1204. {
  1205. //没有作答
  1206. weight= InteractWeight.T0;
  1207. reultType = InteractReultType.T0;
  1208. interactScore=studentScore;
  1209. }
  1210. }
  1211. else
  1212. {
  1213. //没有标准答案的情况
  1214. if (ans0.IsNotEmpty())
  1215. {
  1216. bool hasAns = false;
  1217. ans0.ForEach(x => {
  1218. if (!string.IsNullOrWhiteSpace(x))
  1219. {
  1220. hasAns = true;
  1221. }
  1222. });
  1223. if (hasAns)
  1224. {
  1225. //作答了
  1226. weight= InteractWeight.T1;
  1227. reultType = InteractReultType.T1;
  1228. interactScore=studentScore;
  1229. }
  1230. else
  1231. {
  1232. //没有作答
  1233. weight= InteractWeight.T0;
  1234. reultType = InteractReultType.T0;
  1235. interactScore=studentScore;
  1236. }
  1237. }
  1238. else
  1239. {
  1240. //没有作答
  1241. weight= InteractWeight.T0;
  1242. reultType = InteractReultType.T0;
  1243. interactScore=studentScore;
  1244. }
  1245. //如果教师手动给了分或AI评分
  1246. if (questionScore>0 && studentScore>0)
  1247. {
  1248. weight = studentScore * 1.0 / questionScore* (InteractWeight.TT-InteractWeight.T1);
  1249. if (weight==InteractWeight.T1)
  1250. {
  1251. reultType = InteractReultType.T1;
  1252. interactScore=studentScore;
  1253. }
  1254. else if (weight>InteractWeight.TT)
  1255. {
  1256. reultType = InteractReultType.TT;
  1257. interactScore=studentScore==0 ? questionScore : studentScore;
  1258. }
  1259. else
  1260. {
  1261. reultType = InteractReultType.TP;
  1262. interactScore= studentScore==0 ? 1/(InteractWeight.TT-InteractWeight.T1) * (InteractWeight.TP-InteractWeight.T1) * questionScore : studentScore;
  1263. }
  1264. }
  1265. }
  1266. return (weight, reultType, interactScore);
  1267. }
  1268. /// <summary>
  1269. /// C# 代码 如何判断两句话是否一个意思,非机器学习的算法。使用Levenshtein距离来评估两个字符串的相似度,但是不能判断它们是否表达了同一个意思,后续借助AI实现
  1270. /// </summary>
  1271. /// <param name="s1"></param>
  1272. /// <param name="s2"></param>
  1273. /// <returns></returns>
  1274. public static double CalculateSimilarity(string s1, string s2)
  1275. {
  1276. int n = s1.Length;
  1277. int m = s2.Length;
  1278. int[,] d = new int[n + 1, m + 1];
  1279. for (int i = 0; i <= n; i++)
  1280. {
  1281. d[i, 0] = i;
  1282. }
  1283. for (int j = 0; j <= m; j++)
  1284. {
  1285. d[0, j] = j;
  1286. }
  1287. for (int i = 1; i <= n; i++)
  1288. {
  1289. for (int j = 1; j <= m; j++)
  1290. {
  1291. int cost = (s1[i - 1] == s2[j - 1]) ? 0 : 1;
  1292. d[i, j] = Math.Min(Math.Min(d[i - 1, j] + 1, d[i, j - 1] + 1), d[i - 1, j - 1] + cost);
  1293. }
  1294. }
  1295. return (1.0 - ((double)d[n, m] / Math.Max(s1.Length, s2.Length)));
  1296. }
  1297. public static async Task<List<ExamData>> GetExamInfo(LessonRecord item, TimeLineData? timeLineData, AzureStorageFactory _azureStorage/*,ILogger<LessonETLService> _logger*/, string owner)
  1298. {
  1299. //读取ExamData
  1300. List<ExamData> examDatas = new List<ExamData>();
  1301. try
  1302. {
  1303. var examPages = timeLineData?.events.Where(x => !string.IsNullOrWhiteSpace(x.Pgid) && !string.IsNullOrWhiteSpace(x.ExamId));
  1304. if (examPages!=null && examPages.Count()>0)
  1305. {
  1306. var examsFiles = await _azureStorage.GetBlobContainerClient(owner).List($"records/{item.id}/Exam");
  1307. var paperFiles = await _azureStorage.GetBlobContainerClient(owner).List($"records/{item.id}/ExamPaper");
  1308. foreach (var examsFile in examsFiles)
  1309. {
  1310. if (examsFile.EndsWith("Exam.json"))
  1311. {
  1312. ExamData? examData = null;
  1313. try
  1314. {
  1315. BlobDownloadResult examDataDownload = await _azureStorage.GetBlobContainerClient(owner).GetBlobClient(examsFile).DownloadContentAsync();
  1316. var str = examDataDownload.Content.ToString().Replace("\r\n", "").Replace("\ufeff", "").Replace("\"publish\": \"0\"", "\"publish\": 0").Replace("\"publish\": \"1\"", "\"publish\": 1");
  1317. examData= str.ToObject<ExamData>();
  1318. // examData = examDataDownload.Content.ToObjectFromJson<ExamData>();
  1319. }
  1320. catch (Exception ex)
  1321. {
  1322. if (!ex.Message.Contains("The specified blob does not exist"))
  1323. {
  1324. // _logger.LogError(ex, $"文件不存在:{examsFile}");
  1325. }
  1326. }
  1327. if (examData!=null && examData.exam.papers.IsNotEmpty())
  1328. {
  1329. string paperId = examData.exam.papers.First().id;
  1330. if (_azureStorage.GetBlobContainerClient(owner).GetBlobClient($"/records/{item.id}/ExamPaper/{paperId}/index.json").Exists())
  1331. {
  1332. LessonPaper lessonPaper = null;
  1333. try
  1334. {
  1335. BlobDownloadResult paperblobDownload = await _azureStorage.GetBlobContainerClient(owner).GetBlobClient($"/records/{item.id}/ExamPaper/{paperId}/index.json").DownloadContentAsync();
  1336. lessonPaper = paperblobDownload.Content.ToObjectFromJson<LessonPaper>();
  1337. examData.paper = lessonPaper;
  1338. }
  1339. catch (Exception ex)
  1340. {
  1341. if (!ex.Message.Contains("The specified blob does not exist"))
  1342. {
  1343. // _logger.LogError(ex, $"文件不存在:/records/{item.id}/ExamPaper/{paperId}/index.json");
  1344. }
  1345. }
  1346. }
  1347. examDatas.Add(examData);
  1348. }
  1349. }
  1350. }
  1351. }
  1352. }
  1353. catch (Exception ex)
  1354. {
  1355. // _logger.LogError(ex, ex.Message);
  1356. }
  1357. return examDatas;
  1358. }
  1359. /// <summary>
  1360. /// 获取课中评测数据
  1361. /// </summary>
  1362. /// <param name="lessonBase"></param>
  1363. /// <param name="timeLineData"></param>
  1364. /// <param name="examDatas"></param>
  1365. /// <param name="studentLessonDatas"></param>
  1366. /// <param name="objectiveTypes"></param>
  1367. /// <returns></returns>
  1368. public static List<StudentLessonData> GetExamData(LessonBase lessonBase, TimeLineData timeLineData, List<ExamData> examDatas, List<StudentLessonData> studentLessonDatas, List<string> objectiveTypes, string lessonId)
  1369. {
  1370. foreach (var examData in examDatas)
  1371. {
  1372. //直接取第一个元素的试卷,因为在HiTeach中,只会是一个试卷(一个科目),一个班参与。
  1373. var allocation = examData?.exam?.papers?.FirstOrDefault()?.point?.Sum();
  1374. var answersStd = examData?.exam?.papers?.FirstOrDefault()?.answers;
  1375. List<List<string>> answers = new List<List<string>>();
  1376. if (answersStd!=null)
  1377. {
  1378. answersStd.ForEach(x => //去除[""]此种类型的标准答案,转为[]
  1379. {
  1380. List<string> ans = new List<string>();
  1381. if (x.Count!=0)
  1382. {
  1383. if (x.Count==1)
  1384. {
  1385. if (string.IsNullOrWhiteSpace(x[0]))
  1386. {
  1387. answers.Add(ans);
  1388. }
  1389. else
  1390. {
  1391. answers.Add(x);
  1392. }
  1393. }
  1394. else
  1395. {
  1396. answers.Add(x);
  1397. }
  1398. }
  1399. else
  1400. {
  1401. answers.Add(ans);
  1402. }
  1403. });
  1404. }
  1405. examData?.examClassResult?.ForEach(item => {
  1406. //学生下标
  1407. int index = 0;
  1408. if (item.studentAnswersArray.Count()>0
  1409. && item.studentAnswersArray.Count() == item.studentIds.Count() //学生作答数量和学生id数量一致
  1410. && item.studentScores.Count()==item.studentIds.Count()) //学生分数和学生id数量一致
  1411. {
  1412. item.studentAnswersArray.ForEach(stu => {
  1413. var student = studentLessonDatas.Find(x => x.id!.Equals(item.studentIds[index]));
  1414. if (student!=null && student.attend==1)
  1415. {
  1416. //是否要判断主观题或者客观题, 多套试卷,有主观题的
  1417. //,如果没获得结果,
  1418. //主观题有回答的:608942756458532864\Clients\18782481024\Ans\27-4341670635487887360-examExchangeAnswerlist
  1419. //27 从1开始的学生序号-4341670635487887360评测编号,内容qNo 是从1开始的题号。
  1420. if (stu.IsNotEmpty() && answers.Count()==stu.Count && examData.exam.papers[0].type.Count()==answers.Count)
  1421. {
  1422. StudentExamRecord studentExam = new StudentExamRecord();
  1423. var studentScore = item.studentScores[index];
  1424. List<ItemRecord> answerRecords = new List<ItemRecord>();
  1425. //题目下标
  1426. int itemIndex = 0;
  1427. stu.ForEach(ans =>
  1428. {
  1429. bool objective = objectiveTypes.Contains(examData.exam.papers[0].type[itemIndex]);
  1430. var questionScore = examData.exam.papers[0].point[itemIndex];
  1431. string type = examData.exam.papers[0].type[itemIndex];
  1432. var res = GetInteractResultHasAnswer(answers[itemIndex], ans, objective, type, questionScore, studentScore[itemIndex]);
  1433. ItemRecord interactRecord = new ItemRecord()
  1434. {
  1435. itemType="SPQStrt",//类型
  1436. resultType=res.reultType,//作答结果类型
  1437. resultWeight=res.weight,//得分权重
  1438. criterion= questionScore,//标准分
  1439. itemScore= studentScore[itemIndex]//得分
  1440. };
  1441. answerRecords.Add(interactRecord);
  1442. itemIndex++;
  1443. });
  1444. studentExam.score= answerRecords.Where(x => x.itemScore>=0).Select(x => x.itemScore).Sum();//得分
  1445. studentExam.scoreRate= allocation.HasValue && allocation.Value>0 ? studentExam.score * 1.0/allocation.Value : 0;//得分率
  1446. studentExam.answerRate= answerRecords.Where(x => x.resultWeight>0).Count()*1.0/studentScore.Count();//作答率
  1447. studentExam.examId=examData.exam.id;
  1448. studentExam.itemRecords=answerRecords;
  1449. student.examRecords.Add(studentExam);
  1450. }
  1451. }
  1452. index++;
  1453. });
  1454. }
  1455. });
  1456. }
  1457. return studentLessonDatas;
  1458. }
  1459. /// <summary>
  1460. /// 协作参与率 态度计算
  1461. /// </summary>
  1462. /// <param name="lessonBase"></param>
  1463. /// <param name="timeLineData"></param>
  1464. /// <param name="coworkDatas"></param>
  1465. /// <param name="studentLessonDatas"></param>
  1466. /// <param name="lessonId"></param>
  1467. /// <returns></returns>
  1468. public static List<StudentLessonData> GetCoworkData(LessonBase lessonBase, TimeLineData timeLineData, List<CoworkData> coworkDatas, List<StudentLessonData> studentLessonDatas, string lessonId)
  1469. {
  1470. int p = 0;
  1471. foreach (var coworkData in coworkDatas)
  1472. {
  1473. var keys = coworkData.participateLevelList.Keys;
  1474. foreach (var key in keys)
  1475. {
  1476. var student = studentLessonDatas.Find(x => x.seatID!.Equals(key));
  1477. if (student!=null && student.attend==1)
  1478. {
  1479. var score = coworkData.participateLevelList[key];//协作得分,是否是经过指数计算的
  1480. var itemRecord = new ItemRecord { criterion=-1, itemType= coworkData.coworkType, itemScore=score, isGroup= coworkData.coworkType.Equals("Group") ? true : false };
  1481. //不能完全依赖
  1482. if (score>0)
  1483. {
  1484. student.coworkScore.Add(score);
  1485. itemRecord.resultWeight = InteractWeight.TP;
  1486. itemRecord.resultType = InteractReultType.TP;
  1487. }
  1488. else
  1489. {
  1490. itemRecord.resultWeight = InteractWeight.T0;
  1491. itemRecord.resultType = InteractReultType.T0;
  1492. }
  1493. student.coworkRecord.itemRecords.Add(itemRecord);
  1494. }
  1495. if (key.Contains("g", StringComparison.OrdinalIgnoreCase))
  1496. {
  1497. string groupId = key.Replace("g", "").Replace("G", "");
  1498. var score = coworkData.participateLevelList[key];
  1499. if (score>0)
  1500. {
  1501. var groupStu = studentLessonDatas.FindAll(x => x.attend==1 && !string.IsNullOrWhiteSpace(x.groupId) && x.groupId.Equals(groupId));
  1502. if (groupStu.IsNotEmpty())
  1503. {
  1504. foreach (var stu in groupStu)
  1505. {
  1506. stu.group_coworkScore.Add(score);
  1507. stu.coworkRecord.itemRecords[p].itemScore+=score;
  1508. stu.coworkRecord.itemRecords[p].resultWeight=InteractWeight.TP;
  1509. stu.coworkRecord.itemRecords[p].resultType=InteractReultType.TP;
  1510. }
  1511. }
  1512. }
  1513. }
  1514. }
  1515. var order = studentLessonDatas.Where(x => x.attend==1).OrderByDescending(x => x.coworkRecord.itemRecords[p].itemScore);
  1516. var maxItems = studentLessonDatas.FindAll(x => x.attend==1&& x.coworkRecord.itemRecords[p].itemScore==order.First().coworkRecord.itemRecords[p].itemScore);
  1517. var max = studentLessonDatas.FindAll(x => x.attend==1&& x.coworkRecord.itemRecords[p].itemScore==order.First().coworkRecord.itemRecords[p].itemScore).First().coworkRecord.itemRecords[p].itemScore;
  1518. var min = studentLessonDatas.FindAll(x => x.attend==1&& x.coworkRecord.itemRecords[p].itemScore==order.Last().coworkRecord.itemRecords[p].itemScore).First().coworkRecord.itemRecords[p].itemScore;
  1519. var sum = studentLessonDatas.Where(x => x.attend==1).Sum(x => x.coworkRecord.itemRecords[p].itemScore);
  1520. foreach (var student in studentLessonDatas)
  1521. {
  1522. if (student.attend==1 && student.coworkRecord.itemRecords.Count>=p+1 && student.coworkRecord.itemRecords[p].itemScore>0)
  1523. {
  1524. student.coworkRecord.itemRecords[p].resultType=InteractReultType.TP;
  1525. var data = MinMaxNormalization(min, max, student.coworkRecord.itemRecords[p].itemScore);
  1526. student.coworkRecord.itemRecords[p].resultWeight=InteractWeight.T1+ data * 1.0 / 100 * (InteractWeight.TT-InteractWeight.T1);
  1527. if (maxItems.Select(x => x.seatID).Contains(student.seatID))
  1528. {
  1529. student.coworkRecord.itemRecords[p].resultType= InteractReultType.TT;
  1530. student.coworkRecord.itemRecords[p].resultWeight= InteractWeight.TT;
  1531. }
  1532. }
  1533. }
  1534. p++;
  1535. }
  1536. return studentLessonDatas;
  1537. }
  1538. /// <summary>
  1539. /// 处理学生回推数据,并将回推纳入学习态度计算。
  1540. /// </summary>
  1541. /// <param name="lessonBase"></param>
  1542. /// <param name="timeLineData"></param>
  1543. /// <param name="taskDatas"></param>
  1544. /// <param name="studentLessonDatas"></param>
  1545. /// <returns></returns>
  1546. public static List<StudentLessonData> GetTaskData(LessonBase lessonBase, TimeLineData timeLineData, List<TaskData> taskDatas, List<StudentLessonData> studentLessonDatas, string lessonId)
  1547. {
  1548. //协作也算任务的一种,'WrkSpaceLoad' 作品收集, "isGroupItem": false,
  1549. int indexTask = 0;
  1550. foreach (var taskData in taskDatas)
  1551. {
  1552. //作品收集是全部人员都要参加
  1553. foreach (var student in studentLessonDatas)
  1554. {
  1555. if (student.attend==1)
  1556. {
  1557. var work = taskData.clientWorks.Find(x => $"{x.seatID}".Equals(student.seatID));
  1558. if (work!= null)
  1559. {
  1560. if (work.blobFiles.Count>0)
  1561. {
  1562. student.uploadCount.Add(work.blobFiles.Count);
  1563. }
  1564. student.taskRecord.itemRecords.Add(new ItemRecord { itemType="WrkSpaceLoad", itemScore=work.blobFiles.Count *10, resultWeight=InteractWeight.TT, resultType=InteractReultType.TT, isGroup= work.isGroupItem, optCount=work.blobFiles.Count });
  1565. }
  1566. else
  1567. {
  1568. student.taskRecord.itemRecords.Add(new ItemRecord { itemType="WrkSpaceLoad", itemScore=0, resultWeight=InteractWeight.T0, resultType=InteractReultType.T0, isGroup= false });
  1569. }
  1570. }
  1571. }
  1572. ////////
  1573. ///需要处理小组的情况,当前人员没有提交作品,但是有可能是小组其他人员提交了,需要判断一下。
  1574. ///
  1575. var students = studentLessonDatas.FindAll(x => x.attend==1 && x.taskRecord.itemRecords[indexTask].isGroup==true);
  1576. foreach (var student in students)
  1577. {
  1578. var groupStudents = studentLessonDatas.FindAll(x => x.id!=student.id && x.attend==1 && !string.IsNullOrWhiteSpace(x.groupId) && x.groupId.Equals(student.groupId));
  1579. foreach (var groupstudent in groupStudents)
  1580. {
  1581. groupstudent.taskRecord.itemRecords[indexTask].isGroup=true;
  1582. groupstudent.taskRecord.itemRecords[indexTask].optCount=student.taskRecord.itemRecords[indexTask].optCount;
  1583. groupstudent.taskRecord.itemRecords[indexTask].itemScore=student.taskRecord.itemRecords[indexTask].itemScore;
  1584. groupstudent.taskRecord.itemRecords[indexTask].resultWeight=student.taskRecord.itemRecords[indexTask].resultWeight;
  1585. groupstudent.taskRecord.itemRecords[indexTask].resultType=student.taskRecord.itemRecords[indexTask].resultType;
  1586. }
  1587. }
  1588. var groupDatas = taskData.clientWorks.FindAll(x => x.seatID==0 && x.isGroupItem);
  1589. foreach (var groupData in groupDatas)
  1590. {
  1591. var groupStudents = studentLessonDatas.FindAll(x => x.attend==1 && !string.IsNullOrWhiteSpace(x.groupId) && x.groupId.Equals(groupData.groupID));
  1592. foreach (var student in groupStudents)
  1593. {
  1594. student.taskRecord.itemRecords[indexTask].isGroup=true;
  1595. student.taskRecord.itemRecords[indexTask].optCount=groupData.blobFiles.Count;
  1596. student.taskRecord.itemRecords[indexTask].itemScore= 10* groupData.blobFiles.Count;
  1597. if (groupData.blobFiles.Count>0)
  1598. {
  1599. student.taskRecord.itemRecords[indexTask].resultWeight=InteractWeight.TT;
  1600. student.taskRecord.itemRecords[indexTask].resultType=InteractReultType.TT;
  1601. }
  1602. else
  1603. {
  1604. student.taskRecord.itemRecords[indexTask].resultWeight=InteractWeight.T0;
  1605. student.taskRecord.itemRecords[indexTask].resultType=InteractReultType.T0;
  1606. }
  1607. }
  1608. }
  1609. indexTask++;
  1610. }
  1611. return studentLessonDatas;
  1612. }
  1613. /// <summary>
  1614. ///评分参与率 态度计算
  1615. ///读取互评信息
  1616. ///评分相关 在SmartRating.json 处理 GrandRating 星光大评分, 投票Voting 和 PeerAssessment(All每人多件评分,Two随机分配互评, Self自评)
  1617. ///Event 过滤类型 'RatingStart'
  1618. ///smartRateSummary.mutualSummary.mutualType 互评【All(每人多件评分) Two(随机分配互评) Self(自评)】 smartRateSummary.meteor_VoteSummary 投票
  1619. ///读取SmartRating.json
  1620. /// </summary>
  1621. /// <param name="lessonBase"></param>
  1622. /// <param name="timeLineData"></param>
  1623. /// <param name="smartRatingDatas"></param>
  1624. /// <param name="studentLessonDatas"></param>
  1625. /// <returns></returns>
  1626. public static List<StudentLessonData> GetSmartRatingData(LessonBase lessonBase, TimeLineData timeLineData, List<SmartRatingData> smartRatingDatas, List<StudentLessonData> studentLessonDatas, string lessonId)
  1627. {
  1628. int index = 0;
  1629. foreach (var smartRatingData in smartRatingDatas)
  1630. {
  1631. string type = "";
  1632. //投票类型的
  1633. var keys_vote = smartRatingData.smartRateSummary?.meteor_VoteSummary?.Keys?.ToList();
  1634. if (keys_vote.IsNotEmpty())
  1635. {
  1636. type="Voting";
  1637. bool addData = false;
  1638. foreach (var key in keys_vote!)
  1639. {
  1640. try
  1641. {
  1642. //问题数据F:\lesson-local\632424798693232640-local.json pclxxx
  1643. if (smartRatingData.smartRateSummary!.voteDetailResult.TryGetValue(key, out var value))
  1644. {
  1645. var voteDetailResults = smartRatingData.smartRateSummary!.voteDetailResult[key];
  1646. foreach (var student in studentLessonDatas)
  1647. {
  1648. if (student.attend==1)
  1649. {
  1650. //投票是全员参与
  1651. var datasS = voteDetailResults.FindAll(x => x.id.Equals(student.seatID));
  1652. if (datasS.IsNotEmpty())
  1653. {
  1654. //T1,只有评论别人,没被别人评论 或者是评论了别人,但是没有被别人评论,
  1655. student.rateingRecord.itemRecords.Add(new ItemRecord { itemType=type, resultType=InteractReultType.T1, resultWeight = InteractWeight.T1 });
  1656. addData=true;
  1657. }
  1658. else
  1659. { //T0 是没有评论别人,也没被别人评论,
  1660. student.rateingRecord.itemRecords.Add(new ItemRecord { itemType=type, resultType=InteractReultType.T0, resultWeight = InteractWeight.T0 });
  1661. addData=true;
  1662. }
  1663. //T0 是没有评论别人,也没被别人评论,
  1664. //T1,只有评论别人,没被别人评论 或者是评论了别人,但是没有被别人评论,
  1665. //TP 有被别人评论,且评论了别人,
  1666. //TT是评论了别人,且被别人评论次数最高,或者分值最高。
  1667. }
  1668. }
  1669. }
  1670. }
  1671. catch (Exception ex)
  1672. {
  1673. throw new Exception($"{lessonId}\n{ex.Message}\n{ex.StackTrace}");
  1674. }
  1675. var meteor_VoteSummary = smartRatingData.smartRateSummary!.meteor_VoteSummary[key];
  1676. var order = meteor_VoteSummary.OrderByDescending(x => x.result);
  1677. var maxItems = meteor_VoteSummary.FindAll(x => x.result==order.First().result);
  1678. var max = meteor_VoteSummary.FindAll(x => x.result==order.First().result).First().result;
  1679. var min = meteor_VoteSummary.FindAll(x => x.result==order.Last().result).First().result;
  1680. var sum = meteor_VoteSummary.Sum(x => x.result);
  1681. //排名指数计算=( 当前值分数- 298) / (9992 - 298) * (99 - 60) + 60
  1682. //将每个人的积分转化为60-100
  1683. //排名 = (积分 - 最低积分) / (最高积分 - 最低积分) * (最大排名 - 最小排名) + 最小排名
  1684. foreach (var datasD in meteor_VoteSummary)
  1685. {
  1686. //有被人评论或投票
  1687. var student = studentLessonDatas.Find(x => x.seatID!.Equals(datasD.id));
  1688. if (student!=null)
  1689. {
  1690. if (index<student.rateingRecord.itemRecords.Count && student.rateingRecord.itemRecords[index].itemType!.Equals(type))
  1691. {
  1692. if (student.rateingRecord.itemRecords[index].resultType!.Equals(InteractReultType.T0))
  1693. {
  1694. //T1,只有评论别人,没被别人评论 或者是评论了别人,但是没有被别人评论,
  1695. student.rateingRecord.itemRecords[index].resultType= InteractReultType.T1;
  1696. student.rateingRecord.itemRecords[index].resultWeight= InteractWeight.T1;
  1697. }
  1698. else if (student.rateingRecord.itemRecords[index].resultType!.Equals(InteractReultType.T1))
  1699. {
  1700. //TP 有被别人评论,且评论了别人,
  1701. student.rateingRecord.itemRecords[index].resultType= InteractReultType.TP;
  1702. var data = MinMaxNormalization(min, max, datasD.result);
  1703. //student.rateingRecord.itemRecords[index].resultWeight= InteractWeight.TP;
  1704. student.rateingRecord.itemRecords[index].resultWeight=InteractWeight.T1+ data * 1.0 / 100 * (InteractWeight.TT-InteractWeight.T1);
  1705. //获得的票数
  1706. student.rateingRecord.itemRecords[index].itemScore=datasD.result;
  1707. //TT是评论了别人,且被别人评论次数最高,或者分值最高。
  1708. if (maxItems.Select(x => x.id).Contains(student.seatID))
  1709. {
  1710. student.rateingRecord.itemRecords[index].resultType= InteractReultType.TT;
  1711. student.rateingRecord.itemRecords[index].resultWeight= InteractWeight.TT;
  1712. }
  1713. }
  1714. }
  1715. }
  1716. }
  1717. if (addData)
  1718. {
  1719. index++;
  1720. }
  1721. }
  1722. }
  1723. //星光大评分,全员评分
  1724. var keys_GrandRating = smartRatingData.smartRateSummary?.scoreDetailResult?.Keys?.ToList();
  1725. if (keys_GrandRating.IsNotEmpty() && smartRatingData.smartRateSummary!=null && smartRatingData.smartRateSummary.meteor_ScoreSummary.IsNotEmpty())
  1726. {
  1727. bool addData = false;
  1728. type="GrandRating";
  1729. foreach (var student in studentLessonDatas)
  1730. {
  1731. if (student.attend==1)
  1732. {
  1733. if (keys_GrandRating!.Contains(student.seatID!))
  1734. {
  1735. //T1,只有评论别人,没被别人评论 或者是评论了别人,但是没有被别人评论,
  1736. student.rateingRecord.itemRecords.Add(new ItemRecord { itemType=type, resultType=InteractReultType.T1, resultWeight = InteractWeight.T1 });
  1737. addData = true;
  1738. }
  1739. else
  1740. {
  1741. //T0 是没有评论别人,也没被别人评论,
  1742. student.rateingRecord.itemRecords.Add(new ItemRecord { itemType=type, resultType=InteractReultType.T0, resultWeight = InteractWeight.T0 });
  1743. addData = true;
  1744. }
  1745. }
  1746. }
  1747. var order = smartRatingData.smartRateSummary.meteor_ScoreSummary.Where(x => x.result>0||!string.IsNullOrWhiteSpace(x.comment)).OrderByDescending(x => x.result);
  1748. if (order.Count()>0)
  1749. {
  1750. var maxItems = smartRatingData.smartRateSummary.meteor_ScoreSummary.FindAll(x => x.result==order.First().result);
  1751. var max = smartRatingData.smartRateSummary.meteor_ScoreSummary.FindAll(x => x.result==order.First().result).First().result;
  1752. var min = smartRatingData.smartRateSummary.meteor_ScoreSummary.FindAll(x => x.result==order.Last().result).First().result;
  1753. var sum = smartRatingData.smartRateSummary.meteor_ScoreSummary.Sum(x => x.result);
  1754. foreach (var meteor_ScoreSummary in smartRatingData.smartRateSummary.meteor_ScoreSummary)
  1755. {
  1756. var student = studentLessonDatas.Find(x => x.seatID!.Equals(meteor_ScoreSummary.id));
  1757. if (student!=null)
  1758. {
  1759. if (index<student.rateingRecord.itemRecords.Count && student.rateingRecord.itemRecords[index].itemType!.Equals(type))
  1760. {
  1761. if (student.rateingRecord.itemRecords[index].resultType!.Equals(InteractReultType.T0))
  1762. {
  1763. //T1,只有评论别人,没被别人评论 或者是评论了别人,但是没有被别人评论,
  1764. student.rateingRecord.itemRecords[index].resultType= InteractReultType.T1;
  1765. student.rateingRecord.itemRecords[index].resultWeight= InteractWeight.T1;
  1766. }
  1767. else if (student.rateingRecord.itemRecords[index].resultType!.Equals(InteractReultType.T1))
  1768. {
  1769. //TP 有被别人评论,且评论了别人,
  1770. student.rateingRecord.itemRecords[index].resultType= InteractReultType.TP;
  1771. var data = MinMaxNormalization(min, max, meteor_ScoreSummary.result);
  1772. //student.rateingRecord.itemRecords[index].resultWeight= InteractWeight.TP;
  1773. student.rateingRecord.itemRecords[index].resultWeight= InteractWeight.T1+ data * 1.0 / 100 * (InteractWeight.TT-InteractWeight.T1);
  1774. //被评论次数
  1775. student.rateingRecord.itemRecords[index].itemScore=meteor_ScoreSummary.result;
  1776. //TT是评论了别人,且被别人评论次数最高,或者分值最高。
  1777. if (maxItems.Select(x => x.id).Contains(student.seatID) &&student.rateingRecord.itemRecords[index].itemScore>0)
  1778. {
  1779. student.rateingRecord.itemRecords[index].resultType= InteractReultType.TT;
  1780. student.rateingRecord.itemRecords[index].resultWeight= InteractWeight.TT;
  1781. }
  1782. }
  1783. }
  1784. }
  1785. }
  1786. }
  1787. if (addData)
  1788. {
  1789. index++;
  1790. }
  1791. }
  1792. // 互评 PeerAssessment(All每人多件评分,Two随机分配互评, Self自评)
  1793. var keys_PeerAssessment = smartRatingData.smartRateSummary?.mutualDetailSummary?.Keys?.ToList();
  1794. if (keys_PeerAssessment.IsNotEmpty() && smartRatingData.smartRateSummary?.mutualSummary!=null
  1795. && smartRatingData.smartRateSummary.mutualSummary.mutualResults.IsNotEmpty()
  1796. && smartRatingData.smartRateSummary.mutualSummary.materialInfos.IsNotEmpty())
  1797. {
  1798. bool addData = false;
  1799. type="PeerAssessment";
  1800. foreach (var student in studentLessonDatas)
  1801. {
  1802. if (student.attend==1)
  1803. {
  1804. if (keys_PeerAssessment!.Contains(student.seatID!))
  1805. {
  1806. //T1,只有评论别人,没被别人评论 或者是评论了别人,但是没有被别人评论,
  1807. student.rateingRecord.itemRecords.Add(new ItemRecord { itemType=type, resultType=InteractReultType.T1, resultWeight = InteractWeight.T1 });
  1808. addData = true;
  1809. }
  1810. else
  1811. {
  1812. //T0 是没有评论别人,也没被别人评论,
  1813. student.rateingRecord.itemRecords.Add(new ItemRecord { itemType=type, resultType=InteractReultType.T0, resultWeight = InteractWeight.T0 });
  1814. addData = true;
  1815. }
  1816. }
  1817. }
  1818. var order = smartRatingData.smartRateSummary.mutualSummary.mutualResults.Where(x => x.result>0).OrderByDescending(x => x.result);
  1819. var maxItems = smartRatingData.smartRateSummary.mutualSummary.mutualResults.FindAll(x => x.result==order.First().result);
  1820. var max = smartRatingData.smartRateSummary.mutualSummary.mutualResults.FindAll(x => x.result==order.First().result).First().result;
  1821. var min = smartRatingData.smartRateSummary.mutualSummary.mutualResults.FindAll(x => x.result==order.Last().result).First().result;
  1822. var sum = smartRatingData.smartRateSummary.mutualSummary.mutualResults.Sum(x => x.result);
  1823. foreach (var mutualResult in smartRatingData.smartRateSummary.mutualSummary.mutualResults)
  1824. {
  1825. var student = studentLessonDatas.Find(x => x.seatID!.Equals(mutualResult.id));
  1826. if (student!=null)
  1827. {
  1828. if (index<student.rateingRecord.itemRecords.Count && student.rateingRecord.itemRecords[index].itemType!.Equals(type))
  1829. {
  1830. if (student.rateingRecord.itemRecords[index].resultType!.Equals(InteractReultType.T0))
  1831. {
  1832. //T1,只有评论别人,没被别人评论 或者是评论了别人,但是没有被别人评论,
  1833. student.rateingRecord.itemRecords[index].resultType= InteractReultType.T1;
  1834. student.rateingRecord.itemRecords[index].resultWeight= InteractWeight.T1;
  1835. }
  1836. else if (student.rateingRecord.itemRecords[index].resultType!.Equals(InteractReultType.T1))
  1837. {
  1838. //TP 有被别人评论,且评论了别人,
  1839. //最高分和最低分,票数最多和票数最少的占比来计算TP的占比
  1840. student.rateingRecord.itemRecords[index].resultType= InteractReultType.TP;
  1841. var data = MinMaxNormalization(min, max, mutualResult.result);
  1842. //student.rateingRecord.itemRecords[index].resultWeight= InteractWeight.TP;
  1843. student.rateingRecord.itemRecords[index].resultWeight= InteractWeight.T1+ data * 1.0 / 100 * (InteractWeight.TT-InteractWeight.T1);
  1844. student.rateingRecord.itemRecords[index].itemScore=mutualResult.result;
  1845. //TT是评论了别人,且被别人评论次数最高,或者分值最高。
  1846. if (maxItems.Select(x => x.id).Contains(student.seatID))
  1847. {
  1848. student.rateingRecord.itemRecords[index].resultType= InteractReultType.TT;
  1849. student.rateingRecord.itemRecords[index].resultWeight= InteractWeight.TT;
  1850. }
  1851. }
  1852. }
  1853. }
  1854. }
  1855. if (addData)
  1856. {
  1857. index++;
  1858. }
  1859. }
  1860. }
  1861. return studentLessonDatas;
  1862. }
  1863. /// <summary>
  1864. /// 最小-最大归一化(Min-Max Normalization)算法。这种算法通常用于将数据的特征值缩放到一个指定的范围内,通常是0到1之间,或者任何其他指定的范围。
  1865. /// </summary>
  1866. /// <returns></returns>
  1867. public static double MinMaxNormalization(double min, double max, double x, double minRank = 1, double maxRank = 100)
  1868. {
  1869. //排名指数计算=( 当前值分数- 298) / (9992 - 298) * (99 - 60) + 60
  1870. //将每个人的积分转化为60-100
  1871. //排名 = (积分 - 最低积分) / (最高积分 - 最低积分) * (最大排名 - 最小排名) + 最小排名
  1872. return x==0 ? 0 : max-min!=0 ? (x - min)*1.0 / (max - min) * (maxRank - minRank) + minRank : (x)*1.0 / (max) * (maxRank - minRank) + minRank;
  1873. }
  1874. /// <summary>
  1875. /// 处理学生课中数据
  1876. /// </summary>
  1877. /// <param name="studentLessonDatas"></param>
  1878. /// <param name="lessonDataAnalysis"></param>
  1879. /// <returns></returns>
  1880. public static List<StudentLessonItem> ProcessStudentDataV2(List<StudentLessonData> studentLessonDatas, LessonDataAnalysisCluster lessonDataAnalysis)
  1881. {
  1882. //历史记录的个人计分集合,通过“2倍标准差规则”移除异常值后得到的集合
  1883. var max_q = lessonDataAnalysis.pscore.Max();
  1884. //历史记录的互动计分集合,通过“2倍标准差规则”移除异常值后得到的集合
  1885. var max_t = lessonDataAnalysis.tscore.Max();
  1886. //历史记录的小组计分集合,通过“2倍标准差规则”移除异常值后得到的集合
  1887. var max_h = lessonDataAnalysis.gscore.Max();
  1888. var j = InteractWeight.T1;
  1889. double t = InteractWeight.TT;
  1890. List<StudentLessonItem> lessonItems = new List<StudentLessonItem>();
  1891. foreach (var studentLessonData in studentLessonDatas)
  1892. {
  1893. StudentLessonItem lessonItem = new StudentLessonItem() { studentId= studentLessonData.id! };
  1894. double u = 0.0;
  1895. if (studentLessonData.attend==1)
  1896. {
  1897. u=100.0;
  1898. }
  1899. //c个人计分指数,d互动计分指数,e小组计分指数
  1900. double d = 0, e = 0;
  1901. //本节课教师手动给学生的个人计分
  1902. var s = studentLessonData.pscore;
  1903. //个人计分指数
  1904. double c = GetPersent(lessonDataAnalysis.pscore, s).persent;// s*1.0/max_q;
  1905. {
  1906. //互动相关的计分
  1907. //课例互动次数
  1908. double n = studentLessonData.interactRecord.interactRecords.Count()*1.0;
  1909. if (n>0)
  1910. {
  1911. //是IES大陆正式站历史课例数据,自2024-03-01至2024-10-08日,互动指数或学法指数黄灯或绿灯,不包含醍摩豆学校及测试学校,课例时长超过5分钟的有效课例(10,680笔数据) 的IRS互动+抢权+挑人的次数集合,
  1912. //通过“2倍标准差规则” 移除异常值后得到的集合,再通过K-Means聚类算法得到高低位阶互动频次两个集合,并根据当前课例互动次数位阶的集合的质心值,该值定为m值
  1913. IEnumerable<double> all = lessonDataAnalysis.levelInteract.SelectMany(x => x.Value);
  1914. var currMacth = lessonDataAnalysis.levelInteract.FindAll(x => x.Value.Min()<=n && x.Value.Max()>=n);
  1915. KeyValuePair<double, List<double>> curr = new KeyValuePair<double, List<double>>();
  1916. if (currMacth!=null && currMacth.Count()>0)
  1917. {
  1918. curr = currMacth.MinBy(x => x.Key);
  1919. }
  1920. else
  1921. {
  1922. curr = lessonDataAnalysis.levelInteract.MaxBy(x => x.Key);
  1923. }
  1924. var p = LessonETLService.GetPersent(all, n);
  1925. var l = n<lessonDataAnalysis.interactPass ? lessonDataAnalysis.interactLow : n>lessonDataAnalysis.interactGood ? lessonDataAnalysis.interactHigh : lessonDataAnalysis.interactMedium;
  1926. //出题系数=当前互动次数与互动通过次数之间的比例*当前互动次数与互动中位数之间的比例*当前互动次数与互动高阶互动频次的比例
  1927. var m = (n*1.0/l) *(p.persent/100) * (curr.Value.Count*1.0/all.Count());
  1928. //学生作答次数
  1929. var w = studentLessonData.interactRecord.interactRecords.Where(x => x.resultWeight>=InteractWeight.T1).Count()*1.0;
  1930. //作答正确数(包括部分正确)
  1931. var r = studentLessonData.interactRecord.interactRecords.Where(x => x.resultWeight>InteractWeight.T1).Count()*1.0;
  1932. //有参与的权重集合60≤k(x)≤100
  1933. var kw = studentLessonData.interactRecord.interactRecords.Where(x => x.resultWeight>=InteractWeight.T1).Sum(x => x.resultWeight*1.0);
  1934. //有得分的权重集合60<e(x)≤100
  1935. var er = studentLessonData.interactRecord.interactRecords.Where(x => x.resultWeight>InteractWeight.T1).Sum(x => x.resultWeight*1.0);
  1936. //本节课的所有互动计分
  1937. var i = studentLessonData.interactRecord.interactRecords.Sum(x => x.itemScore*1.0);
  1938. //互动计分指数
  1939. d = GetPersent(lessonDataAnalysis.tscore, i).persent; //i*1.0/max_t;
  1940. //互动成效指数
  1941. var a = 1.0;
  1942. if (w==0)
  1943. {
  1944. a = kw/10/n;
  1945. }
  1946. else
  1947. {
  1948. if (r==0)
  1949. {
  1950. a = (kw/(10*w))*(w/n);
  1951. }
  1952. else
  1953. {
  1954. a = (kw/(10*w))*(w/n)+er/(r*10)*(r/w);
  1955. }
  1956. }
  1957. //c+a= 个人计分指数+ 个人互动成效指数
  1958. //互动成效
  1959. var f1 = Math.Round(190*1.0/(1+Math.Exp(-(a*m)))-95, 4);
  1960. if (f1==0)
  1961. {
  1962. if (d>0 && c==0)
  1963. {
  1964. f1=d*0.6;
  1965. }
  1966. else if (d==0 && c>0)
  1967. {
  1968. f1=c*0.6;
  1969. }
  1970. else
  1971. {
  1972. f1=(d*0.6+c*0.6)/2;
  1973. }
  1974. }
  1975. else
  1976. {
  1977. //如果有互动计分,则互动成效指数取0.8 0.2
  1978. var dy = (95-f1)/95/2;
  1979. if (dy>0.2)
  1980. {
  1981. dy=0.2;
  1982. }
  1983. if (dy<0.1) {
  1984. dy=0.1;
  1985. }
  1986. f1=f1*(dy>0.1? 1-dy : 1-dy*2)+d*dy+c*dy;
  1987. }
  1988. if (f1>95)
  1989. {
  1990. f1=95;
  1991. }
  1992. //var f1 = Math.Round(a*m);
  1993. lessonItem.hd_cx=f1;
  1994. //互动专注指数
  1995. // var b = ((w*w/n)+(r*r/w))*1.0*m;
  1996. // var f2 = Math.Round(200*1.0/(1+Math.Exp(-(b)))-100, 4);
  1997. double f2 = 0;
  1998. //if (w>0)
  1999. //{
  2000. // double xs = m/n>0.1 ? m/n/10 : m/n;
  2001. // if (xs>0.05)
  2002. // {
  2003. // xs=xs/3;
  2004. // }
  2005. // lessonItem.hd_xs=Math.Round(xs, 4);
  2006. // var b = xs* ((w/n)*0.8+ 0.2 * (w/n)* (r/w));
  2007. // f2 = Math.Round(200*1.0/(1+Math.Exp(-(b)))-100, 4);
  2008. // if (f2>1)
  2009. // {
  2010. // f2=100;
  2011. // }
  2012. // else
  2013. // {
  2014. // f2=f2*100;
  2015. // }
  2016. //}
  2017. if (w>0) {
  2018. //作答正确的也算在参与度中,只是占比比作答率占比更小,占20%,即 0.2 * (w/n)* (r/w)*100,计算结果可能会大于100,则强制限定
  2019. f2=(w/n)*100+ 0.2 * (w/n)* (r/w)*100;
  2020. if (f2>100) { f2=100; }
  2021. }
  2022. lessonItem.hd_cy=f2;
  2023. lessonItem.hd_cyc=w;
  2024. lessonItem.hd_fqc=n;
  2025. lessonItem.hd_zqc=r;
  2026. lessonItem.gr_jf=s;
  2027. }
  2028. //studentLessonData.achieve=f1;
  2029. //studentLessonData.attitude=f2;
  2030. // _logger.LogInformation($"{studentLessonData.id}=>学习成效:{f1}\t学习态度:{f2}\t互动次数:{n}\t参与次数:{w}\t正确次数:{r}\t个人计分:{s}\t{Math.Round(c, 2)}\t互动计分:{i}\t{Math.Round(d, 2)}");
  2031. }
  2032. {
  2033. //评测相关指数
  2034. double n = studentLessonData.examRecords.Count()*1.0;
  2035. if (n>0)
  2036. {
  2037. //题目数量
  2038. double nq = studentLessonData.examRecords.Sum(x => x.qcount)*1.0;
  2039. // double max_e = lessonDataAnalysis.exam.Max();
  2040. //得分率
  2041. double sum_s = studentLessonData.examRecords.Sum(x => x.scoreRate);
  2042. //作答率
  2043. double sum_a = studentLessonData.examRecords.Sum(x => x.answerRate);
  2044. double f8 = Math.Round(sum_s/n*100, 4);
  2045. double f9 = Math.Round(sum_a/n*100, 4);
  2046. lessonItem.pc_df=f8;
  2047. lessonItem.pc_zd=f9;
  2048. }
  2049. // _logger.LogInformation($"{studentLessonData.id}=>评测指数:{f8}\t得分率:{Math.Round(sum_s/n,4)}\t专注指数:{f9}\t作答率:{Math.Round(sum_a/n,4)}");
  2050. }
  2051. {
  2052. //小组相关指数
  2053. /* PickupNameLst PickupOption PickupNthGrp PickupGrp PickupRange PickupEachGrp PickupDiff PickupWrong PickupNoDiff PickupRight PickupGener PickupWtoW PickupWtoR PickupLSA_WordFreq PickupLSA_Classify Pickup0_49*/
  2054. var grpPicks = studentLessonData.pickups.Where(x => x.StartsWith("1--") && x.Contains("Grp", StringComparison.OrdinalIgnoreCase));
  2055. var groups= studentLessonDatas.Where(x => !string.IsNullOrWhiteSpace(x.groupId)).Select(x => x.groupId).Distinct();
  2056. int groupCount = 1;
  2057. int memberCount = studentLessonDatas.Count;
  2058. if (groups!=null &&groups.Count()>0)
  2059. {
  2060. groupCount=groups.Count();
  2061. var members = studentLessonDatas.Where(x => !string.IsNullOrWhiteSpace(x.groupId) && !string.IsNullOrWhiteSpace(studentLessonData.groupId)&&x.groupId.Equals(studentLessonData.groupId));
  2062. if (members!=null && members.Count()>0)
  2063. {
  2064. memberCount= members.Count();
  2065. }
  2066. }
  2067. var grpPickCount = grpPicks.Count();
  2068. double pickRate = 0;
  2069. double groupType = 0;
  2070. foreach (var grppick in grpPicks)
  2071. {
  2072. pickRate+= (1.0/groupCount) * (1.0/memberCount)* 100 ;
  2073. }
  2074. if (grpPickCount>0)
  2075. {
  2076. pickRate=100- Math.Round(pickRate/grpPickCount,4);
  2077. groupType+=1;
  2078. lessonItem.xz_tr=grpPickCount;
  2079. }
  2080. double coworkRate = 0;
  2081. if (studentLessonData.group_coworkScore.IsNotEmpty())
  2082. {
  2083. double coworkGrp = studentLessonData.group_coworkScore.Average();
  2084. var coworkData = GetPersent(lessonDataAnalysis.groupCowork, coworkGrp);
  2085. coworkRate= coworkData.persent;
  2086. groupType+=1;
  2087. lessonItem.xz_xz=studentLessonData.group_coworkScore.Sum();
  2088. }
  2089. double gscoreRate = 0;
  2090. if (studentLessonData.gscore>0)
  2091. {
  2092. var gscoreData = GetPersent(lessonDataAnalysis.gscore, studentLessonData.gscore);
  2093. gscoreRate= gscoreData.persent;
  2094. groupType+=1;
  2095. lessonItem.xz_jf=studentLessonData.gscore;
  2096. }
  2097. double groupTask = 0;
  2098. var groupTasks= studentLessonData.taskRecord.itemRecords.Where(x => x.isGroup);
  2099. if(groupTasks!=null && groupTasks.Count()>0)
  2100. {
  2101. double score = CalculateScore(groupTasks.Sum(x=>x.optCount));
  2102. groupType+=1;
  2103. lessonItem.xz_sc=groupTasks.Count();
  2104. }
  2105. double fxGrp = 0;
  2106. if (groupType>0) {
  2107. fxGrp = (pickRate+coworkRate+gscoreRate+groupTask)/groupType; }
  2108. if (groupType==2 &&(pickRate>0 && gscoreRate>0) )
  2109. {
  2110. fxGrp = (pickRate*0.8+coworkRate+gscoreRate*0.8+groupTask)/groupType;
  2111. }
  2112. if (groupType==1)
  2113. {
  2114. fxGrp=(pickRate+coworkRate+gscoreRate+groupTask)*0.8/groupType;
  2115. }
  2116. lessonItem.hz_nl=Math.Round(fxGrp,4);
  2117. }
  2118. {
  2119. //任务相关指数
  2120. double n = studentLessonData.taskRecord.itemRecords.Count()*1.0;
  2121. if (n>0)
  2122. {
  2123. double max_m = lessonDataAnalysis.task.Max();
  2124. double w = studentLessonData.taskRecord.itemRecords.Where(x => x.resultWeight>0).Count()*1.0;
  2125. double y = (10 *w/n+(j/t) *w)/max_m;
  2126. double l = max_m*(w*w/n+(j/t) * w)/n;
  2127. double f4 = Math.Round(190*1.0/(1+Math.Exp(-(y)))-95, 4);
  2128. double f5 = Math.Round(200*1.0/(1+Math.Exp(-(l)))-100, 4);
  2129. lessonItem.rw_fqc =n;
  2130. lessonItem.rw_cyc =w;
  2131. lessonItem.rw_zpc =studentLessonData.taskRecord.itemRecords.Sum(x=>x.optCount);
  2132. lessonItem.rw_cx =f4;
  2133. lessonItem.rw_cy =f5;
  2134. double score = 0;
  2135. if (w>0)
  2136. {
  2137. foreach (var item in studentLessonData.taskRecord.itemRecords)
  2138. {
  2139. score += CalculateScore(item.optCount);
  2140. }
  2141. }
  2142. lessonItem.rw_cx =score*1.0/n;
  2143. }
  2144. // _logger.LogInformation($"{studentLessonData.id}=>任务指数:{f4}\t专注指数:{f5}\t任务次数:{n}\t参与次数:{w}\t");
  2145. }
  2146. {
  2147. //评价相关指数
  2148. double n = studentLessonData.rateingRecord.itemRecords.Count()*1.0;
  2149. if (n>0)
  2150. {
  2151. var v = studentLessonData.rateingRecord.itemRecords.Where(x => x.itemType.Equals("Voting"));
  2152. double vc = v.Count()*1.0;
  2153. var g = studentLessonData.rateingRecord.itemRecords.Where(x => x.itemType.Equals("GrandRating"));
  2154. double gc = g.Count()*1.0;
  2155. var p = studentLessonData.rateingRecord.itemRecords.Where(x => x.itemType.Equals("PeerAssessment"));
  2156. double pc = p.Count()*1.0;
  2157. var vg = v.Sum(x => x.itemScore);
  2158. var vo = v.Sum(x => x.optCount);
  2159. double vs = vc/n* (vg+ vo);
  2160. var gg = g.Sum(x => x.itemScore);
  2161. var go = g.Sum(x => x.optCount);
  2162. double gs = gc/n* (gg+ go);
  2163. var pg = p.Sum(x => x.itemScore);
  2164. var po = p.Sum(x => x.optCount);
  2165. double ps = pc/n* (pg+ po);
  2166. double h = vs+ps+gs;
  2167. double f3 = Math.Round(190*1.0/(1+Math.Exp(-(h)))-95, 4);
  2168. studentLessonData.appraise=f3;
  2169. // _logger.LogInformation($"{studentLessonData.id}=>评价能力:{f3}\t评价次数:{n}\t投票次数:{vc}-{vg}-{vo}\t星光次数:{gc}-{gg}-{go}\t互评次数:{pc}-{pg}-{po}");
  2170. lessonItem.pj_nl =f3;
  2171. lessonItem.pj_cs =n;
  2172. lessonItem.pj_vc =vc;
  2173. lessonItem.pj_vg =vg;
  2174. lessonItem.pj_vo =vo;
  2175. lessonItem.pj_gc =gc;
  2176. lessonItem.pj_gg =gg;
  2177. lessonItem.pj_go =go;
  2178. lessonItem.pj_pc =pc;
  2179. lessonItem.pj_pg =pg;
  2180. lessonItem.pj_po =po;
  2181. }
  2182. }
  2183. {
  2184. //协作相关指数
  2185. var n = studentLessonData.coworkRecord.itemRecords.Count()*1.0;
  2186. if (n>0)
  2187. {
  2188. //总的协作成果数
  2189. var w = studentLessonData.coworkRecord.itemRecords.Where(x => x.resultWeight>0);
  2190. double ss = w.Sum(x => x.itemScore)*1.0;
  2191. double sw = w.Sum(x => x.resultWeight)*1.0;
  2192. double wc = w.Count()*1.0;
  2193. double x = 0.0;
  2194. if (wc>0)
  2195. {
  2196. x=sw/(j *wc);
  2197. }
  2198. double max_xzcg = 40;
  2199. double k = (wc*wc/n+x)/n+ wc*(ss/max_xzcg)* (wc/n);
  2200. double f6 = Math.Round(190*1.0/(1+Math.Exp(-(k)))-95, 4);
  2201. double f7 = Math.Round(200*1.0/(1+Math.Exp(-(k)))-100, 4);
  2202. lessonItem.xz_fqc =n;
  2203. lessonItem.xz_cyc =wc;
  2204. lessonItem.xz_cgf =ss;
  2205. lessonItem.xz_cx =f6;
  2206. lessonItem.xz_cy =f7;
  2207. }
  2208. //_logger.LogInformation($"{studentLessonData.id}=>协作指数:{f6}\t专注指数:{f7}\t协作次数:{n}\t参与次数:{wc}\t协作成果分数:{ss}\t{k}");
  2209. }
  2210. double xx_cx = 0, xx_cy = 0;
  2211. int avg_cx = 0, avg_cy = 0;
  2212. if (lessonItem.xz_cx>0)
  2213. {
  2214. avg_cx+=1;
  2215. }
  2216. if (lessonItem.pj_nl>0)
  2217. {
  2218. avg_cx+=1;
  2219. }
  2220. if (lessonItem.rw_cx>0)
  2221. {
  2222. avg_cx+=1;
  2223. }
  2224. if (lessonItem.pc_df>0)
  2225. {
  2226. avg_cx+=1;
  2227. }
  2228. if (lessonItem.hd_cx>0)
  2229. {
  2230. avg_cx+=1;
  2231. }
  2232. if (lessonItem.hz_nl>0)
  2233. {
  2234. avg_cx+=1;
  2235. }
  2236. if (avg_cx>0)
  2237. {
  2238. xx_cx+=Math.Round(lessonItem.hd_cx * 1.0/avg_cx+ lessonItem.pc_df* 1.0/avg_cx+ lessonItem.rw_cx* 1.0/avg_cx+ lessonItem.pj_nl* 1.0/avg_cx+ lessonItem.xz_cx* 1.0/avg_cx+ lessonItem.hz_nl* 1.0/avg_cx,4);
  2239. }
  2240. if (lessonItem.xz_cy>0)
  2241. {
  2242. avg_cy+=1;
  2243. }
  2244. if (lessonItem.pj_nl>0)
  2245. {
  2246. avg_cy+=1;
  2247. }
  2248. if (lessonItem.rw_cy>0)
  2249. {
  2250. avg_cy+=1;
  2251. }
  2252. if (lessonItem.pc_zd>0)
  2253. {
  2254. avg_cy+=1;
  2255. }
  2256. if (lessonItem.hd_cy>0)
  2257. {
  2258. avg_cy+=1;
  2259. }
  2260. if (lessonItem.hz_nl>0)
  2261. {
  2262. avg_cy+=1;
  2263. }
  2264. if (avg_cy>0)
  2265. {
  2266. xx_cy+=Math.Round(lessonItem.hd_cy * 1.0/avg_cy+ lessonItem.pc_zd* 1.0/avg_cy+ lessonItem.rw_cy* 1.0/avg_cy+ lessonItem.pj_nl* 1.0/avg_cy+ lessonItem.xz_cy* 1.0/avg_cy+ lessonItem.hz_nl* 1.0/avg_cy,4);
  2267. }
  2268. lessonItem.xx_cx=xx_cx;
  2269. lessonItem.xx_cy=xx_cy;
  2270. lessonItems.Add(lessonItem);
  2271. studentLessonData.achieve= lessonItem.xx_cx;
  2272. studentLessonData.attitude= lessonItem.xx_cy;
  2273. studentLessonData.appraise= lessonItem.pj_nl;
  2274. studentLessonData.cowork= lessonItem.xz_cx;
  2275. studentLessonData.cooperation=lessonItem.hz_nl;
  2276. }
  2277. return lessonItems;
  2278. }
  2279. static double CalculateScore(int n, double k = 1)
  2280. {
  2281. if (n == 0)
  2282. {
  2283. return 0;
  2284. }
  2285. else
  2286. {
  2287. double score = 60 + (40 / (1 + Math.Exp(-k * (n - 1))));
  2288. return Math.Max(80, Math.Min(score, 100));
  2289. }
  2290. }
  2291. /// <summary>
  2292. /// 使用标准差定义异常值。如果一个数字与平均值的偏差超过某个标准差倍数(例如2倍或3倍),则可以认为它是异常的。
  2293. /// </summary>
  2294. /// <param name="array"></param>
  2295. /// <returns></returns>
  2296. public static List<double> CleanDataBySDThreshold(IEnumerable<double> array, double thresholdMultiplier = 2)
  2297. {
  2298. if (array.Count() == 0) return new List<double>();
  2299. double average = Math.Round(array.Sum()*1.0/array.Count(), 4);
  2300. double variance = array.Select(x => Math.Round(Math.Pow(x - average, 2), 4)).Sum()*1.0/array.Count();
  2301. double standardDeviation = Math.Sqrt(Math.Round(variance, 4));
  2302. double threshold = Math.Round(thresholdMultiplier * standardDeviation);
  2303. List<double> datas = new List<double>();
  2304. foreach (double value in array)
  2305. {
  2306. double deviation = Math.Round(Math.Abs(value - average), 4);
  2307. if (deviation <= threshold)
  2308. {
  2309. datas.Add(value);
  2310. }
  2311. }
  2312. return datas;
  2313. }
  2314. /// <summary>
  2315. ///
  2316. /// </summary>
  2317. /// <param name="items"></param>
  2318. /// <param name="filePath"></param>
  2319. /// <returns></returns>
  2320. public static async Task ExportToExcelAzureBlob(List<StudentLessonItem> items, AzureStorageFactory azureStorage,string owner , string path , XmlDocument xmlDocument)
  2321. {
  2322. ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
  2323. using (var memoryStream = new MemoryStream())
  2324. {
  2325. using (ExcelPackage package = new ExcelPackage())
  2326. {
  2327. ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("学生课中数据");
  2328. // 获取类的属性
  2329. PropertyInfo[] properties = typeof(StudentLessonItem).GetProperties();
  2330. // 添加表头
  2331. int currentRow = 1;
  2332. for (int i = 0; i < properties.Length; i++)
  2333. {
  2334. string summary = Regex.Replace(GetPropertySummary(properties[i], xmlDocument), @"\s+", "");
  2335. worksheet.Cells[currentRow, i + 1].Value = summary;
  2336. }
  2337. // 填充数据
  2338. currentRow = 2;
  2339. foreach (var item in items)
  2340. {
  2341. for (int i = 0; i < properties.Length; i++)
  2342. {
  2343. worksheet.Cells[currentRow, i + 1].Value = properties[i].GetValue(item);
  2344. }
  2345. currentRow++;
  2346. }
  2347. // 设置表格样式
  2348. worksheet.Cells[worksheet.Dimension.Address].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
  2349. worksheet.Cells[worksheet.Dimension.Address].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Top;
  2350. // 保存到文件流
  2351. await package.SaveAsAsync(memoryStream);
  2352. memoryStream.Position=0;
  2353. }
  2354. await azureStorage.GetBlobContainerClient(owner).UploadFileByContainer(memoryStream, "records", path);
  2355. }
  2356. }
  2357. /// <summary>
  2358. /// 导出Excel
  2359. /// </summary>
  2360. /// <param name="items"></param>
  2361. /// <param name="filePath"></param>
  2362. /// <returns></returns>
  2363. public static async Task ExportToExcelLocal(List<StudentLessonItem> items, string filePath, XmlDocument xmlDocument)
  2364. {
  2365. ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
  2366. using (ExcelPackage package = new ExcelPackage())
  2367. {
  2368. ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("学生课中数据");
  2369. // 获取类的属性
  2370. PropertyInfo[] properties = typeof(StudentLessonItem).GetProperties();
  2371. // 添加表头
  2372. int currentRow = 1;
  2373. for (int i = 0; i < properties.Length; i++)
  2374. {
  2375. string summary = Regex.Replace(GetPropertySummary(properties[i], xmlDocument), @"\s+", "");
  2376. worksheet.Cells[currentRow, i + 1].Value = summary;
  2377. }
  2378. // 填充数据
  2379. currentRow = 2;
  2380. foreach (var item in items)
  2381. {
  2382. for (int i = 0; i < properties.Length; i++)
  2383. {
  2384. worksheet.Cells[currentRow, i + 1].Value = properties[i].GetValue(item);
  2385. }
  2386. currentRow++;
  2387. }
  2388. // 设置表格样式
  2389. worksheet.Cells[worksheet.Dimension.Address].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
  2390. worksheet.Cells[worksheet.Dimension.Address].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Top;
  2391. // 保存到文件
  2392. FileInfo fileInfo = new System.IO.FileInfo(filePath);
  2393. await package.SaveAsAsync(fileInfo);
  2394. }
  2395. }
  2396. private static string GetPropertySummary(PropertyInfo property, XmlDocument xmlDocument)
  2397. {
  2398. XmlNodeList? xmlNodeList = xmlDocument.DocumentElement?.SelectNodes("//member[@name='P:" + property.DeclaringType?.FullName + "." + property.Name + "']");
  2399. if (xmlNodeList!= null && xmlNodeList.Count > 0)
  2400. {
  2401. XmlNode? xmlNode = xmlNodeList[0];
  2402. if (xmlNode != null && xmlNode.FirstChild != null)
  2403. {
  2404. return xmlNode.FirstChild.InnerText;
  2405. }
  2406. }
  2407. return property.Name;
  2408. }
  2409. /// <summary>
  2410. /// 当前数超越集合的百分比
  2411. /// </summary>
  2412. /// <param name="nums"></param>
  2413. /// <param name="curr"></param>
  2414. /// <returns></returns>
  2415. public static (double persent, int count) GetPersent(IEnumerable<double> nums, double curr)
  2416. {
  2417. int count = 0;
  2418. foreach (var op in nums.OrderBy(x => x))
  2419. {
  2420. if (op <= curr)
  2421. {
  2422. count++;
  2423. }
  2424. else
  2425. {
  2426. break;
  2427. }
  2428. }
  2429. return (count *1.0/ nums.Count() * 100, count);
  2430. }
  2431. }
  2432. /// <summary>
  2433. /// 学生导出Excel的Entity
  2434. /// </summary>
  2435. public class StudentLessonItem
  2436. {
  2437. /// <summary>
  2438. /// 学生id
  2439. /// </summary>
  2440. public string? studentId { get; set; }
  2441. /// <summary>
  2442. /// 互动发起次数
  2443. /// </summary>
  2444. public double hd_fqc { get; set; } = 0;
  2445. /// <summary>
  2446. /// 互动参与次数
  2447. /// </summary>
  2448. public double hd_cyc { get; set; } = 0;
  2449. /// <summary>
  2450. /// 互动正确次数
  2451. /// </summary>
  2452. public double hd_zqc { get; set; } = 0;
  2453. /// <summary>
  2454. /// 个人计分
  2455. /// </summary>
  2456. public double gr_jf { get; set; } = 0;
  2457. /// <summary>
  2458. /// 互动成效指数
  2459. /// </summary>
  2460. public double hd_cx { get; set; } = 0;
  2461. /// <summary>
  2462. /// 互动专注指数
  2463. /// </summary>
  2464. public double hd_cy { get; set; } = 0;
  2465. /// <summary>
  2466. /// 评测得分率
  2467. /// </summary>
  2468. public double pc_df { get; set; } = 0;
  2469. /// <summary>
  2470. /// 评测作答率
  2471. /// </summary>
  2472. public double pc_zd { get; set; } = 0;
  2473. /// <summary>
  2474. /// 任务发起次数
  2475. /// </summary>
  2476. public double rw_fqc { get; set; } = 0;
  2477. /// <summary>
  2478. /// 任务参与次数
  2479. /// </summary>
  2480. public double rw_cyc { get; set; } = 0;
  2481. /// <summary>
  2482. /// 任务作品数
  2483. /// </summary>
  2484. public double rw_zpc { get; set; } = 0;
  2485. /// <summary>
  2486. /// 任务成效指数
  2487. /// </summary>
  2488. public double rw_cx { get; set; } = 0;
  2489. /// <summary>
  2490. /// 任务专注指数
  2491. /// </summary>
  2492. public double rw_cy { get; set; } = 0;
  2493. /// <summary>
  2494. /// 评价发起次数
  2495. /// </summary>
  2496. public double pj_cs { get; set; } = 0;
  2497. /// <summary>
  2498. /// 投票发起次数
  2499. /// </summary>
  2500. public double pj_vc { get; set; } = 0;
  2501. /// <summary>
  2502. /// 投票得票数
  2503. /// </summary>
  2504. public double pj_vg { get; set; } = 0;
  2505. /// <summary>
  2506. /// 投票次数
  2507. /// </summary>
  2508. public double pj_vo { get; set; } = 0;
  2509. /// <summary>
  2510. /// 星光发起次数
  2511. /// </summary>
  2512. public double pj_gc { get; set; } = 0;
  2513. /// <summary>
  2514. /// 星光得分数
  2515. /// </summary>
  2516. public double pj_gg { get; set; } = 0;
  2517. /// <summary>
  2518. /// 星光评分次数
  2519. /// </summary>
  2520. public double pj_go { get; set; } = 0;
  2521. /// <summary>
  2522. /// 互评发起次数
  2523. /// </summary>
  2524. public double pj_pc { get; set; } = 0;
  2525. /// <summary>
  2526. /// 互评得分数
  2527. /// </summary>
  2528. public double pj_pg { get; set; } = 0;
  2529. /// <summary>
  2530. /// 互评评分次数
  2531. /// </summary>
  2532. public double pj_po { get; set; } = 0;
  2533. /// <summary>
  2534. /// 评价能力
  2535. /// </summary>
  2536. public double pj_nl { get; set; } = 0;
  2537. /// <summary>
  2538. /// 协作发起次数
  2539. /// </summary>
  2540. public double xz_fqc { get; set; } = 0;
  2541. /// <summary>
  2542. /// 协作参与次数
  2543. /// </summary>
  2544. public double xz_cyc { get; set; } = 0;
  2545. /// <summary>
  2546. /// 协作成果分数
  2547. /// </summary>
  2548. public double xz_cgf { get; set; } = 0;
  2549. /// <summary>
  2550. /// 协作能力指数
  2551. /// </summary>
  2552. public double xz_cx { get; set; } = 0;
  2553. /// <summary>
  2554. /// 协作专注指数
  2555. /// </summary>
  2556. public double xz_cy { get; set; } = 0;
  2557. /// <summary>
  2558. /// 小组挑人
  2559. /// </summary>
  2560. public double xz_tr { get; set; } = 0;
  2561. /// <summary>
  2562. /// 小组计分
  2563. /// </summary>
  2564. public double xz_jf { get; set; } = 0;
  2565. /// <summary>
  2566. /// 小组协作成果分
  2567. /// </summary>
  2568. public double xz_xz { get; set; } = 0;
  2569. /// <summary>
  2570. /// 组任务上传数
  2571. /// </summary>
  2572. public double xz_sc { get; set; } = 0;
  2573. /// <summary>
  2574. /// 合作能力
  2575. /// </summary>
  2576. public double hz_nl { get; set; } = 0;
  2577. /// <summary>
  2578. /// 学习成效
  2579. /// </summary>
  2580. public double xx_cx { get; set; } = 0;
  2581. /// <summary>
  2582. /// 学习专注度
  2583. /// </summary>
  2584. public double xx_cy { get; set; } = 0;
  2585. }
  2586. /// <summary>
  2587. /// 历史课例的关键数据模型
  2588. /// </summary>
  2589. public class LessonDataAnalysisCluster : LessonDataAnalysisBase
  2590. {
  2591. /// <summary>
  2592. ///
  2593. /// </summary>
  2594. // public List<KeyValuePair<double, List<double>>> clustersInteract { get; set; } = new List<KeyValuePair<double, List<double>>>();
  2595. ///// <summary>
  2596. /////
  2597. ///// </summary>
  2598. //public List<KeyValuePair<double, List<double>>> clustersPscore { get; set; } = new List<KeyValuePair<double, List<double>>>();
  2599. ///// <summary>
  2600. /////
  2601. ///// </summary>
  2602. //public List<KeyValuePair<double, List<double>>> clustersTscore { get; set; } = new List<KeyValuePair<double, List<double>>>();
  2603. ///// <summary>
  2604. /////
  2605. ///// </summary>
  2606. //public List<KeyValuePair<double, List<double>>> clustersGscore { get; set; } = new List<KeyValuePair<double, List<double>>>();
  2607. public List<KeyValuePair<double, List<double>>> levelInteract { get; set; } = new List<KeyValuePair<double, List<double>>>();
  2608. public double interactPass { get; set; }
  2609. public double interactGood { get; set; }
  2610. public double interactLow { get; set; }
  2611. public double interactMedium { get; set; }
  2612. public double interactHigh { get; set; }
  2613. }
  2614. /// <summary>
  2615. ///
  2616. /// </summary>
  2617. public abstract class LessonDataAnalysisBase
  2618. {
  2619. ///// <summary>
  2620. ///// 协作次数
  2621. ///// </summary>
  2622. //public IEnumerable<double> cowork { get; set; } = new List<double>();
  2623. ///// <summary>
  2624. /////
  2625. ///// </summary>
  2626. //public IEnumerable<double> coworkBase { get; set; } = new List<double>();
  2627. /// <summary>
  2628. ///
  2629. /// </summary>
  2630. public List<double> task { get; set; } = new List<double>();
  2631. ///// <summary>
  2632. /////
  2633. ///// </summary>
  2634. //public IEnumerable<double> taskBase { get; set; } = new List<double>();
  2635. ///// <summary>
  2636. /////
  2637. ///// </summary>
  2638. //public IEnumerable<double> exam { get; set; } = new List<double>();
  2639. ///// <summary>
  2640. /////
  2641. ///// </summary>
  2642. //public IEnumerable<double> examBase { get; set; } = new List<double>();
  2643. ///// <summary>
  2644. /////
  2645. ///// </summary>
  2646. //public IEnumerable<double> smartRating { get; set; } = new List<double>();
  2647. ///// <summary>
  2648. /////
  2649. ///// </summary>
  2650. //public IEnumerable<double> smartRatingBase { get; set; } = new List<double>();
  2651. /// <summary>
  2652. ///
  2653. /// </summary>
  2654. public List<double> irs { get; set; } = new List<double>();
  2655. /// <summary>
  2656. ///
  2657. /// </summary>
  2658. public List<double> interactNormal { get; set; } = new List<double>();
  2659. /// <summary>
  2660. /// 个人计分
  2661. /// </summary>
  2662. public List<double> pscore { get; set; } = new List<double>();
  2663. /// <summary>
  2664. /// 小组计分
  2665. /// </summary>
  2666. public List<double> gscore { get; set; } = new List<double>();
  2667. /// <summary>
  2668. /// 互动计分
  2669. /// </summary>
  2670. public List<double> tscore { get; set; } = new List<double>();
  2671. /// <summary>
  2672. /// 作品上传数
  2673. /// </summary>
  2674. public List<List<double>> upload { get; set; } = new List<List<double>>();
  2675. /// <summary>
  2676. /// 学生协作成果数
  2677. /// </summary>
  2678. public List<double> stuCowork { get; set; } = new List<double>();
  2679. /// <summary>
  2680. /// 小组协作成果数
  2681. /// </summary>
  2682. public List<double> groupCowork { get; set; } = new List<double>();
  2683. /// <summary>
  2684. /// 挑人集合
  2685. /// </summary>
  2686. public List<List<string>> pickup { get; set; } = new List<List<string>>();
  2687. ///// <summary>
  2688. ///// 挑人集合-小组
  2689. ///// </summary>
  2690. //public List<List<string>> pickup_group { get; set; } = new List<List<string>>();
  2691. }
  2692. /// <summary>
  2693. /// 每月的课例模型数据
  2694. /// </summary>
  2695. public class LessonDataAnalysisMonth : LessonDataAnalysisBase
  2696. {
  2697. /// <summary>
  2698. /// 时间戳
  2699. /// </summary>
  2700. public long updateTime { get; set; }
  2701. /// <summary>
  2702. /// yyyyMM
  2703. /// </summary>
  2704. public string? yearMonth { get; set; }
  2705. }
  2706. public class LessonWeek
  2707. {
  2708. /// <summary>
  2709. /// 第几周
  2710. /// </summary>
  2711. public int week { get; set; }
  2712. /// <summary>
  2713. /// 课例id
  2714. /// </summary>
  2715. public string? id { get; set;}
  2716. /// <summary>
  2717. /// 课程id
  2718. /// </summary>
  2719. public string? cid { get; set; }
  2720. /// <summary>
  2721. /// 科目id
  2722. /// </summary>
  2723. public string? sid { get; set;}
  2724. /// <summary>
  2725. /// 学校
  2726. /// </summary>
  2727. public string?school { get; set; }
  2728. /// <summary>
  2729. /// 名单id
  2730. /// </summary>
  2731. public string? gid { get; set; }
  2732. /// <summary>
  2733. /// 学段id
  2734. /// </summary>
  2735. //public string? pid { get; set; }
  2736. public string? scope { get; set; }
  2737. }
  2738. /// <summary>
  2739. ///
  2740. /// </summary>
  2741. public class LessonLocal
  2742. {
  2743. /// <summary>
  2744. ///
  2745. /// </summary>
  2746. public LessonBase? lessonBase { get; set; }
  2747. /// <summary>
  2748. ///
  2749. /// </summary>
  2750. public TimeLineData? timeLineData { get; set; }
  2751. /// <summary>
  2752. ///
  2753. /// </summary>
  2754. public LessonRecord? lessonRecord { get; set; }
  2755. /// <summary>
  2756. ///
  2757. /// </summary>
  2758. public List<LocalStudent> studentLessonDatas { get; set; } = new List<LocalStudent>();
  2759. /// <summary>
  2760. ///
  2761. /// </summary>
  2762. public List<TaskData> taskDatas { get; set; } = new List<TaskData>();
  2763. /// <summary>
  2764. ///
  2765. /// </summary>
  2766. public List<SmartRatingData> smartRatingDatas { get; set; } = new List<SmartRatingData>();
  2767. /// <summary>
  2768. ///
  2769. /// </summary>
  2770. public List<IRSData> irsDatas { get; set; } = new List<IRSData>();
  2771. /// <summary>
  2772. ///
  2773. /// </summary>
  2774. public List<CoworkData> coworkDatas { get; set; } = new List<CoworkData>();
  2775. /// <summary>
  2776. ///
  2777. /// </summary>
  2778. public List<ExamData> examDatas { get; set; } = new List<ExamData>();
  2779. /// <summary>
  2780. ///
  2781. /// </summary>
  2782. public List<TimeLineEvent> sokratesDatas { get; set; } = new List<TimeLineEvent>();
  2783. }
  2784. /// <summary>
  2785. ///
  2786. /// </summary>
  2787. public class TechCount
  2788. {
  2789. public string? yearMonth { get; set; }
  2790. /// <summary>
  2791. ///
  2792. /// </summary>
  2793. public string? lessonId { get; set; }
  2794. /// <summary>
  2795. /// 评测数量
  2796. /// </summary>
  2797. public int examCount { get; set; }
  2798. /// <summary>
  2799. /// 任务数量
  2800. /// </summary>
  2801. public int taskCount { get; set; }
  2802. /// <summary>
  2803. /// IRS次数
  2804. /// </summary>
  2805. public int irsCount { get; set; }
  2806. /// <summary>
  2807. /// 互动次数
  2808. /// </summary>
  2809. //public int interactExamCount { get; set; }
  2810. /// <summary>
  2811. /// 互动次数
  2812. /// </summary>
  2813. public int interactNormalCount { get; set; }
  2814. /// <summary>
  2815. /// 协作次数
  2816. /// </summary>
  2817. public int coworkCount { get; set; }
  2818. /// <summary>
  2819. /// 智能评分次数
  2820. /// </summary>
  2821. public int smartRatingCount { get; set; }
  2822. /// <summary>
  2823. ///
  2824. /// </summary>
  2825. public List<CodeLong> timeCount { get; set; } = new List<CodeLong>();
  2826. /// <summary>
  2827. ///
  2828. /// </summary>
  2829. public IEnumerable<double> pscore { get; set; } = new List<double>();
  2830. /// <summary>
  2831. ///
  2832. /// </summary>
  2833. public IEnumerable<double> gscore { get; set; } = new List<double>();
  2834. /// <summary>
  2835. ///
  2836. /// </summary>
  2837. public IEnumerable<double> tscore { get; set; } = new List<double>();
  2838. /// <summary>
  2839. /// 评测数量
  2840. /// </summary>
  2841. public int examCountBase { get; set; }
  2842. /// <summary>
  2843. /// 任务数量
  2844. /// </summary>
  2845. public int taskCountBase { get; set; }
  2846. /// <summary>
  2847. /// IRS次数
  2848. /// </summary>
  2849. public int irsCountBase { get; set; }
  2850. /// <summary>
  2851. /// 互动次数
  2852. /// </summary>
  2853. //public int interactExamCountBase { get; set; }
  2854. /// <summary>
  2855. /// 互动次数
  2856. /// </summary>
  2857. public int interactNormalCountBase { get; set; }
  2858. /// <summary>
  2859. /// 协作次数
  2860. /// </summary>
  2861. public int coworkCountBase { get; set; }
  2862. /// <summary>
  2863. /// 智能评分次数
  2864. /// </summary>
  2865. public int smartRatingCountBase { get; set; }
  2866. /// <summary>
  2867. /// 作品上传数
  2868. /// </summary>
  2869. public List<List<double>> upload { get; set; } = new List<List<double>>();
  2870. /// <summary>
  2871. /// 学生协作成果数
  2872. /// </summary>
  2873. public List<double> stuCowork { get; set; } = new List<double>();
  2874. /// <summary>
  2875. /// 小组协作成果数
  2876. /// </summary>
  2877. public List<double> groupCowork { get; set; } = new List<double>();
  2878. public List<string> pickup { get; set; } = new List<string>();
  2879. }
  2880. }