ArticleRecordAnswer.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\App;
  6. use think\Db;
  7. use think\exception\Handle;
  8. class ArticleRecordAnswer extends Base
  9. {
  10. public function __construct(App $app = null) {
  11. parent::__construct($app);
  12. }
  13. public function answerSheet()
  14. {
  15. $recordId=input('recordId');
  16. $ret=Db::name('article_record_answer')
  17. ->field('article_record_id,article_question_id,answer as user_answer')
  18. ->where('article_record_id',$recordId)
  19. ->select();
  20. foreach ($ret as $k=>$val){
  21. $question=Db::name('article_question')
  22. ->field('article_paper_id,options,score,title,type')
  23. ->where('id',$val['article_question_id'])
  24. ->find();
  25. $ret[$k]['article_paper_id']=$question?$question['article_paper_id']:'';
  26. $ret[$k]['options']=$question?$question['options']:'';
  27. $ret[$k]['score']=$question?$question['score']:'';
  28. $ret[$k]['title']=$question?$question['title']:'';
  29. $ret[$k]['type']=$question?$question['type']:'';
  30. }
  31. if($ret){
  32. HelpHander::success($ret);
  33. }else{
  34. HelpHander::error('暂无数据');
  35. }
  36. }
  37. }