增加标准分统计,修改成绩和一键统计
This commit is contained in:
1 parent
eb987f621e
commit
cc1e2961c6
9 files changed
+162
-21
No files matched your search
@@ -67,4 +67,45 @@ class Tongji extends AdminBase
|
||||
// 渲染模板
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
// 统计标准分
|
||||
public function biaoZhunFen()
|
||||
{
|
||||
// 获取参数
|
||||
$src = $this->request
|
||||
->only([
|
||||
'kaoshi_id' => 0
|
||||
,'ruxuenian'
|
||||
,'subject_id'
|
||||
], 'POST');
|
||||
|
||||
$tj = new TJ();
|
||||
if(isset($src['ruxuenian']) && isset($src['subject_id']))
|
||||
{
|
||||
$data = $tj->biaoZhunFen($src);
|
||||
}else{
|
||||
$ksset = new \app\kaoshi\model\KaoshiSet;
|
||||
|
||||
// 重新计算得分率
|
||||
$nj = $ksset->srcGrade($src); # 获取参考年级
|
||||
$jg = 1;
|
||||
foreach ($nj as $key => $value) { # 循环获取各年级参考学科
|
||||
$src['ruxuenian'] = $value['ruxuenian'];
|
||||
$manfen = $ksset->srcSubject($src); # 获取本年级各学科满分
|
||||
// 循环取出当前学科成绩
|
||||
foreach ($manfen as $mf_k => $mf_v) {
|
||||
$src['subject_id'] = $mf_v['id'];
|
||||
$data = $tj->biaoZhunFen($src);
|
||||
$jg = $jg * $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data ? $data = ['msg' => '完成', 'val' => 1]
|
||||
: $data = ['msg' => '数据处理错误', 'val' => 0];
|
||||
|
||||
// 返回信息
|
||||
return json($data);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,8 @@ class Chengji extends BaseModel
|
||||
,'xpaixu' => 'int'
|
||||
,'xweizhi' => 'decimal'
|
||||
,'qpaixu' => 'int'
|
||||
,'qweizhi' =>' decimal'
|
||||
,'qweizhi' => 'decimal'
|
||||
,'biaozhunfen' => 'decimal'
|
||||
,'create_time' =>'int'
|
||||
,'update_time' => 'int'
|
||||
,'delete_time' => 'int'
|
||||
|
||||
@@ -101,7 +101,6 @@ class Tongji extends BaseModel
|
||||
$temp['defenlv'] = round($temp['defenlv'] * 100, 2);
|
||||
$temp['canshilv'] = round($temp['chengji_cnt'] / $temp['stu_cnt'] * 100, 2);
|
||||
$temp['chashenglv'] = round(($temp['chengji_cnt'] - $temp['jige']) / $temp['chengji_cnt'] * 100, 2);
|
||||
|
||||
}
|
||||
$data['cj'][$value['lieming']] = $temp;
|
||||
}
|
||||
@@ -417,5 +416,68 @@ class Tongji extends BaseModel
|
||||
}
|
||||
|
||||
|
||||
// 计算标准分
|
||||
public function biaoZhunFen($srcfrom)
|
||||
{
|
||||
$src = [
|
||||
'kaoshi_id' => 0
|
||||
,'ruxuenian' => 0
|
||||
,'subject_id' => 0
|
||||
];
|
||||
// 用新值替换初始值
|
||||
$src = array_cover($srcfrom, $src);
|
||||
// $src =
|
||||
$cj = new \app\chengji\model\Chengji;
|
||||
$kh = new \app\kaohao\model\Kaohao;
|
||||
$ksset = new \app\kaoshi\model\KaoshiSet;
|
||||
$schTj = new \app\chengji\model\TongjiSch;
|
||||
|
||||
// 查询考号
|
||||
$kaohaoid = $kh->where('kaoshi_id', $src['kaoshi_id'])
|
||||
->where('ruxuenian', $src['ruxuenian'])
|
||||
->column('id');
|
||||
// 查询成绩
|
||||
$cjList = $cj->where('kaohao_id', 'in', $kaohaoid)
|
||||
->where('subject_id', $src['subject_id'])
|
||||
->whereNotNull('defen')
|
||||
->field('id, defen, defenlv')
|
||||
->select();
|
||||
// 查询全区(所有学生)标准差和平均分
|
||||
$schJg = $schTj->where('kaoshi_id', $src['kaoshi_id'])
|
||||
->where('ruxuenian', $src['ruxuenian'])
|
||||
->where('subject_id', $src['subject_id'])
|
||||
->whereNotNull('avg&biaozhuncha')
|
||||
->field('avg, biaozhuncha')
|
||||
->find();
|
||||
|
||||
$data = array();
|
||||
if ($schJg) {
|
||||
// $cha = $schJg->avg * 1 / $schJg->biaozhuncha * 1; # 平均分/标准分
|
||||
// $cha = round($cha, 2);
|
||||
|
||||
// 循环写入新成绩
|
||||
foreach ($cjList as $cj_k => $cj_v) {
|
||||
$bzf = ($cj_v->defen - $schJg->avg * 1) / ($schJg->biaozhuncha * 1); #计算标准分
|
||||
$bzf = round($bzf, 2); # 取两位小数
|
||||
$data[] = [
|
||||
'id' => $cj_v->id
|
||||
,'biaozhunfen' => $bzf
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$cnt = count($data);
|
||||
$data = $cj->saveAll($data)->count();
|
||||
if($cnt == $data)
|
||||
{
|
||||
$data = 1;
|
||||
}else{
|
||||
$data = 0;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loaded 3 of 9 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user