12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918 |
- <?php
- /**
- * 产品设置.
- * User: chenye
- * Date: 2017/11/22
- * Time: 11:05
- */
- class ProductsetController extends Product {
- public $layout = false;
- /**
- * 首页
- */
- public function actionIndex(){
- $subjectId=Yii::app()->session['session_duoxueke_subject_id'];
-
- //////新跳转规则////////
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- // Header("Location: " . Yii::app()->params['product_set'] . '#/ProductSet/VersionSelect?subjectId=3');
- Header("Location: ".Yii::app()->params['product_setting_url']."index.html#/ProductSet/VersionSelect?subjectId=3");
- exit;
- }else if($subjectId == 12){
- Header("Location: ".Yii::app()->params['product_setting_url']."index.html#/ProductSet/Customized?subjectId=12");
- // Header("Location: " . Yii::app()->params['product_set'] . '#/ProductSet/Customized?subjectId=12');
- exit;
- }else{
- $this->redirect(array('oldSet'));exit;
- }
- ///////////////
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- //读取版本选择
- $data=$this->sConn->createCommand("select switch from producut_set_edition where id=1")->queryRow();
- if(!$data){
- $data['switch']=2;
- }
- $this->render('versionOptions',$data);
- }else{
- $this->redirect(array('oldSet'));
- }
- }
- //2.0产品设置
- public function actionOldSet(){
- // phpinfo();exit;
- $data = array();
- $classList = array();
- $productList = array();
- $classRelationIds = array();
- $classRList = array();
- //获取设置详情,没有则获取第一个默认设置
- if(isset($_GET['psId'])){
- $psId = Req::get('psId');
- }else{
- $psId = 0;
- }
- if(isset($_GET['subjectId'])){
- Yii::app()->session['session_duoxueke_subject_id'] = $_GET['subjectId'];
- Yii::app()->session['session_subject_id'] = $_GET['subjectId'];
- }
- $subjectId=Yii::app()->session['session_duoxueke_subject_id']?Yii::app()->session['session_duoxueke_subject_id']:3;
- //当前学期
- $currSemester = $this->schoolManager->getCurrSemester();
- $currClass = $this->schoolManager->getSemesterClasses($currSemester['semester_id']);
- //获取指定产品设置
- $setInfoObj = SProductSetting::model()->getSetInfo($psId,$subjectId);
- if($setInfoObj){
- $setInfo = $setInfoObj->getAttributes();
- $subjectId=$setInfo['subject_id'];
- //获取产品列表
- $productListR = SProductSetting::model()->getProductList($subjectId);
- }else{
- if($subjectId==8){
- SProductSetting::model()->initProductSetting($subjectId,true,$this->schoolInfo['province_id']);
- }else{
- SProductSetting::model()->initProductSetting($subjectId);
- }
- $productListR = SProductSetting::model()->getProductList($subjectId);
- $setInfoObj = SProductSetting::model()->getSetInfo($psId,$subjectId);
- $setInfo = $setInfoObj->getAttributes();
- }
- foreach ($productListR as $k=>$v){
- $productList[$v['product_type']][] = $v;
- }
- //11 江苏 12浙江
- //读取自定义模块
- if($subjectId==8 ){
- //没有自定义模板,新增
- if(!isset($productList[6])){
- SProductSetting::model()->initProductSetting($subjectId,true,$this->schoolInfo['province_id']);
- }elseif(!isset($productList[7])){
- SProductSetting::model()->initEnglishCdch();
- }elseif(!isset($productList[8])){
- SProductSetting::model()->initEnglishMagicWord();
- }elseif(!isset($productList[9])){
- SProductSetting::model()->initEnglishWriting();
- }
- $productListR = SProductSetting::model()->getProductList($subjectId);
- $productList=array();
- foreach ($productListR as $k=>$v){
- $productList[$v['product_type']][] = $v;
- }
- }
- //获取当前学期班级产品关联
- $classRelation = SProductClassRelation::model()->getClassRelation($setInfo['ps_id'],$currSemester['semester_id']);
- if(!empty($classRelation)){
- foreach ($classRelation as $k=>$v){
- $classRelationIds[] = $v['class_id'];
- $classRList[$v['grade']][] = $v;
- }
- }
- //获取班级(屏蔽已经关联的班级)
- foreach ($currClass as $k=>$v){
- if(!in_array($v['class_id'],$classRelationIds,true)){
- $classList[$v['grade']][] = $v;
- }
- }
- //debug($productList);exit;
- $customConfig=array();
- if($subjectId==8){
- foreach ($productList as $val){
- foreach ($val as $value){
- if($value['custom_config']){
- $config=json_decode($value['custom_config'],true);
- if($config){
- $config['name']=$value['name'];
- $config['is_default']=$value['is_default'];
- $config['ps_id']=$value['ps_id'];
- $config['product_type']=$value['product_type'];
- $customConfig[$config['moduleType']][]=$config;
- }
- }
- }
- }
- }
- $data = array(
- 'class_list' => $classList,
- 'product_list' => $productList,
- 'set_info' =>$setInfo,
- 'classR_list' => $classRList,
- 'curr_ps' => $setInfo['ps_id'],
- 'subject_id'=>$subjectId,
- 'customConfig'=>$customConfig,
- 'province_id'=>$this->schoolInfo['province_id'],
- 'is_whole' => $this->isWholeMagic(), //词汇宝是否是完整版
- );
- //获取全学科
- if(isset(Yii::app()->params['subjectId']) && Yii::app()->params['subjectId']){
- $data['subjects']=Yii::app()->params['subjectId'];
- unset($data['subjects'][6]);
- unset($data['subjects'][51]);
- if(isset($data['subjects'][20])) unset($data['subjects'][20]);
- }
- $data['subject_name']=$data['subjects'][$subjectId];
- //debug($data);
- if($subjectId==8 && $setInfo['product_type']>3){
- $data['custom']=json_decode($setInfo['custom_config'],true);
- //debug($data['custom']);
- $this->render('english',$data);
- }else{
- $this->render('index',$data);
- }
- }
- /**
- * 添加班级
- * 删除其他类型的关联关系
- */
- public function actionAddClass(){
- //当前学期
- $currSemester = $this->schoolManager->getCurrSemester();
- $psId = Req::post('ps_id2');
- $classId = Req::post('class_id'); //array()
- $setType = Req::post('setType');
- $subjectId = Req::post('subject_id');
- if($subjectId==3){
- $productListR = SProductSetting::model()->getProductList($subjectId);
- $psIds=array();
- foreach ($productListR as $item){
- if($item['ps_id']!=$psId) $psIds[]=$item['ps_id'];
- }
- $repeat=SProductClassRelation::model()->getPsClass($psIds,$classId);
- if($repeat){
- $data['status'] = 0;
- $data['info'] = "添加失败,该学科已有相同班级";
- exit(json_encode($data));
- }
- }elseif($subjectId==8){
- $psIds=array();
- $productListR=$this->sConn->createCommand("select ps_id from product_setting where subject_id='{$subjectId}' and product_type='{$setType}'")->queryAll();
- foreach ($productListR as $item){
- if($item['ps_id']!=$psId) $psIds[]=$item['ps_id'];
- }
- if($psIds){
- $repeat=$this->sConn->createCommand("select ps_id from product_class_relation where class_id in(".implode(',',$classId).") and ps_id in(".implode(',',$psIds).") ")->queryRow();
- if($repeat){
- $data['status'] = 0;
- $data['info'] = "添加失败,该学科产品类别已有相同班级";
- exit(json_encode($data));
- }
- }
- }
- $bool = SProductClassRelation::model()->insertClassRelation($psId,$classId,$currSemester['semester_id'],$setType);
- if($bool){
- $data['status'] = 1;
- $data['info'] = "添加成功";
- }else{
- $data['status'] = 0;
- $data['info'] = "添加失败";
- }
- //操作记录
- if(Yii::app()->params['handle_log_on_off']){
- writeFileLog(jsonEncode(array(
- 'product_id' => $psId,
- 'account' => Yii::app()->session['coachInfo']['coach_name'],
- 'operate_url' => 'productset/addClass',
- 'operate_param' => json_encode(array('post'=>$_POST)),
- 'school_id' => $this->schoolId,
- 'operate_time' => time(),
- 'title' => '添加关联的班级',
- 'status' => json_encode($data),
- "date"=>date('Y-m-d H:i:s')
- )));
- }
- exit(json_encode($data));
- }
- /**
- * 删除班级-产品关联
- */
- public function actionDelClass(){
- $classId = Req::post('classId');
- $psId = Req::post('psId');
- $currSemester = $this->schoolManager->getCurrSemester();
- $bool = SProductClassRelation::model()->deleteAll("ps_id=:ps_id AND class_id=:class_id AND semester_id=:semester_id",array(':ps_id'=>$psId,':class_id'=>$classId,':semester_id'=>$currSemester['semester_id']));
- if($bool!==false){
- $data['status'] = 1;
- $data['info'] = "删除成功";
- }else{
- $data['status'] = 0;
- $data['info'] = "删除失败";
- }
- //操作记录
- if(Yii::app()->params['handle_log_on_off']){
- writeFileLog(jsonEncode(array(
- 'product_id' => $psId,
- 'account' => Yii::app()->session['coachInfo']['coach_name'],
- 'operate_url' => 'productset/delClass',
- 'operate_param' => json_encode(array('post'=>$_POST)),
- 'school_id' => $this->schoolId,
- 'operate_time' => time(),
- 'title' => '删除关联的班级',
- 'status' => json_encode($data),
- "date"=>date('Y-m-d H:i:s')
- )));
- }
- exit(json_encode($data));
- }
- /**
- * 编辑产品设置
- */
- public function actionEdit(){
- $editdata = array();
- // debug($_POST);
- $subjectId=$_POST['subject_id'];
- if(isset($_POST['show_map'])){
- $editdata['show_map'] = Req::post('show_map');
- }
- if(isset($_POST['show_kp'])){
- $editdata['show_kp'] = Req::post('show_kp');
- }
- if(isset($_POST['show_guide'])){
- $editdata['show_guide'] = Req::post('show_guide');
- }
- if(isset($_POST['show_wrg_origin'])){
- $editdata['show_wrg_origin'] = Req::post('show_wrg_origin');
- }
- if(isset($_POST['show_wrg_analyze'])){
- $editdata['show_wrg_analyze'] = Req::post('show_wrg_analyze');
- }
- if(isset($_POST['show_classmate_optimization'])){
- $editdata['show_classmate_optimization'] = Req::post('show_classmate_optimization');
- }
- if(isset($_POST['show_isp_wrong_answer'])){
- $editdata['show_isp_wrong_answer'] = Req::post('show_isp_wrong_answer');
- }
- if(isset($_POST['level_rule'])){
- $editdata['level_rule'] = Req::post('level_rule');
- }
- if(isset($_POST['show_level'])){
- $editdata['show_level'] = Req::post('show_level');
- }
- if(isset($editdata['show_level']) && $editdata['show_level'] == 2 && isset($_POST['show_top'])){
- $editdata['show_top'] = implode('|',Req::post('show_top'));
- }
- if(isset($_POST['show_wrg_answer'])){
- $editdata['show_wrg_answer'] = Req::post('show_wrg_answer');
- }
- if(isset($_POST['st_tuozhan'])){
- $editdata['st_tuozhan'] = implode('|',Req::post('st_tuozhan'));
- }else{
- $editdata['st_tuozhan'] = '';
- }
- if($subjectId==3){
- if(isset($_POST['st_wrong'])){
- $editdata['st_wrong'] = implode('|',Req::post('st_wrong'));
- }else{
- $editdata['st_wrong'] = '';
- }
- }else{
- if(isset($_POST['st_wrong']) && $_POST['st_wrong']==1){
- $editdata['st_wrong'] = '1|1|1|1|1';
- }else{
- $editdata['st_wrong'] = '0|0|0|0|0';
- }
- }
- if(isset($_POST['st_reduce'])){
- $editdata['st_reduce'] = implode('|',Req::post('st_reduce'));
- }else{
- $editdata['st_reduce'] = '';
- }
- if(isset($_POST['push_question_upgrade'])){
- $editdata['push_question_upgrade'] = Req::post('push_question_upgrade');
- }
- if(isset($_POST['old_top_kps']) && isset($editdata['show_top'])){
- $old_top_kps = explode('|',Req::post('old_top_kps'));
- foreach (array(1,2,3,4) as $key => $level){
- $_key = 'top_kps_'.$level;
- if(isset($_POST[$_key]) && in_array($_POST[$_key],array(3,4,5))){
- $editdata['top_kps'][$key] = (int)Req::post($_key);
- }else{
- if(isset($old_top_kps[$key - 1])){
- $editdata['top_kps'][$key] = $old_top_kps[$key - 1];
- }else{
- $editdata['top_kps'][$key] = 5;
- }
- }
- }
- $editdata['top_kps'] = implode('|',$editdata['top_kps']);
- }
- if(isset($_POST['custom'])){
- if(isset($_POST['product_name']))
- $_POST['custom']['setting']['productName'] = Req::post('product_name');
- }
- $editdata['custom_config']=isset($_POST['custom'])?json_encode($_POST['custom']):'';
- $psId = Req::post('ps_id');
- if(empty($editdata)){
- $data['status'] = 0;
- $data['info'] = "无数据更新";
- }else{
- //个性化学习宝 产品名称不为空且长度不超过15
- if(isset($_POST['custom']) && $_POST['custom']['moduleType'] == 'english_3'){
- $setting = $_POST['custom'];
- if(isset($setting['setting']['productName']) && !$setting['setting']['productName']){
- $data['status'] = 0;
- $data['info'] = "产品名称不为空";
- exit(json_encode($data));
- }elseif(isset($setting['setting']['productName']) && $setting['setting']['productName']){
- if(mb_strlen($setting['setting']['productName'], 'utf-8') > 15){
- $data['status'] = 0;
- $data['info'] = "产品名称最多不超过15个字符";
- exit(json_encode($data));
- }
- }
- }
- $result = SProductSetting::model()->updateByPk($psId,$editdata);
- if($result>=0){
- $data['status'] = 1;
- $data['info'] = "保存成功";
- }else{
- $data['status'] = 0;
- $data['info'] = "保存失败";
- }
- }
- //操作记录
- if(Yii::app()->params['handle_log_on_off']){
- writeFileLog(jsonEncode(array(
- 'product_id' => $psId,
- 'account' => Yii::app()->session['coachInfo']['coach_name'],
- 'operate_url' => 'productset/edit',
- 'operate_param' => json_encode(array('post'=>$_POST)),
- 'school_id' => $this->schoolId,
- 'operate_time' => time(),
- 'title' => '编辑产品设置',
- 'status' => json_encode($data),
- "date"=>date('Y-m-d H:i:s')
- )));
- }
- exit(json_encode($data));
- }
- /*
- * 新增(和同类型默认配置一样)
- */
- public function actionAdd(){
- $type_id = Req::post('psType');
- $name = Req::post('name');
- $subjectId=Req::post('subject');
- $result = SProductSetting::model()->addNew($type_id,$name,$subjectId);
- if($result['status']=='1'){
- $data['status'] = 1;
- $data['info'] = $result['msg'];
- }elseif($result['status']=='2'){
- $data['status'] = 2;
- $data['info'] = "名称已存在";
- }else{
- $data['status'] = 0;
- $data['info'] = "新增失败";
- }
- //操作记录
- if(Yii::app()->params['handle_log_on_off']){
- writeFileLog(jsonEncode(array(
- 'product_id' => $result['msg'],
- 'title' => '新增产品',
- 'operate_url' => 'productset/add',
- 'account' => Yii::app()->session['coachInfo']['coach_name'],
- 'operate_param' => json_encode(array('post'=>$_POST)),
- 'school_id' => $this->schoolId,
- 'operate_time' => time(),
- 'status' => json_encode($data),
- "date"=>date('Y-m-d H:i:s')
- )));
- }
- exit(json_encode($data));
- }
- /*
- * 重命名产品
- */
- public function actionRename(){
- $psType = Req::post('psType');
- $name = Req::post('name');
- $psTypeArr = explode('_',$psType);
- $result = SProductSetting::model()->rename($psType,$name);
- if($result=='1'){
- $data['status'] = 1;
- $data['info'] = "更新成功";
- }elseif($result=='2'){
- $data['status'] = 2;
- $data['info'] = "名称已存在";
- }else{
- $data['status'] = 0;
- $data['info'] = "更新失败";
- }
- //操作记录
- if(Yii::app()->params['handle_log_on_off']){
- writeFileLog(jsonEncode(array(
- 'product_id' => $psTypeArr[1],
- 'title' => '重命名产品',
- 'operate_url' => 'productset/rename',
- 'account' => Yii::app()->session['coachInfo']['coach_name'],
- 'operate_param' => json_encode(array('post'=>$_POST)),
- 'school_id' => $this->schoolId,
- 'operate_time' => time(),
- 'status' => json_encode($data),
- "date"=>date('Y-m-d H:i:s')
- )));
- }
- exit(json_encode($data));
- }
- /*
- * 删除产品
- */
- public function actionDel(){
- //当前学期
- $currSemester = $this->schoolManager->getCurrSemester();
- $semId = $currSemester['semester_id'];
- $psType = explode('_',Req::post('psType'));
- $classR = SProductClassRelation::model()->find("ps_id={$psType[1]} AND semester_id={$semId}");
- if($classR){
- $data['status'] = 2;
- $data['info'] = "有关联的学校,无法删除";
- }else{
- //其他关联了次产品的班级设置为默认
- $otherClassR = SProductClassRelation::model()->find("ps_id={$psType[1]} AND semester_id!={$semId}");
- $defaultId = SProductSetting::model()->find("product_type={$psType[0]} AND is_default=1");
- if($otherClassR){
- //获取默认产品
- $criteria = new CDbCriteria();
- $criteria->addCondition("ps_id={$psType[1]}");
- SProductClassRelation::model()->updateAll(array('ps_id'=>$defaultId->ps_id),$criteria);
- }
- $result = SProductSetting::model()->deleteByPk($psType[1]);
- if($result){
- $data['status'] = 1;
- $data['info'] = "删除成功";
- $data['data']=$defaultId->ps_id;
- }else{
- $data['status'] = 0;
- $data['info'] = "删除失败";
- }
- }
- //操作记录
- if(Yii::app()->params['handle_log_on_off']){
- writeFileLog(jsonEncode(array(
- 'product_id' => $psType[1],
- 'title' => '删除产品',
- 'operate_url' => 'productset/del',
- 'account' => Yii::app()->session['coachInfo']['coach_name'],
- 'operate_param' => json_encode(array('post'=>$_POST)),
- 'school_id' => $this->schoolId,
- 'operate_time' => time(),
- 'status' => json_encode($data),
- "date"=>date('Y-m-d H:i:s')
- )));
- }
- exit(json_encode($data));
- }
- //新版产品设置3.0入口
- public function actionNav(){
- $this->render('productionSetFor3');
- }
- //获取产品版本
- public function actionGetProductEdition()
- {
- echo json_encode(array('status'=>1,'data'=>$this->getProductEdition(), 'isPrecise'=>$this->isPreciseIsp()));exit;
- }
- /**
- * 是否是精准学习宝
- * @return int
- */
- public function isPreciseIsp()
- {
- $http = http('customer/precision-learning-school/check/'.$this->schoolId, 'GET', $this->authUsername);
- $response = formatResponse($http);
- return isset($response['data']) ? $response['data'] : 0;
- }
- public function getProductEdition()
- {
- $switch = 2;
- $data=$this->sConn->createCommand("select switch from producut_set_edition where id=1")->queryRow();
- if($data){
- $switch = $data['switch'];
- }
- return $switch;
- }
- //模板中心
- public function actionTemplate(){
- //读取所有模板
- $data=array();
- $this->initTemplate3();
- //判断版本
- $_num= '';
- $use_version = '';
- if(isset(Yii::app()->session['coachInfo']->use_version))
- {
- $use_version = Yii::app()->session['coachInfo']->use_version;
- }else
- {
- $use_version = Yii::app()->session['coachInfo']['use_version'];
- }
- if(!$use_version)
- {
- $use_version = 100;
- }
- $version_number = implode('',explode('.',$use_version));
- if(strlen($version_number)<7)
- {
- for($i=0;$i<7-strlen($version_number);$i++)
- {
- $_num.='0';
- }
- }
- $version_number=(int)$version_number.$_num;
- $isShowCustomCard=1;
- $data['isShowCustomCard']=$isShowCustomCard;
- $this->render('customMadeCenter',$data);
- }
- //模板列表接口
- public function actionAjaxGetTemplate(){
- $data=array();
- $subject_id = isset(Yii::app()->session['session_duoxueke_subject_id']) ? Yii::app()->session['session_duoxueke_subject_id']:3;
- $productTemplate=$this->sConn->createCommand("select template_id,template_name,product_type,target_type,is_default from product_template where subject_id='{$subject_id}'")->queryAll();
- if($productTemplate){
- foreach ($productTemplate as $val){
- $data['list'][$val['product_type']]=$val;
- }
- }else{
- $this->initTemplate3();
- $productTemplate=$this->sConn->createCommand("select template_id,template_name,product_type,target_type,is_default from product_template where subject_id='{$subject_id}'")->queryAll();
- foreach ($productTemplate as $val){
- $data['list'][$val['product_type']]=$val;
- }
- }
- $result['status'] = 1;
- $result['data']=$data['list'];
- exit(json_encode($result));
- }
- //新版产品设置 错题本班级设置
- public function actionErrorPushSettingForClass(){
- $this->render('errorPushSettingForClass');
- }
- //复用错题本模板设置
- public function actionCopyTemplate(){
- $id = intval(Req::post('id'));
- $result['status'] = 0;
- if(!$id){
- $result['msg']='模板ID不能为空';
- exit(json_encode($result));
- }
- $productTemplate=$this->sConn->createCommand("select template_name,product_type,target_type,config_text,subject_id from product_template where template_id='{$id}'")->queryRow();
- if(!$productTemplate){
- $result['msg']='请选择复用的模板';
- exit(json_encode($result));
- }
- //查询模板名称
- $templateName=$productTemplate['template_name'].'副本';
- $repeat=$this->sConn->createCommand("select template_name from product_template where template_name like '".$templateName."%' and product_type='".$productTemplate['product_type']."' and target_type='".$productTemplate['target_type']."' and subject_id='".$productTemplate['subject_id']."'")->queryAll();
- if($repeat){
- $preg='/\(\d+\)/is';
- $cloneCount=0;
- foreach ($repeat as $value){
- $str=str_replace($templateName,'',$value['template_name']);
- preg_match_all($preg,$str,$match);
- if(isset($match[0]) && count($match[0])==1){
- $cloneCount++;
- }
- }
- $templateName.='('.($cloneCount+1).')';
- }else{
- $templateName.='(1)';
- }
- $isBeta = $this->isBeta($productTemplate['subject_id']);
- $ps = new SProductTemplate();
- $ps->template_name = $templateName;
- $ps->product_type = $productTemplate['product_type'];
- $ps->target_type = $productTemplate['target_type'];
- $ps->config_text = $productTemplate['config_text'];
- $ps->subject_id = $productTemplate['subject_id'];
- $ps->is_default = 0;
- $ps->is_beta = $isBeta;
- $ps->create_time = time();
- if($bool = $ps->save()){
- $result['status'] = 1;
- $result['msg']='操作成功';
- $result['data']=array(
- 'id'=>$ps->template_id,
- 'name'=>$templateName
- );
- }else{
- $result['msg']='操作失败';
- }
- exit(json_encode($result));
- }
- //编辑
- public function actionGetTemplate(){
- $product_type = intval(Req::get('product_type'));
- $target_type = intval(Req::get('target_type'));
- $id = intval(Req::get('id'));
- $subject_id = 3;
- if($id){
- $sql = "select subject_id from product_template where template_id = '{$id}'";
- $template_data = $this->sConn->createCommand($sql)->queryRow();
- if($template_data){
- $subject_id = $template_data["subject_id"];
- }
- }
- if(!$product_type || !$target_type){
- Yii::app()->jump->error('模板类型不正确');
- }
- if($subject_id != 3){
- if($product_type==1){
- if($target_type==1){
- $this->render('errorPushSettingForClass_'.$subject_id);
- }if($target_type==2){
- $this->render('errorPushSettingForStudent_'.$subject_id);
- }
- }elseif($product_type==2){
- if($target_type==1){
- $this->render('addPointStep2ForClass_'.$subject_id);
- }if($target_type==2){
- $this->render('addPointStep2ForStudent_'.$subject_id);
- }
- }elseif($product_type==3){
- if($target_type==1){
- $this->render('addPointStep3ForClass_'.$subject_id);
- }if($target_type==2){
- $this->render('addPointStep3ForStudent_'.$subject_id);
- }
- }
- }else{
- if($product_type==1){
- if($target_type==1){
- $this->render('errorPushSettingForClass');
- }if($target_type==2){
- $this->render('errorPushSettingForStudent');
- }
- }elseif($product_type==2){
- if($target_type==1){
- $this->render('addPointStep2ForClass');
- }if($target_type==2){
- $this->render('addPointStep2ForStudent');
- }
- }elseif($product_type==3){
- if($target_type==1){
- $this->render('addPointStep3ForClass');
- }if($target_type==2){
- $this->render('addPointStep3ForStudent');
- }
- }
- }
- }
- public function actionAjaxGetTemplateById(){
- $id = intval(Req::post('id'));
- $result['status'] = 0;
- if(!$id){
- $result['msg']='模板ID不正确';
- exit(json_encode($result));
- }
- $productTemplate=$this->sConn->createCommand("select template_id,template_name,product_type,target_type,config_text,subject_id,is_default,create_time from product_template where template_id='{$id}'")->queryRow();
- if(!$productTemplate){
- $result['msg']='模板id不正确';
- exit(json_encode($result));
- }else{
- $result['status'] = 1;
- $result['data'] = $productTemplate;
- exit(json_encode($result));
- }
- }
- //保存
- public function actionSaveTemplate(){
- $id = intval(Req::post('id'));
- $config=Req::post('config');
- $result['status'] = 0;
- $subject_id = 3;
- if(!$id || !$config){
- $result['msg']='模板参数不正确';
- exit(json_encode($result));
- }
- //
- $config=str_replace('"','"',$config);
- $configArr=json_decode($config,true);
- if(!$configArr){
- $result['msg']='设置数据格式不正确';
- exit(json_encode($result));
- }
- $productTemplate=$this->sConn->createCommand("select template_id,product_type,target_type,subject_id from product_template where template_id='{$id}'")->queryRow();
- if(!$productTemplate){
- $result['msg']='模板id不正确';
- exit(json_encode($result));
- }else{
- $subject_id = $productTemplate["subject_id"];
- }
- if(!$this->checkoutJson($configArr,$productTemplate['product_type'],$productTemplate['target_type'],$subject_id)){
- $result['msg']='设置数据格式不正确';
- exit(json_encode($result));
- }
- if($productTemplate['target_type']==1){
- //班级模板
- if(isset($configArr['studentLevelDivide']['levelDetails'])){
- foreach ($configArr['studentLevelDivide']['levelDetails'] as $val){
- if(isset($val['trainPushDetail']) && !$val['trainPushDetail']['pushDifficulty']){
- $result['msg']='推送配置难度不能为空';
- exit(json_encode($result));
- }
- }
- }else{
- $result['msg']='设置数据格式不正确';
- exit(json_encode($result));
- }
- }
- $criteria = new CDbCriteria();
- $criteria->addCondition("template_id={$id}");
- SProductTemplate::model()->updateAll(array('config_text'=>$config),$criteria);
- $result['status'] = 1;
- $result['msg']='操作成功';
- exit(json_encode($result));
- }
- //根据类型读取模板
- public function actionGetTemplateByType(){
- $type = intval(Req::post('type')); //模板类型 1-错题本 2-个性化学习方案 3-个性化学习宝
- $targetType=intval(Req::post('target_type')); //使用类型:1班级模板,2学生模板
- $post_subject_id = intval(Req::post('subject_id')); //接口传的subject_id
- $session_subject_id = isset(Yii::app()->session['session_duoxueke_subject_id'])?Yii::app()->session['session_duoxueke_subject_id']:3;
- $subject_id = $post_subject_id?$post_subject_id:$session_subject_id;
- if(!$type ){
- $result['msg']='参数错误';
- exit(json_encode($result));
- }
- $isBeta = $this->isBeta($subject_id);
- $sql="select template_id,template_name,target_type from product_template where product_type='{$type} ' and subject_id={$subject_id} and is_beta={$isBeta}";
- if($targetType && in_array($targetType,array(1,2))){
- $sql.=" and target_type='".$targetType."'";
- }
- $productTemplate=$this->sConn->createCommand($sql)->queryAll();
- $result['status'] = 1;
- $result['msg']='操作成功';
- $result['data']=$productTemplate;
- exit(json_encode($result));
- }
- //班级定制列表,get方法访问空页面,post请求数据
- public function actionProductClassSet(){
- if (Yii::app()->request->getIsPostRequest()) {
- $page=intval(Req::post('page'));
- $class_id=Req::post('class_id');
- $grade_id=Req::post('grade_id');
- $post_subject_id = intval(Req::post('subject_id')); //接口传的subject_id
- $session_subject_id = isset(Yii::app()->session['session_duoxueke_subject_id'])?Yii::app()->session['session_duoxueke_subject_id']:3;
- $subject_id = $post_subject_id?$post_subject_id:$session_subject_id;
- if(!$page) $page=1;
- $isBeta = $this->isBeta($subject_id);
- $pageLimit =10;
- $offset=($page-1)*$pageLimit;
- $semesterId=$this->semesterId;
- $pages=array();
- //wrong_book 或wb ,isp ,wb_isp
- if($class_id){
- $data=$this->sConn->createCommand("select class_id,grade,wrong_book,isp,wb_isp from product_class_set where class_id='{$class_id}' and subject_id='{$subject_id}' and is_beta={$isBeta} and product_type!=31")->queryAll();
- }else{
- if($grade_id){
- $count=$this->sConn->createCommand("select count(*) as count from product_class_set where semester_id='{$semesterId}' and grade='{$grade_id}' and subject_id='{$subject_id}' and is_beta={$isBeta} and product_type!=31")->queryRow();
- $total=$count['count'];
- $totalPage=ceil($total/$pageLimit);
- $data=$this->sConn->createCommand("select class_id,grade,wrong_book,isp,wb_isp from product_class_set where semester_id='{$semesterId}' and grade='{$grade_id}' and subject_id='{$subject_id}' and is_beta={$isBeta} and product_type!=31 limit {$offset},{$pageLimit}")->queryAll();
- }else{
- $count=$this->sConn->createCommand("select count(*) as count from product_class_set where semester_id='{$semesterId}' and subject_id='{$subject_id}' and is_beta={$isBeta} and product_type!=31")->queryRow();
- $total=$count['count'];
- $totalPage=ceil($total/$pageLimit);
- $data=$this->sConn->createCommand("select class_id,grade,wrong_book,isp,wb_isp from product_class_set where semester_id='{$semesterId}' and subject_id='{$subject_id}' and is_beta={$isBeta} and product_type!=31 limit {$offset},{$pageLimit}")->queryAll();
- }
- $pages=array(
- 'totalPage'=>$totalPage,
- 'total'=>$total,
- 'nowPage'=>$page
- );
- }
- if($data){
- //读取所有默认模板
- $defaultTemplateArr=array();
- $defaultTemplate=$this->sConn->createCommand("select template_name,product_type,target_type from product_template where is_default=1 and target_type=1 and subject_id='{$subject_id}' and is_beta={$isBeta}")->queryAll();
- foreach ($defaultTemplate as $value){
- $defaultTemplateArr[$value['product_type']]=$value['template_name'];
- }
- foreach ($data as $key => $val){
- $classInfo=$this->sConn->createCommand("select class_name,level from class where class_id='".$val['class_id']."'")->queryRow();
- $data[$key]['class_name']=$classInfo['class_name'];
- $data[$key]['level']=$classInfo['level'];
- //读取模板名
- if($val['wrong_book']){
- $Template=$this->sConn->createCommand("select template_name from product_template where template_id='{$val['wrong_book']}' and is_beta={$isBeta}")->queryRow();
- $data[$key]['error_book_name']=$Template['template_name'];
- }else{
- $data[$key]['error_book_name']=$defaultTemplateArr[1];
- }
- if($val['isp']){
- $Template=$this->sConn->createCommand("select template_name from product_template where template_id='{$val['isp']}' and is_beta={$isBeta}")->queryRow();
- $data[$key]['step2_name']=$Template['template_name'];
- }else{
- $data[$key]['step2_name']=$defaultTemplateArr[2];
- }
- if($val['wb_isp']){
- $Template=$this->sConn->createCommand("select template_name from product_template where template_id='{$val['wb_isp']}' and is_beta={$isBeta}")->queryRow();
- $data[$key]['step3_name']=$Template['template_name'];
- }else{
- $data[$key]['step3_name']=$defaultTemplateArr[3];
- }
- }
- }
- $result['list']=$data;
- $result['pages']=$pages;
- exit(json_encode(array('status'=>1,'data'=>$result)));
- }else{
- //判断版本
- $_num= '';
- $use_version = '';
- if(isset(Yii::app()->session['coachInfo']->use_version))
- {
- $use_version = Yii::app()->session['coachInfo']->use_version;
- }else
- {
- $use_version = Yii::app()->session['coachInfo']['use_version'];
- }
- if(!$use_version)
- {
- $use_version = 100;
- }
- $version_number = implode('',explode('.',$use_version));
- if(strlen($version_number)<7)
- {
- for($i=0;$i<7-strlen($version_number);$i++)
- {
- $_num.='0';
- }
- }
- $version_number=(int)$version_number.$_num;
- $isShowCustomCard=1;
- $data['isShowCustomCard']=$isShowCustomCard;
- $this->render('customMadeListForClass',$data);
- }
- }
- //学生定制列表,get方法访问空页面,post请求数据
- public function actionProductStudentSet(){
- if (Yii::app()->request->getIsPostRequest()) {
- $page=intval(Req::post('page'));
- $class_id=Req::post('class_id');
- $grade_id=Req::post('grade_id');
- $student_name=Req::post('student_name');
- $post_subject_id = intval(Req::post('subject_id')); //接口传的subject_id
- $session_subject_id = isset(Yii::app()->session['session_duoxueke_subject_id'])?Yii::app()->session['session_duoxueke_subject_id']:3;
- $subject_id = $post_subject_id?$post_subject_id:$session_subject_id;
- if(!$page) $page=1;
- $pageLimit =10;
- $offset=($page-1)*$pageLimit;
- $semesterId=$this->semesterId;
- $subject_id=$this->subjectId;
- $pages=array();
- $where=array();
- $where[]=" semester_id='{$semesterId}'";
- $where[]=" use_custom=0";
- $where[]=" subject_id='{$subject_id}'";
- $where[]=" product_type!=31";
- if($class_id){
- $where[]=" class_id='{$class_id}'";
- }
- if($grade_id){
- $where[]=" grade='{$grade_id}'";
- }
- if($student_name){
- $where[]=" student_name like '%".$student_name."%'";
- }
- if($subject_id){
- $where[]=" subject_id='{$subject_id}'";
- }
- $isBeta = $this->isBeta($subject_id);
- $where[]= " is_beta={$isBeta}";
- $count=$this->sConn->createCommand("select count(*) as count from product_student_set where ".implode(' and ',$where))->queryRow();
- $total=$count['count'];
- $totalPage=ceil($total/$pageLimit);
- $data=$this->sConn->createCommand("select student_id,class_id,grade,wrong_book,isp,wb_isp,student_name from product_student_set where ".implode(' and ',$where)." limit {$offset},{$pageLimit}")->queryAll();
- $pages=array(
- 'totalPage'=>$totalPage,
- 'total'=>$total,
- 'nowPage'=>$page
- );
- if($data){
- //取出所有学生,再查询行政班级名字
- $student_arr = array();
- foreach ($data as $value) {
- $student_arr[$value['student_id']] = $value['student_id'];
- }
- $stu_rel_class = $this->getStudentXzClassName(array_keys($student_arr));
- //读取所有默认模板
- $defaultTemplateArr=array();
- $defaultTemplate=$this->sConn->createCommand("select template_name,product_type,target_type from product_template where is_default=1 and target_type=1 and subject_id = '{$subject_id}' and is_beta={$isBeta}")->queryAll();
- foreach ($defaultTemplate as $value){
- $defaultTemplateArr[$value['product_type']]=$value['template_name'];
- }
- foreach ($data as $key => $val){
- $classInfo=$this->sConn->createCommand("select class_name,level from class where class_id='".$val['class_id']."'")->queryRow();
- if (isset($stu_rel_class[$val['student_id']])) {
- $data[$key]['class_name']=$stu_rel_class[$val['student_id']];
- }else{
- $data[$key]['class_name']=$classInfo['class_name'];
- }
- $data[$key]['level']=$classInfo['level'];
- //读取系统准考证号
- $student=$this->conn->createCommand("select student_card from student where student_id='".$val['student_id']."'")->queryRow();
- $data[$key]['student_card']=$student['student_card'];
- $classTemplateData=$this->sConn->createCommand("select wrong_book,isp,wb_isp from product_class_set where class_id='".$val['class_id']."' and subject_id = '{$subject_id}' and is_beta={$isBeta} and product_type!=31")->queryRow();
- //读取模板名
- if($val['wrong_book']){
- $Template=$this->sConn->createCommand("select template_name from product_template where template_id='{$val['wrong_book']}' and is_beta={$isBeta}")->queryRow();
- $data[$key]['error_book_name']=$Template['template_name'];
- }else{
- if($classTemplateData['wrong_book']){
- $Template=$this->sConn->createCommand("select template_name from product_template where template_id='{$classTemplateData['wrong_book']}' and is_beta={$isBeta}")->queryRow();
- $data[$key]['error_book_name']=$Template['template_name'];
- }else{
- $data[$key]['error_book_name']=$defaultTemplateArr[1];
- }
- }
- if($val['isp']){
- $Template=$this->sConn->createCommand("select template_name from product_template where template_id='{$val['isp']}' and is_beta={$isBeta}")->queryRow();
- $data[$key]['step2_name']=$Template['template_name'];
- }else{
- if($classTemplateData['isp']){
- $Template=$this->sConn->createCommand("select template_name from product_template where template_id='{$classTemplateData['isp']}' and is_beta={$isBeta}")->queryRow();
- $data[$key]['step2_name']=$Template['template_name'];
- }else{
- $data[$key]['step2_name']=$defaultTemplateArr[2];
- }
- }
- if($val['wb_isp']){
- $Template=$this->sConn->createCommand("select template_name from product_template where template_id='{$val['wb_isp']}' and is_beta={$isBeta}")->queryRow();
- $data[$key]['step3_name']=$Template['template_name'];
- }else{
- if($classTemplateData['wb_isp']){
- $Template=$this->sConn->createCommand("select template_name from product_template where template_id='{$classTemplateData['wb_isp']}' and is_beta={$isBeta}")->queryRow();
- $data[$key]['step3_name']=$Template['template_name'];
- }else{
- $data[$key]['step3_name']=$defaultTemplateArr[3];
- }
- }
- }
- }
- $result['list']=$data;
- $result['pages']=$pages;
- exit(json_encode(array('status'=>1,'data'=>$result)));
- }else{
- //判断版本
- $_num= '';
- $use_version = '';
- if(isset(Yii::app()->session['coachInfo']->use_version))
- {
- $use_version = Yii::app()->session['coachInfo']->use_version;
- }else
- {
- $use_version = Yii::app()->session['coachInfo']['use_version'];
- }
- if(!$use_version)
- {
- $use_version = 100;
- }
- $version_number = implode('',explode('.',$use_version));
- if(strlen($version_number)<7)
- {
- for($i=0;$i<7-strlen($version_number);$i++)
- {
- $_num.='0';
- }
- }
- $version_number=(int)$version_number.$_num;
- $isShowCustomCard=1;
- $data['isShowCustomCard']=$isShowCustomCard;
- $this->render('customMadeListForStudent',$data);
- }
- }
- //学生自定义配置列表,get方法访问空页面,post请求数据
- public function actionCustomProductStudentSet(){
- if (Yii::app()->request->getIsPostRequest()) {
- $page=intval(Req::post('page'));
- $class_id=Req::post('class_id');
- $grade_id=Req::post('grade_id');
- $student_name=Req::post('student_name');
- $post_subject_id = intval(Req::post('subject_id')); //接口传的subject_id
- $session_subject_id = isset(Yii::app()->session['session_duoxueke_subject_id'])?Yii::app()->session['session_duoxueke_subject_id']:3;
- $subject_id = $post_subject_id?$post_subject_id:$session_subject_id;
- if(!$page) $page=1;
- $pageLimit =10;
- $offset=($page-1)*$pageLimit;
- $semesterId=$this->semesterId;
- $subject_id=$this->subjectId;
- $pages=array();
- $where=array();
- $where[]=" semester_id='{$semesterId}'";
- $where[]=" use_custom=1";
- $where[]=" subject_id='{$subject_id}'";
- $where[]=" product_type!=31";
- if($class_id){
- $where[]=" class_id='{$class_id}'";
- }
- if($grade_id){
- $where[]=" grade='{$grade_id}'";
- }
- if($student_name){
- $where[]=" student_name like '%".$student_name."%'";
- }
- if($subject_id){
- $where[]=" subject_id='{$subject_id}'";
- }
- //抢先体验版
- $isBeta = $this->isBeta($subject_id);
- $where[] = " is_beta='{$isBeta}'";
- $count=$this->sConn->createCommand("select count(*) as count from product_student_set where ".implode(' and ',$where))->queryRow();
- $total=$count['count'];
- $totalPage=ceil($total/$pageLimit);
- $data=$this->sConn->createCommand("select student_id,student_name,class_id,grade,custom_config_img,custom_config_json from product_student_set where ".implode(' and ',$where)." limit {$offset},{$pageLimit}")->queryAll();
- $pages=array(
- 'totalPage'=>$totalPage,
- 'total'=>$total,
- 'nowPage'=>$page
- );
- if($data){
- //取出所有学生,再查询行政班级名字
- $student_arr = array();
- foreach ($data as $value) {
- $student_arr[$value['student_id']] = $value['student_id'];
- }
- $stu_rel_class = $this->getStudentXzClassName(array_keys($student_arr));
- foreach ($data as $key => $val){
- $classInfo=$this->sConn->createCommand("select class_name,level from class where class_id='".$val['class_id']."'")->queryRow();
- if (isset($stu_rel_class[$val['student_id']])) {
- $data[$key]['class_name']=$stu_rel_class[$val['student_id']];
- }else{
- $data[$key]['class_name']=$classInfo['class_name'];
- }
- $data[$key]['level']=$classInfo['level'];
- //读取系统准考证号
- $student=$this->conn->createCommand("select student_card from student where student_id='".$val['student_id']."'")->queryRow();
- $data[$key]['student_card']=$student['student_card'];
- }
- }
- $result['list']=$data;
- $result['pages']=$pages;
- exit(json_encode(array('status'=>1,'data'=>$result)));
- }else{
- //判断版本
- $_num= '';
- $use_version = '';
- if(isset(Yii::app()->session['coachInfo']->use_version))
- {
- $use_version = Yii::app()->session['coachInfo']->use_version;
- }else
- {
- $use_version = Yii::app()->session['coachInfo']['use_version'];
- }
- if(!$use_version)
- {
- $use_version = 100;
- }
- $version_number = implode('',explode('.',$use_version));
- if(strlen($version_number)<7)
- {
- for($i=0;$i<7-strlen($version_number);$i++)
- {
- $_num.='0';
- }
- }
- $version_number=(int)$version_number.$_num;
- $isShowCustomCard=1;
- $data['isShowCustomCard']=$isShowCustomCard;
- $this->render('studentOptionalCard',$data);
- }
- }
- //删除学生自定义配置
- public function actionDelStudentOptionalCard(){
- $student_id=Req::post('student_id');
- $subject_id=$this->subjectId;
- if(!$student_id){
- $result['msg']='参数异常';
- exit(json_encode($result));
- }
- $semesterId=$this->semesterId;
- $isBeta = $this->isBeta($subject_id);
- $data=$this->sConn->createCommand("select count(*) as count from product_student_set where student_id='{$student_id}' and semester_id='{$semesterId}' and use_custom=1 and subject_id='{$subject_id}' and is_beta={$isBeta}")->queryRow();
- if($data){
- $rs=$this->sConn->createCommand("update product_student_set set use_custom=0 where student_id='{$student_id}' and semester_id='{$semesterId}' and subject_id='{$subject_id}' and is_beta={$isBeta}")->execute();
- if($rs){
- exit(json_encode(array('status'=>1,'msg'=>'删除成功')));
- }else{
- exit(json_encode(array('status'=>0,'msg'=>'删除失败')));
- }
- }else{
- exit(json_encode(array('status'=>0,'msg'=>'学生自定义记录不存在')));
- }
- }
- //新增班级定制
- public function actionCustomMadeForClass(){
- $this->render('customMadeForClass');
- }
- //新增学生定制
- public function actionCustomMadeForStudent(){
- $this->render('customMadeForStudent');
- }
- //保存班级定制
- public function actionSaveClassSet(){
- $post=Req::post('json');
- $product_type=Req::post('template_type');
- // $product_type=$post['template_type']; //1 错题本 2 二步 3 三步
- $classIds=Req::post('classes'); //班级id组 包含年级
- $template_id=Req::post('template_id');
- $post_subject_id = intval(Req::post('subject_id')); //接口传的subject_id
- $session_subject_id = isset(Yii::app()->session['session_duoxueke_subject_id'])?Yii::app()->session['session_duoxueke_subject_id']:3;
- $subject_id = $post_subject_id?$post_subject_id:$session_subject_id;
- $result['status'] = 0;
- if(!$product_type ){
- $result['msg']='请选择模板类型';
- exit(json_encode($result));
- }
- if(!$classIds){
- $result['msg']='请选择班级';
- exit(json_encode($result));
- }
- if(!$template_id){
- $result['msg']='请选择模板';
- exit(json_encode($result));
- }
- $isBeta = $this->isBeta($subject_id);
- $templateInfo=$this->sConn->createCommand("select product_type,target_type from product_template where template_id='{$template_id}' and is_beta={$isBeta}")->queryRow();
- if($templateInfo['product_type']!=$product_type){
- $result['msg']='模板类型不正确';
- exit(json_encode($result));
- }
- if($product_type==1){
- $field='wrong_book';
- }elseif ($product_type==2){
- $field='isp';
- }elseif($product_type==3){
- $field='wb_isp';
- }else{
- $result['msg']='模板类型错误';
- exit(json_encode($result));
- }
- $updateSql=array();
- $insertSql=array();
- foreach ($classIds as $val){
- if(!isset($val['class_id']) || !$val['class_id']){
- $result['msg']='班级数据错误';
- exit(json_encode($result));
- }
- $classInfo=$this->sConn->createCommand("select class_id,grade from class where class_id='{$val['class_id']}'")->queryRow();
- if(!$classInfo){
- $result['msg']='选择的班级不存在';
- exit(json_encode($result));
- }
- $classSet=$this->sConn->createCommand("select class_id from product_class_set where class_id='{$val['class_id']}' and subject_id='{$subject_id}' and is_beta={$isBeta} and product_type<>31")->queryRow();
- $sql='';
- if($classSet){
- $updateSql[]="update product_class_set set `".$field."`='".$template_id."',semester_id='".$this->semesterId."' where class_id='".$val['class_id']."' and subject_id='{$subject_id}' and is_beta={$isBeta}";
- }else{
- $insertSql[]="insert into product_class_set(`class_id`,`semester_id`,`grade`,`".$field."`,`subject_id`,`is_beta`) values('".$val['class_id']."','".$this->semesterId."','".$classInfo['grade']."','".$template_id."','".$subject_id."','".$isBeta."')";
- }
- }
- $trans = $this->sConn->beginTransaction();
- try{
- if($updateSql){
- foreach ($updateSql as $sql){
- $this->sConn->createCommand($sql)->execute();
- }
- }
- if($insertSql){
- foreach ($insertSql as $sql){
- $this->sConn->createCommand($sql)->execute();
- }
- }
- $trans->commit();
- $result['status'] = 1;
- $result['msg'] = "更新成功";
- }catch (Exception $e){
- $trans->rollBack();
- $result['status'] = 0;
- $result['msg'] = "更新失败";
- }
- exit(json_encode($result));
- }
- //保存学生定制
- public function actionSaveStudentSet(){
- $post=Req::post('json');
- $product_type=Req::post('template_type');//1 错题本 2 二步 3 三步
- // $product_type=$post['template_type']; //1 错题本 2 二步 3 三步
- $studentIds=Req::post('students');
- $template_id=Req::post('template_id');
- $post_subject_id = intval(Req::post('subject_id')); //接口传的subject_id
- $session_subject_id = isset(Yii::app()->session['session_duoxueke_subject_id'])?Yii::app()->session['session_duoxueke_subject_id']:3;
- $subject_id = $post_subject_id?$post_subject_id:$session_subject_id;
- $isBeta = $this->isBeta($subject_id);
- $result['status'] = 0;
- if(!$product_type){
- $result['msg']='请选择模板类型';
- exit(json_encode($result));
- }
- if(!$studentIds){
- $result['msg']='请选择学生';
- exit(json_encode($result));
- }
- if(!$template_id){
- $result['msg']='请选择模板';
- exit(json_encode($result));
- }
- $templateInfo=$this->sConn->createCommand("select product_type,target_type from product_template where template_id='{$template_id}' and is_beta={$isBeta}")->queryRow();
- if($templateInfo['product_type']!=$product_type){
- $result['msg']='模板类型不正确';
- exit(json_encode($result));
- }
- if($product_type==1){
- $field='wrong_book';
- }elseif ($product_type==2){
- $field='isp';
- }elseif($product_type==3){
- $field='wb_isp';
- }else{
- $result['msg']='模板类型错误';
- exit(json_encode($result));
- }
- $err=array();
- $updateSql=array();
- $insertSql=array();
- $isBeta = $this->isBeta($subject_id);
- foreach ($studentIds as $val){
- if(!$val['student_id'] || !$val['realname'] || !$val['class_id'] || !$val['grade_id']){
- $result['msg']='学生数据错误';
- exit(json_encode($result));
- }
- $classInfo=$this->sConn->createCommand("select class_id,grade from class where class_id='{$val['class_id']}'")->queryRow();
- if(!$classInfo){
- $result['msg']='选择的班级不存在';
- exit(json_encode($result));
- }
- $studentSet=$this->sConn->createCommand("select student_id,student_name,use_custom,semester_id from product_student_set where student_id='{$val['student_id']}' and subject_id='{$subject_id}' and is_beta={$isBeta} and product_type!=31")->queryRow();
- $sql='';
- if($studentSet){
- if($studentSet['use_custom']==1 && $studentSet['semester_id']==$this->semesterId){
- $err[]=$studentSet['student_name'];
- continue;
- }elseif($studentSet['use_custom']==1){
- $updateSql[]="update product_student_set set `".$field."`='".$template_id."',use_custom=0,semester_id='".$this->semesterId."' where student_id='".$val['student_id']."' and subject_id='".$subject_id."' and product_type!=31";
- }else{
- $updateSql[]="update product_student_set set `".$field."`='".$template_id."',semester_id='".$this->semesterId."' where student_id='".$val['student_id']."' and subject_id='".$subject_id."' and product_type!=31";
- }
- }else{
- $insertSql[]="insert into product_student_set(`student_id`,`student_name`,`semester_id`,`class_id`,`grade`,`".$field."`,`subject_id`,`is_beta`) values('".$val['student_id']."','".$val['realname']."','".$this->semesterId."','".$val['class_id']."','".$classInfo['grade']."','".$template_id."','".$subject_id."','".$isBeta."')";
- }
- }
- $trans = $this->sConn->beginTransaction();
- try{
- if($updateSql){
- foreach ($updateSql as $sql){
- $this->sConn->createCommand($sql)->execute();
- }
- }
- if($insertSql){
- foreach ($insertSql as $sql){
- $this->sConn->createCommand($sql)->execute();
- }
- }
- $trans->commit();
- $result['status'] = 1;
- if($err){
- $result['msg']='更新完成,学生:【'.implode(',',$err).'】因已使用自选卡未更新';
- }else{
- $result['msg']='更新完成';
- }
- }catch (Exception $e){
- $trans->rollBack();
- $result['status'] = 0;
- $result['msg'] = "更新失败";
- }
- exit(json_encode($result));
- }
- //根据年级读取班级
- public function actionGetClassByGrade(){
- $grade_id = Req::post("grade_id");
- $class_array = array();
- if(!in_array($grade_id,array(0,1,2,3)))
- {
- echo json_encode(array('status'=>0,'result'=>array()));exit;
- }
- if($grade_id){
- $class_data = ClassModel::model()->findAll('grade=:grade and semester_id=:semester_id and class_type=:class_type',array(':grade' => $grade_id,':semester_id'=>$this->semesterId,':class_type'=>1));
- }else{
- $class_data = ClassModel::model()->findAll(' semester_id=:semester_id and class_type=:class_type',array(':semester_id'=>$this->semesterId ,':class_type'=>1));
- }
- if($class_data){
- foreach($class_data as $v )
- {
- $class_array[] = $v->attributes;
- }
- echo json_encode(array('status'=>1,'result'=>$class_array));exit;
- }
- echo json_encode(array('status'=>0,'result'=>array()));exit;
- }
- //班级恢复默认
- public function actionResetClassSet(){
- $post_subject_id = intval(Req::post('subject_id')); //接口传的subject_id
- $subject_id = isset(Yii::app()->session['session_duoxueke_subject_id']) ? Yii::app()->session['session_duoxueke_subject_id']:3;
- $subject_id = $post_subject_id?$post_subject_id:$subject_id;
- $isBeta = $this->isBeta($subject_id);
- $sql = "select class_id from product_class_set where subject_id = '{$subject_id}' and is_beta={$isBeta} and (wrong_book!=0 or isp!=0 or wb_isp!=0) and product_type!=31";
- $class_set = $this->sConn->createCommand($sql)->queryRow();
- if(!$class_set){
- echo json_encode(array('status'=>1,'msg'=>'操作成功'));exit;
- }
- if($this->sConn->createCommand("update product_class_set set wrong_book=0,isp=0,wb_isp=0 where subject_id = '{$subject_id}' and is_beta={$isBeta} and product_type!=31")->execute()){
- echo json_encode(array('status'=>1,'msg'=>'操作成功'));exit;
- }else{
- echo json_encode(array('status'=>0,'msg'=>'操作失败'));exit;
- }
- }
- //学生恢复默认
- public function actionResetStudentSet(){
- $post_subject_id = intval(Req::post('subject_id')); //接口传的subject_id
- $subject_id = isset(Yii::app()->session['session_duoxueke_subject_id']) ? Yii::app()->session['session_duoxueke_subject_id']:3;
- $subject_id = $post_subject_id?$post_subject_id:$subject_id;
- $isBeta = $this->isBeta($subject_id);
- $sql = "select student_id from product_student_set where subject_id = '{$subject_id}' and is_beta={$isBeta} and (wrong_book!=0 or isp!=0 or wb_isp!=0) and product_type!=31";
- $student_set = $this->sConn->createCommand($sql)->queryRow();
- if(!$student_set){
- echo json_encode(array('status'=>1,'msg'=>'操作成功'));exit;
- }
- if($this->sConn->createCommand("update product_student_set set wrong_book=0,isp=0,wb_isp=0 where subject_id='{$subject_id}' and is_beta={$isBeta} and product_type!=31")->execute()){
- echo json_encode(array('status'=>1,'msg'=>'操作成功'));exit;
- }else{
- echo json_encode(array('status'=>0,'msg'=>'操作失败'));exit;
- }
- }
- //选择版本切换
- public function actionSwitchEdition(){
- $edition=intval(Req::post('edition')); //产品设置版本,2,3 抢先版4
- if(!in_array($edition,array(2,3,4))){
- echo json_encode(array('status'=>0,'msg'=>'版本不正确'));exit;
- }
- $transaction = $this->sConn->beginTransaction();
- try {
- $switch = $this->sConn->createCommand("select id from producut_set_edition ")->queryRow();
- if (!$switch) {
- $this->sConn->createCommand("insert into producut_set_edition(`id`,`switch`) values(1,2) ")->execute();
- }
- if($edition==2){
- $SendLabel=$this->sConn->createCommand("select paper_id from paper where labelled_type=2 and is_labelled in(2,3,5) limit 1")->queryRow();
- if($SendLabel){
- echo json_encode(array('status'=>0,'msg'=>'当前有正在标注的教师版本,请完成或撤销标注后修改'));exit;
- }
- }
- if($this->sConn->createCommand("update producut_set_edition set switch={$edition} where id=1 ")->execute()){
- if ($edition != 2) {
- $this->initTemplate3();
- }
- }
- $transaction->commit();
- echo json_encode(array('status' => 1, 'msg' => '操作成功'));
- exit;
- }catch (\Exception $exception){
- $transaction->rollback();
- echo json_encode(array('status'=>0,'msg'=>'操作失败'));exit;
- }
- }
- public function actionDownPdf(){
- $isBeta = $this->isBeta($this->subjectId);
- // TODO 下载文件替换
- $schoolId=$this->schoolId;
- if(strlen($schoolId)<=3){
- $fileStr = $isBeta ? 'optional_card_8_3.3.pdf' : 'optional_card_8.pdf';
- }else{
- $fileStr = $isBeta ? 'optional_card_9_3.3.pdf' : 'optional_card_9.pdf';
- }
- $filename= dirname(dirname(dirname(__FILE__))).'/assets/data/'.$fileStr;
- if (FALSE!== ($handler = fopen($filename, 'r')))
- {
- header('Content-Description: File Transfer');
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename=学生自选卡.pdf');
- header('Content-Transfer-Encoding: chunked'); //changed to chunked
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
- while (!feof($handler)) {
- file_put_contents("php://output", fread($handler, 4096));
- }
- fclose($handler);
- }
- }
- //修改自选卡
- public function actionSaveOptionalCard(){
- $studentId=Req::post('studentId');
- $json=Req::post('json');
- $subject_id=$this->subjectId;
- if(!$studentId){
- echo json_encode(array('status'=>0,'msg'=>'学生ID不正确 '));exit;
- }
- $post_subject_id = intval(Req::post('subject_id')); //接口传的subject_id
- $session_subject_id = isset(Yii::app()->session['session_duoxueke_subject_id'])?Yii::app()->session['session_duoxueke_subject_id']:3;
- $subject_id = $post_subject_id?$post_subject_id:$session_subject_id;
- $json=str_replace('"','"',$json);
- $jsonData=json_decode($json,true);
- if(!$jsonData){
- echo json_encode(array('status'=>0,'msg'=>'配置参数格式不正确 '));exit;
- }
- $isBeta = $this->isBeta($this->subjectId);
- $studentSetting=$this->sConn->createCommand("select student_name from product_student_set where student_id='{$studentId}' and semester_id='{$this->semesterId}' and subject_id='{$subject_id}' and is_beta={$isBeta}")->queryRow();
- if(!$studentSetting){
- echo json_encode(array('status'=>0,'msg'=>'未发现该学生配置数据'));exit;
- }
- //TODO 区分3.0和抢先版
- if($isBeta){
- $defaultConfig='{
- "studentLevelDivide": {
- "levelDetails": [
- {
- "isPushTrain": true,
- "errorPushDetail": {
- },
- "trainPushDetail": {
- }
- }
- ]
- },
- "errorTypeSetting": {
- "hasEncourage":true,
- "hasScoreDetail":true,
- "hasPromoteGuide":false,
- "hasErrorOriginNote":true,
- "hasTrainTypesetting":false,
- "testVideo":false,
- "scoreOfCollege":true,
- "classmateOptimization":false,
- "commonProblems":true,
- "hasWrongAnswer":false,
- "hasRankingChange":false,
- "hasAchievementChange":false,
- "hasMathSituation":false,
- "historyCollection":true,
- "pushQuestionUpgrade":false
- }
- }';
- }else{
- $defaultConfig='{
- "studentLevelDivide": {
- "levelDetails": [
- {
- "isPushTrain": true,
- "errorPushDetail": {
- },
- "trainPushDetail": {
- }
- }
- ]
- },
- "errorTypeSetting": {
- "hasEncourage": true,
- "hasRankingChange": true,
- "hasAchievementChange": true,
- "hasGoodKnowledge": true,
- "hasLoseKnowledge": true,
- "hasScoreDetail": true,
- "hasErrorOriginNote": true,
- "hasDividePage": true,
- "pushQuestionUpgrade":true,
- "hasWrongAnswer": true,
- "isWrongAnswerEnd": true
- }
- }';
- }
- $customConfig=json_decode($defaultConfig,true);
- $errorPushDetailValue[15]=array(
- 'A'=>'pushLose',
- 'B'=>'pushZero',
- 'C'=>'pushNone'
- );
- $errorPushDetailValue[16]=array(
- 'A'=>'pushLose',
- 'B'=>'pushZero',
- 'C'=>'pushNone'
- );
- $errorPushDetailValue[17]=array(
- 'A'=>'pushLose',
- 'B'=>'pushThree',
- 'C'=>'pushHalf',
- 'D'=>'pushNone'
- );
- $errorPushDetailValue[18]=array(
- 'A'=>'pushLose',
- 'B'=>'pushThree',
- 'C'=>'pushHalf',
- 'D'=>'pushNone'
- );
- $errorPushDetailValue[19]=array(
- 'A'=>'1',
- 'B'=>'2',
- 'C'=>'3',
- 'D'=>'0'
- );
- $trainPushDetailValue[20]=array(
- 'A'=>'0',
- 'B'=>'1',
- 'C'=>'3',
- // 'D'=>'3'
- );
- $trainPushDetailValue[21]=array(
- 'A'=>'1',
- 'B'=>'2',
- 'C'=>'3',
- 'D'=>'3'
- );
- $defaultValues=array(
- 'A'=>'0',
- 'B'=>'1',
- 'C'=>'2',
- 'D'=>'3'
- );
- $errorPushDetail=array();
- $trainPushDetail=array();
- $maxTopicNumber=0; //变式训练推送题数量最大值
- $pushDifficulty=0; //变式训练推送难度
- if(count($jsonData)!=27 && count($jsonData)!=26){
- $this->output(0, "配置参数数量不正确");
- }
- if($isBeta){
- /** 3.4版本 **/
- foreach ($jsonData as $key => $val){
- switch ($val['questionNum']){
- case 1: //激励语
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasEncourage']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasEncourage']=true;
- }else{
- $customConfig['errorTypeSetting']['hasEncourage']=false;
- }
- break;
- case 2: //得分明细
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasScoreDetail']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasScoreDetail']=true;
- }else{
- $customConfig['errorTypeSetting']['hasScoreDetail']=false;
- }
- break;
- case 3: //提升指导
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasPromoteGuide']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasPromoteGuide']=true;
- }else{
- $customConfig['errorTypeSetting']['hasPromoteGuide']=false;
- }
- break;
- case 4: //排名变化图
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasRankingChange']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasRankingChange']=true;
- }else{
- $customConfig['errorTypeSetting']['hasRankingChange']=false;
- }
- break;
- case 5: //成绩变化图
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasAchievementChange']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasAchievementChange']=true;
- }else{
- $customConfig['errorTypeSetting']['hasAchievementChange']=false;
- }
- break;
- case 6: //数学情境
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasMathSituation']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasMathSituation']=true;
- }else{
- $customConfig['errorTypeSetting']['hasMathSituation']=false;
- }
- break;
- case 7: //学史典藏
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['historyCollection']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['historyCollection']=true;
- }else{
- $customConfig['errorTypeSetting']['historyCollection']=false;
- }
- break;
- case 8: //错题原笔迹
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasErrorOriginNote']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasErrorOriginNote']=true;
- }else{
- $customConfig['errorTypeSetting']['hasErrorOriginNote']=false;
- }
- break;
- case 9: //变式训练题排版方式(是否和错题一起)
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasTrainTypesetting']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasTrainTypesetting']=true;
- }else{
- $customConfig['errorTypeSetting']['hasTrainTypesetting']=false;
- }
- break;
- case 10: //考点视频二维码
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['testVideo']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['testVideo']=true;
- }else{
- $customConfig['errorTypeSetting']['testVideo']=false;
- }
- break;
- case 11: //考点高考分值表
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['scoreOfCollege']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['scoreOfCollege']=true;
- }else{
- $customConfig['errorTypeSetting']['scoreOfCollege']=false;
- }
- break;
- case 12: //同学优解
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['classmateOptimization']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['classmateOptimization']=true;
- }else{
- $customConfig['errorTypeSetting']['classmateOptimization']=false;
- }
- break;
- case 13: //共性问题
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['commonProblems']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['commonProblems']=true;
- }else{
- $customConfig['errorTypeSetting']['commonProblems']=false;
- }
- break;
- case 14: //题目和答案是否一起
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['titleAnswerMerge']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['titleAnswerMerge']=true;
- }else{
- $customConfig['errorTypeSetting']['titleAnswerMerge']=false;
- }
- break;
- case 15: //不需要错题答案解析
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasWrongAnswer']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasWrongAnswer']=true;
- }else{
- $customConfig['errorTypeSetting']['hasWrongAnswer']=false;
- }
- break;
- case 16:
- if(isset($errorPushDetailValue[15][$val['answer']])){
- $errorPushDetail['select'][]=$errorPushDetailValue[15][$val['answer']];
- }else{
- $errorPushDetail['select']=array('pushLose');
- }
- break;
- case 17:
- if(isset($errorPushDetailValue[16][$val['answer']])){
- $errorPushDetail['fillInBlank'][]=$errorPushDetailValue[16][$val['answer']];
- }else{
- $errorPushDetail['fillInBlank'][]=$errorPushDetailValue[16]['A'];
- }
- break;
- case 18:
- if(isset($errorPushDetailValue[17][$val['answer']])){
- $errorPushDetail['answer'][]=$errorPushDetailValue[17][$val['answer']];
- }else{
- $errorPushDetail['answer'][]=$errorPushDetailValue[17]['A'];;
- }
- break;
- case 19:
- if(isset($errorPushDetailValue[18][$val['answer']])){
- $errorPushDetail['chooseAnswer'][]=$errorPushDetailValue[18][$val['answer']];
- }else{
- $errorPushDetail['chooseAnswer'][]=$errorPushDetailValue[18]['A'];;
- }
- break;
- case 20:
- $values=array();
- if($val['answer']){
- $options=explode(',',$val['answer']);
- if($options){
- foreach ($options as $v){
- if(isset($errorPushDetailValue[19][$v])){
- $values[]=$errorPushDetailValue[19][$v];
- }
- }
- }
- }
- if(!$values){
- $values[]=$errorPushDetailValue[19]['D'];
- }
- $errorPushDetail['difficulty']=$values;
- break;
- case 21:
- if(isset($trainPushDetailValue[20][$val['answer']])){
- $pushDifficulty=$trainPushDetailValue[20][$val['answer']];
- }else{
- $pushDifficulty=$trainPushDetailValue[20]['A'];
- }
- break;
- case 22:
- if(isset($defaultValues[$val['answer']])){
- $trainPushDetail['pushNumber']['select']=$defaultValues[$val['answer']];
- }else{
- $trainPushDetail['pushNumber']['select']=$defaultValues['C'];
- }
- $maxTopicNumber = $trainPushDetail['pushNumber']['select'];
- $trainPushDetail['pushDifficulty']['select'] = array();
- if($maxTopicNumber){
- for($i=0;$i<$maxTopicNumber;$i++){
- $trainPushDetail['pushDifficulty']['select'][]=$pushDifficulty;
- }
- }
- break;
- case 23:
- if(isset($defaultValues[$val['answer']])){
- $trainPushDetail['pushNumber']['fillInBlank']=$defaultValues[$val['answer']];
- }else{
- $trainPushDetail['pushNumber']['fillInBlank']=$defaultValues['C'];
- }
- if($maxTopicNumber<$trainPushDetail['pushNumber']['fillInBlank']){
- $maxTopicNumber=$trainPushDetail['pushNumber']['fillInBlank'];
- $trainPushDetail['pushDifficulty']['select'] = array();
- for($i=0;$i<$maxTopicNumber;$i++){
- $trainPushDetail['pushDifficulty']['select'][]=$pushDifficulty;
- }
- }
- break;
- case 24:
- if(isset($defaultValues[$val['answer']])){
- $trainPushDetail['pushNumber']['answer']=$defaultValues[$val['answer']];
- }else{
- $trainPushDetail['pushNumber']['answer']=$defaultValues['B'];
- }
- if($maxTopicNumber<$trainPushDetail['pushNumber']['answer']){
- $maxTopicNumber=$trainPushDetail['pushNumber']['answer'];
- $trainPushDetail['pushDifficulty']['select'] = array();
- for($i=0;$i<$maxTopicNumber;$i++){
- $trainPushDetail['pushDifficulty']['select'][]=$pushDifficulty;
- }
- }
- break;
- case 25:
- if(isset($defaultValues[$val['answer']])){
- $trainPushDetail['pushNumber']['chooseAnswer']=$defaultValues[$val['answer']];
- }else{
- $trainPushDetail['pushNumber']['chooseAnswer']=$defaultValues['B'];
- }
- if($maxTopicNumber<$trainPushDetail['pushNumber']['chooseAnswer']){
- $maxTopicNumber=$trainPushDetail['pushNumber']['chooseAnswer'];
- $trainPushDetail['pushDifficulty']['select'] = array();
- for($i=0;$i<$maxTopicNumber;$i++){
- $trainPushDetail['pushDifficulty']['select'][]=$pushDifficulty;
- }
- }
- break;
- case 26:
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['pushQuestionUpgrade']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['pushQuestionUpgrade']=true;
- }else{
- $customConfig['errorTypeSetting']['pushQuestionUpgrade']=false;
- }
- break;
- default:
- $this->output(1, "上传题目数量错误");
- }
- }
- }else{
- foreach ($jsonData as $key => $val){
- switch ($val['questionNum']){
- case 1:
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasEncourage']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasEncourage']=true;
- }else{
- $customConfig['errorTypeSetting']['hasEncourage']=false;
- }
- break;
- case 2:
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasRankingChange']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasRankingChange']=true;
- }else{
- $customConfig['errorTypeSetting']['hasRankingChange']=false;
- }
- break;
- case 3:
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasAchievementChange']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasAchievementChange']=true;
- }else{
- $customConfig['errorTypeSetting']['hasAchievementChange']=false;
- }
- break;
- case 4:
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasGoodKnowledge']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasGoodKnowledge']=true;
- }else{
- $customConfig['errorTypeSetting']['hasGoodKnowledge']=false;
- }
- break;
- case 5:
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasLoseKnowledge']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasLoseKnowledge']=true;
- }else{
- $customConfig['errorTypeSetting']['hasLoseKnowledge']=false;
- }
- break;
- case 6:
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasScoreDetail']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasScoreDetail']=true;
- }else{
- $customConfig['errorTypeSetting']['hasScoreDetail']=false;
- }
- break;
- case 7: //考试难度小贴士
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['examinationDifficulty']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['examinationDifficulty']=true;
- }else{
- $customConfig['errorTypeSetting']['examinationDifficulty']=false;
- }
- break;
- case 8: //考点视频二维码
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['testVideo']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['testVideo']=true;
- }else{
- $customConfig['errorTypeSetting']['testVideo']=false;
- }
- break;
- case 9: //考点高考分值表
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['scoreOfCollege']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['scoreOfCollege']=true;
- }else{
- $customConfig['errorTypeSetting']['scoreOfCollege']=false;
- }
- break;
- case 10: //同学优解
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['classmateOptimization']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['classmateOptimization']=true;
- }else{
- $customConfig['errorTypeSetting']['classmateOptimization']=false;
- }
- break;
- case 11:
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasErrorOriginNote']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasErrorOriginNote']=true;
- }else{
- $customConfig['errorTypeSetting']['hasErrorOriginNote']=false;
- }
- break;
- case 12:
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasTrainTypesetting']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasTrainTypesetting']=true;
- }else{
- $customConfig['errorTypeSetting']['hasTrainTypesetting']=false;
- }
- break;
- case 13:
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasDividePage']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasDividePage']=true;
- }else{
- $customConfig['errorTypeSetting']['hasDividePage']=false;
- }
- break;
- case 14: //两步错题答案解析不展示
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['hasWrongAnswer']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['hasWrongAnswer']=true;
- }else{
- $customConfig['errorTypeSetting']['hasWrongAnswer']=false;
- }
- break;
- case 15: //错题是否显示在最后
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['isWrongAnswerEnd']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['isWrongAnswerEnd']=true;
- }else{
- $customConfig['errorTypeSetting']['isWrongAnswerEnd']=false;
- }
- break;
- case 16: //共性问题
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['commonProblems']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['commonProblems']=true;
- }else{
- $customConfig['errorTypeSetting']['commonProblems']=false;
- }
- break;
- case 17:
- if(isset($errorPushDetailValue[15][$val['answer']])){
- $errorPushDetail['select'][]=$errorPushDetailValue[15][$val['answer']];
- }else{
- $errorPushDetail['select']=array('pushLose');
- }
- break;
- case 18:
- if(isset($errorPushDetailValue[16][$val['answer']])){
- $errorPushDetail['fillInBlank'][]=$errorPushDetailValue[16][$val['answer']];
- }else{
- $errorPushDetail['fillInBlank'][]=$errorPushDetailValue[16]['A'];
- }
- break;
- case 19:
- if(isset($errorPushDetailValue[17][$val['answer']])){
- $errorPushDetail['answer'][]=$errorPushDetailValue[17][$val['answer']];
- }else{
- $errorPushDetail['answer'][]=$errorPushDetailValue[17]['A'];;
- }
- break;
- case 20:
- if(isset($errorPushDetailValue[18][$val['answer']])){
- $errorPushDetail['chooseAnswer'][]=$errorPushDetailValue[18][$val['answer']];
- }else{
- $errorPushDetail['chooseAnswer'][]=$errorPushDetailValue[18]['A'];;
- }
- break;
- case 21:
- $values=array();
- if($val['answer']){
- $options=explode(',',$val['answer']);
- if($options){
- foreach ($options as $v){
- if(isset($errorPushDetailValue[19][$v])){
- $values[]=$errorPushDetailValue[19][$v];
- }
- }
- }
- }
- if(!$values){
- $values[]=$errorPushDetailValue[19]['D'];
- }
- $errorPushDetail['difficulty']=$values;
- break;
- case 22:
- if(isset($trainPushDetailValue[20][$val['answer']])){
- $pushDifficulty=$trainPushDetailValue[20][$val['answer']];
- }else{
- $pushDifficulty=$trainPushDetailValue[20]['A'];
- }
- break;
- case 23:
- if(isset($trainPushDetailValue[21][$val['answer']])){
- $trainPushDetail['pushNumber']['select']=$trainPushDetailValue[21][$val['answer']];
- }else{
- $trainPushDetail['pushNumber']['select']=$trainPushDetailValue[21]['B'];
- }
- for($i=0;$i<$trainPushDetail['pushNumber']['select'];$i++){
- $trainPushDetail['pushDifficulty']['select'][]=$pushDifficulty;
- }
- break;
- case 24:
- if(isset($trainPushDetailValue[21][$val['answer']])){
- $trainPushDetail['pushNumber']['fillInBlank']=$trainPushDetailValue[21][$val['answer']];
- }else{
- $trainPushDetail['pushNumber']['fillInBlank']=$trainPushDetailValue[21]['B'];
- }
- if($maxTopicNumber<$trainPushDetail['pushNumber']['fillInBlank']){
- $maxTopicNumber=$trainPushDetail['pushNumber']['fillInBlank'];
- }
- if(isset($trainPushDetail['pushDifficulty']['select']) && count($trainPushDetail['pushDifficulty']['select'])<$trainPushDetail['pushNumber']['fillInBlank']){
- $trainPushDetail['pushDifficulty']['select']=array();
- for($i=0;$i<$trainPushDetail['pushNumber']['fillInBlank'];$i++){
- $trainPushDetail['pushDifficulty']['select'][]=$pushDifficulty;
- }
- }
- break;
- case 25:
- if(isset($trainPushDetailValue[21][$val['answer']])){
- $trainPushDetail['pushNumber']['answer']=$trainPushDetailValue[21][$val['answer']];
- }else{
- $trainPushDetail['pushNumber']['answer']=$trainPushDetailValue[21]['B'];
- }
- if(isset($trainPushDetail['pushDifficulty']['select']) && count($trainPushDetail['pushDifficulty']['select'])<$trainPushDetail['pushNumber']['answer']){
- $trainPushDetail['pushDifficulty']['select']=array();
- for($i=0;$i<$trainPushDetail['pushNumber']['answer'];$i++){
- $trainPushDetail['pushDifficulty']['select'][]=$pushDifficulty;
- }
- }
- break;
- case 26:
- if(isset($trainPushDetailValue[21][$val['answer']])){
- $trainPushDetail['pushNumber']['chooseAnswer']=$trainPushDetailValue[21][$val['answer']];
- }else{
- $trainPushDetail['pushNumber']['chooseAnswer']=$trainPushDetailValue[21]['B'];
- }
- if(isset($trainPushDetail['pushDifficulty']['select']) && count($trainPushDetail['pushDifficulty']['select'])<$trainPushDetail['pushNumber']['chooseAnswer']){
- $trainPushDetail['pushDifficulty']['select']=array();
- for($i=0;$i<$trainPushDetail['pushNumber']['chooseAnswer'];$i++){
- $trainPushDetail['pushDifficulty']['select'][]=$pushDifficulty;
- }
- }
- break;
- case 27:
- if(!$val['answer']){
- $customConfig['errorTypeSetting']['pushQuestionUpgrade']=true;
- }elseif($val['answer']=='A'){
- $customConfig['errorTypeSetting']['pushQuestionUpgrade']=true;
- }else{
- $customConfig['errorTypeSetting']['pushQuestionUpgrade']=false;
- }
- break;
- default:
- $this->output(1, "上传题目数量错误");
- }
- }
- }
- $customConfig['studentLevelDivide']['levelDetails'][0]['errorPushDetail']=$errorPushDetail;
- $customConfig['studentLevelDivide']['levelDetails'][0]['trainPushDetail']=$trainPushDetail;
- $this->sConn->createCommand("update product_student_set set use_custom=1,custom_config_json='".json_encode($customConfig)."' where student_id='{$studentId}' and semester_id='{$this->semesterId}' and subject_id='{$subject_id}' and is_beta={$isBeta}")->execute();
- echo json_encode(array('status'=>1,'msg'=>'修改成功 '));exit;
- }
- //修改英语自选卡
- public function actionSaveEnglishOptionalCard(){
- $subject=isset($_POST["subject"])?$_POST["subject"]:'';
- $student_id=isset($_POST["studentId"])?$_POST["studentId"]:'';
- $json=isset($_POST["json"])?$_POST["json"]:'';
- $subject_id=$this->subjectId;
- if(!$student_id){
- $this->output(0, "学生ID不能为空");
- }
- if(!$json){
- $this->output(0, "学生勾选数据不能为空");
- }
- if($subject!=8){
- $this->output(0, "科目错误 ");
- }
- $studentImg=isset($_POST["studentImg"])?$_POST["studentImg"]:'';
- $file['src']=$studentImg;
- //json数据转换
- $jsonData=@json_decode($json,true);
- if(!$jsonData){
- $this->output(0, "数据格式错误");
- }
- $customConfig=array(
- 'moduleName'=>'个性化学习宝',
- 'moduleType'=>'english_3',
- 'setting'=>array(
- 'achievementAnalysisAndGoalSetting' =>1, //成长轨迹
- 'analyzeAndFindTheCause' =>1, //阶段小结
- 'readingTrainingLevel' =>array( //阅读训练分等级
- 'questionTypeScore' =>1, //题型得分表
- 'analysisOfWrongQuestions' =>1 //错分析表
- ),
- 'scoringTraining' =>array( //提分训练
- 'scoreRaisingTraining' =>1, //提分训练
- 'errorAnalysis' =>1, //错因分析
- 'vocabularyAccumulation' =>1, //词汇积累
- 'syntacticAnalysis' =>1, //句法剖析
- 'skillInspiration' =>1, //技巧点拨
- 'readingLevelDescription' =>1, //阅读等级说明
- 'compositionDisplay' =>1, //作文展示
- 'thinkingOfExamination' =>1, //审题思路
- 'standardModelText' =>1, //标准范文
- 'modelTextHighlights' =>1, //范文亮点
- 'writingTemplate' =>1, //写作模板
- ),
- 'variantTrainingOfCommonProblems' =>1, //共性问题变式训练
- 'numberOfWrongQuestions' =>array( //错题数量
- //考后复习部分设置
- 'scoringTraining' =>array(
- 'readingComprehension' =>'1', //阅读理解 1配1,2配2
- 'taskBasedReading' =>1, //短文改错1,2,3==>任务型阅读
- 'sevenChooseFive' =>1, //七选五1,2,3
- 'gestaltFilling' =>'1', //完形填空 1配1,2配2
- 'grammaticalFillIn' =>'1', //语法填空
- 'vocabularyApplication' =>1, //词汇运用
- 'variantTraining' =>1, //变式训练
- ),
- )
- )
- );
- $answer19=array(
- 'A'=>'3',
- 'B'=>'6',
- 'C'=>'10',
- 'D'=>'0'
- );
- $answer20=array(
- 'A'=>'1',
- 'B'=>'2',
- 'C'=>'3',
- 'D'=>'0'
- );
- if(count($jsonData)!=21){
- $this->output(0, "配置参数数量不正确");
- }
- foreach ($jsonData as $key => $val){
- switch ($val['questionNum']){
- case 1: //成长轨迹
- if(!$val['answer']){
- $customConfig['setting']['achievementAnalysisAndGoalSetting']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['achievementAnalysisAndGoalSetting']=1;
- }else{
- $customConfig['setting']['achievementAnalysisAndGoalSetting']=0;
- }
- break;
- case 2://阶段小结
- if(!$val['answer']){
- $customConfig['setting']['analyzeAndFindTheCause']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['analyzeAndFindTheCause']=1;
- }else{
- $customConfig['setting']['analyzeAndFindTheCause']=0;
- }
- break;
- case 3://题型得分表
- if(!$val['answer']){
- $customConfig['setting']['readingTrainingLevel']['questionTypeScore']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['readingTrainingLevel']['questionTypeScore']=1;
- $customConfig['setting']['readingTrainingLevel']['analysisOfWrongQuestions']=1;
- }else{
- $customConfig['setting']['readingTrainingLevel']['questionTypeScore']=0;
- $customConfig['setting']['readingTrainingLevel']['analysisOfWrongQuestions']=0;
- }
- break;
- case 4://错题分析表
- if(!$val['answer']){
- $customConfig['setting']['readingTrainingLevel']['analysisOfWrongQuestions']=1;//错题分析表
- }elseif($val['answer']=='A'){
- $customConfig['setting']['readingTrainingLevel']['analysisOfWrongQuestions']=1;//错题分析表
- }else{
- $customConfig['setting']['readingTrainingLevel']['analysisOfWrongQuestions']=0;//错题分析表
- }
- break;
- case 5://提分训练
- if(!$val['answer']){
- $customConfig['setting']['scoringTraining']['scoreRaisingTraining']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['scoringTraining']['scoreRaisingTraining']=1;
- }else{
- $customConfig['setting']['scoringTraining']['scoreRaisingTraining']=0;
- }
- break;
- case 6://错因分析
- if(!$val['answer']){
- $customConfig['setting']['scoringTraining']['errorAnalysis']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['scoringTraining']['errorAnalysis']=1;
- }else{
- $customConfig['setting']['scoringTraining']['errorAnalysis']=0;
- }
- break;
- case 7://词汇积累
- if(!$val['answer']){
- $customConfig['setting']['scoringTraining']['vocabularyAccumulation']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['scoringTraining']['vocabularyAccumulation']=1;
- }else{
- $customConfig['setting']['scoringTraining']['vocabularyAccumulation']=0;
- }
- break;
- case 8: //句法剖析
- if(!$val['answer']){
- $customConfig['setting']['scoringTraining']['syntacticAnalysis']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['scoringTraining']['syntacticAnalysis']=1;
- }else{
- $customConfig['setting']['scoringTraining']['syntacticAnalysis']=0;
- }
- break;
- case 9: //技巧点拨
- if(!$val['answer']){
- $customConfig['setting']['scoringTraining']['skillInspiration']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['scoringTraining']['skillInspiration']=1;
- }else{
- $customConfig['setting']['scoringTraining']['skillInspiration']=0;
- }
- break;
- case 10://阅读等级说明
- if(!$val['answer']){
- $customConfig['setting']['scoringTraining']['readingLevelDescription']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['scoringTraining']['readingLevelDescription']=1;
- }else{
- $customConfig['setting']['scoringTraining']['readingLevelDescription']=0;
- }
- break;
- case 11://作文展示
- if(!$val['answer']){
- $customConfig['setting']['scoringTraining']['compositionDisplay']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['scoringTraining']['compositionDisplay']=1;
- }else{
- $customConfig['setting']['scoringTraining']['compositionDisplay']=0;
- }
- break;
- case 12: //审题思路
- if(!$val['answer']){
- $customConfig['setting']['scoringTraining']['thinkingOfExamination']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['scoringTraining']['thinkingOfExamination']=1;
- }else{
- $customConfig['setting']['scoringTraining']['thinkingOfExamination']=0;
- }
- break;
- case 13://标准范文
- if(!$val['answer']){
- $customConfig['setting']['scoringTraining']['standardModelText']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['scoringTraining']['standardModelText']=1;
- }else{
- $customConfig['setting']['scoringTraining']['standardModelText']=0;
- }
- break;
- case 14://范文亮点
- if(!$val['answer']){
- $customConfig['setting']['scoringTraining']['modelTextHighlights']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['scoringTraining']['modelTextHighlights']=1;
- }else{
- $customConfig['setting']['scoringTraining']['modelTextHighlights']=0;
- }
- break;
- case 15://写作模板
- if(!$val['answer']){
- $customConfig['setting']['scoringTraining']['writingTemplate']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['scoringTraining']['writingTemplate']=1;
- }else{
- $customConfig['setting']['scoringTraining']['writingTemplate']=0;
- }
- break;
- case 16://共性问题变式训练
- if(!$val['answer']){
- $customConfig['setting']['variantTrainingOfCommonProblems']=1;
- }elseif($val['answer']=='A'){
- $customConfig['setting']['variantTrainingOfCommonProblems']=1;
- }else{
- $customConfig['setting']['variantTrainingOfCommonProblems']=0;
- }
- break;
- case 17://词汇运用
- if(!$val['answer'] && isset($answer19[$val['answer']])){
- $customConfig['setting']['numberOfWrongQuestions']['scoringTraining']['vocabularyApplication']=$answer19[$val['answer']];
- }else{
- $customConfig['setting']['numberOfWrongQuestions']['scoringTraining']['vocabularyApplication']=0;
- }
- break;
- case 18://阅读理解
- if(!$val['answer'] && isset($answer20[$val['answer']])){
- $customConfig['setting']['numberOfWrongQuestions']['scoringTraining']['readingComprehension']=$answer20[$val['answer']];
- }else{
- $customConfig['setting']['numberOfWrongQuestions']['scoringTraining']['readingComprehension']=0;
- }
- break;
- case 19://完形填空
- if(!$val['answer'] && isset($answer20[$val['answer']])){
- $customConfig['setting']['numberOfWrongQuestions']['scoringTraining']['gestaltFilling']=$answer20[$val['answer']];
- }else{
- $customConfig['setting']['numberOfWrongQuestions']['scoringTraining']['gestaltFilling']=0;
- }
- break;
- case 20://七选五
- if(!$val['answer'] && isset($answer20[$val['answer']])){
- $customConfig['setting']['numberOfWrongQuestions']['scoringTraining']['sevenChooseFive']=$answer20[$val['answer']];
- }else{
- $customConfig['setting']['numberOfWrongQuestions']['scoringTraining']['sevenChooseFive']=0;
- }
- break;
- case 21://语法填空
- if(!$val['answer'] && isset($answer20[$val['answer']])){
- $customConfig['setting']['numberOfWrongQuestions']['scoringTraining']['grammaticalFillIn']=$answer20[$val['answer']];
- }else{
- $customConfig['setting']['numberOfWrongQuestions']['scoringTraining']['grammaticalFillIn']=0;
- }
- break;
- default:
- $this->output(1, "上传题目数量错误");
- }
- }
- $this->sConn->createCommand("update product_student_set set use_custom=1,custom_config_json='".json_encode($customConfig)."' where student_id='{$student_id}' and semester_id='{$this->semesterId}' and subject_id='{$subject_id}'")->execute();
- echo json_encode(array('status'=>1,'msg'=>'修改成功 '));exit;
- }
- //切换学科
- public function actionChangeSubject(){
- $subjectId=Req::post('subjectId')?Req::post('subjectId'):0;
- if(!$subjectId){
- echo json_encode(array('status'=>0,'msg'=>'学科不正确 '));exit;
- }else{
- Yii::app()->session['session_duoxueke_subject_id'] = $subjectId;
- Yii::app()->session['session_subject_id'] = $subjectId;
- echo json_encode(array('status'=>1));exit;
- }
- }
- //获取当前学科
- function actionGetSubject(){
- // echo json_encode($_SESSION);exit;
- // echo $_SESSION['session_duoxueke_subject_id'];exit;
- $subjectId = Yii::app()->session['session_duoxueke_subject_id'];
- echo $subjectId;exit;
- }
- //初始化产品设置
- public function actionInitProductSetting(){
- $subjectId = Yii::app()->session['session_duoxueke_subject_id'];
- if($subjectId == 12 || in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- $this->initTemplate3();
- echo json_encode(array('status'=>1));exit;
- }else{
- echo json_encode(array('status'=>0,'msg'=>'学科错误'));exit;
- }
- echo json_encode(array('status'=>1));exit;
- }
- /**
- *
- */
- //教师教案班级列表
- public function actionTeachingList(){
- $ttModel = new TeachingTemplate();
- $teacherId = Req::post('teacher_id')?(string)Req::post('teacher_id'):''; //接口传的教师ID
- $grade = Req::post('grade')?intval(Req::post('grade')):0; //接口传的年级
- $classId = Req::post('class_id')?(string)Req::post('class_id'):''; //接口传的班级ID
- $limit = Req::post('limit')?intval(Req::post('limit')):15; //接口传的每页显示条数
- $page = Req::post('page')?intval(Req::post('page')):1; //接口传的当前页
- $subjectId=Yii::app()->session['session_duoxueke_subject_id'];
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- $subjectId = 3;
- }
- if($subjectId != 3){
- echo json_encode(array('status'=>0,'msg'=>'学科错误'));exit;
- }
- if($subjectId == 3){
- $json = '{"common":1,"common_wrong":1,"paper":1,"paper_wrong":1,"real_topic":1,"classmateOptimization":1}';
- $status = $ttModel->initTemplate($subjectId,$json,'班级默认模板');
- if(!$status){
- echo json_encode(array('status'=>0,'msg'=>'初始化模板失败'));exit;
- }
- }
- $list = $ttModel->listTemplate($subjectId,$teacherId,$grade,$classId,$limit,$page);
- echo json_encode(array('status'=>1,'data'=>$list));exit;
- }
- //教师讲案搜索教师
- public function actionTeachingSearchTeacher(){
- $ttModel = new TeachingTemplate();
- $subjectId=Yii::app()->session['session_duoxueke_subject_id'];
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- $subjectId = 3;
- }
- $list = $ttModel->teacherList($subjectId);
- echo json_encode(array('status'=>1,'data'=>$list));exit;
- }
- //教师讲案编辑保存
- public function actionTeachingEdit(){
- $ttModel = new TeachingTemplate();
- $classId = Req::post('class_id')?Req::post('class_id'):''; //接口传的班级ID
- if(!$classId){
- echo json_encode(array('status'=>0,'msg'=>'班级ID不正确'));exit;
- }else{
- $classIdArr = explode(",",$classId);
- }
- $templateId = Req::post('template_id')?intval(Req::post('template_id')):0; //接口传的模板ID
- if(!$templateId){
- echo json_encode(array('status'=>0,'msg'=>'模板ID不正确'));exit;
- }
- $subjectId=Yii::app()->session['session_duoxueke_subject_id'];
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- $subjectId = 3;
- }
- $status = $ttModel->editTemplate($classIdArr,$subjectId,$templateId);
- if($status){
- echo json_encode(array('status'=>1));exit;
- }else{
- echo json_encode(array('status'=>0,'msg'=>'保存失败'));exit;
- }
- }
- //教师讲案恢复默认
- public function actionTeachingRestoreClass(){
- $ttModel = new TeachingTemplate();
- $classId = Req::post('class_id')?(string)Req::post('class_id'):''; //接口传的班级ID
- if(!$classId){
- echo json_encode(array('status'=>0,'msg'=>'班级ID不正确'));exit;
- }
- $subjectId=Yii::app()->session['session_duoxueke_subject_id'];
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- $subjectId = 3;
- }
- $status = $ttModel->restoreClassDefault($classId,$subjectId);
- if($status){
- echo json_encode(array('status'=>1));exit;
- }else{
- echo json_encode(array('status'=>0,'msg'=>'操作失败'));exit;
- }
- }
- //教师讲案模板列表
- public function actionTeachingTemplateList(){
- $ttModel = new TeachingTemplate();
- $subjectId=Yii::app()->session['session_duoxueke_subject_id'];
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- $subjectId = 3;
- }
- $list = $ttModel->getList($subjectId);
- echo json_encode(array('status'=>1,'data'=>$list));exit;
- }
- //教师讲案模板详情
- public function actionTeachingTemplateDetail(){
- $ttModel = new TeachingTemplate();
- $templateId = Req::post('template_id')?intval(Req::post('template_id')):0; //接口传的模板ID
- if(!$templateId){
- echo json_encode(array('status'=>0,'msg'=>'模板ID不正确'));exit;
- }
- $list = $ttModel->detailTemplate($templateId);
- echo json_encode(array('status'=>1,'data'=>$list));exit;
- }
- //教师讲案模板设置保存
- public function actionTeachingTemplateSave(){
- $ttModel = new TeachingTemplate();
- $templateId = Req::post('template_id')?intval(Req::post('template_id')):0; //接口传的模板ID
- $json = Req::post('json')?(string)Req::post('json'):''; //接口传的设置
- if(!$templateId){
- echo json_encode(array('status'=>0,'msg'=>'模板ID不正确'));exit;
- }
- if(!$json){
- echo json_encode(array('status'=>0,'msg'=>'设置参数不正确'));exit;
- }else{
- $json=str_replace('"','"',$json);
- }
- $status = $ttModel->saveTemplate($templateId,$json);
- if($status){
- echo json_encode(array('status'=>1));exit;
- }else{
- echo json_encode(array('status'=>0,'msg'=>'保存失败'));exit;
- }
- }
- //教师讲案模板改名
- public function actionTeachingTemplateChangeName(){
- $ttModel = new TeachingTemplate();
- $templateId = Req::post('template_id')?intval(Req::post('template_id')):0; //接口传的模板ID
- $templateName = Req::post('template_name')?(string)Req::post('template_name'):''; //接口传的模板名称
- if(!$templateId){
- echo json_encode(array('status'=>0,'msg'=>'模板ID不正确'));exit;
- }
- if(!$templateName){
- echo json_encode(array('status'=>0,'msg'=>'模板名称不正确'));exit;
- }
- $subjectId=Yii::app()->session['session_duoxueke_subject_id'];
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- $subjectId = 3;
- }
- $status = $ttModel->changeName($templateId,$templateName,$subjectId);
- if($status['status'] == 1){
- echo json_encode(array('status'=>1));exit;
- }else{
- echo json_encode(array('status'=>0,'msg'=>$status['error']));exit;
- }
- }
- //教师讲案模板删除
- public function actionTeachingTemplateDel(){
- $ttModel = new TeachingTemplate();
- $templateId = Req::post('template_id')?intval(Req::post('template_id')):0; //接口传的模板ID
- if(!$templateId){
- echo json_encode(array('status'=>0,'msg'=>'模板ID不正确'));exit;
- }
- $subjectId=Yii::app()->session['session_duoxueke_subject_id'];
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- $subjectId = 3;
- }
- $status = $ttModel->delTemplate($templateId,$subjectId);
- if($status['status'] == 1){
- echo json_encode(array('status'=>1));exit;
- }else{
- echo json_encode(array('status'=>0,'msg'=>$status['error']));exit;
- }
- }
- //教师讲案模板复制
- public function actionTeachingTemplateCopy(){
- $ttModel = new TeachingTemplate();
- $templateId = Req::post('template_id')?intval(Req::post('template_id')):0; //接口传的模板ID
- if(!$templateId){
- echo json_encode(array('status'=>0,'msg'=>'模板ID不正确'));exit;
- }
- $subjectId=Yii::app()->session['session_duoxueke_subject_id'];
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- $subjectId = 3;
- }
- $error = $ttModel->copyTemplate($templateId,$subjectId);
- if(!$error){
- echo json_encode(array('status'=>1));exit;
- }else{
- echo json_encode(array('status'=>0,'msg'=>$error));exit;
- }
- }
- /**
- * 教师讲案跳转
- */
- public function actionTeachingIndex(){
- $subjectId=Yii::app()->session['session_duoxueke_subject_id'];
- //////新跳转规则////////
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- Header("Location: ".Yii::app()->params['product_setting_url']."index.html#/TeachSet/ClassList");
- exit;
- }else{
- Yii::app()->jump->error('学科错误!');
- }
- }
- /**
- * 获取样式类型
- */
- public function actionGetStyleType()
- {
- $subjectId=Yii::app()->session['session_duoxueke_subject_id'];
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- $subjectId = 3;
- }
- $styleVersion = new SSubjectStyleVersion();
- echo json_encode(array('status'=>1, 'data'=>array('style_type'=>$styleVersion->getStyleType($subjectId))));exit;
- }
- /**
- * 样式类型切换
- */
- public function actionSwitchStyle()
- {
- $styleType = (int)Req::post('style_type');
- $subjectId=Yii::app()->session['session_duoxueke_subject_id'];
- if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
- $subjectId = 3;
- }
- $count = SSubjectStyleVersion::model()->updateAll(array('style_type'=>$styleType, 'update_time'=>time()),'subject_id=:subject_id',array(':subject_id'=>$subjectId));
- if($count>0){
- echo json_encode(array('status'=>1,'msg'=>'更新成功'));exit;
- }else{
- echo json_encode(array('status'=>0,'msg'=>'更新失败'));exit;
- }
- }
- /**
- * 是否是完整版词汇宝
- * @return bool
- */
- public function isWholeMagic(){
- $http = http('order/goods-type/open-time/'.$this->schoolId, 'GET', $this->authUsername);
- $response = formatResponse($http);
- return isset($response['data']) && !empty($response['data']) ? (strtotime($response['data'])<1653926400 ? true : false) : false;
- }
- /**
- * 词汇宝模块恢复
- */
- public function actionResumeModule(){
- $psId = (int)Req::get('ps_id');
- $model = SProductSetting::model()->findByPk($psId);
- $config = json_decode($model->custom_config, true);
- $config['setting']['isWhole'] = 1;
- SProductSetting::model()->updateByPk($psId, array('custom_config'=>json_encode($config, true)));
- echo 1;exit;
- }
- }
|