JuniorController.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. class JuniorController extends Controller
  3. {
  4. //产品班级页
  5. public function actionProduct()
  6. {
  7. $grade = Req::get("grade");
  8. $classId = Req::get("classId");
  9. $name = Req::get("name");
  10. $type = Req::get("type");
  11. if(!$type) self::responseMsg(0, '参数错误');
  12. $condition = array();
  13. if($name) $condition[] = "e.name like '%{$name}%'";
  14. if($grade) $condition[] = "c.grade = '{$grade}'";
  15. if($classId) $condition[] = "e.class_id = '{$classId}'";
  16. $condition[] = "eg.create_type in (0,1,2,3,5,6) and is_labelled=1 and cep.type={$type}";
  17. if (empty($grade)) {
  18. $grade = 'ALL';
  19. }
  20. $examProduct = new SExamProductStatus();
  21. $resultList = $examProduct->getProductList($condition,array('e.create_time desc'), $type);
  22. $printList = array();
  23. $desc = $type == 1 ? '错题本': '个性化学习宝';
  24. if($resultList["rs"]){
  25. foreach ($resultList['rs'] as $k=>$v) {
  26. $printList[$k] = $v;
  27. $printList[$k]['print_name'] = $v["exam_name"]. $desc;
  28. $printList[$k]['is_cloud_print'] = Yii::app()->cache->getValue(sprintf("cloud_print_task:%s:%s:%s:%s", $this->schoolId,$v['class_id'],$v['exam_id'],$type)) ? 1 : 0;
  29. }
  30. }
  31. $grade_class_array = array();
  32. if($grade) {
  33. $grade_class_data = $this->sConn->createCommand("select class_id,class_name from class where grade='{$grade}' and semester_id='{$this->semesterId}'")->queryAll();
  34. if ($grade_class_data) {
  35. foreach ($grade_class_data as $v) {
  36. $grade_class_array[$v['class_id']] = $v;
  37. }
  38. }
  39. }
  40. $data = array();
  41. $data['printList'] = $printList;
  42. $data['pages'] = $resultList['pager'];
  43. $data['page_total'] = $resultList['pager']->rowsCount;
  44. $data["printName"] = $name;
  45. $data["classes"] = $grade_class_array;
  46. $data["classId"] = $classId;
  47. $data["grade"] = $grade;
  48. $data['subjectId']=$this->subjectId;
  49. $data['type'] = $type;
  50. $data['desc'] = $desc;
  51. unset($resultList);
  52. $this->render('product',$data);
  53. }
  54. //产品学生页面
  55. public function actionProduct_stu(){
  56. $data = array();
  57. $sname = (string)Req::get("sname"); //学生名字
  58. $type = (int)Req::get("type"); //产品类型
  59. $examId = (string)Req::get("eid");
  60. $classId = (string)Req::get("cid");
  61. if(!$examId || !$classId || !$type){
  62. Yii::app()->jump->error('参数错误!');
  63. }
  64. //获取班级名称以及考试名称
  65. $sql = "select e.name,c.class_name,c.grade,e.class_id,p.add_time,e.semester_id from exam e join class_exam_printer p on p.exam_id=e.exam_id
  66. join class c on e.class_id = c.class_id where e.class_id = '{$classId}' and e.exam_id = '{$examId}'";
  67. $names = $this->sConn->createCommand($sql)->queryRow();
  68. if(!$names){
  69. $names = array();
  70. $names['name'] = '';
  71. $names['class_name'] = '';
  72. $names['grade'] = 0;
  73. }else{
  74. $data['name'] = isset($names['name']) && isset($names['class_name'])?$names['class_name'].$names['name']:'';
  75. }
  76. $sql = "select student_id,is_create_pdf from exam_product_status where product_type ='{$type}' and exam_id = '{$examId}'";
  77. $relateStudent = $this->sConn->createCommand($sql)->queryAll();
  78. $studentIds = array();
  79. $stuIsPdf = array();
  80. if($relateStudent){
  81. foreach ($relateStudent as $studentInfo) {
  82. $stuIsPdf[(string)$studentInfo['student_id']] = $studentInfo['is_create_pdf'];
  83. }
  84. }
  85. $allStudent = SStudentClassRelation::model()->getStudentInfoByClassId($classId, $sname);
  86. $i = 1;
  87. foreach ($allStudent as $v) {
  88. $studentIds[] = (string)$v['student_id'];
  89. $data['list'][$i]['stu_id'] = (string)$v['student_id'];
  90. $data['list'][$i]['stu_name'] = $v['realname'];
  91. $data['list'][$i]['name'] = $names['class_name'] . $names['name'];
  92. $data['list'][$i]['is_pdf'] = isset($stuIsPdf[(string)$v['student_id']]) ? $stuIsPdf[(string)$v['student_id']] : 0;
  93. $i++;
  94. }
  95. $Sem=new SSemester();
  96. $code= $Sem->conn->createQuery()
  97. ->from('semester')
  98. ->where("semester_id = '".$names['semester_id']."'")
  99. ->limit(1)
  100. ->query()
  101. ->read();
  102. $intarr=array(
  103. "schoolId"=>$this->schoolId,
  104. "clazzId"=>$names['class_id'],
  105. "semester"=>$code['refer_code'],
  106. "grade"=>$names['grade'],
  107. "students"=>$studentIds,
  108. "examTime"=>$names['add_time'],
  109. "classify"=>$type,
  110. "subject"=>$this->subjectId
  111. );
  112. $basic = imsBasicAuth($this->schoolId.'_'.Yii::app()->session['coachInfo']['coach_name'],Yii::app()->params["zsy_api_key"]);
  113. $rs = json_decode(Curl::http_post_Basic_json(Yii::app()->params["get_limit_url"], json_encode($intarr),$basic));
  114. //TODO 订单
  115. // if(!$rs){
  116. // Yii::app()->jump->error("接口错误");
  117. // }
  118. // if($rs->errCode!="00"){
  119. // Yii::app()->jump->error($rs->errMsg);
  120. // }
  121. if(!empty($rs->data)){
  122. $data['limitstu']=$rs->data;
  123. }
  124. $data['examId'] = $examId;
  125. $data['classId'] = $classId;
  126. $data['sname'] = $sname;
  127. $data['type'] = $type;
  128. $data['desc'] = $type == 1 ? '错题本': '个性化学习宝';
  129. $this->render('product_stu',$data);
  130. }
  131. //FIXME 教师讲案
  132. public function actionTeach(){
  133. $this->layout = false;
  134. set_time_limit (300);
  135. ini_set('memory_limit', '300M');
  136. $examId = (string)Req::get("examId");
  137. $isWb = Req::get("isWb");
  138. require_once('TeachingJunior.php');
  139. $teachingPhysicsObj = new TeachingJunior($this);
  140. $result = $teachingPhysicsObj->getTeachingPdf($this->schoolId, $examId, 1, 1, $isWb);
  141. $result['pdf_path'] = '';
  142. echo json_encode($result);
  143. exit();
  144. }
  145. }