request->getQuery('cid')); if(!$get_id){ Yii::app()->jump->error('参数错误!'); } $data=array(); $data['teamData']=$this->schoolManager->getTeamByClass($get_id); //读取所有分组 //debug($data); $data['cid']=$get_id; $this->render('index',$data); } //添加小组 public function actionAdd_team(){ $team_name = safe_replace(Req::post('team_name')); $cid = safe_replace(Req::post('cid')); $team_id = safe_replace(Req::post('team_id')); $result['status']=0; if(!$team_name){ $result['msg']='添加失败,参数不正确'; exit(json_encode($result)); } $TeamModel=new STeam(); if($team_id){ $checkData=$TeamModel->fetchById($team_id); if(!$checkData){ $result['msg']='编辑失败,分组不存在'; exit(json_encode($result)); } $checkRepeat=$TeamModel->getByName($team_name,$cid); if($checkRepeat && $checkRepeat['team_id']!=$team_id){ $result['msg']='编辑失败,分组名称已存在'; exit(json_encode($result)); } if($TeamModel->updateTeam($team_name,$team_id)){ $result['status']=1; exit(json_encode($result)); }else{ $result['msg']='编辑失败'; exit(json_encode($result)); } }else{ $checkRepeat=$TeamModel->getByName($team_name,$cid); if($checkRepeat){ $result['msg']='添加失败,分组已经存在'; exit(json_encode($result)); } if($team_id=$TeamModel->addTeam($team_name,$cid)){ $result['status']=1; $result['team_id']=$team_id; exit(json_encode($result)); }else{ $result['msg']='添加失败'; exit(json_encode($result)); } } } //编辑小组 public function actionEdit_team(){ $team_name=$getName = safe_replace(Yii::app()->request->getQuery('Name')); $cid=$getName = safe_replace(Yii::app()->request->getQuery('cid')); $team_id=safe_replace(Yii::app()->request->getQuery('tid')); } //删除整组 public function actionDel_team(){ $team_id=safe_replace(Req::post('team_id')); $result['status']=0; if(!$team_id){ $result['msg']='操作失败,参数不正确'; exit(json_encode($result)); } $TeamModel=new STeam(); //判断小组是否有学生 $team_student=$TeamModel->getStudentByTeamId($team_id); if($team_student){ if($TeamModel->delTeam($team_id)){ $result['status']=1; exit(json_encode($result)); } }else{ if($TeamModel->delRealTeam($team_id)){ $result['status']=1; exit(json_encode($result)); } } $result['msg']='操作失败'; exit(json_encode($result)); } //学生列表 public function actionGetStudent(){ $cid=safe_replace(Req::post('cid')); $student_list=$this->schoolManager->getStudentByClassId($cid); //所有学生列表 //已分组学生列表 $team_student=$this->schoolManager->getTeamByClass($cid,'student'); //所有学生列表 $html=''; $html.=""; $html.=""; $html.="姓名"; $html.="性别"; $html.="系统准考证号"; $html.="学校准考证号"; $html.="学号"; $html.="分组状态"; $html.=""; if($student_list){ foreach ($student_list as $key=>$val){ if(in_array($val['student_id'],$team_student)){ $student_list[$key]['assign']=1; }else{ $student_list[$key]['assign']=0; } if($val['sex']==1){ $sex='男'; }else{ $sex='女'; } $html.=""; if(isset($team_student[$val['student_id']])) { $html .= ''; $groupType=$team_student[$val['student_id']]; }else{ $html .= ''; $groupType='未分组'; } $html.="{$val['realname']}"; $html.="{$sex}"; $html.="{$val['student_card']}"; $html.="{$val['school_student_card']}"; $html.="{$val['userno']}"; $html.="{$groupType}"; $html.=""; } } $result['status']=1; $result['data']=$html; exit(json_encode($result)); } //添加学生 public function actionAdd_student(){ $studentId=Req::post('student_id'); $realname=Req::post('realname'); $student_card=Req::post('student_card'); $team_id=Req::post('team_id'); $class_id=Req::post('cid'); $result['status']=0; if(!$team_id || !$studentId || !$realname || !$student_card || !$class_id){ $result['msg']='添加失败,参数不正确'; exit(json_encode($result)); } $insert=array(); foreach ($studentId as $key=>$val){ $insert[]=array( 'team_id'=>$team_id, 'student_id'=>$val, 'class_id'=>$class_id, 'real_name'=>$realname[$key], 'student_card'=>$student_card[$key] ); } $TeamModel=new STeam(); if($insert){ $rs =$TeamModel->addTeamStudent($insert); if($rs){ $result['status']=1; } } exit(json_encode($result)); } //删除学生 public function actionDel_student(){ $studentId=Req::post('student_id'); $class_id=Req::post('cid'); $result['status']=0; if( !$studentId || !$class_id){ $result['msg']='添加失败,参数不正确'; exit(json_encode($result)); } $TeamModel=new STeam(); $team_student=$TeamModel->getStudentByStudentIdClassId($studentId,$class_id); if(!$team_student){ $result['msg']='学生已经删除'; exit(json_encode($result)); } if($TeamModel->delStudentByStudentIdClassId($studentId,$class_id)){ $result['status']=1; exit(json_encode($result)); } $result['msg']='删除失败'; exit(json_encode($result)); } }