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; } }