HomeworkController.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  1. <?php
  2. /**
  3. * Created by 上海互教教育科技有限公司.
  4. * User: 刘红伟
  5. * QQ : 454303753
  6. * Date: 2017/6/16 0016
  7. * Time: 下午 15:29
  8. */
  9. class HomeworkController extends Controller
  10. {
  11. public function actionIndex(){
  12. Url::clean();
  13. $printName = Req::get("name");
  14. $classId = Req::get("classId");
  15. $printType = Req::get("type");
  16. $grade = Req::get("grade");
  17. $labelled = Req::get("labelled");
  18. $display = Req::get("display");
  19. $is_print = Req::get("is_print");
  20. $exam_group_ids = array();
  21. $sheets = array();
  22. $exam_sheets = array();
  23. $sheet_rs = array();
  24. $marking_papers = array();
  25. $list_type =Req::get('list_type');
  26. $condition = array();
  27. if($printName){
  28. $TeacherModel=new Teacher();
  29. //查询命卷人
  30. $teachers=$TeacherModel->getTeacherIdByName($printName);
  31. if($teachers){
  32. $condition[] = "(e.teacher_id in(".implode(',',$teachers).") or e.name like '%{$printName}%')";
  33. }else{
  34. $condition[] = "e.name like '%{$printName}%'";
  35. }
  36. }
  37. if ( empty($display)) {
  38. $condition[] = "e.is_display = 0";
  39. }else
  40. {
  41. $condition[] = "e.is_display = ".$display;
  42. }
  43. // $condition[] = "e.subject_id = '{$this->subjectId}'";
  44. $condition[] = "eg.is_third = 1";
  45. $condition[] = "eg.xb_homework = 1";
  46. if(in_array(Yii::app()->session['session_duoxueke_subject_id'],$this->mathSubjectId)){
  47. $condition[] = "e.subject_id in (".implode(',',$this->mathSubjectId).")";
  48. }else{
  49. $condition[] = "e.subject_id = ".Yii::app()->session['session_duoxueke_subject_id'];
  50. }
  51. // 年级条件
  52. if($grade>0)
  53. {
  54. $class_data = $this->schoolManager->getSchoolByGrade($grade,$this->semesterId);
  55. if($class_data)
  56. {
  57. foreach($class_data as $v)
  58. {
  59. $class_ids[$v['class_id']] = $v['class_id'];
  60. }
  61. $exam_class_data = $this->schoolManager->getClassIdByExam($class_ids);
  62. if($exam_class_data)
  63. {
  64. foreach($exam_class_data as $v)
  65. {
  66. $l_b_exam_ids[$v['exam_id']] = $v['exam_id'];
  67. }
  68. }
  69. unset($exam_class_data);
  70. }
  71. unset($class_data);
  72. }
  73. if(isset($l_b_exam_ids))
  74. {
  75. if($l_b_exam_ids)
  76. {
  77. $condition[] = "e.exam_id in (".implode(',',$l_b_exam_ids).")";
  78. }else
  79. {
  80. $condition[] = "e.exam_id in (0)";
  81. }
  82. }
  83. $gradeCardLength=array();
  84. $gradeData=SGrade::model()->findAll();
  85. foreach ($gradeData as $datum){
  86. if($datum->card_status==1){
  87. $gradeCardLength[$datum->id]=$datum->card_length;
  88. }else{
  89. $gradeCardLength[$datum->id]=0;
  90. }
  91. }
  92. $resultList = $this->schoolManager->getThirdPrintList($condition,array('e.create_time desc','e.exam_id desc'));
  93. $printList = array();
  94. if($resultList["rs"]){
  95. $ExamModel=new Exam();
  96. $StudentPaperRelation=new SStudentPaperRelation();
  97. foreach ($resultList['rs'] as $k=>$v) {
  98. $exam_group_ids[$v['exam_group_id']] = $v['exam_group_id'];
  99. $time = time();
  100. $classinfo=ClassModel::model()->find('class_id=:class_id',array(':class_id'=>$v['class_id']));
  101. $v['grade']=$classinfo['grade'];
  102. $printList[$k] = $v;
  103. $tplData = json_decode($v["tpl_data"], true);
  104. //考试时间
  105. if(isset($tplData['examDate']))
  106. {
  107. $examDate = strtotime($tplData["examDate"]);
  108. }
  109. if(!isset($tplData["examDate"]))
  110. {
  111. $examDate = $v["create_time"];
  112. }
  113. $printList[$k]['examDate'] = $examDate;
  114. $onlineMultiplex=$this->schoolManager->getOnlineCardMultiplexByGroupId($v['exam_group_id']);
  115. if($onlineMultiplex && $onlineMultiplex['is_download']){
  116. $printList[$k]['downloaded'] = 1;
  117. }else{
  118. $printList[$k]['downloaded'] = 0;
  119. }
  120. }
  121. }
  122. $sheet_ids = array();
  123. $exam_sheet_download=array();
  124. $criteria = new CDbCriteria();
  125. $criteria->addInCondition('exam_group_id',$exam_group_ids);
  126. $exam_sheet_data = SThirdAnswerSheet::model()->findAll($criteria);
  127. if($exam_sheet_data)
  128. {
  129. foreach($exam_sheet_data as $v)
  130. {
  131. $exam_sheets[$v->exam_group_id] = $v->online_card_pdf;
  132. if($v->online_card){
  133. $onlineMultiplex=$this->schoolManager->getOnlineCardMultiplexByGroupId($v->exam_group_id);
  134. if($onlineMultiplex && $onlineMultiplex['is_download']){
  135. $exam_sheet_download[$v->exam_group_id] = 1;
  136. }
  137. }
  138. }
  139. }
  140. $subject_exam_data=Yii::app()->params['subjectId'];
  141. $teachers_data = Teacher::model()->findAll();
  142. $class_teacher_data = array();
  143. if($teachers_data)
  144. {
  145. foreach($teachers_data as $k=>$v)
  146. {
  147. $class_teacher_data[$v->teacher_id] = $v->teacher_name;
  148. }
  149. }
  150. $data = array();
  151. $data['is_qxk']=1;
  152. $data['printList'] = $printList;
  153. $data['pages'] = $resultList['pager'];
  154. $data['page_total'] = $resultList['pager']->rowsCount;
  155. $data["printType"] = $printType;
  156. $data["printName"] = $printName;
  157. $data["teachers"] = $class_teacher_data;
  158. $data["classId"] = $classId;
  159. $data["grade"] = $grade;
  160. $data["sheets"] = $sheets;
  161. $data["exam_sheets"] = $exam_sheets;
  162. $data["sheet_rs"] = $sheet_rs;
  163. $data["labelled"] = $labelled;
  164. $data["display"] = $display;
  165. $data["is_print"] = $is_print;
  166. $data["subject"] = $subject_exam_data;
  167. $data['list_type'] =$list_type;
  168. $data['showAssist'] =0;
  169. $data['extendSubject'] =$this->extendSubject;
  170. unset($resultList);
  171. $data['schoolId'] =$this->schoolId;
  172. if(Yii::app()->params['section']==0){
  173. $this->render('index_section',$data);
  174. }else{
  175. $this->render('index',$data);
  176. }
  177. }
  178. public function actionOprateexam()
  179. {
  180. $exam_group_id = Req::post("exam_group_id");
  181. $flag = Req::post("flag");
  182. $error['success'] = 0;
  183. if (empty($exam_group_id)) {
  184. $error['message'] = '操作失败!';
  185. echo json_encode($error);exit();
  186. }
  187. $this->setIs_new($exam_group_id);
  188. if ($this->schoolManager->ThirdOprateExamDisplay($exam_group_id,$flag)) {
  189. $error['success'] = 1;
  190. $error['message'] = '操作成功!';
  191. } else {
  192. $error['message'] = '操作失败!';
  193. }
  194. echo json_encode($error);exit();
  195. }
  196. public function actionExam_list()
  197. {
  198. ini_set("memory_limit","300M");
  199. $exam_group_id = Req::get("exam_group_id");
  200. $branch = Req::get("branch");
  201. $grade = Req::get("grade");
  202. $exam_date = ''; //考试日期
  203. $exam_name = ''; //考试名称
  204. $exam_uploaded=0;
  205. if($exam_group_id>0)
  206. {
  207. if($exam_group_id <= 0)
  208. {
  209. Yii::app()->jump->error('未找到考试信息!');
  210. }
  211. $exam_group_data = ExamGroup::model()->find('exam_group_id=:exam_group_id',array(':exam_group_id'=>$exam_group_id));
  212. if(!$exam_group_data)
  213. {
  214. Yii::app()->jump->error('未找到考试信息!');
  215. }
  216. if($exam_group_data->upload_status>0){
  217. $exam_uploaded=1;
  218. }
  219. $classId = Req::get("classId");
  220. $condition = array();
  221. if($classId)
  222. $condition[] = "e.class_id = '{$classId}'";
  223. $condition[] = "eg.exam_group_id = '{$exam_group_id}'";
  224. $classes = $this->schoolManager->getSemesterClasses($this->semesterId);
  225. if(!$classes)
  226. {
  227. Yii::app()->jump->error('本学期尚未建班级!');
  228. }
  229. $_classes = array();
  230. foreach($classes as $v)
  231. {
  232. $_classes[$v['class_id']][$v['class_id']] = $v;
  233. }
  234. $resultList = $this->schoolManager->getExamList($condition,array('e.create_time desc','e.exam_id desc'));
  235. if($resultList && isset($resultList['rs'][0])){
  236. $tplData=json_decode($resultList['rs'][0]['tpl_data'],true);
  237. }else{
  238. Yii::app()->jump->error('未找到考试信息!');
  239. }
  240. if(!$exam_date) $exam_date=$tplData['examDate'];
  241. if(!$exam_name) $exam_name=$resultList['rs'][0]['exam_name'];
  242. $data['exam_id']=$resultList['rs'][0]['exam_id'];
  243. if(isset($tplData['is_change_to_third']) && $tplData['is_change_to_third']==1){
  244. $data['is_change_to_third'] = 1;
  245. }else{
  246. $data['is_change_to_third'] = 0;
  247. }
  248. //获取paper 表数据
  249. $paper_data = SPaper::model()->find('exam_id=:exam_id',array(':exam_id'=>$resultList['rs'][0]['exam_id']));
  250. if(!$paper_data)
  251. {
  252. Yii::app()->jump->error('未找到考试信息!');
  253. }
  254. //读取试题数据
  255. $isAllSelect=1; //全部客观题判断
  256. $paperTopic=SPaperTopicRelation::model()->findAll('paper_id=:paper_id',array(':paper_id'=>$paper_data->paper_id));
  257. //选择题类型判断
  258. $allSubjectType=array();
  259. if($exam_group_data['qxk_paper_id']>0){
  260. $allSubjectType=array(1,2,3,4,12);
  261. }else{
  262. $allSubjectType=array(1,2,11);
  263. }
  264. if($paperTopic){
  265. $data['answer_card_saved'] = 1;
  266. foreach ($paperTopic as $item){
  267. if(!in_array($item->type,$allSubjectType)){
  268. $isAllSelect=0;
  269. break;
  270. }
  271. }
  272. }else{
  273. //未制作答题卡
  274. $data['answer_card_saved'] = 0;
  275. }
  276. //读取试题推送设置
  277. $topicPushSettingModel=new SExamPushTopicsSetting();
  278. $topicPushSetting=$topicPushSettingModel->getTopicSetting($exam_group_id);
  279. $topicPushSettingRelation=array();
  280. if($topicPushSetting){
  281. foreach ($topicPushSetting as $item){
  282. if($item['topic_ids']){
  283. $topicSetting=json_decode($item['topic_ids'],true);
  284. if($topicSetting){
  285. $topicPushSettingRelation[(string)$item['exam_id']]=1;
  286. }
  287. }
  288. }
  289. }
  290. // $subject_exam_data = $this->schoolManager->getxuekeStatus($this->semesterId);
  291. $this->setIs_new($exam_group_id);
  292. //查询还原记录
  293. $examRestore=SExamRestore::model()->find('exam_group_id=:exam_group_id',array(':exam_group_id'=>$exam_group_id));
  294. if($examRestore){
  295. $data['restore'] = 1;
  296. }else{
  297. $data['restore'] = 0;
  298. }
  299. //是否使用在线答题卡
  300. $studentAnswerOnline=$this->schoolManager->getAnswerSheetOnline($exam_group_id);
  301. if($studentAnswerOnline){
  302. $data['online_card']=$studentAnswerOnline['online_card'];
  303. $data['is_qrcode_online']=$studentAnswerOnline['is_qrcode_online'];
  304. }else{
  305. $data['online_card']=0;
  306. $data['is_qrcode_online']=0;
  307. }
  308. $has_marked = false;
  309. $studentAnswerCardOnline=new SStudentAnswerCardOnline();
  310. foreach ($resultList['rs'] as $key => $item){
  311. if($item['status'] == 1){
  312. $has_marked = true;
  313. }
  314. //查询生成数量
  315. if($data['online_card']==1 && $data['is_qrcode_online']==1){
  316. $studentCardOnline= $studentAnswerCardOnline->getCountByExamId($item['exam_id']);
  317. if($studentCardOnline){
  318. $resultList['rs'][$key]['card_created']=$studentCardOnline['count'];
  319. }
  320. }
  321. }
  322. //是否能添加班级 FIXME add_class_0924
  323. //打印中
  324. $enable_add_class = false;
  325. if($exam_group_data['status'] == 1 || $exam_group_data['mark_type'] == 0){
  326. $enable_add_class = true;
  327. }else{
  328. //混合阅卷
  329. if($exam_group_data['mark_type'] == 3){
  330. $enable_add_class = ($exam_group_data['mark_status']==2 && $exam_group_data['upload_status']== 2) ? false : true;
  331. }
  332. //单独阅卷
  333. if($exam_group_data['mark_type'] == 4){
  334. $enable_add_class = $has_marked ? false : true;
  335. }
  336. }
  337. $data['pages'] = $resultList['pager'];
  338. $data['page_total'] = $resultList['pager']->rowsCount;
  339. if(isset($this->schoolInfo->use_zhixue) && !empty($this->schoolInfo->use_zhixue))
  340. {
  341. $data["use_zhixue"] = $this->schoolInfo->use_zhixue;
  342. }else
  343. {
  344. $data["use_zhixue"] = 0;
  345. }
  346. $data['printList'] = $resultList['rs'];
  347. $data["classes"] = $_classes;
  348. $data["classId"] = $classId;
  349. $data["exam_group_id"] = $exam_group_id;
  350. $data["exam_group_data"] = $exam_group_data;
  351. // $data["subject"] = $subject_exam_data;
  352. $data["branch"] = $branch;
  353. $data["grade"] = $grade;
  354. $data["enable_add_class"] = $enable_add_class;
  355. $data['is_all_select']=$isAllSelect;
  356. $data["exam_name"] = $exam_name;
  357. $data['version_number']=$this->version_number;
  358. $data['exam_date']=$exam_date;
  359. $data['exam_uploaded']=$exam_uploaded;
  360. $data['topic_push_setting']=$topicPushSettingRelation;
  361. $this->render('exam_list',$data);
  362. }
  363. }
  364. public function actionChange(){
  365. ini_set("memory_limit","300M");
  366. Url::clean();
  367. $sname = Req::get("sname");
  368. $cid = Req::get("cid");
  369. $eid = Req::get("eid");
  370. $tid = Req::get("tid");
  371. $isFeedback=0;
  372. switch($tid){
  373. case "0":
  374. $printType = 'wp';
  375. break;
  376. case "1":
  377. $printType = 'wb';
  378. break;
  379. case "2":
  380. $printType = 'isp';
  381. break;
  382. default:
  383. $printType = 'wp';
  384. }
  385. $classInfo = ClassModel::model()->findByPk($cid);
  386. if (empty($classInfo)) {
  387. Yii::app()->jump->error('未找到班级!');
  388. }
  389. $examInfo = Exam::model()->findByPk($eid);
  390. if (empty($examInfo)) {
  391. Yii::app()->jump->error('未找到周周练!');
  392. }
  393. $getResult = ClassExamPrinter::model()->find('class_id=:cid and exam_id=:eid and type=0',array(':cid'=>$cid,':eid'=>$eid));
  394. if (empty($getResult)) {
  395. Yii::app()->jump->error('未找到班级与试卷对应关系!');
  396. }
  397. $paperInfo = SPaper::model()->find('exam_id=:eid',array(':eid'=>$eid));
  398. if (empty($paperInfo)) {
  399. Yii::app()->jump->error('未找到试卷信息!');
  400. }
  401. $paperData = $this->schoolManager->getPaperWithTopicsDetails_v2($paperInfo->paper_id);
  402. if(trim($paperInfo->answer_card_src))
  403. $answerCardUploaded = true;
  404. else
  405. $answerCardUploaded = false;
  406. $tpl = 1;// 需要上传模板
  407. $tplTwo= 1;
  408. if (!in_array($examInfo->tpl_index,Yii::app()->params['no_template_id']) ) {
  409. $paperType = 1;
  410. if (empty($paperInfo->tpl_doc_src)) {
  411. $tpl = 2;
  412. }
  413. $tplTwo= 2;
  414. }else{
  415. $paperType = 2;
  416. }
  417. if(in_array($examInfo->tpl_index,Yii::app()->params['merge_topic_tpl']))
  418. {
  419. $tpl = 1;
  420. $paperType = 1;
  421. $tplTwo= 2;
  422. }
  423. if(in_array($examInfo->tpl_index, Yii::app()->params['custom_tpls_ids'])){
  424. $isCustomTpl = true;
  425. }
  426. else{
  427. $isCustomTpl = false;
  428. }
  429. // 获取阅卷类型
  430. $markType = 0;
  431. $groupInfo = $this->schoolManager->getExam($eid);
  432. if (!empty($groupInfo)) {
  433. $findInfo = SExamGroup::model()->find('exam_group_id=:eg_id',array('eg_id'=>$groupInfo['exam_group_id']));
  434. if (!empty($findInfo)) {
  435. $markType = $findInfo->mark_type;
  436. if($findInfo->mark_type==0 && $findInfo->is_third==1){
  437. $isUnderLine = 1;
  438. }
  439. }
  440. }
  441. $result = array();
  442. $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));
  443. //if (empty($relateStudent)) {
  444. // Yii::app()->jump->error('未找该试卷关联的学生!');
  445. //} else {
  446. //$studentModel = StudentInfo::model();
  447. // 获取学生姓名
  448. $_student_id = array();
  449. foreach($relateStudent as $v)
  450. {
  451. $_student_id[$v->student_id] = $v->student_id;
  452. }
  453. //if(!$_student_id)
  454. //{
  455. // Yii::app()->jump->error('未找该试卷关联的学生!');
  456. //}
  457. $b_student_arr = Yii::app()->redis_business_student->hgetAll('redis_business_del_student:'.$this->schoolId);
  458. if(!$b_student_arr ){
  459. $array_student = array();
  460. $b_student_arr = array();
  461. $criteria = new CDbCriteria();
  462. $criteria->select = 'student_id';
  463. $criteria->addCondition('school_id=:school_id');
  464. $criteria->addCondition('status=:status');
  465. $criteria->params[':school_id'] = $this->schoolId;
  466. $criteria->params[':status'] = 1;
  467. $b_student_data = BusinessStudent::model()->findAll($criteria);
  468. if($b_student_data){
  469. foreach ($b_student_data as $k=>$v){
  470. $array_student[$v->student_id] = $v->student_id;
  471. }
  472. }
  473. Yii::app()->redis_business_student->del('redis_business_del_student:'.$this->schoolId);
  474. if($array_student){
  475. Yii::app()->redis_business_student->hmset('redis_business_del_student:'.$this->schoolId,$array_student);
  476. Yii::app()->redis_business_student->expire('redis_business_del_student:'.$this->schoolId,1296000);
  477. }
  478. unset($criteria);
  479. if($b_student_data)
  480. {
  481. foreach($b_student_data as $v)
  482. {
  483. $b_student_arr[$v->student_id] = $v->student_id;
  484. }
  485. }
  486. unset($b_student_data);
  487. unset($criteria);
  488. }
  489. $studentNames = array();
  490. $criteria = new CDbCriteria();
  491. $criteria->addInCondition('student_id',$_student_id);
  492. $studentArray = SStudentInfo::model()->findAll($criteria);
  493. if (!empty($studentArray)) {
  494. foreach ($studentArray as $student) {
  495. $studentNames[$student->student_id] = $student->realname;
  496. }
  497. }
  498. //查询是否上传答题图片
  499. $uploadAnswerImgStudent=array();
  500. $student_answer_img=$this->schoolManager->getUpAnswerStudent($paperInfo->paper_id,$_student_id,0);
  501. if($student_answer_img){
  502. foreach ($student_answer_img as $val){
  503. $uploadAnswerImgStudent[(string)$val['student_id']]=$val['student_id'];
  504. }
  505. }
  506. foreach ($relateStudent as $key=>$val) {
  507. //查询学生身份证号
  508. $studentInfo=SStudentInfo::model()->find('student_id=:s_id',array('s_id'=>$val->student_id));
  509. if($studentInfo){
  510. $result[$key]['id_number'] = $studentInfo->id_number;
  511. }else{
  512. $result[$key]['id_number'] = '';
  513. }
  514. $result[$key]['student_card'] = $val['student_card'];
  515. $result[$key]['school_student_card'] = $val['school_student_card'];
  516. $result[$key]['upload_answer_img'] =0;
  517. if($val->is_feedback==1){
  518. $isFeedback=1;
  519. if(isset($uploadAnswerImgStudent[(string)$val->student_id])){
  520. $result[$key]['upload_answer_img'] =1;
  521. }
  522. }
  523. //查询在线答题卡是否生成
  524. $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();
  525. if($rs && $rs['answer_card_online_created']==1){
  526. $result[$key]['online_created'] = 1;
  527. }else{
  528. $result[$key]['online_created'] = 0;
  529. }
  530. if (empty($sname)) {
  531. $result[$key]['clazzName'] = $classInfo->class_name;
  532. $result[$key]['paperName'] = $examInfo->name;
  533. $result[$key]['studentCode'] = $val->student_id;
  534. $result[$key]['studentName'] = isset($studentNames[$val->student_id]) ? $studentNames[$val->student_id] : null;
  535. $result[$key]['is_feedback'] = $val->is_feedback;
  536. $result[$key]['student_img_paper'] = $val->student_img_paper;
  537. $result[$key]['is_complete'] = $val->is_complete;
  538. } else {
  539. if ($sname == $studentNames[$val->student_id]) {
  540. $result[$key]['clazzName'] = $classInfo->class_name;
  541. $result[$key]['paperName'] = $examInfo->name;
  542. $result[$key]['studentCode'] = $val->student_id;
  543. $result[$key]['studentName'] = $studentNames[$val->student_id];
  544. $result[$key]['is_feedback'] = $val->is_feedback;
  545. $result[$key]['student_img_paper'] = $val->student_img_paper;
  546. $result[$key]['is_complete'] = $val->is_complete;
  547. }else{
  548. unset($result[$key]);
  549. }
  550. unset($relateStudent[$key]);
  551. }
  552. $printCheck = true;
  553. }
  554. //}
  555. $no_paper_student = array();
  556. $paper_student_array = array();
  557. $c_paper_student_array = array();
  558. $class_student_info_data = array();
  559. $_student_ids = array();
  560. $_student_id_names = array();
  561. $class_student_data = $this->schoolManager->getClassStudentByClassId($cid); //student_class_relation
  562. if($class_student_data)
  563. {
  564. foreach($class_student_data as $v)
  565. {
  566. $_student_ids[$v['student_id']] = $v['student_id'];
  567. }
  568. $criteria = new CDbCriteria();
  569. $criteria->addInCondition('student_id',$_student_ids);
  570. $studentArray = SStudentInfo::model()->findAll($criteria);
  571. if (!empty($studentArray)) {
  572. foreach ($studentArray as $student) {
  573. $_student_id_names[$student->student_id] = $student->realname;
  574. }
  575. }
  576. }
  577. ///$class_student_info_data = $this->schoolManager->getClassStudentInfoByClassId($cid); //student_info
  578. $paper_student_data = $this->schoolManager->getClassPaperByClassAndPaper($cid,$paperInfo->paper_id,1);//已删除考试学生
  579. $c_paper_student_data = $this->schoolManager->getClassPaperByClassAndPaper($cid,$paperInfo->paper_id);//考试学生
  580. if ($paper_student_data) {
  581. foreach ($paper_student_data as $v) {
  582. $paper_student_array[$v['student_id']] = $v['student_id'];
  583. }
  584. $class_student_info_data = $this->schoolManager->getStudentByStudentIds($paper_student_array); //student_info
  585. }
  586. if ($c_paper_student_data) {
  587. foreach ($c_paper_student_data as $v) {
  588. $c_paper_student_array[$v['student_id']] = $v['student_id'];
  589. }
  590. //$class_student_info_data = $this->schoolManager->getStudentByStudentIds($paper_student_array); //student_info
  591. }
  592. if ($class_student_info_data) {
  593. foreach ($class_student_info_data as $v) {
  594. $class_student_info_array[$v['student_id']] = $v['realname'];
  595. }
  596. }
  597. if ($class_student_data) {
  598. foreach($class_student_data as $v)
  599. {
  600. if(!isset($b_student_arr[$v['student_id']]))
  601. {
  602. if ($paper_student_array)
  603. {
  604. if(isset($paper_student_array[$v['student_id']])){
  605. $no_paper_student[$v['student_id']] = array(
  606. 'student_id' => $v['student_id'],
  607. 'realname' => isset($class_student_info_array[$v['student_id']]) ?$class_student_info_array[$v['student_id']]:'',
  608. );
  609. }
  610. }
  611. if($c_paper_student_array )
  612. {
  613. if(!isset($c_paper_student_array[$v['student_id']]) )
  614. {
  615. $no_paper_student[$v['student_id']] = array(
  616. 'student_id' => $v['student_id'],
  617. 'realname' => isset($_student_id_names[$v['student_id']]) ?$_student_id_names[$v['student_id']]:'',
  618. );
  619. }
  620. }else
  621. {
  622. $no_paper_student[$v['student_id']] = array(
  623. 'student_id' => $v['student_id'],
  624. 'realname' => isset($_student_id_names[$v['student_id']]) ?$_student_id_names[$v['student_id']]:'',
  625. );
  626. }
  627. }
  628. }
  629. }
  630. //判断在线答题卡使用情况
  631. $useAnswerCardOnlineQrcode=0;
  632. $answerCardOnline=$this->schoolManager->getAnswerSheetOnline($groupInfo['exam_group_id']);
  633. if($answerCardOnline && $answerCardOnline['online_card']==1 && $answerCardOnline['is_qrcode_online']==1){
  634. $useAnswerCardOnlineQrcode=1;
  635. }
  636. $this->setIs_new($examInfo->exam_group_id);
  637. $data = array();
  638. if(isset($isUnderLine)){
  639. $data['under_line']=$isUnderLine;
  640. }
  641. //判断在线答题卡使用情况
  642. $answerCardOnline=$this->schoolManager->getAnswerSheetOnline($groupInfo['exam_group_id']);
  643. if($answerCardOnline && $answerCardOnline['online_card']==1 && $answerCardOnline['is_qrcode_online']==1){
  644. $data['use_answer_card_online_qrcode']=1;
  645. }else{
  646. $data['use_answer_card_online_qrcode']=0;
  647. }
  648. $_num= '';
  649. $use_version = '';
  650. if(isset(Yii::app()->session['coachInfo']->use_version))
  651. {
  652. $use_version = Yii::app()->session['coachInfo']->use_version;
  653. }else
  654. {
  655. $use_version = Yii::app()->session['coachInfo']['use_version'];
  656. }
  657. if(!$use_version)
  658. {
  659. $use_version = 100;
  660. }
  661. $version_number = implode('',explode('.',$use_version));
  662. if(strlen($version_number)<7)
  663. {
  664. for($i=0;$i<7-strlen($version_number);$i++)
  665. {
  666. $_num.='0';
  667. }
  668. }
  669. $version_number=(int)$version_number.$_num;
  670. $data['version_number']=$version_number;
  671. $data['no_paper_student'] = $no_paper_student;
  672. $data['result'] = $result;
  673. $data["printType"] = $printType;
  674. $data["sname"] = $sname;
  675. $data['paper_id'] = $paperInfo->paper_id;
  676. $data['exam_id'] = $eid;
  677. $data['class_id'] = $cid;
  678. $data['type_id'] = $tid;
  679. if(isset($this->schoolInfo->use_zhixue) && !empty($this->schoolInfo->use_zhixue))
  680. {
  681. $data["use_zhixue"] = $this->schoolInfo->use_zhixue;
  682. }else
  683. {
  684. $data["use_zhixue"] = 0;
  685. }
  686. // $subject_exam_data = $this->schoolManager->getxuekeStatus($this->semesterId);
  687. // $data["subject"] = $subject_exam_data;
  688. $data['wp_type'] = $examInfo->tpl_index;
  689. $data['className'] = $classInfo->class_name;
  690. $data['paperName'] = $examInfo->name;
  691. $data['tpl'] = $tpl;
  692. $data['tplTwo'] = $tplTwo;
  693. $data['markType'] = $markType;
  694. $data['examInfo'] = $examInfo;
  695. $data['paperType'] = $paperType;
  696. $data['answerCardUploaded'] = $answerCardUploaded;
  697. $data['paperData'] = $paperData;
  698. $data['isCustomTpl'] = $isCustomTpl;
  699. $data['isFeedback'] = $isFeedback;
  700. $data['printCheck'] = $printCheck;
  701. $data['useAnswerCardOnlineQrcode'] = $useAnswerCardOnlineQrcode;
  702. $this->render('change',$data);
  703. }
  704. public function actionSet_new()
  705. {
  706. $exam_group_id = Req::post("exam_group_id");
  707. if($exam_group_id>0)
  708. {
  709. $this->setIs_new($exam_group_id);
  710. }
  711. }
  712. // // 更新试卷在线答题卡打印状态、时间
  713. public function actionUpdateOnlinePaperPrintTime() {
  714. $exam_group_id = Req::post("eid");
  715. $thirdAnswerSheet=$this->sConn->createCommand("select multiplex_id from online_card_multiplex where exam_group_id='{$exam_group_id}' ")->queryRow();
  716. if($thirdAnswerSheet){
  717. $this->sConn->createCommand("update online_card_multiplex set is_download=1,update_time=".time()." where multiplex_id='{$thirdAnswerSheet['multiplex_id']}'")->execute();
  718. }
  719. }
  720. public function UUID_SHORT($length = 20)
  721. {
  722. $query = $this->sConn->createCommand("SELECT UUID_SHORT() AS UUID_SHORT")->query()->read();
  723. $result = $query['UUID_SHORT'];
  724. if ($length AND is_int($length))
  725. {
  726. $result = substr($result, ($length * -1));
  727. }
  728. return $result;
  729. }
  730. /*
  731. * 作业答题卡读取token
  732. * */
  733. public function actionGetCardUrl(){
  734. $homeworkId = Req::post("homeworkId");
  735. if(YII_ENV=='production'){
  736. $tokenUrl='https://tchr-cs.mgr.miaobikj.com/api/teacher/taskAssistant/token';
  737. $cardUrl='http://xbzy.schcur.com/#/assistant/exam-builder?taskId='.$homeworkId.'&schoolId='.$this->schoolId;
  738. }else{
  739. $tokenUrl='http://182.108.40.54:50100/curriculum-teacher-api-test/teacher/taskAssistant/token';
  740. $cardUrl='http://xbzy.testing.xiaoben.com/#/assistant/exam-builder?taskId='.$homeworkId.'&schoolId='.$this->schoolId;
  741. }
  742. $return=array('status'=>0,'data'=>'','msg'=>'');
  743. $curl = @curl_init();
  744. if ($curl) {
  745. curl_setopt($curl, CURLOPT_HEADER, 0);
  746. curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
  747. curl_setopt($curl, CURLOPT_TIMEOUT, 5);
  748. curl_setopt($curl, CURLOPT_URL, $tokenUrl);
  749. curl_setopt($curl, CURLOPT_POST, 1);
  750. curl_setopt($curl, CURLOPT_POSTFIELDS, '');
  751. curl_setopt($curl, CURLOPT_HTTPHEADER, array(
  752. 'Content-Type: application/json'
  753. ));
  754. if(substr($tokenUrl,0,5)=='https'){
  755. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false);
  756. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,false);
  757. }
  758. $response = curl_exec($curl);
  759. curl_close($curl);
  760. $result=json_decode($response,true);
  761. if(isset($result['code']) && $result['code']=='200'){
  762. $return['status']=1;
  763. $cardUrl.="&token=".$result['data'];
  764. $return['data']=$cardUrl;
  765. }else{
  766. if(isset($result['msg'])){
  767. $return['msg']=$result['msg'];
  768. }
  769. }
  770. }
  771. exit(json_encode($return));
  772. }
  773. }