UpdateScoreController.class.php
1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?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;
}
}