123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893 |
- <?php
- /**
- * Created by 上海互教教育科技有限公司.
- * User: 刘红伟
- * QQ : 454303753
- * Date: 2017/6/16 0016
- * Time: 下午 15:29
- */
- class HomeworkController extends Controller
- {
- public function actionIndex(){
- 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");
- $exam_group_ids = array();
- $sheets = array();
- $exam_sheets = array();
- $sheet_rs = array();
- $marking_papers = array();
- $list_type =Req::get('list_type');
- $condition = array();
- if($printName){
- $TeacherModel=new Teacher();
- //查询命卷人
- $teachers=$TeacherModel->getTeacherIdByName($printName);
- if($teachers){
- $condition[] = "(e.teacher_id in(".implode(',',$teachers).") or e.name like '%{$printName}%')";
- }else{
- $condition[] = "e.name like '%{$printName}%'";
- }
- }
- if ( empty($display)) {
- $condition[] = "e.is_display = 0";
- }else
- {
- $condition[] = "e.is_display = ".$display;
- }
- // $condition[] = "e.subject_id = '{$this->subjectId}'";
- $condition[] = "eg.is_third = 1";
- $condition[] = "eg.xb_homework = 1";
- if(in_array(Yii::app()->session['session_duoxueke_subject_id'],$this->mathSubjectId)){
- $condition[] = "e.subject_id in (".implode(',',$this->mathSubjectId).")";
- }else{
- $condition[] = "e.subject_id = ".Yii::app()->session['session_duoxueke_subject_id'];
- }
- // 年级条件
- 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)
- {
- $l_b_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)";
- }
- }
- $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;
- }
- }
- $resultList = $this->schoolManager->getThirdPrintList($condition,array('e.create_time desc','e.exam_id desc'));
- $printList = array();
- if($resultList["rs"]){
- $ExamModel=new Exam();
- $StudentPaperRelation=new SStudentPaperRelation();
- foreach ($resultList['rs'] as $k=>$v) {
- $exam_group_ids[$v['exam_group_id']] = $v['exam_group_id'];
- $time = time();
- $classinfo=ClassModel::model()->find('class_id=:class_id',array(':class_id'=>$v['class_id']));
- $v['grade']=$classinfo['grade'];
- $printList[$k] = $v;
- $tplData = json_decode($v["tpl_data"], true);
- //考试时间
- if(isset($tplData['examDate']))
- {
- $examDate = strtotime($tplData["examDate"]);
- }
- if(!isset($tplData["examDate"]))
- {
- $examDate = $v["create_time"];
- }
- $printList[$k]['examDate'] = $examDate;
- $onlineMultiplex=$this->schoolManager->getOnlineCardMultiplexByGroupId($v['exam_group_id']);
- if($onlineMultiplex && $onlineMultiplex['is_download']){
- $printList[$k]['downloaded'] = 1;
- }else{
- $printList[$k]['downloaded'] = 0;
- }
- }
- }
- $sheet_ids = array();
- $exam_sheet_download=array();
- $criteria = new CDbCriteria();
- $criteria->addInCondition('exam_group_id',$exam_group_ids);
- $exam_sheet_data = SThirdAnswerSheet::model()->findAll($criteria);
- if($exam_sheet_data)
- {
- foreach($exam_sheet_data as $v)
- {
- $exam_sheets[$v->exam_group_id] = $v->online_card_pdf;
- if($v->online_card){
- $onlineMultiplex=$this->schoolManager->getOnlineCardMultiplexByGroupId($v->exam_group_id);
- if($onlineMultiplex && $onlineMultiplex['is_download']){
- $exam_sheet_download[$v->exam_group_id] = 1;
- }
- }
- }
- }
- $subject_exam_data=Yii::app()->params['subjectId'];
- $teachers_data = Teacher::model()->findAll();
- $class_teacher_data = array();
- if($teachers_data)
- {
- foreach($teachers_data as $k=>$v)
- {
- $class_teacher_data[$v->teacher_id] = $v->teacher_name;
- }
- }
- $data = array();
- $data['is_qxk']=1;
- $data['printList'] = $printList;
- $data['pages'] = $resultList['pager'];
- $data['page_total'] = $resultList['pager']->rowsCount;
- $data["printType"] = $printType;
- $data["printName"] = $printName;
- $data["teachers"] = $class_teacher_data;
- $data["classId"] = $classId;
- $data["grade"] = $grade;
- $data["sheets"] = $sheets;
- $data["exam_sheets"] = $exam_sheets;
- $data["sheet_rs"] = $sheet_rs;
- $data["labelled"] = $labelled;
- $data["display"] = $display;
- $data["is_print"] = $is_print;
- $data["subject"] = $subject_exam_data;
- $data['list_type'] =$list_type;
- $data['showAssist'] =0;
- $data['extendSubject'] =$this->extendSubject;
- unset($resultList);
- $data['schoolId'] =$this->schoolId;
- if(Yii::app()->params['section']==0){
- $this->render('index_section',$data);
- }else{
- $this->render('index',$data);
- }
- }
- public function actionOprateexam()
- {
- $exam_group_id = Req::post("exam_group_id");
- $flag = Req::post("flag");
- $error['success'] = 0;
- if (empty($exam_group_id)) {
- $error['message'] = '操作失败!';
- echo json_encode($error);exit();
- }
- $this->setIs_new($exam_group_id);
- if ($this->schoolManager->ThirdOprateExamDisplay($exam_group_id,$flag)) {
- $error['success'] = 1;
- $error['message'] = '操作成功!';
- } else {
- $error['message'] = '操作失败!';
- }
- echo json_encode($error);exit();
- }
- public function actionExam_list()
- {
- ini_set("memory_limit","300M");
- $exam_group_id = Req::get("exam_group_id");
- $branch = Req::get("branch");
- $grade = Req::get("grade");
- $exam_date = ''; //考试日期
- $exam_name = ''; //考试名称
- $exam_uploaded=0;
- if($exam_group_id>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;
- }
- $classId = Req::get("classId");
- $condition = array();
- if($classId)
- $condition[] = "e.class_id = '{$classId}'";
- $condition[] = "eg.exam_group_id = '{$exam_group_id}'";
- $classes = $this->schoolManager->getSemesterClasses($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->getExamList($condition,array('e.create_time desc','e.exam_id desc'));
- if($resultList && isset($resultList['rs'][0])){
- $tplData=json_decode($resultList['rs'][0]['tpl_data'],true);
- }else{
- Yii::app()->jump->error('未找到考试信息!');
- }
- if(!$exam_date) $exam_date=$tplData['examDate'];
- if(!$exam_name) $exam_name=$resultList['rs'][0]['exam_name'];
- $data['exam_id']=$resultList['rs'][0]['exam_id'];
- if(isset($tplData['is_change_to_third']) && $tplData['is_change_to_third']==1){
- $data['is_change_to_third'] = 1;
- }else{
- $data['is_change_to_third'] = 0;
- }
- //获取paper 表数据
- $paper_data = SPaper::model()->find('exam_id=:exam_id',array(':exam_id'=>$resultList['rs'][0]['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));
- //选择题类型判断
- $allSubjectType=array();
- if($exam_group_data['qxk_paper_id']>0){
- $allSubjectType=array(1,2,3,4,12);
- }else{
- $allSubjectType=array(1,2,11);
- }
- if($paperTopic){
- $data['answer_card_saved'] = 1;
- foreach ($paperTopic as $item){
- if(!in_array($item->type,$allSubjectType)){
- $isAllSelect=0;
- break;
- }
- }
- }else{
- //未制作答题卡
- $data['answer_card_saved'] = 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);
- //查询还原记录
- $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;
- }
- //是否使用在线答题卡
- $studentAnswerOnline=$this->schoolManager->getAnswerSheetOnline($exam_group_id);
- if($studentAnswerOnline){
- $data['online_card']=$studentAnswerOnline['online_card'];
- $data['is_qrcode_online']=$studentAnswerOnline['is_qrcode_online'];
- }else{
- $data['online_card']=0;
- $data['is_qrcode_online']=0;
- }
- $has_marked = false;
- $studentAnswerCardOnline=new SStudentAnswerCardOnline();
- foreach ($resultList['rs'] as $key => $item){
- if($item['status'] == 1){
- $has_marked = true;
- }
- //查询生成数量
- if($data['online_card']==1 && $data['is_qrcode_online']==1){
- $studentCardOnline= $studentAnswerCardOnline->getCountByExamId($item['exam_id']);
- if($studentCardOnline){
- $resultList['rs'][$key]['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;
- }
- }
- $data['pages'] = $resultList['pager'];
- $data['page_total'] = $resultList['pager']->rowsCount;
- if(isset($this->schoolInfo->use_zhixue) && !empty($this->schoolInfo->use_zhixue))
- {
- $data["use_zhixue"] = $this->schoolInfo->use_zhixue;
- }else
- {
- $data["use_zhixue"] = 0;
- }
- $data['printList'] = $resultList['rs'];
- $data["classes"] = $_classes;
- $data["classId"] = $classId;
- $data["exam_group_id"] = $exam_group_id;
- $data["exam_group_data"] = $exam_group_data;
- // $data["subject"] = $subject_exam_data;
- $data["branch"] = $branch;
- $data["grade"] = $grade;
- $data["enable_add_class"] = $enable_add_class;
- $data['is_all_select']=$isAllSelect;
- $data["exam_name"] = $exam_name;
- $data['version_number']=$this->version_number;
- $data['exam_date']=$exam_date;
- $data['exam_uploaded']=$exam_uploaded;
- $data['topic_push_setting']=$topicPushSettingRelation;
- $this->render('exam_list',$data);
- }
- }
- public function actionChange(){
- ini_set("memory_limit","300M");
- Url::clean();
- $sname = Req::get("sname");
- $cid = Req::get("cid");
- $eid = Req::get("eid");
- $tid = Req::get("tid");
- $isFeedback=0;
- switch($tid){
- case "0":
- $printType = 'wp';
- break;
- case "1":
- $printType = 'wb';
- break;
- case "2":
- $printType = 'isp';
- break;
- default:
- $printType = 'wp';
- }
- $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=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('未找到试卷信息!');
- }
- $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;
- }
- // 获取阅卷类型
- $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;
- if($findInfo->mark_type==0 && $findInfo->is_third==1){
- $isUnderLine = 1;
- }
- }
- }
- $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)) {
- // 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('未找该试卷关联的学生!');
- //}
- $b_student_arr = Yii::app()->redis_business_student->hgetAll('redis_business_del_student:'.$this->schoolId);
- if(!$b_student_arr ){
- $array_student = array();
- $b_student_arr = array();
- $criteria = new CDbCriteria();
- $criteria->select = 'student_id';
- $criteria->addCondition('school_id=:school_id');
- $criteria->addCondition('status=:status');
- $criteria->params[':school_id'] = $this->schoolId;
- $criteria->params[':status'] = 1;
- $b_student_data = BusinessStudent::model()->findAll($criteria);
- if($b_student_data){
- foreach ($b_student_data as $k=>$v){
- $array_student[$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($criteria);
- if($b_student_data)
- {
- foreach($b_student_data as $v)
- {
- $b_student_arr[$v->student_id] = $v->student_id;
- }
- }
- unset($b_student_data);
- unset($criteria);
- }
- $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;
- }
- }
- //查询是否上传答题图片
- $uploadAnswerImgStudent=array();
- $student_answer_img=$this->schoolManager->getUpAnswerStudent($paperInfo->paper_id,$_student_id,0);
- if($student_answer_img){
- foreach ($student_answer_img as $val){
- $uploadAnswerImgStudent[(string)$val['student_id']]=$val['student_id'];
- }
- }
- foreach ($relateStudent as $key=>$val) {
- //查询学生身份证号
- $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'] = '';
- }
- $result[$key]['student_card'] = $val['student_card'];
- $result[$key]['school_student_card'] = $val['school_student_card'];
- $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;
- }
- }
- //查询在线答题卡是否生成
- $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;
- }
- if (empty($sname)) {
- $result[$key]['clazzName'] = $classInfo->class_name;
- $result[$key]['paperName'] = $examInfo->name;
- $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]['student_img_paper'] = $val->student_img_paper;
- $result[$key]['is_complete'] = $val->is_complete;
- } else {
- if ($sname == $studentNames[$val->student_id]) {
- $result[$key]['clazzName'] = $classInfo->class_name;
- $result[$key]['paperName'] = $examInfo->name;
- $result[$key]['studentCode'] = $val->student_id;
- $result[$key]['studentName'] = $studentNames[$val->student_id];
- $result[$key]['is_feedback'] = $val->is_feedback;
- $result[$key]['student_img_paper'] = $val->student_img_paper;
- $result[$key]['is_complete'] = $val->is_complete;
- }else{
- unset($result[$key]);
- }
- unset($relateStudent[$key]);
- }
-
- $printCheck = true;
- }
- //}
- $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
- $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($_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']]:'',
- );
- }
- }
- }
- }
- //判断在线答题卡使用情况
- $useAnswerCardOnlineQrcode=0;
- $answerCardOnline=$this->schoolManager->getAnswerSheetOnline($groupInfo['exam_group_id']);
- if($answerCardOnline && $answerCardOnline['online_card']==1 && $answerCardOnline['is_qrcode_online']==1){
- $useAnswerCardOnlineQrcode=1;
- }
- $this->setIs_new($examInfo->exam_group_id);
- $data = array();
- if(isset($isUnderLine)){
- $data['under_line']=$isUnderLine;
- }
- //判断在线答题卡使用情况
- $answerCardOnline=$this->schoolManager->getAnswerSheetOnline($groupInfo['exam_group_id']);
- if($answerCardOnline && $answerCardOnline['online_card']==1 && $answerCardOnline['is_qrcode_online']==1){
- $data['use_answer_card_online_qrcode']=1;
- }else{
- $data['use_answer_card_online_qrcode']=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;
- $data['version_number']=$version_number;
- $data['no_paper_student'] = $no_paper_student;
- $data['result'] = $result;
- $data["printType"] = $printType;
- $data["sname"] = $sname;
- $data['paper_id'] = $paperInfo->paper_id;
- $data['exam_id'] = $eid;
- $data['class_id'] = $cid;
- $data['type_id'] = $tid;
- 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['examInfo'] = $examInfo;
- $data['paperType'] = $paperType;
- $data['answerCardUploaded'] = $answerCardUploaded;
- $data['paperData'] = $paperData;
- $data['isCustomTpl'] = $isCustomTpl;
- $data['isFeedback'] = $isFeedback;
- $data['printCheck'] = $printCheck;
- $data['useAnswerCardOnlineQrcode'] = $useAnswerCardOnlineQrcode;
- $this->render('change',$data);
- }
- public function actionSet_new()
- {
- $exam_group_id = Req::post("exam_group_id");
- if($exam_group_id>0)
- {
- $this->setIs_new($exam_group_id);
- }
- }
- // // 更新试卷在线答题卡打印状态、时间
- public function actionUpdateOnlinePaperPrintTime() {
- $exam_group_id = Req::post("eid");
- $thirdAnswerSheet=$this->sConn->createCommand("select multiplex_id from online_card_multiplex where exam_group_id='{$exam_group_id}' ")->queryRow();
- if($thirdAnswerSheet){
- $this->sConn->createCommand("update online_card_multiplex set is_download=1,update_time=".time()." where multiplex_id='{$thirdAnswerSheet['multiplex_id']}'")->execute();
- }
- }
- public function UUID_SHORT($length = 20)
- {
- $query = $this->sConn->createCommand("SELECT UUID_SHORT() AS UUID_SHORT")->query()->read();
- $result = $query['UUID_SHORT'];
- if ($length AND is_int($length))
- {
- $result = substr($result, ($length * -1));
- }
- return $result;
- }
- /*
- * 作业答题卡读取token
- * */
- public function actionGetCardUrl(){
- $homeworkId = Req::post("homeworkId");
- if(YII_ENV=='production'){
- $tokenUrl='https://tchr-cs.mgr.miaobikj.com/api/teacher/taskAssistant/token';
- $cardUrl='http://xbzy.schcur.com/#/assistant/exam-builder?taskId='.$homeworkId.'&schoolId='.$this->schoolId;
- }else{
- $tokenUrl='http://182.108.40.54:50100/curriculum-teacher-api-test/teacher/taskAssistant/token';
- $cardUrl='http://xbzy.testing.xiaoben.com/#/assistant/exam-builder?taskId='.$homeworkId.'&schoolId='.$this->schoolId;
- }
- $return=array('status'=>0,'data'=>'','msg'=>'');
- // $tokenUrl='https://tchr-cs.mgr.miaobikj.com/api/teacher/taskAssistant/token';
- $curl = @curl_init();
- if ($curl) {
- curl_setopt($curl, CURLOPT_HEADER, 0);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
- curl_setopt($curl, CURLOPT_TIMEOUT, 5);
- curl_setopt($curl, CURLOPT_URL, $tokenUrl);
- curl_setopt($curl, CURLOPT_POST, 1);
- curl_setopt($curl, CURLOPT_POSTFIELDS, '');
- curl_setopt($curl, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json'
- ));
- if(substr($tokenUrl,0,5)=='https'){
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false);
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,false);
- }
- $response = curl_exec($curl);
- curl_close($curl);
- $result=json_decode($response,true);
- if(isset($result['code']) && $result['code']=='200'){
- $return['status']=1;
- $cardUrl.="&token=".$result['data'];
- $return['data']=$cardUrl;
- }else{
- if(isset($result['msg'])){
- $return['msg']=$result['msg'];
- }
- }
- }
- exit(json_encode($return));
- }
- }
|