SEnglishWritingMarking.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. class SEnglishWritingMarking extends MyActiveRecord
  3. {
  4. public static function model($className = __CLASS__)
  5. {
  6. return parent::model($className);
  7. }
  8. public function tableName()
  9. {
  10. return 'english_writing_marking';
  11. }
  12. public function getMarkingCount($ewId)
  13. {
  14. $sql = "select count(distinct student_id) as count from english_writing_marking where ew_id={$ewId};";
  15. $connect = $this->getDbConnection();
  16. $rs = $connect->createCommand($sql)->queryRow();
  17. $markCount= isset($rs['count']) ? $rs['count'] : 0;
  18. return $markCount;
  19. }
  20. public function getStuMarkingStatus($studentIds, $ewId)
  21. {
  22. $result = array();
  23. if ($studentIds) {
  24. $sql = "select distinct m.student_id from english_writing_marking m where m.ew_id={$ewId} and m.student_id IN (" . implode(',', $studentIds) . ")";
  25. $connect = $this->getDbConnection();
  26. $rs = $connect->createCommand($sql)->queryAll();
  27. if ($rs) {
  28. foreach ($rs as $item) {
  29. $result[$item['student_id']] = 1;
  30. }
  31. }
  32. }
  33. return $result;
  34. }
  35. /**
  36. * 获取班级学生写作宝统计表格数据
  37. * @param $ewId
  38. * @return array
  39. * @throws CException
  40. */
  41. public function getStudentRateList($ewId)
  42. {
  43. $result = array();
  44. $sql = "select m.ocr_text,s.realname
  45. from english_writing_marking m inner join student_info s on m.student_id=s.student_id
  46. where ew_id='{$ewId}';";
  47. $connect = $this->getDbConnection();
  48. $rs = $connect->createCommand($sql)->queryAll();
  49. $studentInfo = array();
  50. if ($rs) {
  51. foreach ($rs as $item) {
  52. $text = json_decode($item['ocr_text'],true);
  53. $studentInfo['score'] = isset($text['total_score']) ? $text['total_score'] : 0;
  54. $studentInfo['student_name'] = $item['realname'];
  55. $studentInfo['composition_ocr'] = isset($text['compositon_ocr'])? $text['compositon_ocr'] : '';
  56. array_push($result, $studentInfo);
  57. }
  58. }
  59. if($result) {
  60. $rate = _array_column($result, 'score');
  61. array_multisort($rate, SORT_DESC, $result);
  62. }
  63. return $result;
  64. }
  65. }