12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168 |
- <?php
- /**
- * 导出报告控制器类
- * @author jiangfei
- * @date 2015-07-22 17:50:00
- * @company 上海风车教育有限公司.
- */
- class ExportController extends Controller {
- public $newline;
- private $units = array(
- 'in' => 96,
- 'cm' => 28,
- 'mm' => 2.8,
- 'pt' => 1.33,
- 'pc' => 12,
- );
- // 打印列表
- public function actionIndex() {
- $this->newline='<br>';
- $getName = safe_replace(Yii::app()->request->getQuery('realname'));
- //$getStatus = safe_replace(Yii::app()->request->getQuery('status'));
- $grade_id = safe_replace(Yii::app()->request->getQuery('grade_id'));
- $class_id = safe_replace(Yii::app()->request->getQuery('class_id'));
- $display = safe_replace(Yii::app()->request->getQuery('display'));
- $type_id = safe_replace(Yii::app()->request->getQuery('type_id'));
- //$getStatus = safe_replace(Yii::app()->request->getQuery('status'));
- $grade_class_array = array();
- $con = array();
- // 打印任务处理
- // $ExamModel = Exam::model();
- //$ClassModel = ClassModel::model();
- $printList = array();
- $grade_class_data=$this->sConn->createCommand("select class_id,class_name from class where grade='{$grade_id}' and semester_id='{$this->semesterId}'")->queryAll();
- //$grade_class_data = ClassModel::model()->findAll('grade=:grade and semester_id=:semester_id', array(':grade' => $grade_id,':semester_id'=>$this->semesterId));
- if ($grade_class_data) {
- foreach ($grade_class_data as $v) {
- $grade_class_array[$v['class_id']] = $v;
- }
- }
- // 获取当前学期班级并组装
- $criteria = new CDbCriteria();
- $criteria->addCondition('semester_id=:semester_id');
- if ($grade_id) {
- $con = array('c.grade = ' . $grade_id);
- $criteria->addCondition('grade=:grade');
- $criteria->params[':grade'] = $grade_id;
- }
- if ($class_id) {
- $con = array_merge($con, array('c.class_id = ' . $class_id));
- $criteria->addCondition('class_id=:class_id');
- $criteria->params[':class_id'] = $class_id;
- }
- if ($getName) {
- $con = array_merge($con, array("e.name like '%{$getName}%'"));
- }
- if(in_array($this->subjectId,$this->mathSubjectId)){
- $con = array_merge($con, array("e.subject_id in (".implode(',',$this->mathSubjectId).")"));
- }else{
- $con = array_merge($con, array('e.subject_id = ' . $this->subjectId));
- }
- if($display)
- {
- $con = array_merge($con, array("e.export_dispaly = 1"));
- }else
- {
- $con = array_merge($con, array("e.export_dispaly = 0"));
- }
- $con = array_merge($con, array('eg.create_type in (0,1,2,3,5,6)'));
- if($type_id){
- if($type_id==1){
- $con =array_merge($con, array('eg.is_third = 0'));
- }elseif($type_id==2){
- $con = array_merge($con, array('eg.is_third = 1'));
- $con = array_merge($con, array('eg.mark_type > 0'));
- }else{
- $con = array_merge($con, array('eg.is_third = 1'));
- $con = array_merge($con, array('eg.mark_type =0'));
- }
- }
- $criteria->params[':semester_id'] = Yii::app()->session['session_semester_id'];
- $class_array = ClassModel::model()->findAll($criteria);
- $ccArray = array();
- $ccName = array();
- foreach ($class_array as $cc => $ca) {
- array_push($ccArray, $ca->class_id);
- $ccName[$ca->class_id] = $ca->class_name;
- }
- $resultList = $this->schoolManager->getPrintListre(array_merge(array("cep.type = '0'", "(e.status = 1 or e.status=4)"), $con),array('e.complete_time desc'));
- // $resultList = $this->schoolManager->getPrintListre(array_merge(array("cep.type = '0'", "(e.status = 1 )"), $con),array('e.complete_time desc'));
- if ($resultList["rs"]) {
- foreach ($resultList['rs'] as $k => $v) {
- $printList[$k] = $v;
- $printList[$k]['class_name'] = @$ccName[$v["class_id"]];
- $printList[$k]['is_method_pdf'] = SExamTeachingProduct::isGenerate($v['exam_id'], 31); //FIXME 方法宝教师端
- $pname = $this->schoolManager->getExamName($v["exam_id"]); // 周周练名称
- $printList[$k]['print_name'] = $pname;
- //试卷类别
- if($v['is_third']==0){
- $printList[$k]['type_name'] = '校本课程平台试卷';
- }elseif($v['is_third']==1){
- if($v['mark_type']==0){
- $printList[$k]['type_name'] = '第三方导入成绩试卷';
- }else{
- $printList[$k]['type_name'] = '第三方线上阅卷试卷';
- }
- }
- if(isset(Yii::app()->params['grade_list'][$v['grade']])){
- $printList[$k]['grade_name']=Yii::app()->params['grade_list'][$v['grade']]['grade_name'];
- }else{
- $printList[$k]['grade_name']='';
- }
- }
- }
- $data = array();
- // $subject_exam_data = $this->schoolManager->getxuekeStatus($this->semesterId);
- $data['realname'] = $getName;
- $data['grade_id'] = $grade_id;
- $data['class_id'] = $class_id;
- $data['display'] = $display;
- $data['grade_class'] = $grade_class_array;
- $data['printList'] = $printList;
- $data['pages'] = $resultList['pager'];
- $data['page_total'] = $resultList['pager']->rowsCount;
- // $data["subject"] = $subject_exam_data;
- $data["subjectId"] = $this->subjectId;
- if (isset($this->schoolInfo->use_zhixue) && !empty($this->schoolInfo->use_zhixue)) {
- $data["use_zhixue"] = $this->schoolInfo->use_zhixue;
- } else {
- $data["use_zhixue"] = 0;
- }
- $data['past_sem_exist'] = 0;//默认不存在过去的学期
- $data['type_id']=$type_id;
- $sql = 'select start_time from semester where status=1 limit 1';
- $res = $this->sConn->createCommand($sql)->queryRow();
- $start_time = $res['start_time'];
- if (!$start_time) {
- Yii::app()->jump->error('该学校无当前学期,请检查学期是否设置错误');
- }
- $sql = 'select count(*) as rownum from semester where status=0 and start_time < '.$start_time;
- $res = $this->sConn->createCommand($sql)->queryRow();
- $row_num = $res['rownum'];
- $row_num && $data['past_sem_exist']=1;
- unset($resultList);
- $this->render('index', $data);
- }
- /**
- * 是否开通过方法宝
- */
- public function isOpenProductMethod($classId=0,$examId=0,$type=ProductDownload::PRODUCT_TYPE_METHOD){
- $allStudent = SStudentClassRelation::model()->getStudentInfoByClassId($classId);
- $studentIds=_array_column($allStudent,'student_id');
- $sql = "select e.name,c.class_name,c.grade,e.class_id,p.add_time,e.semester_id from exam e join class_exam_printer p on p.exam_id=e.exam_id
- join class c on e.class_id = c.class_id where e.class_id = '{$classId}' and e.exam_id = '{$examId}'";
- $names = $this->sConn->createCommand($sql)->queryRow();
- $Sem=new SSemester();
- $code= $Sem->conn->createQuery()
- ->from('semester')
- ->where("semester_id = '".$names['semester_id']."'")
- ->limit(1)
- ->query()
- ->read();
- $intarr=array(
- "schoolId"=>$this->schoolId,
- "clazzId"=>$names['class_id'],
- "semester"=>$code['refer_code'],
- "grade"=>$names['grade'],
- "students"=>$studentIds,
- "examTime"=>$names['add_time'],
- "classify"=>$type,
- "subject"=>$this->subjectId
- );
- $basic = imsBasicAuth($this->schoolId.'_'.Yii::app()->session['coachInfo']['coach_name'],Yii::app()->params["zsy_api_key"]);
- $rs = json_decode(Curl::http_post_Basic_json(Yii::app()->params["get_limit_url"], json_encode($intarr),$basic));
- //该班级是否有学生开通过方法宝
- $isClassOpen=false;
- if(isset($rs->data)){
- $limitstu=$rs->data;
- if(($limitstu==0) || (is_array($limitstu) && array_intersect($studentIds,$limitstu))){
- $isClassOpen=true;
- }
- }
- return $isClassOpen;
- }
-
- //获取错题前十和教师讲堂考试班级
- public function actionClassExamAc(){
- $examGroupId = safe_replace(Yii::app()->request->getQuery('examGroupId'));
-
- $resultList = array();
- if(is_numeric($examGroupId) && $examGroupId > 0){
- $con = array();
- $con = array_merge($con, array(" e.exam_group_id = ".$examGroupId));
-
- if(in_array($this->subjectId,$this->mathSubjectId)){
- $con = array_merge($con, array("e.subject_id in (".implode(',',$this->mathSubjectId).")"));
- }else{
- $con = array_merge($con, array('e.subject_id = ' . $this->subjectId));
- }
- $resultList = $this->schoolManager->getClassExamAc(array_merge(array("cep.type = '0'", "e.status = 1"), $con),array('e.complete_time desc'));
- }
- // var_dump($resultList);die;
- $this->render('reset_ac',array("resultList" => $resultList,'printType'=>''));
- }
- //重置错题前十和教师讲堂
- public function actionResetAc(){
- $param = Yii::app()->request->getParam('examIds');
- foreach($param as $value){
- $examId = $value[0];
- $this->setIs_new($examId);
-
- //教师讲案
- if($value[1] == 1 && $value[2] != ''){
- $status_1 = $this->sConn->createCommand()->update("exam", array("academicr_pdf_path" => '', "academicr_pdf_time" => 0, "is_academicr_pdf" => 0), "exam_id = '{$examId}'");
- }
- //错题前十
- if($value[3] == 1 && $value[4] != ''){
- $status_2 = $this->sConn->createCommand()->update("exam", array("is_topwb_pdf" => 0, "is_topwb_html" => 90), "exam_id = '{$examId}'");
- }
- }
-
- echo 1;
- }
- public function actionIndex_duo() {
- $getName = safe_replace(Yii::app()->request->getQuery('realname'));
- //$getStatus = safe_replace(Yii::app()->request->getQuery('status'));
- $grade_id = safe_replace(Yii::app()->request->getQuery('grade_id'));
- $class_id = safe_replace(Yii::app()->request->getQuery('class_id'));
- $type_id = safe_replace(Yii::app()->request->getQuery('type_id'));
- //$getStatus = safe_replace(Yii::app()->request->getQuery('status'));
- $grade_class_array = array();
- $con = array();
- // 打印任务处理
- // $ExamModel = Exam::model();
- // $ClassModel = ClassModel::model();
- $printList = array();
- $grade_class_data=$this->sConn->createCommand("select class_id,class_name from class where grade='{$grade_id}' and semester_id='{$this->semesterId}'")->queryAll();
- //$grade_class_data = ClassModel::model()->findAll('grade=:grade and semester_id=:semester_id', array(':grade' => $grade_id,':semester_id'=>$this->semesterId));
- if ($grade_class_data) {
- foreach ($grade_class_data as $v) {
- $grade_class_array[$v['class_id']] = $v;
- }
- }
- // 获取当前学期班级并组装
- $criteria = new CDbCriteria();
- $criteria->addCondition('semester_id=:semester_id');
- if ($grade_id) {
- $con = array('c.grade = ' . $grade_id);
- $criteria->addCondition('grade=:grade');
- $criteria->params[':grade'] = $grade_id;
- }
- if ($class_id) {
- $con = array_merge($con, array('c.class_id = ' . $class_id));
- $criteria->addCondition('class_id=:class_id');
- $criteria->params[':class_id'] = $class_id;
- }
- if ($getName) {
- $con = array_merge($con, array("e.name like '%{$getName}%'"));
- }
- if($type_id){
- if($type_id==1){
- $con =array_merge($con, array('eg.is_third = 0'));
- }elseif($type_id==2){
- $con = array_merge($con, array('eg.is_third = 1'));
- $con = array_merge($con, array('eg.mark_type > 0'));
- }else{
- $con = array_merge($con, array('eg.is_third = 1'));
- $con = array_merge($con, array('eg.mark_type =0'));
- }
- }
- if(in_array(Yii::app()->session['session_duoxueke_subject_id'],$this->mathSubjectId)){
- $con = array_merge($con, array("e.subject_id in (".implode(',',$this->mathSubjectId).")"));
- }else{
- $con = array_merge($con, array('e.subject_id = ' . Yii::app()->session['session_duoxueke_subject_id']));
- }
- $criteria->params[':semester_id'] = Yii::app()->session['session_semester_id'];
- $class_array = ClassModel::model()->findAll($criteria);
- $ccArray = array();
- $ccName = array();
- foreach ($class_array as $cc => $ca) {
- array_push($ccArray, $ca->class_id);
- $ccName[$ca->class_id] = $ca->class_name;
- }
- $resultList = $this->schoolManager->getPrintListre(array_merge(array("cep.type = '0'", "(e.status = 1 or e.status=4)"), $con),array('e.complete_time desc'));
- //$resultList = $this->schoolManager->getPrintListre(array_merge(array("cep.type = '0'", "(e.status = 1)"), $con),array('e.complete_time desc'));
- if ($resultList["rs"]) {
- foreach ($resultList['rs'] as $k => $v) {
- $printList[$k] = $v;
- $printList[$k]['class_name'] = @$ccName[$v["class_id"]];
- // $pname = @$ExamModel->getExamName($v["exam_id"]); // 周周练名称
- $pname = $this->schoolManager->getExamName($v["exam_id"]); // 周周练名称
- $printList[$k]['print_name'] = $pname;
- //试卷类别
- if($v['is_third']==0){
- $printList[$k]['type_name'] = '校本课程平台试卷';
- }elseif($v['is_third']==1){
- if($v['mark_type']==0){
- $printList[$k]['type_name'] = '第三方导入成绩试卷';
- }else{
- $printList[$k]['type_name'] = '第三方线上阅卷试卷';
- }
- }
- if(isset(Yii::app()->params['grade_list'][$v['grade']])){
- $printList[$k]['grade_name']=Yii::app()->params['grade_list'][$v['grade']]['grade_name'];
- }else{
- $printList[$k]['grade_name']='';
- }
- //判断是否上传答案、试题
- $uploadExamInfo=SThirdMultiTemplate::model()->getStatusByExamGroupId($v['exam_group_id']);
- $uploadStatus=0;
- if($uploadExamInfo){
- if(isset($uploadExamInfo[1])){
- if($uploadExamInfo[1]['topic_upload']==1){
- $uploadStatus+=1;
- }
- }
- if(isset($uploadExamInfo[2])){
- if($uploadExamInfo[2]['answer_upload']==1){
- $uploadStatus+=3;
- }
- }
- }
- if($uploadStatus<4){
- $printList[$k]['topic_answer_upload']=0;
- }else{
- $printList[$k]['topic_answer_upload']=1;
- }
- }
- }
- $data = array();
- // $subject_exam_data = $this->schoolManager->getxuekeStatus($this->semesterId);
- $data['realname'] = $getName;
- $data['grade_id'] = $grade_id;
- $data['class_id'] = $class_id;
- $data['grade_class'] = $grade_class_array;
- $data['printList'] = $printList;
- $data['pages'] = $resultList['pager'];
- $data['page_total'] = $resultList['pager']->rowsCount;
- // $data["subject"] = $subject_exam_data;
- $data["subjectId"] = $this->subjectId;
- if (isset($this->schoolInfo->use_zhixue) && !empty($this->schoolInfo->use_zhixue)) {
- $data["use_zhixue"] = $this->schoolInfo->use_zhixue;
- } else {
- $data["use_zhixue"] = 0;
- }
- $data['past_sem_exist'] = 0;//默认不存在过去的学期
- $data['type_id']=$type_id;
- $sql = 'select start_time from semester where status=1 limit 1';
- $res = $this->sConn->createCommand($sql)->queryRow();
- $start_time = $res['start_time'];
- if (!$start_time) {
- Yii::app()->jump->error('该学校无当前学期,请检查学期是否设置错误');
- }
- $sql = 'select count(*) as rownum from semester where status=0 and start_time < '.$start_time;
- $res = $this->sConn->createCommand($sql)->queryRow();
- $row_num = $res['rownum'];
- $row_num && $data['past_sem_exist']=1;
- unset($resultList);
- $this->render('index1', $data);
- }
- // 更新试卷为打印状态
- public function actionExcel() {
- $classId = safe_replace(Yii::app()->request->getQuery('classId'));
- $examId = safe_replace(Yii::app()->request->getQuery('examId'));
- $is_outer = safe_replace(Yii::app()->request->getQuery('is_outer'));
- $type = safe_replace(Yii::app()->request->getQuery('type'));
- $type = !in_array($type, array('excel', 'word')) ? 'excel' : $type;
- $url = Yii::app()->params['te_url'] . "wp/reportExcel?wpId={$examId}&classId={$classId}&schoolId={$this->schoolId}&type={$type}&is_outer={$is_outer}";
- $this->redirect($url);
- }
- /**
- * 重置教师讲案
- */
- public function actionreload_academicr(){
- $examId = safe_replace(Yii::app()->request->getQuery('examId'));
- $type = safe_replace(Yii::app()->request->getQuery('type'));
- $this->setIs_new($examId);
- if($type==1){//教师讲案
- if($this->sConn->createCommand()->update("exam", array("academicr_pdf_path" => '', "academicr_pdf_time" => 0, "is_academicr_pdf" => 0), "exam_id = '{$examId}'")){
- echo json_encode(array("status"=>0));exit;
- }
- }elseif($type==2){//错题前十
- $status = $this->sConn->createCommand()->update("exam", array("is_topwb_pdf" => 0, "is_topwb_html" => 90), "exam_id = '{$examId}'");
- if($status !== false){
- $sql = 'select exam_group_id from exam where exam_id = '.$examId;
- $res = $this->sConn->createCommand($sql)->queryRow();
- if (isset($res['exam_group_id'])) {
- //发送消息
- $sendMsg = array(
- 'school_id' => $this->schoolId,
- 'msg_type' => 90,
- 'subject_id' => 3,
- 'send_type' => 'exam',
- 'product_type' => array(14),
- 'exam_group_id' => $res['exam_group_id'],
- 'exam_ids' => array($examId),
- 'complete_rate' => 0.9,
- );
- sendDataToKafka('xbkc-php-product-html',$sendMsg);
- echo json_encode(array("status"=>0));exit;
- }
- }
- }elseif ($type==3){
- if($this->sConn->createCommand()->update("exam_teaching_product", array("is_create_pdf" => 0,"pdf_path"=>""), "exam_id = '{$examId}' and product_type=31")){
- echo json_encode(array("status"=>0));exit;
- }
- }
- echo json_encode(array("status"=>1));exit;
- }
- /**
- * 下载教师讲案
- */
- public function actionAcademicr() {
- @ini_set('default_socket_timeout', 5);
- @ini_set('memory_limit', '512M');
- set_time_limit(0);
- $examId = safe_replace(Yii::app()->request->getQuery('examId'));
- $classId = safe_replace(Yii::app()->request->getQuery('classId'));
- $force = safe_replace(Yii::app()->request->getQuery('force'));
- $isFromPast = safe_replace(Yii::app()->request->getQuery('isFromPast')); //过去学期的教师讲案如果需要生成的话,只生成个性化版的,不生成分层版的
- $sem = new SSemester();
- $codeNow = $sem->getCodeByExamId($examId);
- $this->setIs_new($examId);
- $sql = "select e.teacher_id,eg.mark_type,e.name as exam_name,e.academicr_pdf_path,e.academicr_pdf_time,p.paper_id,e.is_academicr_pdf,c.class_name,eg.import_score_type,c.grade,p.method_ids,e.semester_id from exam as e left join class as c on c.class_id=e.class_id left join exam_group as eg on e.exam_group_id=eg.exam_group_id left join paper as p on p.exam_id=e.exam_id where e.exam_id={$examId}";
- $exam_info = $this->sConn->createCommand($sql)->queryRow();
- $grade = $exam_info['grade'];
- $paper_method_ids = $exam_info['method_ids'];
- $score_type = $exam_info['import_score_type'];//成绩导入流程 0-正常扫描
- $semesterId = $exam_info['semester_id'];
- // $pdfpath = str_replace("protected", "", Yii::app()->basePath) . $exam_info['academicr_pdf_path'];
-
- $pdfurl = $pdfpath = $exam_info['academicr_pdf_path'];
- $is_create=1;
- $force=0;
- if(strpos($pdfurl,'http') !== false){
- // if(!file_get_contents($pdfurl)){
- if(!$this->curlDownloadImage($pdfurl)){
- $force = 1;
- }
- }else{
- $force = 1;
- }
- if (!$exam_info['academicr_pdf_path'] || $exam_info['is_academicr_pdf'] == 0 || $force) {
- $is_create=0;
- $sql = "SELECT e.exam_group_id, e.exam_id, e.name AS exam_name, e.create_time AS exam_time, p.paper_id, p.score as paper_score, e.class_id,e.is_preparation_created,e.tpl_index, eg.mark_type,p.is_labelled,p.labelled_type,eg.qxk_paper_id ";
- $sql.= "FROM exam e ";
- $sql.= "JOIN paper p ON p.exam_id = e.exam_id ";
- $sql.= "JOIN exam_group eg ON eg.exam_group_id = e.exam_group_id ";
- $sql.= "WHERE e.status = '1' AND e.exam_id = '{$examId}' ";
- $data = array();
- $exam = $this->sConn->createCommand($sql)->queryRow();
- $labelled_type = $exam['labelled_type'];
- $class_id = $exam['class_id'];
- $is_qxk = $exam['qxk_paper_id']?1:0;//是否是全学科
- if($class_id){
- $exam['show_level'] = $this->get_version($class_id);
- $exam['level_rule'] = $this->get_level_rule($class_id);
- }
-
- //获取显示设置
- $setting_arr = array("common"=>1,"common_wrong"=>1,"paper"=>1,"paper_wrong"=>1,"real_topic"=>1,"classmateOptimization"=>1);
- $sql = "select tt.template_id,tt.config_text from teaching_template tt join teaching_class_set tcs on tt.template_id=tcs.template_id where tt.subject_id = 3 and tcs.class_id='{$class_id}'";
- $setting_data = $this->sConn->createCommand($sql)->queryRow();
- if($setting_data){
- $setting_data_arr = json_decode($setting_data['config_text'],true);
- if(isset($setting_data_arr['common'])){
- $setting_arr['common'] = $setting_data_arr['common'];
- }
- if(isset($setting_data_arr['common_wrong'])){
- $setting_arr['common_wrong'] = $setting_data_arr['common_wrong'];
- }
- if(isset($setting_data_arr['paper'])){
- $setting_arr['paper'] = $setting_data_arr['paper'];
- }
- if(isset($setting_data_arr['paper_wrong'])){
- $setting_arr['paper_wrong'] = $setting_data_arr['paper_wrong'];
- }
- if(isset($setting_data_arr['real_topic'])){
- $setting_arr['real_topic'] = $setting_data_arr['real_topic'];
- }
- if(isset($setting_data_arr['classmateOptimization'])){
- $setting_arr['classmateOptimization'] = $setting_data_arr['classmateOptimization'];
- }
- }
- $is_same_bs = 1;//是否开启相同变式题(需要读提分宝班级定制的配置)
- $same_bs_data = array();//开启相同变式题 原题跟变式题的对应关系
- $is_same_bs = $this->getClassSet($classId, $semesterId);
- if($is_same_bs && $labelled_type == 1){
- //判断有没有订单(提分方案2,提分宝3) 如果没有订单生成教学宝 有订单没数据不能生成
- $has_order = 0;
- $table_spr = empty($codeNow)?'student_paper_relation':'student_paper_relation_'.$codeNow;
-
- $sql = "select student_id from {$table_spr} where exam_id = '{$examId}'";
- $spr_data = $this->sConn->createCommand($sql)->queryAll();
- $relateStudentRes = array();
- if($spr_data){
- foreach($spr_data as $spr_v){
- $relateStudentRes[]['student_id'] = $spr_v['student_id'];
- }
- }
- foreach(array(2,3) as $product_type){
- $temp_order = $this->getOrderStu($examId, $classId, $product_type, $relateStudentRes, $semesterId, $grade);
- if($temp_order && isset($temp_order['limitstu']) && $temp_order['limitstu']){
- $has_order = 1;
- break;
- }
- }
-
- $sql = "select preparation_plan_id,template_id,topic_id from preparation_plan_topic where preparation_plan_id='{$examId}'";
- $same_bs = $this->sConn->createCommand($sql)->queryAll();
- if($same_bs){
- foreach($same_bs as $same_k=>$same_v){
- $same_bs_data[$same_v['template_id']][] = $same_v['topic_id'];
- }
- }else{
- if($has_order){
- echo json_encode(array("status"=>1,"error"=>"变式题未生成,请等待"));
- exit;
- }
- }
- $setting_arr['common'] = 0;
- }
- if($labelled_type == 2){
- $exam['show_level'] = 0;
- }else{
- $sql = "select switch from producut_set_edition";
- $switch_data = $this->sConn->createCommand($sql)->queryRow();
- if($switch_data && in_array($switch_data['switch'],array(3,4))){
- $exam['show_level'] = 0;
- $sql = "select template_id,topic_id,topic_type from product_common_topic where exam_id = '{$examId}' and is_action=0 order by topic_type asc";
- $gongxing_data = $this->sConn->createCommand($sql)->queryAll();
- if(!$gongxing_data && !$is_same_bs){
- echo json_encode(array("status"=>1,"error"=>"共性问题未生成,请稍等"));
- exit;
- }
- }else{
- if ($exam && !$isFromPast && $exam['show_level'] == 1 && $exam['is_preparation_created'] != 1) { //如果选择的是分层班,教师讲案的生成条件是教师讲评题已经抽出
- echo json_encode(array("status"=>1,"error"=>"文件内容尚未生成,请等待"));
- exit;
- }elseif ($exam && !$isFromPast && $exam['show_level'] == 1 && $exam['is_preparation_created'] == 2) {
- echo json_encode(array("status"=>1,"error"=>"由于题库题目导致无法生成,请联系后台题库老师去处理题目!"));
- exit;
- }
- }
- }
- if (!isset($exam['is_labelled']) || $exam['is_labelled']!=1) {
- echo json_encode(array("status"=>1,"error"=>"试卷还未标注,请先标注试卷"));
- exit;
- }
- // if($switch_data && in_array($switch_data['switch'],array(3,4))){
- // $sql = "select template_id,topic_id,topic_type from product_common_topic where exam_id = '{$examId}' order by topic_type asc";
- // $gongxing_data = $this->sConn->createCommand($sql)->queryAll();
- // if(!$gongxing_data){
- // echo json_encode(array("status"=>1,"error"=>"共性问题未生成,请稍等"));
- // exit;
- // }
- // }
-
- if ($exam) {
- //同学优解
- $staticUrl = Yii::app()->params['static_url'][$this->schoolGroupId];
- $excellent_solution = SStudentPaperTopicRs::model()->bestAnswer($exam,$codeNow,$staticUrl,$this->sConn,$is_qxk);
- //获取共性问题
- $has_topic_gaokao = array();//本教学宝其他题,用于抽取高考真题
- $gen_topics = array();
- $gen_topics_ids = array();//共性所有题ID集合
- $gen_topics_detail = array();//试题详情
- $gen_topics_msg = array();//题目难度、考点、挑战信息
- $schoolId = $this->schoolId;//当前学校
- $school_province_name = "";//学校省份
- $school_province_id = 0;//学校省份Id
- $gen_origin_ids = array();//共性原题Id
- $gen_origin_methods = array();//共性原题考点集合
-
- $school_msg = Yii::app()->businessDb->createCommand()->from('school')
- ->select("province_id")
- ->where("school_id = ".$schoolId)
- ->queryRow();
- if($school_msg){
- $school_province_id = $school_msg['province_id'];
- }
- if($school_province_id){
- $region_msg = Yii::app()->businessDb->createCommand()->from('region')
- ->select("region_name")
- ->where("region_id = ".$school_province_id)
- ->queryRow();
- if($region_msg){
- $school_province_name = $region_msg["region_name"];
- }
- }
- $sql = "select template_id,topic_id,topic_type,template_no from product_common_topic where exam_id = '{$examId}' and is_action=0 order by topic_type asc";
- $gongxing_data = $this->sConn->createCommand($sql)->queryAll();
- if($gongxing_data && $labelled_type != 2){
- foreach($gongxing_data as $k=>$v){
- $i = 0;
- $gen_topics_ids[] = $gen_origin_ids[] = $v['template_id'];
- $gen_topics_ids[] = $v['topic_id'];
- $gen_topics[$v['topic_type']][$i]['topic_id'] = $v['template_id'];
- $gen_topics[$v['topic_type']][$i]['is_template'] = 1;
- $i++;
- $gen_topics[$v['topic_type']][$i]['topic_id'] = $v['topic_id'];
- $gen_topics[$v['topic_type']][$i]['is_template'] = 0;
- //变式训练获取地区挑战数
- if($v['topic_id']){
- $gen_topics_msg[$v['topic_id']]['school_province_name'] = $school_province_name;
- $topic_count = Yii::app()->topic_province_count->hmget('province_stat:topic:'.$school_province_id,array($v['topic_id']));
- if($topic_count && isset($topic_count[0])){
- $gen_topics_msg[$v['topic_id']]['province_count'] = empty($topic_count[0])?1000:$topic_count[0]+1000;
- }else{
- $gen_topics_msg[$v['topic_id']]['province_count'] = 1000;
- }
- $gen_topics_msg[$v['template_id']]['template_no'] = $v['template_no'];
- }
- }
- }
- $gen_topics_ids = array_values(array_unique($gen_topics_ids));
- if($gen_topics_ids){
- $topicItems_1 = $this->aipost('/topic/batchAll', array('topicIds' => $gen_topics_ids));
- //debug($topicItems_1);
- if ($topicItems_1 && !isset($topicItems_1['status'])) {
- foreach ($topicItems_1 as $topicItem) {
- $gen_topics_detail_temp[$topicItem['id']] = $topicItem;
- }
-
- if ($gen_topics_detail_temp) {
- foreach ($gen_topics_detail_temp as $k => $v) {
- $v=(array)$v;
- $teacher_tips= isset($v['teacher_tips'])?$v['teacher_tips']:"";
- if(!$teacher_tips){
- $teacher_tips = $this->dealTeacherTips($v);
- }
- $v['teacher_tips'] = $this->topicProcess($teacher_tips);
- $v['parse_content'] = $this->topicProcess($v['parse_content']);
- if($v['type_id'] == 5 || $v['type_id'] == 6){
- $v['title'] = preg_replace("/<img[^>]*[\s]+src[\s]*=[\s]*(([\'\"](\/images\/list_\d\.png)[\'\"])|(\/images\/list_\d\.png))[^>]*>/si", '__________', $v['title']);
- }
- $v['title'] = $this->topicProcess($v['title']);
- if(isset($v['items'][0])){
- $v['items'][0]=(array)$v['items'][0];
- $v['items'][0]['options']=(array)$v['items'][0]['options'];
- if (isset($v['items']) && isset($v['items'][0]) && isset($v['items'][0]['options'])) {
- foreach ($v['items'][0]['options'] as $key => $val) {
- $val=(array)$val;
- $v['items'][0]['options'][$key]=(array)$v['items'][0]['options'][$key];
- $v['items'][0]['options'][$key]['option_content'] = $this->topicProcess($val['option_content']);
- }
- }
- }
- //难度
- $gen_topics_msg[(string)$v['id']]['difficulty'] = isset($v['difficulty_degree'])?$v['difficulty_degree']:0;
- //考点
- $gen_topics_msg[(string)$v['id']]['methods'] = "";
- $methods_arr = array();
- if(isset($v['specials']) && $v['specials']){
- foreach($v['specials'] as $specials){
- if(isset($specials['method_name'])){
- $methods_arr[] = $specials['method_name'];
- }
- if(in_array($v['id'],$gen_origin_ids)){
- $gen_origin_methods[$specials['method_id']] = $specials['method_name'];
- }
- }
- }elseif (isset($v['kps']) && $v['kps']){
- foreach($v['kps'] as $kps){
- if(isset($kps['kp_name'])){
- $methods_arr[] = $kps['kp_name'];
- }
- if(in_array($v['id'],$gen_origin_ids)){
- $gen_origin_methods[$kps['kp_id']] = $kps['kp_name'];
- }
- }
- }
- if($methods_arr){
- $gen_topics_msg[$v['id']]['methods'] = implode(",",$methods_arr);
- }
- $gen_topics_detail[$v['id']] = $v;
- }
- }
- unset($gen_topics_detail_temp);
- }
- unset($topicItems_1);
- }
- //年级共性问题
- $grade_topics_ids = array();
- $grade_topic_data = array();
- $sql = "select topic_id from product_grade_common_topic where exam_group_id = '{$exam['exam_group_id']}'";
- $grade_data = $this->sConn->createCommand($sql)->queryAll();
- if($grade_data){
- foreach($grade_data as $k=>$v){
- $grade_topics_ids[] = $v['topic_id'];
- }
- }
-
- if($grade_topics_ids){
- $grade_topic_item = $this->aipost('/topic/batchAll', array('topicIds' => $grade_topics_ids));
- if ($grade_topic_item && !isset($grade_topic_item['status'])) {
- foreach ($grade_topic_item as $k => $v) {
- $v['parse_content'] = $this->topicProcess($v['parse_content']);
- if($v['type_id'] == 5 || $v['type_id'] == 6){
- $v['title'] = preg_replace("/<img[^>]*[\s]+src[\s]*=[\s]*(([\'\"](\/images\/list_\d\.png)[\'\"])|(\/images\/list_\d\.png))[^>]*>/si", '__________', $v['title']);
- }
- $v['title'] = $this->topicProcess($v['title']);
- if(isset($v['items'][0])){
- if (isset($v['items']) && isset($v['items'][0]) && isset($v['items'][0]['options'])) {
- foreach ($v['items'][0]['options'] as $key => $val) {
- $v['items'][0]['options'][$key]=(array)$v['items'][0]['options'][$key];
- $v['items'][0]['options'][$key]['option_content'] = $this->topicProcess($val['option_content']);
- }
- }
- }
- $grade_topic_item[$k] =$v;
- }
- $grade_topic_data = $grade_topic_item;
- }
- }
- $data['grade_topic_data'] = $grade_topic_data;
- $data['gen_origin_methods'] = $gen_origin_methods?implode(",",$gen_origin_methods):"";
- $data['gen_topics_msg'] = $gen_topics_msg;
- $data['gen_topics'] = $gen_topics;
- $data['gen_topics_detail'] = $gen_topics_detail;
- $data['excellent_solution'] = $excellent_solution;
- $data['wb_isp_version'] = $exam['show_level'];
- $data['level_rule'] = $exam['level_rule'];
- $data['examGroups'] = array();
- $data['examGroupIds'] = array();
- $data['exams'] = array();
- $data['examIds'] = array();
- $data['prevExams'] = array();
- $data['prevExamIds'] = array();
- $data['papers'] = array();
- $data['paperIds'] = array();
- $data['prevPapers'] = array();
- $data['prevPaperIds'] = array();
- $data['fcTopicIds'] = array();
- $data['methodIds'] = array();
- $data['methodNames'] = array();
- $data['topicIds'] = array();
- $data['noTopicIds'] = array();
- $data['topicDetails'] = array();
- $data['answer_score_details'] = array();//客观题答案明细
- if (!isset($data['examGroups'][$exam['exam_group_id']])) {
- $data['examGroups'][$exam['exam_group_id']] = array(
- 'examIds' => array(),
- 'paperIds' => array(),
- 'examName' => $exam['exam_name'],
- 'examTime' => $exam['exam_time'],
- 'fullScore' => $exam['paper_score'],
- );
- }
- $data['examGroups'][$exam['exam_group_id']]['examIds'][] = $exam['exam_id'];
- $data['examGroups'][$exam['exam_group_id']]['paperIds'][] = $exam['paper_id'];
- if (!isset($data['exams'][$exam['exam_id']])) {
- $data['exams'][$exam['exam_id']] = array(
- 'paperIds' => array(),
- 'examName' => $exam['exam_name'],
- 'examTime' => $exam['exam_time'],
- 'examGroupId' => $exam['exam_group_id'],
- 'fullScore' => $exam['paper_score'],
- );
- }
- $data['exams'][$exam['exam_id']]['paperIds'][] = $exam['paper_id'];
- if (!isset($data['papers'][$exam['paper_id']])) {
- $data['papers'][$exam['paper_id']] = array();
- }
- $data['papers'][$exam['paper_id']]['examId'] = $exam['exam_id'];
- $data['papers'][$exam['paper_id']]['examName'] = $exam['exam_name'];
- $data['papers'][$exam['paper_id']]['examTime'] = $exam['exam_time'];
- $data['papers'][$exam['paper_id']]['examGroupId'] = $exam['exam_group_id'];
- $data['papers'][$exam['paper_id']]['fullScore'] = $exam['paper_score'];
- $data['examGroupIds'][] = $exam['exam_group_id'];
- $data['examIds'][] = $exam['exam_id'];
- $data['paperIds'][] = $exam['paper_id'];
- // 上一次考试
- $sql = "SELECT e.exam_id, p.paper_id
- FROM exam e
- JOIN paper p ON p.exam_id = e.exam_id
- WHERE e.subject_id in(".implode(',',$this->mathSubjectId).") and e.class_id = '" . $exam['class_id'] . "' AND e.create_time < '" . $exam['exam_time'] . "' AND e.status = '1'
- ORDER BY e.create_time DESC
- LIMIT 1";
- $query = $this->sConn->createCommand($sql)->queryRow();
- if ($query) {
- $codePrev = $sem->getCodeByExamId($query['exam_id']);
- $data['prevExamIds'][] = $query['exam_id'];
- $data['prevPaperIds'][] = $query['paper_id'];
- $data['exams'][$exam['exam_id']]['prevExamId'] = $query['exam_id'];
- $data['papers'][$exam['paper_id']]['prevPaperId'] = $query['paper_id'];
- $data['prevExams'][$query['exam_id']] = $exam['exam_id'];
- $data['prevPapers'][$query['paper_id']] = $exam['paper_id'];
- // 上次考试总分
- $prevQuery = $this->sConn->createCommand("
- SELECT score
- FROM paper
- WHERE paper_id = '" . $query['paper_id'] . "'
- ")->queryRow();
- if ($prevQuery) {
- $data['papers'][$exam['paper_id']]['prevFullScore'] = $prevQuery['score'];
- }
- unset($prevQuery);
- // 上次考试的平均得分率
- if(empty($codePrev)){
- $prevQuery = $this->sConn->createCommand("
- SELECT paper_id, COUNT(student_id) AS total_num, SUM(scoring) AS total_score, MAX(scoring) AS max_score, MIN(scoring) AS min_score
- FROM student_paper_relation
- WHERE is_feedback = '1' AND paper_id = '" . $query['paper_id'] . "'
- ")->queryRow();
- }else{
- $prevQuery = $this->sConn->createCommand("
- SELECT paper_id, COUNT(student_id) AS total_num, SUM(scoring) AS total_score, MAX(scoring) AS max_score, MIN(scoring) AS min_score
- FROM student_paper_relation_".$codePrev."
- WHERE is_feedback = '1' AND paper_id = '" . $query['paper_id'] . "'
- ")->queryRow();
- }
-
- if ($prevQuery) {
- $data['papers'][$exam['paper_id']]['prevTotalNum'] = $prevQuery['total_num'];
- $data['papers'][$exam['paper_id']]['prevTotalScore'] = $prevQuery['total_score'];
- $data['papers'][$exam['paper_id']]['prevMaxScore'] = $prevQuery['max_score'];
- $data['papers'][$exam['paper_id']]['prevMinScore'] = $prevQuery['min_score'];
- $data['papers'][$exam['paper_id']]['prevAvgScore'] = 0;
- $data['papers'][$exam['paper_id']]['prevAvgRate'] = 0;
- if ($prevQuery['total_num'] > 0) {
- $data['papers'][$exam['paper_id']]['prevAvgScore'] = number_format($prevQuery['total_score'] / $prevQuery['total_num'], 2);
- if (isset($data['papers'][$exam['paper_id']]['prevFullScore']) && $data['papers'][$exam['paper_id']]['prevFullScore'] > 0) {
- $data['papers'][$exam['paper_id']]['prevAvgRate'] = number_format($prevQuery['total_score'] / ($prevQuery['total_num'] * $data['papers'][$exam['paper_id']]['prevFullScore']), 4) * 100;
- }
- }
- }
- }
- unset($query);
- // 参加考试人数、平均得分率、平均分、及格率、最高分、最低分
- if(empty($codeNow)){
- $query = $this->sConn->createCommand("
- SELECT paper_id, COUNT(student_id) AS total_num, SUM(scoring) AS total_score, MAX(scoring) AS max_score, MIN(scoring) AS min_score
- FROM student_paper_relation
- WHERE is_feedback = '1' AND paper_id IN (" . implode(',', $data['paperIds']) . ")
- GROUP BY paper_id
- ")->queryAll();
- }else{
- $query = $this->sConn->createCommand("
- SELECT paper_id, COUNT(student_id) AS total_num, SUM(scoring) AS total_score, MAX(scoring) AS max_score, MIN(scoring) AS min_score
- FROM student_paper_relation_".$codeNow."
- WHERE is_feedback = '1' AND paper_id IN (" . implode(',', $data['paperIds']) . ")
- GROUP BY paper_id
- ")->queryAll();
- }
-
- if ($query) {
- foreach ($query as $k => $v) {
- $data['papers'][$v['paper_id']]['totalNum'] = $v['total_num'];
- $data['papers'][$v['paper_id']]['totalScore'] = $v['total_score'];
- $data['papers'][$v['paper_id']]['maxScore'] = $v['max_score'];
- $data['papers'][$v['paper_id']]['minScore'] = $v['min_score'];
- $data['papers'][$v['paper_id']]['avgScore'] = 0;
- $data['papers'][$v['paper_id']]['avgRate'] = 0;
- $data['papers'][$v['paper_id']]['avgFluctuate'] = 0;
- if ($v['total_num'] > 0) {
- $data['papers'][$v['paper_id']]['avgScore'] = number_format($v['total_score'] / $v['total_num'], 2);
- if (isset($data['papers'][$exam['paper_id']]['fullScore']) && $data['papers'][$exam['paper_id']]['fullScore'] > 0) {
- $data['papers'][$v['paper_id']]['avgRate'] = number_format($v['total_score'] / ($v['total_num'] * $data['papers'][$exam['paper_id']]['fullScore']), 4) * 100;
- if (isset($data['papers'][$v['paper_id']]['prevAvgRate'])) {
- $data['papers'][$v['paper_id']]['avgFluctuate'] = number_format($data['papers'][$v['paper_id']]['avgRate'] - $data['papers'][$v['paper_id']]['prevAvgRate'], 2);
- }
- }
- }
- }
- }
- unset($query);
- // 单题班级情况
- if(empty($codeNow)){
- $sql = "
- SELECT sptr.student_id, sptr.paper_id, sptr.topic_id, sptr.is_right, sptr.scoring, ptr.score, sptr.handlerIndex
- FROM student_paper_topic_rs sptr
- JOIN paper_topic_relation ptr ON (ptr.paper_id = sptr.paper_id AND ptr.topic_id = sptr.topic_id) where 1=1 ";
- //WHERE sptr.handlerIndex = '1'";
- }else{
- $sql = "
- SELECT sptr.student_id, sptr.paper_id, sptr.topic_id, sptr.is_right, sptr.scoring, ptr.score, sptr.handlerIndex
- FROM student_paper_topic_rs_".$codeNow." sptr
- JOIN paper_topic_relation ptr ON (ptr.paper_id = sptr.paper_id AND ptr.topic_id = sptr.topic_id) where 1=1 ";
- //WHERE sptr.handlerIndex = '1'";
- }
-
- $sql.="AND sptr.paper_id IN (" . implode(',', $data['paperIds']) . ")";
- $query = $this->sConn->createCommand($sql)->queryAll();
- $class_topic_score = array();
- $topic_score_arr = array();
- if ($query) {
- $data['papers'][$v['paper_id']]['topics'] = array();
- foreach ($query as $k => $v) {
- if (!isset($data['papers'][$v['paper_id']]['topics'][$v['topic_id']])) {
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']] = array();
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['fullScore'] = $v['score'];
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['totalScore'] = 0;
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['avgScore'] = 0;
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['avgRate'] = 0;
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['numRight'] = 0;
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['numWrong'] = 0;
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['studentIds'] = array();
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['rateLess70'] = array();//得分率低于70%的,选择题错的
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['classRate'] = 0;
- }
- $topic_score_arr[$v['topic_id']] = $v['score'];
- //班级得分
- if (!isset($class_topic_score[$v['paper_id']])) {
- $class_topic_score[$v['paper_id']] = array();
- }
- if (!isset($class_topic_score[$v['paper_id']][$v['topic_id']])) {
- $class_topic_score[$v['paper_id']][$v['topic_id']] = array();
- }
- $class_topic_score[$v['paper_id']][$v['topic_id']][] = $v['scoring'];
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['totalScore'] += $v['scoring'];
- if ($v['is_right'] == 1) {
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['numRight'] ++;
- } else {
- if($v["handlerIndex"]==1){
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['numWrong'] ++;
- }
- }
- if($v["handlerIndex"]==1){
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['studentIds'][] = $v['student_id'];
- }
- if ($v['score'] && ($v['scoring']/$v['score'] < 0.7 && $v["handlerIndex"]==1)) {
- $data['papers'][$v['paper_id']]['topics'][$v['topic_id']]['rateLess70'][] = $v['student_id'];
- }
- }
- }
- unset($query);
- // 缺考人数
- if(empty($codeNow)){
- $query = $this->sConn->createCommand("
- SELECT paper_id, COUNT(student_id) AS absent_num
- FROM student_paper_relation
- WHERE is_feedback = '0' AND paper_id IN (" . implode(',', $data['paperIds']) . ")
- GROUP BY paper_id
- ")->queryAll();
- }else{
- $query = $this->sConn->createCommand("
- SELECT paper_id, COUNT(student_id) AS absent_num
- FROM student_paper_relation_".$codeNow."
- WHERE is_feedback = '0' AND paper_id IN (" . implode(',', $data['paperIds']) . ")
- GROUP BY paper_id
- ")->queryAll();
- }
-
- if ($query) {
- foreach ($query as $k => $v) {
- $data['papers'][$v['paper_id']]['absentNum'] = $v['absent_num'];
- }
- }
- unset($query);
- // 及格率
- if(empty($codeNow)){
- $query = $this->sConn->createCommand("
- SELECT paper_id, student_id, scoring
- FROM student_paper_relation
- WHERE is_feedback = '1' AND paper_id IN (" . implode(',', $data['paperIds']) . ")
- ")->queryAll();
- }else{
- $query = $this->sConn->createCommand("
- SELECT paper_id, student_id, scoring
- FROM student_paper_relation_".$codeNow."
- WHERE is_feedback = '1' AND paper_id IN (" . implode(',', $data['paperIds']) . ")
- ")->queryAll();
- }
-
- if ($query) {
- foreach ($query as $k => $v) {
- if (!isset($data['papers'][$exam['paper_id']]['passNum'])) {
- $data['papers'][$exam['paper_id']]['passNum'] = 0;
- $data['papers'][$exam['paper_id']]['passNum_90'] = 0;
- }
- if (isset($data['papers'][$exam['paper_id']]['fullScore']) && $data['papers'][$exam['paper_id']]['fullScore'] > 0) {
- if ($v['scoring'] / $data['papers'][$exam['paper_id']]['fullScore'] >= 0.6) {
- $data['papers'][$exam['paper_id']]['passNum'] ++;
- }
- if ($v['scoring'] / $data['papers'][$exam['paper_id']]['fullScore'] >= 0.9) {
- $data['papers'][$exam['paper_id']]['passNum_90'] ++;
- }
- }
- }
- unset($query);
- }
- foreach ($data['paperIds'] as $paperId) {
- if (!isset($data['papers'][$exam['paper_id']]['passRate'])) {
- $data['papers'][$exam['paper_id']]['passRate'] = 0;
- }
- if (isset($data['papers'][$v['paper_id']]['totalNum']) && $data['papers'][$v['paper_id']]['totalNum'] > 0 && isset($data['papers'][$exam['paper_id']]['passNum'])) {
- $data['papers'][$exam['paper_id']]['passRate'] = number_format($data['papers'][$exam['paper_id']]['passNum'] / $data['papers'][$v['paper_id']]['totalNum'], 4) * 100;
- }
- }
- $prevQuery = array();
- if ($data['prevPaperIds']) {
- // 上次考试排名
- if(empty($codePrev)){
- $prevQuery = $this->sConn->createCommand("
- SELECT paper_id, student_id, scoring
- FROM student_paper_relation
- WHERE paper_id IN (" . implode(',', $data['prevPaperIds']) . ") AND is_feedback = '1'
- ORDER BY paper_id ASC, scoring DESC
- ")->queryAll();
- }else{
- $prevQuery = $this->sConn->createCommand("
- SELECT paper_id, student_id, scoring
- FROM student_paper_relation_".$codePrev."
- WHERE paper_id IN (" . implode(',', $data['prevPaperIds']) . ") AND is_feedback = '1'
- ORDER BY paper_id ASC, scoring DESC
- ")->queryAll();
- }
-
- }
- if ($prevQuery) {
- foreach ($prevQuery as $k => $v) {
- if (isset($data['prevPapers'][$v['paper_id']])) {
- if (!isset($data['papers'][$data['prevPapers'][$v['paper_id']]]['prevRanks'])) {
- $data['papers'][$data['prevPapers'][$v['paper_id']]]['prevRanks'] = array();
- $data['papers'][$data['prevPapers'][$v['paper_id']]]['_prevRanks'] = array();
- $data['papers'][$data['prevPapers'][$v['paper_id']]]['_i'] = 0;
- $data['papers'][$data['prevPapers'][$v['paper_id']]]['_j'] = 0;
- }
- if (!isset($prevRank[$data['prevPapers'][$v['paper_id']]])) {
- $prevRank[$data['prevPapers'][$v['paper_id']]] = 0;
- }
- if ($data['papers'][$data['prevPapers'][$v['paper_id']]]['_i'] > 0) {
- if ($v['scoring'] == $data['papers'][$data['prevPapers'][$v['paper_id']]]['_prevRanks'][$data['papers'][$data['prevPapers'][$v['paper_id']]]['_i'] - 1][1]) {
- $data['papers'][$data['prevPapers'][$v['paper_id']]]['_j'] ++;
- $data['papers'][$data['prevPapers'][$v['paper_id']]]['_prevRanks'][] = array(
- $v['student_id'],
- $v['scoring'],
- $prevRank[$data['prevPapers'][$v['paper_id']]]
- );
- } else {
- $prevRank[$data['prevPapers'][$v['paper_id']]] ++;
- $prevRank[$data['prevPapers'][$v['paper_id']]]+= $data['papers'][$data['prevPapers'][$v['paper_id']]]['_j'];
- $data['papers'][$data['prevPapers'][$v['paper_id']]]['_j'] = 0;
- $data['papers'][$data['prevPapers'][$v['paper_id']]]['_prevRanks'][] = array(
- $v['student_id'],
- $v['scoring'],
- $prevRank[$data['prevPapers'][$v['paper_id']]]
- );
- }
- } else {
- $prevRank[$data['prevPapers'][$v['paper_id']]] ++;
- $prevRank[$data['prevPapers'][$v['paper_id']]]+= $data['papers'][$data['prevPapers'][$v['paper_id']]]['_j'];
- $data['papers'][$data['prevPapers'][$v['paper_id']]]['_j'] = 0;
- $data['papers'][$data['prevPapers'][$v['paper_id']]]['_prevRanks'][] = array(
- $v['student_id'],
- $v['scoring'],
- $prevRank[$data['prevPapers'][$v['paper_id']]]
- );
- }
- $data['papers'][$data['prevPapers'][$v['paper_id']]]['prevRanks'][$v['student_id']] = $prevRank[$data['prevPapers'][$v['paper_id']]];
- $data['papers'][$data['prevPapers'][$v['paper_id']]]['_i'] ++;
- }
- }
- unset($prevRank);
- }
- // 本次考试排名
- if(empty($codeNow)){
- $query = $this->sConn->createCommand("
- SELECT spr.paper_id, spr.student_id, si.realname, spr.scoring
- FROM student_paper_relation spr
- JOIN student_info si ON si.student_id = spr.student_id
- WHERE spr.paper_id IN (" . implode(',', $data['paperIds']) . ") AND spr.is_feedback = '1'
- ORDER BY spr.paper_id ASC, spr.scoring DESC
- ")->queryAll();
- }else{
- $query = $this->sConn->createCommand("
- SELECT spr.paper_id, spr.student_id, si.realname, spr.scoring
- FROM student_paper_relation_".$codeNow." spr
- JOIN student_info si ON si.student_id = spr.student_id
- WHERE spr.paper_id IN (" . implode(',', $data['paperIds']) . ") AND spr.is_feedback = '1'
- ORDER BY spr.paper_id ASC, spr.scoring DESC
- ")->queryAll();
- }
-
- $studentNames = array();
- if ($query) {
- foreach ($query as $k => $v) {
- if (!isset($data['papers'][$v['paper_id']]['ranks'])) {
- $data['papers'][$v['paper_id']]['ranks'] = array();
- $data['papers'][$v['paper_id']]['_ranks'] = array();
- $data['papers'][$v['paper_id']]['_i'] = 0;
- $data['papers'][$v['paper_id']]['_j'] = 0;
- }
- if (!isset($rank[$v['paper_id']])) {
- $rank[$v['paper_id']] = 0;
- }
- if ($data['papers'][$v['paper_id']]['_i'] > 0) {
- if ($v['scoring'] == $data['papers'][$v['paper_id']]['_ranks'][$data['papers'][$v['paper_id']]['_i'] - 1][1]) {
- $data['papers'][$v['paper_id']]['_j'] ++;
- $data['papers'][$v['paper_id']]['_ranks'][] = array(
- $v['student_id'],
- $v['scoring'],
- $rank[$v['paper_id']]
- );
- } else {
- $rank[$v['paper_id']] ++;
- $rank[$v['paper_id']]+= $data['papers'][$v['paper_id']]['_j'];
- $data['papers'][$v['paper_id']]['_j'] = 0;
- $data['papers'][$v['paper_id']]['_ranks'][] = array(
- $v['student_id'],
- $v['scoring'],
- $rank[$v['paper_id']]
- );
- }
- } else {
- $rank[$v['paper_id']] ++;
- $rank[$v['paper_id']]+= $data['papers'][$v['paper_id']]['_j'];
- $data['papers'][$v['paper_id']]['_j'] = 0;
- $data['papers'][$v['paper_id']]['_ranks'][] = array(
- $v['student_id'],
- $v['scoring'],
- $rank[$v['paper_id']]
- );
- }
- $data['papers'][$v['paper_id']]['ranks'][] = array(
- 'studentId' => $v['student_id'],
- 'realname' => $v['realname'],
- 'rank' => $rank[$v['paper_id']],
- );
- $data['papers'][$v['paper_id']]['_i'] ++;
- $studentNames[$v['student_id']] = $v['realname'];
- }
- unset($rank);
- }
- //班级得分率
- $class_topic_rate = array();
- if ($class_topic_score) {
- foreach ($class_topic_score as $_p_id => $t_id_scoring) {
- if (!isset($class_topic_rate[$_p_id])) {
- $class_topic_rate[$_p_id] = array();
- }
- foreach ($t_id_scoring as $_t_id => $_t_scoring) {
- if (isset($topic_score_arr[$_t_id]) && $topic_score_arr[$_t_id] > 0) {
- $class_topic_rate[$_p_id][$_t_id] = round(array_sum($_t_scoring)/($topic_score_arr[$_t_id]*count($_t_scoring)),2) * 100;
- }else{
- $class_topic_rate[$_p_id][$_t_id] = 0;
- }
- }
- }
- }
- unset($class_topic_score);
- //得分率低于70%的,选择题错的对应的学生名称
- if($studentNames && isset($data['papers']) && isset($data['papers'][$v['paper_id']]['topics'])){
- foreach ($data['papers'] as $pId => $_topics){
- foreach ($_topics['topics'] as $tId => $less70) {
- foreach ($less70['rateLess70'] as $lessk => $stuId) {
- if (isset($studentNames[$stuId])) {
- $data['papers'][$pId]['topics'][$tId]['rateLess70'][$lessk] = $studentNames[$stuId];
- }
- }
- $data['papers'][$pId]['topics'][$tId]['classRate'] = isset($class_topic_rate[$pId]) && isset($class_topic_rate[$pId][$tId])?$class_topic_rate[$pId][$tId]:0;
- }
- }
- }
- $data['studentNames'] = $studentNames;
- unset($studentNames);
-
-
- // 大幅进步、大幅度退步
- foreach ($data['papers'] as $key => $val) {
- if (isset($val['prevRanks']) && isset($val['ranks'])) {
- foreach ($val['ranks'] as $k => $v) {
- if (isset($val['prevRanks'][$v['studentId']])) {
- // 进步
- if (!isset($data['papers'][$key]['forwards'])) {
- $data['papers'][$key]['forwards'] = array();
- }
- if ($val['prevRanks'][$v['studentId']] - $v['rank'] > 0) {
- if (!isset($data['papers'][$key]['forwards'][$val['prevRanks'][$v['studentId']] - $v['rank']])) {
- $data['papers'][$key]['forwards'][$val['prevRanks'][$v['studentId']] - $v['rank']] = array();
- }
- $data['papers'][$key]['forwards'][$val['prevRanks'][$v['studentId']] - $v['rank']][] = array(
- 'studentId' => $v['studentId'],
- 'realname' => $v['realname'],
- 'rank' => $v['rank'],
- 'prevRank' => $val['prevRanks'][$v['studentId']]
- );
- }
- // 退步
- if (!isset($data['papers'][$key]['rewinds'])) {
- $data['papers'][$key]['rewinds'] = array();
- }
- if ($v['rank'] - $val['prevRanks'][$v['studentId']] > 0) {
- if (!isset($data['papers'][$key]['rewinds'][$v['rank'] - $val['prevRanks'][$v['studentId']]])) {
- $data['papers'][$key]['rewinds'][$v['rank'] - $val['prevRanks'][$v['studentId']]] = array();
- }
- $data['papers'][$key]['rewinds'][$v['rank'] - $val['prevRanks'][$v['studentId']]][] = array(
- 'studentId' => $v['studentId'],
- 'realname' => $v['realname'],
- 'rank' => $v['rank'],
- 'prevRank' => $val['prevRanks'][$v['studentId']]
- );
- }
- }
- }
- if (isset($data['papers'][$key]['forwards'])) {
- krsort($data['papers'][$key]['forwards'], SORT_NUMERIC);
- }
- if (isset($data['papers'][$key]['rewinds'])) {
- krsort($data['papers'][$key]['rewinds'], SORT_NUMERIC);
- }
- }
- if (isset($val['topics'])) {
- foreach ($val['topics'] as $k => $v) {
- if (count($v['studentIds']) > 0) {
- $data['papers'][$key]['topics'][$k]['avgScore'] = number_format($v['totalScore'] / count($v['studentIds']), 2);
- if (isset($data['papers'][$key]['topics'][$k]['fullScore']) && $data['papers'][$key]['topics'][$k]['fullScore'] > 0) {
- $data['papers'][$key]['topics'][$k]['avgRate'] = number_format($v['totalScore'] / (count($v['studentIds']) * $data['papers'][$key]['topics'][$k]['fullScore']), 4) * 100;
- }
- }
- }
- }
- }
- unset($query);
- // 考试情况分析
- if(empty($codeNow)){
- $query = $this->sConn->createCommand("
- SELECT e.exam_group_id, e.exam_id, sptr.paper_id, sptr.student_id, sptr.topic_id, sptr.type, sptr.is_right, sptr.scoring, ptr.topic_id, ptr.stem_id,ptr.no, ptr.`order`,ptr.score, ptr.method_ids, ptr.method_difficulty,sptr.answer
- ,sptr.handlerIndex
- FROM student_paper_topic_rs sptr
- JOIN student_paper_relation spr ON (spr.paper_id = sptr.paper_id AND spr.student_id = sptr.student_id)
- JOIN paper_topic_relation ptr ON (ptr.paper_id = sptr.paper_id AND ptr.topic_id = sptr.topic_id AND ptr.type = sptr.type)
- JOIN paper p ON p.paper_id = ptr.paper_id
- JOIN exam e ON e.exam_id = p.exam_id
- WHERE spr.is_feedback = '1' AND sptr.paper_id IN (" . implode(',', $data['paperIds']) . ")
- ORDER BY sptr.paper_id ASC, sptr.type ASC, ptr.order ASC, sptr.topic_id ASC, sptr.student_id ASC
- ")->queryAll();
- }else{
- $query = $this->sConn->createCommand("
- SELECT e.exam_group_id, e.exam_id, sptr.paper_id, sptr.student_id, sptr.topic_id, sptr.type, sptr.is_right, sptr.scoring, ptr.topic_id, ptr.stem_id,ptr.no, ptr.`order`,ptr.score, ptr.method_ids, ptr.method_difficulty,sptr.answer
- ,sptr.handlerIndex
- FROM student_paper_topic_rs_".$codeNow." sptr
- JOIN student_paper_relation_".$codeNow." spr ON (spr.paper_id = sptr.paper_id AND spr.student_id = sptr.student_id)
- JOIN paper_topic_relation ptr ON (ptr.paper_id = sptr.paper_id AND ptr.topic_id = sptr.topic_id AND ptr.type = sptr.type)
- JOIN paper p ON p.paper_id = ptr.paper_id
- JOIN exam e ON e.exam_id = p.exam_id
- WHERE spr.is_feedback = '1' AND sptr.paper_id IN (" . implode(',', $data['paperIds']) . ")
- ORDER BY sptr.paper_id ASC, sptr.type ASC, ptr.order ASC, sptr.topic_id ASC, sptr.student_id ASC
- ")->queryAll();
- }
- if($is_qxk){
- $qxkKnowledge = SPaperTopicRelation::newKnowledgeRelate();//获取全学科知识点对应老知识点的关系
- }
- if ($query) {
- //转换试卷中每道题目的序号
- $paperNos = $this->transferOrders($data['paperIds'],$is_qxk);
- //计算出每道必做题 做了的人数
- foreach($query as $k => $v){
- if (!isset($data['papers'][$v['paper_id']]['doTopicNums'])) {//每道必做题 做了的人数
- $data['papers'][$v['paper_id']]['doTopicNums'] = array();
- }
- if (!isset($data['papers'][$v['paper_id']]['doTopicNums'][$v['topic_id']])) {
- $data['papers'][$v['paper_id']]['doTopicNums'][$v['topic_id']] = 0;
- }
- if ($v["handlerIndex"] == 1) {
- $data['papers'][$v['paper_id']]['doTopicNums'][$v['topic_id']] ++;
- }
- }
- foreach ($query as $k => $v) {
- if($v['stem_id']){
- $new_topic_id = (string)$v['stem_id'];
- }else{
- $new_topic_id = (string)$v['topic_id'];
- }
- //客观题答案明细
- if($v['type'] == 1 && !$score_type){//单选题
- if(!isset($data['answer_score_details'][$v['topic_id']])){
- $data['answer_score_details'][$v['topic_id']] = array();
- $data['answer_score_details'][$v['topic_id']]['answer'] = '';
- $data['answer_score_details'][$v['topic_id']]['option']['A'] = 0;
- $data['answer_score_details'][$v['topic_id']]['option']['B'] = 0;
- $data['answer_score_details'][$v['topic_id']]['option']['C'] = 0;
- $data['answer_score_details'][$v['topic_id']]['option']['D'] = 0;
- $data['answer_score_details'][$v['topic_id']]['order'] = $v['order'];
- }
- if(isset($data['answer_score_details'][$v['topic_id']]['option'][$v['answer']])){
- $data['answer_score_details'][$v['topic_id']]['option'][$v['answer']]++;
- }
- }
- if((in_array($v['type'],array(2,11)) && !$score_type ) ||($is_qxk && $v['type']==3)){//多选不定项
- $v_answer = str_replace(',','',$v['answer']);
- if(!isset($data['answer_score_details'][$v['topic_id']])){
- $data['answer_score_details'][$v['topic_id']] = array();
- $data['answer_score_details'][$v['topic_id']]['answer'] = '';
- $data['answer_score_details'][$v['topic_id']]['order'] = $v['order'];
- }
- if(isset($data['answer_score_details'][$v['topic_id']]['option'][$v_answer])){
- $data['answer_score_details'][$v['topic_id']]['option'][$v_answer]++;
- }else{
- $data['answer_score_details'][$v['topic_id']]['option'][$v_answer] = 1;
- }
- }
-
- if (!isset($data['papers'][$v['paper_id']]['errorNums'])) {
- $data['papers'][$v['paper_id']]['errorNums'] = array();
- }
- if (!isset($data['papers'][$v['paper_id']]['errorNums'][$v['no']])) {
- $data['papers'][$v['paper_id']]['errorNums'][$v['no']] = 0;
- }
- if ($v['is_right'] != 1 && $v["handlerIndex"] ==1) {
- $data['papers'][$v['paper_id']]['errorNums'][$v['no']] ++;
- }
- if (!in_array((string)$new_topic_id, $data['topicIds'],true)) {
- $data['topicIds'][] = $new_topic_id;
- }
- if (!in_array((string)$v['topic_id'], $data['noTopicIds'],true)) {
- $data['noTopicIds'][] = (string)$v['topic_id'];
- }
- if (!isset($data['papers'][$v['paper_id']]['topicIds'])) {
- $data['papers'][$v['paper_id']]['topicIds'] = array();
- }
- if (!isset($data['papers'][$v['paper_id']]['noTopicIds'])) {
- $data['papers'][$v['paper_id']]['noTopicIds'] = array();
- }
- if (!in_array($new_topic_id, $data['papers'][$v['paper_id']]['topicIds'],true)) {
- $data['papers'][$v['paper_id']]['topicIds'][] = $new_topic_id;
- }
- if (!in_array((string)$v['topic_id'], $data['papers'][$v['paper_id']]['noTopicIds'],true)) {
- $data['papers'][$v['paper_id']]['noTopicIds'][] = (string)$v['topic_id'];
- }
- if (!isset($data['papers'][$v['paper_id']]['topicNos'])) {
- $data['papers'][$v['paper_id']]['topicNos'] = array();
- }
- $data['papers'][$v['paper_id']]['topicNos'][$v['topic_id']] = $v['no'];
- //带选做题的新序号
- if (!isset($data['papers'][$v['paper_id']]['newTopicNos'])) {
- $data['papers'][$v['paper_id']]['newTopicNos'] = array();
- }
- $data['papers'][$v['paper_id']]['newTopicNos'][$v['topic_id']] = isset($paperNos[$v['paper_id']][$v['topic_id']])?$paperNos[$v['paper_id']][$v['topic_id']]:$v['no'];
- if (!isset($data['examGroups'][$v['exam_group_id']]['topicIds'])) {
- $data['examGroups'][$v['exam_group_id']]['topicIds'] = array();
- }
- if (!in_array($v['topic_id'], $data['examGroups'][$v['exam_group_id']]['topicIds'])) {
- $data['examGroups'][$v['exam_group_id']]['topicIds'][] = $v['topic_id'];
- }
- if (!isset($data['examGroups'][$v['exam_group_id']]['rules'])) {
- $data['examGroups'][$v['exam_group_id']]['rules'] = array();
- }
- $ruleMethodIds = $v['method_ids'];
- $ruleType =(in_array($v['type'], array(17, 27)) ? 7 : $v['type']);
- if($is_qxk && $v["method_ids"]){//如果是全学科的考试转变成老知识点
- $methodIds = explode(',', $v['method_ids']);
- $ruleMethodIds = array();
- foreach($methodIds as $methodId){
- if(isset($qxkKnowledge[$methodId])){
- $ruleMethodIds = array_merge($ruleMethodIds,$qxkKnowledge[$methodId]);
- }
- }
- $ruleMethodIds = empty($ruleMethodIds)?"":join(",",$ruleMethodIds);
- $ruleType = 8;
- }
- $data['examGroups'][$v['exam_group_id']]['rules'][$v['topic_id']] = array(
- 'num' => 1,
- 'difficulty' => $v['method_difficulty'],
- 'type' => $ruleType,
- 'inMethodIds' => $ruleMethodIds,
- 'eqMethodIds' => $ruleMethodIds,
- 'callback' => $v['topic_id'],
- );
- $no = $paperNos[$v['paper_id']][$v['topic_id']];
- if ($v['method_ids'] && $data['papers'][$v['paper_id']]['doTopicNums'][$v['topic_id']]) {
- $methodIds = explode(',', $v['method_ids']);
- foreach ($methodIds as $methodId) {
- if (!in_array($methodId, $data['methodIds'])) {
- $data['methodIds'][] = $methodId;
- }
- if (!isset($data['papers'][$v['paper_id']]['methodNos'])) {
- $data['papers'][$v['paper_id']]['methodNos'] = array();
- }
- if (!isset($data['papers'][$v['paper_id']]['methodNos'][$methodId])) {
- $data['papers'][$v['paper_id']]['methodNos'][$methodId] = array();
- }
- if (!in_array($no, $data['papers'][$v['paper_id']]['methodNos'][$methodId]) ) {
- $data['papers'][$v['paper_id']]['methodNos'][$methodId][] = $no;
- }
- if (!isset($data['papers'][$v['paper_id']]['methodErrorNums'])) {
- $data['papers'][$v['paper_id']]['methodErrorNums'] = array();
- }
- if (!isset($data['papers'][$v['paper_id']]['methodErrorNums'][$methodId])) {
- $data['papers'][$v['paper_id']]['methodErrorNums'][$methodId] = 0;
- }
- if ($v['is_right'] != 1 && $v['handlerIndex']==1) {
- $data['papers'][$v['paper_id']]['methodErrorNums'][$methodId] ++;
- }
- if (!isset($data['papers'][$v['paper_id']]['methodErrorStudents'])) {
- $data['papers'][$v['paper_id']]['methodErrorStudents'] = array();
- }
- if (!isset($data['papers'][$v['paper_id']]['methodErrorStudents'][$methodId])) {
- $data['papers'][$v['paper_id']]['methodErrorStudents'][$methodId] = array();
- }
- if ($v['is_right'] != 1) {
- if (!in_array($v['student_id'], $data['papers'][$v['paper_id']]['methodErrorStudents'][$methodId],true) && $v['handlerIndex']==1) {
- $data['papers'][$v['paper_id']]['methodErrorStudents'][$methodId][] = $v['student_id'];
- }
- }
- if (!isset($data['papers'][$v['paper_id']]['methodFullScores'])) {
- $data['papers'][$v['paper_id']]['methodFullScores'] = array();
- }
- if (!isset($data['papers'][$v['paper_id']]['methodFullScores'][$methodId])) {
- $data['papers'][$v['paper_id']]['methodFullScores'][$methodId] = 0;
- }
- $data['papers'][$v['paper_id']]['methodFullScores'][$methodId] += $v['score'];
- if (!isset($data['papers'][$v['paper_id']]['methodScores'])) {
- $data['papers'][$v['paper_id']]['methodScores'] = array();
- }
- if (!isset($data['papers'][$v['paper_id']]['methodScores'][$methodId])) {
- $data['papers'][$v['paper_id']]['methodScores'][$methodId] = 0;
- }
- $data['papers'][$v['paper_id']]['methodScores'][$methodId] += $v['scoring'];
- }
- }
- }
- foreach ($data['papers'] as $key => $val) {
- if (isset($val['errorNums'])) {
- //重置题号
- $i = 1;
- $newErrorNums = array();
- foreach($val['errorNums'] as $k => $v){
- $newErrorNums[$i] = $v;
- $i++;
- }
- if($newErrorNums){
- $val['errorNums'] = $newErrorNums;
- $data['papers'][$key]['errorNums'] = $newErrorNums;
- }
- foreach ($val['errorNums'] as $k => $v) {
- if (!isset($data['papers'][$key]['errorRates'])) {
- $data['papers'][$key]['errorRates'] = array();
- }
- if ($data['papers'][$key]['totalNum'] > 0) {
- $data['papers'][$key]['errorRates'][$k] = number_format($data['papers'][$key]['errorNums'][$k] / $data['papers'][$key]['totalNum'], 4) * 100;
- } else {
- $data['papers'][$key]['errorRates'][$k] = 0;
- }
- }
- }
- }
- }
- } else {
- echo json_encode(array("status" => 1, "error" => "文件尚未生成"));
- exit;
- }
- if ($data['wb_isp_version'] != 1 || $isFromPast) { //个性化版
- if (isset($data['examGroups']) && $data['examGroups'] && is_array($data['examGroups'])) {
- // 抽题
- foreach ($data['examGroups'] as $key => $val) {
- if($same_bs_data){
- $data['examGroups'][$key]['fcTopicIds'] = array();
- $data['examGroups'][$key]['fcCallbacks'] = array();
- foreach($same_bs_data as $sa_k=>$sa_v){
- $has_topic_gaokao[] = $sa_k;
- foreach($sa_v as $sa_v_topic){
- $has_topic_gaokao[] = $sa_v_topic;
- $data['examGroups'][$key]['fcTopicIds'][] = $sa_v_topic;
- $data['examGroups'][$key]['fcCallbacks'][$sa_k][] = $sa_v_topic;
- if (!in_array((string)$sa_v_topic, $data['fcTopicIds'])) {
- $data['fcTopicIds'][] = (string)$sa_v_topic;
- }
- }
- }
- }else{
-
- if($labelled_type == 2){//教师端标注抽题
- $data['examGroups'][$key]['fcTopicIds'] = array();
- $data['examGroups'][$key]['fcCallbacks'] = array();
- $sql = "select topic_id,relation_id from exam_topic_label where exam_group_id = '{$key}'";
- $etl_data = $this->sConn->createCommand($sql)->queryAll();
- if($etl_data){
- foreach($etl_data as $etl_data_v){
- if($etl_data_v['topic_id'] && $etl_data_v['relation_id']){
- $relation_topic_arr = explode(",",$etl_data_v['relation_id']);
- foreach($relation_topic_arr as $relation_topic_v){
- if (!in_array((string)$relation_topic_v, $data['fcTopicIds'])) {
- $data['fcTopicIds'][] = (string)$relation_topic_v;
- }
- $data['examGroups'][$key]['fcTopicIds'][] = $relation_topic_v;
- $data['examGroups'][$key]['fcCallbacks'][$etl_data_v['topic_id']][] = $relation_topic_v;
- $has_topic_gaokao[] = $relation_topic_v;
- }
- $has_topic_gaokao[] = $etl_data_v['topic_id'];
- }
- }
- }
- }else{
- if (isset($val['rules'])) {
- $fc = $this->apiPost('/isp/ai', array(
- 'schoolId' => $this->schoolId,
- 'rules' => $val['rules'],
- 'notInTopicIds' => $data['examGroups'][$key]['topicIds'],
- ));
- if ($fc && !isset($fc->error)) {
- $data['examGroups'][$key]['fcTopicIds'] = array();
- $data['examGroups'][$key]['fcCallbacks'] = array();
- foreach ($fc as $k => $v) {
- if (!in_array($v->id, $data['fcTopicIds'])) {
- $data['fcTopicIds'][] = $v->id;
- }
- $data['examGroups'][$key]['fcTopicIds'][] = $v->id;
- $data['examGroups'][$key]['fcCallbacks'][$v->callback][] = $v->id;
- $has_topic_gaokao[] = $v->id;
- $has_topic_gaokao[] = $v->callback;
- }
- }
- }
- }
- }
- }
-
- $topicDetails=array();
- $topicItems_1 = $this->apiPost('/topic/batchAll', array('topicIds' => array_merge(
- $data['topicIds'],
- (isset($data['fcTopicIds']) ? $data['fcTopicIds'] : array())
- )));
- if (isset($topicItems_1->error)) {
- $error[] = $topicItems_1->error;
- } elseif (! $topicItems_1) {
- $error[] = 'Error in pumping system[2]';
- } else {
- foreach ($topicItems_1 as $topicItem) {
- $topicDetails[(string)$topicItem->id] = (object)$topicItem;
- }
- }
-
- // $topicItems = $this->apiPost('/topic/batch',
- // array('topicIds' => array_merge(
- // $data['topicIds'],
- // (isset($data['fcTopicIds']) ? $data['fcTopicIds'] : array())
- // )));
- //
- // if (isset($topicItems->error)) {
- // $error[] = $topicItems->error;
- // } elseif (! $topicItems) {
- // $error[] = 'Error in pumping system[2]';
- // } else {
- // foreach ($topicItems as $topicItem) {
- // $topicDetails[$topicItem->id] = (object)$topicItem;
- // }
- // }
- // if($data['topicIds']){
- // $condition = "topic_id IN (". implode(',', $data['topicIds']) .")";
- // $topicItems_1 = STopic::model()->getRecords($condition, 0, 100, $exam_info['teacher_id'], true);
- // }
- // if ($topicItems_1) {
- // foreach ($topicItems_1 as $topicItem_1) {
- // $topicDetails[$topicItem_1['id']] = (object)$topicItem_1;
- // }
- // }
- if ($topicDetails) {
- foreach ($topicDetails as $k => $v) {
- $v=(array)$v;
- $v['id'] = (string)$v['id'];
- $teacher_tips= isset($v['teacher_tips'])?$v['teacher_tips']:"";
- if(!$teacher_tips){
- $teacher_tips = $this->dealTeacherTips($v);
- }
- $v['teacher_tips'] = $this->topicProcess($teacher_tips);
- $v['parse_content'] = $this->topicProcess($v['parse_content']);
- if($v['type_id'] == 5){
- $v['title'] = preg_replace("/<img[^>]*[\s]+src[\s]*=[\s]*(([\'\"](\/images\/list_\d\.png)[\'\"])|(\/images\/list_\d\.png))[^>]*>/si", '__________', $v['title']);
- }
- $v['title'] = $this->topicProcess($v['title']);
- if(isset($v['items'][0])){
- $v['items'][0]=(array)$v['items'][0];
- $v['items'][0]['options']=(array)$v['items'][0]['options'];
- if (isset($v['items']) && isset($v['items'][0]) && isset($v['items'][0]['options'])) {
- foreach ($v['items'][0]['options'] as $key => $val) {
- $val=(array)$val;
- $v['items'][0]['options'][$key]=(array)$v['items'][0]['options'][$key];
- $v['items'][0]['options'][$key]['option_content'] = $this->topicProcess($val['option_content']);
- if(isset($data['answer_score_details'][$v['id']]) && $val['option_correct'] == 1){
- $data['answer_score_details'][$v['id']]['answer'] .= $this->numToLetter($key + 1);
- }
- }
- }
- }
- $data['topicDetails'][$v['id']] = $v;
- }
- unset($topicDetails);
- }
- }
- } else { //分层版
- //获取原题以及对应四个层次的提分题
- //$preparation_plan_id = $exam['preparation_plan_id'];
- if($data['level_rule'] == 1){
- $isDiffMin = $this->sConn->createCommand(" select template_id,level,topic_id,difficulty_degree from preparation_plan_topic where preparation_plan_id=" . $examId." and is_diff_min = 1")->queryAll();
- if($isDiffMin){
- $plan_topic_res = $isDiffMin;
- }else{
- $plan_topic_res = $this->sConn->createCommand(" select template_id,level,topic_id,difficulty_degree from preparation_plan_topic where preparation_plan_id=" . $examId)->queryAll();
- if($plan_topic_res){
- $topicsOrigin = array();
- $topicRelation = array();
- foreach($plan_topic_res as $k=>$v){
- $topicsOrigin[] = $v['template_id'];
- $topicRelation[$v['template_id']][] = $v;
- $has_topic_gaokao[] =$v['template_id'];
- $has_topic_gaokao[] =$v['topic_id'];
- }
- if($topicsOrigin){
- $topicsOrigin = array_unique($topicsOrigin);
- $topicDetails = $this->aipost('/topic/batchAll', array('topicIds' => $topicsOrigin));
- if (!$topicDetails) {
- echo json_encode(array("status" => 1, "error" => "获取接口batchALL无数据!"));
- exit();
- } elseif (isset($topicDetails['status']) && $topicDetails['status']==0) {
- echo json_encode(array("status" => 1, "error" => $topicDetails['error'][0]));
- exit();
- }
- $topicDiff = array();
- foreach($topicDetails as $k=>$v){
- if(isset($v['difficulty_degree'])){
- $diff = $v['difficulty_degree'];
- }elseif(isset($v['experience_degree'])){
- $diff = $v['experience_degree'];
- }else{
- $diff = 0;
- }
- $topicDiff[$v['id']] = $diff;
- }
- $new_plan_topic_res = array();
- foreach($topicDiff as $k=>$v){
- if(isset($topicRelation[$k])){
- $arr1 = array();
- $arr2 = array();
- foreach($topicRelation[$k] as $relation){
- $arr1[] = $relation['difficulty_degree'];
- }
- $x=$v;
- $count=count($arr1);
- for ($i=0; $i <$count ; $i++) {
- $arr2[]=abs($x-$arr1[$i]);
- }
- $min= min($arr2);
- for ($i=0; $i <$count ; $i++) {
- if ($min==$arr2[$i]) {
- $new_plan_topic_res[] = $topicRelation[$k][$i];
- break 1;
- }
- }
- }
- }
- }
- $plan_topic_res = $new_plan_topic_res;
- }
-
- }
- }else{
- $plan_topic_res = $this->sConn->createCommand(" select template_id,level,topic_id from preparation_plan_topic where preparation_plan_id=" . $examId)->queryAll();
- }
- if (!$plan_topic_res) {
- echo json_encode(array("status" => 1, "error" => "文件尚未生成"));
- exit;
- }
- $template_topic_arr = array();
- $isp_id_arr = array();
- foreach ($plan_topic_res as $v) {
- $template_id = $v['template_id'];
- $level = $v['level'];
- $topic_id = $v['topic_id'];
- if (!isset($template_topic_arr[$template_id])) {
- $template_topic_arr[$template_id] = array();
- }
- $template_topic_arr[$template_id][$level] = $topic_id;
- $isp_id_arr[] = $topic_id;
- }
- //试卷中校本题库题是哪些,云题库题是哪些
- $sch_id_arr = array(); //试卷中校本题库题是哪些
- $yun_id_arr = array();
- $sql = 'select topic_id,mode,type,no from paper_topic_relation ptr join paper p on p.paper_id = ptr.paper_id where p.exam_id=' . $examId;
- $paper_topic_res = $this->sConn->createCommand($sql)->queryAll();
- if (!$paper_topic_res) {
- echo json_encode(array("status" => 1, "error" => "文件尚未生成"));
- exit;
- }
- $topic_no_arr = $this->getTopicNoByPaper($paper_topic_res, $exam['tpl_index']); //获取每道题在试卷中的序号,如 21A,21B
- foreach ($paper_topic_res as $v) {
- $v['mode'] == 1 && $sch_id_arr[] = $v['topic_id'];
- $v['mode'] == 0 && $yun_id_arr [] = $v['topic_id'];
- }
- $isp_id_arr = array_merge($isp_id_arr, $yun_id_arr);
- //获取所有以上题目的详情,以供显示到教师讲案中
- $topic_detail_arr = $this->paperTopicDetail($isp_id_arr, $sch_id_arr, $examId,'分层提分题');
- if (!$topic_detail_arr) {
- echo json_encode(array("status" => 1, "error" => "获取不到试卷题目内容"));
- exit;
- }
- foreach($topic_detail_arr as $k_topic=>$v_topic){
- if(isset($data['answer_score_details'][(string)$k_topic])){
- $data['answer_score_details'][(string)$k_topic]['answer'] = isset($v_topic['answer_format'])?$v_topic['answer_format']:'';
- }
- }
- $diff_id_arr = array_diff($isp_id_arr + $sch_id_arr, array_keys($topic_detail_arr));
- if ($diff_id_arr) {
- //todo 发送消息到补提
- echo json_encode(array("status" => 1, "error" => "请等待题库老师补题!"));
- exit;
- } else {
- $data['template_topic_arr'] = $template_topic_arr;
- $data['topic_details'] = $topic_detail_arr;
- $data['topic_no_arr'] = $topic_no_arr;
- unset($template_topic_arr);
- unset($topic_detail_arr);
- }
- }
- // 获取考点名称
- if (isset($data['methodIds']) && $data['methodIds']) {
- if($is_qxk){
- $methods = $this->apiPost('/all_knowledge/knowledge_name', array('knowledgeIds' => $data['methodIds']));
- if ($methods && isset($methods->data) && $methods->data) {
- foreach ($methods->data as $k => $v) {
- $data['methodNames'][$k] = $v;
- }
- unset($methods);
- }
- }else{
- $methods = $this->apiPost('/special/methods', array('methodIds' => $data['methodIds']));
- if ($methods) {
- foreach ($methods as $k => $v) {
- $data['methodNames'][$v->method_id] = $v->method_name;
- }
- unset($methods);
- }
- }
-
- }
- if (isset($data['examGroupIds']) && $data['examGroupIds'] && is_array($data['examGroupIds'])) {
- // 年级单题情况
- // $query = $this->sConn->createCommand("
- // SELECT sptr.student_id, sptr.paper_id, sptr.topic_id, sptr.is_right, sptr.scoring, e.exam_group_id, ptr.score
- // FROM student_paper_topic_rs sptr
- // JOIN paper_topic_relation ptr ON (ptr.paper_id = sptr.paper_id AND ptr.topic_id = sptr.topic_id)
- // JOIN paper p ON p.paper_id = sptr.paper_id
- // JOIN exam e ON e.exam_id = p.exam_id
- // WHERE e.exam_group_id IN (" . implode(',', $data['examGroupIds']) . ") AND sptr.handlerIndex = '1'
- // ")->queryAll();
- ////年级单题情况优化后begining////////////////
- // $sql = "SELECT count(0) as count
- // FROM student_paper_topic_rs sptr
- // JOIN paper_topic_relation ptr ON (ptr.paper_id = sptr.paper_id AND ptr.topic_id = sptr.topic_id)
- // JOIN paper p ON p.paper_id = sptr.paper_id
- // JOIN exam e ON e.exam_id = p.exam_id
- // WHERE e.exam_group_id IN (" . implode(',', $data['examGroupIds']) . ") AND sptr.handlerIndex = '1'";
- // $countNum = $this->sConn->createCommand($sql)->queryRow();
- // $query = array();
- // if($countNum){
- // $num = $countNum['count'];
- // $limit = 10000;
- // $page = ceil($num/$limit);
- // $sql_s = "SELECT sptr.student_id, sptr.paper_id, sptr.topic_id, sptr.is_right, sptr.scoring, e.exam_group_id, ptr.score
- // FROM student_paper_topic_rs sptr
- // JOIN paper_topic_relation ptr ON (ptr.paper_id = sptr.paper_id AND ptr.topic_id = sptr.topic_id)
- // JOIN paper p ON p.paper_id = sptr.paper_id
- // JOIN exam e ON e.exam_id = p.exam_id
- // WHERE e.exam_group_id IN (" . implode(',', $data['examGroupIds']) . ") AND sptr.handlerIndex = '1'";
- // for($i = 1;$i <= $page ; $i++){
- // $offset = ($i - 1)*$limit;
- // $sql = $sql_s." limit {$offset},{$limit}";
- // if($query){
- // $query_next = $this->sConn->createCommand($sql)->queryAll();
- // if($query_next){
- // foreach($query_next as $k=>$v){
- // array_push($query,$v);
- // }
- // }
- // unset($query_next);
- // }else{
- // $query = $this->sConn->createCommand($sql)->queryAll();
- // }
- // }
- // }
- //////////////ending///////////////
- //////////newbegining
- $this->sConn->active = false;
- $this->sConn = $this->getDbConnection();
- $query = array();
- if(empty($codeNow)){
- $sql = "SELECT sptr.student_id, sptr.paper_id, sptr.topic_id, sptr.is_right, sptr.scoring, e.exam_group_id,sptr.handlerIndex
- FROM student_paper_topic_rs sptr
- JOIN paper p ON p.paper_id = sptr.paper_id
- JOIN exam e ON e.exam_id = p.exam_id
- WHERE e.exam_group_id IN (" . implode(',', $data['examGroupIds']) . ") ";
- }else{
- $sql = "SELECT sptr.student_id, sptr.paper_id, sptr.topic_id, sptr.is_right, sptr.scoring, e.exam_group_id,sptr.handlerIndex
- FROM student_paper_topic_rs_".$codeNow." sptr
- JOIN paper p ON p.paper_id = sptr.paper_id
- JOIN exam e ON e.exam_id = p.exam_id
- WHERE e.exam_group_id IN (" . implode(',', $data['examGroupIds']) . ") ";
- }
-
- $sptrData = $this->sConn->createCommand($sql)->queryAll();
- if($sptrData){
- $paperTopic = array();
- $paperIds = array();
- foreach($sptrData as $k=>$v){
- if(!in_array($v['paper_id'], $paperIds,true)){
- $paperIds[] = $v['paper_id'];
- }
- }
- if($paperIds){
- $sql = "select score,paper_id,topic_id from paper_topic_relation where paper_id in (" . implode(',', $paperIds) . ")";
- $ptrData = $this->sConn->createCommand($sql)->queryAll();
- if($ptrData){
- foreach($ptrData as $k=>$v){
- $paperTopic[$v['paper_id']][$v['topic_id']] = $v['score'];
- }
- unset($ptrData);
- }
- if($paperTopic){
- foreach($sptrData as $k=>$v){
- if(isset($paperTopic[$v['paper_id']]) && isset($paperTopic[$v['paper_id']][$v['topic_id']])){
- $sptrData[$k]['score'] = $paperTopic[$v['paper_id']][$v['topic_id']];
- }
- }
- $query = $sptrData;
-
- }
- }
- unset($sptrData);
- }
- /////////newending
- ///
- $grade_topic_score = array();
- if ($query) {
- foreach ($query as $k => $v) {
- if (!isset($data['examGroups'][$v['exam_group_id']]['topics'])) {
- $data['examGroups'][$v['exam_group_id']]['topics'] = array();
- }
- if (!isset($data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']])) {
- $data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']] = array();
- $data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']]['fullScore'] = $v['score'];
- $data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']]['totalScore'] = 0;
- $data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']]['avgScore'] = 0;
- $data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']]['avgRate'] = 0;
- $data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']]['numRight'] = 0;
- $data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']]['numWrong'] = 0;
- $data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']]['studentIds'] = array();
- }
- $data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']]['totalScore'] += $v['scoring'];
- if ($v['is_right'] == 1) {
- $data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']]['numRight'] ++;
- } else {
- if($v["handlerIndex"]==1){//必做题
- $data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']]['numWrong'] ++;
- }
- }
- if($v["handlerIndex"]==1) {//必做题
- $data['examGroups'][$v['exam_group_id']]['topics'][$v['topic_id']]['studentIds'][] = $v['student_id'];
- }
- //年级得分
- if (!isset($grade_topic_score[$v['topic_id']])) {
- $grade_topic_score[$v['topic_id']] = array();
- }
- $grade_topic_score[$v['topic_id']][] = $v['scoring'];
- }
- foreach ($data['examGroups'] as $key => $val) {
- if (isset($val['topics'])) {
- foreach ($val['topics'] as $k => $v) {
- if (count($v['studentIds']) > 0) {
- $data['examGroups'][$key]['topics'][$k]['avgScore'] = number_format($v['totalScore'] / count($v['studentIds']), 2);
- if (isset($data['examGroups'][$key]['topics'][$k]['fullScore']) && $data['examGroups'][$key]['topics'][$k]['fullScore'] > 0) {
- $data['examGroups'][$key]['topics'][$k]['avgRate'] = number_format($v['totalScore'] / (count($v['studentIds']) * $data['examGroups'][$key]['topics'][$k]['fullScore']), 4) * 100;
- }
- }
- }
- }
- }
- }
- }
- //debug($data);
- $grade_topic_rate = array();
- if ($grade_topic_score) {
- foreach ($grade_topic_score as $_t_id => $_t_scoring) {
- if (isset($topic_score_arr[$_t_id]) && $topic_score_arr[$_t_id] > 0) {
- $grade_topic_rate[$_t_id] = round(array_sum($_t_scoring)/($topic_score_arr[$_t_id]*count($_t_scoring)),2) * 100;
- }else{
- $grade_topic_rate[$_t_id] = 0;
- }
- }
- }
- unset($grade_topic_score);
- unset($topic_score_arr);
- //高考真题
- $data['gaokao_topic'] = array();
- if($grade == 3){
- $gaokao_topic = array();
-
- $sql = "select topic_id from gaokao_academicr_topic where class_id ='{$classId}'";
- $gaokao_data = $this->sConn->createCommand($sql)->queryAll();
- if($gaokao_data){
- foreach($gaokao_data as $gao){
- $gaokao_topic[] = $gao['topic_id'];
- }
- }
- if($gen_origin_methods){
- $weak_methodids = array_keys($gen_origin_methods);
- }else{
- $weak_methodids = array();
- }
- if($paper_method_ids){
- $paper_methodids = explode(",",$paper_method_ids);
- }else{
- $paper_methodids = array();
- }
- if($has_topic_gaokao){
- $has_topic = $has_topic_gaokao;
- }else{
- $has_topic = array();
- }
- $gaokao_topic = $this->acadGaokao($examId,$classId,$has_topic,$weak_methodids,$paper_methodids);
- if($gaokao_topic){
- $topicBatchs = $this->aipost('topic/batchall', array('topicIds' => $gaokao_topic));
- if ($topicBatchs && !isset($topicBatchs->error)) {
- $data['gaokao_topic'] = $this->formatDetails($topicBatchs);
- }
- }
- }
- //整理客观题明细数据
- if($data['answer_score_details']){
- $new_answer_score_details = array();
- $a = 0;
- foreach($data['answer_score_details'] as $k=>$v){
- if(isset($v['option']) && $v['option']){
- foreach($v['option'] as $option_type=>$option_count){
- $new_answer_score_details[$a]['id'] = $k;
- $new_answer_score_details[$a]['order'] = $v['order'];
- $new_answer_score_details[$a]['answer'] = $v['answer']?$v['answer']:'';
- $new_answer_score_details[$a]['option'] = $option_type;
- $new_answer_score_details[$a]['option_count'] = $option_count;
- $a++;
- }
- }
- }
- $data['answer_score_details'] = $new_answer_score_details;
- }
- $this->sConn->active = false; // 关闭连接 close();
- // debug($data);
- if (isset($data['papers']) && $data['papers'] && is_array($data['papers'])) {
- // 渲染
- foreach ($data['papers'] as $key => $val) {
- if (!isset($val['examId']) || !$val['examId'])
- continue;
- if (!isset($val['examGroupId']) || !$val['examGroupId'])
- continue;
- $classname = ClassModel::model()->getClassName($classId);
- $data = array_merge($val, array(
- 'methodNames' => (isset($data['methodNames']) ? $data['methodNames'] : array()),
- 'topicDetails' => (isset($data['topicDetails']) ? $data['topicDetails'] : array()),
- 'groupTopics' => (isset($data['examGroups']) && isset($data['examGroups'][$val['examGroupId']]) && isset($data['examGroups'][$val['examGroupId']]['topics']) ? $data['examGroups'][$val['examGroupId']]['topics'] : array()),
- 'fcCallbacks' => (isset($data['examGroups']) && isset($data['examGroups'][$val['examGroupId']]) && isset($data['examGroups'][$val['examGroupId']]['fcCallbacks']) ? $data['examGroups'][$val['examGroupId']]['fcCallbacks'] : array()),
- 'wb_isp_version' => isset($data['wb_isp_version']) ? $data['wb_isp_version'] : 0,
- 'template_topic_arr' => isset($data['template_topic_arr']) ? $data['template_topic_arr'] : array(),
- 'topic_details' => isset($data['topic_details']) ? $data['topic_details'] : array(),
- 'topic_no_arr' => isset($data['topic_no_arr']) ? $data['topic_no_arr']: array(),
- 'level_rule' => isset($data['level_rule']) ? $data['level_rule'] : 0,
- 'gradeTopicRate' => $grade_topic_rate,
- 'studentNames'=>isset($data['studentNames']) ? $data['studentNames'] : array(),
- 'excellent_solution'=>isset($data['excellent_solution']) ? $data['excellent_solution'] : array(),
- 'gen_topics'=>isset($data['gen_topics']) ? $data['gen_topics'] : array(),
- 'gen_topics_detail'=>isset($data['gen_topics_detail']) ? $data['gen_topics_detail'] : array(),
- 'gen_topics_msg'=>isset($data['gen_topics_msg']) ? $data['gen_topics_msg'] : array(),
- 'answer_score_details'=>isset($data['answer_score_details']) ? $data['answer_score_details'] : array(),
- 'gen_origin_methods'=>isset($data['gen_origin_methods'])?$data['gen_origin_methods']:'',
- 'gaokao_topic'=>isset($data['gaokao_topic'])?$data['gaokao_topic']:array(),
- 'setting_arr'=>isset($setting_arr)?$setting_arr:array(),
- 'grade_topic_data'=>isset($data['grade_topic_data']) ? $data['grade_topic_data'] : array(),
- 'is_qxk'=>$is_qxk,
- )
- );
- $data['className'] = $classname;
- //是否是精准学习宝学校
- $http = http('customer/precision-learning-school/check/'.$this->schoolId, 'GET', $this->authUsername);
- $response = formatResponse($http);
- $data['isPrecise'] = isset($response['data']) ? $response['data'] : 0;
-
- //教师姓名
- $sql = "select t.teacher_id,t.teacher_name from teacher t join teacher_class_relation tcr on t.teacher_id = tcr.teacher_id where tcr.class_id = '{$class_id}' and tcr.semester_id = '{$semesterId}' and t.subjects=3";
- $teacher_msg = $this->sConn->createCommand($sql)->queryRow();
- if($teacher_msg){
- $data['teacherName'] = $teacher_msg['teacher_name'];
- }
- $html = $this->renderPartial("academicr_1", $data, true);
- //echo 11;exit;
- $htmlpath = str_replace("protected", "", Yii::app()->basePath) . '/upload/tmpDir/academicr/'; //存放生成的HTML路径
- $pdfpath = str_replace("protected", "", Yii::app()->basePath) . '/upload/tmpDir/academicr/' . $this->schoolId . "/"; //存放生成的PDF路径
- $pdfurl = '/upload/tmpDir/academicr/' . $this->schoolId . "/";
- if (!is_dir($htmlpath)) {
- if (!mkdir($htmlpath, 0777, true)) {
- exit('Create directory fail: ' . $htmlpath);
- }
- }if (!is_dir($pdfpath)) {
- if (!mkdir($pdfpath, 0777, true)) {
- exit('Create directory fail1: ' . $pdfpath);
- }
- }
-
- $htmlpath.=$examId . ".html";
- $f = fopen($htmlpath, "w");
- fwrite($f, $html);
- fclose($f);
- // echo 11;exit;
- $htmlurl = '/upload/tmpDir/academicr/' . $examId . ".html"; //访问HTML的路径
-
- if (Yii::app()->basePath == "C:\wamp\www\zsyas2\protected") {//本地的basePath
- $locale='en_US.UTF-8'; // 或 $locale='zh_CN.UTF-8';
- setlocale(LC_ALL,$locale);
- putenv('LC_ALL='.$locale);
- $htmlurl = "http://zsyte.dev.xueping.com/html/%E9%A6%96%E9%A1%B5.html";
- // $pdffname = str_replace(".", "。", $exam_info['class_name'] . "-" . $exam_info['exam_name']);
- // $pdffname = str_replace(" ", "", $pdffname) . ".pdf";
- // $pdffname=iconv("UTF-8", "GBK",$pdffname);
- $pdffname=$classId."-".$examId.".pdf";
- $pdfpath = $pdfpath . $pdffname;
- $pdfurl = $pdfurl . $pdffname;
- $header_str = $this->schoolInfo->school_name.$exam_info['class_name']."+++".$exam_info['exam_name']."+++"."时间:".date("Y-m-d",time());
- $commond = Yii::app()->params['phantomjs_server'] . " "
- . Yii::app()->basePath . '/../js/html2pdf_math.js' . " "
- . " {$htmlurl}"
- . " {$pdfpath}"
- . " 176mm*250mm '{$header_str}'";
- } else {
- $locale='en_US.UTF-8'; // 或 $locale='zh_CN.UTF-8';
- setlocale(LC_ALL,$locale);
- putenv('LC_ALL='.$locale);
- // echo Yii::app()->params['phantomjs'];exit;
- $htmlurl = "http://" . $_SERVER['SERVER_NAME'] . $htmlurl;
- // $pdffname = str_replace(".", "。", $exam_info['class_name'] . "-" . $exam_info['exam_name']);
- // $pdffname = str_replace(" ", "", $pdffname) . ".pdf";
- // $pdffname=iconv("UTF-8", "GBK",$pdffname);
- $pdffname=$classId."-".$examId.".pdf";
- $pdfpath = $pdfpath . $pdffname;
- $pdfurl = $pdfurl . $pdffname;
- $header_str = $this->schoolInfo->school_name.$exam_info['class_name']."+++".$exam_info['exam_name']."+++"."时间:".date("Y-m-d",time());
- // $header_str = '';
- $commond = Yii::app()->params['phantomjs_server'] . " "
- . Yii::app()->basePath . '/../js/html2pdf_math.js' . " "
- . " {$htmlurl}"
- . " {$pdfpath}"
- . " 176mm*250mm '{$header_str}'";
- }
- exec($commond, $res, $code);
- $ucloud = new HuaweiCloud();
- //上传html
- $rehtml = $examId.".html";
- $rehtmlname = 'zsyas2/math_academicr/'.$this->schoolId.'/'. date('Y') . '/' . date('m') . '/' . date('d').'/'. uniqid() . '.' . $rehtml;
- $uploadHtmlInfo = $ucloud->putFile($rehtmlname, $htmlpath);
- if($uploadHtmlInfo['status'] == 0){
- $html_url = "http://" . $_SERVER['SERVER_NAME'].$htmlurl;
- }else{
- $html_url = $uploadHtmlInfo['url'];
- @unlink($htmlpath);
- }
- $this->sConn->createCommand()->update("exam", array("academicr_html_path"=>$html_url), "exam_id = '{$examId}'");
- if(isset($res[0])){
- if (strpos($res[0], 'succeed') !== false) {//命令返回成功
- if ($this->file_exists($pdfpath)) {
-
- $repdf = $examId.".pdf";
- $rename = 'zsyas2/math_academicr/'.$this->schoolId.'/'. date('Y') . '/' . date('m') . '/' . date('d').'/'. uniqid() . '.' . $repdf;
-
- $uploadInfo = $ucloud->putFile($rename, $pdfpath);
- if ($uploadInfo['status'] == 0) {
- $pdfurl="http://" . $_SERVER['SERVER_NAME'].$pdfurl;
- $this->sConn->createCommand()->update("exam", array("academicr_html_path"=>$html_url,"academicr_pdf_path" => $pdfurl, "academicr_pdf_time" => time(), "is_academicr_pdf" => 1), "exam_id = '{$examId}'");
- //throw new CException("PDF文件上传失败");
- }else{
- @unlink($pdfpath);
- $pdfurl = $uploadInfo['url'];
- $this->sConn->createCommand()->update("exam", array("academicr_html_path"=>$html_url,"academicr_pdf_path" => $pdfurl, "academicr_pdf_time" => time(), "is_academicr_pdf" => 1), "exam_id = '{$examId}'");
- }
- // $pdfurl=iconv("GBK", "UTF-8",$pdfurl);
- // $this->sConn->createCommand()->update("exam", array("academicr_pdf_path" => $pdfurl, "academicr_pdf_time" => time(), "is_academicr_pdf" => 1), "exam_id = '{$examId}'");
- // @unlink($htmlpath);
- } else {
- $this->sConn->createCommand()->update("exam", array("academicr_pdf_path" => "", "academicr_pdf_time" => 0, "is_academicr_pdf" => 0), "exam_id = '{$examId}'");
- // @unlink($htmlpath);
- throw new CException("PDF文件未找到");
- }
- } else {
- // @unlink($htmlpath);
- throw new CException("PDF创建失败");
- }
- }else{
- Curl::post(Yii::app()->params['handle_log_api'], array(
- "exam_group_id" => (string)$val['examGroupId'],
- "operate_project" => 'zsyas2',
- "school_id" => $this->schoolId,
- "title" => '下载教师讲案',
- "operate_account" => Yii::app()->session['coachInfo']['coach_name'],
- "operate_method" => $this->action,
- "operate_url" => $this->getRoute(),
- "operate_sql" => '',
- "operate_param" =>json_encode(array('post'=>array("examId"=>$examId,"pdf"=>array("commond"=>$commond,"res"=>$res,"code"=>$code),"htmlurl"=>$html_url))),
- ));
- echo json_encode(array("status" => 1, "error" => "PDF创建失败!"));
- exit;
- }
- }
- } else {
- throw new CException("系统错误");
- }
- }
- if($this->curlDownloadImage($pdfurl)){
- // if (file_get_contents($pdfurl)) {
- echo json_encode(array("status" => 0, "error" => "","is_create"=>$is_create));
- exit;
- } else {
- echo json_encode(array("status" => 1, "error" => "文件尚未生成!"));
- exit;
- }
- }
- private function getTopicNoByPaper($paper_topcic_relation_arr, $tpl_index)
- {
- $topic_no_arr = array(); //每道题的序号
- if ($tpl_index == 10 || $tpl_index == 1010) { //10,1010 表示江苏那个有a,b,c,d选做题的模板,编号不能按表里的编号来
- $prefix_no = 0;
- $num = 0;
- $index_arr = array('A','B','C','D','E');
- foreach($paper_topcic_relation_arr as $v) {
- if (!$prefix_no && $v['type'] == 17) {
- $prefix_no = $v['no'];
- $topic_no_arr[$v['topic_id']] = $prefix_no.'A';
- } elseif ($prefix_no && $v['type'] == 17) {
- $num += 1;
- $topic_no_arr[$v['topic_id']] = $prefix_no.$index_arr[$num];
- }
- if ($v['type'] == 27) {
- $prefix_no += 1;
- $topic_no_arr[$v['topic_id']] = $prefix_no;
- }
- if ($v['type'] != 17 && $v['type'] != 27){
- $topic_no_arr[$v['topic_id']] = $v['no'];
- }
- }
- } else {
- foreach ($paper_topcic_relation_arr as $v) {
- $topic_no_arr[$v['topic_id']] = $v['no'];
- }
- }
- return $topic_no_arr;
- }
- function get_level_rule($class_id)
- {
- if($class_id){
- $sql = 'select level_rule,pcr.set_type from product_class_relation pcr join class c on pcr.class_id=c.class_id join product_setting ps on pcr.ps_id=ps.ps_id where c.class_id='.$class_id;
- $product_res = $this->sConn->createCommand($sql)->queryRow();
- if (!$product_res) { //没有找到班级与设置的关系表
- return 0;
- } else {
- // if ($product_res['set_type'] == 1) { //如果是错题本,还是找以前的配置
- // return 0;
- // } else{
- return $product_res['level_rule'];
- // }
- }
- }
- return 0;
- }
- function get_version($class_id)
- {
- if($class_id){
- $sql = 'select show_level,pcr.set_type from product_class_relation pcr join class c on pcr.class_id=c.class_id join product_setting ps on pcr.ps_id=ps.ps_id where c.class_id='.$class_id;
- $product_res = $this->sConn->createCommand($sql)->queryRow();
- if (!$product_res) { //没有找到班级与设置的关系表
- $sql = 'select wb_isp_version from class where class_id='.$class_id;
- $res = $this->sConn->createCommand($sql)->queryRow();
- return $res['wb_isp_version'];
- } else {
- if ($product_res['set_type'] == 1) { //如果是错题本,还是找以前的配置
- $sql = 'select wb_isp_version from class where class_id='.$class_id;
- $res = $this->sConn->createCommand($sql)->queryRow();
- return $res['wb_isp_version'];
- } else{
- return $product_res['show_level'];
- }
- }
- }
- return 0;
- }
- private function check_pdf($pdf_path) {
- if (substr($pdf_path, strlen($pdf_path) - 4, 4) == ".pdf") {
- if (file_exists($pdf_path)) {
- return true;
- }
- }
- return false;
- }
- public function actiondown_load() {
- //旧下载 暂时注释
- /*set_time_limit(0);
- $data = array();
- $time = time();
- $examId = safe_replace(Yii::app()->request->getQuery('examId'));
- $sql = "select c.class_name,e.teacher_id,eg.mark_type,e.name as exam_name,e.academicr_pdf_path,e.academicr_pdf_time,p.paper_id,e.is_academicr_pdf,e.exam_group_id from exam as e left join exam_group as eg on e.exam_group_id=eg.exam_group_id left join paper as p on p.exam_id=e.exam_id left join `class` as c on c.class_id=e.class_id where e.exam_id={$examId}";
- $exam_info = $this->sConn->createCommand($sql)->queryRow();
- $pdfpath = str_replace("protected", "", Yii::app()->basePath) . $exam_info['academicr_pdf_path'];
- if ($this->check_pdf($pdfpath)) {
- $data['coachId'] = $this->coachId;
- $data['schoolId'] = $this->schoolId;
- $data['examGroupId'] = (string)$exam_info['exam_group_id'];
- $data['examId'] = (string)$examId;
- $data['createTime'] = $time;
- $pushData=json_encode($data);
- @$stompconn = new Stomp(Yii::app()->params["stomp_address"]);
- @$stompconn->send("zsy-task.download-teacher-lecture-data-point", $pushData);
- unset($stompconn);
- Header("Content-type:application/pdf");
- Header("Accept-Ranges: bytes");
- Header("Accept-Length: " . filesize($pdfpath));
- Header("Content-Disposition: attachment; filename=" . $this->filter_file_name($exam_info['exam_name']."-".$exam_info['class_name']) . ".pdf"); // 输出文件内容
- ob_clean();
- flush();// 刷新内容
- $file=fopen($pdfpath,"r");
- $download_rate=1024;
- while (!feof($file)){
-
- print fread($file,round($download_rate*1024));// 发送当前部分文件给浏览者
- flush();// flush 内容输出到浏览器端
- sleep(1);// 终端1秒后继续
- }
- fclose($file);
- } else {
- Yii::app()->jump->error('考试不存在或尚未生成PDF');
- }*/
- //新下载
- set_time_limit(0);
- $data = array();
- $time = time();
- $examId = safe_replace(Yii::app()->request->getQuery('examId'));
- $sql = "select c.class_name,e.teacher_id,eg.mark_type,e.name as exam_name,e.academicr_pdf_path,e.academicr_pdf_time,p.paper_id,e.is_academicr_pdf,e.exam_group_id,e.class_id,e.subject_id from exam as e left join exam_group as eg on e.exam_group_id=eg.exam_group_id left join paper as p on p.exam_id=e.exam_id left join `class` as c on c.class_id=e.class_id where e.exam_id={$examId}";
- $exam_info = $this->sConn->createCommand($sql)->queryRow();
- if($this->curlDownloadImage($exam_info['academicr_pdf_path'])){
- // if(file_get_contents($exam_info['academicr_pdf_path'])){
-
- $url = $exam_info['academicr_pdf_path'];
- // // 获取远程文件大小
- // // 注意filesize()无法获取远程文件大小
- // $headers = get_headers($url, 1);
- // $fileSize = $headers['Content-Length'];
- // //echo $fileSize;exit;
- // // 设置header头
- // // 因为不知道文件是什么类型的,告诉浏览器输出的是字节流
- // header('Content-Type: application/pdf');
- // // 告诉浏览器返回的文件大小类型是字节
- // header('Accept-Ranges:bytes');
- // // 告诉浏览器返回的文件大小
- // header('Content-Length: ' . $fileSize);
- // // 告诉浏览器文件作为附件处理并且设定最终下载完成的文件名称
- // Header("Content-Disposition: attachment; filename=" . $this->filter_file_name($exam_info['exam_name']."-".$exam_info['class_name']) . ".pdf"); // 输出文件内容
- // //针对大文件,规定每次读取文件的字节数为4096字节,直接输出数据
- // ob_clean();
- // $read_buffer = 1024*1024;
- // $handle = fopen($url, 'rb');
- // //总的缓冲的字节数
- // $sum_buffer = 0;
- // //只要没到文件尾,就一直读取
- // while (!feof($handle)) {
- // echo fread($handle, $read_buffer);
- // ob_flush();
- // }
- // fclose($handle);
- $this->curlDownload($url,$this->filter_file_name($exam_info['exam_name']."-".$exam_info['class_name']));
- if(in_array($exam_info['subject_id'],array(18,19))){
- if($exam_info['subject_id'] == 18){//理综 12物理,13化学,14生物
- $subject_arr = array(12,13,14);
- }else{//文综
- $subject_arr = array(15,16,17);
- }
- $sql = "select t.teacher_id,t.subjects from teacher_class_relation tcr left join teacher t on tcr.teacher_id = t.teacher_id where tcr.class_id = '{$exam_info['class_id']}' and t.subjects in (".implode(',',$subject_arr).") and t.status = 0 group by t.subjects";
- $teacher_info = $this->sConn->createCommand($sql)->queryAll();
- if($teacher_info){
- $data['coachId'] = $this->coachId;
- $data['schoolId'] = $this->schoolId;
- $data['examGroupId'] = (string)$exam_info['exam_group_id'];
- $data['examId'] = (string)$examId;
- $data['createTime'] = $time;
- $data['clazzId'] = (string)$exam_info['class_id'];
- $data['toDataPoint'] = true;
- $data['dataPointType'] = 3;
- foreach($teacher_info as $k=>$v){
- if($v['teacher_id']){
- $data['teacherId'] = $v['teacher_id'];
- }else{
- $data['teacherId'] = '0';
- }
- @$this->sendKafka('datapoint-logs',$data);
- }
- // $pushData=json_encode($data);
- // @$stompconn = new Stomp(Yii::app()->params["stomp_address"]);
- // if(isset($stompconn) && $stompconn){
- // foreach($teacher_info as $k=>$v){
- // if($v['teacher_id']){
- // $data['teacherId'] = $v['teacher_id'];
- // }else{
- // $data['teacherId'] = '0';
- // }
- // $pushData=json_encode($data);
- // @$stompconn->send("zsy-task.download-teacher-lecture-data-point", $pushData);
- // }
- // }
- // unset($stompconn);
- }
- }else{
- if(in_array($exam_info['subject_id'],array(3,6,51))){
- $exam_info['subject_id'] = 3;
- }
- $sql = "select t.teacher_id from teacher_class_relation tcr left join teacher t on tcr.teacher_id = t.teacher_id where tcr.class_id = '{$exam_info['class_id']}' and t.subjects = '{$exam_info['subject_id']}' and t.status = 0";
- $teacher_info = $this->sConn->createCommand($sql)->queryRow();
- if($teacher_info){
- $data['teacherId'] = $teacher_info['teacher_id'];
- }else{
- $data['teacherId'] = '0';
- }
- $url = $exam_info['academicr_pdf_path'];
- $data['coachId'] = $this->coachId;
- $data['schoolId'] = $this->schoolId;
- $data['examGroupId'] = (string)$exam_info['exam_group_id'];
- $data['examId'] = (string)$examId;
- $data['createTime'] = $time;
- $data['clazzId'] = (string)$exam_info['class_id'];
- $data['toDataPoint'] = true;
- $data['dataPointType'] = 3;
- @$this->sendKafka('datapoint-logs',$data);
- // $pushData=json_encode($data);
- // @$stompconn = new Stomp(Yii::app()->params["stomp_address"]);
- // @$stompconn->send("zsy-task.download-teacher-lecture-data-point", $pushData);
- // unset($stompconn);
- }
- }else{
- Yii::app()->jump->error('考试不存在或尚未生成PDF');
- }
- }
- function filter_file_name($filename){
- return str_replace(array(',','.','/','?','!','@','#','$','%','^','&','*','(',')','-','+','{','}','[',']',':',';','"','`','~'),
- array(',','。',' ','?','!',' ',' ',' ',' ','·',' ',' ','(',')','-','+','【','】','【','】',':',';','“',' ',' ')
- , $filename);
- }
- function readfile_chunked($filename,$retbytes=true) {
- $chunksize = 1*(1024*1024); // how many bytes per chunk
- $buffer = '';
- $cnt =0;
- // $handle = fopen($filename, 'rb');
- $handle = fopen($filename, 'rb');
- if ($handle === false) {
- return false;
- }
- while (!feof($handle)) {
- $buffer = fread($handle, $chunksize);
- echo $buffer;
- ob_flush();
- flush();
- if ($retbytes) {
- $cnt += strlen($buffer);
- }
- }
- $status = fclose($handle);
- if ($retbytes && $status) {
- return $cnt; // return num. bytes delivered like readfile() does.
- }
- return $status;
- }
- private function paperTopicDetail($yun_id_arr, $sch_id_arr, $exam_id, $typestr) {
- try {
- $all_id_arr = array_merge($yun_id_arr,$sch_id_arr);
- if (!$all_id_arr ) {
- return false;
- }
- $data = array();
- $total_count = count($all_id_arr);
- $page_size = 100;
- $page = ceil($total_count/$page_size);
- for ($i = 0; $i<$page; $i++) {
- $offset = $i * $page_size;
- $id_arr = array_slice($all_id_arr,$offset, $page_size);
- $topicBatchs = $this->aipost('topic/batchall', array('topicIds' => $id_arr));
- if (!$topicBatchs) {
- throw new Exception('获取接口topic/batchALL数据时无任何返回,type is '.$typestr.' ,exam_id is ('.$exam_id.')');
- }if(isset($topicBatchs->status) && $topicBatchs->status == 0 ){
- throw new Exception($topicBatchs->error[0]);
- } else{
-
- $data += $this->formatDetails($topicBatchs);
- }
- }
- return $data;
- } catch (Exception $e) {
- return false;
- }
- }
- public function formatDetails($topicBatches) {
- $optionIndex = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K');
- $topicDetails = array();
- foreach ($topicBatches AS $ke=>$topic) {
- if(!isset($topic["teacher_tips"]) || !$topic["teacher_tips"]){
- $topicBatches[$ke]["teacher_tips"] = $this->dealTeacherTips($topic);
- }
- $topic = (object) $topic;
- $topic->id = (string)$topic->id;
- $type = $topic->type_id;
- 6 == $type && $type = 5; //6表示多空题,多空题也是5
- $topicDetails[$topic->id] = array();
- $topicDetails[$topic->id]['type'] = $type;
- $topicDetails[$topic->id]['methods'] = ''; //考点
- $topicDetails[$topic->id]['method_id_arr'] = ''; //考点id数组
- $topicDetails[$topic->id]['kps'] = ''; //知识点
- $topicDetails[$topic->id]['queBody'] = $this->topicProcess($topic->title); //题目详情
- $topicDetails[$topic->id]['options'] = '';
- $topicDetails[$topic->id]['parse_video_qrcode'] = isset($topic->parse_video_qrcode) ? $topic->parse_video_qrcode : '';
- $topicDetails[$topic->id]['answer'] = ''; //每题的正确答案
- $topicDetails[$topic->id]['analysis'] = $this->topicProcess($topic->parse_content); //答题解析
- $topicDetails[$topic->id]['teacher_tips'] = $this->topicProcess($topic->teacher_tips); //名师点评
- $topicDetails[$topic->id]['difficulty_degree'] = isset($topic->difficulty_degree) ? $topic->difficulty_degree : null;
- $topicDetails[$topic->id]['difficulty'] = $topic->difficulty;
- $topicDetails[$topic->id]['type_name'] = $topic->type_name;
- $topicDetails[$topic->id]['source'] = $topic->source;
- $_methods = array();
- $_method_id_arr = array();
- if ($topic->specials) {
- foreach ($topic->specials AS $_method) {
- $_method = (object) $_method;
- if ($_method->method_name) {
- $_methods[] = $_method->method_name;
- }
- if (isset($_method->method_id)) {
- $_method_id_arr[] = $_method->method_id;
- }
- }
- $topicDetails[$topic->id]['methods'] = implode('|', array_unique($_methods)); //考点
- $topicDetails[$topic->id]['method_id_arr'] = $_method_id_arr;
- }
- $_kps = array();
- if (isset($topic->kps) && $topic->kps) {
- foreach ($topic->kps as $_kp) {
- $_kp = (object) $_kp;
- if ($_kp->kp_name) {
- $_kps[$_kp->kp_id] = $_kp->kp_name;
- }
- }
- $topicDetails[$topic->id]['kps'] = $_kps; //考点
- }
- if ($topic->type_id == 1 || $topic->type_id == 2) { //选择题有选项
- if ($topic->items) {
- if (isset($topic->items[0])) {
- $topic->items[0] = (object) $topic->items[0];
- if (isset($topic->items[0]->options)) {
- $options = $topic->items[0]->options;
- if ($options) {
- $_tmp_options = array();
- $anwer_str = "";
- foreach ($options AS $_optionIndex => $_option) {
- $_option = (object) $_option;
- $_tmp_options[$_optionIndex] = $this->topicProcess($_option->option_content);
- if ($_option->option_correct) {
- if($anwer_str == ""){
- $anwer_str = $this->topicProcess($optionIndex[$_optionIndex]);
- // $topicDetails[$topic->id]['answer'] = $this->topicProcess($optionIndex[$_optionIndex]);
- }else{
- $anwer_str .= "、".$this->topicProcess($optionIndex[$_optionIndex]);
- }
-
- }
- }
- $topicDetails[$topic->id]['answer'] = $anwer_str;
- $topicDetails[$topic->id]['answer_format'] = str_replace('、', '', $anwer_str);
- $_list_type = (int) $topic->items[0]->list_type;
- $topicDetails[$topic->id]['options'] = $this->option_process($_tmp_options, $_list_type);
- }
- }
- }
- }
- } else {
- if ($topic->items) {
- if (isset($topic->items[0])) {
- $topic->items[0] = (object) $topic->items[0];
- if (isset($topic->items[0]->options)) {
- $options = $topic->items[0]->options;
- if ($options) {
- $_answer = '';
- foreach ($options as $v) {
- $_option = (object) $v;
- if (trim($_answer) != '') {
- $_answer .= ' ; ';
- }
- $_answer .= $_option->option_content;
- }
- $topicDetails[$topic->id]['answer'] = $this->topicProcess($_answer);
- }
- }
- }
- }
- }
- }
- return $topicDetails;
- }
- private function option_process($options, $list_type) {
- $option_index = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J');
- if ($list_type == 0) { //纵向排列,即1行1个
- $option_str = "";
- foreach ($options as $key => $option) {
- $option_str.="<li class='fl lis-one'>$option_index[$key].$option</li>";
- }
- } elseif ($list_type == 1) { //横向排列,即1行4个
- $option_str = "";
- foreach ($options as $key => $option) {
- $option_str.="<li class='fl lis-four'>$option_index[$key].$option</li>";
- }
- } elseif ($list_type == 2) { //1行2个
- $option_str = "";
- foreach ($options as $key => $option) {
- if ($key % 2 == 0) {
- $option1 = $options[$key];
- $option_str2 = "<li class='fl lis-two'>$option_index[$key].$option1</li>";
- $key1 = $key + 1;
- if (isset($options[$key1])) {
- $option2 = $options[$key1];
- $option_str2.="<li class='fl lis-two'>$option_index[$key1].$option2</li>";
- }
- $option_str.=$option_str2;
- } else {
- continue;
- }
- }
- }
- return $option_str;
- }
- private function topicProcess($html) {
- if (preg_match_all('/(<img[^>]*[\s]+)((src)[\s]*=[\s]*(([\"]([^\"]*)[\"])|([\']([^\']*)[\'])|([^\s]*)))([^>]*>)/si', $html, $arr)) {
- foreach ($arr[0] as $v) {
- $process_str = $this->img_process($v);
- ;
- $html = str_replace($v, $process_str, $html);
- }
- }
- $html = preg_replace('/style\s*=\s*(([\"]([^\"]*)[\"])|([\']([^\']*)[\']))/si', '', $html);
- $html = preg_replace('/<p\s*>/', '', $html);
- $html = preg_replace('/<\/p>/', '', $html);
- $html = preg_replace('/<br\/*>/', '', $html);
- $html = preg_replace('/<big\s*>/', '', $html);
- $html = preg_replace('/<\/big>/', '', $html);
- $html = str_replace(" ", '', $html);
- return $html;
- }
- private function img_process($img) {
- $widthArr = array();
- $heightArr = array();
- $width = '';
- $height = '';
- if (preg_match('/[\s\'"]width\s*:\s*(\d+\.*\d*)\s*([a-zA-Z]+)*/si', $img, $widthArr)) {
- $width = $this->length_process($widthArr);
- } else {
- if (preg_match('/[\s\'"]width\s*=\s*[\'"]\s*(\d+\.*\d*)\s*([a-zA-Z]+)*;?[\'"]/si', $img, $widthArr)) {
- $width = $this->length_process($widthArr);
- }
- }
- if ($width) {
- $width = "width=" . $width;
- }
- if (preg_match('/[\s\'"]height\s*:\s*(\d+\.*\d*)\s*([a-zA-Z]+)*/si', $img, $heightArr)) {
- $height = $this->length_process($heightArr);
- } else {
- if (preg_match('/[\s\'"]height\s*=\s*[\'"]\s*(\d+\.*\d*)\s*([a-zA-Z]+)*;?[\'"]/si', $img, $heightArr)) {
- $height = $this->length_process($heightArr);
- }
- }
- if ($height) {
- $height = "height=" . $height;
- }
- $return_img = preg_replace('/<img[^>]*[\s]+(src[\s]*=[\s]*(([\"]([^\"]*)[\"])|([\']([^\']*)[\'])|([^\s]*)))([^>]*>)/si', "<img " . $width . " " . $height . " $1 />", $img);
- return $return_img;
- }
- private function length_process($length_arr) {
- $length = 0.6 * $length_arr[1];
- $unit_keys = array_keys($this->units);
- if (isset($length_arr[2])) {
- //将直接连接单位改为 单位换算
- if (in_array($length_arr[2], $unit_keys)) {
- $length = $length * $this->units[$length_arr[2]];
- } else {
- $length .= $length_arr[2];
- }
- }
- return $length;
- }
- public function numToUpper($number) {
- $number = substr($number, 0, 2);
- $arr = array('零', '一', '二', '三', '四', '五', '六', '七', '八', '九');
- if (strlen($number) == 1) {
- $result = $arr[$number];
- } else {
- if ($number == 10) {
- $result = '十';
- } else {
- if ($number < 20) {
- $result = '十';
- } else {
- $result = $arr[substr($number, 0, 1)] . '十';
- }
- if (substr($number, 1, 1) != '0') {
- $result .= $arr[substr($number, 1, 1)];
- }
- }
- }
- return $result;
- }
- public function numToLetter($number) {
- $letters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
- $number = (int) $number;
- $result = '';
- if ($number >= 1 AND $number <= 26) {
- $result = $letters[$number - 1];
- }
- return $result;
- }
- public function actionDownload() {
- $exam_id = safe_replace(Yii::app()->request->getQuery('exam_id'));
- $host = '';
- $databases_data = BusinessDatabase::model()->find('school_id=:school_id', array(':school_id' => $this->schoolId));
- if ($databases_data) {
- $host = isset(Yii::app()->params['static_url'][$databases_data->group_id]) ? Yii::app()->params['static_url'][$databases_data->group_id] : Yii::app()->params['api_host'].'/uploads/';
- }
- $exam_data = Exam::model()->find('exam_id=:exam_id', array(':exam_id' => $exam_id));
- if ($exam_data) {
- $filename = $exam_data->topwb_pdf_path;
- $filenames = explode('/', $filename);
- $filenames = array_reverse($filenames);
- if (!filter_var(trim($filename), FILTER_VALIDATE_URL)) { //没有http
- $filename = $host . '/' . $filename;
- }
- header('Content-Description: File Transfer');
- header('Content-Type: application/vnd.android.package-archive');
- header('Content-Disposition: attachment; filename=' . $filenames[0]);
- header('Content-Transfer-Encoding: binary');
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $filename);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
- curl_setopt($ch, CURLOPT_WRITEFUNCTION, function ($ch, $buffer) {
- echo $buffer;
- return strlen($buffer);
- });
- curl_exec($ch);
- curl_close($ch);
- /*$content = curlDownloadImage($filename);
- $length=strlen($content);//取得字符串长度,即文件大小,单位是字节
- $encoded_filename = rawurlencode($filename);//采用rawurlencode避免空格被替换为+
- $ua = $_SERVER["HTTP_USER_AGENT"];//获取用户浏览器UA信息
- header('Content-Type: application/octet-stream');//告诉浏览器输出内容类型,必须
- header('Content-Encoding: none');//内容不加密,gzip等,可选
- header("Content-Transfer-Encoding: binary" );//文件传输方式是二进制,可选
- header("Content-Length: ".$length);//告诉浏览器文件大小,可选
- if (preg_match("/MSIE/", $ua)) {//从UA中找到MSIE判断是IE
- header('Content-Disposition: attachment; filename="' . $encoded_filename . '"');
- } else if (preg_match("/Firefox/", $ua)) {//同理判断火狐
- header('Content-Disposition: attachment; filename*="utf8\'\'' . $filenames[0] . '"');
- } else {//其他情况,谷歌等
- header('Content-Disposition: attachment; filename="' . $filenames[0] . '"');
- }
- echo $content;
- exit();*/
- }
- }
- public function actionStatistics() {
- $data = array();
- $semester_data = Semester::model()->findAll();
- if ($semester_data) {
- $data['semester'] = $semester_data;
- } else {
- $data['semester'] = array();
- }
- $data['school_info'] = $this->schoolInfo;
- $this->render('statistics', $data);
- }
- public function actionPastacdemicrs()
- {
- $param_semester_id = safe_replace(Yii::app()->request->getQuery('semester'));
- $param_grad_id = safe_replace(Yii::app()->request->getQuery('grade'));
- $param_class_id = safe_replace(Yii::app()->request->getQuery('class'));
- $param_exam_name = safe_replace(Yii::app()->request->getQuery('exam_name'));
- $data = array(
- 'current_sem_id' =>0,
- 'current_grade_id'=>0,
- 'current_class_id'=>0,
- 'current_exam_name'=>'',
- 'sem_arr' => array(),
- 'class_arr' => array()
- );
- if ($param_semester_id) {
- $data['current_sem_id'] = $param_semester_id;
- }
- if ($param_grad_id) {
- $data['current_grade_id'] = $param_grad_id;
- }
- if ($param_class_id) {
- $data['current_class_id'] = $param_class_id;
- }
- if ($param_exam_name) {
- $data['current_exam_name'] = $param_exam_name;
- }
- //获取所有过去的学期,默认当前学期的第一学期被选中
- $_current_sem_start_time = 0;
- $sql = 'select start_time from semester where status=1 limit 1';
- $res = $this->sConn->createCommand($sql)->queryRow();
- $start_time = $res['start_time'];
- if (!$start_time) {
- Yii::app()->jump->error('该学校无当前学期,请检查学期是否设置错误');
- }
- $sql = 'select semester_id,semester_name from semester where status=0 and start_time < '.$start_time.' order by start_time desc ';
- $res = $this->sConn->createCommand($sql)->queryAll();
- if (!$res) {
- Yii::app()->jump->error('以前的学期不存在');
- }
- $sem_arr = array();
- foreach ($res as $v) {
- $sem_arr[$v['semester_id']] = $v['semester_name'];
- }
- $data['sem_arr'] = $sem_arr;
- if (!$data['current_sem_id']) {
- $data['current_sem_id'] = $res[0]['semester_id'];
- }
- //如果选择了年级,显示出对应的班级
- if ($param_grad_id) {
- $class_arr = array();
- $sql = 'select class_id,class_name from class where semester_id='.$data['current_sem_id'].' and grade='.$param_grad_id;
- $res = $this->sConn->createCommand($sql)->queryAll();
- foreach ($res as $v) {
- $class_arr[$v['class_id']] = $v['class_name'];
- }
- $data['class_arr'] = $class_arr;
- }
- //符合查询条件的考试
- $sql = 'select e.exam_id,e.name,e.is_academicr_pdf,c.class_id,c.class_name from exam e join class c on c.class_id=e.class_id join class_exam_printer cep on cep.class_id=e.class_id and cep.exam_id=e.exam_id where e.semester_id='.$data['current_sem_id'].' and e.status=1 and cep.type=0 and e.subject_id in ('.implode(',',$this->mathSubjectId).') ';
- if ($param_grad_id) {
- $sql.= ' and c.grade='.$param_grad_id;
- }
- if ($param_class_id) {
- $sql.= ' and c.class_id='.$param_class_id;
- }
- if ($param_exam_name) {
- $sql .= ' and e.name like "%'.$param_exam_name.'%"';
- }
- $sql .= ' order by cep.add_time desc';
- $res = $this->sConn->createCommand($sql)->query();
- $data['page_total'] = $res->rowCount;
- $sql = $res->queryString." limit :offset, :limit";
- $command = $this->sConn->createCommand($sql);
- $pager = new CPagination($res->rowCount, 10);
- $offset = $pager->getOffset();
- $command->bindValue(":offset", $offset);
- $limit = $pager->getLimit();
- $command->bindValue(":limit", $limit);
- $res = $command->queryAll();
- if (!$res) {
- $exam_data = array();
- } else{
- foreach ($res as $v) {
- $exam_id = $v['exam_id'];
- $exam_data[$exam_id]['exam_name'] = $v['name'];
- $exam_data[$exam_id]['class_name'] = $v['class_name'];
- $exam_data[$exam_id]['class_id']=$v['class_id'];
- $exam_data[$exam_id]['status'] = $v['is_academicr_pdf']?'已生成':'未生成';
- }
- }
- $data['exam_data'] = $exam_data;
- $data['pager'] = $pager;
- $this->render('pastacdemicrs',$data);
- }
- public function actionGetGradeClass()
- {
- $grade = Req::post("grade");
- $semester_id = Req::post("semester_id");
- $sql = 'select class_id,class_name from class where semester_id='.$semester_id.' and grade='.$grade;
- $classes = $this->sConn->createCommand($sql)->queryAll();
- if ($classes) {
- $error['success'] = 1;
- $error['message'] = $classes;
- } else {
- $error['success'] = 0;
- $error['message'] = '未找到班级!';
- }
- echo json_encode($error);
- exit();
- }
- public function actionS_download() {
- $semester_id = Req::post("semester_id");
- $data = array();
- $host = '';
- if (!$semester_id) {
- echo '{"status":-1}';
- exit;
- }
- $semester_data = Semester::model()->find('semester_id=:semester_id', array(':semester_id' => $semester_id));
- if ($semester_data) {
- $databases_data = BusinessDatabase::model()->find('school_id=:school_id', array(':school_id' => $this->schoolId));
- if ($databases_data) {
- $host = isset(Yii::app()->params['static_url'][$databases_data->group_id]) ? Yii::app()->params['static_url'][$databases_data->group_id] : Yii::app()->params['static_url'][0];
- }
- $str = $host . '/teaching_quality/' . $this->schoolId . '/' . $semester_data->semester_id . '/' . trim($this->schoolInfo->school_name) . '学校' . trim($semester_data->semester_name) . '教学质量统计表.xls';
- $file_data = Curl::http_get($str);
- if ($file_data) {
- /*校长报告埋点*/
- $stomp_data = array();
- $stomp_data['coachId'] = $this->coachId;
- $stomp_data['schoolId'] = $this->schoolId;
- $stomp_data['semesterId'] = (string)$semester_id;
- $stomp_data['createTime'] = time();
- $stomp_data['toDataPoint'] = true;
- $stomp_data['dataPointType'] = 4;
- @$this->sendKafka('datapoint-logs',$stomp_data);
- // $pushData=json_encode($stomp_data);
- // @$stompconn = new Stomp(Yii::app()->params["stomp_address"]);
- // @$stompconn->send("zsy-task.download-coach-schoolmaster-report-data-point", $pushData);
- // unset($stompconn);
- echo '{"status":1,"file_path":"' . $str . '"}';
- exit;
- }
- echo '{"status":0}';
- exit;
- } else {
- echo '{"status":-2}';
- exit;
- }
- }
- /**
- * 判断远程文件是否存在
- * @param string $url 文件地址
- * @return boolean
- */
- function url_exists($url) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- //涓嶄笅杞?
- curl_setopt($ch, CURLOPT_NOBODY, 1);
- //璁剧疆瓒呮椂
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
- curl_setopt($ch, CURLOPT_TIMEOUT, 3);
- curl_exec($ch);
- $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- if ($http_code == 200) {
- return true;
- }
- return false;
- }
- function transferOrders($paperIds,$is_qxk=0)
- {
- $sql = 'select paper_id,topic_id,type,`order`,stem_id from paper_topic_relation where paper_id in ('.implode(',',$paperIds).') order by paper_id, type asc,`order` asc';
- $paper_topcic_relation_res = $this->sConn->createCommand($sql)->queryAll();
- $sql = 'select tpl_index,tpl_data,paper_id from exam e join paper p on e.exam_id = p.exam_id where p.paper_id in ('.implode(',',$paperIds).')' ;
- $tpl_index_res = $this->sConn->createCommand($sql)->queryAll();
- $tpl_index_arr = array();
- $topic_no_data_arr = $tpl_data_arr = array();
- $changeDoToicNo = array();
- foreach ($tpl_index_res as $v) {
- $tpl_index_arr[$v['paper_id']] = $v['tpl_index'];
- if($v['tpl_data']){
- $v['tpl_data'] = preg_replace('/:\s*(-?\d{15,})/', ': "$1"', $v['tpl_data']);//把15位的int转成string
- $tplData = json_decode($v['tpl_data'],true);
- if($tplData){
- $tplstatus = 0;
- if(isset($tplData['tplstatus'])){
- $tpl_data_arr[$v['paper_id']] = $tplData['tplstatus'];
- }else{
- $tpl_data_arr[$v['paper_id']] = 0;
- }
- }
- //选做题题号
- if (isset($tplData['new_items']) && $tplData['new_items']) {
- $new_items = array_values($tplData['new_items']);
- foreach ($new_items as $key => &$item) {
- if (isset($item['sameAliasNo']) && $item['sameAliasNo']>0) {
- $no =$item['alias'];
- $item['topicId'] = (string)$item['topicId'];
- $changeDoToicNo[$v['paper_id']]["list"][$item['topicId']]["sameAliasNo"] = $item['sameAliasNo'];//选做题组id
- $changeDoToicNo[$v['paper_id']]["list"][$item['topicId']]["smTopicLen"] = $item['smTopicLen'];//选做题组必做数量
- $changeDoToicNo[$v['paper_id']]["list"][$item['topicId']]["no"] = $no;//题号
- $changeDoToicNo[$v['paper_id']]["list"][$item['topicId']]["topicId"] = $item['topicId'];//题目id
- $changeDoToicNo[$v['paper_id']]["gather"][$item['sameAliasNo']][]=$item['topicId'];
- }
- }
- }
- }
- }
- $paper_topcic_relation_arr = array();
- foreach ( $paper_topcic_relation_res as $v) {
- $paper_id = $v['paper_id'];
- $type = $v['type'];
- $order = $v['order'];
- $topic_id = (string)$v['topic_id'];
- $stem_id = (string)$v['stem_id'];
- if (!isset($paper_topcic_relation_arr[$paper_id])) {
- $paper_topcic_relation_arr[$paper_id] = array();
- }
- $paper_topcic_relation_arr[$paper_id][] = array(
- 'type' => $type,
- 'order' => $order,
- 'topic_id'=>$topic_id,
- 'stem_id'=>$stem_id
- );
- }
- $paper_topic_no_arr = array();
- foreach ($paper_topcic_relation_arr as $paper_id => $paper_topic_relation) {
- $tpl_index = $tpl_index_arr[$paper_id];
- $tplstatus = isset($tpl_data_arr[$paper_id])?$tpl_data_arr[$paper_id]:0;
- $change_do_toicno = isset($changeDoToicNo[$paper_id])?$changeDoToicNo[$paper_id]:array();
- $paper_topic_no_arr[$paper_id] =$this->topic_number($paper_topic_relation,$tpl_index,$tplstatus,$is_qxk,$change_do_toicno);
- }
- return $paper_topic_no_arr;
- }
- function topic_number($paper_topcic_relation_arr, $tpl_index,$tplstatus,$is_qxk=0,$change_do_toicno=array())
- {
- $topic_no_arr = array(); //每道题的序号
- if($is_qxk){
- $_order = 1;
- $small_no = 1;
- //$change_no =65;
- $change_no_arr = $temp_stem_arr = array();
- foreach($paper_topcic_relation_arr as $v){
- if($v['stem_id']){
- $temp_stem_arr[$v['stem_id']][] = $v['topic_id'];
- }
- }
- foreach ($paper_topcic_relation_arr as $v) {
- if(!isset($temp_stem_arr[$v['stem_id']]) || count($temp_stem_arr[$v['stem_id']]) == 1){
- if(!empty($change_do_toicno["list"]) && isset($change_do_toicno["list"][$v['topic_id']]) &&
- count($change_do_toicno["gather"][$change_do_toicno["list"][$v['topic_id']]["sameAliasNo"]])>1){//判断是否选做题
- if(isset($change_no_arr[$change_do_toicno["list"][$v['topic_id']]["sameAliasNo"]])){
- $change_no = $change_no_arr[$change_do_toicno["list"][$v['topic_id']]["sameAliasNo"]];
- }else{
- $change_no = 65;//从A开始
- }
- $topic_no_arr[$v['topic_id']] = $_order . chr($change_no) ;
- $change_no_arr[$change_do_toicno["list"][$v['topic_id']]["sameAliasNo"]] = $change_no +1;
- }else{
- $topic_no_arr[$v['topic_id']] = $_order;
- $_order++;
- }
- $small_no = 1;
- }else{//大小提
- if(!empty($change_do_toicno["list"]) && isset($change_do_toicno["list"][$v['topic_id']]) &&
- count($change_do_toicno["gather"][$change_do_toicno["list"][$v['topic_id']]["sameAliasNo"]])>1) {//判断是否选做题
- if(isset($change_no_arr[$change_do_toicno["list"][$v['topic_id']]["sameAliasNo"]])){
- $change_no = $change_no_arr[$change_do_toicno["list"][$v['topic_id']]["sameAliasNo"]];
- }else{
- $change_no = 65;//从A开始
- }
- $_order = $_order . chr($change_no);
- }
- $topic_no_arr[$v['topic_id']] = $_order.'('.$small_no.')';
- if($small_no == count($temp_stem_arr[$v['stem_id']])){
- $small_no = 1;
- $_order++;
- }
- $small_no++;
- }
- }
- }else if ($tpl_index == 10 || $tpl_index == 1010 || $tplstatus == 3 || $tplstatus == 4) { //10,1010 表示江苏那个有a,b,c,d选做题的模板,编号不能按表里的编号来
- $prefix_no = 0;
- $num = 0;
- $index_arr = array('A','B','C','D','E');
- $_order = 0;
- foreach($paper_topcic_relation_arr as $v) {
- if (!$prefix_no && $v['type'] == 17) {
- $_order += 1; //序号加1
- $prefix_no = $_order;
- $topic_no_arr[$v['topic_id']] = $prefix_no.'A';
- } elseif ($prefix_no && $v['type'] == 17) {
- $num += 1;
- $topic_no_arr[$v['topic_id']] = $prefix_no.$index_arr[$num];
- }
- if ($v['type'] == 27) {
- $prefix_no += 1;
- $topic_no_arr[$v['topic_id']] = $prefix_no;
- }
- if ($v['type'] != 17 && $v['type'] != 27){
- $_order += 1;
- $topic_no_arr[$v['topic_id']] = $_order;
- }
- }
- } else { //其他模板都是根据order就行
- $_order = 0;
- foreach ($paper_topcic_relation_arr as $v) {
- if(!empty($change_do_toicno["list"]) && isset($change_do_toicno["list"][$v['topic_id']]) &&
- count($change_do_toicno["gather"][$change_do_toicno["list"][$v['topic_id']]["sameAliasNo"]])>1) {//判断是否选做题
- if (isset($change_no_arr[$change_do_toicno["list"][$v['topic_id']]["sameAliasNo"]])) {
- $change_no = $change_no_arr[$change_do_toicno["list"][$v['topic_id']]["sameAliasNo"]];
- } else {
- $change_no = 65;//从A开始
- $_order += 1;
- }
- $topic_no_arr[$v['topic_id']] = $_order . chr($change_no);
- $change_no_arr[$change_do_toicno["list"][$v['topic_id']]["sameAliasNo"]] = $change_no + 1;
- }else{
- $_order += 1;
- $topic_no_arr[$v['topic_id']] = $_order;
- }
- }
- }
- return $topic_no_arr;
- }
- public function actionAjax_down()
- {
- $examId = Req::post("exam_id");
- $file_type = Req::post("download_type");
- $param['hasStudentNo'] = (int)Req::post("hasStudentNo"); //是否有学号
- $param['hasStudentSystemCard'] = (int)Req::post("hasStudentSystemCard"); //是否有学生系统准考证号
- $param['hasStudentSchoolCard'] = (int)Req::post("hasStudentSchoolCard"); //是否有学生学校准考证号
- $param['hasIdNumber'] = (int)Req::post("hasIdNumber"); //是否有身份证
- $param['removeOuterStudent'] = (int)Req::post("removeOuterStudent"); //是否移除借读生
- $param['removeZeroStudent'] = (int)Req::post("removeZeroStudent"); //过滤0分考生
- $param['hasClazzAchievement'] = (int)Req::post("hasClazzAchievement"); //班级成绩分析表
- $param['hasStudentAchievementRank'] = (int)Req::post("hasStudentAchievementRank"); //学生成绩排名分析表
- $param['hasGradeAchievement'] = (int)Req::post("hasGradeAchievement"); //年级成绩分析表
- $param['hasClazzAvgScore'] = (int)Req::post("hasClazzAvgScore"); //班级平均分表
- $param['hasScoreSection'] = (int)Req::post("hasScoreSection"); //班级分数段表
- $param['hasSubjectAchievement'] = (int)Req::post("hasSubjectAchievement"); //各科成绩分析表
- $param['hasWenLiZongDetail'] = (int)Req::post("hasWenLiZongDetail"); //是否有文综理综单科成绩明细报表
- $scoreSectionList = Req::post('scoreSection'); //总分段
- $param['isSimpleClazzAchievement'] = (int)Req::post("isSimpleClazzAchievement"); //班级学生成绩分析表(完整版:0;简易版:1,简易版不提供题目统计、答错人数、选项统计、分数段人数、缺考人数)
- $param['isSimpleClazzAvgScore'] = (int)Req::post("isSimpleClazzAvgScore"); //班级平均分表(完整版:0;简易版:1,简易版不提供题目统计)
- $param['isSimpleGradeAchievement'] = (int)Req::post("isSimpleGradeAchievement"); //年级学生成绩分析表(完整版:0;简易版:1,简易版不提供题目统计、答错人数、选项统计、分数段人数)
- $param['totalScoreCoefficient'] = Req::post("totalScoreCoefficient"); //总分系数
- $param['excellentRatio'] = Req::post('excellentRatio'); //优秀率
- $param['goodRatio'] = Req::post('goodRatio'); //良好率
- $param['mediumRatio'] = Req::post('mediumRatio'); //中等率
- $param['hasStudentAnswerDetail'] = Req::post("hasClazzChoiceTopicStatistics"); //选择题作答明细表
- $param['showSetting'] = Req::post("scoreOfEachQuestion"); //每题得分(学生答案,学生得分 0学生答案,1学生得分)
- $param['examId'] = $examId;
- $param['paperSizeType'] = Req::post("paperSizeType"); //A4横向:1;A3纵向:2;默认1;
- $param['showRankingChanges'] = (int)Req::post("showRankingChanges"); //是否显示排名升降 显示:1;隐藏:0
- $param['totalScoreCoefficientIsRounding'] = (int)Req::post("totalScoreCoefficientIsRounding"); //启用总分系数后,是否保留小数,0整数,1保留小数
- if(!$param['paperSizeType']) $param['paperSizeType'] =1;
- if($scoreSectionList){
- // $param['scoreSectionList']=explode(',',$scoreSectionList);
- $param['scoreSectionList']=$scoreSectionList;
- }
- if($param['totalScoreCoefficient']=='-1'){
- $param['totalScoreCoefficient']=0;
- }
- if(!$examId || !$file_type)
- {
- echo json_encode(array('status'=>0,'result'=>''));exit;
- }
- if($file_type==1 || $file_type==2){
- if($file_type==2){
- $urlType='excel';
- }else{
- //word没有
- // unset($param['hasScoreSection']);
- unset($param['hasWenLiZongDetail']);
- unset($param['hasGradeAchievement']);
- unset($param['hasSubjectAchievement']);
- unset($param['isSimpleGradeAchievement']);
- unset($param['hasStudentAnswerDetail']);
- // unset($param['showSetting']);
- $urlType='word';
- }
- //获取是否是全学科组卷
- $sql = "select eg.qxk_paper_id,e.class_id,e.name,e.subject_id,e.exam_group_id from exam_group eg join exam e on eg.exam_group_id = e.exam_group_id where e.exam_id= '{$examId}'";
- $quan_data = $this->sConn->createCommand($sql)->queryRow();
- if($quan_data && $quan_data['qxk_paper_id']){
- $url = Yii::app()->params['zsy_api_url'].'/qxk/academic/exam-report/download/'.$urlType;
- }else{
- $url = Yii::app()->params['zsy_api_url'].'/teacher/academic/download/'.$urlType.'/'.$this->schoolId;
- }
- $this->setIs_new($examId);
- $username = $this->schoolId;
- $password = md5($this->schoolId.Yii::app()->params['zsy_api_key']);
- $rs = $this->CrmApiPost($url,$param,$username,$password);
- if(isset($rs->errCode) && $rs->errCode =='00')
- {
- //组装打印参数
- $printData=array();
- $printData['typeId']=18;
- $printData['productType']=60003;
- $printData['params']=array(
- 'classIds'=>array($quan_data['class_id']),
- 'url'=>$rs->data,
- 'name'=>$quan_data['name'],
- 'subjectId'=>$quan_data['subject_id'],
- 'examGroupId'=>$quan_data['exam_group_id'],
- );
- echo json_encode(array('status'=>1,'result'=>$rs->data,'print'=>$printData));exit;
- }
- $errMsg = '下载失败';
- if(isset($rs->errMsg))
- {
- $errMsg = $rs->errMsg;
- }
- echo json_encode(array('status'=>0,'result'=>$errMsg));exit;
- }
- }
- public function CrmApiPost($url, $arr, $username,$password,$method='POST')
- {
- $ch = @curl_init();
- $result = FALSE;
- if ($ch)
- {
- $data = json_encode($arr);
- if($method=='POST'){
- // Digest认证
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
- curl_setopt($ch, CURLOPT_USERPWD, $username .':'. $password);
- // 不输出头部
- curl_setopt($ch, CURLOPT_HEADER, 0);
- // curl_exec 获取到的内容不直接输出, 而是返回
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
- // 请求重启路由器的地址 传参 进行重启
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_TIMEOUT,120);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Api Client/1.0.0 (chengfei@liancaitech.com)');
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Content-Length: '. strlen($data),
- ));
- }else{
- // Digest认证
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
- curl_setopt($ch, CURLOPT_USERPWD, $username .':'. $password);
- // 不输出头部
- curl_setopt($ch, CURLOPT_HEADER, 0);
- // curl_exec 获取到的内容不直接输出, 而是返回
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
- // 请求重启路由器的地址 传参 进行重启
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Api Client/1.0.0 (chengfei@liancaitech.com)');
- }
- if( !curl_errno($ch))
- {
- $result = json_decode(curl_exec($ch));
- }
- // 释放资源
- curl_close($ch);
- }
- return $result;
- }
- public function setIs_new($exam_id)
- {
- if($exam_id)
- {
- Exam::model()->updateAll(array('is_new'=>2),'exam_id=:exam_id',array(':exam_id'=>$exam_id));
- }
- }
- // 操作周周练显示状态
- public function actionOprateexam(){
- $exam_id = Req::post("exam_id");
- $flag = Req::post("flag");
- $error['success'] = 0;
- if (empty($exam_id)) {
- $error['message'] = '操作失败!';
- echo json_encode($error);exit();
- }
- $this->setIs_new($exam_id);
- if ($this->schoolManager->oprateExamExportDisplay($exam_id,$flag)) {
- $error['success'] = 1;
- $error['message'] = '操作成功!';
- } else {
- $error['message'] = '操作失败!';
- }
- echo json_encode($error);exit();
- }
- public function actionGetSection(){
- $param=array();
- $exam_id = Req::post("exam_id");
- $result['success']=0;
- if(!$exam_id){
- exit(json_encode($result));
- }
- //判断考试类型
- $is_lecture_download=1; //教师讲案
- $is_topwb_download=1; //错题前十
- $is_lecture_download_msg='';
- $is_topwb_download_msg='';
- $exam_data = Exam::model()->find('exam_id=:exam_id', array(':exam_id' => $exam_id));
- $xamGroupData=ExamGroup::model()->find('exam_group_id=:exam_group_id', array(':exam_group_id' => $exam_data->exam_group_id));
- if($xamGroupData->is_third==1 && $xamGroupData->mark_type==0){
- $is_lecture_download=0;
- $is_topwb_download=0;
- $is_lecture_download_msg='线下导入成绩不能下载教师讲案';
- $is_topwb_download_msg='线下导入成绩不能下载错题前十';
- }else{
- if($exam_data->is_topwb_pdf!=1){
- $is_topwb_download=0;
- $is_topwb_download_msg='错题前十未生成';
- }
- }
- $result['download_rule']=array(
- 'is_lecture_download'=>$is_lecture_download,
- 'is_topwb_download'=>$is_topwb_download,
- 'is_lecture_download_msg'=>$is_lecture_download_msg,
- 'is_topwb_download_msg'=>$is_topwb_download_msg,
- );
- if(isset(Yii::app()->session['session_duoxueke_subject_id'])){
- $subjectId= Yii::app()->session['session_duoxueke_subject_id'];
- }else{
- $subjectId= $this->subjectId;
- }
- if(!in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- $result['download_rule']['is_topwb_download']=0;
- $result['download_rule']['is_topwb_download_msg']='当前科目暂未上线错题前十';
- }
- $username = $this->schoolInfo->school_id;
- $password = md5($this->schoolId.Yii::app()->params['zsy_api_key']);
- $url = Yii::app()->params['zsy_api_url'].'/teacher/academic/exam/score/section/'.$this->schoolId.'/'.$exam_id;
- $rs = $this->CrmApiPost($url,$param,$username,$password,'GET');
- //debug($rs);
- if(isset($rs->errCode) && $rs->errCode =='00')
- {
- $result['success']=1;
- $result['data']=$rs->data;
- }
- exit(json_encode($result));
- }
- //读取考试班级
- public function actionGetExamClass(){
- $exam_group_id = Req::post("examGroupId");
- $is_third = Req::post("isThird");
- $result['success']=0;
- //读取考试
- $exam_group_data = ExamGroup::model()->find('exam_group_id=:exam_group_id',array(':exam_group_id'=>$exam_group_id));
- if(!$exam_group_data)
- {
- $result['msg']='未找到考试信息';
- exit(json_encode($result));
- }
- $topic_answer_upload=0;
- if($is_third){
- //判断是否上传答案、试题
- $uploadExamInfo=SThirdMultiTemplate::model()->getStatusByExamGroupId($exam_group_id);
- $uploadStatus=0;
- if($uploadExamInfo){
- if(isset($uploadExamInfo[1])){
- if($uploadExamInfo[1]['topic_upload']==1){
- $uploadStatus+=1;
- }
- }
- if(isset($uploadExamInfo[2])){
- if($uploadExamInfo[2]['answer_upload']==1){
- $uploadStatus+=3;
- }
- }
- }
- if($uploadStatus<4){
- $topic_answer_upload=0;
- }else{
- $topic_answer_upload=1;
- }
- }
- $classes=$this->schoolManager->getExportClassByExamGroupId($exam_group_id);
- $initData=array();
- $exam_id=0;
- if($classes){
- foreach ($classes as $key => $val){
- $initData['examTitle']=$val['name'];
- $temp=array('className'=>$val['class_name'],'id'=>$val['class_id']);
- $check=$this->schoolManager->classExamHasPaperRs($val['exam_id'], $val['class_id']);
- if($check && $val['status']==1) {
- $temp['excel'] = 1;
- $temp['word'] = 1;
- if ($val['is_topwb_pdf'] == 1) {
- $temp['error'] = 1;
- } else {
- $temp['error'] = 0;
- }
- if (!$is_third || $topic_answer_upload == 1) {
- $temp['teacher'] = 1;
- } else {
- $temp['teacher'] = 0;
- }
- $exam_id = $val['exam_id'];
- }elseif($check){
- $temp['excel']=1;
- $temp['word']=0;
- $temp['error']=0;
- $temp['teacher']=0;
- }else{
- $temp['excel']=0;
- $temp['word']=0;
- $temp['error']=0;
- $temp['teacher']=0;
- }
-
- $initData['class'][]=$temp;
- }
- }
- // if(!$exam_id) {
- // $result['msg']='无可下载报告班级';
- // exit(json_encode($result));
- // }
- $result['class']=$classes;
- $username = $this->schoolInfo->school_id;
- $password = md5($this->schoolId.Yii::app()->params['zsy_api_key']);
- $url = Yii::app()->params['zsy_api_url'].'/teacher/academic/exam/score/section/'.$this->schoolId.'/'.$exam_id;
- $rs = $this->CrmApiPost($url,array(),$username,$password,'GET');
- if(isset($rs->errCode) && $rs->errCode =='00')
- {
- $result['success']=1;
- $initData['scorePart']=$rs->data;
- }
- $result['success']=1;
- $result['data']=$initData;
- exit(json_encode($result));
- }
- //发送任务
- public function actionPushTask(){
- $exam_group_id = Req::post("examGroupId");
- $download_type = Req::post("download_type");
- $classes = Req::post("class_ids");
- //新字段
- $param['hasStudentNo'] = (int)Req::post("hasStudentNo"); //是否有学号
- $param['hasStudentSystemCard'] = (int)Req::post("hasStudentSystemCard"); //是否有学生系统准考证号
- $param['hasStudentSchoolCard'] = (int)Req::post("hasStudentSchoolCard"); //是否有学生学校准考证号
- $param['hasIdNumber'] = (int)Req::post("hasIdNumber"); //是否有身份证
- $param['removeOuterStudent'] = (int)Req::post("removeOuterStudent"); //是否移除借读生
- $param['removeZeroStudent'] = (int)Req::post("removeZeroStudent"); //过滤0分考生
- $param['hasClazzAchievement'] = (int)Req::post("hasClazzAchievement"); //班级成绩分析表
- $param['hasStudentAchievementRank'] = (int)Req::post("hasStudentAchievementRank"); //学生成绩排名分析表
- $param['hasGradeAchievement'] = (int)Req::post("hasGradeAchievement"); //年级成绩分析表
- $param['hasClazzAvgScore'] = (int)Req::post("hasClazzAvgScore"); //班级平均分表
- $param['hasScoreSection'] = (int)Req::post("hasScoreSection"); //班级分数段表
- $param['hasSubjectAchievement'] = (int)Req::post("hasSubjectAchievement"); //各科成绩分析表
- $param['hasWenLiZongDetail'] = (int)Req::post("hasWenLiZongDetail"); //是否有文综理综单科成绩明细报表
- $param['scoreSection'] = Req::post('scoreSection'); //总分段
- $param['isSimpleClazzAchievement'] = (int)Req::post("isSimpleClazzAchievement"); //班级学生成绩分析表(完整版:0;简易版:1,简易版不提供题目统计、答错人数、选项统计、分数段人数、缺考人数)
- $param['isSimpleClazzAvgScore'] = (int)Req::post("isSimpleClazzAvgScore"); //班级平均分表(完整版:0;简易版:1,简易版不提供题目统计)
- $param['isSimpleGradeAchievement'] = (int)Req::post("isSimpleGradeAchievement"); //年级学生成绩分析表(完整版:0;简易版:1,简易版不提供题目统计、答错人数、选项统计、分数段人数)
- $param['totalScoreCoefficient'] = Req::post("totalScoreCoefficient"); //总分系数
- $param['excellentRatio'] = Req::post('excellentRatio'); //优秀率
- $param['goodRatio'] = Req::post('goodRatio'); //良好率
- $param['mediumRatio'] = Req::post('mediumRatio'); //中等率
- $param['reportType'] = Req::post('reportType'); //中等率
- $param['showSetting'] = Req::post("scoreOfEachQuestion"); //每题得分(学生答案,学生得分)
- $param['paperSizeType'] = Req::post("paperSizeType"); //纸张设置:A4横向:1;A3纵向:2;默认1;
- $param['showRankingChanges'] = (int)Req::post("showRankingChanges"); //是否显示排名升降 显示:1;隐藏:0
- $param['totalScoreCoefficientIsRounding'] = (int)Req::post("totalScoreCoefficientIsRounding"); //启用总分系数后,是否保留小数,0整数,1保留小数
- if(!$param['paperSizeType']) $param['paperSizeType']=1;
- if($param['totalScoreCoefficient']==-1){
- unset($param['totalScoreCoefficient']);
- }
- if(!$exam_group_id){
- $result['msg']='参数错误,缺少考试ID';
- exit(json_encode($result));
- }
- $school_id =$this->schoolId;
- if(isset(Yii::app()->session['session_duoxueke_subject_id'])){
- $subjectId= Yii::app()->session['session_duoxueke_subject_id'];
- }else{
- $subjectId= $this->subjectId;
- }
- $result['status']=0;
- if(!$download_type){
- $result['msg']='请选择下载类型';
- exit(json_encode($result));
- }
- if(!$classes){
- $result['msg']='请选择下载班级';
- exit(json_encode($result));
- }
- $classIds=array();
- $classNames=array();
- if($classes){
- foreach ($classes as $val){
- $classIds[]=$val['id'];
- $classNames[]=$val['className'];
- }
- }
- $examData=$this->sConn->createCommand("select exam_id,subject_id from exam where exam_group_id='{$exam_group_id}'")->queryRow();
- $paperLabelled=$this->sConn->createCommand("select is_labelled from paper where exam_id='{$examData['exam_id']}'")->queryRow();
- if($examData['subject_id']<>12){
- $paperLabelled['is_labelled']=0; //批量下载除物理其它学科不判断标注
- }
- $insertSql="insert into download_table_setting(`school_id`,`exam_group_id`,`download_type`,`status`,`create_time`,`class_ids`,`class_names`,`update_time`,`subject_id`,`config`,`is_labelled`) values";
- $insertSql.="('".$school_id."','".$exam_group_id."','".$download_type."',1,'".time()."','".implode(',',$classIds)."','".implode(',',$classNames)."',".time().",'".$subjectId."','".json_encode($param)."','".$paperLabelled['is_labelled']."')";
- $this->conn->createCommand($insertSql)->execute();
- $last_insert_id = $this->conn->createCommand("select last_insert_id()")->queryRow();
- $taskId=$last_insert_id['last_insert_id()'];
- if($download_type==1){
- $pushData=array('id'=>$taskId);
- // $stompconn = new Stomp(Yii::app()->params["stomp_address"]);
- // $stompconn->send("academic.batchDownloadAchievementReportWord", $pushData);
- sendDataToKafka('xbkc-academic-batch-download-achievement-report-word',$pushData);
- unset($stompconn);
- }elseif ($download_type==2){
- $pushData=array('id'=>$taskId);
- // $stompconn = new Stomp(Yii::app()->params["stomp_address"]);
- // $stompconn->send("academic.batchDownloadAchievementReportExcel", $pushData);
- sendDataToKafka('xbkc-academic-batch-download-achievement-report-excel',$pushData);
- unset($stompconn);
- }
- $result['status']=1;
- exit(json_encode($result));
- }
- //下载进度
- public function actionDownloadProgress(){
- $subject_id=(int)Req::post("subjectId");
- $status=(int)Req::post("status");
- $page=(int)Req::post("page");
- if(!$page) $page=1;
- $pageLimit=10;
- $limit=($page-1)*$pageLimit;
- $result['success']=0;
- $where[]="school_id ='{$this->schoolId}'";
- if($subject_id){
- $where[]="subject_id ='{$subject_id}'";
- }
- if($status){
- $where[]="status ='{$status}'";
- }
- $count=$this->conn->createCommand("select count(*) as count from `download_table_setting` where ".implode(' and ',$where))->queryRow();
- $total=intval($count['count']);
- $pageTotal=ceil($total/$pageLimit);
- $data=$this->conn->createCommand("select id,download_type,status,class_names,zip_url,exam_group_id,class_ids,school_id,subject_id,error_msg from `download_table_setting` where ".implode(' and ',$where)." order by create_time desc limit {$limit},{$pageLimit} ")->queryAll();
- $downTask=array();
- if($data){
- foreach ($data as $val){
- //判断错题本
- if($val['download_type']==4 && !$val['zip_url']){
- $classIds=explode(',',$val['class_ids']);
- $examPdf=$this->sConn->createCommand("select is_topwb_pdf,topwb_pdf_path,name,subject_id from `exam`where exam_group_id='{$val['exam_group_id']}' and class_id in(".implode(',',$classIds).")")->queryAll();
- $files=array();
- $isAllCreate=true;
- $examName='';
- $subjectId=0;
- if($examPdf){
- foreach ($examPdf as $v){
- $examName=$v['name'];
- $subjectId=$v['subject_id'];
- if($v['is_topwb_pdf']==0){
- $isAllCreate=false;
- break;
- }
- if (filter_var(trim($v['topwb_pdf_path']), FILTER_VALIDATE_URL)) { //有http
- $top_url = $v['topwb_pdf_path'];
- }else{
- $top_url = Yii::app()->params['static_url'][$this->schoolGroupId].'/'.$v['topwb_pdf_path'];
- }
- $files[] = $top_url;
- }
- }
- if($isAllCreate){
- //生成压缩包
- $fileName='【'.Yii::app()->params['subjectId'][$subjectId].'】'.'·'.$this->schoolInfo->school_name.'·'.$examName.'·错题前十';
- $zip_url=$this->createZip($files,$fileName);
- //$zip_url=Yii::app()->request->hostInfo.'/'.$zip_url; FIXME 2019-12-23
- if($zip_url){
- $this->conn->createCommand("update `download_table_setting` set status=2,zip_url='".$zip_url."' where id='".$val['id']."'")->execute();
- $val['status']=2;
- $val['zip_url']=$zip_url;
- }
- }
- }
- if($val['download_type']==1){
- $printProductType=60003;
- }elseif($val['download_type']==3) {
- $printProductType = 20003;
- }elseif($val['download_type']==4){
- $printProductType = 10005;
- }else{
- $printProductType=60003;
- }
- if(isset($downTask[$val['exam_group_id']])){
- //组装打印参数
- $printData=array();
- $printData['typeId']=18;
- $printData['productType']=$printProductType;
- $printData['params']=array(
- 'classIds'=>explode(',',$val['class_ids']),
- 'url'=>$val['zip_url'],
- 'name'=>$downTask[$val['exam_group_id']]['examName'],
- 'subjectId'=>$val['subject_id'],
- 'examGroupId'=>$val['exam_group_id'],
- );
- $downTask[$val['exam_group_id']]['task'][]=array(
- 'downloadType'=>$val['download_type'],
- 'id'=>$val['id'],
- 'status'=>$val['status'],
- 'zipUrl'=>$val['zip_url'],
- 'class'=>explode(',',$val['class_names']),
- 'subject'=>Yii::app()->params['subjectId'][$val['subject_id']],
- 'errorMsg'=>$val['error_msg'],
- 'print'=>$printData
- );
- }else{
- //读取考试信息
- $examInfo=$this->sConn->createCommand("select `name` from `exam` where exam_group_id='{$val['exam_group_id']}'")->queryRow();
- // $downTask[$val['exam_group_id']]=array(
- // 'examName'=>$examInfo['name'],
- // 'task'=>array($val),
- // );
- //组装打印参数
- $printData=array();
- $printData['typeId']=18;
- $printData['productType']=$printProductType;
- $printData['params']=array(
- 'classIds'=>explode(',',$val['class_ids']),
- 'url'=>$val['zip_url'],
- 'name'=>$examInfo['name'],
- 'subjectId'=>$val['subject_id'],
- 'examGroupId'=>$val['exam_group_id'],
- );
- $downTask[$val['exam_group_id']]['examName']=$examInfo['name'];
- $downTask[$val['exam_group_id']]['task'][]=array(
- 'downloadType'=>$val['download_type'],
- 'id'=>$val['id'],
- 'status'=>$val['status'],
- 'zipUrl'=>$val['zip_url'],
- 'class'=>explode(',',$val['class_names']),
- 'subject'=>Yii::app()->params['subjectId'][$val['subject_id']],
- 'errorMsg'=>$val['error_msg'],
- 'print'=>$printData
- );
- }
- }
- }
- $result['success']=1;
- $result['pages']=array(
- 'totalPage'=>$pageTotal,
- 'pageLimit'=>$pageLimit,
- 'nowPage'=>$page,
- 'total'=>$total
- );
- $result['data']['listData']=array_values($downTask);
- if(isset(Yii::app()->params['subjectId']) && Yii::app()->params['subjectId']){
- $viewData['subject']=Yii::app()->params['subjectId'];
- unset($viewData['subject'][6]);
- unset($viewData['subject'][51]);
- if(isset($viewData['subject'][20])) unset($viewData['subject'][20]);
- }
- $result['subjects']=$viewData['subject'];
- $result['sessionSubjectId']= Yii::app()->session['session_duoxueke_subject_id'];
- exit(json_encode($result));
- }
- //生成压缩包
- private function createZip($files,$fileName)
- {
- $zipFileName=$fileName.'.zip';
- $dirFile='upload/tmpDir/BatchDownLoadFile/'.date('Y').'/'.date('m').'/'.date('j');
- if(!is_dir($dirFile)){
- $this->mkdir($dirFile);
- }
- $dirFile.='/'.$zipFileName;
- $zip = new ZipArchive;
- $zip->open($dirFile, ZipArchive::CREATE);
- foreach ($files as $file) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_POST, 0);
- curl_setopt($ch,CURLOPT_URL,$file);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $fileContent = curl_exec($ch);
- curl_close($ch);
- //$zip->addFromString(basename($file), $fileContent);
- $zip->addFromString( iconv('utf-8', 'gbk//ignore', basename($file)), $fileContent);//中文使用这个
- }
- $zip->close();
- if(file_exists($dirFile)){
- //FIXME 20191223
- $rename = 'zsyas2/batchDownLoadFile/'.$this->schoolId.'/'. date('Y') . '/' . date('m') . '/' . date('d').'/'. uniqid() . '/' . $zipFileName;
- $ucloud = new HuaweiCloud();
- $uploadInfo = $ucloud->putFile($rename, $dirFile);
- @unlink($dirFile);
- if ($uploadInfo['status'] == 0) {
- return false;
- }else{
- $uploadInfo['url'] = str_replace("%2F","/",$uploadInfo['url']);
- return $uploadInfo['url'];
- }
- }
- return false;
- }
- public function actionBatch(){
- ini_set('memory_limit', '500M');
- $getName = safe_replace(Yii::app()->request->getQuery('realname'));
- $grade_id = safe_replace(Yii::app()->request->getQuery('grade_id'));
- $type_id = safe_replace(Yii::app()->request->getQuery('type_id'));
- $grade_class_array = array();
- $searchProcessSubjectId=$this->subjectId;
- $con = array();
- // 打印任务处理
- $ExamModel = Exam::model();
- $ClassModel = ClassModel::model();
- $printList = array();
- $grade_class_data = ClassModel::model()->findAll('grade=:grade', array(':grade' => $grade_id));
- if ($grade_class_data) {
- foreach ($grade_class_data as $v) {
- $grade_class_array[$v->class_id] = $v->attributes;
- }
- }
- // 获取当前学期班级并组装
- $criteria = new CDbCriteria();
- $criteria->addCondition('semester_id=:semester_id');
- if ($grade_id) {
- $con = array('c.grade = ' . $grade_id);
- $criteria->addCondition('grade=:grade');
- $criteria->params[':grade'] = $grade_id;
- }
- if ($getName) {
- $con = array_merge($con, array("e.name like '%{$getName}%'"));
- }
- if(in_array($this->subjectId,$this->mathSubjectId)){
- $con = array_merge($con, array("e.subject_id in (".implode(',',$this->mathSubjectId).")"));
- $searchProcessSubjectId=3;
- }else{
- $con = array_merge($con, array('e.subject_id = ' . $this->subjectId));
- }
- $con = array_merge($con, array('eg.create_type in (0,1,2,3,5,6)'));
- if($type_id){
- if($type_id==1){
- $con =array_merge($con, array('eg.is_third = 0'));
- }elseif($type_id==2){
- $con = array_merge($con, array('eg.is_third = 1'));
- $con = array_merge($con, array('eg.mark_type > 0'));
- }else{
- $con = array_merge($con, array('eg.is_third = 1'));
- $con = array_merge($con, array('eg.mark_type =0'));
- }
- }
- $criteria->params[':semester_id'] = Yii::app()->session['session_semester_id'];
- $resultList = $this->schoolManager->getExportList(array_merge(array("(e.status = 1 or e.status=4)"), $con),array('e.complete_time desc'));
- //$resultList = $this->schoolManager->getExportList(array_merge(array("(e.status = 1 )"), $con),array('e.complete_time desc'));
- if ($resultList["rs"]) {
- foreach ($resultList['rs'] as $k => $v) {
- $printList[$k] = $v;
- //班级数量
- $examIds=$ExamModel->getExamIds($v['exam_group_id']);
- $printList[$k]['class_count']=count($examIds);
- if(isset(Yii::app()->params['grade_list'][$v['grade']])){
- $printList[$k]['grade_name']=Yii::app()->params['grade_list'][$v['grade']]['grade_name'];
- }else{
- $printList[$k]['grade_name']='';
- }
- //试卷类别
- if($v['is_third']==0){
- $printList[$k]['type_name'] = '校本课程平台试卷';
- }elseif($v['is_third']==1){
- if($v['mark_type']==0){
- $printList[$k]['type_name'] = '第三方导入成绩试卷';
- }else{
- $printList[$k]['type_name'] = '第三方线上阅卷试卷';
- }
- }
- //考试日期
- $tplData=json_decode($v['tpl_data'],true);
- if(isset($tplData['examDate'])){
- $printList[$k]['exam_date'] =$tplData['examDate'];
- }else{
- $printList[$k]['exam_date'] ='';
- }
- //试题数量
- if(isset($tplData['totals'])){
- $printList[$k]['topic_count'] =$tplData['totals'];
- }else{
- $printList[$k]['topic_count'] =0;
- }
- }
- }
- $data = array();
- // $subject_exam_data = $this->schoolManager->getxuekeStatus($this->semesterId);
- $data['realname'] = $getName;
- $data['grade_id'] = $grade_id;
- $data['grade_class'] = $grade_class_array;
- $data['printList'] = $printList;
- $data['pages'] = $resultList['pager'];
- $data['page_total'] = $resultList['pager']->rowsCount;
- //$data["subject"] = $subject_exam_data;
- $data['searchProcessSubjectId']=$searchProcessSubjectId;
- if (isset($this->schoolInfo->use_zhixue) && !empty($this->schoolInfo->use_zhixue)) {
- $data["use_zhixue"] = $this->schoolInfo->use_zhixue;
- } else {
- $data["use_zhixue"] = 0;
- }
- $data['past_sem_exist'] = 0;//默认不存在过去的学期
- $data['type_id']=$type_id;
- $sql = 'select start_time from semester where status=1 limit 1';
- $res = $this->sConn->createCommand($sql)->queryRow();
- $start_time = $res['start_time'];
- if (!$start_time) {
- Yii::app()->jump->error('该学校无当前学期,请检查学期是否设置错误');
- }
- $sql = 'select count(*) as rownum from semester where status=0 and start_time < '.$start_time;
- $res = $this->sConn->createCommand($sql)->queryRow();
- $row_num = $res['rownum'];
- $row_num && $data['past_sem_exist']=1;
- unset($resultList);
-
- $this->render('index2', $data);
- }
- public function actionBatch_duo(){
- ini_set('memory_limit', '300M');
- $getName = safe_replace(Yii::app()->request->getQuery('realname'));
- $grade_id = safe_replace(Yii::app()->request->getQuery('grade_id'));
- $type_id = safe_replace(Yii::app()->request->getQuery('type_id'));
- $grade_class_array = array();
- $searchProcessSubjectId=Yii::app()->session['session_duoxueke_subject_id'];
- $con = array();
- // 打印任务处理
- $ExamModel = Exam::model();
- $ClassModel = ClassModel::model();
- $printList = array();
- $grade_class_data = ClassModel::model()->findAll('grade=:grade', array(':grade' => $grade_id));
- if ($grade_class_data) {
- foreach ($grade_class_data as $v) {
- $grade_class_array[$v->class_id] = $v->attributes;
- }
- }
- // 获取当前学期班级并组装
- $criteria = new CDbCriteria();
- $criteria->addCondition('semester_id=:semester_id');
- if ($grade_id) {
- $con = array('c.grade = ' . $grade_id);
- $criteria->addCondition('grade=:grade');
- $criteria->params[':grade'] = $grade_id;
- }
- if ($getName) {
- $con = array_merge($con, array("e.name like '%{$getName}%'"));
- }
- if(in_array(Yii::app()->session['session_duoxueke_subject_id'],$this->mathSubjectId)){
- $con = array_merge($con, array("e.subject_id in (".implode(',',$this->mathSubjectId).")"));
- $searchProcessSubjectId=3;
- }else{
- $con = array_merge($con, array('e.subject_id = ' . Yii::app()->session['session_duoxueke_subject_id']));
- }
-
- $con = array_merge($con, array('eg.create_type in (0,1,2,3,5,6)'));
- if($type_id){
- if($type_id==1){
- $con =array_merge($con, array('eg.is_third = 0'));
- }elseif($type_id==2){
- $con = array_merge($con, array('eg.is_third = 1'));
- $con = array_merge($con, array('eg.mark_type > 0'));
- }else{
- $con = array_merge($con, array('eg.is_third = 1'));
- $con = array_merge($con, array('eg.mark_type =0'));
- }
- }
- //如果是物理去掉全学科的组卷
- if($searchProcessSubjectId == 12){
- // $con = array_merge($con, array('(eg.qxk_paper_id is null or eg.qxk_paper_id=0)'));
- }
-
- $criteria->params[':semester_id'] = Yii::app()->session['session_semester_id'];
-
- $resultList = $this->schoolManager->getExportList(array_merge(array("(e.status = 1 or e.status=4)"), $con),array('e.complete_time desc'));
- //$resultList = $this->schoolManager->getExportList(array_merge(array("(e.status = 1)"), $con),array('e.complete_time desc'));
- if ($resultList["rs"]) {
- foreach ($resultList['rs'] as $k => $v) {
- $printList[$k] = $v;
- //班级数量
- $examIds=$ExamModel->getExamIds($v['exam_group_id']);
- $printList[$k]['class_count']=count($examIds);
- if(isset(Yii::app()->params['grade_list'][$v['grade']])){
- $printList[$k]['grade_name']=Yii::app()->params['grade_list'][$v['grade']]['grade_name'];
- }else{
- $printList[$k]['grade_name']='';
- }
- //试卷类别
- if($v['is_third']==0){
- $printList[$k]['type_name'] = '校本课程平台试卷';
- }elseif($v['is_third']==1){
- if($v['mark_type']==0){
- $printList[$k]['type_name'] = '第三方导入成绩试卷';
- }else{
- $printList[$k]['type_name'] = '第三方线上阅卷试卷';
- }
- }
- //考试日期
- $tplData=json_decode($v['tpl_data'],true);
- if(isset($tplData['examDate'])){
- $printList[$k]['exam_date'] =$tplData['examDate'];
- }else{
- $printList[$k]['exam_date'] ='';
- }
- //试题数量
- if(isset($tplData['totals'])){
- $printList[$k]['topic_count'] =$tplData['totals'];
- }else{
- $printList[$k]['topic_count'] =0;
- }
- }
- }
- // debug($printList);
- $data = array();
- // $subject_exam_data = $this->schoolManager->getxuekeStatus($this->semesterId);
- $data['realname'] = $getName;
- $data['grade_id'] = $grade_id;
- $data['grade_class'] = $grade_class_array;
- $data['printList'] = $printList;
- $data['pages'] = $resultList['pager'];
- $data['page_total'] = $resultList['pager']->rowsCount;
- // $data["subject"] = $subject_exam_data;
- $data['searchProcessSubjectId']=$searchProcessSubjectId;
- if (isset($this->schoolInfo->use_zhixue) && !empty($this->schoolInfo->use_zhixue)) {
- $data["use_zhixue"] = $this->schoolInfo->use_zhixue;
- } else {
- $data["use_zhixue"] = 0;
- }
- $data['past_sem_exist'] = 0;//默认不存在过去的学期
- $data['type_id']=$type_id;
- $sql = 'select start_time from semester where status=1 limit 1';
- $res = $this->sConn->createCommand($sql)->queryRow();
- $start_time = $res['start_time'];
- if (!$start_time) {
- Yii::app()->jump->error('该学校无当前学期,请检查学期是否设置错误');
- }
- $sql = 'select count(*) as rownum from semester where status=0 and start_time < '.$start_time;
- $res = $this->sConn->createCommand($sql)->queryRow();
- $row_num = $res['rownum'];
- $row_num && $data['past_sem_exist']=1;
- unset($resultList);
- // debug($data);
- $this->render('index2_duo', $data);
- }
- //删除任务
- public function actionDeleteTask(){
- $ids = Req::post("ids");
- $result['success']=0;
- if(!$ids){
- $result['msg']='请选择删除的任务';
- exit(json_encode($result));
- }
- $rs=$this->conn->createCommand("delete from download_table_setting where id in(".implode(',',$ids).") ")->execute();
- if($rs){
- $result['success']=1;
- exit(json_encode($result));
- }
- }
- private function mkdir($path, $chmod = 0755){
- return is_dir($path) || (self::mkdir(dirname($path), $chmod) && mkdir($path, $chmod));
- }
-
- /**
- * 发送消息队列
- * @return mixed
- */
- private function sendKafka($topic='',$data = array())
- {
- if ($data) {
- $conf = new RdKafka\Conf();
- $conf->set('metadata.broker.list', Yii::app()->params['kafka']);
- $producer = new RdKafka\Producer($conf);
- $topic = $producer->newTopic($topic);
- $topic->produce(RD_KAFKA_PARTITION_UA, 0, json_encode($data));
- $producer->poll(0);
- $result = $producer->flush(10000);
- if($result===0){
- return true;
- }
- // $destination = 'zsyte.markingFinishedNotify';
- //
- // $stomp_address = Yii::app()->params['markingFinishedNotifyAddress'];
- //
- // $stomp = new Stomp($stomp_address);
- // $stomp->subscribe($destination);
- //
- //// $data = array('schoolId'=>123,'examGroupId'=>45679794,'examIds'=>array('54646465'));
- //
- // $bool = $stomp->send($destination, json_encode($data));
- }
- return true;
- }
- /*
- * 假期报告
- */
- public function actionHoliday_index(){
- Url::clean();
- $data = array();
- $classId = Req::get("classId");
- $grade = (int)Req::get("grade");
- $semsterId = (string)Req::get("semesterId");
- $limit = (int)Req::get("limit") ? (int)Req::get("limit") :10;
- $newCondition = array();
- $schoolId = $this->schoolId;
- if($grade){
- $newCondition[] = 'hrs.grade='.$grade;
- }
- if($classId){
- $newCondition[] = 'hrs.class_id='.$classId;
- }
- if(!$semsterId){
- $semsterId = $this->semesterId;
- }
- if($semsterId){
- $newCondition[] = 'hrs.semester_id='.$semsterId;
- }
- $resultList = $this->schoolManager->getHolidayReport($newCondition,array('hrs.create_time desc','hrs.report_id desc'),$limit);
- $printList = array();
- if($resultList["rs"]){
- foreach ($resultList['rs'] as $k=>$v) {
- $printList[$k]=$v;
- }
- }
- if (empty($grade)) {
- $grade = 'ALL';
- }
- // $classes = $this->schoolManager->getClasses($grade);
- //获取全学科试用学校
- $url = Yii::app()->params['zsy_api_url'].'/cms/api/qxk-math-trial-school/'.$this->schoolId;
- $username = $this->schoolInfo->school_id;
- $password = md5($this->schoolId.Yii::app()->params['zsy_api_key']);
- $rs = $this->CrmApiPost($url,array(),$username,$password,'GET');
- $is_qxk_school = (isset($rs->errCode) && $rs->errCode =='00')?$rs->data:false;//是否全学科试用学校---true是全学科--全学科走新的redis的key
- $mkey = $is_qxk_school?"qxk_holiday_school_semester":"holiday_school_semester";
- $semsters = $this->schoolManager->getSemesters();
- $sql = "select report_id from holiday_report_setting where semester_id= '{$semsterId}'";
- $res = $this->sConn->createCommand($sql)->queryRow();
- if(!$res){
- if((string)$semsterId === (string)$this->semesterId){
- $is_current_semester = 1;
- }else{
- $is_current_semester = 0;
- }
- $status = $this->schoolManager->batchInsetHolidayReport($schoolId,$semsterId,$is_current_semester,$is_qxk_school);
- if(isset($status["status"]) && $status["status"] == 1){
- /**
- * 发送redis开始跑数据
- */
- // $holiday_status = Yii::app()->holiday_report->hmget('holiday_school_semester',array($schoolId.':'.$semsterId));
- // if($holiday_status && isset($holiday_status[0]) && $holiday_status[0]){
- Yii::app()->holiday_report->hmset($mkey,array($schoolId.':'.$semsterId=>0));
- // }
- $resultList = $this->schoolManager->getHolidayReport($newCondition,array('hrs.create_time desc','hrs.report_id desc'),$limit);
- $printList = array();
- if($resultList["rs"]){
- foreach ($resultList['rs'] as $k=>$v) {
- $printList[$k]=$v;
- }
- }
- }
- }
- // debug($resultList);
- if(isset($resultList) && $resultList){
- $data['is_all_pdf'] = isset($resultList['is_all_pdf'])?$resultList['is_all_pdf']:0;
- $data['create_time'] = isset($resultList['create_time'])?$resultList['create_time']:0;
- }
- $class_select_arr = array();
- if($semsterId){
- $class_select_arr[] = "hrs.semester_id=".$semsterId;
- }
- if(in_array($grade,array(1,2,3))){
- $class_select_arr[] = "c.grade=".$grade;
- }
- // $class_select_arr[] = "c.class_type=1";
- $classes = $this->schoolManager->getClassesByHolidayReport($class_select_arr,array());
- $data['limit'] = $limit;
- $data['pages'] = $resultList['pager'];
- $data['page_total'] = $resultList['pager']->rowsCount;
- $data['printList'] = $printList;
- $data["classes"] = $classes;
- $data["classId"] = $classId;
- $data["grade"] = $grade;
- $data["semsterId"] = $semsterId;
- $data["semsters"] = $semsters;
- //数据生成状态
- $data['data_status'] = 0;
- $data_status_arr = Yii::app()->holiday_report->hmget($mkey,array($schoolId.':'.$semsterId));
- if($data_status_arr && isset($data_status_arr[0]) && $data_status_arr[0]){
- $data['data_status'] = $data_status_arr[0];
- }
- //批量重置数量
- $holiday_school_semester = Yii::app()->add_exam_class->hmget('zsyas2:holiday_school_reset',array($this->schoolId.'_'.$semsterId));
- if($holiday_school_semester && $holiday_school_semester[0]){
- $data['reset_time'] = $holiday_school_semester[0];
- }else{
- $data['reset_time'] = 0;
- }
- $this->render('holiday_index',$data);
- }
-
- /**
- * 假期报告设置
- */
- public function actionAjaxSettingHolidayReport(){
- $semesterId = $this->semesterId;
- $schoolId = $this->schoolId;
- $report_ids = getBatchUuid($schoolId,100);
- debug(array_values($report_ids));
- $status = $this->schoolManager->batchInsetHolidayReport($schoolId,$semesterId);
- }
-
- /**
- * 假期报告选择学生
- */
- public function actionSelectStuByHolidayReport(){
- $data = array();
- $sname = (string)Req::get("sname"); //学生名字
- $reportId = (string)Req::get("reportId");
- if(!$reportId){
- Yii::app()->jump->error('参数错误!');
- }
- //获取班级名称以及周后推送名称
- $sql = "select c.class_name,hrs.grade,hrs.class_id,hrs.create_time,hrs.semester_id,s.semester_name from holiday_report_setting hrs join class c on hrs.class_id = c.class_id join semester s on s.semester_id = hrs.semester_id where hrs.report_id = '{$reportId}'";
- $names = $this->sConn->createCommand($sql)->queryRow();
- // debug($names);
- if(!$names){
- $names = array();
- $names['name'] = '';
- $names['class_name'] = '';
- $names['grade'] = 0;
- }else{
- $data['name'] = $names['semester_name'].'假期总结报告'.'---'.$names['class_name'];
- }
- $sql = "select student_id,is_report_pdf from holiday_report_student where report_id = '{$reportId}'";
- $relateStudent = $this->sConn->createCommand($sql)->queryAll();
- $studentIds = array();
- $stuIsPdf = array();
- if($relateStudent){
- foreach ($relateStudent as $studentInfo) {
- $studentIds[] = (string)$studentInfo['student_id'];
- $stuIsPdf[(string)$studentInfo['student_id']] = $studentInfo['is_report_pdf'];
- }
- }
- if($studentIds){
- $studentNames = SStudentInfo::model()->getStudentNames($studentIds); //求学生名字
- if($studentNames){
- if($sname){
- $i = 1;
- foreach($studentNames as $k=>$v){
- if(strpos($v,$sname) !== false){
- $data['list'][$i]['stu_id'] = (string)$k;
- $data['list'][$i]['stu_name'] = $v;
- $data['list'][$i]['name'] = $names['class_name'].$v.'假期报告';
- $data['list'][$i]['is_pdf'] = isset($stuIsPdf[(string)$k])?$stuIsPdf[(string)$k]:0;
- $i++;
- }
- }
- }else{
- $i = 1;
- foreach($studentNames as $k=>$v){
- $data['list'][$i]['stu_id'] = (string)$k;
- $data['list'][$i]['stu_name'] = $v;
- $data['list'][$i]['name'] = $names['class_name'].$v.'假期报告';
- $data['list'][$i]['is_pdf'] = isset($stuIsPdf[(string)$k])?$stuIsPdf[(string)$k]:0;
- $i++;
- }
- }
- }
-
- $intarr=array(
- "subject"=>3,
- "grade"=>$names['grade'],
- "examTime"=>$names['create_time'],
- "students"=>$studentIds,
- );
- //暂时去掉验证订单权限
- $data['limitstu']=$studentIds;
- /*
- $basic = imsBasicAuth($this->schoolId.'_'.Yii::app()->session['coachInfo']['coach_name'],Yii::app()->params["zsy_api_key"]);
- $rs = json_decode(Curl::http_post_Basic_json(Yii::app()->params["get_all_limit_url_gather"], json_encode($intarr),$basic),true);
- if(!$rs){
- Yii::app()->jump->error("接口错误");
- }
- if($rs['errCode']!="00"){
- Yii::app()->jump->error($rs['errMsg']);
- }
- if(!empty($rs['data'])){
- $data['limitstu']=$rs['data'];
- }*/
- }
- $data['reportId'] = $reportId;
- $data['sname'] = $sname;
- // debug($data);
- $this->render('holiday_report_stu',$data);
- }
-
- /**
- * 下载假期报告
- */
- public function actionGetHolidayReportFile(){
- $reportId = (string)Req::get("reportId");
- $studentsIds = (string)Req::get("studentsIds");
- $params = array();
- if(!$reportId){
- echo json_encode(array("success" => 0, "message" => "缺少参数"));
- exit();
- }
- //获取组ID
- $sql = "select school_group_id,semester_id from holiday_report_setting where report_id = '{$reportId}'";
- $report_settint_data = $this->sConn->createCommand($sql)->queryRow();
- if(!$report_settint_data){
- echo json_encode(array("success" => 0, "message" => "设置信息错误"));
- exit();
- }else{
- $school_group_id = $report_settint_data['school_group_id'];
- }
- if(isset($school_group_id) && $school_group_id){
- $apiUrl = isset(Yii::app()->params["improve_url"][$school_group_id]) ? Yii::app()->params["improve_url"][$school_group_id] : null;
- }else{
- $apiUrl = isset(Yii::app()->params["improve_url"][$this->schoolGroupId]) ? Yii::app()->params["improve_url"][$this->schoolGroupId] : null;
- }
- if(!$studentsIds){
- $studentsIds = array();
- $sql = "select student_id from holiday_report_student where report_id = '{$reportId}' and is_report_pdf = 1";
- $stuArr = $this->sConn->createCommand($sql)->queryAll();
- if($stuArr){
- foreach($stuArr as $k=>$v){
- $studentsIds[] = $v['student_id'];
- }
- }
- }else{
- $studentsIds = explode(',',$studentsIds);
- }
- if(!$studentsIds || empty($studentsIds)){
- echo json_encode(array("success" => 0, "message" => "无生成的学生"));
- exit();
- }
- $params['reportId'] = $reportId;
- // $apiUrl = isset(Yii::app()->params["improve_url"][$this->schoolGroupId]) ? Yii::app()->params["improve_url"][$this->schoolGroupId] : null;
- if(!$apiUrl){
- echo json_encode(array("success" => 0, "message" => "接口配置信息错误"));
- exit();
- }
- $sql = "select class_id,grade,create_time,semester_id from holiday_report_setting where report_id = '{$reportId}'";
- $msg = $this->sConn->createCommand($sql)->queryRow();
- $Sem=new SSemester();
- $code= $Sem->conn->createQuery()
- ->from('semester')
- ->where("semester_id = '".$msg['semester_id']."'")
- ->limit(1)
- ->query()
- ->read();
- $intarr=array(
- "schoolId"=>$this->schoolId,
- "clazzId"=>$msg['class_id'],
- "semester"=>$code['refer_code'],
- "grade"=>$msg['grade'],
- "students"=>$studentsIds,
- "examTime"=>$msg['create_time'],
- "classify"=>6,
- "subject"=>8
- );
- $schoolInfo = BusinessSchool::model()->find('school_id=:school_id', array(':school_id' => $this->schoolId));
- if(isset($schoolInfo['is_allow_download']) && ($schoolInfo['is_allow_download']==1)){
- if($studentsIds){
- $params["studentIds"] = $studentsIds;
- }
- }else{
- if(Yii::app()->params["limit_open"]){
- // $basic = imsBasicAuth($this->schoolId.'_'.Yii::app()->session['coachInfo']['coach_name'],Yii::app()->params["zsy_api_key"]);
- // $rs = json_decode(Curl::http_post_Basic_json(Yii::app()->params["get_limit_url"], json_encode($intarr),$basic));
- $intarr=array(
- "subject"=>3,
- "grade"=>$msg['grade'],
- "examTime"=>$msg['create_time'],
- "students"=>$studentsIds,
- );
- $basic = imsBasicAuth($this->schoolId.'_'.Yii::app()->session['coachInfo']['coach_name'],Yii::app()->params["zsy_api_key"]);
- $rs = json_decode(Curl::http_post_Basic_json(Yii::app()->params["get_all_limit_url_gather"], json_encode($intarr),$basic),true);
- if(!$rs){
- Yii::app()->jump->error("接口错误");
- }
- if($rs['errCode']!="00"){
- echo json_encode(array("success" => 0, "message" => $rs['errMsg']));
- exit();
- }
- if(!empty($rs['data'])){
- $params["studentIds"]=$rs['data'];
- if(count($rs['data'])<count($intarr['students'])){
- $limitinfo="购买过的".count($intarr['students'])-count($rs['data'])."位学生可下载";
- }
- } else{
- echo json_encode(array("success" => 0, "message" =>"请先购买商品"));
- exit();
- }
- }else{
- if($studentsIds){
- $params["studentIds"] = $studentsIds;
- }
- }
- }
- $params['schoolId'] = $this->schoolId;
- $params['type'] = 4;
- // $apiUrl = "http://zsyapi.testing.xueping.com";
- $rs = Curl::post($apiUrl."/rest/download_week_pdf/index", $params);
- if(!($rs = json_decode($rs))){
- $rs = array(
- "success" => 0,
- "message" => "请求接口失败",
- );
- }else{
- //更新下载时间
- $time = time();
- if($studentsIds){
- $sql = "update holiday_report_student set is_report_download = 1,report_download_time={$time} where report_id = '{$reportId}' and student_id in (".implode(',',$studentsIds).") and report_download_time = 0";
- $this->sConn->createCommand($sql)->execute();
- }
- }
- // if(isset($rs->downloadPath)){
- // if (YII_ENV == 'pro' || YII_ENV == 'production') {
- // $rs->downloadPath = preg_replace('/http\:\/\/zstatic\d{1,2}/','http://zstatic'.$groupId,$rs->downloadPath);
- // }
- // }
- echo json_encode($rs);exit;
- }
-
- /**
- * 重置假期报告
- */
- public function actionAjaxResetHolidayReport(){
- $reportId = Req::post('report_id');
- $classId = Req::post('class_id');
- $semsterId = Req::post('semster_id');
- $schoolId = $this->schoolId;
- if(!$reportId){
- echo json_encode(array("status"=>0,"result"=>"假期报告ID不能为空"));exit;
- }
- if(!$classId){
- echo json_encode(array("status"=>0,"result"=>"班级ID不能为空"));exit;
- }
- if(!$semsterId){
- echo json_encode(array("status"=>0,"result"=>"学期ID不能为空"));exit;
- }
- if((string)$semsterId === (string)$this->semesterId){
- $is_current_semester = 1;
- }else{
- $is_current_semester = 0;
- }
- //获取全学科试用学校
- $url = Yii::app()->params['zsy_api_url'].'/cms/api/qxk-math-trial-school/'.$this->schoolId;
- $username = $this->schoolInfo->school_id;
- $password = md5($this->schoolId.Yii::app()->params['zsy_api_key']);
- $rs = $this->CrmApiPost($url,array(),$username,$password,'GET');
- $is_qxk_school = (isset($rs->errCode) && $rs->errCode =='00')?$rs->data:false;//是否全学科试用学校---true是全学科--全学科走新的redis的key
- $mkey = $is_qxk_school?"qxk_holiday_school_semester":"holiday_school_semester";
- $status = $this->schoolManager->resetReport($reportId,$classId,$is_current_semester,$is_qxk_school);
- Yii::app()->holiday_report->hmset($mkey,array($schoolId.':'.$semsterId=>0));
- if($status){
- echo json_encode(array("status"=>1,"result"=>"重置成功"));exit;
- }else{
- echo json_encode(array("status"=>0,"result"=>"重置失败"));exit;
- }
-
-
- }
-
-
- /**
- * 批量下载假期报告
- */
- public function actionAjaxBatchPrintHoliday(){
-
-
-
- }
-
- /**
- * 批量重置假期报告
- */
- public function actionAjaxBatchResetHoliday(){
- $semesterId = Req::post("semster_id");
- if(!$semesterId){
- echo json_encode(array("status"=>0,"result"=>"请指定学期Id"));exit;
- }
- // echo $semesterId;exit;
- $school_id = $this->schoolId;
- $holiday_school_semester = Yii::app()->add_exam_class->hmget('zsyas2:holiday_school_reset',array($school_id.'_'.$semesterId));
- if($holiday_school_semester && $holiday_school_semester[0]){
- $reset_time = $holiday_school_semester[0];
- }else{
- $reset_time = 0;
- }
- if($reset_time > 4){
- echo json_encode(array("status"=>0,"result"=>"重置次数不能超过5次"));exit;
- }
- //获取全学科试用学校
- $url = Yii::app()->params['zsy_api_url'].'/cms/api/qxk-math-trial-school/'.$this->schoolId;
- $username = $this->schoolInfo->school_id;
- $password = md5($this->schoolId.Yii::app()->params['zsy_api_key']);
- $rs = $this->CrmApiPost($url,array(),$username,$password,'GET');
- $is_qxk_school = (isset($rs->errCode) && $rs->errCode =='00')?$rs->data:false;//是否全学科试用学校---true是全学科--全学科走新的redis的key
- $status = $this->schoolManager->batchResetReport($semesterId);
- $mkey = $is_qxk_school?"qxk_holiday_school_semester":"holiday_school_semester";
- Yii::app()->holiday_report->hmset($mkey,array($school_id.':'.$semesterId=>0));
- if($status){
- $holiday_school_semester = Yii::app()->add_exam_class->hmset('zsyas2:holiday_school_reset',array($school_id.'_'.$semesterId=>$reset_time+1));
- echo json_encode(array("status"=>1,"result"=>"批量重置成功"));exit;
- }else{
- echo json_encode(array("status"=>0,"result"=>"批量重置失败"));exit;
- }
- }
-
- function curlDownloadImage($url)
- {
- if (empty($url)) {
- return false;
- }
- $curl = curl_init($url);
- // 不取回数据
- curl_setopt($curl, CURLOPT_NOBODY, true);
- // 发送请求
- $result = curl_exec($curl);
- $found = false;
- // 如果请求没有发送失败
- if ($result !== false) {
- // 再检查http响应码是否为200
- $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
- if ($statusCode == 200) {
- $found = true;
- }
- }
- curl_close($curl);
- return $found;
-
- }
-
- function curlDownload($url,$title)
- {
- if (empty($url) || empty($title)) {
- return false;
- }
- $ext=substr($url,strrpos($url,'.')+1);
- $path='upload/tmpDir/downloadTempFiled/';
- if (!file_exists($path)) {
- mkdir($path, 0777, true);
- }
- $pathName=$path.$title.'.'.$ext;
- $pathName = iconv('UTF-8', 'GBK', $pathName);
- // 获取远程文件资源
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
- $tempFile = curl_exec($ch);
- curl_close($ch);
- // 保存文件
- $fp = @fopen($pathName, "w");
- fwrite($fp, $tempFile);
- fclose($fp);
- header('content-type:application/octet-stream');
- header('content-disposition:attachment; filename='.$title.'.'.$ext);
- header('content-length:'.filesize($pathName));
- readfile($pathName);
- }
-
- /**
- * 教师讲案高考真题
- * @exam_id 考试ID
- * @class_id 班级ID
- * @has_topic 教师讲案其他题集合
- * @weak_methodids 共性题考点
- * @paper_methodids 试卷考点
- */
- function acadGaokao($exam_id,$class_id,$has_topic,$weak_methodids,$paper_methodids){
- //最终抽出来的题
- $final_topic = array();
-
- if(!$weak_methodids){
- return $final_topic;
- }else{
- $topic_data = $this->aipost('/relation_math/true_topic', array('methodIds' => $weak_methodids));
- if($topic_data && isset($topic_data['data']) && $topic_data['data']){
- $topic_pool = $topic_data['data'];
- }else{
- return $final_topic;
- }
- }
-
-
- //step1 过滤已经存在的题
- if($has_topic){
- foreach($topic_pool as $k=>$v){
- if(in_array($k,$has_topic)){
- unset($topic_pool[$k]);
- }
- }
- }
- //step2 过滤超纲的题
- if($paper_methodids){
- foreach($topic_pool as $k=>$v){
- foreach($v as $method){
- if(!in_array($method,$paper_methodids)){
- unset($topic_pool[$k]);
- continue;
- }
- }
- }
- }
- //step3 优先抽全部薄弱考点的题,如果题不够,逐一减少薄弱考点,直到抽到2题为止 $weak_methodids(薄弱考点)
- if($topic_pool){
- //整理数据
- $topic_methods_count = array();//题目对应薄弱考点数量
- $count_to_topic = array();//薄弱考点数量对应题目
- foreach($topic_pool as $k=>$v){
- foreach($v as $method){
- if(in_array($method,$weak_methodids)){
- if(!isset($topic_methods_count[$k])){
- $topic_methods_count[$k] = 1;
- }else{
- $topic_methods_count[$k] ++;
- }
- }
- }
- }
- if($topic_methods_count){
- foreach($topic_methods_count as $k=>$v){
- for($a=1;$a<=$v;$a++){
- if(!isset($count_to_topic[$a])){
- $count_to_topic[$a] = array();
- }
- $count_to_topic[$a][] = $k;
- }
- }
- }
- if($count_to_topic){
- krsort($count_to_topic);//根据薄弱考点数量倒序
- foreach($count_to_topic as $k=>$v){
-
- foreach($v as $topic_id){
- if(count($final_topic) > 1){
- break;
- }
- if(!in_array($topic_id,$final_topic)){
- $final_topic[] = $topic_id;
- }
- }
- }
- }
- }
- //过滤完没题就随机抽两题
- if(!$final_topic || count($final_topic) < 2){
- $topic_keys = array_keys($topic_pool);
- shuffle($topic_keys);
- foreach($topic_keys as $k=>$v){
- if(count($final_topic) > 1){
- break;
- }
- if(!in_array($v,$final_topic)){
- $final_topic[] = $v;
- }
- }
- }
-
- //插入数据
- if($final_topic){
- $delSql = "delete from gaokao_academicr_topic where exam_id = '".$exam_id."'";
- $insertSql="insert into gaokao_academicr_topic (`exam_id`,`class_id`,`topic_id`,`create_time`) values";
- $insertSqlStr = "";
- foreach($final_topic as $k=>$v){
- $insertSqlStr.="('".$exam_id."','".$class_id."','".$v."','".time()."'),";
- }
- $insertSql .= substr($insertSqlStr, 0, -1);
- $this->sConn->createCommand($delSql)->execute();
- $this->sConn->createCommand($insertSql)->execute();
- }
- return $final_topic;
- }
-
- /**
- * 教师假期报告设置
- */
- public function actionHoliday_teacher_index(){
- Url::clean();
- $data = array();
- $semsterId = (string)Req::get("semesterId");
- $teacher_name = (string)Req::get("teacher_name");
- $limit = (int)Req::get("limit") ? (int)Req::get("limit") :10;
- $newCondition = array();
- $schoolId = $this->schoolId;
- if(!$semsterId){
- $semsterId = $this->semesterId;
- }
- if($semsterId){
- $newCondition[] = "htrs.semester_id='$semsterId'";
- }
- if($teacher_name){
- $newCondition[] = "t.teacher_name='$teacher_name'";
- }
- $resultList = $this->schoolManager->getTeacherHolidayReport($newCondition,array('htrs.create_time desc','htrs.report_id desc'),$limit);
- $printList = array();
- if($resultList["rs"]){
- foreach ($resultList['rs'] as $k=>$v) {
- $printList[$k]=$v;
- }
- }
- $sql = "select report_id from holiday_teacher_report_setting where semester_id= '{$semsterId}'";
- $res = $this->sConn->createCommand($sql)->queryRow();
- if(!$res){
- $status = $this->schoolManager->batchInsetHolidayTeacherReport($schoolId,$semsterId,1);
- if(isset($status["status"]) && $status["status"] == 1){
- $resultList = $this->schoolManager->getTeacherHolidayReport($newCondition,array('htrs.create_time desc','htrs.report_id desc'),$limit);
- $printList = array();
- if($resultList["rs"]){
- foreach ($resultList['rs'] as $k=>$v) {
- $printList[$k]=$v;
- }
- }
- }
- }else{
- //验证有无新老师
- $this->schoolManager->batchInsetHolidayTeacherReport($schoolId,$semsterId,2);
-
- }
- $semsters = $this->schoolManager->getSemesters();
-
- $data['limit'] = $limit;
- $data['pages'] = $resultList['pager'];
- $data['page_total'] = $resultList['pager']->rowsCount;
- $data['printList'] = $printList;
- $data["semsterId"] = $semsterId;
- $data["semsters"] = $semsters;
- $data["teacher_name"] = $teacher_name;
- // debug($data);
- $this->render('holiday_teacher_index',$data);
-
- }
-
- /**
- * 重置教师假期报告
- */
- public function actionAjaxResetHolidayTeacherReport(){
- $reportId = Req::post('report_id');
- $teacherId = Req::post('teacher_id');
- $semsterId = Req::post('semster_id');
- $schoolId = $this->schoolId;
- if(!$reportId){
- echo json_encode(array("status"=>0,"result"=>"假期报告ID不能为空"));exit;
- }
- if(!$teacherId){
- echo json_encode(array("status"=>0,"result"=>"教师ID不能为空"));exit;
- }
- if(!$semsterId){
- echo json_encode(array("status"=>0,"result"=>"学期ID不能为空"));exit;
- }
-
- $status = $this->schoolManager->resetTeacherReport($reportId,$teacherId,$semsterId);
- if($status){
- echo json_encode(array("status"=>1,"result"=>"重置成功"));exit;
- }else{
- echo json_encode(array("status"=>0,"result"=>"重置失败"));exit;
- }
-
-
- }
-
- /**
- * 批量重置教师假期报告
- */
- public function actionAjaxBatchResetHolidayTeacher(){
- $semesterId = Req::post("semster_id");
- if(!$semesterId){
- echo json_encode(array("status"=>0,"result"=>"请指定学期Id"));exit;
- }
- $school_id = $this->schoolId;
-
- $status = $this->schoolManager->batchResetTeacherReport($semesterId);
- if($status){
- echo json_encode(array("status"=>1,"result"=>"批量重置成功"));exit;
- }else{
- echo json_encode(array("status"=>0,"result"=>"批量重置失败"));exit;
- }
- }
-
- /**
- * 获取订单
- */
- function getOrderStu($eid, $cid, $typeVal,$relateStudentRes,$semesterId, $grade)
- {
- $data = array();
- $Sem=new SSemester();
- $code= $Sem->conn->createQuery()
- ->from('semester')
- ->where("semester_id = '".$this->semesterId."'")
- ->limit(1)
- ->query()
- ->read();
- $examInfo = Exam::model()->findByPk($eid);
- $print_time=ClassExamPrinter::model()->findAll('exam_id=:exam_id and class_id=:classid and type=0',array(':exam_id'=>$eid,':classid'=>$cid));
- if($print_time && $print_time[0]->add_time){
- $exam_time = $print_time[0]->add_time;
- }else{
- $exam_time = $examInfo['create_time'];
- }
- $intarr=array(
- "schoolId"=>$this->schoolId,
- "clazzId"=>$cid,
- "semester"=>$code['refer_code'],
- "grade"=>$grade,
- "examTime"=>$exam_time,
- "students"=>array(),
- "classify"=>$typeVal,
- );
-
- $intarr['subject']=$examInfo['subject_id'];
- if(in_array($intarr['subject'],$this->mathSubjectId)){
- $intarr['subject']=3;
- }
- foreach($relateStudentRes as $key => $val){
- $intarr['students'][] = $val['student_id'];
- }
- $basic = imsBasicAuth($this->schoolId.'_'.Yii::app()->session['coachInfo']['coach_name'],Yii::app()->params["zsy_api_key"]);
- $rs = json_decode(Curl::http_post_Basic_json(Yii::app()->params["get_limit_url"], json_encode($intarr),$basic));
- if(!$rs){
- //Yii::app()->jump->error("接口错误");
- return false;
- }
- if($rs->errCode!="00"){
- //Yii::app()->jump->error($rs->errMsg);
- //exit();
- return false;
- }
- if(!empty($rs->data)){
- foreach($rs->data as $v){
- $data['limitstu'][$v]=$v;
- }
- }else{
- $data['limitstu']=-1;
- }
- return $data;
- }
-
- /**
- * 获取班级设置
- */
- function getClassSet($classId,$semesterId){
- $is_set = 0;
- $temp_swich = 3;
- $temp_bate = 0;
- $switch_arr = array(3=>0,4=>1);
-
- $sql = "select switch from producut_set_edition";
- $switch_data = $this->sConn->createCommand($sql)->queryRow();
- if($switch_data && $switch_data['switch'] && in_array($switch_data['switch'],array(3,4))){
- $temp_swich = $switch_data['switch'];
- $temp_bate = $switch_arr[$temp_swich];
- }
-
-
- if($classId && $semesterId){
- $sql = "select wrong_book,isp,wb_isp from product_class_set where class_id = '{$classId}' and semester_id='{$semesterId}' and subject_id =3 and is_beta={$temp_bate}";
- $res = $this->sConn->createCommand($sql)->queryAll();
- if($res){
- foreach($res as $res_k=>$res_v){
- $setting_arr = array();
- $setting_arr[1] = $res_v['wrong_book'];
- $setting_arr[2] = $res_v['isp'];
- $setting_arr[3] = $res_v['wb_isp'];
- foreach($setting_arr as $k=>$v){
- $sql = "select config_text from product_template where template_id = '{$v}'";
- $data = $this->sConn->createCommand($sql)->queryRow();
- if($data){
- $json_data = $data['config_text'];
- $json_data_arr = json_decode($json_data,true);
- if(isset($json_data_arr['studentLevelDivide']) && isset($json_data_arr['studentLevelDivide']['isPushSameTrain']) && $json_data_arr['studentLevelDivide']['isPushSameTrain']){
- $is_set = 1;
- break 2;
- }
- }
- }
- }
-
- }else{
- $sql = "select template_id,config_text from product_template where subject_id=3 and is_default=1 and target_type=1 and is_beta={$temp_bate}";
- $data = $this->sConn->createCommand($sql)->queryAll();
- if($data){
- foreach($data as $k=>$v){
- $json_data = $v['config_text'];
- $json_data_arr = json_decode($json_data,true);
- if(isset($json_data_arr['studentLevelDivide']) && isset($json_data_arr['studentLevelDivide']['isPushSameTrain']) && $json_data_arr['studentLevelDivide']['isPushSameTrain']){
- $is_set = 1;
- break;
- }
- }
- }
- }
-
- }
- return $is_set;
- }
- /**获取名师指点信息
- * @param $topicInfo
- * @return mixed|string
- */
- public function dealTeacherTips($topicInfo){
- if(isset($topicInfo["teacher_tips"]) && $topicInfo["teacher_tips"]){//如果有的话直接返回
- return $topicInfo["teacher_tips"];
- }
- //兼容全学科题目
- if(!isset($topicInfo["topic_type_config"]) || empty($topicInfo["topic_type_config"]) || !isset($topicInfo["affiliate"])|| empty($topicInfo["affiliate"])){
- return "";
- }
- $topicTypeConfig = $topicInfo["topic_type_config"];
- if(is_object($topicTypeConfig)){
- $topicTypeConfig = json_decode(json_encode($topicTypeConfig),true);
- }
- //$topicTypeConfig = json_decode($topicInfo["topic_type_config"],true);
- if(!isset($topicTypeConfig["subject_custom"]) || !isset($topicTypeConfig["subject_custom"]["custom_column"])){
- return "";
- }
- if(!isset($topicTypeConfig["subject_custom"]["custom_column"][$topicInfo["subject_id"]])){
- return "";
- }
- $customColumnArr = $topicTypeConfig["subject_custom"]["custom_column"][$topicInfo["subject_id"]];
- $field_name = "";
- foreach($customColumnArr as $value){//获取题型对应的 名师指点定制标签
- if(isset($value["field_describe"]) && strpos($value["field_describe"],"名师指点") !==false){
- $field_name =$value["field_name"];
- break;
- }
- }
- if(!$field_name){
- return "";
- }
- $returnTeacherTips ="";
- $affiliate = $topicInfo["affiliate"];
- if(is_object($affiliate)){
- $affiliate = json_decode(json_encode($affiliate),true);
- }
- foreach($affiliate as $affValue){//获取定制标签的值
- if(is_object($affValue)){
- $affValue = json_decode(json_encode($affValue),true);
- }
- if(isset($affValue["field_key"]) && $affValue["field_key"] == $field_name){
- $returnTeacherTips = isset($affValue["field_value"])?$affValue["field_value"]:"";
- break;
- }
- }
- return $returnTeacherTips;
- }
- }
|