ThirdAnswerSheet.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. class ThirdAnswerSheet extends AssistModel
  3. {
  4. public function getDb($dsn,$user,$pwd){
  5. $my_connection = new CDbConnection($dsn,$user,$pwd);
  6. $my_connection->emulatePrepare = true;
  7. $my_connection->enableProfiling = true;
  8. $my_connection->enableParamLogging = true;
  9. $myDbDsn = null;
  10. return $my_connection;
  11. }
  12. public function tableName()
  13. {
  14. return '{{third_answer_sheet}}';
  15. }
  16. public function getDetail($dsn,$user,$pwd,$eid){
  17. $db=$this->getDb($dsn,$user,$pwd);
  18. $data=array(
  19. 'answer_card'=>0,
  20. 'paper'=>0,
  21. 'parse'=>0
  22. );
  23. $thirdPaper=$db->createCommand("select topic_upload,answer_upload,template_type from third_multi_template where exam_group_id='".$eid."'")->queryAll();
  24. if($thirdPaper){
  25. foreach ($thirdPaper as $item){
  26. if($item['template_type']==1 && $item['topic_upload']==1){
  27. $data['paper']=1;
  28. }
  29. if($item['template_type']==2 && $item['answer_upload']==1){
  30. $data['parse']=1;
  31. }
  32. }
  33. }
  34. //查询答题卡
  35. $thirdCard=$db->createCommand("select sheet_id from third_answer_sheet where exam_group_id='".$eid."'")->queryRow();
  36. if($thirdCard){
  37. $data['answer_card']=1;
  38. }
  39. return $data;
  40. }
  41. public function getTemplate($dsn,$user,$pwd,$eid){
  42. $db=$this->getDb($dsn,$user,$pwd);
  43. $data['paper_template']=0;
  44. $data['parse_template']=0;
  45. $thirdPaper=$db->createCommand("select template_id,template_type from third_multi_template where exam_group_id='".$eid."'")->queryAll();
  46. if($thirdPaper){
  47. foreach ($thirdPaper as $item){
  48. if($item['template_type']==1){
  49. $data['paper_template']=$item['template_id'];
  50. }
  51. if($item['template_type']==2){
  52. $data['parse_template']=$item['template_id'];
  53. }
  54. }
  55. }
  56. return $data;
  57. }
  58. //读取考试信息
  59. public function getExamTplData($dsn,$user,$pwd,$eid){
  60. $db=$this->getDb($dsn,$user,$pwd);
  61. $tpl_data=$db->createCommand("select tpl_data from exam where exam_group_id='".$eid."'")->queryRow();
  62. return $tpl_data['tpl_data'];
  63. }
  64. //读取答题卡
  65. public function getAnswerSheet($dsn,$user,$pwd,$eid){
  66. $db=$this->getDb($dsn,$user,$pwd);
  67. $thirdCard=$db->createCommand("select sheet_id from third_answer_sheet where exam_group_id='".$eid."'")->queryRow();
  68. if($thirdCard){
  69. return $thirdCard['sheet_id'];
  70. }
  71. return 0;
  72. }
  73. }