123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2018/8/13
- * Time: 10:48
- */
- require_once 'pData.class.php';
- require_once 'pDraw.class.php';
- require_once 'pImage.class.php';
- require_once 'pScatter.class.php';
- require_once 'IspMongo.php';
- class TeachingController extends Controller
- {
- public $subjectId;
- private $typeName;
- private $logicTypeName;
- private $imgArr = array();
- private $isThird = 0;
- // private $domainUrl = '';
- public function __construct()
- {
- $this->typeName = array('1' => '选择题', '11' => '不定项选择题', '5' => '填空题', '7' => '解答题', '17' => '选做解答题');
- }
- /**
- * 第三方教学宝
- * @throws CException
- */
- public function actionIndex()
- {
- set_time_limit(300);
- ini_set('memory_limit', '300M');
- $classId = Req::get("classId");
- $examId = (string)Req::get("examId");
- $force = (int)Req::get('force');
- $viewHtml = (int)Req::get('viewHtml');
- $subjectId = $this->subjectId;
- if ($viewHtml) {
- $force = 1;
- }
- if (!$examId || !is_numeric($examId)) {
- echo json_encode(array("status" => 1, "error" => "考试ID参数不正确!"));
- }
- $examObj = new Exam();
- $examInfo = $examObj->getTeachingInfo($examId);
- if (!$examInfo) {
- echo json_encode(array("status" => 1, "error" => "没有考试信息!"));
- exit;
- }
- if ($examInfo['subject_id']) {
- $this->subjectId = $examInfo['subject_id'];
- }
- $subjectId = $this->subjectId;
- $this->logicTypeName = getSubjectTopicType($subjectId);
- $pdfpath = str_replace("protected", "", Yii::app()->basePath) . $examInfo['academicr_pdf_path'];
- $pdfurl = $examInfo['academicr_pdf_path'];
- $res = array();//生成pdf命令结果
- if (strpos($examInfo['academicr_pdf_path'], 'http') !== false) {
- if (!file_get_contents($examInfo['academicr_pdf_path'])) {
- $force = 1;
- }
- } else {
- $force = 1;
- }
- //英语兼容新老标注
- $getTopicTypeRelate = $this->getTopicTypeRelate();
- $batch_subject_id = $subjectId;
- if ($batch_subject_id == 8 && $examInfo['qxk_paper_id']) {
- $batch_subject_id = 0;
- }
- if (!$examInfo['academicr_pdf_path'] || $examInfo['is_academicr_pdf'] == 0 || $force) {
- // if (!$examInfo['academicr_pdf_path'] || $examInfo['is_academicr_pdf'] == 0 || !$this->check_pdf($pdfpath) || $force) {
- //domain 域名
- // if ($subjectId == 8) {
- // if (isset($_SESSION['myDatebase'])) {
- // $groupId = $_SESSION['myDatebase']->group_id;
- // }else{
- // $groupId = 0;
- // }
- //
- // $groupServer = new BGroupServer();
- // $this->domainUrl = $groupServer->getDomainUrl($groupId);
- // }
- $paperObj = new SPaper();
- $ptrObj = new SPaperTopicRelation();
- $ptlObj = new SPaperTopicLarge();
- $sprObj = new SStudentPaperRelation();
- $sptRsObj = new SStudentPaperTopicRs();
- $tmt = new SThirdMultiTemplate();
- $examGroupId = $examInfo['exam_group_id'];
- $arr = $tmt->getStatusByExamGroupId($examGroupId);
- if ($subjectId == 8 && $examInfo['is_third'] == 1 && !$examInfo['qxk_paper_id']) {
- $isUpload = 0;
- if ($arr) {
- foreach ($arr as $k => $v) {
- if ($k == 1 && $v['topic_upload'] == 1) {
- $isUpload++;
- } elseif ($k == 2 && $v['answer_upload'] == 1) {
- $isUpload++;
- }
- }
- }
- //精品试卷不用上传试题和答案,第三方需要
- if ($examInfo['is_fine_paper'] <= 0 && $isUpload != 2) {
- echo json_encode(array("status" => 1, "error" => "试卷试题或答案没上传!"));
- exit();
- }
- }
- $examIds = $examObj->getExamIds($examGroupId);
- $examGroupObj = new SExamGroup();
- $isThird = $examGroupObj->getExamIsTird($examGroupId, $examId);
- $this->isThird = $isThird;
- //去除没有上传成绩的学生
- $ptrInfo = $stuIdsArr = array();
- if ($examIds) {
- $stuIdsArr = $sptRsObj->getHasScoreStu($examIds);
- $ptrInfo = $sprObj->getStudentExamInfo($examIds);
- }
- if (!$ptrInfo) {
- echo json_encode(array("status" => 1, "error" => "考试没有数据!"));
- exit();
- }
- $paperIds = array();
- foreach ($ptrInfo as $value) {
- $paperIds[$value['exam_id']] = $value['paper_id'];
- }
- //试卷总分
- $paperScore = $paperObj->getPaperScore($paperIds);
- if (!$paperScore) {
- echo json_encode(array("status" => 1, "error" => "试卷总分不正确!"));
- exit();
- }
- /**************************** 一、班级情况分析 ***********************************/
- //获取当前考试的上一次考试数据
- $cepObj = new SClassExamPrinter();
- $preInfo = $cepObj->getPreExamId($examId, $examInfo['subject_id'], $examInfo['class_id']);
- $preExamId = isset($preInfo['exam_id']) ? $preInfo['exam_id'] : '';
- $preExamGroupId = isset($preInfo['exam_group_id']) ? $preInfo['exam_group_id'] : '';
- $prePaperScore = 0;
- $preStuIdsArr = array();
- if ($preExamId) {
- $preExamIds = $examObj->getExamIds($preExamGroupId);
- //去除没有上传成绩的学生
- $prePtrInfo = array();
- if ($preExamIds) {
- $preStuIdsArr = $sptRsObj->getHasScoreStu($preExamIds);
- $prePtrInfo = $sprObj->getStudentExamInfo($preExamIds);
- }
- $prePaperIds = array();
- foreach ($prePtrInfo as $value) {
- $prePaperIds[$value['exam_id']] = $value['paper_id'];
- }
- if ($prePaperIds) {
- $prePaperScore = $paperObj->getPaperScore($prePaperIds);
- }
- } else {
- $prePtrInfo = array();
- }
- if (!$prePaperScore && $prePtrInfo) {
- echo json_encode(array("status" => 1, "error" => "试卷总分不正确!"));
- exit();
- }
- if (isset($paperIds[$examId])) {
- $paperId = $paperIds[$examId];
- } else {
- echo json_encode(array("status" => 1, "error" => "试卷id没有考试信息!"));
- exit();
- }
- //班级排名得分率人数等数据
- $classAnalyData = $this->getClassAnalyse($examId, $ptrInfo, $paperScore, $preExamId, $prePtrInfo, $prePaperScore, $stuIdsArr, $preStuIdsArr);
- //大幅进步,大幅退步,前5名和后5名
- $largeOrderData = $this->getLargeOrder($examId, $ptrInfo, $preExamId, $prePtrInfo, $stuIdsArr, $preStuIdsArr);
- $sutName = isset($largeOrderData['stu_name']) ? $largeOrderData['stu_name'] : array();
- $sutOrder = isset($largeOrderData['stu_order']) ? $largeOrderData['stu_order'] : array();
- unset($ptrInfo);
- unset($prePtrInfo);
- /**************************** 二、考试情况分析 ***********************************/
- //试卷题对应的题号,分数
- list($largeTopicType, $largeTopicMethod) = $ptlObj->getPaperLargeTopicInfo($paperId);
- list($smallTopicScore, $smallTopicNo, $topicScore, $topicNo, $topicType, $topicLogicType, $topicRelLarge, $topicRelMethod, $topicTypeRelNo, $topicRelTopicCount) = $ptrObj->getPaperTopicInfo2($paperId, $largeTopicType, $subjectId, $examInfo);
- if (!$topicScore) {
- echo json_encode(array("status" => 1, "error" => "没有试卷题数据!"));
- exit();
- }
- // // 学生得分
- $stuRs = $sptRsObj->getStudentRs($paperIds);
- if (!$stuRs) {
- echo json_encode(array("status" => 1, "error" => "没有学生做题数据!"));
- exit();
- }
- // $examAnalyData = $this->getExamAnalyse($stuRs,$topicScore,$topicNo,$paperId,$topicRelLarge);
- $typeMasterData = $this->getTopicTypeAnaly($stuRs, $topicScore, $topicNo, $paperId, $topicLogicType, $topicRelLarge, $smallTopicNo);
- //英语全学科判断
- if ($subjectId == 8 && $examInfo['qxk_paper_id']) {
- $newTopicTypeRelNo = array();
- foreach ($topicTypeRelNo as $topic_type => $topic_data) {
- if (isset($getTopicTypeRelate[$topic_type])) {
- $newTopicTypeRelNo[$getTopicTypeRelate[$topic_type]] = $topic_data;
- } else {
- $newTopicTypeRelNo[$topic_type] = $topic_data;
- }
- }
- $topicTypeRelNo = $newTopicTypeRelNo;
- }
- //班级高频错题 统计班级得分率小于50%的题目
- $high_rate_wrong_topic = array();
- if ($typeMasterData['type_name_arr']) {
- foreach ($typeMasterData['type_name_arr'] as $large_type => $type_name) {
- if (isset($topicTypeRelNo[$large_type])) {
- $high_rate_wrong_topic[$large_type] = array(array(), array(), array(), array(), array());
- foreach ($topicTypeRelNo[$large_type] as $topic_id => $topic_no) {
- $topic_class_rate = isset($typeMasterData['topic_class_rate'][$topic_id]) ? $typeMasterData['topic_class_rate'][$topic_id] : 0;
- if ($topic_class_rate <= 10) {
- $high_rate_wrong_topic[$large_type][0][] = $smallTopicNo[$topic_id];
- } elseif ($topic_class_rate > 10 && ($topic_class_rate <= 20)) {
- $high_rate_wrong_topic[$large_type][1][] = $smallTopicNo[$topic_id];
- } elseif ($topic_class_rate > 20 && ($topic_class_rate <= 30)) {
- $high_rate_wrong_topic[$large_type][2][] = $smallTopicNo[$topic_id];
- } elseif ($topic_class_rate > 30 && ($topic_class_rate <= 40)) {
- $high_rate_wrong_topic[$large_type][3][] = $smallTopicNo[$topic_id];
- } elseif ($topic_class_rate > 40 && ($topic_class_rate <= 50)) {
- $high_rate_wrong_topic[$large_type][4][] = $smallTopicNo[$topic_id];
- }
- }
- }
- }
- }
- $typeMasterData['high_rate_wrong_topic'] = $high_rate_wrong_topic;
- $typeRateImgUrl = array();
- // if($subjectId == 8){
- // //题型得分率图片
- // $typeRateImgUrl = $this->getTopicTypeRateImg($typeMasterData,$examId,$paperId);
- // if(!$typeRateImgUrl){
- // echo json_encode(array("status" => 1, "error" => "题型得分率图片未生成!"));
- // exit();
- // }
- // }
- /**************************** 三、考点掌握情况 ***********************************/
- // 15,3,5,2,6,18,13
- // $topicNo = array(
- // '10001190' => 4,
- // '10000151' => 6,
- // '10000917' => 7,
- // '10000166' => 8,
- // '10001228' => 9,
- // '10000405' => 10,
- // '10001172' => 11,
- // '10001174' => 12,
- // '10048797' => 14,
- // '10096054' => 16,
- // '10095990' => 17,
- // '10017696' => 18,
- // '10017824' => 19,
- // '10096052' => 20,
- // );
- //题信息
- $topicIds = array_keys($topicNo);
- $tplData = array();
- if ($examInfo['tpl_data']) {
- $tplData = $examInfo['tpl_data'];
- if ($tplData && !is_array($tplData)) {
- $tplData = json_decode($tplData, true);
- }
- }
- $isNewEnglish = (isset($tplData['isNewEnglish']) && $tplData['isNewEnglish'] == 1) ? 1 : 0;
- $_params = array('isFormat' => $subjectId == 8 ? 0 : 1, 'isTird' => $isThird, 'isNewEnglish' => $isNewEnglish, 'isNoReplaceLable' => 1);
- $topicDetails = $this->apiBrainPost('/topic/batchAll', array('topicIds' => $topicIds, 'subjectId' => $batch_subject_id, 'params' => $_params), 25, true);
- unset($tplData);
- // unset($examInfo['tpl_data']);
- // if(($this->subjectId == 8 && !$isThird) || (isset($tplData['isNewEnglish']) && $tplData['isNewEnglish'] == 1 && $isThird)){
- // $topicDetails = $this->getEnglishTopic($topicIds);
- //// $topicDetails = $this->getEnglishTopic(array(20001740));
- // }else{
- // $topicDetails = $this->aipost('/topic/batchAll', array('topicIds' => $topicIds));
- // }
- //获取考点名称
- // $methodName = $this->getMethodName($topicDetails);
- $methodName = array();
- $largeTopicScore = array();
- 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();
- } else {
- if ($subjectId == 8) {
- $tempDetials = array();
- if ($examInfo['qxk_paper_id']) {
- $topicDetails = $this->quanTopicDetail($topicDetails);
- }
- foreach ($topicDetails as $detail) {
- //范文
- // $fineArticle = $this->getFineArticle($examId,$topicLogicType);
- //语篇
- $keyWords = array();
- if (isset($getTopicTypeRelate[$detail['type_id']])) {
- $detail['type_id'] = $getTopicTypeRelate[$detail['type_id']];
- }
- if (in_array($detail['type_id'], array(2, 3, 4, 5))) {
- $wordsIds = array();
- $wordInfoArr = array();
- if (isset($detail['key_words_levels']) && $detail['key_words_levels']) {
- $key_words_level = $detail['key_words_levels'];
- $class = array();
- foreach ($key_words_level as $val) {
- $class[] = $val['level'];
- }
- array_multisort($class, SORT_DESC, $key_words_level);
- $_new_key_words = $key_words_level;
- $word_content = array();
- foreach ($_new_key_words as $item) {
- $word_content[] = '"' . $item['name'] . '"';
- }
- if ($word_content) {
- $wordInfoArr = $this->getWord(array('content' => $word_content, 'type_id' => array(1, 2), 'core_words' => 1, 'status' => 1));
- $topic_word_level = array();
- foreach ($wordInfoArr as $word_id => $word_info) {
- $level = isset($word_info['levels']) ? $word_info['levels'] : 0;
- $topic_word_level[$word_id] = $level;
- }
- arsort($topic_word_level);
- foreach ($topic_word_level as $word_id => $level) {
- if (count($wordsIds) <= 10) {
- $wordsIds[] = $word_id;
- }
- }
- }
- }
- if ($wordsIds) {
- foreach ($wordsIds as $w_id) {
- if (isset($wordInfoArr[$w_id])) {
- $keyWords[] = $wordInfoArr[$w_id];
- }
- }
- $keyWords = $this->handleWordClass($keyWords);
- }
- unset($wordInfoArr);
- }
- $detail['key_words'] = $keyWords;
- if ($examInfo['qxk_paper_id']) {
- $detail['key_words'] = isset($detail['new_key_words']) ? $detail['new_key_words'] : array();
- }
- //替换序号
- // if (in_array($detail['type_id'], array(2,4,5,6,9, 10, 11, 12, 14))) {
- // $this->replaceTitle($detail['title'],$detail['id'],$topicRelLarge,$smallTopicNo);
- // }
- $detail['title'] = str_replace(' ', ' ', $detail['title']);
- $tempDetials[(string)$detail['id']] = $detail;
- }
- $topicDetails = $tempDetials;
- unset($tempDetials);
- //大题分数
- foreach ($topicRelLarge as $small_id => $large_id) {
- if (!isset($largeTopicScore[$large_id])) {
- $largeTopicScore[$large_id] = 0;
- }
- $largeTopicScore[$large_id] += $topicScore[$small_id];
- }
- }
- }
- $diff_id_arr = array_diff($topicIds, array_keys($topicDetails));
- if ($diff_id_arr) {
- //todo 发送消息到补提
- echo json_encode(array("status" => 1, "error" => "没有试题内容!(" . implode(',', $diff_id_arr) . ")"));
- exit;
- }
- //1.薄弱考点统计
- //2.薄弱考点掌握较差学生名单
- //3.班级排名后25%学生的薄弱考点
- $pramas = array($smallTopicScore, $smallTopicNo, $paperId, $topicType, $topicLogicType, $topicRelLarge, $topicRelMethod, $largeTopicMethod, $sutName, $sutOrder, $methodName);
- // $methodCount = $this->getMethodCount($stuRs,$pramas);
- $methodCount = array();
- //4.考点掌握情况变化趋势
- //生成图片
- // if($subjectId == 8){
- if (false) {
- $_classRate = array();
- $thirdExam = $cepObj->getTirdExamIds($examId, $examInfo['subject_id'], $examInfo['class_id']);
- if (count($thirdExam) > 3) {
- $thirdExamIds = array();
- $examTime = array();
- foreach ($thirdExam as $value) {
- $thirdExamIds[] = $value['exam_id'];
- $examTime[$value['exam_id']] = $value['add_time'];
- }
- list($paperRelExam, $exmaRelPaper) = $paperObj->getPaperIdsByExamIds($thirdExamIds);
- $_topicScore = array();
- $_topicMethod = array();
- $_stuRs = array();
- if ($paperRelExam) {
- $thirdPaperInfo = $ptrObj->getPaperInfos($paperRelExam);
- foreach ($thirdPaperInfo as $item) {
- $_topicScore[$item['topic_id']] = $item['score'];
- $_topicMethod[$item['topic_id']] = explode(',', $item['method_ids']);
- }
- $_stuRs = $sptRsObj->getStudentRs($paperRelExam);
- }
- $_scoring = $_score = array();
- foreach ($_stuRs as $stuId => $stuR) {
- foreach ($stuR as $tId => $item) {
- $pId = $item['paper_id'];
- $eId = isset($exmaRelPaper[$pId]) ? $exmaRelPaper[$pId] : 0;
- $eTime = isset($examTime[$eId]) ? $examTime[$eId] : 0;
- if (!$eTime) continue;
- $_tScore = isset($_topicScore[$tId]) ? $_topicScore[$tId] : 0;
- if (isset($_topicMethod[$tId]) && $_topicMethod[$tId]) {
- foreach ($_topicMethod[$tId] as $mId) {
- if (!$mId) {
- continue;
- }
- if (!isset($_scoring[$eTime])) {
- $_scoring[$eTime] = array();
- }
- if (!isset($_scoring[$eTime][$mId])) {
- $_scoring[$eTime][$mId] = 0;
- }
- $_scoring[$eTime][$mId] += $item['scoring'];
- if (!isset($_score[$eTime])) {
- $_score[$eTime] = array();
- }
- if (!isset($_score[$eTime][$mId])) {
- $_score[$eTime][$mId] = 0;
- }
- $_score[$eTime][$mId] += $_tScore;
- }
- }
- }
- }
- foreach ($_scoring as $eTime => $scorings) {
- if (!isset($_classRate[$eTime])) {
- $_classRate[$eTime] = array();
- }
- foreach ($scorings as $mId => $scoring) {
- if (isset($_score[$eTime]) && isset($_score[$eTime][$mId]) && $_score[$eTime][$mId]) {
- $_classRate[$eTime][$mId] = round($scoring / $_score[$eTime][$mId], 4) * 100;
- } else {
- $_classRate[$eTime][$mId] = 0;
- }
- }
- }
- }
- ksort($_classRate);
- //三次考试同一考点的得分率
- $timeMethodRate = array();
- foreach ($_classRate as $time => $rates) {
- foreach ($rates as $mId => $rate) {
- if (!isset($timeMethodRate[$mId])) {
- $timeMethodRate[$mId] = array();
- }
- $timeMethodRate[$mId][] = $rate;
- $timeMethodRate[$mId][] = $rate;
- $timeMethodRate[$mId][] = $rate;
- }
- }
- //取出符合规则的三个考点
- $rateCompare = array();
- foreach ($timeMethodRate as $mId => $rates) {
- $rate_1 = $rates[2] - $rates[1];
- $rate_2 = $rates[1] - $rates[0];
- $rateCompare[$mId] = $rate_1 - $rate_2;
- }
- arsort($rateCompare);
- $rateCompare = array_slice($rateCompare, 0, 3, true);
- $timeMethodRate = array();
- foreach ($_classRate as $time => $rates) {
- foreach ($rates as $mId => $rate) {
- if (isset($rateCompare[$mId])) {
- if (!isset($timeMethodRate[$mId])) {
- $timeMethodRate[$mId] = array();
- }
- $timeMethodRate[$mId][] = $rate;
- }
- }
- }
- $imgPath = str_replace("protected", "", Yii::app()->basePath) . 'assets/temp_img/';
- $urlPath = Yii::app()->request->hostInfo . '/assets/temp_img/';
- $methodRatePath = $imgPath . $examId . "_rate.png";
- $methodRateUrl = $urlPath . $examId . "_rate.png";
- $this->imgArr[] = $methodRatePath;
- if (count($timeMethodRate) >= 3) {
- $this->getImage($methodRatePath, $timeMethodRate);
- }
- if (!file_exists($methodRatePath)) {
- // echo json_encode(array("status" => 1, "error" => "考点得分率图片未生成!"));
- // exit();
- $methodRateUrl = '';
- }
- } else {
- $methodRateUrl = '';
- }
- /**************************** 四、试卷讲评 ***********************************/
- //选择题
- $choinceIds = $this->getChoiceIds($topicType, $topicLogicType, $subjectId, $examInfo['tpl_index']);
- //试题年级和班级得分率,答对和答错人数
- $topicRateStu = $this->getTopicRateWrongPerson($stuRs, $topicScore, $paperId, $stuIdsArr, $topicRelLarge, $choinceIds, $sutName, $topicLogicType);
- $common_practice = array();
- $commonTopicDetail = array();
- if ($subjectId == 8) {
- $commonCheck = SProductSetting::model()->getCommonSetting($classId, $subjectId, 6);
- if ($commonCheck) {
- if ($examInfo['academicr_common_practice']) {
- $common_push_all_topics = array();
- $common_practice = json_decode($examInfo['academicr_common_practice'], true);
- foreach ($common_practice as $type => $cp_info) {
- if ($type == 'min_rate_text' || $type == 'common_extra') {
- $t_ids = _array_column($cp_info, 'topic_id');
- $common_push_all_topics = array_merge($common_push_all_topics, $t_ids);
- } else {
- foreach ($cp_info as $topic_type => $t_info) {
- $t_ids = _array_column($t_info, 'topic_id');
- $common_push_all_topics = array_merge($common_push_all_topics, $t_ids);
- }
- }
- }
- } else {
- //20211221新逻辑:学生提分宝不生成共性问题的话 教师讲案直接不生成
- echo json_encode(array("status" => 1, "error" => "共性题未生成!"));
- exit;
- $common_wrong_topic = $this->getCommonPractice($topicDetails, $topicRateStu['large_topic_score'], $stuRs, $largeTopicType, $topicRateStu['large_contain_score']);
- list($common_practice, $common_push_all_topics) = $common_wrong_topic;
- $sql = "update exam set academicr_common_practice = '" . json_encode($common_practice) . "' where exam_id={$examId}";
- $dbConn = Exam::model()->getDbConnection();
- $dbConn->createCommand($sql)->execute();
- }
- if ($common_push_all_topics) {
- $commonTopicDetail = $this->apiBrainPost('/topic/batchAll', array('topicIds' => array_values($common_push_all_topics), 'subjectId' => $batch_subject_id, 'params' => array('isNoReplaceLable' => 1)), 25, true);
- if (!$commonTopicDetail) {
- echo json_encode(array("status" => 1, "error" => "获取接口batchALL无数据!"));
- exit();
- } elseif (isset($commonTopicDetail['status']) && $commonTopicDetail['status'] == 0) {
- echo json_encode(array("status" => 1, "error" => $commonTopicDetail['error'][0]));
- exit();
- } else {
- $tempDetials = array();
- if ($examInfo['qxk_paper_id']) {
- $commonTopicDetail = $this->quanTopicDetail($commonTopicDetail);
- }
- foreach ($commonTopicDetail as $detail) {
- if (isset($getTopicTypeRelate[$detail['type_id']])) {
- $detail['type_id'] = $getTopicTypeRelate[$detail['type_id']];
- }
- $tempDetials[(string)$detail['id']] = $detail;
- }
- $commonTopicDetail = $tempDetials;
- }
- }
- }
- }
- //echo 111;exit;
- $topicTypeScore = array();
- if ($subjectId == 8) {
- //题型重新按照组卷顺序排序
- $new_type_name_arr = array();
- $new_high_rate_wrong_topic = array();
- $new_class_rate = array();
- $new_type_order = array_keys($topicTypeRelNo);
- if ($new_type_order) {
- foreach ($new_type_order as $new_type) {
- if (isset($this->logicTypeName) && isset($this->logicTypeName[$new_type]) && $this->logicTypeName[$new_type]) {
- $new_type_name_arr[$new_type] = $this->logicTypeName[$new_type];
- } else {
- $new_type_name_arr[$new_type] = '';
- }
- if (isset($typeMasterData['high_rate_wrong_topic']) && $typeMasterData['high_rate_wrong_topic'] && isset($typeMasterData['high_rate_wrong_topic'][$new_type])) {
- $new_high_rate_wrong_topic[$new_type] = $typeMasterData['high_rate_wrong_topic'][$new_type];
- }
- if (isset($typeMasterData['class_rate']) && $typeMasterData['class_rate'] && isset($typeMasterData['class_rate'][$new_type])) {
- $new_class_rate[$new_type] = $typeMasterData['class_rate'][$new_type];
- }
- }
- }
- if ($new_type_name_arr) {
- $typeMasterData['type_name_arr'] = $new_type_name_arr;
- }
- if ($new_high_rate_wrong_topic) {
- $typeMasterData['high_rate_wrong_topic'] = $new_high_rate_wrong_topic;
- }
- if ($new_class_rate) {
- $typeMasterData['class_rate'] = $new_class_rate;
- }
- //获取题型对应题目关系
- $typeToTopicIds = array();
- if ($topicDetails) {
- foreach ($topicDetails as $topicIdTemp => $topicDetailTemp) {
- if (isset($topicDetailTemp['type_id']) && $topicDetailTemp['type_id']) {
- $typeToTopicIds[$topicDetailTemp['type_id']][] = (string)$topicIdTemp;
- }
- }
- }
- //增加班级题型得分表
- if ($topicTypeRelNo) {
- foreach ($topicTypeRelNo as $typeTemp => $topicNoDataTemp) {
- if ($topicNoDataTemp) {
- $topicTypeScore[$typeTemp]['score'] = 0;
- $topicTypeScore[$typeTemp]['class_score'] = 0;
- $topicTypeScore[$typeTemp]['grade_score'] = 0;
- $topicTypeScore[$typeTemp]['diff_score'] = 0;
- $topicTypeScore[$typeTemp]['no'] = '';
- $tempClassScore = $tempGradeScore = $tempClassCount = $tempGradeCount = 0;
- $tempClassStuIds = $tempGradeStuIds = array();
- if (isset($topicRateStu) && $topicRateStu && isset($topicRateStu['large_topic_score']) && $topicRateStu['large_topic_score']) {
- foreach ($topicRateStu['large_topic_score'] as $stuIdTemp => $stuScoreTemp) {
- foreach ($stuScoreTemp as $tempTopicIdK => $tempTopicIdV) {
- if (isset($typeToTopicIds[$typeTemp]) && $typeToTopicIds[$typeTemp] && in_array((string)$tempTopicIdK, $typeToTopicIds[$typeTemp], true)) {
- if (isset($sutName[$stuIdTemp])) {//本班
- $tempClassScore += (isset($tempTopicIdV['scoring']) && $tempTopicIdV['scoring']) ? $tempTopicIdV['scoring'] : 0;
- // $tempClassCount ++;
- $tempClassStuIds[] = (string)$stuIdTemp;
- }
- $tempGradeScore += (isset($tempTopicIdV['scoring']) && $tempTopicIdV['scoring']) ? $tempTopicIdV['scoring'] : 0;
- // $tempGradeCount ++;
- $tempGradeStuIds[] = (string)$stuIdTemp;
- }
- }
- }
- }
- if ($tempClassStuIds) {
- $tempClassCount = count(array_unique($tempClassStuIds));
- $topicTypeScore[$typeTemp]['class_score'] = round($tempClassScore / $tempClassCount, 1);
- }
- if ($tempGradeStuIds) {
- $tempGradeCount = count(array_unique($tempGradeStuIds));
- $topicTypeScore[$typeTemp]['grade_score'] = round($tempGradeScore / $tempGradeCount, 1);
- }
- $topicTypeScore[$typeTemp]['diff_score'] = round($topicTypeScore[$typeTemp]['class_score'] - $topicTypeScore[$typeTemp]['grade_score'], 1);
- if (isset($typeToTopicIds[$typeTemp]) && $typeToTopicIds[$typeTemp]) {
- foreach ($typeToTopicIds[$typeTemp] as $bigTopicTemp) {
- if (isset($largeTopicScore[$bigTopicTemp]) && $largeTopicScore[$bigTopicTemp]) {
- $topicTypeScore[$typeTemp]['score'] += $largeTopicScore[$bigTopicTemp];
- }
- }
- }
- $topicNoValue = array_values($topicNoDataTemp);
- if (count($topicNoValue) == 1) {
- $topicTypeScore[$typeTemp]['no'] = $topicNoValue[0];
- } else {
- $topicTypeScore[$typeTemp]['no'] = min($topicNoValue) . '-' . max($topicNoValue);
- }
- }
- }
- }
- }
- $data = array();
- $data['examInfo'] = $examInfo;
- $data['classAnalyData'] = $classAnalyData;
- $data['largeOrderData'] = $largeOrderData;
- // $data['examAnalyData'] = $examAnalyData;
- $data['typeMasterData'] = $typeMasterData;
- $data['typeRateImg'] = $typeRateImgUrl;
- $data['methodCount'] = $methodCount;
- $data['topicDetails'] = $topicDetails;
- $data['paperTopicNo'] = $topicNo;
- $data['smallTopicNo'] = $smallTopicNo;
- $data['topicTypeRelNo'] = $topicTypeRelNo;
- $data['topicRateStu'] = $topicRateStu;
- $data['methodRateUrl'] = $methodRateUrl;
- $data['subjectId'] = $subjectId;
- $data['isThird'] = $isThird;
- $data['sutName'] = $sutName;
- $data['methodName'] = $methodName;
- $data['logicTypeName'] = $this->logicTypeName;
- $data['topic_score'] = $largeTopicScore;
- $data['topic_rel_topic_count'] = $topicRelTopicCount;
- $data['common_practice'] = $common_practice;
- $data['common_topic_detail'] = $commonTopicDetail;
- $data['topicTypeScore'] = $topicTypeScore;
- //echo json_encode($data);exit;
- if ($subjectId == 8) {
- $html_name = 'en_teach';
- } else {
- $html_name = 'teach';
- }
- if ($viewHtml) {
- $this->renderPartial("teaching/{$html_name}", $data);
- exit();
- } else {
- $html = $this->renderPartial("teaching/{$html_name}", $data, true);
- }
- unset($data);
- $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);
- $htmlurl = '/upload/tmpDir/academicr/' . $examId . ".html"; //访问HTML的路径
- if (Yii::app()->basePath == "E:\wamp64\www\zsyas2\protected") {//本地的basePath
- $htmlurl = " http://local.zsyas2teaching.com" . '/' . $examId . '.html';
- $pdffname = $classId . "-" . $examId . ".pdf";
- $pdfpath = $pdfpath . $pdffname;
- $pdfurl = $pdfurl . $pdffname;
- $commond = Yii::app()->params['phantomjs'] . " "
- . Yii::app()->params['html2pdf'] . " "
- . " {$htmlurl}"
- . " {$pdfpath}"
- . " 176mm*250mm ''";
- } else {
- $server = Yii::app()->params['phantomjs_server'];
- $js = 'html2pdf.js';
- if ($subjectId == 8) {
- $server = Yii::app()->params['phantomjs_server_en'];
- $js = 'html2pdf_en.js';
- }
- $htmlurl = "http://" . $_SERVER['SERVER_NAME'] . $htmlurl;
- $pdffname = $classId . "-" . $examId . ".pdf";
- $pdfpath = $pdfpath . $pdffname;
- $pdfurl = $pdfurl . $pdffname;
- $commond = $server . " "
- . Yii::app()->basePath . '/../js/' . $js . " "
- . " {$htmlurl}"
- . " {$pdfpath}"
- . " 176mm*250mm ''";
- }
- exec($commond, $res, $code);
- //删除生成的图片
- $this->delCreateImgs();
- $ucloud = new Qcloud();
- //上传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])) {
- $isBool = false;
- foreach ($res as $msg) {
- if (strpos($msg, 'succeed') !== false) {
- $isBool = true;
- }
- }
- if ($isBool) {//命令返回成功
- if (file_exists($pdfpath)) {
- // $pdfurl=iconv("GBK", "UTF-8",$pdfurl);
- $repdf = $examId . ".pdf";
- $rename = 'zsyas2/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_pdf_path" => $pdfurl, "academicr_pdf_time" => time(), "is_academicr_pdf" => 1), "exam_id = '{$examId}'");
- // if($uploadInfo['msg']){
- // exit(json_encode(array("status" => 0, "error" => $uploadInfo['msg'])));
- // }else{
- // exit(json_encode(array("status" => 0, "error" => 'PDF文件上传失败')));
- // }
- //throw new CException("PDF文件上传失败");
- } else {
- $pdfurl = $uploadInfo['url'];
- $this->sConn->createCommand()->update("exam", array("academicr_pdf_path" => $pdfurl, "academicr_pdf_time" => time(), "is_academicr_pdf" => 1), "exam_id = '{$examId}'");
- @unlink($pdfpath);
- }
- @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);
- echo json_encode(array("status" => 1, "error" => "PDF文件未找到!"));
- exit;
- }
- } else {
- @unlink($htmlpath);
- echo json_encode(array("status" => 1, "error" => "PDF创建失败!", 'exec_rs' => json_encode($res)));
- exit;
- }
- } else {
- Curl::post(Yii::app()->params['handle_log_api'], array(
- "exam_group_id" => (string)$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" => $htmlurl))),
- ));
- echo json_encode(array("status" => 1, "error" => "PDF创建失败!"));
- exit;
- }
- }
- if (fileGetContents($pdfurl)) {
- // if ($this->check_pdf($pdfpath)) {
- echo json_encode(array("status" => 0, "error" => "", "is_create" => 1, 'exec_rs' => json_encode($res)));
- exit;
- } else {
- echo json_encode(array("status" => 1, "error" => "文件尚未生成!!", 'exec_rs' => json_encode($res)));
- exit;
- }
- }
- //替换序号
- private function replaceTitle(&$title, $topicId, $topicRelLarge, $smallTopicNo)
- {
- // $str = '<img src="http://zsytk2.zhixinhuixue.com/static/images/4.gif" _src="http://zsytk2.zhixinhuixue.com/static/images/4.gif" class="tiankong" data-num="3">';
- $topicNoArr = array();
- foreach ($topicRelLarge as $small_id => $large_id) {
- if ($topicId == $large_id && isset($smallTopicNo[$small_id])) {
- $topicNoArr[] = $smallTopicNo[$small_id];
- }
- }
- $imgArr = array();
- $pattern = "/<img[\s\S]*?src\s*=\s*[\"|\'](.*?)[\"|\'][\s\S]*?>/";
- preg_match_all($pattern, $title, $match);
- if (isset($match[0]) && $match[0]) {
- foreach ($match[0] as $img) {
- $pattern = "/data-num=[\"|\'](\d{0,2})[\"|\']/";
- preg_match_all($pattern, $img, $match);
- if (isset($match[0]) && isset($match[1]) && isset($match[1][0])) {
- $imgArr[$match[1][0]] = $img;
- }
- }
- }
- if (count($imgArr) == count($topicNoArr)) {
- asort($topicNoArr);
- $searchArr = $replaceArr = array();
- foreach ($topicNoArr as $key => $no) {
- $searchArr[] = isset($imgArr[$key]) ? $imgArr[$key] : '';
- $replaceArr[] = ' (' . $no . ') ';
- }
- $title = str_replace($searchArr, $replaceArr, $title);
- }
- }
- /**
- * 精品范文
- * @return array
- */
- public function getFineArticle($examId, $topicLogicType)
- {
- $fineArticle = array();
- $studentModelEssay = new SStudentModelEssay();
- $stuRsIds = $studentModelEssay->getStuRsId($examId);
- if (!$stuRsIds) {
- return $fineArticle;
- }
- $sptr = new SStudentPaperTopicRs();
- $rsInfo = $sptr->getStuRsByIds($stuRsIds);
- if ($rsInfo) {
- foreach ($rsInfo as $v) {
- $id = $v['id'];
- $ansUrl = $v['answer_trace'];
- $topic_id = $v['topic_id'];
- $type = isset($topicLogicType[$topic_id]) ? $topicLogicType[$topic_id] : 0;
- if (!$ansUrl) {
- $ansUrl = $v['simplify_answer_url'];
- }
- if (!$ansUrl) {
- $ansUrl = $v['answer_url'];
- }
- $ansUrl = answer_process($this->domainUrl, $ansUrl);
- if (!isset($fineArticle[$type])) {
- $fineArticle[$type] = array();
- }
- if ($v['answer_url']) {
- $fineArticle[$type][$id] = $ansUrl;
- } else {
- $fineArticle[$type][$id] = '';
- }
- }
- }
- return $fineArticle;
- }
- //获取词汇
- private function getWord($condition)
- {
- $wordsInfo = array();
- // $params = array(
- // '_id' => array('$in' => array_values($word_ids))
- // );
- //
- // return IspMongo::selectMongo('english_single',$params);
- $rs = $this->apiBrainPost('/zsytk2/getIspInfo', array('condition' => $condition, 'table' => 'en_single_word', 'isAll' => 1), 25, true);
- if (isset($rs['status']) && $rs['status'] == 1 && isset($rs['data']) && $rs['data']) {
- foreach ($rs['data'] as $v) {
- $wordsInfo[$v['single_word_id']] = $v;
- }
- }
- return $wordsInfo;
- }
- 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;
- }
- /**
- * 班级排名得分率人数等数据
- * @param $examId
- * @param $ptrInfo
- * @param $paperScore
- * @param $preExamId
- * @param $prePtrInfo
- * @param $prePaperScore
- * @return array
- */
- private function getClassAnalyse($examId, &$ptrInfo, $paperScore, $preExamId, &$prePtrInfo, $prePaperScore, &$stuIdsArr, &$preStuIdsArr)
- {
- $result = array();
- $gradePerson = $classPerson = 0;//参考人数
- $gradeAbsentPerson = $classAbsentPerson = 0;//缺考人数
- $gradeOrder = $classOrder = 0; //排名
- $gradeAvgScore = $classAvgScore = 0; //平均分
- $gradeScoreRate = $classScoreRate = 0; //得分率
- $gradeFineRate = $classFineRate = 0; //优秀率 80%
- $gradePassRate = $classPassRate = 0; //合格率 60%
- $gradeLowRate = $classLowRate = 0; //低分率 30%
- $angData = array(
- 'class_num' => 0,//班级数量
- 'order' => 0,
- 'absent_person' => 0,
- 'exam_person' => 0,
- 'avg_score' => 0,
- 'score_rate' => 0,
- 'fine_rate' => 0,
- 'pass_rate' => 0,
- 'low_rate' => 0,
- );
- $result['grade'] = $result['class'] = $angData;
- $gradeScoring = $classScoring = array();
- $gradeScoringSum = array();//年级中每个考试的得分和
- // $classScoringSum = 0;//考试得分和
- $gradeStuScoringRate = $classStuScoringRate = array();//学生得分率
- foreach ($ptrInfo as $value) {
- $stuIds = isset($stuIdsArr[$value['exam_id']]) ? $stuIdsArr[$value['exam_id']] : array();
- if (!isset($gradeScoringSum[$value['exam_id']])) {
- $gradeScoringSum[$value['exam_id']] = 0;
- }
- if (inArray($value['student_id'], $stuIds)) {
- $gradeScoringSum[$value['exam_id']] += $value['scoring'];
- $gradeScoring[] = $value['scoring'];
- $gradeStuScoringRate[] = round($value['scoring'] / $paperScore, 4) * 100;
- $gradePerson++;
- }
- if (!inArray($value['student_id'], $stuIds)) {
- $gradeAbsentPerson++;
- }
- // if($examId == $value['exam_id']){
- if (strcmp($examId, $value['exam_id']) == 0) {
- if (inArray($value['student_id'], $stuIds)) {
- // $classScoringSum += $value['scoring'];
- $classScoring[] = $value['scoring'];
- $classStuScoringRate[] = round($value['scoring'] / $paperScore, 4) * 100;
- $classPerson++;
- }
- if (!inArray($value['student_id'], $stuIds)) {
- $classAbsentPerson++;
- }
- }
- }
- unset($ptrInfo);
- $result['class']['class_num'] = count($gradeScoringSum);
- $result['grade']['exam_person'] = $gradePerson;
- $result['grade']['absent_person'] = $gradeAbsentPerson;
- $result['class']['exam_person'] = $classPerson;
- $result['class']['absent_person'] = $classAbsentPerson;
- //排名
- if ($gradeScoringSum) {
- $scoringArr = array();
- foreach ($gradeScoringSum as $eId => $scoring) {
- $stuCount = isset($stuIdsArr[$eId]) ? count($stuIdsArr[$eId]) : 0;
- if ($stuCount) {
- $scoringArr[$eId] = round($scoring / $stuCount, 2);
- }
- }
- if (isset($scoringArr[$examId])) {
- $classOrder = $this->getOrder($scoringArr[$examId], $scoringArr);
- } else {
- $classOrder = 0;
- }
- }
- $result['class']['order'] = $classOrder;
- //平均分,得分率
- $count = count($gradeScoring);
- if ($count > 0) {
- $gradeAvgScore = round(array_sum($gradeScoring) / $count, 2);//平均分
- $gradeScoreRate = round(array_sum($gradeScoring) / ($paperScore * $count), 4) * 100;//得分率
- } else {
- $gradeAvgScore = 0;
- $gradeScoreRate = 0;
- }
- $result['grade']['avg_score'] = $gradeAvgScore;
- $result['grade']['score_rate'] = $gradeScoreRate;
- $count = count($classScoring);
- if ($count > 0) {
- $classAvgScore = round(array_sum($classScoring) / $count, 2);
- $classScoreRate = round(array_sum($classScoring) / ($paperScore * $count), 4) * 100;//得分率
- } else {
- $classAvgScore = 0;
- $classScoreRate = 0;
- }
- $result['class']['avg_score'] = $classAvgScore;
- $result['class']['score_rate'] = $classScoreRate;
- //优秀率,合格率,低分率
- // $gradeFineRate = $classFineRate = 0; //优秀率 85%
- // $gradePassRate = $classPassRate = 0; //合格率 60%
- // $gradeLowRate = $classLowRate = 0; //低分率 30%
- $tempFineNum = $tempPassNum = $tempLowNum = 0;
- $rateCount = count($gradeStuScoringRate);
- foreach ($gradeStuScoringRate as $scoringRate) {
- if ($scoringRate >= 85) {
- $tempFineNum++;
- }
- if ($scoringRate >= 60) {
- $tempPassNum++;
- }
- if ($scoringRate <= 30) {
- $tempLowNum++;
- }
- }
- $gradeFineRate = round($tempFineNum / $rateCount, 4) * 100;
- $gradePassRate = round($tempPassNum / $rateCount, 4) * 100;
- $gradeLowRate = round($tempLowNum / $rateCount, 4) * 100;
- $result['grade']['fine_rate'] = $gradeFineRate;
- $result['grade']['pass_rate'] = $gradePassRate;
- $result['grade']['low_rate'] = $gradeLowRate;
- $tempFineNum = $tempPassNum = $tempLowNum = 0;
- $rateCount = count($classStuScoringRate);
- foreach ($classStuScoringRate as $scoringRate) {
- if ($scoringRate >= 85) {
- $tempFineNum++;
- }
- if ($scoringRate >= 60) {
- $tempPassNum++;
- }
- if ($scoringRate <= 30) {
- $tempLowNum++;
- }
- }
- if ($rateCount) {
- $classFineRate = round($tempFineNum / $rateCount, 4) * 100;
- $classPassRate = round($tempPassNum / $rateCount, 4) * 100;
- $classLowRate = round($tempLowNum / $rateCount, 4) * 100;
- } else {
- $classFineRate = 0;
- $classPassRate = 0;
- $classLowRate = 0;
- }
- $result['class']['fine_rate'] = $classFineRate;
- $result['class']['pass_rate'] = $classPassRate;
- $result['class']['low_rate'] = $classLowRate;
- /**************** 提升数据 ******************/
- $result['class']['order_increase'] = 0;
- $result['class']['rate_increase'] = 0;
- $result['class']['fine_rate_increase'] = 0;
- if ($prePtrInfo) {
- $preClassStuScoringRate = array();
- $preGradeScoringSum = array();
- $preClassScoringSum = 0;
- $preClassScoring = array();
- if ($prePtrInfo) {
- foreach ($prePtrInfo as $value) {
- $stuIds = isset($preStuIdsArr[$value['exam_id']]) ? $preStuIdsArr[$value['exam_id']] : array();
- if (!isset($preGradeScoringSum[$value['exam_id']])) {
- $preGradeScoringSum[$value['exam_id']] = 0;
- }
- if (inArray($value['student_id'], $stuIds)) {
- $preGradeScoringSum[$value['exam_id']] += $value['scoring'];
- }
- // if($preExamId == $value['exam_id']){
- if (strcmp($preExamId, $value['exam_id']) == 0) {
- if (inArray($value['student_id'], $stuIds)) {
- $preClassScoringSum += $value['scoring'];
- $preClassScoring[] = $value['scoring'];
- $preClassStuScoringRate[] = round($value['scoring'] / $prePaperScore, 4) * 100;
- }
- }
- }
- }
- //上一次考试排名
- if ($gradeScoringSum) {
- $scoringArr = array();
- foreach ($preGradeScoringSum as $eId => $scoring) {
- $stuCount = isset($preStuIdsArr[$eId]) ? count($preStuIdsArr[$eId]) : 0;
- if ($stuCount) {
- $scoringArr[$eId] = round($scoring / $stuCount, 2);
- }
- }
- if (isset($scoringArr[$preExamId])) {
- $preClassOrder = $this->getOrder($scoringArr[$preExamId], $scoringArr);
- } else {
- $preClassOrder = 0;
- }
- $result['class']['order_increase'] = -($classOrder - $preClassOrder);
- }
- $count = count($preClassScoring);
- if ($count > 0) {
- $preClassScoreRate = round(array_sum($preClassScoring) / ($prePaperScore * $count), 4) * 100;//得分率
- $result['class']['rate_increase'] = $classScoreRate - $preClassScoreRate;
- }
- $tempFineNum = 0;
- $rateCount = count($preClassStuScoringRate);
- foreach ($preClassStuScoringRate as $scoringRate) {
- if ($scoringRate >= 85) {
- $tempFineNum++;
- }
- }
- if ($rateCount) {
- $preClassFineRate = round($tempFineNum / $rateCount, 4) * 100;
- } else {
- $preClassFineRate = 0;
- }
- $result['class']['fine_rate_increase'] = $classFineRate - $preClassFineRate;
- }
- return $result;
- }
- /**
- * 大幅进步,大幅退步,前5名和后5名
- * @param $examId
- * @param $ptrInfo
- * @param $paperScore
- * @param $preExamId
- * @param $prePtrInfo
- * @param $prePaperScore
- */
- private function getLargeOrder($examId, &$ptrInfo, $preExamId, &$prePtrInfo, &$stuIdsArr, &$preStuIdsArr)
- {
- $result = array();
- $stuOrderArr = $this->getStudentOrder($examId, $ptrInfo, $stuIdsArr);
- $diffNum = ceil(count($stuOrderArr) * 0.2);
- if ($prePtrInfo) {
- $preStuOrderArr = $this->getStudentOrder($preExamId, $prePtrInfo, $preStuIdsArr);
- } else {
- $preStuOrderArr = array();
- }
- if ($preStuOrderArr) {
- $interOrderArr = array_intersect_key($stuOrderArr, $preStuOrderArr);
- if (!$interOrderArr) {
- $interOrderArr = $stuOrderArr;
- }
- } else {
- $interOrderArr = array();
- }
- //大幅进步,退步
- $increaseArr = $reduceArr = array();
- $stuDiffOrder = array();
- if ($interOrderArr) {
- foreach ($stuOrderArr as $stuId => $order) {
- if (isset($interOrderArr[$stuId]) && isset($preStuOrderArr[$stuId])) {
- $stuDiffOrder[$stuId] = -($order - $preStuOrderArr[$stuId]);
- } else {
- $stuDiffOrder[$stuId] = 0;
- }
- }
- arsort($stuDiffOrder);
- foreach ($stuDiffOrder as $stuId => $num) {
- if ($num >= $diffNum) {
- $increaseArr[] = $stuId;
- }
- }
- $increaseArr = array_slice($increaseArr, 0, 5, true);
- asort($stuDiffOrder);
- foreach ($stuDiffOrder as $stuId => $num) {
- if ($num <= -$diffNum) {
- $reduceArr[] = $stuId;
- }
- }
- $reduceArr = array_slice($reduceArr, 0, 5, true);
- } else {
- $increaseArr = array_slice($stuOrderArr, 0, 5, true);
- $reduceArr = array();
- }
- $result['stu_diff_order'] = $stuDiffOrder;
- $result['stu_order'] = $stuOrderArr;
- $result['increase_stu'] = $increaseArr;
- $result['reduce_stu'] = $reduceArr;
- //前5名和后5名
- $font5 = $back5 = array();
- $i = 1;
- $fonrt5_order = array();
- foreach ($stuOrderArr as $stuId => $order) {
- if ($i <= 5) {
- $font5[] = $stuId;
- $fonrt5_order[] = $order;
- } else {
- break;
- }
- $i++;
- }
- $result['font_five'] = $font5;
- $i = 1;
- //删除前5排名
- $_stuOrderArr = $stuOrderArr;
- foreach ($_stuOrderArr as $k => $order) {
- if (in_array($order, $fonrt5_order)) {
- unset($_stuOrderArr[$k]);
- }
- }
- arsort($_stuOrderArr);
- foreach ($_stuOrderArr as $stuId => $order) {
- if ($i <= 5) {
- $back5[] = $stuId;
- } else {
- break;
- }
- $i++;
- }
- $result['back_five'] = $back5;
- //学生名称
- $stuInfoObj = new SStudentInfo();
- $stuName = $stuInfoObj->getStudentNames(array_keys($stuOrderArr));
- $result['stu_name'] = $stuName;
- unset($stuOrderArr);
- return $result;
- }
- /**
- * 考试情况分析
- * @param $stuRs
- * @param $topicScore
- * @param $topicNo
- * @return array
- */
- private function getExamAnalyse(&$stuRs, $paperTopicScore, $topicNo, $paperId, $topicRelLarge)
- {
- $result = array();
- $stuTopicWrong = array();//题答错人数
- $topicScoreRate = array();//题得分率
- $topicScoring = array();//题得分
- $topicScore = array();//题分
- foreach ($stuRs as $stuId => $rs) {
- foreach ($rs as $v) {
- // if($paperId == $v['paper_id']){
- if (strcmp($paperId, $v['paper_id']) == 0) {
- if (isset($topicRelLarge[$v['topic_id']]) && $topicRelLarge[$v['topic_id']] > 0) {
- $t_id = $topicRelLarge[$v['topic_id']];
- } else {
- $t_id = $v['topic_id'];
- }
- $t_score = isset($paperTopicScore[$t_id]) ? $paperTopicScore[$t_id] : 0;
- if (!isset($topicScoring[$t_id])) {
- $topicScoring[$t_id] = 0;
- }
- $topicScoring[$t_id] += $v['scoring'];
- if (!isset($topicScore[$t_id])) {
- $topicScore[$t_id] = 0;
- }
- $topicScore[$t_id] += $t_score;
- if (!isset($stuTopicWrong[$t_id])) {
- $stuTopicWrong[$t_id] = array();
- }
- if ($t_score != $v['scoring']) {
- $stuTopicWrong[$t_id][] = $stuId;
- }
- }
- }
- }
- //题得分率
- foreach ($topicScoring as $topicId => $scoring) {
- if (isset($topicScore[$topicId]) && $topicScore[$topicId] > 0) {
- $topicScoreRate[$topicId] = round($scoring / $topicScore[$topicId], 4) * 100;
- } else {
- $topicScoreRate[$topicId] = 0;
- }
- }
- unset($topicScoring);
- //答错人数
- if ($stuTopicWrong) {
- foreach ($stuTopicWrong as $key => $stuIds) {
- $stuIds = array_unique($stuIds);
- $stuTopicWrong[$key] = count($stuIds);
- }
- }
- $result['stu_topic_wrong'] = $stuTopicWrong;
- $result['topic_score_rate'] = $topicScoreRate;
- $result['topic_no'] = $topicNo;
- unset($stuTopicWrong);
- unset($topicScoreRate);
- unset($topicNo);
- unset($topicScore);
- return $result;
- }
- //题类型掌握情况
- private function getTopicTypeAnaly(&$stuRs, $topicScore, $topicNo, $paperId, $topicLogicType, $topicRelLarge, $smallTopicNo)
- {
- $result = array();
- $getTopicTypeRelate = $this->getTopicTypeRelate();
- $gradeRate = $classRate = array();//班级和年级得分率
- $stuTypeWrong = array();//题型答错人数
- $typeTopicNo = array();//题型对应的题号
- $typeMasterDegree = array();//题型掌握水平
- $typeName = $this->typeName;
- $logicTypeName = $this->logicTypeName;
- $gradeScoreArr = $classScoreArr = array();
- $gradeScoring = $classScoring = array();
- $_gradeScore = $_classScore = array();
- $_gradeScoring = $_classScoring = array();
- $typeNameArr = array();
- $allClassScore = $allClassScoring = array();
- $paperScoreSum = array();
- //优化strcmp($paperId ,$value['paper_id']) == 0
- $paperIndexArr = array();
- foreach ($stuRs as $stuId => $rs) {
- foreach ($rs as $value) {
- $paperIndexArr[$value['paper_id']] = 0;
- }
- }
- if ($paperIndexArr) {
- $paperIndexArr = array_keys($paperIndexArr);
- $paperIndexArr = array_flip($paperIndexArr);
- }
- //当前paper_id的索引
- $curPaperIndex = isset($paperIndexArr[$paperId]) ? $paperIndexArr[$paperId] : false;
- foreach ($stuRs as $stuId => $rs) {
- foreach ($rs as $k => $value) {
- $tId = $value['topic_id'];
- $t_score = isset($topicScore[$value['topic_id']]) ? $topicScore[$value['topic_id']] : 0;
- if (isset($topicLogicType[$value['topic_id']]) && $topicLogicType[$value['topic_id']] > 0) {
- $type = $topicLogicType[$value['topic_id']];
- if ($this->subjectId == 9) {
- $typeArr = explode('_', $type);
- if (count($typeArr) > 1) {
- $type = $typeArr[0];
- }
- }
- if ($this->subjectId == 8) {
- if (isset($getTopicTypeRelate[$type])) {
- $type = $getTopicTypeRelate[$type];
- }
- }
- $typeNameArr[$type] = isset($logicTypeName[$type]) ? $logicTypeName[$type] : '';
- } else {
- $type = $value['type'];
- $typeNameArr[$type] = isset($typeName[$type]) ? $typeName[$type] : '';
- }
- if (!isset($gradeScoring[$type])) {
- $gradeScoring[$type] = array();
- }
- $gradeScoring[$type][] = $value['scoring'];
- if (!isset($gradeScoreArr[$type])) {
- $gradeScoreArr[$type] = 0;
- }
- $gradeScoreArr[$type] += $t_score;
- if (!isset($_gradeScoring[$tId])) {
- $_gradeScoring[$tId] = 0;
- }
- $_gradeScoring[$tId] += $value['scoring'];
- if (!isset($_gradeScore[$tId])) {
- $_gradeScore[$tId] = 0;
- }
- $_gradeScore[$tId] += $t_score;
- //当前班级
- // if(strcmp($paperId ,$value['paper_id']) == 0){
- if (isset($paperIndexArr[$value['paper_id']]) && $paperId !== false && $paperIndexArr[$value['paper_id']] == $curPaperIndex) {
- if (!isset($classScoring[$type])) {
- $classScoring[$type] = 0;
- }
- $classScoring[$type] += $value['scoring'];
- if (!isset($classScoreArr[$type])) {
- $classScoreArr[$type] = 0;
- }
- $classScoreArr[$type] += $t_score;
- if (!isset($stuTypeWrong[$type])) {
- $stuTypeWrong[$type] = array();
- }
- if (!isset($stuTypeWrong[$type][$stuId])) {
- $stuTypeWrong[$type][$stuId] = array(
- 'scoring' => 0,
- 'score' => 0,
- );
- }
- $stuTypeWrong[$type][$stuId]['scoring'] += $value['scoring'];
- $stuTypeWrong[$type][$stuId]['score'] += $t_score;
- if (!isset($typeTopicNo[$type])) {
- $typeTopicNo[$type] = array();
- }
- //小题得分率
- if (!isset($_classScoring[$tId])) {
- $_classScoring[$tId] = 0;
- }
- $_classScoring[$tId] += $value['scoring'];
- if (!isset($_classScore[$tId])) {
- $_classScore[$tId] = 0;
- }
- $_classScore[$tId] += $t_score;
- if (!isset($typeTopicNo[$type])) {
- $typeTopicNo[$type] = array();
- }
- // if(isset($topicNo[$value['topic_id']])){
- // $typeTopicNo[$type][] = $topicNo[$value['topic_id']];
- // }
- }
- //所以班级
- $pId = $value['paper_id'];
- if (!isset($allClassScoring[$pId])) {
- $allClassScoring[$pId] = array();
- }
- if (!isset($allClassScoring[$pId][$type])) {
- $allClassScoring[$pId][$type] = 0;
- }
- $allClassScoring[$pId][$type] += $value['scoring'];
- if (!isset($allClassScore[$pId])) {
- $allClassScore[$pId] = array();
- }
- if (!isset($allClassScore[$pId][$type])) {
- $allClassScore[$pId][$type] = 0;
- }
- $allClassScore[$pId][$type] += $t_score;
- if (!isset($paperScoreSum[$pId])) {
- $paperScoreSum[$pId] = 0;
- }
- $paperScoreSum[$pId] += $t_score;
- }
- }
- //年级得分率
- foreach ($gradeScoring as $type => $scorings) {
- if (isset($gradeScoreArr[$type]) && $gradeScoreArr[$type]) {
- $gradeRate[$type] = round(array_sum($scorings) / $gradeScoreArr[$type], 2) * 100;
- } else {
- $gradeRate[$type] = 0;
- }
- }
- //班级得分率
- foreach ($classScoring as $type => $scoring) {
- if (isset($classScoreArr[$type]) && $classScoreArr[$type] > 0) {
- $classRate[$type] = round($scoring / $classScoreArr[$type], 2) * 100;
- } else {
- $classRate[$type] = 0;
- }
- }
- //小题
- //年级得分率
- $_gradeRate = array();
- foreach ($_gradeScoring as $tId => $scoring) {
- if (isset($_gradeScore[$tId]) && $_gradeScore[$tId]) {
- $_gradeRate[$tId] = round($scoring / $_gradeScore[$tId], 2) * 100;
- } else {
- $_gradeRate[$tId] = 0;
- }
- }
- //班级得分率
- $_classRate = array();
- foreach ($_classScoring as $tId => $scoring) {
- if (isset($_classScore[$tId]) && $_classScore[$tId] > 0) {
- $_classRate[$tId] = round($scoring / $_classScore[$tId], 2) * 100;
- } else {
- $_classRate[$tId] = 0;
- }
- }
- //题型对应题号排序
- foreach ($typeTopicNo as $type => $nos) {
- asort($nos);
- $typeTopicNo[$type] = array_unique($nos);
- }
- //题型掌握水平: 85%包括85%以上,5星;75%-85%,包括75%,4星。65%-75%,包括65%,3星;55%-65%,包括55%,2星;55%以下1星。
- foreach ($classRate as $type => $rate) {
- if ($rate >= 85) {
- $typeMasterDegree[$type] = 5;
- } elseif ($rate < 85 && $rate >= 75) {
- $typeMasterDegree[$type] = 4;
- } elseif ($rate < 75 && $rate >= 65) {
- $typeMasterDegree[$type] = 3;
- } elseif ($rate < 65 && $rate >= 55) {
- $typeMasterDegree[$type] = 2;
- } else {
- $typeMasterDegree[$type] = 1;
- }
- }
- //所有班级得分率
- $allClassRate = array();
- foreach ($allClassScoring as $pId => $scoringArr) {
- foreach ($scoringArr as $type => $scoring) {
- if (isset($allClassScore[$pId]) && isset($allClassScore[$pId][$type]) && $allClassScore[$pId][$type] > 0) {
- $allClassRate[$pId][$type] = round($scoring / $allClassScore[$pId][$type], 4) * 100;
- } else {
- $allClassRate[$pId][$type] = 0;
- }
- }
- }
- //班级题型/试卷总分
- $typePaperRate = array();
- foreach ($allClassScoring as $pId => $scoringArr) {
- foreach ($scoringArr as $type => $scoring) {
- $paperScore = isset($paperScoreSum[$pId]) ? $paperScoreSum[$pId] : 0;
- if ($paperScore > 0) {
- $typePaperRate[$pId][$type] = round($scoring / $paperScore, 4) * 100;
- } else {
- $typePaperRate[$pId][$type] = 0;
- }
- }
- }
- //题型答错人数
- foreach ($stuTypeWrong as $type => $stuScore) {
- $wrongNum = 0;
- foreach ($stuScore as $stuId => $score) {
- if ($score['score'] != $score['scoring']) {
- $wrongNum++;
- }
- }
- $stuTypeWrong[$type] = $wrongNum;
- }
- $result['class_rate'] = $classRate;
- $result['grade_rate'] = $gradeRate;
- $result['all_class_rate'] = $allClassRate;
- $result['type_paper_rate'] = $typePaperRate;
- $result['stu_type_wrong'] = $stuTypeWrong;
- $result['type_topic_no'] = $typeTopicNo;
- $result['type_master_degree'] = $typeMasterDegree;
- $result['type_name_arr'] = $typeNameArr;
- $result['topic_grade_rate'] = $_gradeRate;
- $result['topic_class_rate'] = $_classRate;
- return $result;
- }
- /**
- * 试题年级和班级得分率,答对和答错人数
- * @param $stuRs
- * @param $topicScore
- * @param $paperId
- * @return array
- */
- public function getTopicRateWrongPerson(&$stuRs, $topicScore, $paperId, &$stuIdsArr, $topicRelLarge, $choinceIds, $sutName, $topicLogicType)
- {
- $gradeRate = $classRate = array();//班级和年级得分率
- $wrongStu = $rightStu = array();//答对答错人数
- $isChoiceTopic = array();
- $stuNormalIds = array();
- foreach ($stuIdsArr as $stuIds) {
- foreach ($stuIds as $stuId) {
- $stuNormalIds[$stuId] = 0;
- }
- }
- $gradeScoring = $classScoring = array();
- $gradeScore = $classScore = array();
- $doneTopicNum = array();//每题做题总人数
- $stuScoring = $stuScore = array();
- $classTopicScoring = array();//班级题得分
- $choiceTopicWrong = array();//单选题答错统计
- $stuLargeTopicScore = array();//学生大题得分统计
- $largeContainScore = array();
- $readingTopicIds = array();
- $readingWrongStu = array();
- //优化strcmp($paperId ,$value['paper_id']) == 0
- $paperIndexArr = array();
- foreach ($stuRs as $stuId => $rs) {
- foreach ($rs as $value) {
- $paperIndexArr[$value['paper_id']] = 0;
- }
- }
- if ($paperIndexArr) {
- $paperIndexArr = array_keys($paperIndexArr);
- $paperIndexArr = array_flip($paperIndexArr);
- }
- //当前paper_id的索引
- $curPaperIndex = isset($paperIndexArr[$paperId]) ? $paperIndexArr[$paperId] : false;
- //阅读理解选项显示答错学生姓名
- foreach ($topicLogicType as $tId => $logicType) {
- if ($logicType == 3 || $logicType == 42) {
- $readingTopicIds[] = $tId;
- }
- }
- foreach ($stuRs as $stuId => $rs) {
- if (!isset($stuNormalIds[$stuId])) {
- continue;
- }
- foreach ($rs as $k => $value) {
- if (isset($topicRelLarge[$value['topic_id']]) && $topicRelLarge[$value['topic_id']] > 0) {
- $t_id = $topicRelLarge[$value['topic_id']];
- } else {
- $t_id = $value['topic_id'];
- }
- if (!isset($largeContainScore[$t_id])) {
- $largeContainScore[$t_id] = array();
- }
- $largeContainScore[$t_id][$value['topic_id']] = $topicScore[$value['topic_id']];
- if (!isset($stuLargeTopicScore[$stuId][$t_id])) {
- $stuLargeTopicScore[$stuId][$t_id] = array('scoring' => 0, 'score' => 0);
- }
- $stuLargeTopicScore[$stuId][$t_id]['scoring'] += $value['scoring'];
- $stuLargeTopicScore[$stuId][$t_id]['score'] += $topicScore[$value['topic_id']];
- $t_score = isset($topicScore[$value['topic_id']]) ? $topicScore[$value['topic_id']] : 0;
- if (!isset($gradeScoring[$t_id])) {
- $gradeScoring[$t_id] = 0;
- }
- $gradeScoring[$t_id] += $value['scoring'];
- if (!isset($gradeScore[$t_id])) {
- $gradeScore[$t_id] = 0;
- }
- $gradeScore[$t_id] += $t_score;
- // if(strcmp($paperId,$value['paper_id']) == 0){
- if (isset($paperIndexArr[$value['paper_id']]) && $paperId !== false && $paperIndexArr[$value['paper_id']] == $curPaperIndex) {
- if (!isset($classScoring[$t_id])) {
- $classScoring[$t_id] = 0;
- }
- $classScoring[$t_id] += $value['scoring'];
- if (!isset($classScore[$t_id])) {
- $classScore[$t_id] = 0;
- }
- $classScore[$t_id] += $t_score;
- if (!isset($wrongStu[$t_id])) {
- $wrongStu[$t_id] = array();
- }
- // if($t_score != $value['scoring']){
- // $wrongStu[$t_id][] = $stuId;
- // }
- if (!isset($doneTopicNum[$t_id])) {
- $doneTopicNum[$t_id] = array();
- }
- $doneTopicNum[$t_id][] = $stuId;
- //学生得分率
- if (!isset($stuScoring[$stuId])) {
- $stuScoring[$stuId] = array();
- }
- if (!isset($stuScoring[$stuId][$t_id])) {
- $stuScoring[$stuId][$t_id] = 0;
- }
- $stuScoring[$stuId][$t_id] += $value['scoring'];
- if (!isset($stuScore[$stuId])) {
- $stuScore[$stuId] = array();
- }
- if (!isset($stuScore[$stuId][$t_id])) {
- $stuScore[$stuId][$t_id] = 0;
- }
- $stuScore[$stuId][$t_id] += $t_score;
- //班级平均得分
- if (!isset($classTopicScoring[$t_id])) {
- $classTopicScoring[$t_id] = array();
- }
- $classTopicScoring[$t_id][] = $value['scoring'];
- //统计单选题答错人数
- if (isset($topicLogicType[$t_id]) && $topicLogicType[$t_id] == 1) {
- if ($value['is_right'] != 1 && in_array($value['answer'], array('A', 'B', 'C', 'D', 'E'))) {
- if (!isset($choiceTopicWrong[$t_id])) {
- $choiceTopicWrong[$t_id] = array();
- }
- if (!isset($choiceTopicWrong[$t_id][$value['answer']])) {
- $choiceTopicWrong[$t_id][$value['answer']] = 0;
- }
- $choiceTopicWrong[$t_id][$value['answer']]++;
- }
- }
- }
- if (in_array($value['topic_id'], $readingTopicIds)) {
- if (empty($value['is_right']) && $value['answer']) {
- if (!isset($readingWrongStu[$value['topic_id']])) {
- $readingWrongStu[$value['topic_id']][$value['answer']] = array();
- }
- if (isset($sutName[$stuId])) {
- $readingWrongStu[$value['topic_id']][$value['answer']][] = $sutName[$stuId];
- }
- }
- }
- }
- }
- //年级得分率
- foreach ($gradeScoring as $tId => $scorings) {
- if (isset($gradeScore[$tId]) && $gradeScore[$tId] > 0) {
- $gradeRate[$tId] = round($scorings / $gradeScore[$tId], 4) * 100;
- } else {
- $gradeRate[$tId] = 0;
- }
- }
- //班级得分率
- foreach ($classScoring as $tId => $scoring) {
- if (isset($classScore[$tId]) && $classScore[$tId] > 0) {
- $classRate[$tId] = round($scoring / $classScore[$tId], 4) * 100;
- } else {
- $classRate[$tId] = 0;
- }
- }
- //答错人数
- foreach ($stuScore as $stuId => $tScores) {
- if (isset($stuScoring[$stuId])) {
- foreach ($tScores as $tId => $score) {
- $_scoring = isset($stuScoring[$stuId][$tId]) ? $stuScoring[$stuId][$tId] : 0;
- if ($score != $_scoring) {
- $wrongStu[$tId][] = $stuId;
- }
- }
- }
- }
- if ($wrongStu) {
- foreach ($wrongStu as $key => $stuIds) {
- $stuIds = array_unique($stuIds);
- $wrongStu[$key] = count($stuIds);
- if (isset($doneTopicNum[$key])) {
- $_stuIds = array_unique($doneTopicNum[$key]);
- $rightStu[$key] = count($_stuIds) - $wrongStu[$key];
- }
- }
- }
- //题得分率低于70%的学
- $rateLess70 = array();
- if ($stuScoring) {
- foreach ($stuScoring as $stuId => $tScoring) {
- $stuScoreArr = isset($stuScore[$stuId]) ? $stuScore[$stuId] : array();
- foreach ($tScoring as $tId => $scoring) {
- if (!isset($rateLess70[$tId])) {
- $rateLess70[$tId] = array();
- }
- if (isset($stuScoreArr[$tId]) && $stuScoreArr[$tId] > 0) {
- $tempRate = round($scoring / $stuScoreArr[$tId], 4) * 100;
- } else {
- $tempRate = 0;
- }
- if (inArray($tId, $choinceIds)) {
- if ($tempRate < 100 && !inArray($stuId, $rateLess70[$tId])) {
- $rateLess70[$tId][] = $stuId;
- }
- $isChoiceTopic[] = $tId;
- } else {
- if ($tempRate < 70 && !inArray($stuId, $rateLess70[$tId])) {
- $rateLess70[$tId][] = $stuId;
- }
- }
- }
- }
- }
- foreach ($rateLess70 as $tId => $stuIds) {
- $nameArr = array();
- foreach ($stuIds as $stuId) {
- $nameArr[] = isset($sutName[$stuId]) ? $sutName[$stuId] : '';
- }
- $rateLess70[$tId] = implode('、', $nameArr);
- }
- //大题对应的小题个数
- $large_rel_count = array();
- foreach ($topicRelLarge as $tId => $ltId) {
- if (!isset($large_rel_count[$ltId])) {
- $large_rel_count[$ltId] = 0;
- }
- $large_rel_count[$ltId]++;
- }
- //班级平均分
- $classTopicAvg = array();
- foreach ($classTopicScoring as $tId => $scorings) {
- if ($scorings) {
- $classTopicAvg[$tId] = round(array_sum($scorings) / (count($scorings) / $large_rel_count[$tId]), 2);
- } else {
- $classTopicAvg[$tId] = 0;
- }
- }
- unset($classTopicScoring);
- //低于班级平均分
- $rateLessAvg = array();
- if ($stuScoring) {
- foreach ($stuScoring as $stuId => $tScoring) {
- foreach ($tScoring as $tId => $scoring) {
- if (!isset($rateLessAvg[$tId])) {
- $rateLessAvg[$tId] = array();
- }
- if (isset($classTopicAvg[$tId]) && $scoring < $classTopicAvg[$tId]) {
- $rateLessAvg[$tId][$stuId] = $scoring;
- }
- }
- }
- }
- foreach ($rateLessAvg as $tId => $stuScoring) {
- if ($stuScoring) {
- asort($stuScoring);
- $nameArr = array();
- foreach ($stuScoring as $stuId => $scoring) {
- $nameArr[] = isset($sutName[$stuId]) ? $sutName[$stuId] : '';
- }
- $rateLessAvg[$tId] = implode('、', $nameArr);
- } else {
- $rateLessAvg[$tId] = '';
- }
- }
- foreach ($readingWrongStu as $tId => $val) {
- foreach ($val as $option => $stuArr) {
- $readingWrongStu[$tId][$option] = implode('、', $stuArr);
- }
- }
- $result = array();
- $result['grade_rate'] = $gradeRate;
- $result['class_rate'] = $classRate;
- $result['wrong_stu'] = $wrongStu;
- $result['right_stu'] = $rightStu;
- $result['rate_less_70'] = $rateLess70;
- $result['rate_less_avg'] = $rateLessAvg;
- $result['is_choice_topic'] = $isChoiceTopic;
- $result['choice_topic_wrong'] = $choiceTopicWrong;
- $result['large_topic_score'] = $stuLargeTopicScore;
- $result['large_contain_score'] = $largeContainScore;
- $result['reading_wrong_stu'] = $readingWrongStu;
- $gradeScoring = $classScoring = array();
- $gradeScore = $classScore = array();
- $doneTopicNum = array();//每题做题总人数
- unset($gradeScoring);
- unset($classScoring);
- unset($gradeScore);
- unset($classScore);
- unset($doneTopicNum);
- unset($stuScoring);
- unset($stuScore);
- return $result;
- }
- /**
- * 获取学生排名
- * @param $examId
- * @param $ptrInfo
- * @return array
- */
- private function getStudentOrder($examId, &$ptrInfo, &$stuIdsArr)
- {
- $stuOrderArr = array();
- $stuScoring = array();
- foreach ($ptrInfo as $value) {
- // if($examId == $value['exam_id']){
- if (strcmp($examId, $value['exam_id']) == 0) {
- $stuIds = isset($stuIdsArr[$value['exam_id']]) ? $stuIdsArr[$value['exam_id']] : array();
- if (inArray($value['student_id'], $stuIds)) {
- $stuScoring[$value['student_id']] = $value['scoring'];
- }
- }
- }
- $scoringArr = array_values($stuScoring);
- foreach ($stuScoring as $stuId => $scoring) {
- $stuOrderArr[$stuId] = $this->getOrder($scoring, $scoringArr);
- }
- if ($stuOrderArr) {
- asort($stuOrderArr);
- }
- return $stuOrderArr;
- }
- /**
- * 获取排名
- * @param $ele
- * @param $arr
- * @return false|int|string
- */
- private function getOrder($ele, $arr)
- {
- $orderRs = 0;
- if ($arr) {
- arsort($arr);
- $arr = array_values($arr);
- $index = array_search($ele, $arr);
- $orderRs = $index + 1;
- }
- return $orderRs;
- }
- /**
- * 整理题详情
- * @param $allApiInfo
- * @return mixed
- * @throws CException
- */
- public function getTopicDetail($topicBatches)
- {
- $optionIndex = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K');
- $topicDetails = array();
- foreach ($topicBatches AS $topic) {
- $topic = (object)$topic;
- $type = $topic->type_id;
- 6 == $type && $type = 5; //6表示多空题,多空题也是5
- $topic->id = (string)$topic->id;
- $topicDetails[$topic->id] = array();
- $topicDetails[$topic->id]['is_large_topic'] = isset($topic->is_large_topic) ? $topic->is_large_topic : 0;
- $topicDetails[$topic->id]['type'] = $type;
- $topicDetails[$topic->id]['subject_id'] = $topic->subject_id;
- $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;
- $_methods = array();
- $_method_id_arr = array();
- $_method_names = 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;
- }
- if (isset($_method->method_id) && isset($_method->method_name)) {
- $_method_names[$_method->method_id] = $_method->method_name;
- }
- }
- $topicDetails[$topic->id]['methods'] = implode('|', array_unique($_methods));//考点
- $topicDetails[$topic->id]['method_id_arr'] = $_method_id_arr;
- $topicDetails[$topic->id]['method_names'] = $_method_names;
- }
- $_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 == 11) { //选择题有选项
- 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();
- $correct_answer_arr = array();
- foreach ($options AS $_optionIndex => $_option) {
- $_option = (object)$_option;
- $_tmp_options[$_optionIndex] = $this->topicProcess($_option->option_content);
- if ($_option->option_correct) {
- $correct_answer_arr[] = $this->topicProcess($optionIndex[$_optionIndex], true);
- // $topicDetails[$topic->id]['answer']=topicProcess($optionIndex[$_optionIndex]);
- }
- }
- $topicDetails[$topic->id]['answer'] = implode(',', $correct_answer_arr);
- $_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, true);
- }
- }
- }
- }
- }
- //大题的小题
- $topicDetails[$topic->id]['slave'] = array();
- if (isset($topic->slave) && $topic->slave) {
- $topicDetails[$topic->id]['answer'] = array();
- foreach ($topic->slave as $slave) {
- $slave = (object)$slave;
- $_slave = array();
- $_slave['topic_slave_id'] = (string)$slave->topic_slave_id;
- $_slave['type'] = $slave->topic_type;
- $_slave['methods'] = '';//考点
- $_slave['method_id_arr'] = '';//考点id数组
- $_slave['kps'] = '';//知识点
- $_slave['queBody'] = $this->topicProcess($slave->title);//题目详情
- $_slave['options'] = '';
- $_slave['answer'] = ''; //每题的正确答案
- // $_slave['analysis']=topicProcess($slave->parse_content);//答题解析
- // $_slave['teacher_tips']=topicProcess($slave->teacher_tips);//名师点评
- $_slave['difficulty_degree'] = isset($slave->difficulty_degree) ? $slave->difficulty_degree : null;
- $_slave['difficulty'] = $slave->difficulty;
- if ($slave->topic_type == 1 || $slave->topic_type == 11) { //选择题有选项
- if ($slave->items) {
- if (isset($slave->items)) {
- $slave->items = (object)$slave->items;
- if (isset($slave->items->options)) {
- $options = (object)$slave->items->options;
- if ($options) {
- $_tmp_options = array();
- $correct_answer_arr = array();
- foreach ($options AS $_optionIndex => $_option) {
- $_option = (object)$_option;
- $_tmp_options[$_optionIndex] = $this->topicProcess($_option->option_content);
- if ($_option->option_correct) {
- if (isset($_option->content_is_answer) && $_option->content_is_answer == 1) {
- $correct_answer_arr[] = $_option->option_content;
- } else {
- $correct_answer_arr[] = $this->topicProcess($optionIndex[$_optionIndex]);
- }
- }
- }
- $_slave['answer'] = implode(',', $correct_answer_arr);
- $topicDetails[$topic->id]['answer'][(string)$slave->topic_slave_id] = $_slave['answer'];
- $_list_type = (int)$slave->items->list_type;
- $_slave['options'] = $this->option_process($_tmp_options, $_list_type);
- }
- }
- }
- }
- } else {
- if ($slave->items) {
- if (isset($slave->items)) {
- $slave->items = (object)$slave->items;
- if (isset($slave->items->options)) {
- $options = (object)$slave->items->options;
- if ($options) {
- $_answer = '';
- foreach ($options as $v) {
- $_option = (object)$v;
- if (trim($_answer) != '') {
- $_answer .= ' ; ';
- }
- $_answer .= $_option->option_content;
- }
- $_slave['answer'] = $this->topicProcess($_answer, true);
- $topicDetails[$topic->id]['answer'][(string)$slave->topic_slave_id] = $_slave['answer'];
- }
- }
- }
- }
- }
- $topicDetails[$topic->id]['slave'][] = $_slave;
- }
- }
- }
- return $topicDetails;
- }
- /**
- *对选项的处理
- * @param $options
- * @param $list_type
- * @return string
- */
- public 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="<ul class='answer clearfix font8' style='margin-right:45px'>";
- $option_str = "";
- foreach ($options as $key => $option) {
- if ($option) {
- $option_str .= "<li style='width:100%;'>$option_index[$key].$option</li>";
- }
- }
- // $option_str.="</ul>";
- } elseif ($list_type == 1) { //横向排列,即1行4个
- // $option_str="<ul class='answer clearfix font8' style='margin-right:45px'>";
- $option_str = "";
- foreach ($options as $key => $option) {
- $option_str .= "<li class='fl'>$option_index[$key].$option</li>";
- }
- // $option_str.="</ul>";
- } elseif ($list_type == 2) { //1行2个
- // $option_str="<ul class='answer clearfix font8' style='margin-right:45px'>";
- $option_str = "";
- foreach ($options as $key => $option) {
- if ($key % 2 == 0) {
- $option1 = $options[$key];
- $option_str2 = "<li class='fl' style='width:50%;'>$option_index[$key].$option1</li>";
- $key1 = $key + 1;
- if (isset($options[$key1])) {
- $option2 = $options[$key1];
- $option_str2 .= "<li class='fl' style='width:50%;'>$option_index[$key1].$option2</li>";
- }
- $option_str .= $option_str2;
- } else {
- continue;
- }
- }
- // $option_str.="</ul>";
- }
- return $option_str;
- }
- public function topicProcess($html, $isAnswer = false)
- {
- if ($this->subjectId == 8 && !$this->isThird && !$isAnswer) {
- $html = preg_replace('/<br\/*>/', '', $html);
- return $html;
- }
- 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;
- }
- public function img_process($img)
- {
- $widthArr = array();
- $heightArr = array();
- $width = '';
- $height = '';
- preg_match('/[\s\'"]width\s*:\s*(\d+\.*\d*)\s*([a-zA-Z]+)*/si', $img, $widthArr);
- if ($widthArr) {
- $width = $this->length_process($widthArr);
- } else {
- preg_match('/[\s\'"]width\s*=\s*[\'"]\s*(\d+\.*\d*)\s*([a-zA-Z]+)*;?[\'"]/si', $img, $widthArr);
- if ($widthArr) {
- $width = $this->length_process($widthArr);
- }
- }
- if ($width) {
- $width = "width=" . $width;
- }
- preg_match('/[\s\'"]height\s*:\s*(\d+\.*\d*)\s*([a-zA-Z]+)*/si', $img, $heightArr);
- if ($heightArr) {
- $height = $this->length_process($heightArr);
- } else {
- preg_match('/[\s\'"]height\s*=\s*[\'"]\s*(\d+\.*\d*)\s*([a-zA-Z]+)*;?[\'"]/si', $img, $heightArr);
- if ($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;
- }
- public function length_process($length_arr)
- {
- $units = array(
- 'in' => 96,
- 'cm' => 28,
- 'mm' => 2.8,
- 'pt' => 1.33,
- 'pc' => 12,
- );
- $length = 0.6 * $length_arr[1];
- $unit_keys = array_keys($units);
- if (isset($length_arr[2])) {
- //将直接连接单位改为 单位换算
- if (in_array($length_arr[2], $unit_keys)) {
- $length = $length * $units[$length_arr[2]];
- } else {
- $length .= $length_arr[2];
- }
- }
- return $length;
- }
- protected function getTopicTypeRateImg(&$typeMasterData, $examId, $paperId)
- {
- $imgPath = str_replace("protected", "", Yii::app()->basePath) . 'assets/temp_img/';
- $urlPath = Yii::app()->request->hostInfo . '/assets/temp_img/';
- if (!is_dir($imgPath)) {
- if (!mkdir($imgPath, 0777, true)) {
- exit('Create directory fail: ' . $imgPath);
- }
- }
- $data = array();
- foreach ($typeMasterData['grade_rate'] as $type => $rate) {
- if (!isset($data[$type])) {
- $data[$type] = array();
- }
- $data[$type]['type_name'] = isset($typeMasterData['type_name_arr'][$type]) ? $typeMasterData['type_name_arr'][$type] : array();
- $data[$type]['class_rate'] = isset($typeMasterData['class_rate'][$type]) ? $typeMasterData['class_rate'][$type] : array();
- //当前班级得分率坐标
- $data[$type]['all_class_rate'] = array();
- foreach ($typeMasterData['all_class_rate'] as $pId => $rates) {
- foreach ($rates as $ty => $_rate) {
- if ($ty == $type) {
- $data[$type]['all_class_rate'][] = $_rate;
- // if($paperId == $pId){
- if (strcmp($paperId, $pId) == 0) {
- $data[$ty]['curr_rate_x'] = $_rate;
- }
- }
- }
- }
- $data[$type]['type_paper_rate'] = array();
- foreach ($typeMasterData['type_paper_rate'] as $pId => $rates) {
- foreach ($rates as $ty => $_rate) {
- if ($ty == $type) {
- // if($paperId == $pId){
- if (strcmp($paperId, $pId) == 0) {
- $data[$ty]['curr_rate_y'] = $_rate;
- }
- $data[$type]['type_paper_rate'][] = $_rate;
- }
- }
- }
- }
- //复制我班的数据
- foreach ($data as $type => $rates) {
- foreach ($rates['type_paper_rate'] as $rate) {
- $data[$type]['my_class_rate'][] = $rates['curr_rate_x'];
- }
- }
- $typeRateImgPath = array();
- $typeRateImgUrl = array();
- foreach ($data as $type => $value) {
- $tempPath = $imgPath . $examId . "_" . $type . ".png";
- $this->imgArr[] = $tempPath;
- $bool = $this->getScatterImage($value, $tempPath);
- if ($bool) {
- $typeRateImgUrl[$type] = $urlPath . $examId . "_" . $type . ".png";
- }
- }
- return $typeRateImgUrl;
- }
- protected function getScatterImage($data, $imgPath)
- {
- /* Create the pData object */
- $myData = new pData();
- /* Create the X axis and the binded series */
- // for ($i=0;$i<=10;$i=$i+1) { $myData->addPoints(rand(1,20),"Probe 1"); }
- // for ($i=0;$i<=10;$i=$i+1) { $myData->addPoints(rand(1,20),"Probe 2"); }
- foreach ($data['all_class_rate'] as $v) {
- $myData->addPoints($v, "Probe 1");
- }
- foreach ($data['my_class_rate'] as $v) {
- $myData->addPoints($v, "Probe 2");
- }
- $myData->setAxisName(0, "总得分率");
- $myData->setAxisXY(0, AXIS_X);
- $myData->setAxisPosition(0, AXIS_POSITION_BOTTOM);
- /* Create the Y axis and the binded series */
- // for ($i=0;$i<=10;$i=$i+1) { $myData->addPoints(rand(1,20),"Probe 3"); }
- foreach ($data['type_paper_rate'] as $v) {
- $myData->addPoints($v, "Probe 3");
- }
- foreach ($data['type_paper_rate'] as $v) {
- $myData->addPoints($data['curr_rate_y'], "Probe 4");
- }
- $myData->setSerieOnAxis("Probe 3", 1);
- $myData->setAxisName(1, $data['type_name'] . "得分率");
- $myData->setAxisXY(1, AXIS_Y);
- $myData->setAxisPosition(1, AXIS_POSITION_LEFT);
- /* Create the 1st scatter chart binding */
- $myData->setScatterSerie("Probe 1", "Probe 3", 0);
- $myData->setScatterSerieDescription(0, "其它班级");
- $myData->setScatterSerieColor(0, array("R" => 0, "G" => 0, "B" => 0));
- // $myData->setScatterSerieColor(0,array("R"=>255,"G"=>255,"B"=>255));
- $myData->setScatterSerieShape(0, SERIE_SHAPE_TRIANGLE);
- //========================================================
- $myData->setSerieOnAxis("Probe 4", 1);
- // $myData->setAxisName(1,$data['type_name']."得分率");
- // $myData->setAxisXY(1,AXIS_Y);
- // $myData->setAxisPosition(1,AXIS_POSITION_LEFT);
- /* Create the 2nd scatter chart binding */
- $myData->setScatterSerie("Probe 2", "Probe 4", 1);
- $myData->setScatterSerieDescription(1, "我班");
- $myData->setScatterSerieShape(1, SERIE_SHAPE_FILLEDTRIANGLE);
- /* Create the pChart object */
- $myPicture = new pImage(800, 400, $myData);
- /* Turn of Anti-aliasing */
- $myPicture->Antialias = FALSE;
- /* Add a border to the picture */
- // $myPicture->drawRectangle(0,0,399,399,array("R"=>0,"G"=>0,"B"=>0));
- /* Set the default font */
- $myPicture->setFontProperties(array("FontName" => str_replace("protected", "", Yii::app()->basePath) . "fonts/pChart/msyh.ttf", "FontSize" => 8));
- /* Set the graph area */
- $myPicture->setGraphArea(40, 20, 760, 360);
- /* Create the Scatter chart object */
- $myScatter = new pScatter($myPicture, $myData);
- /* Draw the scale */
- $scaleSettings = array("XMargin" => 15, "YMargin" => 15, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE);
- $myScatter->drawScatterScale($scaleSettings);
- /* Draw the legend */
- $myScatter->drawScatterLegend(650, 388, array("Mode" => LEGEND_HORIZONTAL, "Style" => LEGEND_NOBORDER));
- $myPicture->drawText(100, 20, "总分与{$data['type_name']}成绩", array("FontSize" => 10, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
- $myPicture->drawText(80, 50, "总分低,", array("FontSize" => 8, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
- $myPicture->drawText(80, 60, "{$data['type_name']}高", array("FontSize" => 8, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
- $myPicture->drawText(720, 340, "总分高,", array("FontSize" => 8, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
- $myPicture->drawText(720, 350, "{$data['type_name']}低", array("FontSize" => 8, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
- //用例图标
- // $myPicture->drawRectangle(250,385,256,391,array("R"=>0,"G"=>0,"B"=>0));
- $xNum = 91;
- $yNum = 315;
- // $myPicture->drawFilledRectangle($xNum,$yNum,$xNum + 6,$yNum + 6,array("R"=>0,"G"=>0,"B"=>0));
- // $myPicture->drawFilledCircle($data['curr_rate_x'] + $xNum,$yNum - $data['curr_rate_x'],3,array("R"=>0,"G"=>0,"B"=>0));
- //画线
- arsort($data['all_class_rate']);
- $maxAllRate = round(current($data['all_class_rate']));
- arsort($data['type_paper_rate']);
- $maxTypePaper = round(current($data['type_paper_rate']));
- // $myPicture->drawLine($xNum + $maxAllRate,15,$xNum + $maxAllRate,315,array("R"=>0,"G"=>0,"B"=>0));
- $myPicture->drawLine($xNum + $maxAllRate + 5, 35, $xNum + $maxAllRate + 5, 345, array("R" => 0, "G" => 0, "B" => 0));
- $myPicture->drawLine($xNum + $maxAllRate - 5, 35, $xNum + $maxAllRate - 5, 345, array("R" => 0, "G" => 0, "B" => 0));
- $myPicture->drawLine(55, ($yNum - $maxTypePaper) + 5, 745, ($yNum - $maxTypePaper) + 5, array("R" => 0, "G" => 0, "B" => 0));
- $myPicture->drawLine(55, ($yNum - $maxTypePaper) - 5, 745, ($yNum - $maxTypePaper) - 5, array("R" => 0, "G" => 0, "B" => 0));
- /* Draw a scatter plot chart */
- $myPicture->Antialias = TRUE;
- $myScatter->drawScatterPlotChart();
- /* Render the picture (choose the best way) */
- // $myPicture->autoOutput("pictures/example.example.drawScatterShape.png");
- $myPicture->render($imgPath);
- // $myPicture->autoOutput($imgPath);die;
- return $imgPath;
- }
- //考点掌握情况
- protected function getMethodCount(&$stuRs, &$pramas)
- {
- list($smallTopicScore, $smallTopicNo, $paperId, $topicType, $topicLogicType, $topicRelLarge, $topicRelMethod, $largeTopicMethod, $sutName, $sutOrder, $methodName) = $pramas;
- $gradeScoring = $gradeScore = array();
- $classScoring = $classScore = array();
- $rightNum = $wrongNum = array();
- $methodRelNo = array();
- $diffStu = array();//考点较差学生
- $classDiffStu = array();//班级排名后25%学生的薄弱考点
- $methodRelType = array();//考点对应的题型
- $typeNameArr = array();//考点对应的题型
- $back25Rate = array();
- $reStuOrder = $sutOrder;
- $stuCount = count($reStuOrder);
- $stuCount = ceil($stuCount * 0.25);
- arsort($reStuOrder);
- $reStuOrder = array_slice($reStuOrder, 0, $stuCount);
- $typeName = $this->typeName;
- $logicTypeName = $this->logicTypeName;
- foreach ($stuRs as $sId => $value) {
- foreach ($value as $tId => $v) {
- if (isset($topicRelMethod[$tId]) && $topicRelMethod[$tId]) {
- foreach ($topicRelMethod[$tId] as $methodId) {
- if (!$methodId) continue;
- if (isset($topicLogicType[$tId]) && $topicLogicType[$tId] > 0) {
- $type = (int)$topicLogicType[$tId];
- $typeNameArr[$type] = isset($logicTypeName[$type]) ? $logicTypeName[$type] : '';
- } else {
- $type = $v['type'];
- $typeNameArr[$type] = isset($typeName[$type]) ? $typeName[$type] : '';
- }
- $methodRelType[$methodId] = $type;
- $tScore = isset($smallTopicScore[$tId]) ? $smallTopicScore[$tId] : 0;
- if ($tScore) {
- $stuRate = round($v['scoring'] / $tScore, 4) * 100;
- } else {
- $stuRate = 0;
- }
- //年级
- if (!isset($gradeScoring[$methodId])) {
- $gradeScoring[$methodId] = 0;
- }
- $gradeScoring[$methodId] += $v['scoring'];
- if (!isset($gradeScore[$methodId])) {
- $gradeScore[$methodId] = 0;
- }
- $gradeScore[$methodId] += $tScore;
- //班级
- // if($paperId == $v['paper_id']){
- if (strcmp($paperId, $v['paper_id']) == 0) {
- if (!isset($classScoring[$methodId])) {
- $classScoring[$methodId] = 0;
- }
- $classScoring[$methodId] += $v['scoring'];
- if (!isset($classScore[$methodId])) {
- $classScore[$methodId] = 0;
- }
- $classScore[$methodId] += $tScore;
- //对错人数
- if ($v['is_right'] == 1) {
- if (!isset($rightNum[$methodId])) {
- $rightNum[$methodId] = array();
- }
- $rightNum[$methodId][] = $sId;
- } else {
- if (!isset($wrongNum[$methodId])) {
- $wrongNum[$methodId] = array();
- }
- $wrongNum[$methodId][] = $sId;
- }
- //薄弱考点掌握较差学生
- if (!isset($diffStu[$methodId])) {
- $diffStu[$methodId] = array();
- }
- if ($stuRate <= 40) {
- if (!inArray($sId, $diffStu[$methodId])) {
- $diffStu[$methodId][] = $sId;
- }
- }
- }
- //班级排名后25%学生的薄弱考点
- if (isset($reStuOrder[$sId])) {
- if (!isset($classDiffStu[$sId])) {
- $classDiffStu[$sId] = array();
- }
- if ($stuRate <= 40) {
- if (!inArray($methodId, $classDiffStu[$sId])) {
- $classDiffStu[$sId][] = $methodId;
- }
- }
- }
- }
- }
- }
- }
- //年级得分率
- $gradeRate = array();
- if ($gradeScoring) {
- foreach ($gradeScoring as $mId => $scoring) {
- if (isset($gradeScore[$mId]) && $gradeScore[$mId]) {
- $gradeRate[$mId] = round($scoring / $gradeScore[$mId], 4) * 100;
- } else {
- $gradeRate[$mId] = 0;
- }
- }
- }
- //年级得分率
- $classRate = array();
- if ($classScoring) {
- foreach ($classScoring as $mId => $scoring) {
- if (isset($classScore[$mId]) && $classScore[$mId]) {
- $classRate[$mId] = round($scoring / $classScore[$mId], 4) * 100;
- } else {
- $classRate[$mId] = 0;
- }
- }
- }
- //对错人数
- foreach ($rightNum as $mId => $stuIds) {
- $rightNum[$mId] = count(array_unique($stuIds));
- }
- foreach ($wrongNum as $mId => $stuIds) {
- $wrongNum[$mId] = count(array_unique($stuIds));
- }
- //考点对应题号
- foreach ($topicRelMethod as $tId => $mIds) {
- if (isset($smallTopicNo[$tId]) && $smallTopicNo[$tId]) {
- foreach ($mIds as $mId) {
- if ($mId) {
- if (!isset($methodRelNo[$mId])) {
- $methodRelNo[$mId] = array();
- }
- $methodRelNo[$mId][] = $smallTopicNo[$tId];
- }
- }
- }
- }
- //题号数组转成字符串
- foreach ($methodRelNo as $mId => $nos) {
- asort($nos);
- $methodRelNo[$mId] = $nos;
- }
- //题型掌握水平: 85%包括85%以上,5星;75%-85%,包括75%,4星。65%-75%,包括65%,3星;55%-65%,包括55%,2星;55%以下1星。
- $masterDegree = array();
- foreach ($classRate as $mId => $rate) {
- if ($rate >= 85) {
- $masterDegree[$mId] = 5;
- } elseif ($rate < 85 && $rate >= 75) {
- $masterDegree[$mId] = 4;
- } elseif ($rate < 75 && $rate >= 65) {
- $masterDegree[$mId] = 3;
- } elseif ($rate < 65 && $rate >= 55) {
- $masterDegree[$mId] = 2;
- } else {
- $masterDegree[$mId] = 1;
- }
- }
- //薄弱考点掌握较差学生
- foreach ($diffStu as $mId => $stuIds) {
- $stuNameArr = array();
- foreach ($stuIds as $stuId) {
- $stuNameArr[$stuId] = isset($sutName[$stuId]) ? $sutName[$stuId] : '';
- }
- $diffStu[$mId] = implode(',', $stuNameArr);
- }
- //考点顺序按班级得分率升序进行。
- asort($classRate);
- $typeRelMethod = array();
- foreach ($classRate as $mId => $rate) {
- if (isset($methodRelType[$mId])) {
- if (!isset($typeRelMethod[$methodRelType[$mId]])) {
- $typeRelMethod[$methodRelType[$mId]] = array();
- }
- $typeRelMethod[$methodRelType[$mId]][] = $mId;
- }
- }
- //班级排名后25%学生的薄弱考点
- foreach ($classDiffStu as $stuId => $mIds) {
- // asort($mIds);
- $mName = array();
- foreach ($mIds as $mId) {
- if (isset($methodName[$mId]) && $methodName[$mId]) {
- $mName[] = $methodName[$mId];
- }
- }
- $classDiffStu[$stuId] = implode('、', $mName);
- }
- $result = array(
- 'grade_rate' => $gradeRate,
- 'class_rate' => $classRate,
- 'method_rel_no' => $methodRelNo,
- 'master_degree' => $masterDegree,
- 'right_num' => $rightNum,
- 'wrong_num' => $wrongNum,
- 'diff_stu' => $diffStu,
- 'class_diff_stu' => $classDiffStu,
- 'type_rel_method' => $typeRelMethod,
- 'type_name_arr' => $typeNameArr,
- );
- return $result;
- }
- protected function getImage($ratePath, $timeMethodRate)
- {
- /* Create and populate the pData object */
- $MyData = new pData();
- $i = 1;
- foreach ($timeMethodRate as $arr) {
- $MyData->addPoints($arr, "Probe {$i}");
- $i++;
- if ($i > 3) {
- break;
- }
- }
- // $MyData->addPoints(array(4,1,2,12,8,3),"Probe 1");
- // $MyData->addPoints(array(3,12,15,8,5,5),"Probe 2");
- // $MyData->addPoints(array(2,7,5,18,19,22),"Probe 3");
- $MyData->setSerieTicks("Probe 2", 4);
- $MyData->setSerieWeight("Probe 3", 2);
- $MyData->setAxisName(0, "得分率");
- $MyData->addPoints(array("上上次", "上次", "本次"), "Labels");
- $MyData->setSerieDescription("Labels", "Months");
- $MyData->setAbscissa("Labels");
- $MyData->setSerieShape(0, SERIE_SHAPE_TRIANGLE);
- /* Create the pChart object */
- $myPicture = new pImage(700, 230, $MyData);
- /* Turn of Antialiasing */
- $myPicture->Antialias = FALSE;
- /* Add a border to the picture */
- $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
- /* Write the chart title */
- $myPicture->setFontProperties(array("FontName" => str_replace("protected", "", Yii::app()->basePath) . "fonts/pChart/msyh.ttf", "FontSize" => 11));
- $myPicture->drawText(150, 35, "考点掌握情况变化趋势", array("FontSize" => 12, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
- /* Set the default font */
- $myPicture->setFontProperties(array("FontName" => str_replace("protected", "", Yii::app()->basePath) . "fonts/pChart/msyh.ttf", "FontSize" => 8));
- /* Define the chart area */
- $myPicture->setGraphArea(60, 40, 650, 200);
- /* Draw the scale */
- $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE);
- $myPicture->drawScale($scaleSettings);
- /* Turn on Antialiasing */
- $myPicture->Antialias = false;
- /* Draw the line chart */
- // $myPicture->drawLineChart();
- $myPicture->drawLineChart(array("ForceColor" => true, "ForceR" => 0, "ForceG" => 0, "ForceB" => 0, "ForceAlpha" => 80));
- $myPicture->drawPlotChart(array("DisplayValues" => TRUE, "PlotBorder" => TRUE, "BorderSize" => 2, "Surrounding" => -60, "BorderAlpha" => 80));
- /* Write the chart legend */
- $myPicture->drawLegend(510, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
- /* Render the picture (choose the best way) */
- // $myPicture->autoOutput($ratePath);die;
- $myPicture->render($ratePath);
- }
- /**
- * 删除生成的图片
- */
- private function delCreateImgs()
- {
- if ($this->imgArr && is_array($this->imgArr)) {
- foreach ($this->imgArr as $path) {
- if (file_exists($path)) {
- @unlink($path);
- }
- }
- }
- }
- /**
- * 获取试题内容参数
- * @param $topicIds
- * @return array
- */
- private function getEnglishTopic($topicIds)
- {
- $result = array('status' => 0, 'error' => array('无题'));
- // $topicIds = array(1821);
- // $topicIds = array(20001908);
- $param = array(
- 'size' => count($topicIds),
- 'query' => array(
- 'bool' => array(
- 'must' => array(
- array(
- 'match' => array(
- 'status' => array(
- 'query' => 1,
- 'type' => 'boolean'
- )
- )
- ),
- array(
- 'terms' => array(
- 'topicId' => $topicIds
- )
- )
- )
- )
- )
- );
- $url = Yii::app()->params['english_topic_search_url'];
- $rs = $this->aipostEng($url, $param);
- if (!$rs) {
- return false;
- }
- if (isset($rs['hits'])) {
- if (isset($rs['hits']['hits'])) {
- $topicInfos = array();
- foreach ($rs['hits']['hits'] as $v) {
- if (isset($v['_source']) && $v['_source']) {
- $src = $v['_source'];
- $temp_info = array(
- 'id' => $src['topicId'],
- 'is_large_topic' => isset($src['options']) && $src['options'] ? 0 : 1,
- 'type_id' => $src['physicalTypeId'],
- 'title' => $src['content'],
- 'topic_type' => $src['physicalTypeId'],
- 'school_id' => 0,
- 'type_name' => '',
- 'difficulty' => $src['difficulty'],
- 'subject_id' => 8,
- 'create_time' => time(),
- 'update_time' => time(),
- 'subject_name' => '英语',
- 'teacher_tips' => '',
- 'source' => '',
- 'relation_topic' => 0,
- 'teaching_quality' => 0,
- 'source_title' => '',
- 'parse_video' => null,
- 'parse_content' => $src['parse'],
- 'difficulty_degree' => 0.86,
- // 'difficulty_degree' => 0.86,
- 'kps' => array(),
- 'specials' => array(),
- 'uses' => array(),
- 'total' => 0,
- 'oneself' => 0,
- 'items' => array(),
- 'slave' => array(),
- );
- //考点
- if (isset($src['methods']) && $src['methods']) {
- $specials = array();
- foreach ($src['methods'] as $method) {
- if (isset($method['isLast']) && $method['isLast']) {
- $_method = array(
- "method_id" => $method['methodId'],
- "method_name" => $method['methodName'],
- );
- $specials[] = $_method;
- }
- }
- $temp_info['specials'] = $specials;
- }
- //小题
- if (isset($src['slaves']) && $src['slaves']) {
- foreach ($src['slaves'] as $slave) {
- $_slave = array(
- 'topic_slave_id' => $slave['topicId'],
- 'topic_type' => $slave['physicalTypeId'],
- 'type_name' => '',
- 'difficulty_degree' => 0.86,
- // 'difficulty_degree' => float 0.86
- 'difficulty' => $slave['difficulty'],
- 'title' => $slave['content'],
- 'items' => array(),
- 'kps' => array(),
- 'specials' => array(),
- );
- $_items = array(
- 'type_id' => 1,
- 'type_name' => '',
- 'list_type' => 1,
- // 'list_type' => int 0
- 'title' => $slave['content'],
- 'options' => array(),
- );
- if (isset($slave['options']) && $slave['options']) {
- $_option = array();
- foreach ($slave['options'] as $option) {
- $_temp_op = array(
- 'option_id' => 0,
- 'option_content' => $option['content'],
- 'option_correct' => $option['isTrue'],
- );
- $_option[] = $_temp_op;
- }
- $_items['options'] = $_option;
- } elseif (isset($slave['answer']) && $slave['answer']) {
- $_option = array();
- $_temp_op = array(
- 'option_id' => 0,
- 'option_content' => $slave['answer'],
- 'option_correct' => 1,
- );
- if ($src['physicalTypeId'] == 11) {
- $_temp_op['content_is_answer'] = 1;
- }
- $_option[] = $_temp_op;
- $_items['options'] = $_option;
- }
- $_slave['items'] = $_items;
- if (isset($slave['methods']) && $slave['methods']) {
- $_specials = array();
- foreach ($slave['methods'] as $method) {
- if (isset($method['isLast']) && $method['isLast']) {
- $__method = array(
- "method_id" => $method['methodId'],
- "method_name" => $method['methodName'],
- );
- $_specials[] = $__method;
- }
- }
- $_slave['specials'] = $_specials;
- }
- $temp_info['slave'][] = $_slave;
- }
- } elseif (isset($src['options']) && $src['options']) {//大题单选选择
- $temp_info['items'] = array();
- $_option = array();
- $_items = array(
- 'type_id' => 1,
- 'type_name' => '',
- 'list_type' => 1,
- // 'list_type' => int 0
- 'title' => '',
- 'options' => array(),
- );
- foreach ($src['options'] as $option) {
- $_temp_op = array(
- 'option_id' => 0,
- 'option_content' => $option['content'],
- 'option_correct' => $option['isTrue'],
- );
- $_option[] = $_temp_op;
- }
- $_items['options'] = $_option;
- $temp_info['items'][] = $_items;
- } elseif (isset($src['answer']) && $src['answer']) {//主题有答案的从题没有的,加一个从题
- $_slave = array(
- 'topic_slave_id' => $src['topicId'],
- 'topic_type' => $src['physicalTypeId'],
- 'type_name' => '',
- 'difficulty_degree' => 0.86,
- // 'difficulty_degree' => float 0.86
- 'difficulty' => $src['difficulty'],
- 'title' => '',
- 'items' => array(),
- 'kps' => array(),
- 'specials' => array(),
- );
- $_items = array(
- 'type_id' => 1,
- 'type_name' => '',
- 'list_type' => 1,
- // 'list_type' => int 0
- 'title' => '',
- 'options' => array(),
- );
- $_option = array();
- $_temp_op = array(
- 'option_id' => 0,
- 'option_content' => $src['answer'],
- 'option_correct' => 1,
- );
- $_option[] = $_temp_op;
- $_items['options'] = $_option;
- $_slave['items'] = $_items;
- $temp_info['slave'][] = $_slave;
- }
- $topicInfos[] = $temp_info;
- }
- }
- if ($topicInfos) {
- return $topicInfos;
- } else {
- return $result;
- }
- }
- }
- return $result;
- }
- /**
- * 获取试卷选择题id
- * @param $topic_type_arr
- * @param $topic_logic_type_arr
- * @param $is_has_large
- */
- protected function getChoiceIds($topic_type_arr, $topic_logic_type_arr, $subject_id, $paper_type)
- {
- $choice_ids = array();
- $type_arr = array();
- if (inArray($paper_type, array(0, 1, 2))) {
- if ($subject_id == 12) {//物理
- $type_arr = array(1, 4, 5, 8, 9);
- } elseif ($subject_id == 13) {//化学
- $type_arr = array(1);
- } elseif ($subject_id == 14) {//生物
- $type_arr = array(1, 3, 4);
- } elseif ($subject_id == 15) {//政治
- $type_arr = array(1, 3, 4, 6, 7);
- } elseif ($subject_id == 16) {//历史
- $type_arr = array(1);
- } elseif ($subject_id == 17) {//地理
- $type_arr = array(1, 3, 4);
- }
- } else {
- $type_arr = array(1, 11);
- }
- foreach ($topic_logic_type_arr as $t_id => $type) {
- if (inArray($type, $type_arr)) {
- $choice_ids[] = $t_id;
- }
- }
- //
- $diff_topic = array_diff(array_keys($topic_logic_type_arr), $choice_ids);
- if ($diff_topic) {
- foreach ($topic_type_arr as $t_id => $item) {
- if (inArray($t_id, $diff_topic) && inArray($item, array(1, 11))) {
- $choice_ids[] = $t_id;
- }
- }
- }
- return $choice_ids;
- }
- /**
- * 获取考点名称
- * @param $topicDetails
- * @return array
- */
- public function getMethodName(&$topicDetails)
- {
- $methodName = array();
- if (is_array($topicDetails)) {
- foreach ($topicDetails as $topicDetail) {
- if (isset($topicDetail['specials']) && $topicDetail['specials']) {
- foreach ($topicDetail['specials'] as $special) {
- $methodName[$special['method_id']] = $special['method_name'];
- }
- }
- if (isset($topicDetail['slave']) && $topicDetail['slave']) {
- foreach ($topicDetail['slave'] as $slave) {
- if (isset($slave['specials']) && $slave['specials']) {
- foreach ($slave['specials'] as $spec) {
- $methodName[$spec['method_id']] = $spec['method_name'];
- }
- }
- }
- }
- }
- }
- return $methodName;
- }
- //共性问题变式训练
- protected function getCommonPractice($paper_topic_detail, $stu_score_info, $stu_topic_rs, $large_topic_type_arr, $large_contain)
- {
- $class_wrong_topic = array();
- $cls_grammar_topic = array();
- $texturl_topic = array();
- $common_push_topic = array();
- $topic_method_arr = array();
- $_push_all_topics = array();
- $paper_topics = array_keys($large_topic_type_arr);
- foreach ($paper_topic_detail as $topic_id => $detail) {
- if (in_array($detail['type_id'], array(2, 3, 4, 5, 6, 7, 18, 19))) {
- $topic_method_arr[$topic_id] = isset($detail['specials']) ? _array_column($detail['specials'], 'method_id') : array();
- if (isset($detail['slave'])) {
- foreach ($detail['slave'] as $slave) {
- if (isset($slave['topic_slave_id'])) {
- $topic_method_arr[$slave['topic_slave_id']] = isset($slave['method_names']) ? _array_column($slave['method_names'], 'method_id') : array();
- }
- }
- }
- }
- }
- foreach ($stu_score_info as $stu_id => $score_info) {
- foreach ($score_info as $large_topic_id => $scoring) {
- if (isset($large_topic_type_arr[$large_topic_id])) {
- if (in_array($large_topic_type_arr[$large_topic_id], array(2, 3, 4, 5))) {
- if (!isset($class_wrong_topic[$large_topic_id])) {
- $class_wrong_topic[$large_topic_id] = array('scoring' => 0, 'score' => 0);
- }
- $_scoring = $class_wrong_topic[$large_topic_id]['scoring'];
- $_score = $class_wrong_topic[$large_topic_id]['score'];
- $class_wrong_topic[$large_topic_id] = array('scoring' => ($scoring['scoring'] + $_scoring), 'score' => ($scoring['score'] + $_score));
- } elseif (in_array($large_topic_type_arr[$large_topic_id], array(18, 19))) {
- $small_topic = $large_contain[$large_topic_id];
- $stu_topic_info = isset($stu_topic_rs[$stu_id]) ? $stu_topic_rs[$stu_id] : array();
- if ($stu_topic_info) {
- foreach ($small_topic as $small_topic_id => $score) {
- if (!isset($cls_grammar_topic[$large_topic_type_arr[$large_topic_id]][$small_topic_id])) {
- $cls_grammar_topic[$large_topic_type_arr[$large_topic_id]][$small_topic_id] = array('scoring' => 0, 'score' => 0);
- }
- $stu_scoring = $stu_topic_info[$small_topic_id];
- $_scoring = $cls_grammar_topic[$large_topic_type_arr[$large_topic_id]][$small_topic_id]['scoring'];
- $_score = $cls_grammar_topic[$large_topic_type_arr[$large_topic_id]][$small_topic_id]['score'];
- $cls_grammar_topic[$large_topic_type_arr[$large_topic_id]][$small_topic_id] = array('scoring' => ($stu_scoring['scoring'] + $_scoring), 'score' => ($score + $_score));
- }
- }
- } elseif (in_array($large_topic_type_arr[$large_topic_id], array(6, 7))) {
- $texturl_topic[] = $large_topic_id;
- }
- }
- }
- }
- $class_score_rate = array();
- foreach ($class_wrong_topic as $large_topic_id => $score_info) {
- $score_rate = $this->scoreRate($score_info['scoring'], $score_info['score']);
- $class_score_rate[$large_topic_id] = $score_rate;
- }
- if ($class_score_rate) {
- asort($class_score_rate);
- reset($class_score_rate);
- $push_text_topic = key($class_score_rate);
- $text_detail = $paper_topic_detail[$push_text_topic];
- $kps = _array_column($text_detail['specials'], 'method_id');
- $text_level = isset($text_detail['text_level']) ? $text_detail['text_level'] : 5;
- $cloze_type = 0;
- if ($text_detail['type_id'] == 2) {
- $cloze_type = count($text_detail['slave']) == 15 ? 1 : 2;
- }
- $rules = array();
- $rules[] = array(
- 'type' => $text_detail['type_id'],
- 'size' => 600,
- 'cloze_type' => $cloze_type
- );
- $params_eng = array();
- $params_eng['subjectId'] = 10;
- $params_eng['rules'] = $rules;
- $params_eng['inMethodIds'] = $kps;
- $params_eng['isAudit'] = 2;
- $params_eng['notInTopicIds'] = $paper_topics;
- $type_topic_arr = $this->apiBrainPost('/relation_english/extract', $params_eng, 25, true);
- if (isset($type_topic_arr[$text_detail['type_id']])) {
- $all_topic = array();
- $extract_topics = $type_topic_arr[$text_detail['type_id']];
- while ($text_level > 0) {
- if ($extract_topics[$text_level]) {
- $all_topic = $extract_topics[$text_level];
- break;
- }
- $text_level--;
- }
- if ($all_topic) {
- $push_topic_key = array_rand($all_topic, 1);
- $common_push_topic['min_rate_text'][$text_detail['type_id']] = array('topic_id' => $all_topic[$push_topic_key], 'topic_type' => $text_detail['type_id']);
- $_push_all_topics[$all_topic[$push_topic_key]] = $all_topic[$push_topic_key];
- }
- }
- }
- $grammar_rules = array();
- //班级错误率在50%及以上的
- $grammar_score_rate = array();
- $grammar_method = array();
- foreach ($cls_grammar_topic as $type => $cgt_info) {
- foreach ($cgt_info as $small_topic_id => $score_info) {
- $score_rate = $this->scoreRate($score_info['scoring'], $score_info['score'], true);
- if ($score_rate < 50) {
- $grammar_score_rate[$type][$small_topic_id] = isset($topic_method_arr[$small_topic_id]) ? $topic_method_arr[$small_topic_id] : array();
- }
- }
- }
- $topic_count = array('19' => 10, '18' => 0);
- foreach ($grammar_score_rate as $type => $gsr) {
- if ($type == 6 || $type == 19) {
- $type = 19;
- }
- $grammar_rules[$type] = array(
- 'type' => 19,
- 'size' => 600
- );
- if (!isset($grammar_method[$type])) {
- $grammar_method[$type] = array();
- }
- foreach ($gsr as $item) {
- if ($type == 18) {
- $topic_count[18]++;
- }
- $grammar_method[$type] = array_merge($grammar_method[$type], $item);
- }
- }
- //$read_base_obj = new ReadBase();
- foreach ($grammar_rules as $type => $gr) {
- $rules = array();
- $rules[] = array(
- 'type' => $type,
- 'size' => 600
- );
- $params_eng = array();
- $params_eng['subjectId'] = 10;
- $params_eng['rules'] = $rules;
- $params_eng['inMethodIds'] = isset($grammar_method[$type]) ? $grammar_method[$type] : array();
- $params_eng['notInTopicIds'] = $paper_topics;
- $type_topic_arr = $this->apiBrainPost('/relation_english/extract', $params_eng, 25, true);
- if ($type_topic_arr) {
- if (isset($type_topic_arr[$type]) && $type_topic_arr[$type]) {
- $topics = reset($type_topic_arr[$type]);
- $push_topic_key = array_rand($topics, $topic_count[$type]);
- foreach ($push_topic_key as $key) {
- $_push_all_topics[$topics[$key]] = $topics[$key];
- $common_push_topic['common_grammar_topic'][$type][] = array('topic_id' => $topics[$key], 'topic_type' => $type);
- }
- }
- }
- }
- $texturl_topic = array_unique($texturl_topic);
- foreach ($texturl_topic as $t_id) {
- $rules = array();
- $rules[] = array(
- 'type' => $paper_topic_detail[$t_id]['type_id'],
- 'size' => 600
- );
- $params_eng = array();
- $params_eng['subjectId'] = 10;
- $params_eng['rules'] = $rules;
- $params_eng['inMethodIds'] = isset($topic_method_arr[$t_id]) ? $topic_method_arr[$t_id] : array();
- $params_eng['notInTopicIds'] = $paper_topics;
- $type_topic_arr = $this->apiBrainPost('/relation_english/extract', $params_eng, 25, true);
- if ($type_topic_arr) {
- if (isset($type_topic_arr[$paper_topic_detail[$t_id]['type_id']]) && $type_topic_arr[$paper_topic_detail[$t_id]['type_id']]) {
- $topics = reset($type_topic_arr[$paper_topic_detail[$t_id]['type_id']]);
- if ($topics) {
- $push_topic_key = array_rand($topics, 1);
- $_push_all_topics[$topics[$push_topic_key]] = $topics[$push_topic_key];
- $common_push_topic['common_extra'][$paper_topic_detail[$t_id]['type_id']] = array('topic_id' => $topics[$push_topic_key], 'topic_type' => $paper_topic_detail[$t_id]['type_id']);
- }
- }
- }
- }
- return array($common_push_topic, $_push_all_topics);
- }
- function scoreRate($scoring, $total_score, $is_per = false)
- {
- if ($total_score > 0) {
- if ($is_per) {
- $pre_rate = 100;
- $decimal = 4;
- } else {
- $pre_rate = 1;
- $decimal = 2;
- }
- return round($scoring / $total_score, $decimal) * $pre_rate;
- } else {
- return 0;
- }
- }
- private function handleWordClass($keyWords)
- {
- $word_ids = _array_column($keyWords, 'single_word_id');
- $rs = $this->apiBrainPost('/zsytk2/getIspInfo', array('condition' => array('single_word_id' => $word_ids), 'table' => 'en_single_word_label', 'isAll' => 1), 25, true);
- if (isset($rs['status']) && $rs['status'] == 1 && isset($rs['data']) && $rs['data']) {
- $label_ids = array();
- $swm_ids = array();
- foreach ($rs['data'] as $key => $v) {
- if ($v['label_type_id'] == 3) {
- unset($rs['data'][$key]);
- }
- if ($v['label_type_id'] == 7) {
- $label_ids[] = $v['label_id'];
- $swm_ids[] = $v['swm_id'];
- }
- }
- $rel = array();
- if ($label_ids) {
- $label_rs = $this->apiBrainPost('/zsytk2/getIspInfo', array('condition' => array('label_id' => $label_ids), 'table' => 'en_label', 'isAll' => 1), 25, true);
- if (isset($label_rs['status']) && $label_rs['status'] == 1 && isset($label_rs['data']) && $label_rs['data']) {
- $rel = array();
- foreach ($label_rs['data'] as $v) {
- $rel[$v['label_id']] = $v['content'];
- }
- }
- }
- foreach ($rs['data'] as &$item) {
- $item['content'] = isset($rel[$item['label_id']]) ? $rel[$item['label_id']] : '';
- }
- unset($item);
- $new_swm_res = array();
- if ($swm_ids) {
- $swm_rs = $this->apiBrainPost('/zsytk2/getIspInfo', array('condition' => array('swm_id' => $swm_ids), 'table' => 'en_single_word_mean', 'isAll' => 1), 25, true);
- if (isset($swm_rs['status']) && $swm_rs['status'] == 1 && isset($swm_rs['data']) && $swm_rs['data']) {
- foreach ($swm_rs['data'] as $item) {
- $new_swm_res[$item['swm_id']] = $item;
- }
- }
- }
- $new_res = array();
- $res = $rs['data'];
- foreach ($res as $res_val) {
- $s_id = $res_val['single_word_id'];
- if (!isset($new_res[$s_id])) {
- $new_res[$s_id] = array('con_str' => '', 'swm_ids' => array(), 'single_word_id' => $s_id);
- }
- $new_res[$s_id]['con_str'] .= $res_val['content'];
- $new_res[$s_id]['swm_ids'][] = $res_val['swm_id'];
- if ($res_val['swm_id']) {
- $new_res[$s_id]['swm_con'][$res_val['swm_id']] = $res_val['content'];
- }
- }
- $_tmp_res = array();
- foreach ($new_res as $tmp) {
- $single_id = $tmp['single_word_id'];
- $swm_ids = array_filter($tmp['swm_ids']);
- if (!isset($_tmp_res[$single_id])) {
- $_tmp_res[$single_id] = '';
- }
- if ($swm_ids) {
- foreach ($swm_ids as $_id) {
- if (isset($new_swm_res[$_id])) {
- $_tmp_res[$single_id] .= ' ' . $tmp['swm_con'][$_id] . " {$new_swm_res[$_id]['mean']} ";
- }
- }
- }
- }
- foreach ($keyWords as &$val) {
- $val['word_class'] = isset($new_res[$val['single_word_id']]) ? $new_res[$val['single_word_id']]['con_str'] : '';
- $val['new_mean'] = isset($_tmp_res[$val['single_word_id']]) ? $_tmp_res[$val['single_word_id']] : '';
- }
- }
- return $keyWords;
- }
- /**
- * 物理教师讲案
- * @return array
- */
- public function actionPhysics()
- {
- set_time_limit(300);
- ini_set('memory_limit', '300M');
- $examId = (string)Req::get("examId");
- $viewHtml = (int)Req::get('viewHtml');
- $force = (int)Req::get('force');
- require_once('TeachingPhysics.php');
- $teachingPhysicsObj = new TeachingPhysics($this);
- $result = $teachingPhysicsObj->getTeachingPdf($this->schoolId, $examId, $force, $viewHtml);
- $result['pdf_path'] = '';
- echo json_encode($result);
- exit();
- }
- /**
- * 英语题型新转老
- */
- public function getTopicTypeRelate()
- {
- return array(
- '553' => '1',
- '28' => '1',
- '554' => '2',
- '41' => '2',
- '555' => '3',
- '42' => '3',
- '281' => '4',
- '566' => '4',
- '556' => '5',
- '44' => '5',
- '563' => '6',
- '278' => '6',
- '286' => '7',
- '570' => '7',
- '47' => '8',
- '557' => '8',
- '282' => '9',
- '567' => '9',
- '279' => '10',
- '564' => '10',
- '288' => '11',
- '572' => '11',
- '285' => '12',
- '444' => '13',
- '741' => '13',
- '280' => '14',
- '565' => '14',
- '287' => '15',
- '571' => '15',
- '116' => '17',
- '562' => '17',
- '54' => '18',
- '559' => '18',
- '55' => '19',
- '560' => '19',
- '56' => '20',
- '561' => '20',
- '428' => '21',
- '284' => '16'
- );
- }
- //全学科试题详情兼容
- public function quanTopicDetail($data)
- {
- $result = array();
- $answer_arr = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J");
- $getTopicTypeRelate = $this->getTopicTypeRelate();
- if ($data) {
- foreach ($data as $k => $v) {
- $temp_basic_type_id = isset($v['basic_type_id']) ? $v['basic_type_id'] : 1;
- $result[$k]['topic_id'] = $v['id'];
- $result[$k]['id'] = $v['id'];
- if (isset($v['bank_type']) && $v['bank_type']) {
- $temp_type_id = $v['bank_type'];
- } else {
- $temp_type_id = $v['type_id'];
- }
- $result[$k]['type'] = $result[$k]['type_id'] = isset($getTopicTypeRelate[$temp_type_id]) ? $getTopicTypeRelate[$temp_type_id] : $temp_type_id;
- $result[$k]['queBody'] = $v['title'];
- $result[$k]['title'] = $v['title'];
- $result[$k]['analysis'] = $v['parse_content'];
- $result[$k]['parse_content'] = $v['parse_content'];
- $result[$k]['slave'] = array();
- $result[$k]['items'] = array();
- $result[$k]['answer'] = '';
- $result[$k]['answer_str'] = '';
- $result[$k]['key_words_levels'] = array();
- $result[$k]['key_words'] = array();
- $result[$k]['isp_ids'] = array();
- $result[$k]['text_level'] = 0;
- $result[$k]['method_id_arr'] = array();
- $result[$k]['sentences_analysis'] = '';
- $result[$k]['topic_solution'] = '';
- $result[$k]['model_essay_point'] = '';
- $result[$k]['new_key_words'] = array();
- if (isset($v['kps']) && $v['kps']) {
- foreach ($v['kps'] as $kps) {
- $result[$k]['method_id_arr'][] = $kps['kp_id'];
- }
- }
- if (isset($v['affiliate']) && $v['affiliate']) {
- foreach ($v['affiliate'] as $aff) {
- if (isset($aff['field_key']) && $aff['field_key'] == 'tag_8_118') {
- $result[$k]['text_level'] = isset($aff['field_value']) ? $aff['field_value'] : 0;
- }
- if (isset($aff['field_name']) && $aff['field_name'] == '长难句解析') {
- $result[$k]['sentences_analysis'] = $aff['field_value'];
- }
- if (isset($aff['field_name']) && $aff['field_name'] == '审题思路') {
- $result[$k]['topic_solution'] = $aff['field_value'];
- }
- if (isset($aff['field_name']) && $aff['field_name'] == '范文亮点') {
- $result[$k]['model_essay_point'] = $aff['field_value'];
- }
- if (isset($aff['field_name']) && $aff['field_name'] == '词汇积累') {
- if (isset($aff['field_value']) && $aff['field_value']) {
- $temp_chjl = strip_tags($aff['field_value']);
- $strPattern = "/(?<=\()[^\)]+/";
- preg_match_all($strPattern, $temp_chjl, $result_words);
- if (isset($result_words[0]) && $result_words[0]) {
- $single_word_ids = $result_words[0];
- $single_word_data = $this->apiBrainPost('/all_library/getSingleWords', array("single_word_id" => $single_word_ids), 25, true);
- if ($single_word_data && $single_word_data['data']) {
- $temp_single_word_data = $single_word_data['data'];
- foreach ($temp_single_word_data as $temp_single_word_data_k => $temp_single_word_data_v) {
- $result[$k]['new_key_words'][] = array(
- "content" => isset($temp_single_word_data_v['content']) ? $temp_single_word_data_v['content'] : '',
- "phonetic_symbol" => isset($temp_single_word_data_v['phonetic_symbol']) ? $temp_single_word_data_v['phonetic_symbol'] : '',
- "new_mean" => isset($temp_single_word_data_v['mean']) ? $temp_single_word_data_v['mean'] : ''
- );
- }
- }
- }
- }
- }
- }
- }
- if (isset($v['slave']) && $v['slave']) {
- //七选五特殊处理
- if ($result[$k]['type_id'] == 5) {
- foreach ($v['slave'] as $slave_k => $slave_v) {
- if (isset($slave_v['items']) && isset($slave_v['items']['options']) && $slave_v['items']['options']) {
- foreach ($slave_v['items']['options'] as $option_k => $option_v) {
- if ($option_v["option_correct"]) {
- $v['slave'][$slave_k]['items']['options'][$option_k] = array("option_content" => isset($answer_arr[$option_k]) ? $answer_arr[$option_k] : '');
- }
- }
- }
- }
- }
- $result[$k]['slave'] = $v['slave'];
- } else {
- $result[$k]['items'] = $v['items'];
- $options_arr = array();
- if ($v['items'] && isset($v['items'][0]) && isset($v['items'][0]['options'])) {
- $options_arr = $v['items'][0]['options'];
- if ($v['items'][0]['options'] && count($v['items'][0]['options']) == 1) {
- foreach ($v['items'][0]['options'] as $op_v) {
- $result[$k]['answer'] = $op_v['option_content'];
- }
- }
- }
- $result[$k]['slave'][] = array('topic_slave_id' => $v['id'], 'items' => array('options' => $options_arr));
- }
- }
- }
- return $result;
- }
- }
|