SStudentPaperRelation.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * @author: CeeFee
  4. * @description: 班级
  5. */
  6. class SStudentPaperRelation extends MyActiveRecord
  7. {
  8. public static function model($className = __CLASS__)
  9. {
  10. return parent::model($className);
  11. }
  12. public function tableName()
  13. {
  14. return 'student_paper_relation';
  15. }
  16. public function getRelationsByClassId_PaperId($classId, $paperId)
  17. {
  18. $result = array();
  19. if ($classId AND is_numeric($classId) AND $paperId AND is_numeric($paperId))
  20. {
  21. $criteria = new CDbCriteria();
  22. $criteria->addCondition("class_id = '". $classId ."' AND paper_id = '". $paperId ."'");
  23. $result = getAttributes($this->findAll($criteria));
  24. }
  25. return $result;
  26. }
  27. public function getStudentIdsByClassId_PaperId($classId, $paperId)
  28. {
  29. $relations = $this->getRelationsByClassId_PaperId($classId, $paperId);
  30. $result = array();
  31. if ($relations)
  32. {
  33. foreach ($relations AS $relation)
  34. {
  35. $result[] = $relation['student_id'];
  36. }
  37. }
  38. return $result ? array_unique($result) : $result;
  39. }
  40. /**
  41. * 获取试卷题信息
  42. * @param $examIds
  43. * @return array|CDbDataReader
  44. */
  45. public function getStudentExamInfo($examIds){
  46. $info = array();
  47. if($examIds){
  48. $sql = "select student_id,is_del,paper_id,exam_id,scoring,is_feedback,is_three_isp_download,is_two_isp_download from ".$this->tableName()." where exam_id in (".implode(',',$examIds).") ";
  49. $info = $this->getCommandBuilder()->createSqlCommand($sql)->queryAll();
  50. if($info){
  51. return $info;
  52. }
  53. }
  54. return $info;
  55. }
  56. /**
  57. * 获取试卷题信息
  58. * @param $examIds
  59. * @return array|CDbDataReader
  60. */
  61. public function getStudentFeedBack($examIds){
  62. if($examIds){
  63. $sql = "select is_feedback from ".$this->tableName()." where exam_id in (".implode(',',$examIds).") and is_feedback=1 limit 1";
  64. $info = $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
  65. if($info){
  66. return true;
  67. }
  68. }
  69. return false;
  70. }
  71. }