12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892 |
- using ClouDASLibx;
- using Microsoft.AspNetCore.Mvc;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.Json;
- using System.Threading.Tasks;
- using TEAMModelOS.SDK.Models;
- using TEAMModelOS.SDK;
- using TEAMModelOS.SDK.DI;
- using TEAMModelOS.SDK.Extension;
- using Microsoft.Extensions.Options;
- using TEAMModelOS.Models;
- using Microsoft.Azure.Cosmos;
- using TEAMModelOS.Models.Dto;
- using System.Text;
- using Microsoft.AspNetCore.Http;
- using HTEXLib.Translator;
- namespace TEAMModelOS.Controllers.Analysis
- {
- [Route("analysis")]
- [ApiController]
- public class AchievementController : ControllerBase
- {
- private readonly AzureCosmosFactory _azureCosmos;
- private readonly DingDing _dingDing;
- private readonly Option _option;
- private const string CacheCosmosPrefix = "Analysis:";
- private const int timeoutSeconds = 3600;
- public readonly AzureStorageFactory _azureStorage;
- public DOXC2HTMLTranslator _DOXC2HTMLTranslator { get; set; }
- //public PPTX2HTEXTranslator _PPTX2HTEXTranslator { get; set; }
- public HTML2ITEMV3Translator _HTML2ITEMV3Translator { get; set; }
- public AchievementController(DOXC2HTMLTranslator DOXC2HTMLTranslator, HTML2ITEMV3Translator HTML2ITEMV3Translator,AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage)
- {
- _azureCosmos = azureCosmos;
- _dingDing = dingDing;
- _option = option?.Value;
- _azureStorage = azureStorage;
- _DOXC2HTMLTranslator = DOXC2HTMLTranslator;
- _HTML2ITEMV3Translator = HTML2ITEMV3Translator;
- }
- // [HttpPost("Achievement")]
- // public async Task<BaseResponse> FindExam(JsonElement request)
- // {
- // ResponseBuilder builder = ResponseBuilder.custom();
- // Dictionary<string, object> dict = new Dictionary<string, object>();
- // var emobj = request.EnumerateObject();
- // while (emobj.MoveNext())
- // {
- // dict[emobj.Current.Name] = emobj.Current.Value;
- // }
- // Dictionary<string, dynamic> info = new Dictionary<string, dynamic>();
- // if (RedisHelper.Instance != null)
- // {
- // info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "Achievement",
- // ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindExamRedis(dict, "Achievement"); });
- // //数据从redis读取过后进行转换格式
- // builder.Data(info);
- // }
- // else
- // {
- // info = await FindExamRedis(dict, "Achievement");
- // builder.Data(info);
- // }
- // return builder.build();
- // }
- // public async Task<List<ExamResult>> FindExamResultRedis(Dictionary<string, object> dict, string method)
- // {
- // return new List<ExamResult>();
- // //try
- // //{
- // // List<ExamResult> info = await _azureCosmos.FindByDict<ExamResult>(dict);
- // // if (RedisHelper.Instance != null)
- // // {
- // // if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- // // {
- // // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- // // }
- // // else
- // // {
- // // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- // // await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- // // }
- // // }
- // // return info;
- // //}
- // //catch (Exception e)
- // //{
- // // throw new BizException(e.Message);
- // //}
- // }
- // public async Task<Dictionary<string, dynamic>> FindExamRedis(Dictionary<string, object> dict, string method)
- // {
- // ResponseBuilder builder = ResponseBuilder.custom();
- // //Console.WriteLine(DateTimeOffset.Now.Second);
- // //
- // dict.TryGetValue("subjectCode", out object subjectCode);
- // dict.TryGetValue("code", out object code);
- // dict.TryGetValue("schoolCode", out object schoolCode);
- // List<ExamResultDto> exams = new List<ExamResultDto>();
- // /*if (RedisHelper.Instance != null)
- // {
- // exams = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "FindExamResultRedis",
- // ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindExamResultRedis(dict, "FindExamResultRedis"); });
- // }
- // else
- // {
- // exams = await FindExamResultRedis(dict, "FindExamResultRedis");
- // }*/
- // List<string> subjectCouns = JsonExtensions.ToObject<List<string>>(subjectCode.ToJsonString());
- // for (int i = 0; i < subjectCouns.Count; i++)
- // {
- // if (RedisHelper.Exists(CacheCosmosPrefix + "examResult" + subjectCouns[i]))
- // {
- // ExamResultDto result = RedisHelper.HGet<ExamResultDto>(CacheCosmosPrefix + "examResult" + subjectCouns[i], ShaHashHelper.GetSHA1(code.ToString()));
- // //builder.Data(info);
- // exams.Add(result);
- // }
- // }
- // }
- // Dictionary<string, object> stuMap = new Dictionary<string, object>
- // {
- // { "schoolCode", "Habook" }
- // };
- // //声明进行标准用来设置进线标准,权重等参数
- // dict.TryGetValue("Standard", out object Standard);
- // //List<Student> students = await _azureCosmos.FindByDict<Student>(stuMap);
- // List<OldStudent> students = null;
- // if (RedisHelper.Exists(CacheCosmosPrefix + "students"))
- // {
- // students = RedisHelper.HGet<List<OldStudent>>(CacheCosmosPrefix + "students", ShaHashHelper.GetSHA1(schoolCode.ToString()));
- // //builder.Data(info);
- // //students.Add(student);
- // }
- // //Console.WriteLine(DateTimeOffset.Now.Second);
- // List<Dictionary<string, object>> examList = new List<Dictionary<string, object>>();
- // HashSet<string> classList = new HashSet<string>();
- // HashSet<string> classId = new HashSet<string>();
- // List<string> subjectAverage = new List<string>();
- // List<List<string>> subjectPoints = new List<List<string>>();
- // Dictionary<string, object> Average = new Dictionary<string, object>();
- // Dictionary<string, object> entryTable = new Dictionary<string, object>();
- // Dictionary<string, dynamic> achievementAnalysis = new Dictionary<string, dynamic>();
- // List<string> arrSubject = new List<string>();
- // List<string> keys = new List<string>();
- // List<string> person = new List<string>();
- // List<List<double>> subSum = new List<List<double>>();
- // List<string> gAverage = new List<string>();
- // List<string> cAverage = new List<string>();
- // Dictionary<string, object> AclassAverage = new Dictionary<string, object>();
- // Dictionary<string, object> passRateMap = new Dictionary<string, object>();
- // List<List<string>> passALL = new List<List<string>>();
- // List<string> gradeList = new List<string>();
- // List<string> areaList = new List<string>();
- // List<string> sbujectsList = new List<string>();
- // if (exams.IsNotEmpty())
- // {
- // //存放进线情况统计key值
- // keys.Add("name");
- // keys.Add("className");
- // keys.Add("gradeRank");
- // keys.Add("score");
- // //初始化进行人数
- // double iPersons = 0;
- // if (exams.IsNotEmpty())
- // {
- // int classLen = exams[0].classes.Count;
- // for (int cls = 0; cls<classLen; cls++)
- // {
- // if (exams[0].classes[cls].TryGetValue(exams[0].classes[cls].Keys.ToArray<string>()[0], out int[] index))
- // {
- // List<double> stuScore = new List<double>();
- // int stdLen = index[1] - index[0] + 1;
- // for (int i = 0; i<stdLen; i++)
- // {
- // stuScore.Add(0);
- // }
- //subSum.Add(stuScore);
- // }
- // }
- // }
- // int xx = 0;
- ////初始化总分
- //double sumPoint = 0;
- //int sumperson = exams[0].ids.Count;
- //for (int i = 0; i < exams[0].ids.Count; i++)
- //{
- // if (exams[0].ids[i].Equals("0"))
- // {
- // sumperson--;
- // }
- //}
- //exams.ForEach(e =>
- //{
- // //获取总分数
- // e.result.ForEach(r =>
- // {
- // sumPoint += r.Sum();
- // });
- //});
- //var gradeAverage = sumPoint / sumperson;
- ////存放年级平均
- //gAverage.Add(gradeAverage.ToString());
- ////任意一次考试数据提取班级信息
- //List<Dictionary<string, int[]>> classToName = exams[0].classes;
- ////任意一次考试数据提取学生ID信息
- //List<string> idToName = exams[0].ids;
- ////var gradeAverage = Math.Floor(Math.Round(decimal.Parse((10 / 3).ToString("0.000")), 2));
- //List<string> subjects = new List<string>();
- //exams.ForEach(e =>
- //{
- // int peopleCount = 0;
- // Dictionary<string, object> detail = new Dictionary<string, object>
- // {
- // { "name", e.subjectCode }
- // };
- // subjects.Add(e.subjectCode);
- // List<string> ClassAverage = new List<string>();
- // //计算试卷总分
- // double sum = e.point.Sum();
- // //及格分数
- // double passRate = sum * 0.6;
- // int gradeCount = 0;
- // //初始化科目总分
- // double subjectPoint = 0;
- // //科目平均分
- // double subAverage = 0;
- // //计算班级平均分
- // int classIndex = 0;
- // List<string> passList = new List<string>();
- // e.classes.ForEach(c =>
- // {
- // List<List<string>> classPRL = new List<List<string>>();
- // //初始化班级总分
- // double classPoint = 0;
- // //初始化班级缺考人数
- // int classCount = 0;
- // //初始化班级平均分
- // double points = 0;
- // double passPoint = 0;
- // //初始化及格人数
- // int passCount = 0;
- // //初始化各班参考人数
- // int counts = 0;
- // //c.Keys遍历key值
- // foreach (string key in c.Keys)
- // {
- // classList.Add(key);
- // }
- // //每个班级平均分
- // foreach (int[] value in c.Values)
- // {
- // for (int i = value[0]; i <= value[1]; i++)
- // {
- // //初始化学生单科个人得分
- // double stuPoints = e.result[i].Sum();
- // //Console.WriteLine("xx: "+xx+" classIndex:" + classIndex + ",i:" + i + " value[0]:" + value[0]+ " value[0]:" + value[1]);
- // subSum[classIndex][i - value[0]] = stuPoints + subSum[classIndex][i - value[0]];
- // if (stuPoints > passRate)
- // {
- // passCount++;
- // gradeCount++;
- // }
- // classPoint += e.result[i].Sum();
- // if (e.result[i].Sum() == 0)
- // {
- // classCount++;
- // }
- // }
- // //每个班级实际参考人数
- // counts = value[1] - value[0] - classCount + 1;
- // points = Convert.ToDouble(classPoint) / counts;
- // ClassAverage.Add(points.ToString("0.00"));
- // person.Add(counts + "");
- // }
- // passPoint = Convert.ToDouble(passCount) / counts;
- // passList.Add(passPoint.ToString("0.00"));
- // //classPRM.Add(classPRL);
- // classIndex += 1;
- // });
- // //科目平均分
- // ClassAverage.ForEach(a =>
- // {
- // subjectPoint += Convert.ToDouble(a);
- // });
- // subAverage = subjectPoint / ClassAverage.Count();
- // subjectAverage.Add(subAverage.ToString("0.00"));
- // detail.Add("schoolAverage", subAverage.ToString("0.00"));
- // detail.Add("areaAverage", subAverage.ToString("0.00"));
- // detail.Add("score", ClassAverage);
- // examList.Add(detail);
- // //获取实际参考总人数
- // e.ids.ForEach(i =>
- // {
- // if (!i.Equals("0"))
- // {
- // peopleCount++;
- // }
- // });
- // //班级及格率
- // passALL.Add(passList);
- // //年级及格率
- // double gradePass = Convert.ToDouble(gradeCount) / peopleCount;
- // gradeList.Add(gradePass.ToString("0.00"));
- // //passALL.Add(gradeList);
- // //区级及格率
- // //passALL.Add(areaList);
- // //获取进线人数
- // iPersons = peopleCount * 0.4;
- // //计算每个学生单科成绩
- // for (int i = 0; i < e.ids.Count(); i++)
- // {
- // List<string> info = new List<string>();
- // //info = new List<string>();
- // info.Add(e.ids[i]);
- // info.Add(e.subjectCode);
- // info.Add(e.result[i].Sum() + "");
- // //classId.Add(e.Ids[i]);
- // subjectPoints.Add(info);
- // }
- // keys.Add(e.subjectCode);
- // xx += 1;
- // //subjectPoints = GetMark(e.Result,e.Ids);
- // });
- ////subjectPoints.ForEach(f => f.GroupBy(f[0]));
- ////进线情况统计
- //Dictionary<string, List<List<string>>> dicts = new Dictionary<string, List<List<string>>>();
- //foreach (IGrouping<string, List<string>> group in subjectPoints.GroupBy(c => c[0]))
- //{
- // dicts.Add(group.Key, group.ToList());
- //};
- //Average.Add("classList", classList);
- //List<List<string>> sp = new List<List<string>>();
- ////Dictionary<string, int> rankScore = new Dictionary<string, int>();
- //List<double> rankScore = new List<double>();
- //foreach (string key in dicts.Keys)
- //{
- // double score = 0;
- // List<string> values = new List<string>();
- // keys.ForEach(x =>
- // {
- // values.Add("-");
- // });
- // foreach (List<string> val in dicts[key])
- // {
- // int index = keys.IndexOf(val[1]);
- // values[index] = val[2];
- // values[keys.IndexOf("name")] = val[0];
- // score += double.Parse(val[2]);
- // values[keys.IndexOf("score")] = score + "";
- // }
- // rankScore.Add(score);
- // sp.Add(values);
- //}
- //AchievementService.ReName(sp, idToName, classToName, students);
- ////处理人数为整
- //string ip = iPersons.ToString("0");
- ////初始化进线分数
- //double ipoint = 0;
- ////计算成绩年级排名
- //rankScore.Sort(delegate (double s1, double s2) { return s2.CompareTo(s1); });
- //ipoint = rankScore[int.Parse(ip)];
- //foreach (List<string> rank in sp)
- //{
- // int index = rankScore.IndexOf(double.Parse(rank[3]));
- // rank[2] = (index + 1) + "";
- //}
- ////排除成绩为零的选手
- //for (int i = sp.Count - 1; i >= 0; i--)
- //{
- // if (sp[i][0].Equals("0"))
- // {
- // sp.Remove(sp[i]);
- // }
- //}
- //entryTable.Add("keys", keys);
- //entryTable.Add("datas", sp);
- ////封装进线人数统计
- //List<string> keyLine = new List<string>
- // {
- // "gradeRank",
- // "name",
- // "entryNum",
- // "totalNum",
- // "overAverageRate"
- // };
- //Dictionary<string, object> entryLineBar = new Dictionary<string, object>();
- ////存放班级信息
- //List<string> className = new List<string>();
- //foreach (string cla in classList)
- //{
- // className.Add(cla);
- //}
- //List<List<string>> datas = new List<List<string>>();
- ////记录各个班级进线率占比
- //List<string> persent = new List<string>();
- //int m = 0;
- //foreach (List<double> points in subSum)
- //{
- // List<string> detail = new List<string>();
- // keyLine.ForEach(x =>
- // {
- // detail.Add("-");
- // });
- // double sum = points.Count;
- // int j = 0;
- // for (int i = 0; i < points.Count; i++)
- // {
- // if (points[i] > ipoint)
- // {
- // j++;
- // }
- // }
- // double Lines = j;
- // detail[1] = className[m].ToString();
- // detail[2] = j.ToString();
- // detail[3] = points.Count.ToString();
- // var t3 = Math.Floor(Math.Round(decimal.Parse((Lines / sum).ToString("0.000")), 2) * 100);
- // persent.Add(t3.ToString());
- // detail[4] = t3.ToString();
- // datas.Add(detail);
- // m++;
- //}
- //persent.Sort(delegate (string s1, string s2) { return int.Parse(s2).CompareTo(int.Parse(s1)); });
- ////存放班级的年级排名
- //List<string> ranks = new List<string>();
- //foreach (List<string> des in datas)
- //{
- // int index = persent.IndexOf(des[4]);
- // des[0] = (index + 1).ToString();
- // ranks.Add((index + 1).ToString());
- //}
- ////预警统计
- //Dictionary<string, object> early = new Dictionary<string, object>();
- //List<List<string>> earlyWarning = new List<List<string>>();
- //List<string> keyWarning = new List<string>
- // {
- // "classId",
- // "totalNum",
- // "average",
- // "standardDeviation",
- // "overAverageRate",
- // "gradeRank"
- // };
- //int n = 0;
- //foreach (List<double> points in subSum)
- //{
- // double sum = 0;
- // List<string> classInfo = new List<string>();
- // classInfo.Add(className[n]);
- // classInfo.Add(points.Count.ToString());
- // foreach (int point in points)
- // {
- // sum += point;
- // }
- // double Aver = sum / points.Count;
- // classInfo.Add(Aver.ToString());
- // //存放班级平均
- // cAverage.Add(Aver.ToString());
- // //标准差
- // double powSum = 0;
- // foreach (int point in points)
- // {
- // powSum += Math.Pow(point - Aver, 2);
- // }
- // var pow = Math.Pow(powSum / points.Count, 0.5);
- // classInfo.Add(pow.ToString("0.00"));
- // //超均率
- // var super = (sum - (sum - 100)) / (sum - 100);
- // classInfo.Add(super.ToString("0.00"));
- // //年级排名
- // classInfo.Add(ranks[n]);
- // earlyWarning.Add(classInfo);
- // n++;
- //}
- ////sbujectsList.Add(subjects);
- //passRateMap.Add("subjects", subjects);
- //passRateMap.Add("class", passALL);
- //passRateMap.Add("grade", gradeList);
- //passRateMap.Add("area", areaList);
- ////passRate.Add("passRate", passALL);
- //early.Add("keys", keyWarning);
- //early.Add("datas", earlyWarning);
- //AclassAverage = AchievementService.GetAverage(exams, gAverage, cAverage, subSum, students);
- //List<Dictionary<string, object>> rankPR = AchievementService.GetPR(exams, subSum, students);
- //entryLineBar.Add("keys", keyLine);
- //entryLineBar.Add("datas", datas);
- ////sp.Sort(delegate (string s1, string s2) { return int.Parse(s1).CompareTo(int.Parse(s2)); });
- //Average.Add("subjectAverage", subjectAverage);
- //Average.Add("datas", examList);
- //achievementAnalysis.Add("passRate", passRateMap);
- //achievementAnalysis.Add("average", Average);
- //achievementAnalysis.Add("entryLineBar", entryLineBar);
- //achievementAnalysis.Add("entryTable", entryTable);
- //achievementAnalysis.Add("earlyWarning", early);
- //achievementAnalysis.Add("rankPR", rankPR);
- //achievementAnalysis.Add("stuAverage", AclassAverage);
- ////Redis处理结果集
- //if (RedisHelper.Instance != null)
- //{
- // if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- // {
- // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), achievementAnalysis);
- // }
- // else
- // {
- // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), achievementAnalysis);
- // await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- // }
- //}
- //return achievementAnalysis;
- // }
- // else return achievementAnalysis;
- // }
- // /* public List<string> GetMark(List<List<int>> point,List<string> ids) {
- // List<string> info = null;
- // for (int i = 0;i <= ids.Count();i++) {
- // info = new List<string>();
- // info.Add(ids[i]);
- // info.Add(point[i].Sum()+"");
- // }
- // return info;
- // }*/
- // [HttpPost("PointAnalysis")]
- //public async Task<BaseResponse> PointAnalysis(JsonElement request)
- //{
- // ResponseBuilder builder = ResponseBuilder.custom();
- // /*Dictionary<string, object> dict = new Dictionary<string, object>();
- // var emobj = request.EnumerateObject();
- // while (emobj.MoveNext())
- // {
- // dict[emobj.Current.Name] = emobj.Current.Value;
- // }
- // List<Dictionary<string, dynamic>> info = new List<Dictionary<string, dynamic>>();
- // if (RedisHelper.Instance != null)
- // {
- // info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "PointAnalysis",
- // ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindPointAnalysisRedis(dict, "PointAnalysis"); });
- // //数据从redis读取过后进行转换格式
- // builder.Data(info);
- // }
- // else
- // {
- // info = await FindPointAnalysisRedis(dict, "PointAnalysis");
- // builder.Data(info);
- // }*/
- // return builder.build();
- //}
- //[HttpPost("ExerciseScatter")]
- //public async Task<BaseResponse> ExerciseScatter(JsonElement request)
- //{
- // /* ResponseBuilder builder = ResponseBuilder.custom();
- // Dictionary<string, object> dict = new Dictionary<string, object>();
- // var emobj = request.EnumerateObject();
- // while (emobj.MoveNext())
- // {
- // dict[emobj.Current.Name] = emobj.Current.Value;
- // }
- // List<Dictionary<string, dynamic>> info = new List<Dictionary<string, dynamic>>();
- // if (RedisHelper.Instance != null)
- // {
- // info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "ExerciseScatter",
- // ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindExerciseScatterRedis(dict, "ExerciseScatter"); });
- // //数据从redis读取过后进行转换格式
- // builder.Data(info);
- // }
- // else
- // {
- // info = await FindExerciseScatterRedis(dict, "ExerciseScatter");
- // builder.Data(info);
- // }*/
- // return null;
- //}
- //public async Task<Dictionary<string, dynamic>> FindKnowledgePointRedis(Dictionary<string, object> dict, string method)
- //{
- // //ResponseBuilder builder = ResponseBuilder.custom();
- // dict.TryGetValue("subjectCode", out object subjectCode);
- // dict.TryGetValue("schoolCode", out object schoolCode);
- // dict.TryGetValue("code", out object code);
- // //dict.TryGetValue("scopeCode", out object scopeCode);
- // /* Dictionary<string, object> sub = new Dictionary<string, object>
- // {
- // { "subjectCode", subjectCode.ToString()},
- // { "code",code.ToString()}
- // };
- // Dictionary<string, object> examMap = new Dictionary<string, object>
- // {
- // { "schoolCode", schoolCode.ToString()},
- // { "code", code.ToString()},
- // { "subjectCode", subjectCode.ToString()}
- // };*/
- // List<ExamResultDto> exams = new List<ExamResultDto>();
- // if (RedisHelper.Exists(CacheCosmosPrefix + "examResult" + subjectCode.ToString()))
- // {
- // ExamResultDto res = RedisHelper.HGet<ExamResultDto>(CacheCosmosPrefix + "examResult" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
- // exams.Add(res);
- // }
- // List<PaperDto> paper = new List<PaperDto>();
- // if (RedisHelper.Exists(CacheCosmosPrefix + "paperInfo" + subjectCode.ToString()))
- // {
- // PaperDto papers = RedisHelper.HGet<PaperDto>(CacheCosmosPrefix + "paperInfo" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
- // paper.Add(papers);
- // }
- // Dictionary<string, object> stuMap = new Dictionary<string, object>
- // {
- // { "schoolCode", "Habook" }
- // };
- // //List<Student> students = await azureCosmosDBRepository.FindByDict<Student>(stuMap);
- // List<OldStudent> students = null;
- // if (RedisHelper.Exists(CacheCosmosPrefix + "students"))
- // {
- // students = RedisHelper.HGet<List<OldStudent>>(CacheCosmosPrefix + "students", ShaHashHelper.GetSHA1(schoolCode.ToString()));
- // //builder.Data(info);
- // //students.Add(student);
- // }
- // HashSet<string> knowledge = new HashSet<string>();
- // HashSet<string> area = new HashSet<string>();
- // List<double> point = new List<double>();
- // List<List<double>> result = new List<List<double>>();
- // List<Dictionary<string, int[]>> classes = new List<Dictionary<string, int[]>>();
- // List<string> ids = new List<string>();
- // //string Type = "";
- // if (dict.TryGetValue("type", out object Type))
- // {
- // /*paper.ForEach(p =>
- // {
- // p.item.ForEach(i =>
- // {
- // knowledge.Add(i.field);
- // area.Add(i.field);
- // });
- // });*/
- // knowledge.Add("知识");
- // knowledge.Add("理解");
- // knowledge.Add("应用");
- // knowledge.Add("分析");
- // knowledge.Add("综合");
- // knowledge.Add("评鉴");
- // area.Add("知识");
- // area.Add("理解");
- // area.Add("应用");
- // area.Add("分析");
- // area.Add("综合");
- // area.Add("评鉴");
- // }
- // else
- // {
- // paper.ForEach(p =>
- // {
- // p.item.ForEach(i =>
- // {
- // i.points.ForEach(o =>
- // {
- // knowledge.Add(o);
- // });
- // area.Add(i.field);
- // });
- // });
- // }
- // double Qnum = 0;
- // //确定高分组 低分组人数
- // List<List<double>> re = exams[0].result;
- // List<double> resultSum = new List<double>();
- // foreach (List<double> data in re)
- // {
- // resultSum.Add(data.Sum());
- // }
- // //确定高分组 最低分数
- // resultSum.Sort(delegate (double s1, double s2) { return s2.CompareTo(s1); });
- // for (int i = resultSum.Count - 1; i >= 0; i--)
- // {
- // if (resultSum[i] == 0)
- // {
- // resultSum.Remove(resultSum[i]);
- // }
- // }
- // double rhwCount = resultSum.Count * 0.27;
- // double rhw = resultSum[int.Parse(rhwCount.ToString("0"))];
- // //确定低分组 最高分数
- // resultSum.Sort(delegate (double s1, double s2) { return s1.CompareTo(s2); });
- // double rhlCount = resultSum.Count * 0.27;
- // double rhl = resultSum[int.Parse(rhwCount.ToString("0"))];
- // foreach (ExamResultDto ex in exams)
- // {
- // point = ex.point;
- // result = ex.result;
- // classes = ex.classes;
- // ids = ex.ids;
- // }
- // /* exams.ForEach(e =>
- // {
- // point = e.Point;
- // result = e.Result;
- // classes = e.Classes;
- // ids = e.Ids;
- // });*/
- // List<string> knowledgeName = new List<string>();
- // foreach (string cla in knowledge)
- // {
- // knowledgeName.Add(cla);
- // }
- // for (int k = 0; k < knowledgeName.Count; k++)
- // {
- // if (null == knowledgeName[k])
- // {
- // knowledgeName.Remove(knowledgeName[k]);
- // }
- // }
- // List<string> areaName = new List<string>();
- // foreach (string cla in area)
- // {
- // areaName.Add(cla);
- // }
- // for (int k = 0; k < areaName.Count; k++)
- // {
- // if (null == areaName[k])
- // {
- // areaName.Remove(areaName[k]);
- // }
- // }
- // //初始化年级总分
- // double total = 0;
- // //处理年级单个知识点得分率
- // foreach (List<double> grade in result)
- // {
- // total += grade.Sum();
- // }
- // foreach (string id in ids)
- // {
- // if (!id.Equals("0"))
- // {
- // Qnum++;
- // }
- // }
- // //试卷总分
- // double TotalPoint = point.Sum();
- // //计算认知层次占比
- // List<string> fper = new List<string>();
- // for (int a = 0; a < areaName.Count; a++)
- // {
- // double fieldPoint = 0;
- // paper.ForEach(p =>
- // {
- // int n = 0;
- // p.item.ForEach(i =>
- // {
- // if (i.field != null && i.field.Contains(areaName[a]))
- // {
- // fieldPoint += point[n];
- // }
- // n++;
- // });
- // });
- // double fieldPersent = fieldPoint / TotalPoint;
- // fper.Add(fieldPersent.ToString("0.00"));
- // }
- // //求单个知识点所占分数
- // List<string> per = new List<string>();
- // List<string> gper = new List<string>();
- // List<string> knowPer = new List<string>();
- // List<Dictionary<string, double>> eper = new List<Dictionary<string, double>>();
- // Dictionary<string, object> knowledgeALL = new Dictionary<string, object>();
- // Dictionary<string, object> knowledgeMap = new Dictionary<string, object>();
- // Dictionary<string, object> classMap = new Dictionary<string, object>();
- // Dictionary<string, object> wrongMap = new Dictionary<string, object>();
- // HashSet<string> className = new HashSet<string>();
- // List<List<string>> wrongPersent = new List<List<string>>();
- // List<string> key = new List<string>
- // {
- // "id",
- // "className",
- // "seatNO",
- // "point",
- // "anwPoint",
- // "persent"
- // };
- // List<string> keyWrong = new List<string>
- // {
- // "name",
- // "point",
- // "itemNO",
- // "persent",
- // "wrong",
- // "rhw",
- // "rlw"
- // };
- // for (int k = 0; k < knowledgeName.Count; k++)
- // {
- // List<string> knowledgeClass = new List<string>();
- // List<List<string>> stuPersent = new List<List<string>>();
- // double OnePoint = 0;
- // //获取每个知识点占有多少分值
- // double ePoint = 0;
- // double anwGPoint = 0;
- // double poG = 0;
- // int m = 0;
- // List<string> valuew = new List<string>();
- // List<string> itemNo = new List<string>();
- // keyWrong.ForEach(x =>
- // {
- // valuew.Add("-");
- // });
- // int wrongCount = 0;
- // valuew[0] = knowledgeName[k];
- // paper.ForEach(p =>
- // {
- // int n = 0;
- // if (dict.TryGetValue("type", out object Type))
- // {
- // p.item.ForEach(i =>
- // {
- // if (i.field != null && i.field.Contains(knowledgeName[k]))
- // {
- // OnePoint += point[n];
- // itemNo.Add((n + 1).ToString());
- // }
- // n++;
- // });
- // }
- // else
- // {
- // p.item.ForEach(i =>
- // {
- // if (i.points != null && i.points.Contains(knowledgeName[k]))
- // {
- // OnePoint += 1 / Convert.ToDouble(i.points.Count) * point[n];
- // itemNo.Add((n + 1).ToString());
- // }
- // n++;
- // });
- // }
- // valuew[1] = OnePoint.ToString();
- // string itemNos = "";
- // if (itemNo.Count > 0)
- // {
- // foreach (string index in itemNo)
- // {
- // itemNos += index + ",";
- // }
- // valuew[2] = itemNos[0..^1];
- // }
- // else
- // {
- // valuew[2] = itemNos;
- // }
- // });
- // int rhwC = 0;
- // int rhlC = 0;
- // foreach (string id in ids)
- // {
- // if (id.Equals("0") || result[m].Sum() == 0)
- // {
- // m++;
- // continue;
- // }
- // List<string> values = new List<string>();
- // key.ForEach(x =>
- // {
- // values.Add("-");
- // });
- // foreach (OldStudent info in students)
- // {
- // if (info.studentId.Equals(id))
- // {
- // values[2] = info.seatNo.ToString();
- // break;
- // }
- // }
- // //List<string> stu = new List<string>();
- // values[0] = id;
- // values[1] = "-";
- // //List<List<string>> stuItem = new List<List<string>>();
- // int statuCount = 0;
- // paper.ForEach(p =>
- // {
- // int n = 0;
- // double anwPoint = 0;
- // double po = 0;
- // p.item.ForEach(i =>
- // {
- // if (dict.TryGetValue("type", out object Type))
- // {
- // if (i.field != null && i.field.Contains(knowledgeName[k]))
- // {
- // //Dictionary<string, double> mapkeyItem = new Dictionary<string, double>();
- // //OnePoint += 1 / Convert.ToDouble(i.points.Count) * point[n];
- // //当前认知层次在该题占比多少
- // ePoint = 1;
- // anwPoint += result[m][n] * ePoint;
- // //所有学生单个认知层次得分情况
- // anwGPoint += result[m][n] * ePoint;
- // po += point[n] * ePoint;
- // //认知层次所占分数
- // poG += point[n] * ePoint;
- // if (result[m][n] == 0 && statuCount == 0)
- // {
- // statuCount++;
- // wrongCount++;
- // if (result[m].Sum() >= rhw)
- // {
- // rhwC++;
- // }
- // if (result[m].Sum() <= rhl)
- // {
- // rhlC++;
- // }
- // }
- // }
- // n++;
- // }
- // else
- // {
- // if (i.points != null && i.points.Contains(knowledgeName[k]))
- // {
- // {
- // //Dictionary<string, double> mapkeyItem = new Dictionary<string, double>();
- // //OnePoint += 1 / Convert.ToDouble(i.points.Count) * point[n];
- // //当前知识点在该题占比多少
- // ePoint = 1 / Convert.ToDouble(i.points.Count);
- // anwPoint += result[m][n] * ePoint;
- // //所有学生单个知识点得分情况
- // anwGPoint += result[m][n] * ePoint;
- // po += point[n] * ePoint;
- // //知识点所占分数
- // poG += point[n] * ePoint;
- // if (result[m][n] == 0 && statuCount == 0)
- // {
- // statuCount++;
- // wrongCount++;
- // if (result[m].Sum() >= rhw)
- // {
- // rhwC++;
- // }
- // if (result[m].Sum() <= rhl)
- // {
- // rhlC++;
- // }
- // }
- // }
- // n++;
- // }
- // });
- // if (po == 0)
- // {
- // values[3] = "0";
- // values[4] = "0";
- // values[5] = "0";
- // }
- // else
- // {
- // double stuPser = anwPoint / po;
- // values[3] = po.ToString();
- // values[4] = anwPoint.ToString();
- // values[5] = stuPser.ToString("0.00");
- // }
- // //stuItem.Add(values);
- // });
- // stuPersent.Add(values);
- // m++;
- // }
- // AchievementService.ReName(stuPersent, ids, classes, students);
- // double knowPser = 0;
- // if (poG == 0)
- // {
- // knowPer.Add("0");
- // }
- // else
- // {
- // knowPser = anwGPoint / poG;
- // knowPer.Add(knowPser.ToString("0.00"));
- // }
- // values[5] = stuPser.ToString("0.00");
- // //错题关系表
- // valuew[3] = knowPser.ToString("0.00");
- // valuew[4] = wrongCount.ToString();
- // valuew[5] = rhwC.ToString();
- // valuew[6] = rhlC.ToString();
- // wrongPersent.Add(valuew);
- // knowledgeMap.Add(knowledgeName[k], stuPersent);
- // //知识点占比
- // double persent = OnePoint / TotalPoint;
- // foreach (Dictionary<string, int[]> map in classes)
- // {
- // List<string> classPoints = new List<string>();
- // //初始化班级得分
- // double anwCPoint = 0;
- // double cpo = 0;
- // foreach (KeyValuePair<string, int[]> kvp in map)
- // {
- // className.Add(kvp.Key);
- // for (int n = kvp.Value[0]; n < kvp.Value[1]; n++)
- // {
- // if (result[n].Sum() == 0) continue;
- // paper.ForEach(p =>
- // {
- // int x = 0;
- // wrongPersent.Add(valuew);
- // knowledgeMap.Add(knowledgeName[k], stuPersent);
- // p.item.ForEach(i =>
- // {
- // if (dict.TryGetValue("type", out object Type))
- // {
- // if (i.field != null && i.field.Contains(knowledgeName[k]))
- // {
- // //当前认知层次在该题占比多少
- // ePoint = 1;
- // anwCPoint += result[n][x] * ePoint;
- // cpo += point[x] * ePoint;
- // }
- // x++;
- // }
- // else
- // {
- // if (i.points != null && i.points.Contains(knowledgeName[k]))
- // {
- // //当前知识点在该题占比多少
- // ePoint = 1 / Convert.ToDouble(i.points.Count);
- // anwCPoint += result[n][x] * ePoint;
- // cpo += point[x] * ePoint;
- // }
- // x++;
- // }
- // });
- // });
- // }
- // }
- // if (cpo == 0)
- // {
- // //double classPser = anwCPoint / cpo;
- // knowledgeClass.Add("0");
- // }
- // else
- // {
- // double classPser = anwCPoint / cpo;
- // knowledgeClass.Add(classPser.ToString("0.00"));
- // }
- // classMap.Add(knowledgeName[k], knowledgeClass);
- // per.Add(persent.ToString("0.00"));
- // }
- // knowledgeMap.Add("grade", knowPer);
- // knowledgeMap.Add("keys", key);
- // classMap.Add("className", className);
- // wrongMap.Add("keys", keyWrong);
- // wrongMap.Add("datas", wrongPersent);
- // knowledgeALL.Add("pointList", knowledgeName);
- // knowledgeALL.Add("per", per);
- // knowledgeALL.Add("level", areaName);
- // knowledgeALL.Add("fper", fper);
- // knowledgeALL.Add("stupercent", knowledgeMap);
- // knowledgeALL.Add("classpercent", classMap);
- // knowledgeALL.Add("wrong", wrongMap);
- // //builder.Data(knowledgeALL);
- // classMap.Add(knowledgeName[k], knowledgeClass);
- // per.Add(persent.ToString("0.00"));
- // //Redis处理结果集
- // if (RedisHelper.Instance != null)
- // {
- // if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- // {
- // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), knowledgeALL);
- // }
- // else
- // {
- // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), knowledgeALL);
- // await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- // }
- // }
- // return knowledgeALL;
- // }
- // [HttpPost("knowledgePoint")]
- // public async Task<BaseResponse> KnowledgePoint(JsonElement request)
- // {
- // ResponseBuilder builder = ResponseBuilder.custom();
- // Dictionary<string, object> dict = new Dictionary<string, object>();
- // var emobj = request.EnumerateObject();
- // while (emobj.MoveNext())
- // {
- // dict[emobj.Current.Name] = emobj.Current.Value;
- // }
- // Dictionary<string, dynamic> info = new Dictionary<string, dynamic>();
- // if (RedisHelper.Instance != null)
- // {
- // info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "knowledgePoint",
- // ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindKnowledgePointRedis(dict, "knowledgePoint"); });
- // //数据从redis读取过后进行转换格式
- // }
- // else
- // {
- // info = await FindKnowledgePointRedis(dict, "knowledgePoint");
- // builder.Data(info);
- // }
- // return builder.build();
- // }
- // [HttpPost("FindExamInfo")]
- // public async Task<BaseResponse> FindExamInfo(JsonElement request)
- // {
- // ResponseBuilder builder = ResponseBuilder.custom();
- // Dictionary<string, object> dict = new Dictionary<string, object>();
- // var emobj = request.EnumerateObject();
- // while (emobj.MoveNext())
- // {
- // dict[emobj.Current.Name] = emobj.Current.Value;
- // }
- // if (RedisHelper.Instance != null)
- // {
- // try
- // {
- // ///RedisHelper.Instance.CurrentSerialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
- // /// RedisHelper.Instance.CurrentDeserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
- // List<ExamInfoDto> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "FindExamInfo",
- // ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindExamInfoRedis(dict, "FindExamInfo"); });
- // builder.Data(info);
- // }
- // catch (Exception e)
- // {
- // // throw new BizException(e.Message);
- // }
- // }
- // else
- // {
- // List<ExamInfoDto> info = await FindExamInfoRedis(dict, "FindExamInfo");
- // builder.Data(info);
- // }
- // return builder.build();
- // }
- // //目前单次考试权重关系和权重次数
- // info[i].index = info[i].piont * 1 / 1;
- // public async Task<List<ExamInfoDto>> FindExamInfoRedis(Dictionary<string, object> dict, string method)
- // {
- // return new List<ExamInfoDto>();
- // //{
- // // List<ExamInfoDto> info = await _azureCosmos.FindByDict<ExamInfoDto>(dict);
- // // List<ExamResultDto> exams = new List<ExamResultDto>();
- // // for (int i = 0; i < info.Count; i++) {
- // // for (int j = 0; j < info[i].conditions.subject.Count; j++)
- // // {
- // // if (RedisHelper.Exists(CacheCosmosPrefix + "examResult" + info[i].conditions.subject[j]))
- // // {
- // // ExamResultDto result = RedisHelper.HGet<ExamResultDto>(CacheCosmosPrefix + "examResult" + info[i].conditions.subject[j], ShaHashHelper.GetSHA1(info[i].examCode.ToString()));
- // // //builder.Data(info);
- // // exams.Add(result);
- // // }
- // // }
- // // //初始化总分
- // // double sumPoint = 0;
- // // for (int k = 0; k < exams.Count; k++) {
- // // for (int n = exams[k].ids.Count - 1; n >= 0;n--)
- // // {
- // // if (exams[k].ids[n].Equals("0"))
- // // {
- // // exams[k].ids.Remove(exams[k].ids[n]);
- // // }
- // // }
- // // //获取总分数
- // // exams[k].result.ForEach(r =>
- // // {
- // // sumPoint += r.Sum();
- // // });
- // // info[i].realCount = exams[k].ids.Count;
- // // }
- // // info[i].piont = sumPoint / info[i].realCount;
- // // //目前单次考试权重关系和权重次数
- // // info[i].index = info[i].piont * 1 / 1;
- // // }
- // // if (RedisHelper.Instance != null)
- // // {
- // // if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- // // {
- // // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- // // }
- // // else
- // // {
- // // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- // // await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- // // }
- // // }
- // // return info;
- // //}
- // //catch (Exception e)
- // //{
- // // throw new BizException(e.Message);
- // //}
- // }
- // [HttpPost("FindExamPaper")]
- // public BaseResponse FindExamPaper(JsonElement request)
- // {
- // //Dictionary<string, object> dict = new Dictionary<string, object>();
- // /* var emobj = request.EnumerateObject();
- // while (emobj.MoveNext())
- // {
- // dict[emobj.Current.Name] = emobj.Current.Value;
- // }*/
- // request.TryGetProperty("subjectCode", out JsonElement subjectCode);
- // request.TryGetProperty("code", out JsonElement code);
- // /*dict.TryGetValue("subjectCode", out object subjectCode);
- // dict.TryGetValue("code", out object code);*/
- // ResponseBuilder builder = ResponseBuilder.custom();
- // /*if (RedisHelper.Instance != null)
- // {
- // List<Paper> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
- // ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExamPaperRedis(request.@params, request.method); });
- // }
- // else
- // {
- // List<Paper> info = await FindExamPaperRedis(request.@params, request.method);
- // builder.Data(info);
- // }*/
- // List<PaperDto> paper = new List<PaperDto>();
- // if (RedisHelper.Exists(CacheCosmosPrefix + "paperInfo" + subjectCode.ToString()))
- // {
- // PaperDto paper1 = RedisHelper.HGet<PaperDto>(CacheCosmosPrefix + "paperInfo" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
- // paper.Add(paper1);
- // builder.Data(paper);
- // }
- // {
- // return builder.build();
- // }
- // /* public async Task<List<Paper>> FindExamPaperRedis(Dictionary<string, object> dict, string method)
- // {
- // try
- // {
- // List<Paper> info = await _azureCosmos.FindByDict<Paper>(dict);
- // if (RedisHelper.Instance != null)
- // {
- // if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- // {
- // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- // }
- // else
- // {
- // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- // await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- // }
- // }
- // return info;
- // }
- // catch (Exception e)
- // {
- // throw new BizException(e.Message);
- // builder.Data(exams);
- // }
- // }
- // }*/
- // [HttpPost("FindExamAnswer")]
- // public BaseResponse FindExamAnswer(JsonElement request)
- // {
- // request.TryGetProperty("subjectCode", out JsonElement subjectCode);
- // request.TryGetProperty("code", out JsonElement code);
- // ResponseBuilder builder = ResponseBuilder.custom();
- // List<ExamAnswer> exams = new List<ExamAnswer>();
- // if (RedisHelper.Exists(CacheCosmosPrefix + "examAnswer" + subjectCode.ToString()))
- // {
- // ExamAnswer exam = RedisHelper.HGet<ExamAnswer>(CacheCosmosPrefix + "examAnswer" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
- // exams.Add(exam);
- // builder.Data(exams);
- // }
- // return builder.build();
- // }
- // public async Task<List<ExamAnswer>> FindExamAnswerRedis(Dictionary<string, object> dict, string method)
- // {
- // return new List<ExamAnswer>();
- // //try
- // //{
- // // List<ExamAnswer> info = await _azureCosmos.FindByDict<ExamAnswer>(dict);
- // // if (RedisHelper.Instance != null)
- // // {
- // // if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- // // {
- // // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- // // }
- // // else
- // // {
- // // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- // // await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- // // }
- // // }
- // // return info;
- // //}
- // //catch (Exception e)
- // //{
- // // throw new BizException(e.Message);
- // //}
- // }
- // public async Task<List<ExamAnswer>> FindExamAnswerRedis(Dictionary<string, object> dict)
- // {
- // return new List<ExamAnswer>();
- // //try
- // //{
- // // List<ExamAnswer> info = await _azureCosmos.FindByDict<ExamAnswer>(dict);
- // // if (RedisHelper.Instance != null)
- // // {
- // // if (!RedisHelper.Exists(CacheCosmosPrefix + "FindExamAnswer"))
- // // {
- // // await RedisHelper.HSetAsync(CacheCosmosPrefix + "FindExamAnswer", ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- // // }
- // // else
- // // {
- // // await RedisHelper.HSetAsync(CacheCosmosPrefix + "FindExamAnswer", ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- // // await RedisHelper.ExpireAsync(CacheCosmosPrefix + "FindExamAnswer", timeoutSeconds);
- // // }
- // // }
- // // return info;
- // //}
- // //catch (Exception e)
- // //{
- // // throw new BizException(e.Message);
- // //}
- // }
- // [HttpPost("HomeStatistics")]
- // public async Task<BaseResponse> HomeStatistics(JsonElement request)
- // {
- // ResponseBuilder builder = ResponseBuilder.custom();
- // Dictionary<string, object> dict = new Dictionary<string, object>();
- // var emobj = request.EnumerateObject();
- // while (emobj.MoveNext())
- // {
- // dict[emobj.Current.Name] = emobj.Current.Value;
- // }
- // List<Dictionary<string, dynamic>> info = new List<Dictionary<string, dynamic>>();
- // if (RedisHelper.Instance != null)
- // {
- // info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "HomeStatistics",
- // ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindHomeStatisticsRedis(dict, "HomeStatistics"); });
- // //数据从redis读取过后进行转换格式
- // builder.Data(info);
- // }
- // else
- // {
- // info = await FindHomeStatisticsRedis(dict, "HomeStatistics");
- // builder.Data(info);
- // }
- // return builder.build();
- // }
- // public async Task<List<Dictionary<string, dynamic>>> FindHomeStatisticsRedis(Dictionary<string, object> dict, string method)
- // {
- // return new List<Dictionary<string, dynamic>>();
- // //request.@params.TryGetValue("subjectCode", out object subjectCode);
- // // dict.TryGetValue("schoolCode", out object schoolCode);
- // // dict.TryGetValue("code", out object code);
- // // Dictionary<string, object> eMap = new Dictionary<string, object>
- // // {
- // // { "code", code.ToString()}
- // // };
- // // Dictionary<string, object> SCMap = new Dictionary<string, object>
- // // {
- // // { "id", schoolCode.ToString()},
- // // };
- // // //说明 同学校、同类型考试数据
- // // //List<ExamInfo> exams = await azureCosmosDBRepository.FindByDict<ExamInfo>(eMap);
- // // List<ExamInfoDto> exams = new List<ExamInfoDto>();
- // // if (RedisHelper.Instance != null)
- // // {
- // // exams = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "FindExamInfo",
- // // ShaHashHelper.GetSHA1(eMap.ToJsonString()), timeoutSeconds, () => { return FindExamInfoRedis(eMap, "FindExamInfo"); });
- // // }
- // // else
- // // {
- // // exams = await FindExamInfoRedis(eMap, "FindExamInfo");
- // // }
- // // List<ExamInfoDto> newInfo = new List<ExamInfoDto>();
- // // //获取各个学段最新的考试信息
- // // foreach (IGrouping<string, ExamInfoDto> group in exams.GroupBy(c => c.conditions.grade))
- // // {
- // // ExamInfoDto examInfo = group.ToList().OrderByDescending(e => e.createTime).ToList().FirstOrDefault();
- // // newInfo.Add(examInfo);
- // // };
- // // //newInfo.Select(e => e.type.Equals("union"));
- // // //List<ExamInfo> unionInfo = newInfo.Where(e => e.type.Equals("union")).ToList();
- // // //exams.GroupBy(e => e.conditions.period);
- // // //ExamInfo info = exams.OrderByDescending(e => e.createTime).ToList().FirstOrDefault();
- // // //查询学校对应的年级信息
- // // List<School> schools = await _azureCosmos.FindByDict<School>(SCMap);
- // // //List<School> schools = new List<School>();
- // ///* if (RedisHelper.Exists(CacheCosmosPrefix + "schoolInfo"))
- // // {
- // // School sc = RedisHelper.HGet<School>(CacheCosmosPrefix + "schoolInfo",
- // // ShaHashHelper.GetSHA1(schoolCode.ToString()));
- // // schools.Add(sc);
- // // }*/
- // // string Period = "";
- // // string Grade = "";
- // // //List<double> CoreAverage = new List<double>();
- // // try
- // // {
- // // List<Period> periods = new List<Period>();
- // // List<Grade> grades = new List<Grade>();
- // // foreach (School s in schools)
- // // {
- // // periods = s.period;
- // // }
- // // periods.ForEach(p =>
- // // {
- // // p.grades.ForEach(g => {
- // // grades.Add(g);
- // // });
- // // /*if (p.periodCode.Equals("初中"))
- // // {
- // // grades = p.grades;
- // // }
- // // else if (p.periodCode.Equals("高中"))
- // // {
- // // grades = p.grades;
- // // }
- // // else
- // // {
- // // grades = p.grades;
- // // }*/
- // // });
- // // List<Dictionary<string, object>> map = new List<Dictionary<string, object>>();
- // // //循环处理不同年级考试信息
- // // foreach (Grade g in grades)
- // // {
- // // double weightSum = 0;
- // // List<double> CoreAverage = new List<double>();
- // // List<List<List<string>>> AllPoint = new List<List<List<string>>>();
- // // List<List<List<string>>> AllPointAverage = new List<List<List<string>>>();
- // // List<List<List<string>>> AllKeyLine = new List<List<List<string>>>();
- // // HashSet<string> classList = new HashSet<string>();
- // // HashSet<string> subjectList = new HashSet<string>();
- // // for (int i = 0; i < newInfo.Count; i++)
- // // {
- // // if (g.id.Equals(newInfo[i].conditions.grade))
- // // {
- // // List<ExamResultDto> simples = new List<ExamResultDto>();
- // // for (int j = 0; j < newInfo[i].conditions.subject.Count; j++)
- // // {
- // // ExamResultDto result = new ExamResultDto();
- // // if (RedisHelper.Exists(CacheCosmosPrefix + "examResult" + newInfo[i].conditions.subject[j]))
- // // {
- // // result = RedisHelper.HGet<ExamResultDto>(CacheCosmosPrefix + "examResult" + newInfo[i].conditions.subject[j],
- // // ShaHashHelper.GetSHA1(newInfo[i].examCode));
- // // simples.Add(result);
- // // }
- // // //List<ExamResult> examResults = new List<ExamResult>();
- // // /*Dictionary<string, object> sub = new Dictionary<string, object>
- // // {
- // // { "code", newInfo[i].id}
- // // };*/
- // // Period = newInfo[i].conditions.period;
- // // Grade = newInfo[i].conditions.grade;
- // // List<string> subjects = new List<string>();
- // // List<List<string>> SubjectClassAverage = new List<List<string>>();
- // // List<List<string>> SubjectAverage = new List<List<string>>();
- // // //List<List<string>> SubjectClassAverage = new List<List<string>>();
- // // //List<ExamResult> simples = await azureCosmosDBRepository.FindByDict<ExamResult>(sub);
- // }
- // }
- // // // 学生总分
- // // double coreSum = 0;
- // // int stuCount = newInfo[i].stuCount;
- // // //int stuCount = 0;
- // // //初始化进行人数
- // // double iPersons = 0;
- // // //
- // // List<List<double>> subSum = new List<List<double>>();
- // // if (simples.IsEmpty()) continue;
- // // double weight = 0.5;
- // // weightSum += weight;
- // // int classLen = simples[0].classes.Count;
- // // for (int cls = 0; cls < classLen; cls++)
- // // {
- // // if (simples[0].classes[cls].TryGetValue(simples[0].classes[cls].Keys.ToArray<string>()[0], out int[] indexs))
- // // {
- // // List<double> stuScore = new List<double>();
- // // int stdLen = indexs[1] - indexs[0] + 1;
- // // for (int n = 0; n < stdLen; n++)
- // // {
- // // stuScore.Add(0);
- // // }
- // // subSum.Add(stuScore);
- // // }
- // // }
- // // simples.ForEach(s =>
- // // {
- // // subjectList.Add(s.subjectCode);
- // // //计算试卷总分
- // // double sum = s.point.Sum();
- // // //int stuSum = 0;
- // // int classIndex = 0;
- // // List<string> ClassAverage = new List<string>();
- // // List<string> Average = new List<string>();
- // // List<string> passList = new List<string>();
- // // s.classes.ForEach(c =>
- // // {
- // // List<List<string>> classPRL = new List<List<string>>();
- // // //初始化班级总分
- // // double classPoint = 0;
- // // //初始化班级缺考人数
- // // int classCount = 0;
- // // //初始化班级平均得分率
- // // double points = 0;
- // // //初始化班级平均得分率
- // // double AveragePoints = 0;
- // // //初始化各班参考人数
- // // int counts = 0;
- // // //c.Keys遍历key值
- // // foreach (string key in c.Keys)
- // // {
- // // classList.Add(key);
- // // }
- // // //每个班级平均分
- // // foreach (int[] value in c.Values)
- // // {
- // // for (int i = value[0]; i <= value[1]; i++)
- // // {
- // // //初始化学生单科个人得分
- // // double stuPoints = s.result[i].Sum();
- // // subSum[classIndex][i - value[0]] = stuPoints + subSum[classIndex][i - value[0]];
- // // classPoint += s.result[i].Sum();
- // // coreSum += s.result[i].Sum();
- // // if (s.result[i].Sum() == 0)
- // // {
- // // classCount++;
- // // }
- // // }
- // // //每个班级实际参考人数
- // // counts = value[1] - value[0] + 1;
- // // //stuSum += counts;
- // // //stuCount += counts;
- // // points = Convert.ToDouble(classPoint) / counts / sum;
- // // //计算每个班级平均得分
- // // AveragePoints = Convert.ToDouble(classPoint) / counts;
- // // ClassAverage.Add(points.ToString("0.000"));
- // // Average.Add(AveragePoints.ToString());
- // // }
- // // classIndex += 1;
- // // });
- // // SubjectClassAverage.Add(ClassAverage);
- // // SubjectAverage.Add(Average);
- // // //subAverage = subjectPoint / ClassAverage.Count();
- // // //subjectAverage.Add(subAverage.ToString("0.00"));
- // // });
- // // //获取进线人数
- // // iPersons = stuCount / classList.Count * 0.4;
- // // //权重配分 学生总平均分 * 权重配分
- // // double core = coreSum / stuCount * weight;
- // // CoreAverage.Add(core);
- // // AllPoint.Add(SubjectClassAverage);
- // // AllPointAverage.Add(SubjectAverage);
- // // //处理人数为整
- // // string ip = iPersons.ToString("0");
- // // //初始化进线分数
- // // int ipoint = 0;
- // // List<int> AllPoints = new List<int>();
- // // foreach (List<double> points in subSum)
- // // {
- // // foreach (int po in points)
- // // {
- // // AllPoints.Add(po);
- // // }
- // // }
- // // for (int sn = 0; sn < subSum.Count; sn++)
- // // {
- // // for (int j = 0; j < subSum[sn].Count; j++)
- // // {
- // // if (subSum[sn][j].Equals("0"))
- // // {
- // // subSum[sn].Remove(subSum[sn][j]);
- // // }
- // // }
- // // }
- // // //计算成绩年级排名
- // // AllPoints.Sort(delegate (int s1, int s2) { return s2.CompareTo(s1); });
- // // ipoint = AllPoints[int.Parse(ip)];
- // // int m = 0;
- // // List<List<string>> KeyLine = new List<List<string>>();
- // // foreach (List<double> points in subSum)
- // // {
- // // List<string> detail = new List<string>();
- // // double sum = points.Count;
- // // int l = 0;
- // // for (int mq = 0; mq < points.Count; mq++)
- // // {
- // // if (points[mq] >= ipoint)
- // // {
- // // l++;
- // // }
- // // }
- // // double Lines = l;
- // // detail.Add(Lines.ToString());
- // // detail.Add(points.Count.ToString());
- // // var t3 = Math.Floor(Math.Round(decimal.Parse((Lines / sum).ToString("0.000")), 2) * 100);
- // // detail.Add(t3.ToString());
- // // KeyLine.Add(detail);
- // // m++;
- // // }
- // // AllKeyLine.Add(KeyLine);
- // // }
- // // else {
- // // continue;
- // // }
- // // //年级成就指标
- // // if (weightSum == 0)
- // // {
- // // weightSum = 1;
- // // }
- // // double index = CoreAverage.Sum() / weightSum;
- // // List<List<double>> AveragePoint = new List<List<double>>();
- // // List<List<double>> AverageClassPoint = new List<List<double>>();
- // // //List<double> ClassCore = new List<double>();
- // // int k = AllPoint.Count;
- // // if (k > 0)
- // // {
- // // for (int m = 0; m < AllPoint[0].Count; m++)
- // // {
- // // List<double> SubjectAverage = new List<double>();
- // // for (int n = 0; n < AllPoint[0][m].Count; n++)
- // // {
- // // double startPoint = 0;
- // // for (int f = 0; f < k; f++)
- // // {
- // // startPoint = double.Parse(AllPoint[f][m][n]) + startPoint;
- // // }
- // // SubjectAverage.Add(startPoint / k);
- // // }
- // // AveragePoint.Add(SubjectAverage);
- // // }
- // // }
- // // //每个班级成就指标
- // // int p = AllPointAverage.Count;
- // // if (p > 0)
- // // {
- // // for (int m = 0; m < AllPointAverage[0].Count; m++)
- // // {
- // // List<double> SubjectAverage = new List<double>();
- // // for (int n = 0; n < AllPointAverage[0][m].Count; n++)
- // // {
- // // double startPoint = 0;
- // // for (int f = 0; f < k; f++)
- // // {
- // // startPoint = double.Parse(AllPointAverage[f][m][n]) + startPoint;
- // // }
- // // SubjectAverage.Add(startPoint / k);
- // // }
- // // AverageClassPoint.Add(SubjectAverage);
- // // }
- // // }
- // // int c = AverageClassPoint.Count;
- // // List<double> ClassCore = new List<double>();
- // // if (c > 0)
- // // {
- // // for (int j = 0; j < AverageClassPoint[0].Count; j++)
- // // {
- // // double startAverage = 0;
- // // for (int f = 0; f < c; f++)
- // // {
- // // startAverage = AverageClassPoint[f][j] + startAverage;
- // // }
- // // ClassCore.Add(startAverage / c / weightSum);
- // // }
- // // }
- // // //班级平均进线率
- // // int ExamCount = AllKeyLine.Count;
- // // List<List<double>> KeyLines = new List<List<double>>();
- // // if (ExamCount > 0)
- // // {
- // // for (int m = 0; m < AllKeyLine[0].Count; m++)
- // // {
- // // List<double> ClassLine = new List<double>();
- // // for (int n = 0; n < AllKeyLine[0][m].Count; n++)
- // // {
- // // double startPoint = 0;
- // // for (int f = 0; f < ExamCount; f++)
- // // {
- // // startPoint = double.Parse(AllKeyLine[f][m][n]) + startPoint;
- // // }
- // // ClassLine.Add(startPoint / ExamCount);
- // // }
- // // KeyLines.Add(ClassLine);
- // // }
- // // }
- // // Dictionary<string, object> AveragePointMap = new Dictionary<string, object>
- // // {
- // // { "Period",Period},
- // // { "Grade",Grade},
- // // { "index", index},
- // // { "className", classList },
- // // { "subjectName", subjectList },
- // // { "AveragePoint", AveragePoint },
- // // //{ "AverageClassPoint", AverageClassPoint },
- // // { "ClassCore", ClassCore },
- // // { "KeyLines",KeyLines}
- // // };
- // // map.Add(AveragePointMap);
- // // }
- // // }
- // // //Redis处理结果集
- // // if (RedisHelper.Instance != null)
- // // {
- // // if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- // // {
- // // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), map);
- // // }
- // // else
- // // {
- // // await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), map);
- // // await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- // // }
- // // }
- // // return map;
- // // }
- // // catch (Exception e)
- // // {
- // // throw new BizException(e.Message);
- // // }
- //}
- //[HttpPost("getAnalysis")]
- //public async Task<IActionResult> getAnalysis(JsonElement request)
- //{
- // //获取评测的ID
- // if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
- // if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- // try
- // {
- // var client = _azureCosmos.GetCosmosClient();
- // //获取本次评测所有科目结算结果
- // ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
- // School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
- // List<ExamResult> examResults = new List<ExamResult>();
- // var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId = '{id}' ";
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
- // {
- // /*using var json = await JsonDocument.ParseAsync(item.Content);
- // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- // {
- // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- // {
- // examResults.Add(obj.ToObject<ExamResult>());
- // }
- // }*/
- // examResults.Add(item);
- // }
- // //获取本次评测所有班级作答结果
- // List<ExamClassResult> examClassResults = new List<ExamClassResult>();
- // var queryClass = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.gradeId,c.info from c where c.examId = '{id}' and c.progress = true ";
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
- // {
- // examClassResults.Add(item);
- // /*using var json = await JsonDocument.ParseAsync(item.Content);
- // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- // {
- // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- // {
- // examClassResults.Add(obj.ToObject<ExamClassResult>());
- // }
- // }*/
- // }
- // //获取进线标准
- // int touch = 0;
- // foreach (Period period in school.period)
- // {
- // if (info.period.id.Equals(period.id))
- // {
- // touch = period.analysis.touch;
- // }
- // }
- // int personCount = (int)System.Math.Round(info.stuCount * (touch / 100.0), MidpointRounding.AwayFromZero);
- // if (info.period.id.Equals(period.id))
- // StudentAnalysis analysis = new StudentAnalysis();
- // List<ClassAnalysis> classAnalyses = new List<ClassAnalysis>();
- // /* //声明年级所有科目总分
- // List<double> total = new List<double>();*/
- // //以班级为单位
- // List<double> stuTotals = new List<double>();
- // List<dynamic> classes = new List<dynamic>();
- // HashSet<string> idName = new HashSet<string>();
- // foreach (ExamResult examResult in examResults)
- // {
- // foreach (string ids in examResult.studentIds)
- // {
- // idName.Add(ids);
- // }
- // }
- // foreach (string s in info.classes)
- // {
- // //存放每个班级学生总分
- // List<double> totalClass = new List<double>();
- // ClassAnalysis classAnalysis = new ClassAnalysis();
- // classAnalysis.classId = s;
- // var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(s, new PartitionKey($"Class-{code}"));
- // if (sresponse.StatusCode==System.Net.HttpStatusCode.OK)
- // {
- // using var json = await JsonDocument.ParseAsync(sresponse.Content);
- // Class classroom = json.ToObject<Class>();
- // classes.Add(new { name = classroom.name, id = s });
- // //初始化参考人数
- // int count = 0;
- // //处理班级学生名单
- // List<Student> students = new List<Student>();
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIteratorSql<Student>(queryText: $"select c.id from c where c.classId = '{classroom.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{code}") }))
- // {
- // students.Add(item);
- // }
- // foreach (Student stu in students)
- // {
- // if (idName.Contains(stu.id))
- // {
- // count++;
- // }
- // else
- // {
- // continue;
- // }
- // classAnalysis.studentIds.Add(stu.id);
- // analysis.names.Add(stu.name);
- // analysis.ids.Add(stu.id);
- // //计算学生多科考试成绩总分
- // double stuTotal = 0;
- // foreach (ExamResult examResult in examResults)
- // {
- // int index = examResult.studentIds.IndexOf(stu.id);
- // if (index >= 0)
- // {
- // stuTotal = stuTotal + examResult.studentScores[index].Sum();
- // }
- // }
- // classAnalysis.total.Add(stuTotal);
- // analysis.total.Add(stuTotal);
- // stuTotals.Add(stuTotal);
- // totalClass.Add(stuTotal);
- // //total.Add(stuTotal);
- // }
- // classAnalysis.stuCount = count;
- // }
- // /* //声明单个班级单科总分
- // double subjectTotal = 0;*/
- // info.subjects.ForEach(sub =>
- // {
- // //初始化及格人数
- // int i = 0;
- // //初始化单科总分
- // double sumClass = 0;
- // //记录每个科目数据
- // SubjectScore subjectScore = new SubjectScore();
- // subjectScore.id = sub.id;
- // double subjectSum = 0;
- // double passScore = 0;
- // //计算单科评测总分
- // foreach (ExamResult examResult in examResults)
- // {
- // if (sub.id.Equals(examResult.subjectId))
- // {
- // subjectSum = examResult.paper.point.Sum();
- // }
- // }
- // //单科及格率分数
- // passScore = subjectSum * 0.6;
- // //存放学生单科记录
- // Score score = new Score();
- // score.subjectId = sub.id;
- // List<double> subjectTotal = new List<double>();
- // //处理每个班级各个学生各科总分
- // foreach (ExamClassResult result in examClassResults)
- // {
- // if (sub.id.Equals(result.subjectId) && s.Equals(result.info.id))
- // {
- // foreach (List<double> scores in result.studentScores)
- // {
- // //添加每个学生各科总分
- // score.csc.Add(scores.Sum());
- // //计算大于及格分数的人数
- // if (scores.Sum() >= passScore)
- // {
- // i++;
- // }
- // //totalClass.Add(scores.Sum());
- // subjectTotal.Add(scores.Sum());
- // sumClass = sumClass + scores.Sum();
- // }
- // //处理班级及格率以及均分
- // double percentClass = i / (result.studentIds.Count * 1.0);
- // double averageClass = sumClass / (result.studentIds.Count * 1.0);
- // //total += averageClass;
- // subjectScore.passPercent = percentClass;
- // subjectScore.averageScore = averageClass;
- // classAnalysis.subjects.Add(subjectScore);
- // //analysis.scores.Add(score);
- // }
- // }
- // //处理单科科班级PR
- // subjectTotal.Sort(delegate (double s1, double s2) { return s2.CompareTo(s1); });
- // foreach (double sc in score.csc)
- // {
- // int index = subjectTotal.IndexOf(sc);
- // double CPR = 100 - (100 * (index + 1) - 50) / score.csc.Count;
- // score.cdpr.Add(CPR);
- // {
- // }
- // analysis.scores.Add(score);
- // });
- // //处理全科班级PR
- // totalClass.Sort(delegate (double s1, double s2) { return s2.CompareTo(s1); });
- // foreach (double pr in classAnalysis.total)
- // {
- // int index = totalClass.IndexOf(pr);
- // double CPR = 100 - (100 * (index + 1) - 50) / classAnalysis.total.Count;
- // analysis.cpr.Add(CPR);
- // }
- // classAnalyses.Add(classAnalysis);
- // }
- // /*info.targetClassIds.ForEach( async s => {
- // });*/
- // //初始化进线分数
- // double ipoint = 0;
- // stuTotals.Sort(delegate (double s1, double s2) { return s2.CompareTo(s1); });
- // ipoint = stuTotals[personCount];
- // //补充班级总平均分/进行人数/标准差
- // foreach (ClassAnalysis classAnalysis in classAnalyses)
- // {
- // //初始化进线人数
- // int i = 0;
- // //初始化班级总分
- // double score = 0;
- // //标准差
- // double powSum = 0;
- // foreach (double sc in classAnalysis.total)
- // {
- // if (sc > ipoint)
- // {
- // i++;
- // }
- // score = score + sc;
- // }
- // //总平均分
- // double totalAverage = 0;
- // totalAverage = score / classAnalysis.stuCount;
- // //计算标准差
- // foreach (double sc in classAnalysis.total)
- // {
- // powSum += Math.Pow(sc - totalAverage, 2);
- // }
- // var pow = Math.Pow(powSum / classAnalysis.stuCount, 0.5);
- // classAnalysis.standardDeviation = pow;
- // classAnalysis.totalAverage = totalAverage;
- // classAnalysis.lineCount = i;
- // }
- // //处理全科年级PR值
- // foreach (double no in analysis.total)
- // {
- // int index = stuTotals.IndexOf(no);
- // int GPR = 100 - (100 * (index + 1) - 50) / analysis.total.Count;
- // analysis.gpr.Add(GPR);
- // }
- // List<GradeAnalysis> gradeAnalyses = new List<GradeAnalysis>();
- // List<Dictionary<string, dynamic>> PointAnalysis = new List<Dictionary<string, dynamic>>();
- // List<Dictionary<string, dynamic>> exerciseScatter = new List<Dictionary<string, dynamic>>();
- // List<Dictionary<string, dynamic>> KnowledgePoint = new List<Dictionary<string, dynamic>>();
- // if (info.grades.Count > 0)
- // {
- // gradeAnalyses = GetGradeAnalyses(info, examResults, examClassResults, analysis);
- // PointAnalysis = getPointAnalysis(examResults, info);
- // exerciseScatter = getExerciseScatter(examResults, info);
- // KnowledgePoint = getKnowledgePoint(examResults, info);
- // }
- // return Ok(new { analysis, classAnalyses, gradeAnalyses, PointAnalysis, exerciseScatter, KnowledgePoint });
- // }
- // catch (Exception e)
- // {
- // await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/getAnalysis()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- // return BadRequest();
- // }
- // foreach (double sc in classAnalysis.total)
- // KnowledgePoint = getKnowledgePoint(examResults, info);
- //}
- //private List<GradeAnalysis> GetGradeAnalyses(ExamInfo info, List<ExamResult> examResults, List<ExamClassResult> examClassResults, StudentAnalysis analysis)
- //{
- // List<GradeAnalysis> gradeAnalyses = new List<GradeAnalysis>();
- // info.grades.ForEach(g =>
- // {
- // GradeAnalysis gradeAnalysis = new GradeAnalysis();
- // gradeAnalysis.gradeId = g.id;
- // //初始化单个年级总分
- // double gradeScore = 0;
- // info.subjects.ForEach(sub =>
- // {
- // //初始化及格人数
- // int i = 0;
- // //初始化年级人数
- // int count = 0;
- // //初始化单科总分
- // double sumClass = 0;
- // //记录每个科目数据
- // GradeSubjectScore subjectScore = new GradeSubjectScore();
- // subjectScore.id = sub.id;
- // double subjectSum = 0;
- // double passScore = 0;
- // //计算单科评测总分
- // foreach (ExamResult examResult in examResults)
- // {
- // if (sub.id.Equals(examResult.subjectId))
- // {
- // subjectSum = examResult.paper.point.Sum();
- // }
- // }
- // //单科及格率分数
- // passScore = subjectSum * 0.6;
- // List<double> subjectTotal = new List<double>();
- // //存放单科每个班级学生总分
- // List<double> totalClass = new List<double>();
- // //存放学生单科记录
- // foreach (Score score in analysis.scores)
- // {
- // if (score.subjectId.Equals(sub.id))
- // {
- // //处理每个班级各个学生各科总分
- // foreach (ExamClassResult result in examClassResults)
- // {
- // if (sub.id.Equals(result.subjectId) && g.id.Equals(result.gradeId))
- // {
- // foreach (List<double> scores in result.studentScores)
- // {
- // //添加每个学生各科总分
- // score.gsc.Add(scores.Sum());
- // //计算大于及格分数的人数
- // if (scores.Sum() >= passScore)
- // {
- // i++;
- // }
- // subjectTotal.Add(scores.Sum());
- // sumClass = sumClass + scores.Sum();
- // if (sub.id.Equals(result.subjectId) && g.id.Equals(result.gradeId))
- // }
- // count += result.studentIds.Count;
- // }
- // }
- // //处理班级及格率以及均分
- // double persentClass = i / (count * 1.0);
- // double averageClass = sumClass / (count * 1.0);
- // gradeScore += averageClass;
- // subjectScore.passPercent = persentClass;
- // subjectScore.averageScore = averageClass;
- // gradeAnalysis.subjects.Add(subjectScore);
- // gradeAnalyses.Add(gradeAnalysis);
- // //处理单科科年级PR
- // subjectTotal.Sort(delegate (double s1, double s2) { return s2.CompareTo(s1); });
- // foreach (double sc in score.gsc)
- // {
- // int index = subjectTotal.IndexOf(sc);
- // double GPR = 100 - (100 * (index + 1) - 50) / score.gsc.Count;
- // score.gdpr.Add(GPR);
- // //analysis.gpr.Add(GPR);
- // }
- // //analysis.scores.Add(score);
- // }
- // }
- // });
- // foreach (GradeAnalysis grade in gradeAnalyses)
- // {
- // grade.GradeaverageScore = gradeScore / grade.subjects.Count;
- // }
- // });
- // return gradeAnalyses;
- //}
- //analysis.gpr.Add(GPR);
- // }
- // //落点分析
- // private List<Dictionary<string, dynamic>> getPointAnalysis(List<ExamResult> exams, ExamInfo exam)
- //{
- // List<Dictionary<string, dynamic>> scatterAnalysis = new List<Dictionary<string, dynamic>>();
- // List<string> key = new List<string>
- // {
- // "name",
- // "className",
- // "x",
- // "y",
- // "memberId",
- // "score",
- // "trueNum",
- // "falseNum",
- // "hardList",
- // "carefulList",
- // "scatter"
- // };
- // //key.Add("areaName");
- // if (exams.Count > 0)
- // {
- // /* //提取班级信息
- // List<Dictionary<string, int[]>> classToName = exams[0].classes;
- // //提取学生ID信息
- // List<string> idToName = exams[0].ids;*/
- // exams.ForEach(e =>
- // {
- // Dictionary<string, object> detail = new Dictionary<string, object>
- // {
- // { "keys", key }
- // };
- // List<List<string>> datas = new List<List<string>>();
- // Dictionary<string, object> subject = new Dictionary<string, object>
- // {
- // { "name", e.subjectId }
- // };
- // double[] point = StringHelper.ListTodouble(e.paper.point);
- // double[,] result = StringHelper.ListToDouble(e.studentScores);
- // try
- // {
- // var cdm = new ClouDASMatrix(result, point);
- // //学生通过率
- // List<double> pass = cdm.PassingRate;
- // //学生稳定度
- // List<double> sta = cdm.StabilityRate;
- // //落点区域
- // List<string> stu = cdm.StuFallArea;
- // //需努力的题型
- // List<int[]> strive = cdm.StriveTopic;
- // //需小心的题型
- // List<int[]> careful = cdm.CarefulTopic;
- // int i = 0;
- // for (int k = e.studentIds.Count - 1; k >= 0; k--)
- // {
- // if (e.studentIds[k].Equals("0"))
- // {
- // e.studentIds.Remove(e.studentIds[k]);
- // }
- // }
- // e.studentIds.ForEach(s =>
- // {
- // if (e.studentScores[i].Sum() != 0)
- // {
- // List<string> info = new List<string>
- // {
- // s,
- // "-",
- // sta[i].ToString(),
- // pass[i].ToString(),
- // i + 1 + "",
- // e.studentScores[i].Sum().ToString()
- // };
- // int right = 0;
- // int wrong = 0;
- // foreach (int p in e.studentScores[i])
- // {
- // if (p > 0)
- // {
- // right++;
- // }
- // else
- // {
- // wrong++;
- // }
- // }
- // info.Add(right + "");
- // info.Add(wrong + "");
- // int[] str = strive[i];
- // string striveAll = "";
- // if (p > 0)
- // {
- // right++;
- // }
- // else
- // {
- // wrong++;
- // }
- // }
- // info.Add(right + "");
- // info.Add(wrong + "");
- // int[] str = strive[i];
- // string striveAll = "";
- // foreach (int n in str)
- // {
- // striveAll += n.ToString() + ",";
- // }
- // int[] care = careful[i];
- // string careAll = "";
- // foreach (int n in care)
- // {
- // careAll += n.ToString() + ",";
- // }
- // if (string.IsNullOrEmpty(striveAll))
- // {
- // info.Add("无");
- // }
- // else
- // {
- // info.Add(striveAll.Substring(0, striveAll.Length - 1));
- // }
- // if (string.IsNullOrEmpty(careAll))
- // {
- // info.Add("无");
- // }
- // else
- // {
- // info.Add(careAll.Substring(0, careAll.Length - 1)); ;
- // }
- // info.Add(stu[i].ToString());
- // datas.Add(info);
- // }
- // i++;
- // });
- // });
- //return scatterAnalysis;
- // }
- // else return scatterAnalysis;
- // }
- // catch (Exception ex)
- // private List<Dictionary<string, dynamic>> getExerciseScatter(List<ExamResult> exams, ExamInfo exam)
- //{
- // /* ResponseBuilder builder = ResponseBuilder.custom();*/
- // List<string> classList = new List<string>();
- // List<Dictionary<string, object>> exerciseScatter = new List<Dictionary<string, object>>();
- // //Dictionary<string, object> scatterAnalysis = new Dictionary<string, object>();
- // classList = exam.classes;
- // List<string> key = new List<string>
- // {
- // "id",
- // "type",
- // "areaName",
- // "score",
- // "diff",
- // "identify",
- // "classScoreRate",
- // "gradeScoreRate",
- // "areaScoreRate",
- // "highScoreRate",
- // "lowScoreRate",
- // "knowledgePoint",
- // "R1",
- // "R2",
- // "R3",
- // "R4",
- // "R5",
- // "R6",
- // "PH",
- // "PL",
- // "X",
- // "Y",
- // "knowledge"
- // };
- // if (exams.IsNotEmpty())
- // {
- // exams.ForEach(e =>
- // {
- // List<double> gradeAnswer = new List<double>();
- // List<string> grasdepersent = new List<string>();
- // for (int n = 0; n < e.paper.point.Count; n++)
- // {
- // gradeAnswer.Add(0);
- // }
- // //参考人数
- // double Qnum = 0;
- // e.studentIds.ForEach(i =>
- // {
- // if (!i.Equals("0"))
- // {
- // Qnum++;
- // }
- // });
- // /* Dictionary<string, object> detail = new Dictionary<string, object>
- // {
- // { "keys", key }
- // };*/
- // List<List<string>> datas = new List<List<string>>();
- // List<string[]> itemAnalysis = new List<string[]>();
- // Dictionary<string, object> subject = new Dictionary<string, object>
- // {
- // { "name", e.subjectId }
- // };
- // Dictionary<string, object> classPersent = new Dictionary<string, object>();
- // List<List<string>> classdatas = new List<List<string>>();
- // try
- // {
- // e.classes.ForEach(c =>
- // {
- // //初始化每题得分情况
- // List<int> answerCount = new List<int>();
- // List<string> persent = new List<string>();
- // double peopleCount = 0;
- // for (int n = 0; n < e.paper.point.Count; n++)
- // {
- // answerCount.Add(0);
- // }
- // int qCount = 0;
- // //int right = 0;
- // /* //c.Keys遍历key值
- // foreach (string keys in c.Keys)
- // {
- // classList.Add(keys);
- // }*/
- // //每个班级得分占比
- // double peopleCount = 0;
- // for (int i = c.range[0]; i <= c.range[1]; i++)
- // {
- // if (e.studentScores[i].Sum() > 0)
- // {
- // for (int j = 0; j < e.studentScores[i].Count; j++)
- // {
- // if (e.studentScores[i][j] > 0)
- // {
- // //记录班级每题得分数
- // answerCount[j] = answerCount[j] + 1;
- // //记录年级每题得分数
- // gradeAnswer[j] = gradeAnswer[j] + 1;
- // //right++;
- // }
- // }
- // }
- // else
- // {
- // qCount++;
- // }
- // 记录班级每题得分数
- // peopleCount = c.range[1] - c.range[0] + 1 - qCount;
- // }
- // foreach (int p in answerCount)
- // {
- // var t = Math.Floor(Math.Round(decimal.Parse((p * 1.0 / peopleCount).ToString("0.000")), 2) * 100);
- // persent.Add(t.ToString());
- // }
- // }
- // else
- // {
- // qCount++;
- // }
- // peopleCount = c.range[1] - c.range[0] + 1 - qCount;
- // }
- // double[] point = StringHelper.ListTodouble(e.paper.point);
- // double[,] result = StringHelper.ListToDouble(e.studentScores);
- // var cdm = new ClouDASMatrix(result, point);
- // //试题Y
- // List<double> answer = cdm.AnswerRate;
- // //试题X
- // List<double> quality = cdm.QualityRate;
- // //试题区域
- // List<string> topic = cdm.TopicFallArea;
- // //试题相关分析结果
- // List<(double Diff, double Identify, double R1, double R2, double R3, double R4, double R5, double R6, double RH, double RL)> rs = cdm.RS;
- // for (int i = 0; i < rs.Count; i++)
- // {
- // string[] ex = new string[] { };
- // string ss = rs[i].ToString()[1..^1];
- // ex = ss.Split(",");
- // itemAnalysis.Add(ex);
- // }
- // foreach (int p in gradeAnswer)
- // {
- // var t = Math.Floor(Math.Round(decimal.Parse((p / Qnum).ToString("0.000")), 2) * 100);
- // grasdepersent.Add(t.ToString());
- // }
- // for (int k = 0; k < e.paper.point.Count; k++)
- // {
- // List<string> values = new List<string>();
- // key.ForEach(x =>
- // {
- // values.Add("-");
- // });
- // values[0] = (k + 1).ToString();
- // values[1] = "";
- // values[2] = topic[k].ToString();
- // values[3] = e.paper.point[k].ToString();
- // if (itemAnalysis.Count > 0)
- // {
- // values[4] = itemAnalysis[k][0];
- // values[5] = itemAnalysis[k][1];
- // values[12] = itemAnalysis[k][2];
- // values[13] = itemAnalysis[k][3];
- // values[14] = itemAnalysis[k][4];
- // values[15] = itemAnalysis[k][5];
- // values[16] = itemAnalysis[k][6];
- // values[17] = itemAnalysis[k][7];
- // values[18] = itemAnalysis[k][8];
- // values[19] = itemAnalysis[k][9];
- // }
- // else
- // {
- // values[4] = "-";
- // values[5] = "-";
- // values[12] = "-";
- // values[13] = "-";
- // values[14] = "-";
- // values[15] = "-";
- // values[16] = "-";
- // values[17] = "-";
- // values[18] = "-";
- // values[19] = "-";
- // }
- // values[7] = grasdepersent[k];
- // values[8] = grasdepersent[k];
- // values[20] = quality[k].ToString();
- // values[21] = answer[k].ToString();
- // string pointName = "";
- // /*if (paper[0].item[k].points.Count == 1)
- // {
- // foreach (string index in paper[0].item[k].points)
- // {
- // pointName = index;
- // }
- // }
- // else if (paper[0].item[k].points.Count > 1)
- // {
- // foreach (string index in paper[0].item[k].points)
- // {
- // pointName += index + ",";
- // }
- // }*/
- // values[22] = pointName;
- // datas.Add(values);
- // {
- // pointName = index;
- // }
- // }
- // else if (paper[0].item[k].points.Count > 1)
- // {
- // foreach (string index in paper[0].item[k].points)
- // {
- // pointName += index + ",";
- // }
- // }
- // */
- // values[22] = pointName;
- // datas.Add(values);
- // });
- // return exerciseScatter;
- // }
- // else return exerciseScatter;
- //}
- //[HttpPost("answer")]
- //public async Task<IActionResult> answer(JsonElement request)
- //{
- // //获取评测的ID
- // if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
- // if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- // try
- // {
- // var client = _azureCosmos.GetCosmosClient();
- // //获取本次评测所有科目结算结果
- // ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
- // School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
- // List<ExamResult> examResults = new List<ExamResult>();
- // var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId = '{id}' ";
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
- // {
- // /*using var json = await JsonDocument.ParseAsync(item.Content);
- // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- // {
- // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- // {
- // examResults.Add(obj.ToObject<ExamResult>());
- // }
- // }*/
- // examResults.Add(item);
- // }
- // //获取本次评测所有班级作答结果
- // List<ExamClassResult> examClassResults = new List<ExamClassResult>();
- // var queryClass = $"select c.id,c.code,c.name,c.school,c.examId,c.year,c.scope,c.pk,c.subjectId,c.studentScores,c.studentIds,c.gradeId,c.info,c.studentAnswers,c.sum,c.progress from c where c.examId = '{id}' ";
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
- // {
- // examClassResults.Add(item);
- // /*using var json = await JsonDocument.ParseAsync(item.Content);
- // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- // {
- // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- // {
- // examClassResults.Add(obj.ToObject<ExamClassResult>());
- // }
- // }*/
- // }
- // int m = 0;
- // foreach (ExamSubject subject in info.subjects)
- // {
- // foreach (ExamClassResult classResult in examClassResults)
- // {
- // if (subject.id.Equals(classResult.subjectId))
- // {
- // int k = 0;
- // foreach (string stu in classResult.studentIds)
- // {
- // if (classResult.studentAnswers[k].Count > 0)
- // {
- // k++;
- // continue;
- // }
- // int n = 0;
- // List<List<string>> ans = new List<List<string>>();
- // foreach (List<string> simple in info.papers[m].answers)
- // {
- // List<string> option = new List<string>();
- // if (simple.Count > 0)
- // {
- // List<string> opt = new List<string> { "A", "B", "C", "D" };
- // int rd = new Random().Next(0, 3);
- // if (rd == 1 || rd == 2)
- // {
- // option.AddRange(simple);
- // classResult.studentScores[k][n] = info.papers[m].point[n];
- // }
- // else
- // {
- // simple.ForEach(x => { opt.Remove(x); });
- // option.Add(opt[new Random().Next(0, opt.Count - 1)]);
- // classResult.studentScores[k][n] = 0;
- // }
- // ans.Add(option);
- // }
- // else
- // {
- // //classResult.studentScores[k][n] = new Random().Next(0, (int)info.papers[m].point[n]) * 1.0;
- // ans.Add(new List<string> { "测试作答数据一", "测试作答数据二" });
- // }
- // n++;
- // }
- // /* StringBuilder builder = new StringBuilder();
- // builder.Append(classResult.examId + "/");
- // builder.Append(classResult.subjectId + "/");
- // builder.Append(stu + "/");
- // builder.Append("ans.json");*/
- // string FileName = classResult.examId + "/" + classResult.subjectId + "/" + stu;
- // string blob = FileName + "/" + "ans.json";
- // await _azureStorage.UploadFileByContainer(code.ToString(), ans.ToJsonString(), "exam", FileName + "/" + "ans.json");
- // classResult.studentAnswers[k].Add(blob);
- // classResult.sum[k] = classResult.studentScores[k].Sum();
- // k++;
- // }
- // //await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
- // if (!classResult.progress)
- // {
- // bool flag = true;
- // foreach (List<double> scores in classResult.studentScores)
- // {
- // foreach (double score in scores)
- // {
- // if (score == -1)
- // {
- // flag = false;
- // break;
- // }
- // }
- // }
- // if (flag)
- // {
- // classResult.progress = true;
- // info.subjects[m].classCount += 1;
- // }
- // }
- // await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
- // }
- // }
- // m++;
- // }
- // await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
- // return Ok(new { examClassResults });
- // }
- // catch (Exception e)
- // {
- // await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/answer()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- // return BadRequest();
- // }
- //}
- //[HttpPost("scoring")]
- //public async Task<IActionResult> Scoring(JsonElement request)
- //{
- // //获取评测的ID
- // if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
- // if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- // try
- // {
- // var client = _azureCosmos.GetCosmosClient();
- // //获取本次评测所有科目结算结果
- // ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
- // School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
- // List<ExamResult> examResults = new List<ExamResult>();
- // var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId = '{id}' ";
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
- // {
- // examResults.Add(item);
- // }
- // //获取本次评测所有班级作答结果
- // List<ExamClassResult> examClassResults = new List<ExamClassResult>();
- // var queryClass = $"select c.id,c.code,c.name,c.school,c.examId,c.year,c.scope,c.pk,c.subjectId,c.studentScores,c.studentIds,c.gradeId,c.info,c.studentAnswers,c.sum,c.progress from c where c.examId = '{id}' ";
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
- // {
- // examClassResults.Add(item);
- // }
- // int m = 0;
- // foreach (ExamSubject subject in info.subjects)
- // {
- // foreach (ExamClassResult classResult in examClassResults)
- // {
- // if (subject.id.Equals(classResult.subjectId))
- // {
- // int k = 0;
- // foreach (string stu in classResult.studentIds)
- // {
- // int n = 0;
- // List<List<string>> ans = new List<List<string>>();
- // foreach (List<string> simple in info.papers[m].answers)
- // {
- // List<string> option = new List<string>();
- // if (simple.Count == 0)
- // {
- // classResult.studentScores[k][n] = new Random().Next(0, (int)info.papers[m].point[n]) * 1.0;
- // }
- // n++;
- // }
- // classResult.sum[k] = classResult.studentScores[k].Sum();
- // k++;
- // }
- // if (!classResult.progress)
- // {
- // bool flag = true;
- // foreach (List<double> scores in classResult.studentScores)
- // {
- // foreach (double score in scores)
- // {
- // if (score == -1)
- // {
- // flag = false;
- // break;
- // }
- // }
- // }
- // if (flag)
- // {
- // classResult.progress = true;
- // info.subjects[m].classCount += 1;
- // }
- // }
- // else
- // {
- // info.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
- // }
- // await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
- // }
- // }
- // m++;
- // }
- // await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
- // return Ok(new { examClassResults });
- // }
- // catch (Exception e)
- // {
- // await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/scoring()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- // return BadRequest();
- // }
- //}
- //[HttpPost("import")]
- //public async Task<IActionResult> importIES3(JsonElement request)
- //{
- // //获取评测的ID
- // if (!request.TryGetProperty("exam", out JsonElement exam)) return BadRequest();
- // //if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- // try
- // {
- // var client = _azureCosmos.GetCosmosClient();
- // ExamDto examDtos = new ExamDto();
- // examDtos = exam.ToObject<ExamDto>();
- // ExamInfo info = new ExamInfo();
- // info.code = info.pk + "-hbcn";
- // info.progress = "pending";
- // info.id = examDtos.id;
- // info.name = examDtos.name;
- // info.grades = examDtos.grades;
- // info.subjects = examDtos.subjects;
- // info.period = examDtos.period;
- // examDtos.targetClasses.ForEach(e =>
- // {
- // info.classes.Add(e.id);
- // });
- // examDtos.papers.ForEach(p =>
- // {
- // PaperSimple simple = new PaperSimple();
- // simple.id = p.id;
- // simple.name = p.name;
- // p.points.ForEach(po =>
- // {
- // simple.point.Add(double.Parse(po));
- // });
- // p.answers.ForEach(an =>
- // {
- // List<string> ans = new List<string>();
- // if (an.Length > 1)
- // {
- // char[] aa = an.ToCharArray();
- // foreach (char a in aa)
- // {
- // switch (a)
- // {
- // case '1':
- // ans.Add("A");
- // break;
- // case '2':
- // ans.Add("B");
- // break;
- // case '3':
- // ans.Add("C");
- // break;
- // case '4':
- // ans.Add("D");
- // break;
- // default:
- // ans.Add("");
- // break;
- // }
- // }
- // }
- // else
- // {
- // switch (an)
- // {
- // case "1":
- // ans.Add("A");
- // break;
- // case "2":
- // ans.Add("B");
- // break;
- // case "3":
- // ans.Add("C");
- // break;
- // case "4":
- // ans.Add("D");
- // break;
- // default:
- // ans.Add("");
- // break;
- // }
- // }
- // simple.answers.Add(ans);
- // });
- // info.papers.Add(simple);
- // });
- // await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(info, new PartitionKey("Exam-hbcn"));
- // return Ok(new { info });
- // }
- // catch (Exception e)
- // {
- // await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/scoring()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- // return BadRequest();
- // }
- //}
- //[HttpPost("importResult")]
- //public async Task<IActionResult> importClassResult(JsonElement request)
- //{
- // //获取评测的ID
- // if (!request.TryGetProperty("classResult", out JsonElement classResult)) return BadRequest();
- // if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
- // try
- // {
- // var client = _azureCosmos.GetCosmosClient();
- // List<ExamClassResultDto> examClassResultDto = new List<ExamClassResultDto>();
- // examClassResultDto = classResult.ToObject<List<ExamClassResultDto>>();
- // //获取本次评测所有班级作答结果
- // List<ExamClassResult> examClassResults = new List<ExamClassResult>();
- // var queryClass = $"select value(c) from c where c.examId = '{id}'";
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ExamClassResult-hbcn") }))
- // {
- // examClassResults.Add(item);
- // }
- // foreach (ExamClassResultDto e in examClassResultDto)
- // {
- // foreach (ExamClassResult ex in examClassResults)
- // {
- // if (e.subject.Equals(ex.subjectId))
- // {
- // foreach (ClassResults examClass in e.examClassResult)
- // {
- // if (examClass.classInfo.id.Equals(ex.info.id))
- // {
- // ex.studentIds = examClass.studentIds;
- // List<List<double>> newScores = new List<List<double>>();
- // examClass.studentScores.ForEach(sc =>
- // {
- // List<double> scores = new List<double>();
- // if (sc.Count == 0)
- // {
- // for (int i = 0; i < ex.studentScores[0].Count; i++)
- // {
- // scores.Add(0);
- // }
- // }
- // else
- // {
- // sc.ForEach(s =>
- // {
- // scores.Add(double.Parse(s));
- // });
- // }
- // newScores.Add(scores);
- // });
- // ex.studentScores = newScores;
- // int index = 0;
- // List<Task<string>> tasks = new List<Task<string>>();
- // List<List<string>> answers = new List<List<string>>();
- // foreach (List<string> an in examClass.studentAnswers)
- // {
- // //List<List<string>> stuAns = new List<List<string>>();
- // an.ForEach(aa =>
- // {
- // List<string> ans = new List<string>();
- // if (aa.Length > 1)
- // {
- // char[] str = aa.ToCharArray();
- // foreach (char a in aa)
- // {
- // switch (a)
- // {
- // case '1':
- // ans.Add("A");
- // break;
- // case '2':
- // ans.Add("B");
- // break;
- // case '3':
- // ans.Add("C");
- // break;
- // case '4':
- // ans.Add("D");
- // break;
- // default:
- // ans.Add("");
- // break;
- // }
- // answers.Add(ans);
- // }
- // }
- // else
- // {
- // switch (aa)
- // {
- // case "1":
- // ans.Add("A");
- // break;
- // case "2":
- // ans.Add("B");
- // break;
- // case "3":
- // ans.Add("C");
- // break;
- // case "4":
- // ans.Add("D");
- // break;
- // default:
- // ans.Add("");
- // break;
- // }
- // answers.Add(ans);
- // }
- // //answers.Add(stuAns);
- // });
- // string FileName = ex.examId + "/" + ex.subjectId + "/" + examClass.studentIds[index];
- // string blob = FileName + "/" + "ans.json";
- // tasks.Add(_azureStorage.UploadFileByContainer(ex.school.ToString(), answers.ToJsonString(), "exam", FileName + "/" + "ans.json"));
- // ex.studentAnswers[index].Add(blob);
- // index++;
- // }
- // await Task.WhenAll(tasks);
- // }
- // }
- // }
- // }
- // }
- // foreach (ExamClassResult result in examClassResults)
- // {
- // result.progress = true;
- // await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
- // }
- // return Ok(new { examClassResults });
- // }
- // catch (Exception e)
- // {
- // await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/importResult()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- // return BadRequest();
- // }
- //}
- //private List<Dictionary<string, dynamic>> getKnowledgePoint(List<ExamResult> examResults, ExamInfo info)
- //{
- // Dictionary<string, object> stuMap = new Dictionary<string, object>
- // {
- // { "schoolCode", "Habook" }
- // };
- // List<Dictionary<string, object>> keyValues = new List<Dictionary<string, object>>();
- // HashSet<string> knowledge = new HashSet<string>();
- // HashSet<string> area = new HashSet<string>();
- // List<double> point = new List<double>();
- // List<List<double>> result = new List<List<double>>();
- // List<ClassRange> classes = new List<ClassRange>();
- // List<string> ids = new List<string>();
- // examResults.ForEach(e =>
- // {
- // //定位试卷信息
- // int index = 0;
- // foreach (ExamSubject subject in info.subjects)
- // {
- // if (subject.id.Equals(e.subjectId))
- // {
- // break;
- // }
- // else
- // {
- // index++;
- // }
- // }
- // info.papers[index].knowledge.ForEach(k =>
- // {
- // k.ForEach(e =>
- // {
- // knowledge.Add(e);
- // });
- // });
- // info.papers[index].field.ForEach(f =>
- // {
- // area.Add(f.ToString());
- // });
- // double Qnum = 0;
- // point = info.papers[index].point;
- // result = e.studentScores;
- // classes = e.classes;
- // ids = e.studentIds;
- // //确定高分组 低分组人数
- // List<List<double>> re = e.studentScores;
- // List<double> resultSum = new List<double>();
- // foreach (List<double> data in re)
- // {
- // resultSum.Add(data.Sum());
- // }
- // //确定高分组 最低分数
- // resultSum.Sort(delegate (double s1, double s2) { return s2.CompareTo(s1); });
- // for (int i = resultSum.Count - 1; i >= 0; i--)
- // {
- // if (resultSum[i] == 0)
- // {
- // resultSum.Remove(resultSum[i]);
- // }
- // }
- // double rhwCount = resultSum.Count * 0.27;
- // double rhw = resultSum[int.Parse(rhwCount.ToString("0"))];
- // //确定低分组 最高分数
- // resultSum.Sort(delegate (double s1, double s2) { return s1.CompareTo(s2); });
- // double rhlCount = resultSum.Count * 0.27;
- // double rhl = resultSum[int.Parse(rhwCount.ToString("0"))];
- // List<string> knowledgeName = new List<string>();
- // foreach (string cla in knowledge)
- // {
- // knowledgeName.Add(cla);
- // }
- // for (int k = 0; k < knowledgeName.Count; k++)
- // {
- // if (null == knowledgeName[k])
- // {
- // knowledgeName.Remove(knowledgeName[k]);
- // }
- // }
- // List<string> areaName = new List<string>();
- // foreach (string cla in area)
- // {
- // areaName.Add(cla);
- // }
- // for (int k = 0; k < areaName.Count; k++)
- // {
- // if (null == areaName[k])
- // {
- // areaName.Remove(areaName[k]);
- // }
- // }
- // //初始化年级总分
- // double total = 0;
- // //处理年级单个知识点得分率
- // foreach (List<double> grade in result)
- // {
- // total += grade.Sum();
- // }
- // foreach (string id in ids)
- // {
- // if (!id.Equals("0"))
- // {
- // Qnum++;
- // }
- // }
- // //试卷总分
- // double TotalPoint = point.Sum();
- // //计算认知层次占比
- // List<string> fper = new List<string>();
- // for (int a = 0; a < areaName.Count; a++)
- // {
- // double fieldPoint = 0;
- // int no = 0;
- // info.papers[index].field.ForEach(f =>
- // {
- // if (f.ToString().Equals(areaName[a], StringComparison.OrdinalIgnoreCase))
- // {
- // e.studentScores.ForEach(s =>
- // {
- // fieldPoint += s[no];
- // });
- // }
- // no++;
- // });
- // double fieldPersent = fieldPoint / TotalPoint;
- // fper.Add(fieldPersent.ToString("0.00"));
- // }
- // //求单个知识点所占分数
- // List<string> per = new List<string>();
- // List<string> gper = new List<string>();
- // List<string> knowPer = new List<string>();
- // List<Dictionary<string, double>> eper = new List<Dictionary<string, double>>();
- // Dictionary<string, object> knowledgeALL = new Dictionary<string, object>();
- // Dictionary<string, object> knowledgeMap = new Dictionary<string, object>();
- // Dictionary<string, object> classMap = new Dictionary<string, object>();
- // Dictionary<string, object> wrongMap = new Dictionary<string, object>();
- // HashSet<string> className = new HashSet<string>();
- // List<List<string>> wrongPersent = new List<List<string>>();
- // List<string> key = new List<string>
- // {
- // "id",
- // "className",
- // "seatNO",
- // "point",
- // "anwPoint",
- // "persent"
- // };
- // List<string> keyWrong = new List<string>
- // {
- // "name",
- // "point",
- // "itemNO",
- // "persent",
- // "wrong",
- // "rhw",
- // "rlw"
- // };
- // for (int k = 0; k < knowledgeName.Count; k++)
- // {
- // List<string> knowledgeClass = new List<string>();
- // List<List<string>> stuPersent = new List<List<string>>();
- // double OnePoint = 0;
- // //获取每个知识点占有多少分值
- // double ePoint = 0;
- // double anwGPoint = 0;
- // double poG = 0;
- // int m = 0;
- // List<string> valuew = new List<string>();
- // List<string> itemNo = new List<string>();
- // keyWrong.ForEach(x =>
- // {
- // valuew.Add("-");
- // });
- // int wrongCount = 0;
- // valuew[0] = knowledgeName[k];
- // int n = 0;
- // info.papers[index].knowledge.ForEach(kno =>
- // {
- // if (kno.Contains(knowledgeName[k]))
- // {
- // OnePoint += point[n];
- // itemNo.Add((n + 1).ToString());
- // }
- // valuew[1] = OnePoint.ToString();
- // string itemNos = "";
- // if (itemNo.Count > 0)
- // {
- // foreach (string np in itemNo)
- // {
- // itemNos += np + ",";
- // }
- // valuew[2] = itemNos[0..^1];
- // }
- // else
- // {
- // valuew[2] = itemNos;
- // }
- // n++;
- // });
- // int rhwC = 0;
- // int rhlC = 0;
- // foreach (string id in ids)
- // {
- // if (id.Equals("0") || result[m].Sum() == 0)
- // {
- // m++;
- // continue;
- // }
- // List<string> values = new List<string>();
- // key.ForEach(x =>
- // {
- // values.Add("-");
- // });
- // /* foreach (OldStudent info in students)
- // {
- // if (info.studentId.Equals(id))
- // {
- // values[2] = info.seatNo.ToString();
- // break;
- // }
- // }*/
- // //List<string> stu = new List<string>();
- // values[0] = id;
- // values[1] = "-";
- // //List<List<string>> stuItem = new List<List<string>>();
- // int statuCount = 0;
- // info.papers[index].knowledge.ForEach(kno =>
- // {
- // int sno = 0;
- // double anwPoint = 0;
- // double po = 0;
- // if (kno.Contains(knowledgeName[k]))
- // {
- // //当前认知层次在该题占比多少
- // ePoint = 1;
- // anwPoint += result[m][sno] * ePoint;
- // //所有学生单个认知层次得分情况
- // anwGPoint += result[m][sno] * ePoint;
- // po += point[sno] * ePoint;
- // //认知层次所占分数
- // poG += point[sno] * ePoint;
- // if (result[m][sno] == 0 && statuCount == 0)
- // {
- // statuCount++;
- // wrongCount++;
- // if (result[m].Sum() >= rhw)
- // {
- // rhwC++;
- // }
- // if (result[m].Sum() <= rhl)
- // {
- // rhlC++;
- // }
- // }
- // if (po == 0)
- // {
- // values[3] = "0";
- // values[4] = "0";
- // values[5] = "0";
- // }
- // else
- // {
- // double stuPser = anwPoint / po;
- // values[3] = po.ToString();
- // values[4] = anwPoint.ToString();
- // values[5] = stuPser.ToString("0.00");
- // }
- // }
- // });
- // stuPersent.Add(values);
- // m++;
- // }
- // //AchievementService.ReName(stuPersent, ids, classes, students);
- // double knowPser = 0;
- // if (poG == 0)
- // {
- // knowPer.Add("0");
- // }
- // else
- // {
- // knowPser = anwGPoint / poG;
- // knowPer.Add(knowPser.ToString("0.00"));
- // }
- // //错题关系表
- // valuew[3] = knowPser.ToString("0.00");
- // valuew[4] = wrongCount.ToString();
- // valuew[5] = rhwC.ToString();
- // valuew[6] = rhlC.ToString();
- // wrongPersent.Add(valuew);
- // knowledgeMap.Add(knowledgeName[k], stuPersent);
- // //知识点占比
- // double persent = OnePoint / TotalPoint;
- // foreach (ClassRange classRange in e.classes)
- // {
- // List<string> classPoints = new List<string>();
- // //初始化班级得分
- // double anwCPoint = 0;
- // double cpo = 0;
- // for (int stuIndex = classRange.range[0]; stuIndex < classRange.range[1]; stuIndex++)
- // {
- // if (result[stuIndex].Sum() == 0) continue;
- // info.papers[index].knowledge.ForEach(kno =>
- // {
- // int x = 0;
- // if (kno.Contains(knowledgeName[k]))
- // {
- // //当前认知层次在该题占比多少
- // ePoint = 1;
- // anwCPoint += result[stuIndex][x] * ePoint;
- // cpo += point[x] * ePoint;
- // }
- // });
- // }
- // if (cpo == 0)
- // {
- // //double classPser = anwCPoint / cpo;
- // knowledgeClass.Add("0");
- // }
- // else
- // {
- // double classPser = anwCPoint / cpo;
- // knowledgeClass.Add(classPser.ToString("0.00"));
- // }
- // }
- // classMap.Add(knowledgeName[k], knowledgeClass);
- // per.Add(persent.ToString("0.00"));
- // }
- // knowledgeMap.Add("grade", knowPer);
- // knowledgeMap.Add("keys", key);
- // classMap.Add("className", className);
- // wrongMap.Add("keys", keyWrong);
- // wrongMap.Add("datas", wrongPersent);
- // knowledgeALL.Add("pointList", knowledgeName);
- // knowledgeALL.Add("per", per);
- // knowledgeALL.Add("level", areaName);
- // knowledgeALL.Add("fper", fper);
- // knowledgeALL.Add("stupercent", knowledgeMap);
- // knowledgeALL.Add("classpercent", classMap);
- // knowledgeALL.Add("wrong", wrongMap);
- // keyValues.Add(knowledgeALL);
- // });
- // return keyValues;
- //}
- //}
- //}
- // knowledgeALL.Add("pointList", knowledgeName);
- //knowledgeALL.Add("per", per);
- //knowledgeALL.Add("level", areaName);
- //knowledgeALL.Add("fper", fper);
- //knowledgeALL.Add("stupercent", knowledgeMap);
- //knowledgeALL.Add("classpercent", classMap);
- //knowledgeALL.Add("wrong", wrongMap);
- //keyValues.Add(knowledgeALL);
- // });
- //return keyValues;
- // }
- // [HttpPost("answer")]
- //public async Task<IActionResult> answer(JsonElement request)
- //{
- // 获取评测的ID
- // if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
- // if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- // try
- // {
- // var client = _azureCosmos.GetCosmosClient();
- // 获取本次评测所有科目结算结果
- // ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
- // School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
- // List<ExamResult> examResults = new List<ExamResult>();
- // var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId = '{id}' ";
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
- // {
- // /*using var json = await JsonDocument.ParseAsync(item.Content);
- // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- // {
- // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- // {
- // examResults.Add(obj.ToObject<ExamResult>());
- // }
- // }*/
- // examResults.Add(item);
- // }
- // 获取本次评测所有班级作答结果
- // List<ExamClassResult> examClassResults = new List<ExamClassResult>();
- // var queryClass = $"select c.id,c.code,c.name,c.school,c.examId,c.year,c.scope,c.pk,c.subjectId,c.studentScores,c.studentIds,c.gradeId,c.info,c.studentAnswers,c.sum,c.progress from c where c.examId = '{id}' ";
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
- // {
- // examClassResults.Add(item);
- // /*using var json = await JsonDocument.ParseAsync(item.Content);
- // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- // {
- // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- // {
- // examClassResults.Add(obj.ToObject<ExamClassResult>());
- // }
- // }*/
- // }
- // int m = 0;
- // foreach (ExamSubject subject in info.subjects)
- // {
- // foreach (ExamClassResult classResult in examClassResults)
- // {
- // if (subject.id.Equals(classResult.subjectId))
- // {
- // int k = 0;
- // foreach (string stu in classResult.studentIds)
- // {
- // if (classResult.studentAnswers[k].Count > 0)
- // {
- // k++;
- // continue;
- // }
- // int n = 0;
- // List<List<string>> ans = new List<List<string>>();
- // foreach (List<string> simple in info.papers[m].answers)
- // {
- // List<string> option = new List<string>();
- // if (simple.Count > 0)
- // {
- // List<string> opt = new List<string> { "A", "B", "C", "D" };
- // int rd = new Random().Next(0, 3);
- // if (rd == 1 || rd == 2)
- // {
- // option.AddRange(simple);
- // classResult.studentScores[k][n] = info.papers[m].point[n];
- // }
- // else
- // {
- // simple.ForEach(x => { opt.Remove(x); });
- // option.Add(opt[new Random().Next(0, opt.Count - 1)]);
- // classResult.studentScores[k][n] = 0;
- // }
- // ans.Add(option);
- // }
- // else
- // {
- // classResult.studentScores[k][n] = new Random().Next(0, (int)info.papers[m].point[n]) * 1.0;
- // ans.Add(new List<string> { "测试作答数据一", "测试作答数据二" });
- // }
- // n++;
- // }
- // /* StringBuilder builder = new StringBuilder();
- // builder.Append(classResult.examId + "/");
- // builder.Append(classResult.subjectId + "/");
- // builder.Append(stu + "/");
- // builder.Append("ans.json");*/
- // string FileName = classResult.examId + "/" + classResult.subjectId + "/" + stu;
- // string blob = FileName + "/" + "ans.json";
- // await _azureStorage.UploadFileByContainer(code.ToString(), ans.ToJsonString(), "exam", FileName + "/" + "ans.json");
- // classResult.studentAnswers[k].Add(blob);
- // classResult.sum[k] = classResult.studentScores[k].Sum();
- // k++;
- // }
- // await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
- // if (!classResult.progress)
- // {
- // bool flag = true;
- // foreach (List<double> scores in classResult.studentScores)
- // {
- // foreach (double score in scores)
- // {
- // if (score == -1)
- // {
- // flag = false;
- // break;
- // }
- // }
- // }
- // if (flag)
- // {
- // classResult.progress = true;
- // info.subjects[m].classCount += 1;
- // }
- // }
- // await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
- // }
- // }
- // m++;
- // }
- // await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
- // return Ok(new { examClassResults });
- // }
- // catch (Exception e)
- // {
- // await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/answer()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- // return BadRequest();
- // }
- //}
- //[HttpPost("scoring")]
- //public async Task<IActionResult> Scoring(JsonElement request)
- //{
- // 获取评测的ID
- // if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
- // if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- // try
- // {
- // var client = _azureCosmos.GetCosmosClient();
- // 获取本次评测所有科目结算结果
- // ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
- // School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
- // List<ExamResult> examResults = new List<ExamResult>();
- // var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId = '{id}' ";
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
- // {
- // examResults.Add(item);
- // }
- // 获取本次评测所有班级作答结果
- // List<ExamClassResult> examClassResults = new List<ExamClassResult>();
- // var queryClass = $"select c.id,c.code,c.name,c.school,c.examId,c.year,c.scope,c.pk,c.subjectId,c.studentScores,c.studentIds,c.gradeId,c.info,c.studentAnswers,c.sum,c.progress from c where c.examId = '{id}' ";
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
- // {
- // examClassResults.Add(item);
- // }
- // int m = 0;
- // foreach (ExamSubject subject in info.subjects)
- // {
- // foreach (ExamClassResult classResult in examClassResults)
- // {
- // if (subject.id.Equals(classResult.subjectId))
- // {
- // int k = 0;
- // foreach (string stu in classResult.studentIds)
- // {
- // int n = 0;
- // List<List<string>> ans = new List<List<string>>();
- // foreach (List<string> simple in info.papers[m].answers)
- // {
- // List<string> option = new List<string>();
- // if (simple.Count == 0)
- // {
- // classResult.studentScores[k][n] = new Random().Next(0, (int)info.papers[m].point[n]) * 1.0;
- // }
- // n++;
- // }
- // classResult.sum[k] = classResult.studentScores[k].Sum();
- // k++;
- // }
- // if (!classResult.progress)
- // {
- // bool flag = true;
- // foreach (List<double> scores in classResult.studentScores)
- // {
- // foreach (double score in scores)
- // {
- // if (score == -1)
- // {
- // flag = false;
- // break;
- // }
- // }
- // }
- // if (flag)
- // {
- // classResult.progress = true;
- // info.subjects[m].classCount += 1;
- // }
- // }
- // else
- // {
- // info.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
- // }
- // await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
- // }
- // }
- // m++;
- // }
- // await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
- // return Ok(new { examClassResults });
- // }
- // catch (Exception e)
- // {
- // await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/scoring()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- // return BadRequest();
- // }
- //}
- [HttpPost("import")]
- public async Task<IActionResult> importIES3(JsonElement request)
- {
- //获取评测的ID
- if (!request.TryGetProperty("exam", out JsonElement exam)) return BadRequest();
- if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- if (!request.TryGetProperty("classResult", out JsonElement classResult)) return BadRequest();
- //if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- ExamDto examDtos = new ExamDto();
- examDtos = exam.ToObject<ExamDto>();
- ExamInfo info = new ExamInfo();
- info.code = info.pk + "-" + code;
- info.progress = "finish";
- info.id = Guid.NewGuid().ToString();
- info.name = examDtos.name;
- info.grades = examDtos.grades;
- info.subjects = examDtos.subjects;
- info.period = examDtos.period;
- examDtos.targetClasses.ForEach(e =>
- {
- info.classes.Add(e);
- });
- info.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
- info.startTime = examDtos.startTime;
- info.endTime = examDtos.endTime;
- info.school = code.GetString();
- info.type = examDtos.type;
- info.scope = "school";
- info.examType = examDtos.examType;
- await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(info, new PartitionKey($"Exam-{code}"));
- return Ok(new { info });
- }
- catch (Exception e)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/import()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- public class FileDto
- {
- public string periodId { get; set; }
- public string code { get; set; }
- public string name { get; set; }
- public int multipleRule { get; set; }
- public string examId { get; set; }
- public string subjectId { get; set; }
- public List<string> gradeIds { get; set; }
- public IFormFile file { get; set; }
- }
- [HttpPost("parse-word")]
- public async Task<IActionResult> ParseWord([FromForm] FileDto fileDto)
- {
- if (!FileType.GetExtention(fileDto.file.FileName).ToLower().Equals("docx"))
- {
- return BadRequest(new Dictionary<string, object> { { "msg", "type is not docx!" }, { "code", ResponseCode.FAILED } });
- }
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(fileDto.examId, new PartitionKey($"Exam-{fileDto.code}"));
- ExamInfo examInfo;
- if (response.StatusCode == System.Net.HttpStatusCode.OK)
- {
- using var json = await JsonDocument.ParseAsync(response.Content);
- examInfo = json.ToObject<ExamInfo>();
- }
- else
- {
- return Ok(new { error = 404, msg = "请先导入评测信息" });
- }
- foreach (PaperSimple paper in examInfo.papers)
- {
- if (paper.id.Contains(fileDto.subjectId))
- {
- return Ok(new { error = 500, msg = "该试卷信息已存在" });
- }
- }
- PaperSimple simple = new();
- var doc = _DOXC2HTMLTranslator.Translate(fileDto.file.OpenReadStream());
- (List<HTEXLib.DOCX.Models.ItemInfo> tests, List<string> error) = _HTML2ITEMV3Translator.Translate(doc);
- List<Task<string>> tasks = new List<Task<string>>();
- PaperDto paperDto = new()
- {
- id = Guid.NewGuid().ToString(),
- name = fileDto.name,
- code = fileDto.code,
- scope = "school",
- multipleRule = fileDto.multipleRule,
- gradeIds = fileDto.gradeIds,
- subjectId = fileDto.subjectId,
- periodId = fileDto.periodId
- };
- foreach (HTEXLib.DOCX.Models.ItemInfo item in tests)
- {
- Slides slides = new();
- ItemDto dto = new();
- TEAMModelOS.SDK.Models.Scoring scoring = new();
- dto.id = Guid.NewGuid().ToString();
- dto.exercise.answer = item.answer;
- dto.exercise.explain = item.explain;
- dto.exercise.type = item.type;
- dto.exercise.opts = item.option.Count;
- dto.exercise.knowledge = item.knowledge;
- dto.exercise.field = item.field;
- dto.exercise.level = item.level;
- dto.exercise.subjectId = fileDto.subjectId;
- dto.exercise.periodId = fileDto.periodId;
- dto.exercise.gradeIds = fileDto.gradeIds;
- slides.url = dto.id + ".json";
- slides.type = dto.exercise.type;
- scoring.ans = dto.exercise.answer;
- scoring.score = dto.exercise.score;
- scoring.knowledge = dto.exercise.knowledge;
- scoring.field = dto.exercise.field;
- slides.scoring = scoring;
- //添加试卷信息
- paperDto.slides.Add(slides);
- if (!slides.type.Equals("compose"))
- {
- simple.point.Add(dto.exercise.score);
- simple.answers.Add(dto.exercise.answer);
- simple.knowledge.Add(dto.exercise.knowledge);
- simple.type.Add(dto.exercise.type);
- simple.field.Add((int)dto.exercise.field);
- }
- if (item.children.Count > 0)
- {
- foreach (HTEXLib.DOCX.Models.ItemInfo its in item.children)
- {
- Slides cslides = new();
- TEAMModelOS.SDK.Models.Scoring cscoring = new();
- ItemDto dtoChildren = new ItemDto();
- dtoChildren.id = Guid.NewGuid().ToString();
- dtoChildren.pid = dto.id;
- dtoChildren.exercise.answer = its.answer;
- dtoChildren.exercise.explain = its.explain;
- dtoChildren.exercise.type = its.type;
- dtoChildren.exercise.opts = its.option.Count;
- dtoChildren.exercise.knowledge = its.knowledge;
- dtoChildren.exercise.field = its.field;
- dtoChildren.exercise.level = its.level;
- dtoChildren.exercise.scope = "school";
- dtoChildren.exercise.score = its.score;
- dtoChildren.exercise.subjectId = fileDto.subjectId;
- dtoChildren.exercise.periodId = fileDto.periodId;
- dtoChildren.exercise.gradeIds = fileDto.gradeIds;
- dtoChildren.exercise.children.Add(dtoChildren.id);
- info info1 = new();
- info1.uid = dtoChildren.id;
- info1.question = its.question;
- info1.option = JsonSerializer.Deserialize<List<TEAMModelOS.Models.Dto.CodeValue>>(its.option.ToJsonString());
- dtoChildren.item.Add(info1);
- dto.exercise.children.Add(dtoChildren.id);
- //处理子题的slides
- cslides.url = dtoChildren.id + ".json";
- cslides.type = dtoChildren.exercise.type;
- cscoring.ans = dtoChildren.exercise.answer;
- cscoring.score = dtoChildren.exercise.score;
- cscoring.knowledge = dtoChildren.exercise.knowledge;
- cscoring.field = dtoChildren.exercise.field;
- cslides.scoring = scoring;
- paperDto.slides.Add(cslides);
- //添加试卷信息
- simple.point.Add(dtoChildren.exercise.score);
- simple.answers.Add(dto.exercise.answer);
- simple.knowledge.Add(dto.exercise.knowledge);
- simple.type.Add(dto.exercise.type);
- simple.field.Add((int)dto.exercise.field);
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.Append(fileDto.examId).Append("/");
- stringBuilder.Append("paper").Append("/");
- stringBuilder.Append(fileDto.subjectId).Append("/");
- stringBuilder.Append(dtoChildren.id + ".json");
- tasks.Add(_azureStorage.GetBlobContainerClient(fileDto.code).UploadFileByContainer(dtoChildren.ToJsonString(), "exam", stringBuilder.ToString(), false));
- }
- }
- info @info = new();
- @info.uid = dto.id;
- @info.question = item.question;
- @info.option = JsonSerializer.Deserialize<List<TEAMModelOS.Models.Dto. CodeValue>>(item.option.ToJsonString());
- dto.item.Add(@info);
- dto.exercise.scope = "school";
- dto.exercise.score = item.score;
- StringBuilder builder = new StringBuilder();
- builder.Append(fileDto.examId).Append('/');
- builder.Append("paper").Append('/');
- builder.Append(fileDto.subjectId).Append('/');
- builder.Append(dto.id + ".json");
- tasks.Add(_azureStorage.GetBlobContainerClient(fileDto.code).UploadFileByContainer(dto.ToJsonString(), "exam", builder.ToString(), false));
- }
- StringBuilder paperBuilder = new StringBuilder();
- paperBuilder.Append(fileDto.examId).Append('/');
- paperBuilder.Append("paper").Append('/');
- paperBuilder.Append(fileDto.subjectId).Append('/');
- paperBuilder.Append("index.json");
- tasks.Add(_azureStorage.GetBlobContainerClient(fileDto.code).UploadFileByContainer(paperDto.ToJsonString(), "exam", paperBuilder.ToString(), false));
- //开始给ExamInfo paper赋值
- simple.id = fileDto.subjectId;
- simple.code = "Paper-" + fileDto.code;
- simple.name = fileDto.name;
- simple.blob = paperBuilder.ToString().Replace("index.json", "");
- simple.scope = "school";
- simple.multipleRule = fileDto.multipleRule;
- examInfo.papers.Add(simple);
- await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(examInfo, examInfo.id, new PartitionKey($"{examInfo.code}"));
- await Task.WhenAll(tasks);
- return Ok(new { code = 200 });
- }
- catch (Exception e)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/word()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- [HttpPost("importResult")]
- [RequestSizeLimit(100_000_000)]//最大允许100M
- public async Task<IActionResult> importClassResult(JsonElement request)
- {
- //获取评测的ID
- if (!request.TryGetProperty("classResult", out JsonElement classResult)) return BadRequest();
- if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
- if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- List<ExamClassResultDto> examClassResultDto = new List<ExamClassResultDto>();
- examClassResultDto = classResult.ToObject<List<ExamClassResultDto>>();
- //获取本次评测所有班级作答结果
- List<ExamClassResult> examClassResults = new List<ExamClassResult>();
- var queryClass = $"select value(c) from c where c.examId = '{id}'";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
- {
- examClassResults.Add(item);
- }
- ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
- if (info == null)
- {
- return Ok(new { code = 404, msg = "请先录入评测数据" });
- }
- else
- {
- foreach (ExamClassResultDto e in examClassResultDto)
- {
- int no = 0;
- foreach (ExamSubject sub in info.subjects)
- {
- if (!sub.id.Equals(e.subject))
- {
- no++;
- }
- }
- //获取标准答案
- List<List<string>> standard = new();
- standard = info.papers[no].answers;
- foreach (ExamClassResult ex in examClassResults)
- {
- if (e.subject.Equals(ex.subjectId))
- {
- foreach (ClassResults examClass in e.examClassResult)
- {
- if (examClass.classInfo.id.Equals(ex.info.id))
- {
- ex.studentIds = examClass.studentIds;
- List<List<double>> newScores = new List<List<double>>();
- examClass.studentScores.ForEach(sc =>
- {
- List<double> scores = new List<double>();
- if (sc.Count == 0)
- {
- for (int i = 0; i < ex.studentScores[0].Count; i++)
- {
- scores.Add(0);
- }
- }
- else
- {
- sc.ForEach(s =>
- {
- scores.Add(s);
- });
- }
- newScores.Add(scores);
- });
- ex.studentScores = newScores;
- int index = 0;
- List<Task<string>> tasks = new List<Task<string>>();
- foreach (List<string> an in examClass.studentAnswers)
- {
- List<List<string>> answers = new List<List<string>>();
- //存放客观题答案
- List<List<string>> objective = new List<List<string>>();
- int index_item = 0;
- an.ForEach(aa =>
- {
- List<string> ans = new List<string>();
- List<string> oans = new List<string>();
- //判断此题是否为主观题作答
- if (standard[index_item].Count == 0)
- {
- ans.Add(aa);
- oans.Add("");
- answers.Add(ans);
- objective.Add(oans);
- }
- else
- {
- if (aa.Length > 1)
- {
- char[] str = aa.ToCharArray();
- foreach (char a in aa)
- {
- ans.Add(a.ToString());
- oans.Add(a.ToString());
- }
- objective.Add(oans);
- answers.Add(ans);
- }
- else
- {
- ans.Add(aa);
- oans.Add(aa);
- objective.Add(oans);
- answers.Add(ans);
- }
- }
- index_item++;
- //answers.Add(stuAns);
- });
- ex.ans[index] = objective;
- string FileName = ex.examId + "/" + ex.subjectId + "/" + examClass.studentIds[index];
- string blob = FileName + "/" + "ans.json";
- tasks.Add(_azureStorage.GetBlobContainerClient(ex.school.ToString()).UploadFileByContainer(answers.ToJsonString(), "exam", FileName + "/" + "ans.json"));
- ex.studentAnswers[index].Clear();
- ex.studentAnswers[index].Add(blob);
- index++;
- }
- await Task.WhenAll(tasks);
- }
- }
- }
- }
- }
- }
- foreach (ExamClassResult result in examClassResults)
- {
- result.progress = true;
- await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
- }
- return Ok(new { examClassResults });
- }
- catch (Exception e)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/importResult()\n", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- //获取学校简易基础信息
- [HttpPost("getSchoolInfo")]
- public async Task<IActionResult> getInfoSchool(JsonElement request)
- {
- if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- List<object> info = new List<object>();
- var query = $"select c.period,c.id,c.campuses from c where c.id = '{code}'";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
- {
- using var json = await JsonDocument.ParseAsync(item.Content);
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- info.Add(obj.ToObject<object>());
- }
- }
- }
- return Ok(new { info });
- }
- catch (Exception e)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/getSchoolInfo()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- //获取学校某学段班级信息
- [HttpPost("getClassInfo")]
- public async Task<IActionResult> getClassInfo(JsonElement request)
- {
- if (!request.TryGetProperty("periodId", out JsonElement periodId)) return BadRequest();
- if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- List<object> classInfo = new List<object>();
- var query = $"select c.id,c.name from c where c.periodId = '{periodId}'";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{code}") }))
- {
- using var json = await JsonDocument.ParseAsync(item.Content);
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- classInfo.Add(obj.ToObject<object>());
- }
- }
- }
- return Ok(new { classInfo });
- }
- catch (Exception e)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/getClassInfo()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- //获取学校某学段班级信息
- [HttpPost("getClass")]
- public async Task<IActionResult> getClass(JsonElement request)
- {
- if (!request.TryGetProperty("periodId", out JsonElement periodId)) return BadRequest();
- if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- List<Class> classInfo = new List<Class>();
- School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey("Base"));
- var query = $"select value(c) from c where c.periodId = '{periodId}'";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<Class>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{code}") }))
- {
- classInfo.Add(item);
- }
- foreach (Class @class in classInfo)
- {
- foreach (Period period in school.period)
- {
- if (period.id.Equals(@class.periodId))
- {
- //switch (period.name)
- //{
- // case "小学":
- // foreach (Grade grade in period.grades)
- // {
- // if (@class.gradeId.Equals(grade.id))
- // {
- // switch (grade.name)
- // {
- // case "一年级":
- // @class.year = DateTimeOffset.UtcNow.Year - 1;
- // break;
- // case "二年级":
- // @class.year = DateTimeOffset.UtcNow.Year - 2;
- // break;
- // case "三年级":
- // @class.year = DateTimeOffset.UtcNow.Year - 3;
- // break;
- // case "四年级":
- // @class.year = DateTimeOffset.UtcNow.Year - 4;
- // break;
- // case "五年级":
- // @class.year = DateTimeOffset.UtcNow.Year - 5;
- // break;
- // case "六年级":
- // @class.year = DateTimeOffset.UtcNow.Year - 6;
- // break;
- // }
- // }
- // }
- // break;
- // case "初中":
- // foreach (Grade grade in period.grades)
- // {
- // if (@class.gradeId.Equals(grade.id))
- // {
- // switch (grade.name)
- // {
- // case "七年级":
- // @class.year = DateTimeOffset.UtcNow.Year - 1;
- // break;
- // case "八年级":
- // @class.year = DateTimeOffset.UtcNow.Year - 2;
- // break;
- // case "九年级":
- // @class.year = DateTimeOffset.UtcNow.Year - 3;
- // break;
- // }
- // }
- // }
- // break;
- // case "高中":
- // foreach (Grade grade in period.grades)
- // {
- // if (@class.gradeId.Equals(grade.id))
- // {
- // switch (grade.name)
- // {
- // case "十年级":
- // @class.year = DateTimeOffset.UtcNow.Year - 1;
- // break;
- // case "十一年级":
- // @class.year = DateTimeOffset.UtcNow.Year - 2;
- // break;
- // case "十二年级":
- // @class.year = DateTimeOffset.UtcNow.Year - 3;
- // break;
- // default:
- // @class.year = DateTimeOffset.UtcNow.Year;
- // break;
- // }
- // }
- // }
- // break;
- //}
- }
- }
- }
- return Ok(new { classInfo });
- }
- catch (Exception e)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/getClassInfo()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- [HttpPost("import-exam")]
- public async Task<IActionResult> importExam(JsonElement request)
- {
- //获取评测的ID
- if (!request.TryGetProperty("exam", out JsonElement exam)) return BadRequest();
- if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- ExamInfo info = exam.ToObject<ExamInfo>();
- info.progress = "going";
- await client.GetContainer(Constant.TEAMModelOS, "Common").UpsertItemAsync(info, new PartitionKey($"Exam-{code}"));
- return Ok(new { info });
- }
- catch (Exception e)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/import-exam()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- [HttpPost("import-result")]
- public async Task<IActionResult> importResult(JsonElement request)
- {
- //获取评测的ID
- if (!request.TryGetProperty("classResult", out JsonElement classResult)) return BadRequest();
- if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
- if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- List<ExamClassResultDto> examClassResultDto = new();
- examClassResultDto = classResult.ToObject<List<ExamClassResultDto>>();
- //获取本次评测所有班级作答结果
- List<ExamClassResult> examClassResults = new();
- var queryClass = $"select value(c) from c where c.examId = '{id}'";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
- {
- examClassResults.Add(item);
- }
- try
- {
- ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
- }
- catch (Exception)
- {
- return Ok(new { code = 404, msg = "请先检查该评测数据" });
- }
- List<Task<ItemResponse<ExamClassResult>>> tasks = new();
- foreach (ExamClassResultDto e in examClassResultDto)
- {
- foreach (ExamClassResult ex in examClassResults)
- {
- if (e.subject.Equals(ex.subjectId))
- {
- foreach (ClassResults examClass in e.examClassResult)
- {
- if (examClass.classInfo.id.Equals(ex.info.id))
- {
- ex.studentIds = examClass.studentIds;
- //ex.studentScores = examClass.studentScores;
- ex.studentAnswers = examClass.studentAnswers;
- ex.ans = examClass.ans;
- }
- }
- tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(ex, ex.id, new PartitionKey($"{ex.code}")));
- }
- }
- }
- await Task.WhenAll(tasks);
- return Ok(new { examClassResults });
- }
- catch (Exception e)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/import-result()\n", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- //查询名单
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("set-no-list")]
- public async Task<IActionResult> setNo()
- {
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- List<GroupList> stuSchool = new List<GroupList>();
- List<GroupList> stuTeacher = new List<GroupList>();
- var query = $"select value(c) from c where c.pk = 'GroupList'";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<GroupList>(queryText: query))
- {
- stuSchool.Add(item);
- }
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<GroupList>(queryText: query))
- {
- stuTeacher.Add(item);
- }
- foreach (GroupList stu in stuSchool)
- {
- if (string.IsNullOrEmpty(stu.no))
- {
- string channelnum = $"{_option.LocationNum}{Utils.CreatSaltString(6, "123456789")}";
- stu.no = channelnum;
- }
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(stu, stu.id);
- }
- foreach (GroupList stu in stuTeacher)
- {
- if (string.IsNullOrEmpty(stu.no))
- {
- string channelnum = $"{_option.LocationNum}{Utils.CreatSaltString(6, "123456789")}";
- stu.no = channelnum;
- }
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(stu, stu.id);
- }
- return Ok(new { code = 200 });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/setNo()\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- [ProducesDefaultResponseType]
- [HttpPost("upsert-record")]
- public async Task<IActionResult> upsertRecord(JsonElement request)
- {
- if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
- if (!request.TryGetProperty("students", out JsonElement students)) return BadRequest();
- if (!request.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
- //根据不同评测的类型返回对应的编码
- if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- //List<string> ids = students.ToObject<List<string>>();
- List<students> stus = students.ToObject<List<students>>();
- ExamInfo info = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.GetString(), new PartitionKey($"Exam-{code}"));
- string classCode = info.scope.Equals("school") ? info.school : info.creatorId;
- List<ExamClassResult> examClassResults = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(
- queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{classCode}") }))
- {
- examClassResults.Add(item);
- }
- int n = 0;
- foreach (ExamSubject subject in info.subjects)
- {
- if (!subject.id.Equals(subjectId.GetString()))
- {
- n++;
- }
- else {
- break;
- }
- }
- //获取试卷信息
- PaperSimple standerAnswers = new PaperSimple();
- List<List<string>> standard = new List<List<string>>();
- List<double> points = new List<double>();
- standerAnswers = info.papers[n];
- standard = standerAnswers.answers;
- points = standerAnswers.point;
- int rule = standerAnswers.multipleRule;
- List<string> value = new List<string>() ;
- await foreach (var s in stuTask(stus, examClassResults, standard, points, rule, info, subjectId.GetString(), client)) {
- if (s.code == 1) {
- value.Add(s.value);
- }
- }
- if (value.Count > 0)
- {
- return Ok(new { code = 1, msg = "学生ID异常", value = value });
- }
- else {
- return Ok(new { code = 0 });
- }
-
- }
- catch (Exception e)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/upsert-record()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- private async IAsyncEnumerable<(int code,string value)> stuTask(List<students> stus,List<ExamClassResult> examClassResults, List<List<string>> standard,
- List<double> points, int rule,ExamInfo info,string subjectId, CosmosClient client) {
- foreach(var s in stus)
- {
- string value = "";
- int code = 0;
- List<List<string>> ans = s.answer;
- bool isExist = examClassResults.Exists(e => e.studentIds.Contains(s.id));
- if (!isExist)
- {
- value = s.id;
- code = 1;
- }
- else
- {
- foreach (ExamClassResult result in examClassResults)
- {
- if (!result.studentIds.Contains(s.id))
- {
- continue;
- }
- else
- {
- int newIndex = result.studentIds.IndexOf(s.id);
- StringBuilder builder = new StringBuilder();
- builder.Append(result.examId).Append('/');
- builder.Append(result.subjectId).Append('/');
- builder.Append(s.id).Append('/');
- builder.Append("ans.json");
- result.studentAnswers[newIndex].Clear();
- result.studentAnswers[newIndex].Add(builder.ToString());
- result.status[newIndex] = 0;
- for (int i = 0; i < ans.Count; i++)
- {
- if (ans[i] == null)
- {
- continue;
- //ans[i] = new List<string>();
- }
- var ac = ans[i].Count;
- var sc = standard[i].Count;
- //记录次数
- int n = 0;
- //算分处理
- if (sc > 0)
- {
- result.ans[newIndex][i] = ans[i];
- if (ac == sc && sc == 1)
- {
- foreach (string right in ans[i])
- {
- if (standard[i].Contains(right))
- {
- result.studentScores[newIndex][i] = points[i];
- }
- else
- {
- result.studentScores[newIndex][i] = 0;
- }
- }
- }
- else
- {
- if (rule > 0)
- {
- int falseCount = 0;
- if (ac > 0)
- {
- foreach (string obj in ans[i])
- {
- if (!standard[i].Contains(obj))
- {
- falseCount++;
- }
- }
- switch (rule)
- {
- case 1:
- if (ac == sc)
- {
- if (falseCount == 0)
- {
- result.studentScores[newIndex][i] = points[i];
- }
- else
- {
- result.studentScores[newIndex][i] = 0;
- }
- }
- else
- {
- result.studentScores[newIndex][i] = 0;
- }
- break;
- case 2:
- if (falseCount > 0)
- {
- result.studentScores[newIndex][i] = 0;
- }
- else
- {
- if (ac == sc)
- {
- result.studentScores[newIndex][i] = points[i];
- }
- else
- {
- result.studentScores[newIndex][i] = points[i] / 2;
- }
- }
- break;
- case 3:
- if (falseCount > 0)
- {
- result.studentScores[newIndex][i] = 0;
- }
- else
- {
- if (ac == sc)
- {
- result.studentScores[newIndex][i] = points[i];
- }
- else
- {
- result.studentScores[newIndex][i] = System.Math.Round((double)ac / sc * points[i], 1);
- }
- }
- break;
- case 4:
- if (ac == sc)
- {
- result.studentScores[newIndex][i] = points[i];
- }
- else
- {
- double persent = (double)(sc - 2 * falseCount) / sc;
- if (persent <= 0)
- {
- result.studentScores[newIndex][i] = 0;
- }
- else
- {
- result.studentScores[newIndex][i] = System.Math.Round(persent * points[i], 1);
- }
- }
- break;
- }
- }
- else
- {
- result.studentScores[newIndex][i] = 0;
- }
- }
- }
- }
- }
- bool flag = true;
- foreach (List<double> scores in result.studentScores)
- {
- foreach (double score in scores)
- {
- if (score == -1)
- {
- flag = false;
- break;
- }
- }
- }
- if (flag)
- {
- result.progress = true;
- info.subjects.ForEach(s =>
- {
- if (s.id.Equals(subjectId.ToString()))
- {
- s.classCount += 1;
- }
- });
- await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, info.id.ToString(), new PartitionKey($"{info.code}"));
- }
- result.sum[newIndex] = result.studentScores[newIndex].Sum();
- await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
- break;
- }
- }
- }
- yield return (code, value);
- }
- }
- private class students {
- public string id { get; set; }
- public List<List<string>> answer { get; set; }
- }
- }
- }
- //private List<Dictionary<string, dynamic>> getKnowledgePoint(List<ExamResult> examResults, ExamInfo info)
- //{
- // Dictionary<string, object> stuMap = new Dictionary<string, object>
- // {
- // { "schoolCode", "Habook" }
- // };
- // List<Dictionary<string, object>> keyValues = new List<Dictionary<string, object>>();
- // HashSet<string> knowledge = new HashSet<string>();
- // HashSet<string> area = new HashSet<string>();
- // List<double> point = new List<double>();
- // List<List<double>> result = new List<List<double>>();
- // List<ClassRange> classes = new List<ClassRange>();
- // List<string> ids = new List<string>();
- // examResults.ForEach(e =>
- // {
- // 定位试卷信息
- // int index = 0;
- // foreach (ExamSubject subject in info.subjects)
- // {
- // if (subject.id.Equals(e.subjectId))
- // {
- // break;
- // }
- // else
- // {
- // index++;
- // }
- // }
- // info.papers[index].knowledge.ForEach(k =>
- // {
- // k.ForEach(e =>
- // {
- // knowledge.Add(e);
- // });
- // });
- // info.papers[index].field.ForEach(f =>
- // {
- // area.Add(f.ToString());
- // });
- // double Qnum = 0;
- // point = info.papers[index].point;
- // result = e.studentScores;
- // classes = e.classes;
- // ids = e.studentIds;
- // 确定高分组 低分组人数
- // List<List<double>> re = e.studentScores;
- // List<double> resultSum = new List<double>();
- // foreach (List<double> data in re)
- // {
- // resultSum.Add(data.Sum());
- // }
- // 确定高分组 最低分数
- // resultSum.Sort(delegate (double s1, double s2) { return s2.CompareTo(s1); });
- // for (int i = resultSum.Count - 1; i >= 0; i--)
- // {
- // if (resultSum[i] == 0)
- // {
- // resultSum.Remove(resultSum[i]);
- // }
- // }
- // double rhwCount = resultSum.Count * 0.27;
- // double rhw = resultSum[int.Parse(rhwCount.ToString("0"))];
- // 确定低分组 最高分数
- // resultSum.Sort(delegate (double s1, double s2) { return s1.CompareTo(s2); });
- // double rhlCount = resultSum.Count * 0.27;
- // double rhl = resultSum[int.Parse(rhwCount.ToString("0"))];
- // List<string> knowledgeName = new List<string>();
- // foreach (string cla in knowledge)
- // {
- // knowledgeName.Add(cla);
- // }
- // for (int k = 0; k < knowledgeName.Count; k++)
- // {
- // if (null == knowledgeName[k])
- // {
- // knowledgeName.Remove(knowledgeName[k]);
- // }
- // }
- // List<string> areaName = new List<string>();
- // foreach (string cla in area)
- // {
- // areaName.Add(cla);
- // }
- // for (int k = 0; k < areaName.Count; k++)
- // {
- // if (null == areaName[k])
- // {
- // areaName.Remove(areaName[k]);
- // }
- // }
- // 初始化年级总分
- // double total = 0;
- // 处理年级单个知识点得分率
- // foreach (List<double> grade in result)
- // {
- // total += grade.Sum();
- // }
- // foreach (string id in ids)
- // {
- // if (!id.Equals("0"))
- // {
- // Qnum++;
- // }
- // }
- // 试卷总分
- // double TotalPoint = point.Sum();
- // 计算认知层次占比
- // List<string> fper = new List<string>();
- // for (int a = 0; a < areaName.Count; a++)
- // {
- // double fieldPoint = 0;
- // int no = 0;
- // info.papers[index].field.ForEach(f =>
- // {
- // if (f.ToString().Equals(areaName[a], StringComparison.OrdinalIgnoreCase))
- // {
- // e.studentScores.ForEach(s =>
- // {
- // fieldPoint += s[no];
- // });
- // }
- // no++;
- // });
- // double fieldPersent = fieldPoint / TotalPoint;
- // fper.Add(fieldPersent.ToString("0.00"));
- // }
- // 求单个知识点所占分数
- // List<string> per = new List<string>();
- // List<string> gper = new List<string>();
- // List<string> knowPer = new List<string>();
- // List<Dictionary<string, double>> eper = new List<Dictionary<string, double>>();
- // Dictionary<string, object> knowledgeALL = new Dictionary<string, object>();
- // Dictionary<string, object> knowledgeMap = new Dictionary<string, object>();
- // Dictionary<string, object> classMap = new Dictionary<string, object>();
- // Dictionary<string, object> wrongMap = new Dictionary<string, object>();
- // HashSet<string> className = new HashSet<string>();
- // List<List<string>> wrongPersent = new List<List<string>>();
- // List<string> key = new List<string>
- // {
- // "id",
- // "className",
- // "seatNO",
- // "point",
- // "anwPoint",
- // "persent"
- // };
- // List<string> keyWrong = new List<string>
- // {
- // "name",
- // "point",
- // "itemNO",
- // "persent",
- // "wrong",
- // "rhw",
- // "rlw"
- // };
- // for (int k = 0; k < knowledgeName.Count; k++)
- // {
- // List<string> knowledgeClass = new List<string>();
- // List<List<string>> stuPersent = new List<List<string>>();
- // double OnePoint = 0;
- // 获取每个知识点占有多少分值
- // double ePoint = 0;
- // double anwGPoint = 0;
- // double poG = 0;
- // int m = 0;
- // List<string> valuew = new List<string>();
- // List<string> itemNo = new List<string>();
- // keyWrong.ForEach(x =>
- // {
- // valuew.Add("-");
- // });
- // int wrongCount = 0;
- // valuew[0] = knowledgeName[k];
- // int n = 0;
- // info.papers[index].knowledge.ForEach(kno =>
- // {
- // if (kno.Contains(knowledgeName[k]))
- // {
- // OnePoint += point[n];
- // itemNo.Add((n + 1).ToString());
- // }
- // valuew[1] = OnePoint.ToString();
- // string itemNos = "";
- // if (itemNo.Count > 0)
- // {
- // foreach (string np in itemNo)
- // {
- // itemNos += np + ",";
- // }
- // valuew[2] = itemNos[0..^1];
- // }
- // else
- // {
- // valuew[2] = itemNos;
- // }
- // n++;
- // });
- // int rhwC = 0;
- // int rhlC = 0;
- // foreach (string id in ids)
- // {
- // if (id.Equals("0") || result[m].Sum() == 0)
- // {
- // m++;
- // continue;
- // }
- // List<string> values = new List<string>();
- // key.ForEach(x =>
- // {
- // values.Add("-");
- // });
- // /* foreach (OldStudent info in students)
- // {
- // if (info.studentId.Equals(id))
- // {
- // values[2] = info.seatNo.ToString();
- // break;
- // }
- // }*/
- // List<string> stu = new List<string>();
- // values[0] = id;
- // values[1] = "-";
- // List<List<string>> stuItem = new List<List<string>>();
- // int statuCount = 0;
- // info.papers[index].knowledge.ForEach(kno =>
- // {
- // int sno = 0;
- // double anwPoint = 0;
- // double po = 0;
- // if (kno.Contains(knowledgeName[k]))
- // {
- // 当前认知层次在该题占比多少
- // ePoint = 1;
- // anwPoint += result[m][sno] * ePoint;
- // 所有学生单个认知层次得分情况
- // anwGPoint += result[m][sno] * ePoint;
- // po += point[sno] * ePoint;
- // 认知层次所占分数
- // poG += point[sno] * ePoint;
- // if (result[m][sno] == 0 && statuCount == 0)
- // {
- // statuCount++;
- // wrongCount++;
- // if (result[m].Sum() >= rhw)
- // {
- // rhwC++;
- // }
- // if (result[m].Sum() <= rhl)
- // {
- // rhlC++;
- // }
- // }
- // if (po == 0)
- // {
- // values[3] = "0";
- // values[4] = "0";
- // values[5] = "0";
- // }
- // else
- // {
- // double stuPser = anwPoint / po;
- // values[3] = po.ToString();
- // values[4] = anwPoint.ToString();
- // values[5] = stuPser.ToString("0.00");
- // }
- // }
- // });
- // stuPersent.Add(values);
- // m++;
- // }
- // AchievementService.ReName(stuPersent, ids, classes, students);
- // double knowPser = 0;
- // if (poG == 0)
- // {
- // knowPer.Add("0");
- // }
- // else
- // {
- // knowPser = anwGPoint / poG;
- // knowPer.Add(knowPser.ToString("0.00"));
- // }
- // 错题关系表
- // valuew[3] = knowPser.ToString("0.00");
- // valuew[4] = wrongCount.ToString();
- // valuew[5] = rhwC.ToString();
- // valuew[6] = rhlC.ToString();
- // wrongPersent.Add(valuew);
- // knowledgeMap.Add(knowledgeName[k], stuPersent);
- // 知识点占比
- // double persent = OnePoint / TotalPoint;
- // foreach (ClassRange classRange in e.classes)
- // {
- // List<string> classPoints = new List<string>();
- // 初始化班级得分
- // double anwCPoint = 0;
- // double cpo = 0;
- // for (int stuIndex = classRange.range[0]; stuIndex < classRange.range[1]; stuIndex++)
- // {
- // if (result[stuIndex].Sum() == 0) continue;
- // info.papers[index].knowledge.ForEach(kno =>
- // {
- // int x = 0;
- // if (kno.Contains(knowledgeName[k]))
- // {
- // 当前认知层次在该题占比多少
- // ePoint = 1;
- // anwCPoint += result[stuIndex][x] * ePoint;
- // cpo += point[x] * ePoint;
- // }
- // });
- // }
- // if (cpo == 0)
- // {
- // double classPser = anwCPoint / cpo;
- // knowledgeClass.Add("0");
- // }
- // else
- // {
- // double classPser = anwCPoint / cpo;
- // knowledgeClass.Add(classPser.ToString("0.00"));
- // }
- // }
- // classMap.Add(knowledgeName[k], knowledgeClass);
- // per.Add(persent.ToString("0.00"));
- // }
- // knowledgeMap.Add("grade", knowPer);
- // knowledgeMap.Add("keys", key);
- // classMap.Add("className", className);
- // wrongMap.Add("keys", keyWrong);
- // wrongMap.Add("datas", wrongPersent);
- // knowledgeALL.Add("pointList", knowledgeName);
- // knowledgeALL.Add("per", per);
- // knowledgeALL.Add("level", areaName);
- // knowledgeALL.Add("fper", fper);
- // knowledgeALL.Add("stupercent", knowledgeMap);
- // knowledgeALL.Add("classpercent", classMap);
- // knowledgeALL.Add("wrong", wrongMap);
- // keyValues.Add(knowledgeALL);
- // });
- // return keyValues;
- //}
- // }
- //}
|