LessonETLService.cs 157 KB

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