<?php /** * 更新错误的得分数据 */ namespace Frontend\Controller\Temp; use Common\Model\AnswerDetailModel; use Common\Service\AnswerService; use Common\Service\PaperService; use Think\Exception; class UpdateScoreController extends AbstractController { public function before_action($action = '') { if (!parent::before_action($action)) { return false; } return true; } public function Index() { set_time_limit(0); $ep_id = I('get.ep_id', 0, 'intval'); // 非空判断 if (empty($ep_id)) { return true; } $paper = new PaperService(); // 获取试卷基本详情 $data = $paper->get($ep_id); if (empty($data)) { return true; } $answer = new AnswerService(); // 查询得分为0并且已阅卷的答题列表 $answer_list = $answer->list_by_conds(array('my_score' => 0, 'answer_status' => 3, 'ep_id' => $ep_id)); $answer_detail_m = new AnswerDetailModel(); foreach ($answer_list as $v) { // 计算已批阅的总分 $score_conds = array( 'ea_id' => $v['ea_id'], 'marking_status' => 1 ); // 考试得分 $my_score = $answer_detail_m->get_score($score_conds); if($my_score==0){ continue; } // 及格分大于得分 if ($data['pass_score'] > $my_score) { // 不通过 $my_is_pass = 0; } else { // 通过 $my_is_pass = 1; } // 追加答卷表待更新数据 $read_data['my_score'] = $my_score; $read_data['my_is_pass'] = $my_is_pass; $answer->update($v['ea_id'], $read_data); } return true; } }