-1)
{
$paper_exam = $this->schoolManager->getPaerLabelledByExam($labelled);
if($paper_exam)
{
foreach($paper_exam as $v)
{
$s_exam_ids[$v['exam_id']] = $v['exam_id'];
}
}
unset($paper_exam);
}
// 年级条件
if($grade>0)
{
$class_data = $this->schoolManager->getSchoolByGrade($grade,$this->semesterId);
if($class_data)
{
foreach($class_data as $v)
{
$class_ids[$v['class_id']] = $v['class_id'];
}
$exam_class_data = $this->schoolManager->getClassIdByExam($class_ids);
if($exam_class_data)
{
foreach($exam_class_data as $v)
{
if(isset($s_exam_ids[$v['exam_id']]))
{
$l_b_exam_ids[$v['exam_id']] = $v['exam_id'];
}else
{
$s_exam_ids[$v['exam_id']] = $v['exam_id'];
}
}
}
unset($exam_class_data);
}
unset($class_data);
}
if(isset($l_b_exam_ids))
{
if($l_b_exam_ids)
{
$condition[] = "e.exam_id in (".implode(',',$l_b_exam_ids).")";
}else
{
$condition[] = "e.exam_id in (0)";
}
}else
{
if($labelled<0||$grade<1)
{
if(isset($s_exam_ids))
{
if($s_exam_ids)
{
$condition[] = "e.exam_id in (".implode(',',$s_exam_ids).")";
}else
{
$condition[] = "e.exam_id in (0)";
}
}
}else
{
$condition[] = "e.exam_id in (0)";
}
}
// 多学科切换条件
if(in_array($this->subjectId,$this->mathSubjectId)){
$condition[] = "e.subject_id in (".implode(',',$this->mathSubjectId).")";
}else{
$condition[] = "e.subject_id = '{$this->subjectId}'";
}
if ( $display == 1) {
$condition[] = "e.is_display = 1";
}else
{
$condition[] = "e.is_display = 0";
}
$TeacherModel=new Teacher();
// 考试名称条件
if($printName)
{
//查询教师id
$teacherIds=$TeacherModel->getTeacherIdByName($printName);
if($teacherIds){
$condition[] = " (e.name like '%{$printName}%' or eg.teacher_id in(".implode(',',$teacherIds)."))";
}else{
$condition[] = "e.name like '%{$printName}%'";
}
}
$condition[] = "eg.is_third = 0";
$condition[] = "eg.create_type in (0,1,2,3,5,6) ";
$condition[] = "eg.is_united = 0";
// $condition[] = "eg.homework = 0";
$teachers_data = Teacher::model()->findAll();
$class_teacher_data = array();
$teacherNames=array();
if($teachers_data) {
foreach ($teachers_data as $k => $v) {
$teacherNames[$v->teacher_id] = $v->teacher_name;
}
}
$gradeCardLength=array();
$gradeData=SGrade::model()->findAll();
foreach ($gradeData as $datum){
if($datum->card_status==1){
$gradeCardLength[$datum->id]=$datum->card_length;
}else{
$gradeCardLength[$datum->id]=0;
}
}
//获取考试列表
$exam_list = $this->schoolManager->getPrintGroupList($condition,array('e.create_time desc'),12);
//获取打印班级
if($exam_list)
{
//查询教师
$ExamModel=new Exam();
$StudentPaperRelation=new SStudentPaperRelation();
foreach($exam_list['rs'] as $key=>$v)
{
$items = array();
$tpl_data=array();
$exam_group_ids[$v['exam_group_id']] = $v['exam_group_id'];
$exam_list['rs'][$key]['is_tpl'] = 0; // 需要上传模板
$exam_list['rs'][$key]['is_custom_optional_topic'] = 0;
$exam_list['rs'][$key]['is_paper_49'] = 0;
//准考证
if(!$v['school_card_status']){
$exam_list['rs'][$key]['school_card_length'] = $gradeCardLength[$v['grade']];
}
if(isset($teacherNames[$v['teacher_id']])){
$exam_list['rs'][$key]['teacher_name'] = $teacherNames[$v['teacher_id']];
}else{
$exam_list['rs'][$key]['teacher_name'] = '';
}
if(isset($v['tpl_data'])){
$tpl_data = json_decode($v['tpl_data'],1);
//标注期望完成时间
if(isset($tpl_data['estimateTime']))
{
$exam_list['rs'][$key]['estimate_time'] = date('Y-m-d H:i:s',$tpl_data["estimateTime"]);
}
}
if(isset($tpl_data['branch'])){
$exam_list['rs'][$key]['branch'] = $tpl_data['branch'];
}else{
$exam_list['rs'][$key]['branch'] =0;
}
if(in_array($v['tpl_index'], Yii::app()->params['custom_tpls_ids'])){
//自定义模板
$exam_list['rs'][$key]['is_custom_tpl'] = true;
if(isset($tpl_data['items']) && isset($tpl_data['items'][17])){
$exam_list['rs'][$key]['is_custom_optional_topic'] = 1;
}
$v['is_custom_tpl'] = true;
}else{
//非自定义模板
$exam_list['rs'][$key]['is_custom_tpl'] = false;
$v['is_custom_tpl'] = false;
}
if (in_array($v['tpl_index'], Yii::app()->params['no_template_id']) || $v['is_custom_tpl']) {
$exam_list['rs'][$key]['is_tpl'] = 1;
//题卡分离
$exam_list['rs'][$key]['paper_tpl_type'] = 2;
}else{
$exam_list['rs'][$key]['paper_tpl_type'] = 1;
}
if(in_array($v['tpl_index'],Yii::app()->params['merge_topic_tpl']))
{
$exam_list['rs'][$key]['paper_tpl_type'] = 3;
if($v['tpl_index'] == 9 )
{
$exam_list['rs'][$key]['paper_tpl_type'] = 4;
}
}
if(in_array($v['tpl_index'],Yii::app()->params['merge_topic_tpl_all']))
{
$exam_list['rs'][$key]['paper_tpl_type'] = 3;
if($v['tpl_index'] == 9 )
{
$exam_list['rs'][$key]['paper_tpl_type'] = 4;
}
}
if(in_array($v['tpl_index'],Yii::app()->params['merge_topic_tpl7']))
{
$exam_list['rs'][$key]['is_paper_49'] = 1;
}
if(in_array($v['tpl_index'],Yii::app()->params['merge_topic_tpl8']))
{
$exam_list['rs'][$key]['is_paper_49'] = 1;
}
if(in_array($v['tpl_index'],Yii::app()->params['template_id_qrcode']))
{
$exam_list['rs'][$key]['qrcode'] = 1;
}else{
$exam_list['rs'][$key]['qrcode'] = 0;
}
//判断是否已上传成绩
$exam_list['rs'][$key]['is_feedback']=0;
$exam=$ExamModel->getExamIds($v['exam_group_id']);
if($exam){
if($StudentPaperRelation->getStudentFeedBack($exam)){
$exam_list['rs'][$key]['is_feedback']=1;
}
}
//是否使用在线答题卡
$exam_list['rs'][$key]['third_card']=0;
$exam_list['rs'][$key]['online_card']=0;
$exam_list['rs'][$key]['is_qrcode_online']=0;
$exam_list['rs'][$key]['marking_papers']=0;
$studentAnswerOnline=$this->schoolManager->getAnswerSheet($v['exam_group_id']);
if($studentAnswerOnline){
if($studentAnswerOnline['online_card']==1){
$exam_list['rs'][$key]['online_card']=$studentAnswerOnline['online_card'];
$exam_list['rs'][$key]['is_qrcode_online']=$studentAnswerOnline['is_qrcode_online'];
$exam_list['rs'][$key]['marking_papers']=$studentAnswerOnline['marking_papers'];
if($studentAnswerOnline['paper_size']==1){
$exam_list['rs'][$key]['paper_size']='A3';
}elseif($studentAnswerOnline['paper_size']==2){
$exam_list['rs'][$key]['paper_size']='A4';
}elseif($studentAnswerOnline['paper_size']==3){
$exam_list['rs'][$key]['paper_size']='16K';
}elseif($studentAnswerOnline['paper_size']==4){
$exam_list['rs'][$key]['paper_size']='8K';
}elseif($studentAnswerOnline['paper_size']==5){
$exam_list['rs'][$key]['paper_size']='8K';
}
}else{
$exam_list['rs'][$key]['third_card']=1;
}
}
}
//获取考试ID
$criteria = new CDbCriteria();
$criteria->select = 'exam_id,exam_group_id';
$criteria->addInCondition('exam_group_id',$exam_group_ids);
$exam_data = Exam::model()->findAll($criteria);
unset($criteria);
unset($exam_group_ids);
if($exam_data)
{
foreach($exam_data as $v)
{
//$exam_use_wp
$exam_ids[$v->exam_id] = $v->exam_id;
$_exam_group_ids[$v->exam_group_id][$v->exam_id] = $v->exam_id;
$_exam_ids[$v->exam_id] = $v->exam_group_id;
}
unset($exam_data);
//通过考试ID,获取打印班级
$criteria = new CDbCriteria();
$criteria->select = 'exam_id,class_id,is_print,is_print_online';
$criteria->addInCondition('exam_id',$exam_ids);
$criteria->addCondition('is_print = 1 or is_print_online=1');
$class_print_data = ClassExamPrinter::model()->findAll($criteria);
if($class_print_data)
{
foreach($class_print_data as $v)
{
if( isset($_exam_ids[$v->exam_id]))
{
if($v->is_print==1){
$exam_printer_num['word'][$_exam_ids[$v->exam_id]][$v->exam_id] = $v->exam_id;
}
if($v->is_print_online==1){
$exam_printer_num['online'][$_exam_ids[$v->exam_id]][$v->exam_id] = $v->exam_id;
}
}
}
}
unset($criteria);
unset($class_print_data);
}
}
//获取班级年级
$class_data = ClassModel::model()->findAll('semester_id=:semester_id',array(':semester_id'=>$this->semesterId));
if($class_data)
{
foreach($class_data as $v)
{
$class_grade_arr[$v->class_id] = $v->grade;
}
}
unset($class_data);
//获取试卷标注状态
$criteria = new CDbCriteria();
$criteria->select = 'exam_id,is_labelled,labelled_type';
$criteria->addInCondition('exam_id',$exam_ids);
$paper_data = SPaper::model()->findAll($criteria);
unset($criteria);
if($paper_data)
{
foreach($paper_data as $v)
{
if( isset($_exam_ids[$v->exam_id]))
{
$paper_arr[$_exam_ids[$v->exam_id]] = $v->is_labelled;
$paper_labelled_type_arr[$_exam_ids[$v->exam_id]] = $v->labelled_type;
}
}
}
//获取产品设置版本
$productEdition=$this->sConn->createCommand("select switch from producut_set_edition where id=1")->queryRow();
if(!$productEdition || $productEdition['switch']==2){
$data['productSwitch']=2;
}else{
$data['productSwitch']=3;
}
// 获取多学科状态
// $subject_exam_data = $this->schoolManager->getxuekeStatus($this->semesterId);
$findSchool = BusinessSchool::model()->find('school_id=:scid',array(':scid'=>Yii::app()->session['coachInfo']['school_id']));
$data['pages'] = $exam_list['pager'];
$data['page_total'] = $exam_list['pager']->rowsCount;
$data['printList'] = $exam_list['rs'];
$data['printer'] = $exam_printer_num;
$data['exam_class'] = $_exam_group_ids;
//$data["subject"] = $subject_exam_data;
$data["exam_use_wp"] = $findSchool->use_wp;
$data["display"] = $display;
$data["labelled"] = $labelled;
$data["grade"] = $grade;
$data["printName"] = $printName;
$data["paper"] = $paper_arr;
$data["paper_labelled_type"] = $paper_labelled_type_arr;
$data["class_grade"] = $class_grade_arr;
$data["printType"] = $type;
$data['teacherNames']=$teacherNames;
$data["teacherId"] = $teacherId;
//获取导出数据白名单
$data["exportExam"] = $this->schoolManager->getExportExamWhiteList($this->schoolId);;
$this->render('group_list',$data);
}
public function actionClass_exam()
{
$condition = array();
$exam_ids = array();
$exam_id = '';
$exam_name = '';
$class_names = array();
$class_ids = array();
$class_print = array();
$class_online_print = array();
$data = array();
$exam_student_up_num = array();
$exam_student_num = array();
$student_img_up_num = array();//学生答题原图
$class_name = Req::get("class_name");
$exam_group_id = Req::get("exam_group_id");
$masttype = (int)Req::get("masttype");
$is_united = (int)Req::get('is_united');
$grade = Req::get('grade');
$branch = Req::get('branch');
$multiple_choice_required=0; //多选题必选数量
$exam_date=''; //考试日期
$exam_uploaded=0;
if($exam_group_id <= 0)
{
Yii::app()->jump->error('未找到考试信息!');
}
$exam_group_data = ExamGroup::model()->find('exam_group_id=:exam_group_id',array(':exam_group_id'=>$exam_group_id));
if(!$exam_group_data)
{
Yii::app()->jump->error('未找到考试信息!');
}
if($exam_group_data->upload_status>0){
$exam_uploaded=1;
}
$condition[] = "exam_group_id = ".$exam_group_id;
//获取班级信息
$class_data = $this->schoolManager->getSemesterClasses($this->semesterId);
$class_types=array();
if($class_data)
{
foreach($class_data as $v)
{
if($class_name && $v['class_name'] == $class_name)
{
$class_ids[$v['class_id']] = $v['class_id'];
}
$class_names[$v['class_id']] = $v['class_name'];
if($v['class_type']==1){
$class_types[$v['class_id']]='行政班';
}elseif($v['class_type']==2){
$class_types[$v['class_id']]='教学班';
}
}
}
//debug($class_data);
if($class_ids)
{
$condition[] = "class_id in (".implode(',',$class_ids).") ";
}
// 多学科切换条件
if(in_array($this->subjectId,$this->mathSubjectId)){
$condition[] = "subject_id in (".implode(',',$this->mathSubjectId).")";
}else{
$condition[] = "subject_id = '{$this->subjectId}'";
}
if($class_ids)
{
$condition[] = "class_id in (".implode(',',$class_ids).") ";
}
//获取考试列表
$exam_data = $this->schoolManager->getExamsByExamGroupIdList($condition,array('exam_id desc'),12);
if($exam_data['rs'])
{
foreach($exam_data['rs'] as $k=>$v)
{
$exam_ids[$v['exam_id']] = $v['exam_id'];
$exam_id = $v['exam_id'];
$exam_name = $v['print_name'];
}
}else
{
Yii::app()->jump->error('未找到考试信息!');
}
//获取班级考试是否打印
$criteria = new CDbCriteria();
$criteria->addInCondition('exam_id',$exam_ids);
$criteria->addCondition('type = 0');
$class_print_data = ClassExamPrinter::model()->findAll($criteria);
if($class_print_data)
{
foreach($class_print_data as $v)
{
$class_print[$v->exam_id] = $v->is_print;
$class_online_print[$v->exam_id] = $v->is_print_online;
}
}
unset($criteria);
unset($class_print_data);
//获取班级考试的上传成绩
$criteria = new CDbCriteria();
$criteria->select= 'student_id,is_feedback,exam_id,student_img_paper';
$criteria->addInCondition('exam_id',$exam_ids);
$criteria->addCondition('is_del = 0');
$student_paper_data = SStudentPaperRelation::model()->findAll($criteria);
if($student_paper_data)
{
foreach($student_paper_data as $v)
{
if($v->is_feedback)
{
$exam_student_up_num[$v->exam_id][$v->student_id] = $v->student_id;
}
$exam_student_num[$v->exam_id][$v->student_id] = $v->student_id;
if (!isset($student_img_up_num[$v->exam_id])) {
$student_img_up_num[$v->exam_id] = array();
}
if (trim($v['student_img_paper'])) {
$student_img_up_num[$v->exam_id][$v->student_id] = $v->student_id;
}
}
}
unset($criteria);
unset($student_paper_data);
//获取paper
$paperIds=array();
$criteria = new CDbCriteria();
$criteria->addInCondition('exam_id',$exam_ids);
$paperData = SPaper::model()->findAll($criteria);
if($paperData)
{
foreach($paperData as $v)
{
$paperIds[$v->exam_id] = $v->paper_id;
}
}
unset($criteria);
unset($exam_ids);
$student_answer_img_num=array();
foreach($exam_student_up_num as $eid =>$sids){
$student_answer_img_num[$eid]=$this->schoolManager->getUpAnswerStudent($paperIds[$eid],$sids,true);
}
//获取paper 表数据
$paper_data = SPaper::model()->find('exam_id=:exam_id',array(':exam_id'=>$exam_id));
if(!$paper_data)
{
Yii::app()->jump->error('未找到考试信息!');
}
//读取试题数据
$isAllSelect=1; //全部客观题判断
$paperTopic=SPaperTopicRelation::model()->findAll('paper_id=:paper_id',array(':paper_id'=>$paper_data->paper_id));
if(!$paperTopic){
Yii::app()->jump->error('未找到考试信息!');
}
//选择题类型判断
$allSubjectType=array();
if($exam_group_data['qxk_paper_id']>0){
$allSubjectType=array(1,2,3,4,12);
}else{
$allSubjectType=array(1,2,11);
}
foreach ($paperTopic as $item){
if(!in_array($item->type,$allSubjectType)){
$isAllSelect=0;
break;
}
}
$printList = array();
$has_marked = false;
$data['online_card'] = 0;
$data['is_qrcode_online'] = 0;
if($exam_data["rs"]){
$studentAnswerOnline=$this->schoolManager->getAnswerSheet($exam_group_id);
$studentAnswerCardOnline=new SStudentAnswerCardOnline();
foreach ($exam_data['rs'] as $k=>$v) {
$printList['is_tpl'] = 0; // 需要上传模板
$printList['answer_card_uploaded'] = false;
if(in_array($v['tpl_index'], Yii::app()->params['custom_tpls_ids'])){
//自定义模板
$printList['is_custom_tpl'] = true;
$v['is_custom_tpl'] = true;
}else{
//非自定义模板
$printList['is_custom_tpl'] = false;
$v['is_custom_tpl'] = false;
}
if (in_array($v['tpl_index'], Yii::app()->params['no_template_id']) || $v['is_custom_tpl']) {
$printList['is_tpl'] = 1;
if(trim($paper_data->answer_card_src)){
$printList['answer_card_uploaded'] = true;
}
//题卡分离
$printList['paper_tpl_type'] = 2;
}else{
$printList['paper_tpl_type'] = 1;
}
if(in_array($v['tpl_index'],Yii::app()->params['merge_topic_tpl']))
{
$printList['paper_tpl_type'] = 3;
if($v['tpl_index'] == 9 )
{
$printList['paper_tpl_type'] = 4;
}
}
if(in_array($v['tpl_index'],Yii::app()->params['merge_topic_tpl_all']))
{
$printList['paper_tpl_type'] = 3;
if($v['tpl_index'] == 9 )
{
$printList['paper_tpl_type'] = 4;
}
}
//英语题卡分离一
if($this->subjectId == 8){
$printList['paper_tpl_type'] = 5;
}
if($v['status'] == 1){
$has_marked = true;
}
//判断多选题
if(!$multiple_choice_required){
$tpl_data=json_decode($v['tpl_data'],true);
if(isset($tpl_data['items'][17]) && isset($tpl_data['items'][17]['required']) ){
$multiple_choice_required=$tpl_data['items'][17]['required'];
}
$exam_date=$tpl_data['examDate'];
}
//是否使用在线答题卡
$exam_data['rs'][$k]['online_card']=0;
$exam_data['rs'][$k]['is_qrcode_online']=0;
if($studentAnswerOnline){
$exam_data['rs'][$k]['online_card']=$studentAnswerOnline['online_card'];
$exam_data['rs'][$k]['is_qrcode_online']=$studentAnswerOnline['is_qrcode_online'];
$data['online_card'] = $studentAnswerOnline['online_card'];
$data['is_qrcode_online'] = $studentAnswerOnline['is_qrcode_online'];
if($studentAnswerOnline['online_card']==1){
if($studentAnswerOnline['paper_size']==1){
$exam_data['rs'][$k]['paper_size']='A3';
}elseif($studentAnswerOnline['paper_size']==2){
$exam_data['rs'][$k]['paper_size']='A4';
}elseif($studentAnswerOnline['paper_size']==3){
$exam_data['rs'][$k]['paper_size']='16K';
}elseif($studentAnswerOnline['paper_size']==4){
$exam_data['rs'][$k]['paper_size']='8K';
}elseif($studentAnswerOnline['paper_size']==5){
$exam_data['rs'][$k]['paper_size']='8K';
}
}
if($studentAnswerOnline['online_card']==1 && $studentAnswerOnline['is_qrcode_online']==1){
//查询生成数量
$studentCardOnline= $studentAnswerCardOnline->getCountByExamId($v['exam_id']);
if($studentCardOnline){
$exam_data['rs'][$k]['card_created']=$studentCardOnline['count'];
}
}
}
}
}
//是否能添加班级 FIXME add_class_0924
//打印中
$enable_add_class = false;
if($exam_group_data['status'] == 1 || $exam_group_data['mark_type'] ==0){
$enable_add_class = true;
}else{
//混合阅卷
if($exam_group_data['mark_type'] == 3){
$enable_add_class = ($exam_group_data['mark_status']==2 && $exam_group_data['upload_status']== 2) ? false : true;
}
//单独阅卷
if($exam_group_data['mark_type'] == 4){
$enable_add_class = $has_marked ? false : true;
}
}
//查询还原记录
$examRestore=SExamRestore::model()->find('exam_group_id=:exam_group_id',array(':exam_group_id'=>$exam_group_id));
if($examRestore){
$data['restore'] = 1;
}else{
$data['restore'] = 0;
}
//读取试题推送设置
$topicPushSettingModel=new SExamPushTopicsSetting();
$topicPushSetting=$topicPushSettingModel->getTopicSetting($exam_group_id);
$topicPushSettingRelation=array();
if($topicPushSetting){
foreach ($topicPushSetting as $item){
if($item['topic_ids']){
$topicSetting=json_decode($item['topic_ids'],true);
if($topicSetting){
$topicPushSettingRelation[(string)$item['exam_id']]=1;
}
}
}
}
// 获取多学科状态
//$subject_exam_data = $this->schoolManager->getxuekeStatus($this->semesterId);
$this->setIs_new($exam_group_id);
$data['printList'] = $exam_data['rs'];
$data['print'] = $printList;
$data['pages'] = $exam_data['pager'];
$data['page_total'] = $exam_data['pager']->rowsCount;
$data["class_name"] = $class_name;
$data["class_data"] = $class_names;
$data["class_types"] = $class_types;
$data["exam_group_data"] = $exam_group_data;
//$data["subject"] = $subject_exam_data;
$data["exam_id"] = $exam_id;
$data["exam_name"] = $exam_name;
$data["exam_print"] = $class_print;
$data["exam_online_print"] = $class_online_print;
$data["exam_student"] = $exam_student_num;
$data["exam_up_student"] = $exam_student_up_num;
$data["student_img_up_num"] = $student_img_up_num;
$data["student_answer_img_num"] = $student_answer_img_num;
$data["exam_group_id"] = $exam_group_id;
$data["grade"] = $grade;
$data["branch"] = $branch;
$data["enable_add_class"] = $enable_add_class;
$data["qxk_paper_id"] = $exam_group_data->qxk_paper_id;
$data['exam_date']=$exam_date;
$data['exam_uploaded']=$exam_uploaded;
$data['topic_push_setting']=$topicPushSettingRelation;
$data['is_all_select']=$isAllSelect;
$data['qxk_paper_id']=$exam_group_data['qxk_paper_id'];
//判断全学科白名單
$data['new_answer_sheet_subject']=0;
if($data['qxk_paper_id']){
$rs = http('/cms/api/module-white-list/new_answer_sheet_subject/'.$this->subjectId,'GET',$this->schoolId,array(),'cgi');
$rs=json_decode($rs,true);
if(isset($rs['errCode']) && $rs['errCode']=='00' && $rs['data']==true){
$data['new_answer_sheet_subject']=1;
}
}
$data["subject"]=$this->subjectId;
if($studentAnswerOnline){
$data['online_card']=$studentAnswerOnline['online_card'];
$data['is_qrcode_online']=$studentAnswerOnline['is_qrcode_online'];
}
if($multiple_choice_required>1){
$data['noOnline']=1;
}elseif(isset($exam_data['rs'][0]['paper_size']) && $exam_data['rs'][0]['paper_size']!='A3'){
$data['noOnline']=2;
}elseif($exam_group_data['mark_type']==0) {
$data['noOnline'] = 3;
}elseif($printList['paper_tpl_type'] == 1 || $printList['paper_tpl_type'] == 3){
$data['noOnline'] = 4;
}else{
$data['noOnline']=0;
}
$data['online_token']=getOnlineToolToken($this->schoolId);
$_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;
$data['version_number']=$version_number;
if($is_united==1){
$this->render('class_exam_united',$data);
}else{
$this->render('class_exam2',$data);
}
}
// 打印列表
public function actionSub_index(){
Url::clean();
$printName = Req::get("name");
$classId = Req::get("classId");
$printType = Req::get("type");
$grade = Req::get("grade");
$labelled = Req::get("labelled");
$display = Req::get("display");
$is_print = Req::get("is_print");
if (empty($printType)) {
$printType = 'wp';
$printTypeData = 0;
} else {
switch ($printType) {
case "wp":
$printTypeData = 0;
break;
case "wtb":
$printTypeData = 1;
break;
case "isp":
$printTypeData = 2;
break;
case "studytrend":
$printTypeData = 3;
break;
case "section":
$printTypeData = 4;
break;
case "third_wb": //多学科错题本
$printTypeData = 1;
$this->subjectId = Yii::app()->session['session_duoxueke_subject_id'];
break;
case "third_isp": //多学科个性化学习宝
$printTypeData = 3;
$this->subjectId = Yii::app()->session['session_duoxueke_subject_id'];
break;
default:
$printTypeData = null;
break;
}
}
$condition = array();
if($is_print > -1)
{
$condition[] = "cep.is_print = '{$is_print}'";
}else{
$is_print = -1;
}
if($printName)
$condition[] = "e.name like '%{$printName}%'";
if(!Str::isBlank($printTypeData))
$condition[] = "cep.type = '{$printTypeData}'";
if($classId)
$condition[] = "c.class_id = '{$classId}'";
if ($grade) {
$condition[] = "c.grade = '{$grade}'";
}
if (!Str::isBlank($labelled)) {
$condition[] = "p.is_labelled = '{$labelled}'";
}
if ($printType=='wp' && $display != 1) {
$condition[] = "e.is_display = '0'";
}
if(in_array($this->subjectId,$this->mathSubjectId)){
$condition[] = "e.subject_id in (".implode(',',$this->mathSubjectId).")";
}else{
$condition[] = "e.subject_id = '{$this->subjectId}'";
}
$condition[] = "eg.create_type in (0,1,2,3,5,6) ";
//$condition[] = "eg.homework = 0";
//debug($condition);die;
if (empty($grade)) {
$grade = 'ALL';
}
$classes = $this->schoolManager->getClasses($grade);
if($printType=='wp')
{
$condition[] = "eg.is_third = 0";
$resultList = $this->schoolManager->getPrintList($condition,array('e.create_time desc'));
}else{
$resultList = $this->schoolManager->getPrintList_ipf($condition,array('e.complete_time desc'));
}
$printList = array();
if($resultList["rs"]){
foreach ($resultList['rs'] as $k=>$v) {
$printList[$k] = $v;
if ($v["type"] == 1) {
$printList[$k]['print_name']= $v["exam_name"].'"错题本"';
}
elseif ($v["type"] == 2) {
$printList[$k]['print_name']= $v["exam_name"].'"个性化学习方案"';
}
elseif ($v["type"] == 3) {
if($this->subjectId == 8){
$printList[$k]['print_name']= $v["exam_name"].'"个性化学习宝"';
}else{
$printList[$k]['print_name']= $v["exam_name"].'"个性化学习宝"';
}
}elseif ($v["type"] == 4) {
$printList[$k]['print_name']= $v["exam_name"].'"阶段复习个性化学习宝"';
}
else {
$printList[$k]['print_name']= $v["exam_name"];
}
$printList[$k]['is_tpl'] = 0; // 需要上传模板
$printList[$k]['answer_card_uploaded'] = false;
if(in_array($v['tpl_index'], Yii::app()->params['custom_tpls_ids'])){
//自定义模板
$printList[$k]['is_custom_tpl'] = true;
$v['is_custom_tpl'] = true;
}else{
//非自定义模板
$printList[$k]['is_custom_tpl'] = false;
$v['is_custom_tpl'] = false;
}
if (in_array($v['tpl_index'], Yii::app()->params['no_template_id']) || $v['is_custom_tpl']) {
$printList[$k]['is_tpl'] = 1;
if(trim($printList[$k]['answer_card_src'])){
$printList[$k]['answer_card_uploaded'] = true;
}
//题卡分离
$printList[$k]['paper_tpl_type'] = 2;
}else{
$printList[$k]['paper_tpl_type'] = 1;
}
if(in_array($v['tpl_index'],Yii::app()->params['merge_topic_tpl']))
{
$printList[$k]['paper_tpl_type'] = 3;
if($v['tpl_index'] == 9 )
{
$printList[$k]['paper_tpl_type'] = 4;
}
}
if(in_array($v['tpl_index'],Yii::app()->params['merge_topic_tpl_all']))
{
$printList[$k]['paper_tpl_type'] = 3;
if($v['tpl_index'] == 9 )
{
$printList[$k]['paper_tpl_type'] = 4;
}
}
//题卡合一
}
}
//$subject_exam_data = $this->schoolManager->getxuekeStatus($this->semesterId);
$data = array();
$data['printList'] = $printList;
$data['pages'] = $resultList['pager'];
$data['page_total'] = $resultList['pager']->rowsCount;
$data["printType"] = $printType;
$data["printName"] = $printName;
$data["classes"] = $classes;
$data["classId"] = $classId;
$data["grade"] = $grade;
$data["labelled"] = $labelled;
$data["display"] = $display;
$data["is_print"] = $is_print;
//$data["subject"] = $subject_exam_data;
$data['subjectId']=$this->subjectId;
if(isset($this->schoolInfo->use_zhixue) && !empty($this->schoolInfo->use_zhixue))
{
$data["use_zhixue"] = $this->schoolInfo->use_zhixue;
}else
{
$data["use_zhixue"] = 0;
}
unset($resultList);
$this->render('index',$data);
}
// 打印试卷、纠错本、个性化学习宝
public function actionAjaxupdate(){
$cid = safe_replace($_POST['cid']);
$eid = safe_replace($_POST['eid']);
$tid = safe_replace($_POST['tid']);
$error = array();
$error['success'] = 0;
if (empty($cid) || !is_numeric($cid)) {
$error['message'] = 'classId 错误!';
echo json_encode($error);exit();
}
if (empty($eid) || !is_numeric($eid)) {
$error['message'] = 'examId 错误!';
echo json_encode($error);exit();
}
if ($tid == 0) { // 打印试卷
$_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;
self::printPaper_v2($cid,$eid);
} elseif ($tid == 1) { // 纠错本
//self::printWrongTopic($cid,$eid);
self::downloadWrongTopic($cid,$eid);
} elseif ($tid == 2) { // 个性化学习宝
self::printRaiseScheme($cid, $eid);
}
}
// 选择需打印试卷的学生
public function actionChange(){
Url::clean();
$sname = Req::get("sname");
$cid = Req::get("cid");
$eid = Req::get("eid");
$tid = Req::get("tid");
$isFeedback=0;
$useAnswerCardOnlineQrcode=0;
switch($tid){
case "0":
$printType = 'wp';
break;
case "1":
$printType = 'wb';
break;
case "2":
$printType = 'isp';
break;
default:
$printType = 'wp';
}
if($sname)
{ $_student_ids = array();
$criteria = new CDbCriteria();
$criteria->select = 'student_id';
$criteria->addSearchCondition('realname',$sname);
$student_info_data = SStudentInfo::model()->findAll($criteria);
if($student_info_data)
{
foreach($student_info_data as $v)
{
$_student_ids[$v->student_id] = $v->student_id;
}
}
}
$classInfo = ClassModel::model()->findByPk($cid);
if (empty($classInfo)) {
Yii::app()->jump->error('未找到班级!');
}
$examInfo = Exam::model()->findByPk($eid);
if (empty($examInfo)) {
Yii::app()->jump->error('未找到周周练!');
}
$examGroupInfo=ExamGroup::model()->findByPk($examInfo->exam_group_id);
$getResult = ClassExamPrinter::model()->find('class_id=:cid and exam_id=:eid and type=0',array(':cid'=>$cid,':eid'=>$eid));
if (empty($getResult)) {
Yii::app()->jump->error('未找到班级与试卷对应关系!');
}
$paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
if (empty($paperInfo)) {
Yii::app()->jump->error('未找到试卷信息!');
}
$_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;
$paperData='{}';
if($examGroupInfo->qxk_paper_id==0){
$paperData = $this->schoolManager->getPaperWithTopicsDetails_v2($paperInfo->paper_id);
}
if(trim($paperInfo->answer_card_src))
$answerCardUploaded = true;
else
$answerCardUploaded = false;
$tpl = 1;// 需要上传模板
$tplTwo= 1;
if (!in_array($examInfo->tpl_index,Yii::app()->params['no_template_id']) ) {
$paperType = 1;
if (empty($paperInfo->tpl_doc_src)) {
$tpl = 2;
}
$tplTwo= 2;
}else{
$paperType = 2;
}
if(in_array($examInfo->tpl_index,Yii::app()->params['merge_topic_tpl']))
{
$tpl = 1;
$paperType = 1;
$tplTwo= 2;
}
if(in_array($examInfo->tpl_index, Yii::app()->params['custom_tpls_ids'])){
$isCustomTpl = true;
}
else{
$isCustomTpl = false;
}
//判断在线答题卡使用情况
$answerCardOnline=$this->schoolManager->getAnswerSheetOnline($examInfo->exam_group_id);
if($answerCardOnline && $answerCardOnline['online_card']==1 && $answerCardOnline['is_qrcode_online']==1){
$useAnswerCardOnlineQrcode=1;
}
$relateTopic = SPaperTopicRelation::model()->count('paper_id=:paid',array(':paid'=>$paperInfo->paper_id));
if (empty($relateTopic)) {
Yii::app()->jump->error('未找该试卷试题信息!');
}
// 获取阅卷类型
$markType = 0;
$groupInfo = $this->schoolManager->getExam($eid);
if (!empty($groupInfo)) {
$findInfo = SExamGroup::model()->find('exam_group_id=:eg_id',array('eg_id'=>$groupInfo['exam_group_id']));
if (!empty($findInfo)) {
$markType = $findInfo->mark_type;
}
}
$result = array();
if(isset($_student_ids) && !empty($_student_ids))
{
$criteria = new CDbCriteria();
$criteria->select = 'student_id,paper_id,class_id,exam_id,student_card,school_student_card,is_feedback,is_complete';
$criteria->addCondition('paper_id=:paid');
$criteria->addCondition('class_id=:caid');
$criteria->addInCondition('student_id',$_student_ids);
$criteria->addCondition('is_del=:is_del');
$criteria->params[':paid'] = $paperInfo->paper_id;
$criteria->params[':caid'] = $cid;
$criteria->params[':is_del'] = 0;
$relateStudent = SStudentPaperRelation::model()->findAll($criteria);
}else
{
$relateStudent = SStudentPaperRelation::model()->findAll(array(
'select' => array('student_id','paper_id','class_id','exam_id','student_card','school_student_card','is_feedback','is_complete','student_img_paper'),
'condition' => 'paper_id=:paid and class_id=:caid and is_del=:is_del',
'params' => array(':paid'=>$paperInfo->paper_id,':caid'=>$cid,':is_del'=>0)));
}
//if (empty($relateStudent)) {
// Yii::app()->jump->error('未找该试卷关联的学生!');
//} else {
//$studentModel = StudentInfo::model();
// 获取学生姓名
$_student_id = array();
foreach($relateStudent as $v)
{
$_student_id[$v->student_id] = $v->student_id;
}
//if(!$_student_id)
//{
// Yii::app()->jump->error('未找该试卷关联的学生!');
//}
$studentNames = array();
$b_student_arr = array();
$b_student_arr = Yii::app()->redis_business_student->hgetAll('redis_business_del_student:'.$this->schoolId);
if(!$b_student_arr ){
$array_student = array();
$b_student_data=$this->schoolManager->getStudentBySchool($this->schoolId);
if($b_student_data){
foreach ($b_student_data as $k=>$v){
$array_student[$v['student_id']] = $v['student_id'];
$b_student_arr[$v['student_id']]=$v['student_id'];
}
}
Yii::app()->redis_business_student->del('redis_business_del_student:'.$this->schoolId);
if($array_student){
Yii::app()->redis_business_student->hmset('redis_business_del_student:'.$this->schoolId,$array_student);
Yii::app()->redis_business_student->expire('redis_business_del_student:'.$this->schoolId,1296000);
}
unset($b_student_data);
unset($criteria);
}
$studentNames = array();
$criteria = new CDbCriteria();
$criteria->addInCondition('student_id',$_student_id);
$studentArray = SStudentInfo::model()->findAll($criteria);
unset($criteria);
if (!empty($studentArray)) {
foreach ($studentArray as $student) {
$studentNames[$student->student_id] = $student->realname;
}
}
unset($studentArray);
//查询是否上传答题图片
$uploadAnswerImgStudent=array();
$student_answer_img=$this->schoolManager->getUpAnswerStudent($paperInfo->paper_id,$_student_id,false);
if($student_answer_img){
foreach ($student_answer_img as $val){
$uploadAnswerImgStudent[(string)$val['student_id']]=$val['student_id'];
}
}
//redis里查询模板是否生成
$redis_obj = new Redis();
$server = Yii::app()->params["redis"]["server"];
$redis_obj->connect($server["host"], $server["port"]);
if(isset($server["password"])){
$redis_obj->auth($server["password"]);
}
if (YII_ENV == 'pro' || YII_ENV == 'production') {
$redis_obj->select(0);
}else{
$redis_obj->select(10);
}
$redisKey = 'zsy:paper_template:'.$this->schoolId.':'.$eid;
$tempArr = array('0'=>'生成中','1'=>'已生成','2'=>'生成失败','3'=>'未生成');
$tempCheck = $printCheck = false;
foreach ($relateStudent as $key=>$val) {
$result[$key]['clazzName'] = $classInfo->class_name;
$result[$key]['paperName'] = $examInfo->name;
$result[$key]['studentCode'] = $val->student_id;
$result[$key]['student_card'] = $val->student_card;
$result[$key]['school_student_card'] = $val->school_student_card;
$result[$key]['studentCode'] = $val->student_id;
$result[$key]['studentName'] = isset($studentNames[$val->student_id]) ? $studentNames[$val->student_id] : null;
$result[$key]['is_feedback'] = $val->is_feedback;
$result[$key]['is_complete'] = $val->is_complete;
$result[$key]['student_img_paper'] = $val->student_img_paper;
$result[$key]['upload_answer_img'] =0;
if($val->is_feedback==1){
$isFeedback=1;
if(isset($uploadAnswerImgStudent[(string)$val->student_id])){
$result[$key]['upload_answer_img'] =1;
}
}
$stuId = (string)$val->student_id;
$template = $redis_obj->hMGet($redisKey,array($stuId));
$result[$key]['temp_str'] = '未生成';
$result[$key]['temp_status'] = 3;
if(isset($template[$stuId]) && $template[$stuId]){
$redisData = json_decode($template[$stuId],true);
if(isset($redisData['status']) && isset($tempArr[$redisData['status']])){
$result[$key]['temp_str'] = $tempArr[$redisData['status']];
$result[$key]['temp_status'] = $redisData['status'];
if($redisData['status'] == 1){
$printCheck = true;
}
if($redisData['status'] == 2){
$tempCheck = true;
}
}else{
$tempCheck = true;
}
}else{
$tempCheck = true;
}
//查询在线答题卡是否生成
$rs=$this->sConn->createCommand("select answer_card_online_created from student_answer_card_online where exam_id='{$eid}' and student_id='{$val->student_id}' ")->queryRow();
if($rs && $rs['answer_card_online_created']==1){
$result[$key]['online_created'] = 1;
}else{
$result[$key]['online_created'] = 0;
}
//查询学生身份证号
$studentInfo=SStudentInfo::model()->find('student_id=:s_id',array('s_id'=>$val->student_id));
if($studentInfo){
$result[$key]['id_number'] = $studentInfo->id_number;
}else{
$result[$key]['id_number'] = '';
}
}
$redis_obj->close();
unset($relateStudent);
//}
$no_paper_student = array();
$paper_student_array = array();
$c_paper_student_array = array();
$class_student_info_data = array();
$class_student_data = $this->schoolManager->getClassStudentByClassId($cid); //student_class_relation
$class_student_info_data = $this->schoolManager->getClassStudentInfoByClassId($cid); //student_info
$paper_student_data = $this->schoolManager->getClassPaperByClassAndPaper($cid,$paperInfo->paper_id,1);//已删除考试学生
$c_paper_student_data = $this->schoolManager->getClassPaperByClassAndPaper($cid,$paperInfo->paper_id);//考试学生
if ($paper_student_data) {
foreach ($paper_student_data as $v) {
$paper_student_array[$v['student_id']] = $v['student_id'];
}
//$class_student_info_data = $this->schoolManager->getStudentByStudentIds($paper_student_array); //student_info
}
if ($c_paper_student_data) {
foreach ($c_paper_student_data as $v) {
$c_paper_student_array[$v['student_id']] = $v['student_id'];
}
//$class_student_info_data = $this->schoolManager->getStudentByStudentIds($paper_student_array); //student_info
}
if ($class_student_info_data) {
foreach ($class_student_info_data as $v) {
$class_student_info_array[$v['student_id']] = $v['realname'];
}
}
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($class_student_info_array[$v['student_id']]) ?$class_student_info_array[$v['student_id']]:'',
);
}
}else
{
$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']]:'',
);
}
}
}
}
unset($b_student_arr);
$data = array();
$data['no_paper_student'] = $no_paper_student;
$data['result'] = $result;
$data["printType"] = $printType;
$data["sname"] = $sname;
$data['examInfo'] = $examInfo;
$data['paper_id'] = $paperInfo->paper_id;
$data['exam_id'] = $eid;
$data['class_id'] = $cid;
$data['exam_group_id'] = $examInfo->exam_group_id;
$data['type_id'] = $tid;
$data['tempCheck'] = $tempCheck;
$data['printCheck'] = $printCheck;
if(isset($this->schoolInfo->use_zhixue) && !empty($this->schoolInfo->use_zhixue))
{
$data["use_zhixue"] = $this->schoolInfo->use_zhixue;
}else
{
$data["use_zhixue"] = 0;
}
//$subject_exam_data = $this->schoolManager->getxuekeStatus($this->semesterId);
//$data["subject"] = $subject_exam_data;
$data['wp_type'] = $examInfo->tpl_index;
$data['className'] = $classInfo->class_name;
$data['paperName'] = $examInfo->name;
$data['tpl'] = $tpl;
$data['tplTwo'] = $tplTwo;
$data['markType'] = $markType;
$data['paperType'] = $paperType;
$data['answerCardUploaded'] = $answerCardUploaded;
$data['paperData'] = $paperData;
$data['isCustomTpl'] = $isCustomTpl;
$data['isFeedback'] = $isFeedback;
$data['useAnswerCardOnlineQrcode']=$useAnswerCardOnlineQrcode;
$data['qxkPaperId'] = $examGroupInfo->qxk_paper_id;
$_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;
$data['version_number']=$version_number;
$this->render('change2',$data);
}
// 选择需打印纠错本的同学
public function actionChangewrongtopic(){
$sname = Req::get("sname");
$cid = Req::get("cid");
$eid = Req::get("eid");
$printType = (string)Req::get("printType");
$classInfo = ClassModel::model()->findByPk($cid);
if (empty($classInfo)) {
Yii::app()->jump->error('未找到班级!');
}
$semesterId = $classInfo->semester_id;//当前学期id
$grade = $classInfo->grade;
$examInfo = Exam::model()->findByPk($eid);
if (empty($examInfo)) {
Yii::app()->jump->error('未找到周周练!');
}
$getResult = ClassExamPrinter::model()->find('class_id=:cid and exam_id=:eid and type=1',array(':cid'=>$cid,':eid'=>$eid));
if (empty($getResult)) {
Yii::app()->jump->error('未找到班级与试卷对应关系!');
}
$paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
if (empty($paperInfo)) {
Yii::app()->jump->error('未找到试卷信息!');
}
$paperIsLabelled = isset($paperInfo->is_labelled) ? (($paperInfo->is_labelled == 1) ? true : false) : false;
$printTaskName = "{$classInfo->class_name}{$examInfo->name}\"错题本\"";
$relateStudent = SStudentPaperRelation::model()->findAll('paper_id=:paid and class_id=:caid',array(':paid'=>$paperInfo->paper_id,':caid'=>$cid));
//$relateStudent = SStudentPaperRelation::model()->findAll('paper_id=:paid and class_id=:caid and is_wrongbook_pdf=1',array(':paid'=>$paperInfo->paper_id,':caid'=>$cid));
if (empty($relateStudent)) {
Yii::app()->jump->error('未找到学生和试卷的对应关系!');
} else {
$studentIds = array();
foreach ($relateStudent as $studentInfo) {
$studentIds[] = (string)$studentInfo['student_id'];
}
$studentNames = SStudentInfo::model()->getStudentNames($studentIds); //求学生名字
$result = array();
$no = 1;
foreach ($relateStudent as $v) {
$studentId = (string)$v['student_id'];
$_studentName = isset($studentNames[$studentId])?$studentNames[$studentId]:'';
$is_html = $v['is_wrongbook_html'];
$is_pdf = $v['is_wrongbook_pdf'];
$status = $this->getStatusDesc($is_html, $is_pdf); //错题本状态
$className = $classInfo->class_name;
$scoring = $v['scoring'];
if ($sname ) { //如果写了学生名字,那么返回时只返回该学生的
if (strpos($_studentName, $sname) !== false) { //是搜索的学生
$result[$studentId] = array();
$result[$studentId]['no'] = $no; //序号
$result[$studentId]['studentId'] = $studentId; //学生id
$result[$studentId]['studentName'] = $_studentName; //学生名称
$result[$studentId]['studentCode'] = $studentId; //学生id,即编号
$result[$studentId]['clazzName'] = $className; //班级名称
$result[$studentId]['wrongStatus'] = $status; //错题本状态
$result[$studentId]['scoring'] = $scoring; //得分
$result[$studentId]['complete_time'] = $v['complete_time']; //完成阅卷时间
$result[$studentId]['isAbsent'] = $v['is_del']; //是否缺考
$no += 1;
} else{
continue;
}
} else {
$result[$studentId] = array();
$result[$studentId]['no'] = $no; //序号
$result[$studentId]['studentId'] = $studentId; //学生id
$result[$studentId]['studentName'] = $_studentName; //学生名称
$result[$studentId]['studentCode'] = $studentId; //学生id,即编号
$result[$studentId]['clazzName'] = $className; //班级名称
$result[$studentId]['wrongStatus'] = $status; //错题本状态
$result[$studentId]['scoring'] = $scoring; //得分
$result[$studentId]['complete_time'] = $v['complete_time']; //完成阅卷时间
$result[$studentId]['isAbsent'] = $v['is_del']; //是否缺考
$no += 1;
}
}
}
$data = array();
$data['exam_id'] = $eid;
$data['examName'] = $examInfo["name"];
$data['class_id'] = $cid;
$data['className'] = $classInfo->class_name;
$data['sname'] = $sname;
$data['paper_id'] = $paperInfo->paper_id;
$data['printTaskName'] = $printTaskName;
$data['paperIsLabelled'] = $paperIsLabelled;
$data['result'] = $result;
$data['printType'] = $printType;
$data['stuIspErroMsg'] = $this->stuIspErrorMsg(1,$eid,$studentIds);
$order_res = $this->getOrderStu($eid, $cid, 1, $relateStudent,$semesterId, $grade);
if (!$order_res) {
Yii::app()->jump->error("接口错误");
}
$data = array_merge($data, $order_res);
$this->render('changewrongtopic',$data);
}
/**
* 学生错题本个性化学习宝未生成错题信息
* @param $productType
* @param $examId
* @param array $studentIds
*/
protected function stuIspErrorMsg($productType,$examId,$studentIds = array())
{
$result = array();
if (!in_array($this->subjectId, $this->mathSubjectId)) {
return $result;
}
if (!$studentIds) {
return $result;
}
//转字符串
foreach ($studentIds as $k => $_stuId) {
$studentIds[$k] = '"'.$_stuId.'"';
}
//需要显示学生个性化学习宝错误码
$showErrorCode = Yii::app()->params['show_isp_error_code'];
//个性化学习宝错误代码信息
$errorCodeMsg = Yii::app()->params['isp_error_code_msg'];
$rs = SStudentIspErrorCode::model()->getStudentIspErrorCode($examId, $productType);
if ($rs) {
foreach ($rs as $value) {
if(!in_array($value['error_code'],$showErrorCode)) continue;
if (!isset($result[$value['student_id']])) {
$result[$value['student_id']] = array();
}
$result[$value['student_id']][$value['error_code']] = isset($errorCodeMsg[$value['error_code']])?$errorCodeMsg[$value['error_code']]:'错误码无信息';
}
}
unset($rs);
return $result;
}
// 处理选择后同学纠错本打印(于20160908使用API接口的方法替换此方案,暂时废弃)
public function actionChangewrongtopicdo(){
$cid = Req::get("cid");
$eid = Req::get("eid");
$stids = Req::get("stids");
if (empty($stids) || empty($cid) || empty($eid)) {
Yii::app()->jump->error('打印纠错本参数有误!');
}
$classInfo = ClassModel::model()->findByPk($cid);
if (empty($classInfo)) {
Yii::app()->jump->error('未找到班级!');
}
$examInfo = Exam::model()->findByPk($eid);
if (empty($examInfo)) {
Yii::app()->jump->error('未找到周周练!');
}
$paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
if (empty($paperInfo)) {
Yii::app()->jump->error('未找到试卷信息!');
}
$filePath = array();
$getPaths = $this->schoolManager->getStudentsPdfsPaths($paperInfo->paper_id,explode(',',$stids));
if (empty($getPaths)) {
Yii::app()->jump->error('正在努力生成纠错本!');
} else {
// 下载文件名称
$fileName = $classInfo->class_name.$examInfo->name.'纠错本.zip';
// 下载文件路径
$result = array();
//$pdfPath = dirname(dirname(dirname(dirname(__FILE__)))).'/api/uploads/';
$pdfPath = Yii::app()->params['student_wrong_isp_path'];
foreach ($getPaths as $path) {
/* if(file_exists(iconv("utf-8", "gbk", $pdfPath.$path->wrongbook_pdf_path))){
$result[] = $path->wrongbook_pdf_path;
} */
if(strpos($path->wrongbook_pdf_path, "data")!==false){
$paths=$pdfPath.$path->wrongbook_pdf_path;
}else{
$paths=$pdfPath."uploads/".$path->wrongbook_pdf_path;
}
if(file_exists($paths)){//aaaaaaaaa
$result[] = $paths;
}
}
if (empty($result)) {
Yii::app()->jump->error('正在生成学生纠错本!');
}
// 下载
self::downloadStudentFile($fileName,$result);
}
}
// 选择需打印个性化学习宝的同学
public function actionChangeraisescheme(){
$sname = Req::get("sname"); //学生名字
$cid = Req::get("cid"); //班级id
$eid = Req::get("eid"); //考试id
$type = Req::get("type"); //2步 还是 3步
$subjectId = Req::get("subid"); //学科ID
$planName = "";
if($type == "isp"){
$postTypeVal=2;
if($subjectId == 8){
$postTypeVal=3;
$planName = "个性化学习宝";
}else{
$planName = "个性化学习方案";
}
$typeVal = 2;
}else if($type == "third_isp"){
$planName = "个性化学习宝";
$typeVal = 3;
if($subjectId == 8){
$postTypeVal = 3;
}else{
$postTypeVal = 2;
}
}else if($type == "studytrend"){
$planName = "个性化学习宝";
$typeVal = 3;
$postTypeVal=3;
}else{
Yii::app()->jump->error('参数错误!');
}
$classInfo = ClassModel::model()->findByPk($cid);
if (empty($classInfo)) {
Yii::app()->jump->error('未找到班级!');
}
$semesterId = $classInfo->semester_id;//当前学期id
$grade = $classInfo->grade;
$examInfo = Exam::model()->findByPk($eid);
if (empty($examInfo)) {
Yii::app()->jump->error('未找到周周练!');
}
$getResult = ClassExamPrinter::model()->find('class_id=:cid and exam_id=:eid and type='.$typeVal,array(':cid'=>$cid,':eid'=>$eid));
if (empty($getResult)) {
Yii::app()->jump->error('未找到班级与试卷对应关系!');
}
$paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
if (empty($paperInfo)) {
Yii::app()->jump->error('未找到试卷信息!');
}
$paperIsLabelled = isset($paperInfo->is_labelled) ? (($paperInfo->is_labelled == 1) ? true : false) : false;
$printTaskName = "{$classInfo->class_name}{$examInfo->name}\"{$planName}\"";
/*$studentIds = array();
$planNames = array();
$result = array();
$ispStatus = array();
$studentIdsTwo = array();*/
//$relateStudent = SStudentPaperRelation::model()->findAll('paper_id=:paid and class_id=:caid and is_isp_pdf=1',array(':paid'=>$paperInfo->paper_id,':caid'=>$cid));
$relateStudent = SStudentPaperRelation::model()->findAll('paper_id=:paid and class_id=:caid ',array(':paid'=>$paperInfo->paper_id,':caid'=>$cid));//所有记录
if (!$relateStudent) {
Yii::app()->jump->error('未找到学生和试卷的对应关系!');
}
$studentIds = array();
foreach ($relateStudent as $studentInfo) {
$studentIds[] = (string)$studentInfo['student_id'];
}
$studentNames = SStudentInfo::model()->getStudentNames($studentIds); //求学生名字
$result = array();
$no = 1;
foreach ($relateStudent as $v) {
$studentId = (string)$v['student_id'];
$_studentName = isset($studentNames[$studentId])?$studentNames[$studentId]:'';
if ($type == 'isp') {
$is_html = $v['is_isp_html'];
$is_pdf = $v['is_isp_pdf'];
}elseif ($type == 'studytrend') {
$is_html = $v['is_wbisp_html'];
$is_pdf = $v['is_wbisp_pdf'];
}elseif ($type == 'third_isp') {
$is_html = $v['is_wbisp_html'];
$is_pdf = $v['is_wbisp_pdf'];
}
$status = $this->getStatusDesc($is_html, $is_pdf); //个性化学习宝状态
$className = $classInfo->class_name;
$_planName = $className.$_studentName.$examInfo->name.$planName;
if ($sname ) { //如果写了学生名字,那么返回时只返回该学生的
if (strpos($_studentName, $sname) !== false) { //是搜索的学生
$result[$studentId] = array();
$result[$studentId]['no'] = $no; //序号
$result[$studentId]['studentId'] = $studentId; //学生id
$result[$studentId]['studentName'] = $_studentName; //学生名称
$result[$studentId]['studentCode'] = $studentId; //学生id,即编号
$result[$studentId]['clazzName'] = $className; //班级名称
$result[$studentId]['ispStatus'] = $status; //个性化学习宝状态
$result[$studentId]['planName'] = $_planName;
$result[$studentId]['complete_time'] = $v['complete_time']; //完成阅卷时间
$result[$studentId]['isAbsent'] = $v['is_del']; //是否缺考
$no += 1;
} else{
continue;
}
} else {
$result[$studentId] = array();
$result[$studentId]['no'] = $no; //序号
$result[$studentId]['studentId'] = $studentId; //学生id
$result[$studentId]['studentName'] = $_studentName; //学生名称
$result[$studentId]['studentCode'] = $studentId; //学生id,即编号
$result[$studentId]['clazzName'] = $className; //班级名称
$result[$studentId]['ispStatus'] = $status; //个性化学习宝状态
$result[$studentId]['planName'] = $_planName;
$result[$studentId]['complete_time'] = $v['complete_time']; //完成阅卷时间
$result[$studentId]['isAbsent'] = $v['is_del']; //是否缺考
$no += 1;
}
}
$data = array();
$data['exam_id'] = $eid;
$data['class_id'] = $cid;
$data['className'] = $grade;
$data['sname'] = $sname;
$data['paper_id'] = $paperInfo->paper_id;
$data['result'] = $result;
$data['type'] = $type;
$data['paperIsLabelled'] = $paperIsLabelled;
$data['printTaskName'] = $printTaskName;
$data['printType'] = $type;
$data['subjectId']=$subjectId;
$data['stuIspErroMsg'] = $this->stuIspErrorMsg($type == 'isp'?2:3,$eid,$studentIds);
$order_res = $this->getOrderStu($eid, $cid, $postTypeVal, $relateStudent,$semesterId, $grade);
// debug($order_res);
if (!$order_res) {
Yii::app()->jump->error("接口错误");
}
$data = array_merge($data, $order_res);
// debug($data);
$this->render('changeraisescheme',$data);
/*// 获取当前试卷提分计划
$improveScore = StudentImproveScorePlan::model()->findAll('paper_id=:paid and is_created=1',array(':paid'=>$paperInfo->paper_id));
if (empty($relateStudent)) {
Yii::app()->jump->error('学生的个性化学习宝还未生成,请等待!');
} else {
if($type == "isp"){
foreach ($relateStudent as $paperStudent) {
$rs = $this->sConn->createCommand("select exists(select * from student_class_relation where student_id = '{$paperStudent->student_id}')")->queryRow();
$rs = current($rs);
if($rs == 0)
continue;
$studentIds[] = $paperStudent->student_id;
$ispStatus[$paperStudent->student_id] = $paperStudent->is_isp_pdf;
}
// 获取当前班级需打印周周练的同学
foreach ($improveScore as $improve) {
if (in_array($improve->student_id, $studentIds)) {
$studentIdsTwo[] = $improve->student_id;
}
}
}
else if($type == "studytrend"){
foreach ($relateStudent as $paperStudent) {
$rs = $this->sConn->createCommand("select exists(select * from student_class_relation where student_id = '{$paperStudent->student_id}' )")->queryRow();
$rs = current($rs);
if($rs == 0)
continue;
$studentIds[] = $paperStudent->student_id;
$ispStatus[$paperStudent->student_id] = $paperStudent->is_wbisp_pdf;
}
// 获取当前班级需打印周周练的同学
foreach ($improveScore as $improve) {
if (in_array($improve->student_id, $studentIds)) {
$studentIdsTwo[] = $improve->student_id;
}
}
}
}
if (empty($studentIdsTwo)) {
Yii::app()->jump->error('当前班级还未生成个性化学习宝');
} else {
// 获取有错题的学生姓名
$studentNames = SStudentInfo::model()->getStudentNames($studentIdsTwo);
foreach ($studentIdsTwo as $key=>$val) { //val是学生id
if (empty($sname)) {
$result[$key]['studentName'] = $studentNames[$val];
$result[$key]['studentCode'] = $val;
$result[$key]['clazzName'] = $classInfo->class_name;
$result[$key]['ispStatus'] = $ispStatus[$val];
$result[$key]['planName'] = $classInfo->class_name.$studentNames[$val].$examInfo->name.$planName;
} else {
if (false !== strpos($studentNames[$val],$sname) ) {
$result[$key]['studentName'] = $studentNames[$val];
$result[$key]['studentCode'] = $val;
$result[$key]['clazzName'] = $classInfo->class_name;
$result[$key]['ispStatus'] = $ispStatus[$val];
$result[$key]['planName'] = $classInfo->class_name.$studentNames[$val].$examInfo->name.$planName;
}
unset($studentIdsTwo[$key]);
}
}
}*/
}
function getStatusDesc($is_html, $is_pdf)
{
if ($is_html == 0 || $is_html == 90) {
$status = 0; // 未生成
} elseif ($is_html == 1 && $is_pdf == 0) {
$status = 1; //正在生成中
} elseif ($is_pdf == 1) {
$status = 2; //已生成
} elseif ($is_html == 9 && $is_pdf == 9) {
$status = 3; //已过期
} else {
$status = 4; //未知状态
}
return $status;
}
function getOrderStu($eid, $cid, $typeVal,$relateStudentRes,$semesterId, $grade)
{
$data = array();
$Sem=new SSemester();
$code= $Sem->conn->createQuery()
->from('semester')
->where("semester_id = '".$this->semesterId."'")
->limit(1)
->query()
->read();
$print_time=ClassExamPrinter::model()->findAll('exam_id=:exam_id and class_id=:classid and type=0',array(':exam_id'=>$eid,':classid'=>$cid));
$intarr=array(
"schoolId"=>$this->schoolId,
"clazzId"=>$cid,
"semester"=>$code['refer_code'],
"grade"=>$grade,
"examTime"=>$print_time[0]->add_time,
"students"=>array(),
"classify"=>$typeVal,
);
$examInfo = Exam::model()->findByPk($eid);
$intarr['subject']=$examInfo['subject_id'];
if(in_array($intarr['subject'],$this->mathSubjectId)){
$intarr['subject']=3;
}
foreach($relateStudentRes as $key => $val){
$intarr['students'][] = $val['student_id'];
}
$basic = imsBasicAuth($this->schoolId.'_'.Yii::app()->session['coachInfo']['coach_name'],Yii::app()->params["zsy_api_key"]);
$rs = json_decode(Curl::http_post_Basic_json(Yii::app()->params["get_limit_url"], json_encode($intarr),$basic));
if(!$rs){
//Yii::app()->jump->error("接口错误");
return false;
}
if($rs->errCode!="00"){
//Yii::app()->jump->error($rs->errMsg);
//exit();
return false;
}
if(!empty($rs->data)){
foreach($rs->data as $v){
$data['limitstu'][$v]=$v;
}
}else{
$data['limitstu']=-1;
}
return $data;
}
// 选择打印个性化学习宝同学处理(于20160908使用API接口的方法替换此方案,暂时废弃)
public function actionChangeraiseschemedo(){
$cid = Req::get("cid");
$eid = Req::get("eid");
$stids = Req::get("stids");
$type = Req::get("type");
if (empty($stids) || empty($cid) || empty($eid) || empty($type)) {
Yii::app()->jump->error('打印个性化学习宝参数有误!');
}
$classInfo = ClassModel::model()->findByPk($cid);
if (empty($classInfo)) {
Yii::app()->jump->error('未找到班级!');
}
$examInfo = Exam::model()->findByPk($eid);
if (empty($examInfo)) {
Yii::app()->jump->error('未找到周周练!');
}
$paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
if (empty($paperInfo)) {
Yii::app()->jump->error('未找到试卷信息!');
}
$filePath = array();
$getPaths = $this->schoolManager->getStudentsPdfsPaths($paperInfo->paper_id,explode(',',$stids));
if (empty($getPaths)) {
Yii::app()->jump->error('正在努力生成个性化学习宝!');
} else {
$fName = "";
if($type == "isp")
$fName = "个性化学习方案";
else if($type == "studytrend")
$fName = "个性化学习宝";
// 下载文件名称
$fileName = $classInfo->class_name.$examInfo->name.$fName.'.zip';
// 下载文件路径
$result = array();
//$pdfPath = dirname(dirname(dirname(dirname(__FILE__)))).'/api/uploads/';
$pdfPath = Yii::app()->params['student_wrong_isp_path'];
foreach ($getPaths as $path) {
/* if(file_exists(iconv("utf-8", "gbk//IGNORE", $pdfPath.$path->isp_pdf_path))){
$result[] = $path->isp_pdf_path;
} */
if($type == "isp"){
if(strpos($path->isp_pdf_path,'data')!==false){
$paths=$pdfPath.$path->isp_pdf_path;
}else{
$paths=$pdfPath."uploads/".$path->isp_pdf_path;
}
$result[] = $paths;
}
else if($type == "studytrend" ){
if(strpos($path->isp_pdf_path,'data')!==false){
$paths=$pdfPath.$path->wbisp_pdf_path;
}else{
$paths=$pdfPath."uploads/".$path->wbisp_pdf_path;
}
$result[] = $paths;
}
}
if (empty($result)) {
Yii::app()->jump->error('正在生成学生个性化学习宝!');
}
// 下载
self::downloadStudentFile($fileName,$result);
}
}
// 打印试卷
private function printPaper($cid,$eid){
$error = array();
$error['success'] = 0;
$classInfo = ClassModel::model()->findByPk($cid);
if (empty($classInfo)) {
$error['message'] = '未找到班级!';
echo json_encode($error);exit();
}
$examInfo = Exam::model()->findByPk($eid);
if (empty($examInfo)) {
$error['message'] = '未找到周周练!';
echo json_encode($error);exit();
}
$getResult = ClassExamPrinter::model()->find('class_id=:cid and exam_id=:eid and type=0',array(':cid'=>$cid,':eid'=>$eid));
if (empty($getResult)) {
$error['message'] = '未找到班级与试卷对应关系!';
echo json_encode($error);exit();
}
$paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
if (empty($paperInfo)) {
$error['message'] = '未找到试卷信息!';
echo json_encode($error);exit();
}
if (!in_array($examInfo->tpl_index,Yii::app()->params['no_template_id']) && !in_array($examInfo->tpl_index, Yii::app()->params['custom_tpls_ids'])) {
if (empty($paperInfo->tpl_doc_src)) {
$error['message'] = '未上传模板,请先上传模板!';
echo json_encode($error);exit();
}
}
// 获取阅卷类型
$markType = 0;
$groupInfo = $this->schoolManager->getExam($eid);
if (!empty($groupInfo)) {
$findInfo = SExamGroup::model()->find('exam_group_id=:eg_id',array('eg_id'=>$groupInfo['exam_group_id']));
if (!empty($findInfo)) {
$markType = $findInfo->mark_type;
}
}
$relateTopic = SPaperTopicRelation::model()->count('paper_id=:paid',array(':paid'=>$paperInfo->paper_id));
if (empty($relateTopic)) {
$error['message'] = '未找该试卷试题信息!';
echo json_encode($error);exit();
}
$result = array();
$relateStudent = SStudentPaperRelation::model()->findAll('paper_id=:paid and class_id=:caid and is_del=:is_del',array(':paid'=>$paperInfo->paper_id,':caid'=>$cid,'is_del'=>0));
if (empty($relateStudent)) {
$error['message'] = '未找该试卷关联的学生!';
echo json_encode($error);exit();
} else {
// 组装json数据发到客户端
$studentModel = StudentInfo::model();
$paperData = $this->schoolManager->getPaperWithTopicsDetails($paperInfo->paper_id, "ARR");
foreach ($relateStudent as $key=>$val) {
$result[$key]['clazzName'] = $classInfo->class_name;
$result[$key]['paperId'] = $paperInfo->paper_id;
$result[$key]['paperName'] = $examInfo->name;
$result[$key]['schoolId'] = Yii::app()->session['school_id'];
$result[$key]['studentCode'] = $val->student_id;
$result[$key]['studentName'] = $studentModel->findByPk($val->student_id)->realname;
$result[$key]['wpCode'] = $eid;
$result[$key]['wpType'] = $examInfo->tpl_index;
$result[$key]['markType'] = $markType;
if(isset($paperData["object"]["topicsCount"])){
$result[$key]['selectQTNub'] = $paperData["object"]["topicsCount"]["singleChoice"];
$result[$key]['completionNub'] = $paperData["object"]["topicsCount"]["blankFilling"];
$result[$key]['questionSNub'] = $paperData["object"]["topicsCount"]["shortAnswer"];
}
else{
$result[$key]['selectQTNub'] = 0;
$result[$key]['completionNub'] = 0;
$result[$key]['questionSNub'] = 0;
}
}
}
if (empty($result)) {
$error['message'] = '没有打印信息!';
echo json_encode($error);exit();
} else {
// 更新试卷打印状态、时间
$getResult->is_print = 1;
$getResult->print_time = time();
$getResult->save();
$error['success'] = 1;
$error['message'] = $result;
echo json_encode($error);exit();
}
}
private function printPaper_v2($cid,$eid){
$error = array();
$error['success'] = 0;
$classInfo = ClassModel::model()->findByPk($cid);
if (empty($classInfo)) {
$error['message'] = '未找到班级!';
echo json_encode($error);exit();
}
$examInfo = Exam::model()->findByPk($eid);
if (empty($examInfo)) {
$error['message'] = '未找到周周练!';
echo json_encode($error);exit();
}
$getResult = ClassExamPrinter::model()->find('class_id=:cid and exam_id=:eid and type=0',array(':cid'=>$cid,':eid'=>$eid));
if (empty($getResult)) {
$error['message'] = '未找到班级与试卷对应关系!';
echo json_encode($error);exit();
}
$paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
if (empty($paperInfo)) {
$error['message'] = '未找到试卷信息!';
echo json_encode($error);exit();
}
if (!in_array($examInfo->tpl_index,Yii::app()->params['no_template_id']) && !in_array($examInfo->tpl_index, Yii::app()->params['custom_tpls_ids'])) {
if (empty($paperInfo->tpl_doc_src)) {
$error['message'] = '未上传模板,请先上传模板!';
echo json_encode($error);exit();
}
}
// 获取阅卷类型
$markType = 0;
$groupInfo = $this->schoolManager->getExam($eid);
if (!empty($groupInfo)) {
$findInfo = SExamGroup::model()->find('exam_group_id=:eg_id',array('eg_id'=>$groupInfo['exam_group_id']));
if (!empty($findInfo)) {
$markType = $findInfo->mark_type;
}
}
$relateTopic = SPaperTopicRelation::model()->count('paper_id=:paid',array(':paid'=>$paperInfo->paper_id));
if (empty($relateTopic)) {
$error['message'] = '未找该试卷试题信息!';
echo json_encode($error);exit();
}
$result = array();
$relateStudent = SStudentPaperRelation::model()->findAll('paper_id=:paid and class_id=:caid and is_del=:is_del',array(':paid'=>$paperInfo->paper_id,':caid'=>$cid,'is_del'=>0));
if (empty($relateStudent)) {
$error['message'] = '未找该试卷关联的学生!';
echo json_encode($error);exit();
} else {
// 组装json数据发到客户端
$studentModel = StudentInfo::model();
$paperData = $this->schoolManager->getPaperWithTopicsDetails_v2($paperInfo->paper_id, "ARR");
foreach ($relateStudent as $key=>$val) {
$studentInfo=$studentModel->findByPk($val->student_id);
$result[$key]['clazzName'] = $classInfo->class_name;
$result[$key]['paperId'] = $examInfo->exam_group_id;
$result[$key]['paperName'] = $examInfo->name;
$result[$key]['schoolId'] = Yii::app()->session['school_id'];
$result[$key]['studentCode'] = $val->student_id;
$result[$key]['studentName'] = $studentInfo->realname;
$result[$key]['wpCode'] = $eid;
$result[$key]['wpType'] = $examInfo->tpl_index;
$result[$key]['markType'] = $markType;
$result[$key]['idNumber'] = $studentInfo->id_number;
if(isset($paperData["object"]["topicsCount"])){
$result[$key]['selectQTNub'] = $paperData["object"]["topicsCount"]["singleChoice"];
$result[$key]['completionNub'] = $paperData["object"]["topicsCount"]["blankFilling"];
$result[$key]['questionSNub'] = $paperData["object"]["topicsCount"]["shortAnswer"];
}
else{
$result[$key]['selectQTNub'] = 0;
$result[$key]['completionNub'] = 0;
$result[$key]['questionSNub'] = 0;
}
}
}
if (empty($result)) {
$error['message'] = '没有打印信息!';
echo json_encode($error);exit();
} else {
// 更新试卷打印状态、时间
$getResult->is_print = 1;
$getResult->print_time = time();
$getResult->save();
$error['success'] = 1;
$error['message'] = $result;
echo json_encode($error);exit();
}
}
// 下载全班学生纠错本
public function actionDownloadwrongtopic() {
$cid = Req::get("cid");
$eid = Req::get("eid");
$classInfo = ClassModel::model()->findByPk($cid);
if (empty($classInfo)) {
Yii::app()->jump->error('未找到班级!');
}
$examInfo = Exam::model()->findByPk($eid);
if (empty($examInfo)) {
Yii::app()->jump->error('未找到周周练!');
}
$getResult = ClassExamPrinter::model()->find('class_id=:cid and exam_id=:eid and type=1',array(':cid'=>$cid,':eid'=>$eid));
if (empty($getResult)) {
Yii::app()->jump->error('未找到班级与纠错本对应关系!');
}
$paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
if (empty($paperInfo)) {
Yii::app()->jump->error('未找到试卷信息!');
}
$result = array();
$relateStudent = SStudentPaperRelation::model()->findAll('paper_id=:paid and class_id=:caid and is_wrongbook_pdf=1 and is_del=:is_del',array(':is_del'=>0,':paid'=>$paperInfo->paper_id,':caid'=>$cid));
if (empty($relateStudent)) {
Yii::app()->jump->error('正在努力生成纠错本!');
} else {
$studentIdArray = array();
// 获取当前考试所有学生ID
foreach ($relateStudent as $key=>$val) {
$studentIdArray[] = $val->student_id;
}
}
$filePath = array();
$getPaths = $this->schoolManager->getStudentsPdfsPaths($paperInfo->paper_id,$studentIdArray);
if (empty($getPaths)) {
Yii::app()->jump->error('正在生成纠错本!');
} else {
// 下载文件名称
$fileName = $classInfo->class_name.$examInfo->name.'错题本.zip';
// 下载文件路径
$result = array();
//$pdfPath = dirname(dirname(dirname(dirname(__FILE__)))).'/api/uploads/';
$pdfPath = Yii::app()->params['student_wrong_isp_path'];
foreach ($getPaths as $path) {
/* if(file_exists(iconv("utf-8", "gbk//IGNORE", $pdfPath.$path->wrongbook_pdf_path))){
$result[] = $path->wrongbook_pdf_path;
} */
if(strpos($path->wrongbook_pdf_path,"data")!==false){
$pathstr=$pdfPath.$path->wrongbook_pdf_path;
}else{
$pathstr=$pdfPath."uploads/".$path->wrongbook_pdf_path;
}
if(file_exists($pathstr)){
$result[] = $pathstr;
}
}
if (empty($result)) {
Yii::app()->jump->error('正在生成学生纠错本!');
}
// 下载
self::downloadStudentFile($fileName,$result);
}
}
// 下载全班学生个性化学习宝
public function actionDownloadraisescheme($cid,$eid,$type){
if(!in_array($type, array(2, 3)))
Yii::app()->jump->error('缺少参数!');
$classInfo = ClassModel::model()->findByPk($cid);
if (empty($classInfo)) {
Yii::app()->jump->error('未找到班级!');
}
$examInfo = Exam::model()->findByPk($eid);
if (empty($examInfo)) {
Yii::app()->jump->error('未找到周周练!');
}
$getResult = ClassExamPrinter::model()->find('class_id=:cid and exam_id=:eid and type=1',array(':cid'=>$cid,':eid'=>$eid));
if (empty($getResult)) {
Yii::app()->jump->error('未找到班级与纠错本对应关系!');
}
$paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
if (empty($paperInfo)) {
Yii::app()->jump->error('未找到试卷信息!');
}
if($type == 2){
$field = "is_isp_pdf";
$check = "ISP";
}
else{
$field = "is_wbisp_pdf";
$check = "WB_ISP";
}
$relateStudent = SStudentPaperRelation::model()->findAll("paper_id=:paid and class_id=:caid and {$field}=1 and is_del=0",array(':paid'=>$paperInfo->paper_id,':caid'=>$cid));
if (empty($relateStudent)) {
Yii::app()->jump->error('正在努力生成个性化学习宝!');
} else {
$studentIdArray = array();
// 获取当前考试所有学生ID
foreach ($relateStudent as $key=>$val) {
$studentIdArray[] = $val->student_id;
}
}
$filePath = array();
$getPaths = $this->schoolManager->getStudentsPdfsPaths($paperInfo->paper_id,$studentIdArray, $check);
if (empty($getPaths)) {
Yii::app()->jump->error('正在努力生成个性化学习宝!');
} else {
$fName = $type == 2 ? "个性化学习方案" : "个性化学习宝";
// 下载文件名称
$fileName = $classInfo->class_name.$examInfo->name."{$fName}.zip";
// 下载文件路径
$result = array();
//$pdfPath = dirname(dirname(dirname(dirname(__FILE__)))).'/api/uploads/';
$pdfPath = Yii::app()->params['student_wrong_isp_path'];
foreach ($getPaths as $path) {
/* if(file_exists(iconv("utf-8", "gbk//IGNORE", $pdfPath.$path->isp_pdf_path))){
$result[] = $path->isp_pdf_path;
} */
if($type == 2){
if(strpos($path->wrongbook_pdf_path,"data")!==false){
$pathstr=$pdfPath.$path->isp_pdf_path;
}else{
$pathstr=$pdfPath."uploads/".$path->isp_pdf_path;
}
if(is_file($pathstr)){
$result[] = $pathstr;
}
}
else if($type == 3){
if(strpos($path->wrongbook_pdf_path,"data")!==false){
$pathstr=$pdfPath.$path->wbisp_pdf_path;
}else{
$pathstr=$pdfPath."uploads/".$path->wbisp_pdf_path;
}
if(is_file($pathstr)){
$result[] = $pathstr;
}
}
}
if (empty($result)) {
Yii::app()->jump->error('正在生成学生个性化学习宝!');
}
// 下载
self::downloadStudentFile($fileName,$result);
}
}
// 下载学生纠错本、个性化学习宝PDF
function downloadStudentFile($fileName,$result) {
if (empty($fileName) || empty($result)) {
return false;
}
$downName = mb_convert_encoding($fileName, 'gbk', 'utf-8');
$filename = dirname(dirname(dirname(__FILE__))).'/upload/'. uniqid().".zip"; //最终生成的文件名(含路径)
$zip = new ZipArchive();//使用本类,linux需开启zlib,windows需取消php_zip.dll前的注释
if ($zip->open($filename, ZIPARCHIVE::OVERWRITE)!==TRUE) {
Yii::app()->jump->error('无法打开文件,或者文件创建失败');
}
//$pdfPath = dirname(dirname(dirname(dirname(__FILE__)))).'/api/uploads/';
// $pdfPath = Yii::app()->params['student_wrong_isp_path'];
foreach ($result as $val) {
$res=$zip->addFile($val,mb_convert_encoding(preg_replace('/^.+[\\\\\\/]/', '', $val), 'GBK', 'UTF-8'));
}
$zip->close();//关闭
if (is_file($filename)){
if (FALSE!== ($handler = fopen($filename, 'r')))
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$downName);
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);
unlink($filename);
}
exit;
}
}
// 获取周周练试卷详情(生成模板使用、打印答案解析使用)
public function actionCreatetempelate(){
$wpcode = Req::post("eid");
$flag = Req::post("flag");
$error['success'] = 0;
if (empty($wpcode)) {
$error['message'] = '么有周周练id!';
echo json_encode($error);exit();
}
$_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;
$getRes = apiPost(Yii::app()->params['get_api_url'].'/coachio/iointerface_v2/getWpPapers', 'wpCode='.$wpcode);
$exam_data = Exam::model()->find('exam_id=:exam_id',array(':exam_id'=>$wpcode));
//获取本次考试的examids
$exam_ids = array();
if($exam_data)
{
$exam_group_data = Exam::model()->findAll('exam_group_id=:exam_group_id',array(':exam_group_id'=>$exam_data->exam_group_id));
$index_tpl = 0;
if($exam_group_data)
{
foreach($exam_group_data as $v)
{
$exam_ids[$v->exam_id] = $v->exam_id;
$index_tpl = $v->tpl_index;
}
}
if(in_array($index_tpl,Yii::app()->params['print_topic_tpl']))
{
$flag = 0;
}
if($flag==3 || $flag==4 || $flag == 12)
{
$criteria = new CDbCriteria();
$criteria->addInCondition('exam_id',$exam_ids);
$criteria->addCondition('type=:type');
$criteria->params[':type'] = 0;
$getResult = ClassExamPrinter::model()->findAll($criteria);
if (!empty($getResult)) {
ClassExamPrinter::model()->updateAll(array('is_print'=>1,'print_time'=>time()),$criteria);
}
}
if($flag==2 || $flag==11){
$this->schoolManager->saveExamProcess($exam_data->exam_group_id,14,time());
}else{
$this->schoolManager->saveExamProcess($exam_data->exam_group_id,9,time());
}
}
echo $getRes;die;
}
// 验证试卷是否已上传模板
public function actionVerifyTpl(){
$eid = Req::post('eid');
$error['success'] = 0;
if (empty($eid)) {
$error['message'] = '考试信息不存在!';
echo json_encode($error);exit();
}
$paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
if (empty($paperInfo)) {
$error['message'] = '未找到试卷信息!';
echo json_encode($error);exit();
}
if (empty($paperInfo->tpl_doc_src)) {
$error['message'] = '未上传模板!';
echo json_encode($error);exit();
} else {
$error['success'] = 1;
$error['message'] = '已上传模板!';
echo json_encode($error);exit();
}
//$getRes = apiPost(Yii::app()->params['get_api_url'].'/coachio/iointerface/getpapertpl', 'paperId='.$paperInfo->paper_id);
//echo $getRes;
}
public function actionCheckAnswerCard(){
$eid = Req::post('eid');
$error['success'] = 0;
if (empty($eid)) {
$error['message'] = '考试信息不存在!';
echo json_encode($error);exit();
}
$paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
if (empty($paperInfo)) {
$error['message'] = '未找到试卷信息!';
echo json_encode($error);exit();
}
if (empty($paperInfo->answer_card_src)) {
$error['message'] = '未上传模板!';
echo json_encode($error);exit();
} else {
$error['success'] = 1;
$error['message'] = '已上传模板!';
echo json_encode($error);exit();
}
}
// 上传试卷模板
public function actionUploadTpl(){
$eid = Req::post('eid');
$type = Req::post("type");
$error['success'] = 0;
if (empty($eid)) {
$error['message'] = '周周练id不存在!';
echo json_encode($error);exit();
}
$paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
if (empty($paperInfo)) {
$error['message'] = '未找到试卷信息333!';
echo json_encode($error);exit();
}
$examInfo = Exam::model()->findByPk($eid);
if(empty($examInfo)){
$error['message'] = '未找到统考信息!';
echo json_encode($error);exit();
}
if (empty($_FILES['word_file'])) {
$error['message'] = '未找到上传文件!';
echo json_encode($error);exit();
}
if(!is_uploaded_file($_FILES['word_file']['tmp_name'])){
$error['message'] = '非法上传!';
echo json_encode($error);exit();
}
if ($_FILES['word_file']['error'] > 0) {
switch ($_FILES['word_file']['error']) {
case 1:
$error['message'] = '文件大小超出了服务器的空间大小!';
break;
case 2:
$error['message'] = '要上传的文件大小超出浏览器限制!';
break;
case 3:
$error['message'] = '文件只有部分被上传!';
break;
case 4:
$error['message'] = '没有找到要上传的文件!';
break;
case 5:
$error['message'] = '服务器临时文件夹丢失!';
break;
case 6:
$error['message'] = '文件写入到临时文件夹出错!';
break;
}
echo json_encode($error);exit();
}
// 保存上传文件至服务器
$pathName = dirname(dirname(dirname(__FILE__))).'/upload/tmpDir/word/'. date('Y') .'/'. date('m') . '/';
if (!file_exists($pathName)) {
mkdir($pathName, 0777, true);
}
$extName = substr($_FILES['word_file']['name'],strrpos($_FILES['word_file']['name'],'.'));
$fileName = uniqid() . $extName;
if (!move_uploaded_file($_FILES['word_file']['tmp_name'], $pathName.$fileName)) {
$error['message'] = '上传文件失败!';
echo json_encode($error);exit();
}
$param['tpl_name'] = $_FILES['word_file']['name'];
$param['paperId'] = $paperInfo->paper_id;
$param['templetA'] = $_FILES['word_file']['type'];
$param['path_tpl'] = $pathName.$fileName;
$fileSrc = $pathName.$fileName;
//FIXME 20191224
if(file_exists($fileSrc)){
$rename = 'zsyas2/uploadTpl/'.$this->schoolId.'/'. date('Y') . '/' . date('m') . '/' . date('d').'/'. uniqid() . '/' . $extName;
$ucloud = new Qcloud();
$uploadInfo = $ucloud->putFile($rename, $fileSrc);
@unlink($fileSrc);
if ($uploadInfo['status'] == 0) {
$error['message'] = '上传文件失败!';
echo json_encode($error);exit();
}else{
$examModel = new Exam();
$examIds = $examModel->getExamIds($examInfo['exam_group_id']);
if(empty($examIds)){
$error['message'] = '上传文件失败!';
echo json_encode($error);exit();
}
$uploadInfo['url'] = str_replace("%2F","/",$uploadInfo['url']);
if($type == 1){
$this->sConn->createCommand("update paper set tpl_doc_src = '{$uploadInfo['url']}' where exam_id in (".implode(',',$examIds).") ")->execute();
}
else if($type == 2){
$this->sConn->createCommand("update paper set answer_card_src = '{$uploadInfo['url']}' where exam_id in (".implode(',',$examIds).") ")->execute();
}
else{
$error['message'] = '上传文件失败!';
echo json_encode($error);exit();
}
$error['success'] = 1;
$error['message'] = '上传成功!';
echo json_encode($error);exit();
}
}else{
$error['message'] = '上传文件失败!';
echo json_encode($error);exit();
}
}
public function actionExportExcel(){
$classId = Req::get("classId");
$examId = Req::get("examId");
$class = $this->schoolManager->getClass($classId);
$exam = $this->schoolManager->getExam($examId);
$className = $class ? $class["class_name"] : "";
$wpName = $exam ? $exam["name"] : "";
$report = $this->schoolManager->getExamRsByClass($examId, $classId, array(), "EXCEL");
$excel = new Excel();
$fileName = "{$className}-{$wpName}报告";
$excel->export($report, $fileName);
}
public function actionReplaceIspTopicAct(){
$planId = Req::post("planId");
$previousTopicId = Req::post("previousTopicId");
$newTopicId = Req::post("newTopicId");
$rs = $this->schoolManager->replaceIspTopic($planId, $previousTopicId, $newTopicId);
echo json_encode($rs);exit;
}
public function actionIspCheck(){
$planId = Req::get("planId");
$isp = $this->schoolManager->getIspInfo($planId);
if(!$isp)
Yii::app()->jump->error('个性化学习宝不存在');
$topics = $this->schoolManager->getIspTopics($planId);
$sections = $this->schoolManager->composeIspTopics($planId, $topics);
unset($topics);
$paper = $this->schoolManager->getExamPaper($isp["exam_id"]);
$ispTopicsIds = $this->schoolManager->getIspTopicsIds($planId);
$this->render("ispcheck", array(
"topicSections" => $sections,
"isp" => $isp,
"planId" => $planId,
"examId" => $isp["exam_id"],
"paperId" => $paper ? $paper["paper_id"] : null,
"ispTopicsIds" => implode(",", $ispTopicsIds),
));
}
public function actionAjaxGetPaperTopicReplace()
{
$error = array();
$result = array();
if ( ! Yii::app()->request->isAjaxRequest OR ! Yii::app()->request->isPostRequest)
{
$error[] = '错误的来源!';
}
else
{
$examId = Yii::app()->request->getPost('examId');
$paperId = Yii::app()->request->getPost('paperId');
$topicType = (int)Yii::app()->request->getPost('topicType');
$topicId = (int)Yii::app()->request->getPost('topicId');
$methodId = (int)Yii::app()->request->getPost('methodId');
$methodDifficulty = (int)Yii::app()->request->getPost('methodDifficulty');
$notIncludeTopicId = (int)Yii::app()->request->getPost('notIncludeTopicId');
$num = (int)Yii::app()->request->getPost('num', 1);
$isArray = (int)Yii::app()->request->getPost('isArray');
$isFind = (int)Yii::app()->request->getPost('isFind');
$notInTopicsIds = Req::post('notInTopicsIds');
if ( ! $paperId OR ! is_numeric($paperId))
{
$error[] = '必须指定paperId';
}
else
{
$paperCls = new SPaper();
$paperDetail = $paperCls->getDetailByPaperId($paperId);
if ( ! $paperDetail)
{
$error[] = '未找到指定的 试卷';
}
}
if ($topicType <= 0)
{
$error[] = '必须指定 topicType';
}
elseif ( ! in_array($topicType, array(1, 5, 7)))
{
$error[] = '不允许的 topicType';
}
if ($topicId <= 0)
{
$error[] = '必须指定 topicId';
}
if (empty($methodId))
{
$error[] = '必须指定 methodId';
}
if ($methodDifficulty <= 0 OR $methodDifficulty > 3)
{
$error[] = '不允许的 methodDifficulty';
}
if ($num <= 0) $num = 1;
}
if ( ! $error)
{
$paperTopicRelationCls = new SPaperTopicRelation();
$paperTopicRelationDetail = $paperTopicRelationCls->getDetailByPaperId_TopicId($paperId, $topicId);
if ( ! $paperTopicRelationDetail)
{
$error[] = '未找到指定的试题';
}
else
{
$topicScore = $paperTopicRelationDetail['score'];
}
}
if ( ! $error)
{
$methodId = explode(",", $methodId);
$notInTopicsIds = explode(",", $notInTopicsIds);
$topicRule = array(
'num' => $num,
'score' => $topicScore,
'types' => $topicType,
'difficultys' => $methodDifficulty,
'methods' => $methodId,
);
// if ( ! $isFind)
// {
// $topicRule['difficultys'] = $methodDifficulty;
// }
$topicItem = $this->apiPost('/smart/pull', array(
'subjectId' => Yii::app()->params['subject_id'],
'notInTopicsIds' => $notInTopicsIds,
'rules' => array($topicRule),
));
if (isset($topicItem->error))
{
$error[] = $topicItem->error;
}
else
{
if ( ! $isArray AND $num == 1)
{
$result = $topicItem[0];
}
else
{
$result = $topicItem;
}
}
}
if ( ! $error)
{
if ( ! $result)
{
$error[] = '未找到符合的题';
}
}
//header('Content-Type: application/json');
if ($error)
{
echo json_encode(array('status' => 0, 'error'=> implode('
', $error)));exit;
}
else
{
$result = Obj::toArr($result);
$topic = $this->schoolManager->getTopic($topicId);
$topicMethosCount = isset($topic["specials"]) ? count($topic["specials"]) : 0;
$matchTopics = array();
foreach($result as $key => $val){
$sameCount = 0;
$diffCount = 0;
if(isset($val["specials"]) && isset($topic["specials"])){
$diff1 = Arr::diff($val["specials"], $topic["specials"]);
$diff2 = Arr::diff($topic["specials"], $val["specials"]);
if(!$diff1 && !$diff2){
$matchTopics[] = $val;
unset($result[$key]);
continue;
}
if($diff1)
$diffCount = count($diff1);
$same = Arr::intersect($topic["specials"], $val["specials"]);
if($same)
$sameCount = count($same);
}
$result[$key]["methods_same_count"] = $sameCount;
$result[$key]["methods_diff_count"] = $diffCount;
}
//按照考点不同点升序排序
Arr::sortByField($result, "methods_diff_count");
//按照考点相同点降序排序
Arr::sortByField($result, "methods_same_count", "DESC");
//合并完全匹配考点和部分匹配考点的题 完全匹配在前
$result = Arr::merge($matchTopics, $result);
echo json_encode($result);exit;
}
}
public function actionSetPrintTransChecked(){
$planId = Req::post("planId");
$classId = Req::post("classId");
$examId = Req::post("examId");
$studentId = $this->schoolManager->getStudentIdByIspId($planId);
$this->schoolManager->setStudentIspChecked($planId);
$this->schoolManager->setPrintTransChecked($classId, $examId);
$arr=array(
'cate' => 3,
'schoolId' => $this->schoolId,
'examId' => $examId,
'studentId'=>$studentId
);
$send_json=json_encode($arr);
$stompconn = new Stomp(Yii::app()->params["activeMq"]["server"]);
$stompconn->send("wb_isp_html", $send_json);
unset($stompconn);
$redis_obj = new Redis();
$server = Yii::app()->params["redis"]["server"];
$redis_obj->connect($server["host"], $server["port"]);
$redis_obj->auth($server["password"]);
$redis_obj->select(2);
$redis_obj->set('activeMq.wb_isp_consumer.producer_time',time());
$this->redirect($this->createUrl("print/studentsispslist?classId={$classId}&examId={$examId}"));
}
public function actionIspsList(){
$getName = safe_replace(Yii::app()->request->getQuery('printName'));
$getStatus = safe_replace(Yii::app()->request->getQuery('status'));
$statusArray= array();
if ($getStatus !== '') {
$statusArray= array($getStatus);
}
// 打印任务处理
$ExamModel = Exam::model();
$ClassModel = ClassModel::model();
$printList = array();
// 获取当前学期班级并组装
$class_array= ClassModel::model()->findAll('semester_id='.Yii::app()->session['session_semester_id']);
$ccArray = array();
$ccName = array();
foreach ($class_array as $cc=>$ca) {
array_push($ccArray, $ca->class_id);
$ccName[$ca->class_id] = $ca->class_name;
}
if(Yii::app()->session['coachInfo']['leader'] == 1) {
$resultList = $this->schoolManager->getPrintList(array("cep.type = 2"));
}
else{
$resultList = $this->schoolManager->getPrintListOfCoach($this->coachId, array("cep.type = 2"));
}
if($resultList["rs"]){
foreach ($resultList['rs'] as $k=>$v) {
$printList[$k] = $v;
$printList[$k]['class_name'] = @$ccName[$v["class_id"]];
$pname = @$ExamModel->getExamName($v["exam_id"]); // 周周练名称
if ($v["type"] == 1) {
$printList[$k]['print_name']= $pname.'"纠错本"打印任务!';
} elseif ($v["type"] == 2) {
$printList[$k]['print_name']= $pname.'"个性化学习宝"打印任务!';
} else {
$printList[$k]['print_name']= $pname.'打印任务!';
}
}
}
$data = array();
$data['getName'] = $getName;
$data['status'] = $getStatus;
$data['printList'] = $printList;
$data['pages'] = $resultList['pager'];
$data['page_total'] = $resultList['pager']->rowsCount;
unset($resultList);
$this->render("ispslist", $data);
}
public function actionStudentsIspsList(){
$classId = Req::get("classId");
$examId = Req::get("examId");
$isps = $this->schoolManager->getClassStudentsIspsList($classId, $examId);
$this->render("studentsispslist", array(
"isps" => $isps,
));
}
public function actionUploadConfirm()
{
$error = array();
if (Yii::app()->request->getIsPostRequest())
{
$classId = safe_replace(Yii::app()->request->getPost('classId'));
$examId = safe_replace(Yii::app()->request->getPost('examId'));
if ( ! $classId AND ! is_numeric($classId))
{
$error[] = 'Params: classId error.';
}
if ( ! $examId AND ! is_numeric($examId))
{
$error[] = 'Params: examId error.';
}
}
else
{
$error[] = 'Must post request.';
}
if ( ! $error)
{
/*$relations = $this->schoolManager->getExamClassesRelations($examId);
$uploadedRelations = $this->schoolManager->getExamClassesRelationsFilteredByUploadStatus($examId, 2);
if (count($relations) == count($uploadedRelations))
{*/
$this->schoolManager->changeExamStatus($examId, 4);
$this->schoolManager->changeExamUploadStatus($examId, 2);
//}
if (!$error && ($examGroupId = $this->schoolManager->getExamGroupIdByExamId($examId)))
{
$examIds = $this->schoolManager->getExamsIdsByExamGroupId($examGroupId);
if ($examIds)
{
$exams = getAttributes(Exam::model()->findAll("exam_id IN (". implode(',', $examIds) .") AND upload_status = '2'"));
if (count($examIds) == count($exams))
{
$examGroup = SExamGroup::model()->find('exam_group_id = :examGroupId', array(
':examGroupId' => $examGroupId
));
$examGroup->upload_status = 2;
$examGroup->save();
}
}
}
}
if ($error)
{
echo json_encode(array('status' => 0, 'error' => implode(PHP_EOL, $error)));exit;
}
else
{
echo json_encode(array('status' => 1, 'error' => ''));exit;
}
}
// // 更新试卷打印状态、时间
public function actionUpdatepaperprinttime() {
$cid = Req::post("cid");
$eid = Req::post("eid");
$type = Req::post("type");
$getResult = ClassExamPrinter::model()->find('class_id=:cid and exam_id=:eid and type=:type',array(':cid'=>$cid,':eid'=>$eid,':type'=>$type));
if (!empty($getResult)) {
$getResult->is_print = 1;
$getResult->print_time = time();
if ($getResult->save()) {
exit('1');
} else {
exit('2');
}
}
}
/* public function actionDownstudentexcel() {
$filename="导入学生示例.xls";
$path = dirname(dirname(__FILE__)).'/data/';
$file=fopen($path.$filename,"r");
Header("Content-type:application/octet-stream");
Header("Accept-Ranges:bytes");
header("Content-Type:application/msexcel");
Header("Accept-Length:".filesize($path.$filename));
Header("Content-Disposition:attachment;filename=".$filename);
echo fread($file,filesize($path.$filename));
fclose($file);
} */
/**
* 发送/取消/重新发送标注
*/
public function actionSendLabelTask(){
$examId = Req::post("examId");
$examName = Req::post("examName");
$createTime = Req::post("createTime");
$type = Req::post('type');
$status = Req::post('status');
$remark = Req::post('remark');
$isTagging = Req::post('isTagging'); //新方法宝发送标注
$estimate= Req::post('estimate'); //期望时间
if(!$examId || !$examName || !$type){
echo json_encode(array("success" => 0, "message" => "缺少必要参数"));
exit();
}
if(!($paper = $this->schoolManager->getExamPaper($examId))){
echo json_encode(array("success" => 0, "message" => "找不到试卷"));
exit();
}
if(!($topicsRecords = $this->schoolManager->getPaperTopicsRecords($paper["paper_id"]))){
echo json_encode(array("success" => 0, "message" => "找不到试卷题目"));
exit();
}
$labelledType=$paper['labelled_type']; //标注类型
$subjectId = 0;
$examTime = time();
if(($exam = $this->schoolManager->getExam($examId)) && isset($exam["tpl_data"]) && ($tplData = json_decode($exam["tpl_data"], true))){
$subjectId = $this->schoolManager->getSubjectIdByTplData($tplData);
if(isset($tplData["examDate"]))
$examTime = strtotime($tplData["examDate"]);
}
//取消和重新发送的时候判断题库那边是否已经标注完成
$sql = "select is_third,qxk_paper_id,is_tagging from exam_group where exam_group_id = '{$exam['exam_group_id']}'";
$examGroup = $this->sConn->createCommand($sql)->queryRow();
if ($status==='2' || $status==='4' || $status==='3'){
$is_labelled = $paper['is_labelled'];
if ($is_labelled==='1'){
echo json_encode(array(
'success' => 2,
'message' => '已经标注完成,点击确定后刷新状态。'
));
exit;
}
}
$this->setIs_new($exam['exam_group_id']);
if ($type=='cancel'){
$title = '取消标注';
}elseif ($type=='resend'){
$title = '重新发送标注';
}else{
$title = '发送标注';
}
//操作日志
if(Yii::app()->params['handle_log_on_off'])
{
writeFileLog(jsonEncode(array(
"exam_group_id" => (string)$exam['exam_group_id'],
"operate_project" => 'zsyas2',
"title" => $title,
"school_id" => $this->schoolId,
"operate_account" => Yii::app()->session['coachInfo']['coach_name'],
"operate_method" => $this->action,
"operate_url" => $this->getRoute(),
"operate_sql" => '',
"operate_param" =>json_encode(array('post'=>$_POST,'get'=>$_GET)),
"date"=>date('Y-m-d H:i:s')
)));
}
//判断学科
if($subjectId==8 && !$isTagging){
$topics = array();
foreach($topicsRecords as $topicRecord){
$topics[$topicRecord["stem_id"]] = array(
"topic_id" => $topicRecord["stem_id"],
"school_id" => $topicRecord["mode"] ? $this->schoolId : 0,
"topic_type" => $topicRecord["type"],
"no" => $topicRecord["no"],
);
}
$jsonArr = array();
$jsonArr['exam_name'] = $examName;
$jsonArr['school_id'] = $this->schoolId;
$jsonArr['exam_group_id'] = $exam['exam_group_id'];
$jsonArr['exam_time'] = $examTime;
$jsonArr['origin'] = 'zxhx'; //校本课程平台试卷
$jsonArr['exam_topic'] = $topics; //校本课程平台试卷
if($type=='send' || $type=='resend'){
$result = Curl::http_post_json(Yii::app()->params['english_send_mark'], json_encode($jsonArr));
$resultArr=json_decode($result,true);
if($resultArr['status'] == 1) {
$sql = "select exam_id from exam where exam_group_id = '{$exam['exam_group_id']}'";
$examAll = $this->sConn->createCommand($sql)->queryAll();
$examArr = array();
if ($examAll) {
foreach ($examAll as $k => $v) {
$examArr[] = $v['exam_id'];
}
$transcation = $this->sConn->beginTransaction();
try {
$this->sConn->createCommand("update paper set is_labelled = 3,labelled_type=1,send_labelled_time='".time()."' where exam_id in (" . implode(',', $examArr) . ")")->execute();
$transcation->commit();
$rs['success'] = 1;
$rs = json_encode($rs);
} catch (Exception $e) {
$transcation->rollback();
$error['message'] = '更新失败!';
$error['success'] = 0;
echo json_encode($error);
exit();
}
} else {
$error['message'] = '考试信息错误!';
$error['success'] = 0;
echo json_encode($error);
exit();
}
}elseif($resultArr['status'] == 2){ //完成标注
$rs['success'] = 1;
$rs = json_encode($rs);
}else{
$error['message'] = $resultArr['message'];
$error['success']=0;
echo json_encode($error);exit();
}
}else{
if($labelledType==2){
if($this->schoolManager->sendLabelToTeacher($exam['exam_group_id'],'cancel')){
$error['message'] = '取消成功';
$error['success']=1;
echo json_encode($error);exit();
}else{
$error['message'] = '取消失败';
$error['success']=0;
echo json_encode($error);exit();
}
}else{
$result = Curl::http_post_json(Yii::app()->params['english_cancel_mark'], json_encode($jsonArr));
$resultArr=json_decode($result,true);
if($resultArr['status'] == 1){
$error['message'] = '取消成功';
$error['success']=1;
echo json_encode($error);exit();
}else{
$error['message'] = $resultArr['message'];
$error['success']=0;
echo json_encode($error);exit();
}
}
}
}else if($subjectId==12 || Yii::app()->params['section']==0 || $isTagging){
$topics = array();
if($type=='send' && Yii::app()->params['section']==1){
if(!$estimate){
echo json_encode(array("success" => 0, "message" => "期望时间不能为空"));
exit();
}
if(strtotime($estimate)