12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177 |
- <?php
- /**
- * 家校考试管理控制器类
- * @author li
- * @date 2019-04-17 10:50:00
- * @company 上海风车教育有限公司.
- */
- class ZhiliaoController extends Controller{
- // 首页
- public function actionIndex(){
- Url::clean();
- $Grade=intval(Req::get('grade'));
- $Class=Req::get('classId');
- $Page=intval(Req::get('page'));
- $Display=intval(Req::get('display'));
- $coach_id = $this->coachId;
- $semester_id = $this->semesterId;
- $PageLimit=9;
- if(!$Page) $Page=1;
- $ZlExamGroup=new ZlExamGroup();
- $result=$ZlExamGroup->getList($Grade,$Class,$semester_id,$Page,$PageLimit,$Display);
- $ZlStudentExamRelation=new ZlStudentExamRelation();
- $ZlStudentExamRs=new ZlStudentExamRs();
- if($result['data']){
- foreach($result['data'] as $key=>$val){
- $tpl_data=json_decode($val['zl_tpl_data'],true);
- $result['data'][$key]['classCount']=$tpl_data['classCount'];
- $result['data'][$key]['subjectCount']=count($tpl_data['items']);
- $subjectArr=array();
- foreach ($tpl_data['items'] as $sid=>$c){
- $subjectArr[]= Yii::app()->params['subjectId'][$sid];
- }
- $result['data'][$key]['subjects']=$subjectArr;
- //上传进度
- $allStudent=$ZlStudentExamRelation->getCountStudentByExamGroupId($val['zl_exam_group_id']);
- $allStudentRs=$ZlStudentExamRs->getCountStudentRsByExamGroupId($val['zl_exam_group_id']);
- $result['data'][$key]['progress']=$allStudentRs.'/'.$allStudent;
- if($allStudentRs){
- $result['data'][$key]['status']=1;
- }else{
- $result['data'][$key]['status']=0;
- }
- }
- }
- // debug($result);
- $printType = '2';
- $printTypeData = 0;
- $viewData=array(
- 'pageTotal' =>$result['pageTotal'],
- 'dataList' =>$result['data'],
- 'page' =>$Page,
- 'grade' =>$Grade,
- 'class' =>$Class,
- 'display' =>$Display,
- 'totalCount' =>$result['totalCount'],
- 'printType' =>$printType
- );
- //$HeadInfo=$this->getHeadInfo();
- // $viewData=array_merge($viewData,$HeadInfo);
- $this->render('index',$viewData);
- }
- public function actionEdit(){
- $viewData=array();
- $viewData=array(
- 'printType'=>'zl'
- );
- if(isset(Yii::app()->params['subjectId']) && Yii::app()->params['subjectId']){
- $viewData['subject']=Yii::app()->params['subjectId'];
- unset($viewData['subject'][3]);
- unset($viewData['subject'][51]);
- unset($viewData['subject'][20]);
- }
- $exam_group_id = Req::get("exam_group_id");
- if($exam_group_id){
- //读取考试信息
- $ZlExamGroup=new ZlExamGroup();
- $ZlStudentExamRs=new ZlStudentExamRs();
- $studentRs=$ZlStudentExamRs->getCountStudentRsByExamGroupId($exam_group_id);
- if($studentRs){
- Yii::app()->jump->error('已上传成绩,不能编辑考试!');
- }
- $examData=$ZlExamGroup->getExamByExamGroupId($exam_group_id);
- $examView=array();
- $tplData=array();
- foreach ($examData as $val){
- if(!$tplData){
- $tplData=json_decode($val['zl_tpl_data'],true);
- $examView['items']=$tplData['items'];
- //$examView['examDate']=$tplData['examDate'];
- }
- $examView['zl_exam_name']=$val['zl_exam_name'];
- $examView['zl_exam_type']=$val['zl_exam_type'];
- $examView['examDate']=date('Y-m-d',$val['zl_exam_date']);
- $examView['classes'][$val['zl_class_id']]=ClassModel::model()->getClassName($val['zl_class_id']);
- $examView['grade']=$val['zl_grade'];
- }
- $viewData['exam']=$examView;
- $viewData['exam_group_id']=$exam_group_id;
- }
-
- $this->render('thirdview',$viewData);
- }
- public function actionAjaxchangeclasses()
- {
- $result = array();
- $error = array();
- $class_arr_select=array();
- if (Yii::app()->request->getIsPostRequest()){
- $selectedClassId=Req::post('selectedClassId');
- $semester_id = $this->semesterId;
- if($selectedClassId){
- $anotherSelectClass=ClassModel ::model()->getClassArrayByIds($selectedClassId);
- $i = 0;
- if($anotherSelectClass){
- foreach ($anotherSelectClass as $cas){
- $class_arr_select[$i]['class_id'] = $cas['class_id'];
- $class_arr_select[$i]['class_name'] = $cas['class_name'];
- $class_arr_select[$i]['grade'] = $cas['grade'];
- $i++;
- $class_arr_select_ids[] = $cas['class_id'];
- }
- }
- }
- $class_arr_select_ids_str = "";
- if(isset($class_arr_select_ids) && $class_arr_select_ids){
- foreach($class_arr_select_ids as $v){
- $class_arr_select_ids_str.=$v.",";
- }
- $class_arr_select_ids_str=substr($class_arr_select_ids_str,0,-1);
- }
- $class_arr_noselect_data = ClassModel ::model()->getNoSelectclasses($semester_id,$class_arr_select_ids_str);
- $class_arr_noselect =array();
- $j = 0;
- if($class_arr_noselect_data){
- foreach($class_arr_noselect_data as $cans){
- $class_arr_noselect[$j]['class_id'] = $cans->class_id;
- $class_arr_noselect[$j]['class_name'] = $cans->class_name;
- $class_arr_noselect[$j]['grade'] = $cans->grade;
- $j++;
- }
- }
- $result['class_arr_select'] = $class_arr_select;
- $result['class_arr_noselect'] = $class_arr_noselect;
- }else{
- $error[] = "错误的来源";
- }
- header('Content-Type: application/json');
- if($error){
- echo json_encode(array('status' => 0, 'error'=> implode('<br/>', $error)));exit;
- }else{
- echo json_encode($result);exit;
- }
- }
- public function actionCreateexam(){
- $error = array();
- $examName = Req::post("examName");
- $type = (int)Req::post("type");
- $classIds = Req::post("classIds");
- $subjects = Req::post("subjects");
- $examDate = Req::post("examDate");
- $grade = Req::post("grade");
- $ExamGroupId = Req::post("exam_group_id");
- if(empty($classIds)){
- $error[] = '请指定考试班级';
- }else{
- $classIds = explode(',',substr($classIds,0,-1));
- }
- if(empty($examName)){
- $error[] = '请设置考试名称';
- }
- if ($type <= 0 || $type > 8) {
- $error[] = '考试类型错误';
- }
- if(empty($subjects)){
- $error[] = '请选择科目';
- }
- if(empty($examDate)){
- $error[] = '请指定考试时间';
- }
- if((time()-strtotime($examDate))>86400*90){
- $error[] = '考试时间不正确';
- }
- if($error){
- Yii::app()->jump->error(implode(',',$error));
- }else{
- //解析科目分数
- $tplData=array();
- $tplData['name']=$examName;
- // $tplData['examDate']=$examDate;
- $tplData['classCount']=count($classIds);
- $subject_ids=array();
- $subjectArr=explode(',',$subjects);
- if($subjectArr){
- $total_score=0;
- foreach ($subjectArr as $value){
- $subject_score=explode('///',$value);
- $tplData['items'][$subject_score[0]]=$subject_score[1];
- $total_score+=$subject_score[1];
- $subject_ids[]=$subject_score[0];
- }
- $tplData['scores']=$total_score;
- }
-
- $time = time();
- $transaction = $this->sConn->beginTransaction();
- try{
- if($ExamGroupId){
- $this->sConn->createCommand("delete from `zl_exam_group` where zl_exam_group_id='".$ExamGroupId."'")->execute();
- $this->sConn->createCommand("delete from `zl_exam` where zl_exam_group_id='".$ExamGroupId."'")->execute();
- $this->sConn->createCommand("delete from `zl_student_exam_relation` where zl_exam_group_id='".$ExamGroupId."'")->execute();
- $newExamGroupId = $ExamGroupId;
- }else{
- // $newExamGroupId = $this->schoolManager->UUID_SHORT();
- $newExamGroupId=getUniqueId($this->schoolId);
- }
- $sql = "insert into `zl_exam_group` (`zl_exam_group_id`,`zl_exam_name`,`zl_exam_type`,`zl_grade`,`zl_exam_date`,`zl_create_time`,`zl_is_display`,`zl_semester_id`) "
- . "values (".$newExamGroupId.",'".$examName."',".$type.",'".$grade."','".strtotime($examDate)."',".time().",0,'".$this->semesterId."')";
- $this->sConn->createCommand($sql)->execute();
- foreach($classIds as $classId){
- //$newExamId = $this->schoolManager->UUID_SHORT();
- $newExamId=getUniqueId($this->schoolId);
- $sql = "select g.card_length,g.card_status FROM grade g LEFT JOIN class c on g.id = c.grade where c.class_id = $classId";
- $cardData = $this->sConn->createCommand($sql)->queryRow();
- if($cardData['card_status']==0){
- $cardData['card_length'] = 8;
- if($this->schoolId >999){
- $cardData['card_length'] = 9;
- }
- }
- $this->sConn->createCommand()->insert('zl_exam',array(
- 'zl_exam_id' => $newExamId,
- 'zl_exam_group_id' => $newExamGroupId,
- 'zl_semester_id' => $this->semesterId,
- 'zl_subject_ids' => implode(',',$subject_ids),
- 'create_time' => $time,
- 'zl_tpl_data' => jsonEncode($tplData),
- 'zl_class_id' => $classId,
- ));
- $studentIds = SStudentClassRelation::model()->getStudentIdsByClassId_Status_0($classId);
- $studentIds_0 = BusinessStudent::model()->keepStudentsStatus_0($studentIds);
- $BStudentCards = BusinessStudent::model()->getCardsByStudentIds($studentIds_0);
- if($studentIds_0){
- foreach ($studentIds_0 as $studentId) {
- $this->sConn->createCommand()->insert('zl_student_exam_relation', array(
- 'zl_student_id' => $studentId,
- 'zl_exam_group_id' => $newExamGroupId,
- 'zl_exam_id' => $newExamId,
- 'zl_semester_id' => $this->semesterId,
- 'zl_class_id' => $classId,
- 'zl_student_card' => (isset($BStudentCards[0]) && isset($BStudentCards[0][$studentId]) ? $BStudentCards[0][$studentId] : 0),
- 'zl_school_student_card' => (isset($BStudentCards[1]) && isset($BStudentCards[1][$studentId]) ? $BStudentCards[1][$studentId] : ''),
- ));
- }
- }
- }
- $transaction->commit();
- }catch(Exception $e){
- $transaction->rollBack();
- if (YII_ENV == 'production') {
- $error[] = '系统错误[SQL]';
- } else {
- $error[] = $e->getMessage();
- }
- }
- }
- if(!$error){
- $this->redirect($this->createUrl('zhiliao/index'));
- }else{
- Yii::app()->jump->error(implode(',',$error));
- }
- }
- public function actionExam_list()
- {
- $exam_group_id = Req::get("exam_group_id");
- if($exam_group_id>0)
- {
- $classId = Req::get("classId");
- $condition = array();
- if($classId)
- $condition[] = "e.zl_class_id = '{$classId}'";
- $condition[] = "eg.zl_exam_group_id = '{$exam_group_id}'";
- // $classes = $this->schoolManager->getSemesterClasses($this->semesterId);
- $classes=ClassModel::model()->getClassBySemester($this->semesterId);
- if(!$classes)
- {
- Yii::app()->jump->error('本学期尚未建班级!');
- }
- $_classes = array();
- foreach($classes as $v)
- {
- $_classes[$v['class_id']][$v['class_id']] = $v;
- }
- $resultList = $this->schoolManager->getZlExamList($condition);
- $subject_exam_data = $this->schoolManager->getxuekeStatus($this->semesterId);
- $data['printList'] = $resultList['rs'];
- $data["classes"] = $_classes;
- $data['pages'] = $resultList['pager'];
- $data['page_total'] = $resultList['pager']->rowsCount;
- $data["classId"] = $classId;
- $data["exam_group_id"] = $exam_group_id;
- $data["subject"] = $subject_exam_data;
- $this->render('exam_list',$data);
- }
- }
- //删除全部未考试学生
- public function actionDelExamStudentAll()
- {
- $exam_group_id = Req::post('exam_group_id');
- if(!$exam_group_id)
- {
- echo json_encode(array('status'=>0));exit;
- }
- $ZlStudentExamRelation=new ZlStudentExamRelation();
- $student_data =$ZlStudentExamRelation->getCountStudentByExamGroupId($exam_group_id);
- if(!$student_data){
- echo json_encode(array('status'=>2));exit;
- }
- if($ZlStudentExamRelation->delStudentPaperByExamIds($exam_group_id))
- {
- //操作日志
- if(Yii::app()->params['handle_log_on_off'])
- {
- writeFileLog(jsonEncode(array(
- "exam_group_id" =>$exam_group_id,
- "operate_project" => 'zsyas2',
- "school_id" => $this->schoolId,
- "title" => '清空本次考试的学生(家校考试)',
- "operate_account" => Yii::app()->session['coachInfo']['coach_name'],
- "operate_method" => $this->action,
- "operate_url" => $this->getRoute(),
- "operate_sql" => json_encode(array('delete'=>array(
- 'student_paper_relation'=>array('exam_group_id'=>$exam_group_id)))),
- "operate_param" =>json_encode(array('post'=>$_POST,'get'=>$_GET)),
- "date"=>date('Y-m-d H:i:s')
- )));
- }
- echo json_encode(array('status'=>1));exit;
- }
- echo json_encode(array('status'=>0));exit;
- }
- //上传成绩
- public function actionUpload(){
- $exam_group_id = Req::get("exam_group_id");
- $sql="select * from import_score_temp where exam_group_id<>'".$exam_group_id."' and exam_type=1 limit 1";
- $anotherData=$this->sConn->createCommand($sql)->queryRow();
- if($anotherData){
- Yii::app()->jump->error('请先处理完成其它考试上传成绩数据,再上传新的考试');
- }
- $sql="select * from import_score_temp where exam_group_id='".$exam_group_id."' and exam_type=1 limit 1";
- $Data=$this->sConn->createCommand($sql)->queryRow();
- if($Data){
- //跳转检测页
- $this->redirect(Yii::app()->createUrl('zhiliao/check_excel'));
- }
- $printType = '2';
- $viewData=array(
- 'printType' =>$printType,
- 'examGroupId' =>$exam_group_id
- );
- $this->render('upload',$viewData);
- }
- //新版导入成绩,导入表格
- public function actionImportStore(){
- ini_set ('memory_limit', '300M');
- if(!$_FILES){
- Yii::app()->jump->error('文件大小超过范围');
- }else{
- if(!isset($_FILES['exname']) || !isset($_FILES['exname']['size']) || $_FILES['exname']['size'] > 5242880){
- Yii::app()->jump->error('文件大小超过范围');
- }
- }
- if (Yii::app()->request->getIsPostRequest()) {
- $exam_group_id=Req::post('exam_group_id');
- if(!$exam_group_id)
- {
- Yii::app()->jump->error('请选择考试信息');
- }
- $uploader = new Uploader("upload/tmpDir/zhiliao_chengji/{$this->schoolId}/");
- $uploader->allowTypes = array("xls","xlsx");
- $uploader->fieldsMappings = array("exname" => array(0 => $this->schoolId . date('Ymdhis', time())));
- $file = $uploader->act();
- $file = Arr::current(Arr::current($file));
- if (!$file || !isset($file["error"]))
- Yii::app()->jump->error('请上传的Excel!');
- if ($file["error"] != 0) {
- switch ($file["error"]) {
- case 2001:
- Yii::app()->jump->error('文件类型不符');
- break;
- case 2002:
- Yii::app()->jump->error('文件大小超出允许范围');
- break;
- default:
- Yii::app()->jump->error('上传失败');
- break;
- }
- }
- $inputFileName = $file["src"];
- // 导入PHPExcel类
- Yii::import('application.extensions.*');
- require_once('phpexcel/PHPExcel/IOFactory.php');
- try{
- $objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
- $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
- //FIXME 2019-12-02
- @unlink($file["src"]);
- }catch (Exception $e){
- //FIXME 2019-12-02
- @unlink($file["src"]);
- Yii::app()->jump->error('Excel格式不正确:'.$e->getMessage());
- }
- if(!$sheetData)
- {
- Yii::app()->jump->error('请正确的Excel!');
- }
- unset($objPHPExcel);
- unset($sheetData[1]);
- if(!$sheetData)
- {
- Yii::app()->jump->error('请输入学生成绩数据');
- }
- $ZlExam=new ZlExam();
- $exam_group_data = $ZlExam->getExamByExamGroupId($exam_group_id);
- //debug($exam_group_data);
- $total_score=0;
- //表格科目对应
- $letters = array('C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM');
- $allSubject=Yii::app()->params['subjectId'];
- unset($allSubject[3]);
- unset($allSubject[20]);
- unset($allSubject[51]);
- $subjectExcel=array();
- $subjectOrder=0;
- foreach ($allSubject as $key =>$val){
- $subjectExcel[$letters[$subjectOrder]]=$key;
- $subjectOrder++;
- }
- $zlSubjectIds=array(); //考试科目
- if($exam_group_data) {
- $zl_subject_ids=$exam_group_data[0]['zl_subject_ids'];
- $zlSubjectIds=explode(',',$zl_subject_ids);
- }
- $insertSql="insert into import_score_temp(`student_name`,`class_name`,`check_field_value`,`score_data`,`exam_group_id`,`check_field`,`renew`,`exam_type`) values";
- $valuesArray=array();
- foreach ($sheetData as $val){
- if(!isset($val['A']) || !isset($val['B']) ){
- continue;
- }
- $topic_score= array_merge(array(),array_slice($val,2));
- foreach ($topic_score as $k=>$v){
- if(!empty($v) && (!is_numeric($v) || floatval($v)<0)){
- Yii::app()->jump->error('分数必须是数值类型且》=0');
- }
- //验证科目
- if(isset($v) && !empty($zlSubjectIds) && in_array($subjectExcel[$k],$zlSubjectIds)){
- unset($zlSubjectIds[array_search($subjectExcel[$k],$zlSubjectIds)]);
- }
- }
- $valuesArray[]="('".$val['A']."','".$val['B']."','','".json_encode($topic_score)."','".$exam_group_id."','student_name','0',1)";
- }
-
- if(!empty($zlSubjectIds)){
- $errSubjects=array();
- foreach ($zlSubjectIds as $subjectId){
- $errSubjects[]=Yii::app()->params['subjectId'][$subjectId];
- }
- Yii::app()->jump->error('分数设置不正确,科目:【'.implode(',',$errSubjects).'】没有提交分数');
- }
- if($valuesArray){
- //$delSql="truncate table import_score_temp;";
- $delSql="delete from import_score_temp where exam_type=1;";
- $this->sConn->createCommand($delSql)->execute();
- $insertSql.=implode(',',$valuesArray);
- $this->sConn->createCommand($insertSql)->execute();
- $this->redirect(Yii::app()->createUrl('zhiliao/check_excel'));
- }else{
- Yii::app()->jump->error('没有发现学生成绩数据');
- }
- Yii::app()->jump->error('导入失败');
- }
- }
- //导入数据检测页
- public function actionCheck_Excel(){
- $sql="select * from import_score_temp where exam_type=1 limit 1";
- $data=$this->sConn->createCommand($sql)->queryRow();
- $data['check_field_name']='学生姓名';
- $data['need_check_name']=1;
- $this->render('check',$data);
- }
- //检测格式
- public function actionCheck_field_first(){
- $result['status']=0;
- $sql="select * from import_score_temp where exam_type=1";
- $All_Data=$this->sConn->createCommand($sql)->queryAll();
- if(!$All_Data){
- exit(json_encode($result));
- }
- $data=$All_Data[0];
- $check_field=$data['check_field'];
- $score_data=json_decode($data['score_data'],true);
- $exam_group_id=$data['exam_group_id'];
- if(!$score_data){
- $result['msg']='数据不完整';
- exit(json_encode($result));
- }
- //检测题量
- $ZlExam=new ZlExam();
- $exam_group_data = $ZlExam->getExamByExamGroupId($data['exam_group_id']);
- //debug($exam_group_data);
- $total_score=0;
- //表格科目对应
- $letters = array('C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM');
- $allSubject=Yii::app()->params['subjectId'];
- unset($allSubject[3]);
- unset($allSubject[51]);
- unset($allSubject[20]);
- $subjectExcel=array();
- $subjectOrder=0;
- foreach ($allSubject as $key =>$val){
- $subjectExcel[$letters[$subjectOrder]]=$key;
- $subjectOrder++;
- }
- if($exam_group_data) {
- $tpl_data=json_decode($exam_group_data[0]['zl_tpl_data'],true);
- if(!$tpl_data) {
- $result['msg']='考试数据错误';
- exit(json_encode($result));
- }
- $subjectScores=$tpl_data['items'];
- //检测试题数据
- foreach($All_Data as $key=> $val){
- $topic_score=json_decode($val['score_data'],true);
- $uploadSubjectCount=0;
- foreach($topic_score as $order => $v){
- if(!empty($v) && (!is_numeric($v) || floatval($v)<0)){
- $result['msg']='试题分数必须是数值类型:'.$val['student_name'];
- exit(json_encode($result));
- }
- if(isset($v)==true){
- $uploadSubjectCount++;
- if(isset($subjectExcel[$order])){
- if(isset($subjectScores[$subjectExcel[$order]])){
- if($v>$subjectScores[$subjectExcel[$order]]){
- $result['msg']=$val['student_name'].':科目:'.(Yii::app()->params['subjectId'][$subjectExcel[$order]]).'分数和考试设置分数不一致,提交分数:'.$v."试卷设置分数:".$subjectScores[$subjectExcel[$order]];
- exit(json_encode($result));
- }
- }else{
- $result['msg']=$val['student_name'].':科目:'.(Yii::app()->params['subjectId'][$subjectExcel[$order]]).'考试设置中未设置';
- exit(json_encode($result));
- }
- }else{
- $result['msg']='Excel格式不正确';
- exit(json_encode($result));
- }
- }
- }
- /*
- if($uploadSubjectCount!=count($subjectScores)){
- $result['msg']='上传科目数量和考试设置不一致';
- exit(json_encode($result));
- }
- */
- }
- $result['msg']='检测完成';
- $result['status']=1;
- }else{
- $result['msg']='未发现对应考试';
- exit(json_encode($result));
- }
- exit(json_encode($result));
- }
- //重新上传
- public function actionGiveup(){
- // $delSql="truncate table import_score_temp;";
- $delSql="delete from import_score_temp where exam_type=1;";
- $this->sConn->createCommand($delSql)->execute();
- $result['status']=1;
- exit(json_encode($result));
- }
- //检测姓名
- public function actionCheck_student_name(){
- ini_set('memory_limit','512M');
- set_time_limit(0);
- $result['status']=0;
- $result['data']=0;
- $student_all_data = $this->sConn->createCommand("SELECT id,student_name FROM `import_score_temp` `t` where exam_type=1")->queryAll();
- if($student_all_data){
- //去除非中文字符
- $updateArr=array();
- $preg="/[^\x{4E00}-\x{9FFF}^·]+/u";
- $count=0;
- foreach($student_all_data as $val){
- if(preg_match($preg,$val['student_name'])){
- $ModifyName = preg_replace($preg, "", $val['student_name']);
- if($ModifyName){
- $updateArr[$val['id']]=$ModifyName;
- $count++;
- }
- }else{
- $updateArr[$val['id']]=$val['student_name'];
- }
- }
- //组织更新语句
- if($updateArr){
- $arrNumber=ceil(count($updateArr)/500);
- $Arr=array_chunk($updateArr,$arrNumber,true);
- $transcation = $this->sConn->beginTransaction();
- try {
- foreach ($Arr as $item){
- $sql='update import_score_temp set `check_field_value`= case id ';
- foreach ($item as $key=> $val){
- $sql.=" WHEN ".$key." THEN '".$val."' ";
- }
- $sql.=" End ";
- $sql.=" where check_field_value='' or check_field_value is null and exam_type=1";
- $this->sConn->createCommand($sql)->execute();
- }
- $transcation->commit();
- $result['status']=1;
- }catch (Exception $e){
- $transcation->rollback();
- }
- }
- $result['count']=$count;
- }
- exit(json_encode($result));
- }
- //匹配信息
- public function actionMatching(){
- $noExistent=0; //不存在
- $repeat=0; //重复(组)
- $success=0; //匹配成功
- $scoreWrong=0; //成绩不正确
- $result['status']=0;
- $sql="select * from import_score_temp where exam_type=1 limit 1";
- $data=$this->sConn->createCommand($sql)->queryRow();
- if(!$data){
- exit(json_encode($result));
- }
- $check_field=$data['check_field'];
- $exam_group_id=$data['exam_group_id'];
- $classArr=array();
- $classIds=array();
- $check_data_group=array(); //检查字段对应临时表id
- $update_temp_data=array(); //更新临时表数据
- $student_card=array(); //学生id,准考证号对应数据
- $tpl_data=array();
- $updateSql=array();
- $ZlExam=new ZlExam();
- $exam_group_data=$ZlExam->getExamByExamGroupId($exam_group_id);
- $paperIds=array();
- if($exam_group_data){
- foreach ($exam_group_data as $v){
- if(!$tpl_data && isset($v['zl_tpl_data'])){
- $tpl_data=json_decode($v['zl_tpl_data'],true);
- }
- $classIds[]=$v['zl_class_id'];
- $examIds[]=$v['zl_exam_id'];
- }
- }
- //统计已经匹配成功的数据
- $success_student_data = $this->sConn->createCommand("SELECT id,student_name,check_field,exam_group_id,score_data,check_field_value FROM `import_score_temp` `t` where student_id is not null and student_id<>0 and exam_type=1")->queryAll();
- if($success_student_data){
- $success=count($success_student_data);
- }
- $check_field_val_arr=array();
- $student_all_data = $this->sConn->createCommand("SELECT id,student_name,check_field,exam_group_id,score_data,check_field_value FROM `import_score_temp` `t` where student_id is null or student_id=0 and exam_type=1 ")->queryAll();
- if(!$student_all_data){
- $result['repeat']=0;
- $result['success']=$success;
- $result['noExistent']=0;
- $result['status']=1;
- exit(json_encode($result));
- }
- foreach ($student_all_data as $val){
- //验证学生分数
- $check_field_val_arr[]="'".$val['check_field_value']."'";
- $check_data_group[$val['check_field_value']]=$val['id'];
- }
- //处理重复数据
- $repeat_group_data=array();
- $search_value_arr=array();
- foreach ($check_field_val_arr as $value){
- $repeat_group_data[$value][]=$value;
- }
- foreach ($repeat_group_data as $key=>$val){
- if(count($val)>1){
- $repeat++;
- $modify_name=str_replace("'",'',$key);
- $updateSql[]="update import_score_temp set is_repeat=1 where check_field_value='".$modify_name."' and (student_id is null or student_id=0) and exam_type=1";
- }else{
- $search_value_arr[]=$val[0];
- }
- }
- if($search_value_arr){
- $student_info=array();
- $sql="select si.student_id,si.realname from student_info si join zl_student_exam_relation spr on si.student_id = spr.zl_student_id where realname in(".implode(',',$search_value_arr).") and zl_exam_id in(".implode(',',$examIds).")";
- $student_info=$this->sConn->createCommand($sql)->queryAll();
- if(!$student_info){
- $noExistent=count($search_value_arr);
- $result['repeat']=$repeat;
- $result['success']=$success;
- $result['noExistent']=$noExistent;
- $result['status']=1;
- }else{
- $result['status']=1;
- //过滤掉已被删除的学生
- foreach ($student_info as $key=>$value){
- $sql_class_relation="select * from student_class_relation where student_id='".$value['student_id']."' and status=0 ";
- $student_class_realtion=$this->sConn->createCommand($sql_class_relation)->queryRow();
- if(!$student_class_realtion){
- unset($student_info[$key]);
- }
- }
- $nameArr=array();
- foreach ($student_info as $item){
- $preg="/[^\x{4E00}-\x{9FFF}^·]+/u";
- $ModifyName = preg_replace($preg, "", $item['realname']);
- $nameArr[$ModifyName][]=$item;
- }
- $noExistent=count($search_value_arr)-count($nameArr);
- if($noExistent<0) $noExistent=0;
- $result['noExistent']=$noExistent;
- foreach ($nameArr as $key=>$value){
- if(count($value)>1){
- $repeat++;
- $updateSql[]="update import_score_temp set is_repeat=1 where check_field_value='".$key."' and (student_id is null or student_id=0) and exam_type=1";
- }else{
- $success++;
- if(isset($check_data_group[$key])){
- $update_temp_data[$check_data_group[$key]]=$value[0]['student_id'];
- }
- }
- }
- $result['repeat']=$repeat;
- $result['success']=$success;
- }
- }else{
- $result['repeat']=$repeat;
- $result['success']=$success;
- $result['noExistent']=0;
- $result['status']=1;
- }
- //更新检测成功的数据
- if($update_temp_data || $updateSql){
- $transcation = $this->sConn->beginTransaction();
- try {
- if($update_temp_data) {
- if ($check_field == 'student_name') {
- $sql = 'update import_score_temp set `student_id`= case id ';
- } else {
- $sql = 'update import_score_temp set `student_id`= case id ';
- }
- foreach ($update_temp_data as $key => $val) {
- $sql .= " WHEN " . $key . " THEN '" . $val . "' ";
- }
- $sql .= " End ";
- $sql .= " where (student_id='' or student_id is null) and exam_type=1";
- $this->sConn->createCommand($sql)->execute();
- }
- if($updateSql){
- foreach ($updateSql as $query){
- $this->sConn->createCommand($query)->execute();
- }
- }
- $transcation->commit();
- $result['status']=1;
- }catch (Exception $e){
- $result['status']=0;
- $transcation->rollback();
- }
- }
- exit(json_encode($result));
- }
- //处理重复学生
- public function actionHandle_repeat(){
- $page=Req::post('page');
- $name_like=Req::post('name');
- if(!$page) $page=1;
- $pageSize=10;
- $offset=($page-1)*$pageSize;
- $sql="select * from import_score_temp where exam_type=1 limit 1";
- $checkData=$this->sConn->createCommand($sql)->queryRow();
- $check_field=$checkData['check_field'];
- $sql="select count(*) as count,check_field_value,check_field from import_score_temp where is_repeat=1 and exam_type=1 group by check_field_value ";
- if($name_like){
- $sql.=" having check_field_value='".$name_like."'";
- }
- $sql.="order by count desc";
- $all_data=$this->sConn->createCommand($sql)->queryAll();
- if(!$all_data){
- $this->redirect(Yii::app()->createUrl('zhiliao/check_excel'));
- }
- $repeat=array();
- $total=count($all_data);
- $data['total_page']=ceil($total/$pageSize);
- $data['name_group']=array_slice($all_data,$offset,$pageSize);
- $data['page']=$page;
- if(Yii::app()->request->isAjaxRequest){
- $result['status']=1;
- $result['data']=$data['name_group'];
- $result['total_page']=$data['total_page'];
- exit(json_encode($result));
- }else{
- $this->render('handle', $data);
- }
- }
- //根据名称加载重名学生
- public function actionShowrepeatstudent(){
- $name=Req::post('name');
- $fileName=array(
- 'student_name'=>'学生姓名',
- 'userno'=>'学号',
- 'student_card'=>'准考证号',
- 'school_student_card'=>'学校准考证号',
- 'zhixue_student_card'=>'智学网考证号',
- 'id_number'=>'身份证号',
- 'student_phone'=>'手机号'
- );
- //扩展字段
- $studentExtend=$this->schoolManager->getStudentExtend();
- if($studentExtend){
- foreach ($studentExtend as $key=> $value){
- $fileName[$key]=$value['field_mean'];
- }
- }
- //表格科目对应
- $letters = array('C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM');
- $allSubject=Yii::app()->params['subjectId'];
- unset($allSubject[3]);
- unset($allSubject[51]);
- unset($allSubject[20]);
- $ExcelToSubject=array();
- $subjectOrder=0;
- foreach ($allSubject as $key =>$val){
- $ExcelToSubject[$letters[$subjectOrder]]=$key;
- $subjectOrder++;
- }
- $classIds=array();
- $sql="select * from import_score_temp where check_field_value='".$name."' and ( student_id is null or student_id =0) and exam_type=1";
- $nameArr=array();
- $systemStudent=array();
- $numberToId=array();
- $excel_data = $this->sConn->createCommand($sql)->queryAll();
- if($excel_data){
- $topic_score=json_decode($excel_data[0]['score_data'],true);
- $check_field=$excel_data[0]['check_field'];
- $excel_html='<table class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable">';
- $excel_html.='<tr>';
- $excel_html.='<th>序号</th>';
- $excel_html.='<th>姓名</th>';
- $excel_html.='<th>班级</th>';
- // $scoreArr=array_slice($topic_score,2);
- foreach($topic_score as $f=>$v){
- $excel_html.='<th>'.Yii::app()->params['subjectId'][$ExcelToSubject[$f]].'</th>';
- }
- $excel_html.='</tr>';
- $i=1;
- foreach($excel_data as $val){
- $topic_score=json_decode($val['score_data'],true);
- $numberToId[$i]=$val['id'];
- $excel_html.='<tr>';
- $excel_html.='<td>'.$i.'</td>';
- $excel_html.='<td>'.$val['check_field_value'].'(原'.$val['student_name'].')</td>';
- $excel_html.='<td>'.$val['class_name'].'</td>';
- foreach($topic_score as $v){
- $excel_html.='<td>'.$v.'</td>';
- }
- $excel_html.='</tr>';
- $i++;
- }
- $excel_html.='</table>';
- $ZlExam=new ZlExam();
- $exam_group_data=$ZlExam->getExamByExamGroupId($excel_data[0]['exam_group_id']);
- $classIds=array();
- $examIds=array();
- if($exam_group_data){
- foreach ($exam_group_data as $v){
- $classIds[]=$v['zl_class_id'];
- $examIds[]=$v['zl_exam_id'];
- }
- }
- $_allStudent=array();
- $check_field='realname';
- $sys_sql="SELECT sc.realname,sc.id_number,sc.class_id,sc.student_id,sc.is_outer,sc.id_number,c.class_name,s.semester_id,s.semester_name,s.school_year,s.end_time,sc.field_1,sc.field_2,sc.field_3,sc.field_4,sc.field_5 FROM `student_info` sc ";
- $sys_sql.="LEFT JOIN class c on sc.class_id=c.class_id ";
- $sys_sql.="LEFT JOIN semester s on s.semester_id=c.semester_id ";
- $sys_sql.="LEFT JOIN zl_student_exam_relation spr on sc.student_id = spr.zl_student_id ";
- $sys_sql.=" where `".$check_field."` = '".$name."' and spr.zl_exam_id in(".implode(',',$examIds).") and s.semester_id <>'' ";
- $sys_sql.="order by end_time desc ;";
- $_allStudent = $this->sConn->createCommand($sys_sql)->queryAll();
- $nameArr=array();
- $studentData=array();
- $businessData=array();
- $semester=array();
- $studentId=array();
- $html='';
- if($_allStudent){
- foreach ($_allStudent as $val){
- $val['serial_number']=0;
- $val['userno']=0;
- //班级信息
- $sql_class_relation="select * from student_class_relation where student_id='".$val['student_id']."' and status=0 ";
- $student_class_realtion=$this->sConn->createCommand($sql_class_relation)->queryRow();
- if($student_class_realtion){
- $val['serial_number']=$student_class_realtion['serial_number'];
- $val['userno']=$student_class_realtion['userno'];
- }else{
- continue;
- }
- //查询副号
- $sql_fuhao="select * from student_relation where find_in_set('".$val['student_id']."',relation_student_id)";
- $student_fuhao=$this->sConn->createCommand($sql_fuhao)->queryRow();
- $val['fuhao']=0;
- if($student_fuhao){
- if($val['student_id']!=$student_fuhao['master_student_id']){
- continue;
- }else{
- $fuhao_arr=explode(',',$student_fuhao['relation_student_id']);
- $val['fuhao']=count($fuhao_arr)-1;
- }
- }
- $studentData[$val['semester_id']][]=$val;
- $semester[$val['semester_id']]=$val['semester_name'];
- $studentId[]=$val['student_id'];
- }
- //查询business
- $criteria = new CDbCriteria();
- $b_student = array();
- $criteria->addInCondition('student_id',$studentId);
- $b_student_data = BusinessStudent::model()->findAll($criteria);
- if($b_student_data){
- foreach($b_student_data as $v)
- {
- $businessData[$v->student_id]=array(
- 'username'=>$v->username,
- 'student_card'=>$v->student_card,
- 'school_student_card'=>$v->school_student_card,
- 'zhixue_student_card'=>$v->zhixue_student_card,
- );
- }
- }
- $i=1;
- $currSemester = $this->schoolManager->getCurrSemester();
- $smid=$currSemester['semester_id'];
- foreach ($semester as $key=> $val){
- $semesterStatus='非当前学期';
- if($smid==$key){
- $semesterStatus='当前学期';
- }
- $html.='<div class="handel-term-list">';
- $html.='<div class="term-name fw"></div>';
- $html.='<div class="relative flex">';
- $html.='<img src="/images/prev-arrow.png" alt="" class="prev-arrow arrow-img pointer">';
- $html.='<div class="term-card-layout flex-one" >';
- $html.='<ul class="term-card-detail">';
- if(isset($studentData[$key])){
- // debug($studentData[$key]);
- foreach ($studentData[$key] as $item){
- $isZj='是';
- if($item['is_outer']==1){
- $isZj='否';
- }
- $html.='<li class="term-card-list" id="'.$item['student_id'].'" draggable="true" >';
- $html.='<div class="padding-layout">';
- $html.='<div class="card-lis-data flex">';
- $html.='<div class="card_select">';
- $html.='<select class="nToId"><option value="0">请选择序号</option>';
- foreach ($numberToId as $number=>$Id){
- $html.='<option value="'.$Id.'">'.$number.'</option>';
- }
- $html.='</select>';
- $html.='</div>';
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">姓名</span>';
- $html.='<span class="card-list-msg flex-one">'.$item['realname'].'</span>';
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">班级</span>';
- $html.='<span class="card-list-msg flex-one">'.$item['class_name'].'</span>';
- $html.='</div>';
- $html.='<div class="hide-list">';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">学期</span>';
- $html.='<span class="card-list-msg flex-one">'.$val.'</span>';
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">学期状态</span>';
- $html.='<span class="card-list-msg flex-one">'.$semesterStatus.'</span>';
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">班级序号</span>';
- $html.='<span class="card-list-msg flex-one">'.$item['serial_number'].'</span>';
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">学号</span>';
- $html.='<span class="card-list-msg flex-one">'.$item['userno'].'</span>';
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">登录账号</span>';
- if(isset($businessData[$item['student_id']])){
- $html.='<span class="card-list-msg flex-one">'.$businessData[$item['student_id']]['username'].'</span>';
- }else{
- $html.='<span class="card-list-msg flex-one"></span>';
- }
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">系统准考证号</span>';
- if(isset($businessData[$item['student_id']])){
- $html.='<span class="card-list-msg flex-one">'.$businessData[$item['student_id']]['student_card'].'</span>';
- }else{
- $html.='<span class="card-list-msg flex-one"></span>';
- }
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">学校准考证号</span>';
- if(isset($businessData[$item['student_id']])){
- $html.='<span class="card-list-msg flex-one">'.$businessData[$item['student_id']]['school_student_card'].'</span>';
- }else{
- $html.='<span class="card-list-msg flex-one"></span>';
- }
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">智学网考号</span>';
- if(isset($businessData[$item['student_id']])){
- $html.='<span class="card-list-msg flex-one">'.$businessData[$item['student_id']]['zhixue_student_card'].'</span>';
- }else{
- $html.='<span class="card-list-msg flex-one"></span>';
- }
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">身份证号</span>';
- $html.='<span class="card-list-msg flex-one">'.$item['id_number'].'</span>';
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">是否为在籍生</span>';
- $html.='<span class="card-list-msg flex-one">'.$isZj.'</span>';
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">历史考试成绩</span>';
- $html.='<span rel="'.$item['student_id'].'" class="card-list-msg flex-one browse-history green-font">查看</span>';
- $html.='</div>';
- $html.='<div class="card-lis-data flex">';
- $html.='<span class="card-list-menu gray-font">副号</span>';
- $html.='<span rel="'.$item['student_id'].'" class="card-list-msg flex-one green-font pointer fuhao-lock">'.$item['fuhao'].'</span>';
- $html.='</div>';
- $html.='</div>';
- $html.='<span class="toggle-opt-btn green-font pointer">展开</span>';
- $html.='</div>';
- $html.='</li>';
- $i++;
- }
- }
- $html.='</ul>';
- $html.='</div>';
- $html.='<img src="/images/next-arrow.png" alt="" class="next-arrow arrow-img pointer">';
- $html.='</div>';
- $html.='</div>';
- }
- }
- }
- $result['html']=$html;
- $result['excel_html']=$excel_html;
- $result['status']=1;
- exit(json_encode($result));
- }
- //绑定学生id
- public function actionBinding(){
- $str=Req::post('str');
- $result['status']=0;
- if(!$str || !is_array($str)){
- exit(json_encode($result));
- }
- $studentIds=array();
- $tempIds=array();
- foreach($str as $val){
- @$nToId=explode('///',$val);
- if(isset($nToId[0])){
- if(in_array((string)$nToId[0],$studentIds,true)){
- $result['msg']='不能学生重复选择';
- exit(json_encode($result));
- }else{
- $studentIds[]=(string)$nToId[0];
- }
- }
- if(isset($nToId[1])){
- if(in_array((string)$nToId[1],$tempIds,true)){
- $result['msg']='不能学生重复选择';
- exit(json_encode($result));
- }else{
- $tempIds[]=(string)$nToId[1];
- }
- }
- }
- $updateSql=array();
- foreach($str as $val){
- @$nToId=explode('///',$val);
- if(isset($nToId[0]) && isset($nToId[1])){
- //判断学生id是否已关联过
- $related=$this->sConn->createCommand("select id from import_score_temp where student_id='".$nToId[0]."' and exam_type=1 limit 1")->queryRow();
- if($related){
- $result['msg']='学生已经被关联,请重新检查';
- exit(json_encode($result));
- }
- $updateSql[]="update import_score_temp set student_id='".$nToId[0]."',is_repeat=0 where id='".$nToId[1]."' and exam_type=1";
- }
- }
- if($updateSql){
- foreach($updateSql as $query){
- $this->sConn->createCommand($query)->execute();
- }
- $result['status']=1;
- }
- exit(json_encode($result));
- }
- //处理不存在学生
- public function actionHandle_existent(){
- $fileName=array(
- 'student_name'=>'学生姓名',
- 'userno'=>'学号',
- 'student_card'=>'准考证号',
- 'school_student_card'=>'学校准考证号',
- 'zhixue_student_card'=>'智学网考证号',
- 'id_number'=>'身份证号',
- 'student_phone'=>'手机号'
- );
- //扩展字段
- $studentExtend=$this->schoolManager->getStudentExtend();
- if($studentExtend){
- foreach ($studentExtend as $key=> $value){
- $fileName[$key]=$value['field_mean'];
- }
- }
- //查询不存在的数据
- $sql="select * from import_score_temp where is_repeat=0 and (student_id is null or student_id =0) and exam_type=1 ";
- $all_data=$this->sConn->createCommand($sql)->queryAll();
- if($all_data){
- $data['check_field']=$all_data[0]['check_field'];
- }else{
- $data['check_field']='';
- }
- $data['list']=$all_data;
- $data['fieldName']=$fileName;
- $this->render('handle_existent',$data);
- }
- //修改不存在的学生数据
- public function actionChange_value(){
- $id=Req::post('id');
- $value=Req::post('value');
- $result['status']=0;
- if(!$id || !$value){
- $result['msg']='参数不正确';
- exit(json_encode($result));
- }
- $sql="select student_name,class_name,check_field_value,score_data,exam_group_id,check_field,renew,student_id,is_repeat from import_score_temp where id='".$id."' limit 1";
- $data=$this->sConn->createCommand($sql)->queryRow();
- if(!$data){
- $result['msg']='id不正确';
- exit(json_encode($result));
- }
- $check_field=$data['check_field'];
- //excel中是否有重复数据
- $excelCheck="select id from import_score_temp where check_field_value='".$value."' and exam_type=1 ";
- $excelCheckData=$this->sConn->createCommand($excelCheck)->queryRow();
- if($excelCheckData){
- $result['msg']='excel中已存在相同记录';
- if($check_field=='student_name'){
- $result['status']=1;
- $updateSql="update import_score_temp set `is_repeat`=1,check_field_value='{$value}' where (id={$id} or check_field_value='{$value}') and exam_type=1";
- $this->sConn->createCommand($updateSql)->execute();
- $result['msg']='excel中已存在相同记录,请返回检测页面,继续处理重名';
- }
- exit(json_encode($result));
- }
- //系统中是否有数据
- $exam_group_id=$data['exam_group_id'];
- $ZlExam=new ZlExam();
- $exam_group_data=$ZlExam->getExamByExamGroupId($exam_group_id);
- $classIds=array();
- $examIds=array();
- if($exam_group_data){
- foreach ($exam_group_data as $v){
- $classIds[]=$v['zl_class_id'];
- $examIds[]=$v['zl_exam_id'];
- }
- }
- if($exam_group_data){
- $student_info=array();
- $sql="select si.student_id,si.realname from student_info si join zl_student_exam_relation spr on si.student_id = spr.zl_student_id where realname ='".$value."' and zl_exam_id in(".implode(',',$examIds).")";
- $student_info=$this->sConn->createCommand($sql)->queryAll();
- if(!$student_info){
- $result['msg']='系统中不存在,或学生没有参加该次考试';
- exit(json_encode($result));
- }elseif(count($student_info)>1){
- $updateSql="update import_score_temp set `is_repeat`=1,check_field_value='{$value}' where id={$id}";
- $this->sConn->createCommand($updateSql)->execute();
- $result['msg']='系统中存在多个该学生数据,请返回检测页面,继续处理重名';
- exit(json_encode($result));
- }else{
- $result['status']=1;
- $studentId=$student_info[0]['student_id'];
- //查询是否参加考试
- $StudentPaperRelation=$this->sConn->createCommand("select zl_student_id from `zl_student_exam_relation` where zl_student_id='".$studentId."' and zl_exam_id in(".implode(',',$examIds).")")->queryRow();
- if(!$StudentPaperRelation){
- $result['status']=1;
- $result['msg']='学生没有参加本次考试';
- exit(json_encode($result));
- }
- //判断学生id是否已关联过
- $related=$this->sConn->createCommand("select id from import_score_temp where student_id='".$studentId."' and exam_type=1 limit 1")->queryRow();
- if($related){
- $result['msg']='学生已经被关联,请重新检查';
- exit(json_encode($result));
- }
- $updateSql="update import_score_temp set student_id='{$studentId}',check_field_value='{$value}',is_repeat=0 where id={$id}";
- $this->sConn->createCommand($updateSql)->execute();
- exit(json_encode($result));
- }
- }else{
- $result['msg']='考试数据有误';
- exit(json_encode($result));
- }
- }
- //处理完毕,执行成绩导入
- public function actionUpdate_score(){
- $result['status']=0;
- $sql="select * from import_score_temp where student_id is not null and is_repeat=0 and exam_type=1";
- $all_data=$this->sConn->createCommand($sql)->queryAll();
- if(!$all_data){
- $result['msg']='没有发现可导入学生成绩数据';
- exit(json_encode($result));
- }
- $exam_group_id=$all_data[0]['exam_group_id'];
- $ZlExam=new ZlExam();
- $exam_group_data=$ZlExam->getExamByExamGroupId($exam_group_id);
- if(!$exam_group_data){
- $result['msg']='考试ID不正确,请从考试列表点击上传成绩';
- exit(json_encode($result));
- }
- $classIds=array();
- if($exam_group_data){
- foreach ($exam_group_data as $v){
- $classIds[]=$v['zl_class_id'];
- $examIds[]=$v['zl_exam_id'];
- }
- }
- $letters = array('C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM');
- $allSubject=Yii::app()->params['subjectId'];
- unset($allSubject[3]);
- unset($allSubject[51]);
- unset($allSubject[20]);
- $ExcelToSubject=array();
- $subjectOrder=0;
- foreach ($allSubject as $key =>$val){
- $ExcelToSubject[$letters[$subjectOrder]]=$key;
- $subjectOrder++;
- }
- // $tpl_data=json_decode($exam_group_data[0]['tpl_data'],true);
- $sql='INSERT INTO `zl_student_exam_rs` (`id`,`zl_student_id`,`zl_exam_group_id`,`zl_exam_id`,`zl_subject_id`,`zl_scoring`)VALUE ';
- $deleteSql=array();
- $error=array();
- $studentIds=array(); //用于检测重复
- $time=time();
- foreach($all_data as $val){
- $StudentPaperRelation=$this->sConn->createCommand("select zl_student_id,zl_exam_id from `zl_student_exam_relation` where zl_student_id='".$val['student_id']."' and zl_exam_id in(".implode(',',$examIds).")")->queryRow();
- if(!$StudentPaperRelation){
- $error[]='学生没有参加本次考试 :'.$val['student_name'];
- continue;
- }
- $ZlExamId=$StudentPaperRelation['zl_exam_id'];
- $deleteSql[]="delete from `zl_student_exam_rs` where zl_student_id='".$val['student_id']."' and zl_exam_group_id='".$exam_group_id."' ";
- $topicScoreData=json_decode($val['score_data'],true);
- $uuidArr=array();
- $uuidArr=getBatchUuid($this->schoolId,count($topicScoreData));
- foreach($topicScoreData as $key=> $ts){
- if(isset($ts)== true){
- if(!is_numeric($ts) || floatval($ts)<0){
- continue;
- }
- $ts=(float)$ts;
- if(!$ts){
- $ts=0;
- }
- // $uuid = $this->sConn->createCommand("select RIGHT(UUID_SHORT(), 20)")->queryAll();
- // $uuid = current(current($uuid));
- //$uuid=getUniqueId($this->schoolId);
- $uuid=current($uuidArr);
- unset($uuidArr[$uuid]);
- $valueSql[]=' ('.$uuid.','.$val['student_id'].','.$exam_group_id.','.$ZlExamId.','.$ExcelToSubject[$key].','.$ts.') ';
- }
- }
- }
- if($deleteSql && $valueSql){
- $transaction = $this->sConn->beginTransaction();
- try{
- if($deleteSql){
- foreach ($deleteSql as $dquery){
- $this->sConn->createCommand($dquery)->execute();
- }
- if($valueSql){
- if(count($valueSql)>100){
- $valueSql = array_chunk($valueSql, 10);
- foreach($valueSql as $value){
- $chunkSql=$sql;
- $chunkSql.=implode(',',$value);
- $this->sConn->createCommand($chunkSql)->execute();
- }
- }else{
- $sql.=implode(',',$valueSql);
- $this->sConn->createCommand($sql)->execute();
- }
- }
- //清理导入临时数据
- // $delSql="truncate table import_score_temp;";
- $delSql="delete from import_score_temp where exam_type=1;";
- $this->sConn->createCommand($delSql)->execute();
- $transaction->commit();
- $result['status']=1;
- if($error){
- // Yii::app()->jump->error('导入成功,有部分学生成绩没有导入:'.implode(',',$error));
- $result['msg']=implode('<br>',$error);
- }else{
- $result['msg']='导入成功';
- }
- exit(json_encode($result));
- }
- }catch (Exception $e) {
- //如果操作失败, 数据回滚
- $transaction->rollback();
- // Yii::app()->jump->error('成绩导入失败,请检查后重新');
- $result['msg']='成绩导入失败,请检查后重新导入';
- exit(json_encode($result));
- }
- }else{
- //没有需要重新导入的数据,清理导入临时数据
- $delSql="delete from import_score_temp where exam_type=1;";
- $this->sConn->createCommand($delSql)->execute();
- $result['status']=1;
- exit(json_encode($result));
- }
- }
- /*切换记录状态*/
- public function actionChangeStatus(){
- $display=intval(Req::post('display'));
- $examGroupId=Req::post('cid');
- $result=array(
- 'status'=>0
- );
- if(!$examGroupId || !in_array($display,array(0,1))){
- exit(json_encode($result));
- }
- $ZlExamGroup=new ZlExamGroup();
- $data=array(
- 'zl_is_display'=>$display
- );
- $Condition=array(
- 'zl_exam_group_id'=>$examGroupId
- );
- $res=$ZlExamGroup->updateByCondition($data,$Condition);
- if($res){
- $result['status']=1;
- }
- exit(json_encode($result));
- }
- public function actionChange(){
- ini_set("memory_limit","200M");
- Url::clean();
- $sname = Req::get("sname");
- $cid = Req::get("cid");
- $eid = Req::get("eid");
- $classInfo = ClassModel::model()->findByPk($cid);
- if (empty($classInfo)) {
- Yii::app()->jump->error('未找到班级!');
- }
- $ZlExam=new ZlExam();
- $examInfo = $ZlExam->getExamByExamId($eid);
- if (empty($examInfo)) {
- Yii::app()->jump->error('未找到考试!');
- }
- $ZlexmGroup=new ZlExamGroup();
- $examInfo=$ZlexmGroup->getExamGroupByExamGroupId($examInfo['zl_exam_group_id']);
- $ZlStudent=new ZlStudentExamRelation();
- $result = array();
- $relateStudent = $ZlStudent->getStudentByExamId($eid);
- // 获取学生姓名
- $_student_id = array();
- foreach($relateStudent as $v)
- {
- $_student_id[$v['zl_student_id']] = $v['zl_student_id'];
- }
- $studentNames = array();
- $criteria = new CDbCriteria();
- $criteria->addInCondition('student_id',$_student_id);
- $studentArray = SStudentInfo::model()->findAll($criteria);
- if (!empty($studentArray)) {
- foreach ($studentArray as $student) {
- $studentNames[$student->student_id] = $student->realname;
- }
- }
- //debug($examInfo);
- foreach ($relateStudent as $key=>$val) {
- //查询学生身份证号
- $studentInfo=SStudentInfo::model()->find('student_id=:s_id',array('s_id'=>$val['zl_student_id']));
- if($studentInfo){
- $result[$key]['id_number'] = $studentInfo->id_number;
- }else{
- $result[$key]['id_number'] = '';
- }
- if (empty($sname)) {
- $result[$key]['clazzName'] = $classInfo->class_name;
- $result[$key]['paperName'] = $examInfo['zl_exam_name'];
- $result[$key]['studentCode'] = $val['zl_student_id'];
- $result[$key]['studentName'] = isset($studentNames[$val['zl_student_id']]) ? $studentNames[$val['zl_student_id']] : null;
- $result[$key]['is_complete'] = !empty($val['zl_subject_id'])?1:0;
- } else {
- if ($sname == $studentNames[$val['zl_student_id']]) {
- $result[$key]['clazzName'] = $classInfo->class_name;
- $result[$key]['paperName'] = $examInfo['zl_exam_name'];
- $result[$key]['studentCode'] = $val['zl_student_id'];
- $result[$key]['studentName'] = $studentNames[$val['zl_student_id']];
- $result[$key]['is_complete'] = !empty($val['zl_subject_id'])?1:0;
- }else{
- unset($result[$key]);
- }
- unset($relateStudent[$key]);
- }
- }
- //}
- $no_paper_student = array();
- $paper_student_array = array();
- $c_paper_student_array = array();
- $class_student_info_data = array();
- $_student_ids = array();
- $_student_id_names = array();
- $class_student_data = $this->schoolManager->getClassStudentByClassId($cid); //student_class_relation
- if($class_student_data)
- {
- foreach($class_student_data as $v)
- {
- $_student_ids[$v['student_id']] = $v['student_id'];
- }
- $criteria = new CDbCriteria();
- $criteria->addInCondition('student_id',$_student_ids);
- $studentArray = SStudentInfo::model()->findAll($criteria);
- if (!empty($studentArray)) {
- foreach ($studentArray as $student) {
- $_student_id_names[$student->student_id] = $student->realname;
- }
- }
- }
- ///$class_student_info_data = $this->schoolManager->getClassStudentInfoByClassId($cid); //student_info
- if ($class_student_data) {
- foreach($class_student_data as $v)
- {
- if(!isset($b_student_arr[$v['student_id']]))
- {
- if ($paper_student_array)
- {
- if(isset($paper_student_array[$v['student_id']])){
- $no_paper_student[$v['student_id']] = array(
- 'student_id' => $v['student_id'],
- 'realname' => isset($class_student_info_array[$v['student_id']]) ?$class_student_info_array[$v['student_id']]:'',
- );
- }
- }
- if($c_paper_student_array )
- {
- if(!isset($c_paper_student_array[$v['student_id']]) )
- {
- $no_paper_student[$v['student_id']] = array(
- 'student_id' => $v['student_id'],
- 'realname' => isset($_student_id_names[$v['student_id']]) ?$_student_id_names[$v['student_id']]:'',
- );
- }
- }else
- {
- $no_paper_student[$v['student_id']] = array(
- 'student_id' => $v['student_id'],
- 'realname' => isset($_student_id_names[$v['student_id']]) ?$_student_id_names[$v['student_id']]:'',
- );
- }
- }
- }
- }
- $printType = '2';
-
- $data = array();
- if(isset($isUnderLine)){
- $data['under_line']=$isUnderLine;
- }
- $data['no_paper_student'] = $no_paper_student;
- $data['result'] = $result;
- $data["sname"] = $sname;
- $data['exam_id'] = $eid;
- $data['class_id'] = $cid;
- $subject_exam_data = $this->schoolManager->getxuekeStatus($this->semesterId);
- $data["subject"] = $subject_exam_data;
- $data['className'] = $classInfo->class_name;
- $data['paperName'] = $examInfo['zl_exam_name'];
- $data['examInfo'] = $examInfo;
- $data['printType'] = $printType;
- $this->render('change',$data);
- }
- //不推送成绩设置列表
- public function actionBlackList(){
- $name = Req::get("name");
- $classId = Req::get("class_id");
- $grade = Req::get("grade");
- $page = intval(Req::get("page"));
- $subjectId=$this->subjectId;
- $query=array();
- if(!$page) $page=1;
- $query['page']=$page;
- $where=array();
- if(in_array($subjectId,$this->mathSubjectId)){
- $where[]=" subject_id in(".implode(',',$this->mathSubjectId).") and semester_id='".$this->semesterId."'";
- }else{
- $where[]=" subject_id ='".$subjectId."' and semester_id='".$this->semesterId."'";
- }
-
- if($name){
- $where[]=" name like '%".$name."%'";
- $query['name']=$name;
- }
- if($classId){
- $where[]=" class_id = '".$classId."'";
- $query['class_id']=$classId;
- }
- if($grade){
- $where[]=" grade = '".$grade."'";
- $query['grade']=$grade;
- }
- $pageLimit=10;
- $data=Blacklist::model()->getExamList($where,$page,$pageLimit);
- $ExamModel=new SExam();
- if($data['dataList']){
- foreach ($data['dataList'] as $key =>$val){
- $data['dataList'][$key]['subject']=Yii::app()->params['subjectId'][$val['subject_id']];
- //判断成绩是否生成
- $exam=$ExamModel->getDetailByExamId($val['exam_id']);
- if($exam['status']==1){
- $data['dataList'][$key]['status']='是';
- }else{
- $data['dataList'][$key]['status']='否';
- }
- }
- }
- $data['query']=$query;
- $data['subject']=$subjectId;
- $data['name'] = $name?$name:"";
- $data['grade'] = $grade?$grade:0;
- $data['classId'] = $classId?$classId:'';
- // debug($data);
- $this->render('blacklist',$data);
- }
- //加载考试
- public function actionAjaxSearchExam(){
- $grade=Req::post('grade');
- $class=Req::post('class');
- $keyword=Req::post('keyword');
- $page=Req::post('page');
- if(!$page) $page=1;
- $pageLimit=10;
- $condition=array();
- $subject=$this->subjectId;
- $condition[]="e.semester_id='".$this->semesterId."'";
- if($subject==3){
- $condition[]='e.subject_id in ('.implode(',',$this->mathSubjectId).')';
- }else{
- $condition[]="e.subject_id ='".$subject."'";
- }
- if($grade){
- $condition[]="c.grade='".$grade."'";
- }
- if($class){
- $condition[]="c.class_id='".$class."'";
- }
- if($keyword){
- $condition[]="e.name like '%".$keyword."%'";
- }
- $notInExamIds=array();
- if(in_array($subject,$this->mathSubjectId)){
- $blacklist=$this->sConn->createCommand("select exam_id from blacklist where subject_id in(".implode(',',$this->mathSubjectId).") and semester_id='".$this->semesterId."'")->queryAll();
- }else{
- $blacklist=$this->sConn->createCommand("select exam_id from blacklist where subject_id='".$subject."' and semester_id='".$this->semesterId."'")->queryAll();
- }
- if($blacklist){
- foreach ($blacklist as $value){
- $notInExamIds[]=$value['exam_id'];
- }
- }
- if($notInExamIds){
- $condition[]="e.exam_id not in(".implode(',',$notInExamIds).")";
- }
- $sqlCount="SELECT count(*) as count FROM `exam` e ";
- $sqlCount.="join class c on c.class_id=e.class_id ";
- if($condition){
- $sqlCount.=" where ".implode(' and ',$condition);
- }
- $countData=$this->sConn->createCommand($sqlCount)->queryRow();
- $pages=array(
- 'total'=>$countData['count'],
- 'totalPage'=>ceil($countData['count']/$pageLimit),
- 'page'=>$page,
- );
- $offset=($page-1)*$pageLimit;
- $sql="SELECT e.exam_id,e.name,c.grade,e.tpl_data,e.`status`,c.class_id,e.type,c.class_type,c.class_name,e.create_time FROM `exam` e ";
- $sql.="join class c on c.class_id=e.class_id ";
- if($condition){
- $sql.=" where ".implode(' and ',$condition);
- }
- $sql.=" order by e.create_time desc limit {$offset},{$pageLimit}";
- $classArr=array(
- 1=>'行政班',
- 2=>'教学班'
- );
- //1:周考2:单元考3:月考4:联考5:期中6:期末7:高考模拟8:冲刺
- $typeArr=array(
- 1=>'周考',
- 2=>'单元考',
- 3=>'月考',
- 4=>'联考',
- 5=>'期中',
- 6=>'期末',
- 7=>'高考模拟',
- 8=>'冲刺',
- 9=>'测验'
- );
- $list = $this->sConn->createCommand($sql)->queryAll();
- if($list){
- foreach ($list as $key=>$val){
- $list[$key]['class_type']=$classArr[$val['class_type']];
- if(isset($typeArr[$val['type']])){
- $list[$key]['type']=$typeArr[$val['type']];
- }
- $list[$key]['subject_name']=Yii::app()->params['subjectId'][$this->subjectId];
- $list[$key]['create_date']=date('Y-m-d',$val['create_time']);
- $list[$key]['exam_date']='';
- if($val['tpl_data']){
- $tpl_data=json_decode($val['tpl_data'],true);
- if(isset($tpl_data['examDate'])){
- $list[$key]['exam_date']=$tpl_data['examDate'];
- }
- }
- if($val['status']==1){
- $list[$key]['status_msg']='是';
- }else{
- $list[$key]['status_msg']='否';
- }
- switch ($val['grade']){
- case 1:
- $list[$key]['grade']='高一';
- break;
- case 2:
- $list[$key]['grade']='高二';
- break;
- case 3:
- $list[$key]['grade']='高三';
- break;
- default:
- $list[$key]['grade']='高一';
- }
- }
- }
- $result['status']=1;
- $result['list']=$list;
- $result['pages']=$pages;
- exit(json_encode($result));
- }
- //添加黑名单
- public function actionAddBlacklist(){
- $examIds=Req::post('examIds');
- $result['status']=0;
- if(!$examIds){
- exit(json_encode($result));
- }
- $delSql="delete from blacklist where exam_id in(".implode(',',$examIds).")";
- $insertSql="insert into blacklist(`exam_group_id`,`exam_id`,`name`,`type`,`subject_id`,`semester_id`,`class_id`,`class_name`,`class_type`,`grade`,`exam_create_time`,`exam_date`,`dateline`) values ";
- $insertData=array();
- $ExamModel=new SExam();
- foreach ($examIds as $val){
- $ExamInfo=$ExamModel->getDetailByExamId($val);
- $classInfo = ClassModel::model()->findByPk($ExamInfo['class_id']);
- $tpl_data=json_decode($ExamInfo['tpl_data'],true);
- $insertData[]="('".$ExamInfo['exam_group_id']."','".$val."','".$ExamInfo['name']."','".$ExamInfo['type']."','".$ExamInfo['subject_id']."','".$this->semesterId."','".$ExamInfo['class_id']."','".$classInfo->class_name."','".$classInfo->class_type."','".$classInfo->grade."','".$ExamInfo['create_time']."','".$tpl_data['examDate']."','".time()."')";
- }
- if($insertData){
- $transcation = $this->sConn->beginTransaction();
- try {
- $insertSql.=implode(',',$insertData);
- $this->sConn->createCommand($delSql)->execute();
- $this->sConn->createCommand($insertSql)->execute();
- $transcation->commit();
- $result['status']=1;
- }catch (Exception $e){
- $transcation->rollback();
- }
- }
- exit(json_encode($result));
- }
- //删除黑名单
- public function actionDelBlacklist(){
- $examId=Req::get('exam_id');
- if(!$examId || !is_numeric($examId)){
- Yii::app()->jump->error('参数异常!');
- }
- $url=$_SERVER['HTTP_REFERER'];
- if($this->sConn->createCommand("delete from blacklist where exam_id = '".$examId."'")->execute()){
- $arr=array(
- 'schoolId' => $this->schoolId,
- 'examIds' =>array($examId)
- );
- sendDataToKafka('zsyte-marking-finished-notify-parent',$arr);
- // $send_json=json_encode($arr);
- // $stompconn = new Stomp(Yii::app()->params["activeMq"]["server"]);
- // $stompconn->send("zsyte.markingFinishedNotifyParent", $send_json);
- unset($stompconn);
- $this->redirect($url);
- }
- }
- //下载excel
- public function actionDownloadExcel(){
- $rs = $this->schoolManager->getClasses('ALL',array('class_id desc'));
- $objPHPExcel = new PHPExcel();
- $objPHPExcel->getProperties()->setCreator("ctos")
- ->setLastModifiedBy("ctos")
- ->setTitle("班级信息")
- ->setSubject("班级信息")
- ->setDescription("班级信息")
- ->setKeywords("excel")
- ->setCategory("result file");
- $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
- $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(10);
- $letters = array('C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
- $allSubject=Yii::app()->params['subjectId'];
- unset($allSubject[3]);
- unset($allSubject[51]);
- unset($allSubject[20]);
- $objPHPExcel->setActiveSheetIndex(0)
- ->setCellValue('A1', '姓名(必填)')
- ->setCellValue('B1', '班级(当前学期唯一)');
- $i=0;
- foreach ($allSubject as $key =>$val){
- $column=$letters[$i].'1';
- $objPHPExcel->getActiveSheet(0)->setCellValue($column,$val);
- $i++;
- }
- // $objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
- $i = 2;
- $objPHPExcel->getActiveSheet(0)->setCellValue('A' . $i, '小李1');
- $objPHPExcel->getActiveSheet(0)->setCellValue('B' . $i, '高一一班');
- $subjectOrder=0;
- foreach ($allSubject as $key =>$val){
- $column=$letters[$subjectOrder].$i;
- $subjectOrder++;
- $objPHPExcel->getActiveSheet(0)->setCellValue($column, '');
- }
- $objPHPExcel->getActiveSheet()->setTitle('知了家校导入成绩');
- $objPHPExcel->setActiveSheetIndex(0);
- ob_end_clean(); // Added by me
- header("Accept-Ranges:bytes");
- header('Content-Type:application/vnd.ms-excel');
- header("Content-type:application/vnd.ms-excel;charset=UTF-8");
- header('Content-Disposition:attachment;filename="知了家校导入成绩.xls"');
- header('Cache-Control:max-age=0');
- $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
- $objWriter->save('php://output');
- exit;
- }
- //成绩报告设置
- public function actionReportsetting(){
- $data = array();
- $this->render('reportsetting',$data);
- }
- //获取成绩报告设置
- public function actionAjaxGetReportSetting(){
- $data = array();
- $error = array();
- $zl_model = new BusinessZl_report_setting();
- $setting_data = $zl_model->getReportSetting($this->schoolId);
- if($setting_data){
- $data['class_average'] = $setting_data['class_average'];
- $data['grade_average'] = $setting_data['grade_average'];
- $data['class_rank'] = $setting_data['class_rank'];
- $data['grade_rank'] = $setting_data['grade_rank'];
- $data['level_replace_score'] = $setting_data['level_replace_score'];
- if($setting_data['score_level_setting']){
- $data['score_level_setting'] = json_decode($setting_data['score_level_setting'],true);
- }else{
- $data['score_level_setting']['A']['min_score'] = 90;
- $data['score_level_setting']['A']['max_score'] = 100;
- $data['score_level_setting']['B']['min_score'] = 70;
- $data['score_level_setting']['B']['max_score'] = 89;
- $data['score_level_setting']['C']['min_score'] = 60;
- $data['score_level_setting']['C']['max_score'] = 69;
- $data['score_level_setting']['D']['min_score'] = 40;
- $data['score_level_setting']['D']['max_score'] = 59;
- $data['score_level_setting']['E']['min_score'] = 0;
- $data['score_level_setting']['E']['max_score'] = 39;
- }
- }else{
- $data['class_average'] = 1;
- $data['grade_average'] = 1;
- $data['class_rank'] = 1;
- $data['grade_rank'] = 1;
- $data['level_replace_score'] = 0;
- $data['score_level_setting']['A']['min_score'] = 90;
- $data['score_level_setting']['A']['max_score'] = 100;
- $data['score_level_setting']['B']['min_score'] = 70;
- $data['score_level_setting']['B']['max_score'] = 89;
- $data['score_level_setting']['C']['min_score'] = 60;
- $data['score_level_setting']['C']['max_score'] = 69;
- $data['score_level_setting']['D']['min_score'] = 40;
- $data['score_level_setting']['D']['max_score'] = 59;
- $data['score_level_setting']['E']['min_score'] = 0;
- $data['score_level_setting']['E']['max_score'] = 39;
- }
- if($error){
- echo json_encode(array("status"=>0,"error"=>implode("<br>",$error)));exit;
- }else{
- echo json_encode(array("status"=>1,"data"=>$data));exit;
- }
- }
-
- //保存成绩报告设置
- public function actionAjaxSaveReportSetting(){
- $error = array();
- $insert_data = array();
- $class_average = (int)Req::post('class_average');
- $grade_average = (int)Req::post('grade_average');
- $class_rank = (int)Req::post('class_rank');
- $grade_rank = (int)Req::post('grade_rank');
- $level_replace_score = (int)Req::post('level_replace_score');
- $setting_data = Req::post('setting_data');
- if($level_replace_score == 1 && !$setting_data){
- $error[] = "分数等级不能为空";
- }
- if(!$error){
- $insert_data["class_average"] = $class_average;
- $insert_data["grade_average"] = $grade_average;
- $insert_data["class_rank"] = $class_rank;
- $insert_data["grade_rank"] = $grade_rank;
- $insert_data["level_replace_score"] = $level_replace_score;
- $insert_data["score_level_setting"] = $setting_data?htmlspecialchars_decode($setting_data):"";
- $zl_model = new BusinessZl_report_setting();
- $status= $zl_model->saveReportSetting($this->schoolId,$insert_data);
- if(!$status){
- $error[] = "更新失败";
- }
- }
- if($error){
- echo json_encode(array("status"=>0,"error"=>implode(",",$error)));exit;
- }else{
- echo json_encode(array("status"=>1));exit;
- }
- }
- //未付费用户权限设置
- public function actionUnpaidUserSetting(){
- $unpaidModel=new UnpaidUserSetting();
- $formData=getAttribute($unpaidModel->find('school_id=:school_id',array(':school_id'=>$this->schoolId)));
- if (Yii::app()->request->getIsPostRequest()){
- $parent_report=(int)Req::post('parent_report');
- $parent_exam_notify=(int)Req::post('parent_exam_notify');
- $student_report=(int)Req::post('student_report');
- $student_knowledge_bill=(int)Req::post('student_knowledge_bill');
- if($parent_report==$formData['parent_report'] && $parent_exam_notify==$formData['parent_exam_notify'] && $student_report==$formData['student_report'] && $student_knowledge_bill==$formData['student_knowledge_bill']){
- // Yii::app()->jump->error('保存成功');
- }
- $insertData=array(
- 'school_id'=>$this->schoolId,
- 'parent_report'=>$parent_report,
- 'parent_exam_notify'=>$parent_exam_notify,
- 'student_report'=>$student_report,
- 'student_knowledge_bill'=>$student_knowledge_bill
- );
- if($unpaidModel->saveReportSetting($insertData)){
-
- Yii::app()->unpaid_user_setting->hmset('zhiliao:unpaid_user_setting:'.$this->schoolId,$insertData);
- Yii::app()->jump->error('保存成功');
- }else{
- Yii::app()->jump->error('保存失败');
- }
- }
- $this->render('unpaid',$formData);
- }
- }
|