修改成绩统计数据模型

This commit is contained in:
cxdbz committed 2019-06-15 09:12:41 +08:00
1 parent 8542901614
commit e8fee110f3
4 files changed
+38 -16

No files matched your search

+1 -1
View File
@@ -625,7 +625,7 @@ class Index extends Base
->only([
'page'=>'1',
'limit'=>'10',
'field'=>'banji',
'field'=>'subject_id',
'type'=>'desc',
'kaohao'=>''
],'POST');
+35 -14
View File
@@ -82,7 +82,15 @@ class Tongji extends Model
// 统计成绩
/**
* 统计全样本成绩
* 包括:数量、合计、标准差、平均、优秀、及格、四分位
* 全科及格率、全科平均分
* @access public
* @param array $cj 成绩
* @param number $kaoshi 考试ID
* @return array 返回类型
*/
public function tongji($cj=array(),$kaoshi)
{
@@ -92,20 +100,9 @@ class Tongji extends Model
->with('ksSubject')
->find();
$data = array();
$allcj = array();
foreach ($ksinfo->ks_subject as $key => $value) {
$cjcol = array_column($cj,$value->lieming);
$allcj = array_merge($allcj,$cjcol);
$temp = array();
$temp['cnt'] = count($cjcol);
$temp['sum'] = array_sum($cjcol);
$temp['cnt']>0 ? $temp['avg'] = $temp['sum']/$temp['cnt'] : $temp['avg']=0;
$temp['biaozhuncha'] = round($this->getVariance($temp['avg'], $cjcol,true),2);
$temp['avg'] = round($temp['avg'],2);
$temp['youxiu'] = $this->rate($cjcol,$value->youxiu);
$temp['jige'] = $this->rate($cjcol,$value->jige);
$temp['sifenwei'] = $this->quartile($cjcol);
$data[$value->lieming] = $temp;
$data[$value->lieming] = $this->tj($cjcol,$value->youxiu,$value->jige);
}
$cjcol = array_column($cj,'sum');
$data['cnt'] = count($cjcol);
@@ -121,6 +118,30 @@ class Tongji extends Model
}
/**
* 统计给定一维数组的成绩
* 包括:数量、合计、标准差、平均、优秀、及格、四分位
* @access public
* @param array $cj 成绩
* @param number $youxiu 优秀分数线
* @param number $jige 优秀分数线
* @return array 返回类型
*/
public function tj($cj=array(),$youxiu,$jige)
{
$temp = array();
$temp['cnt'] = count($cj);
$temp['sum'] = array_sum($cj);
$temp['cnt']>0 ? $temp['avg'] = $temp['sum']/$temp['cnt'] : $temp['avg']=0;
$temp['biaozhuncha'] = round($this->getVariance($temp['avg'], $cj,true),2);
$temp['avg'] = round($temp['avg'],2);
$temp['youxiu'] = $this->rate($cj,$youxiu);
$temp['jige'] = $this->rate($cj,$jige);
$temp['sifenwei'] = $this->quartile($cj);
return $temp;
}
// 统计优秀、及格率
public function rate($cj = array(),$fenshuxian)
{
@@ -180,7 +201,7 @@ class Tongji extends Model
* @param Array $list
* @param Boolen $isSwatch
* @return unknown type
*/
*/
public static function getVariance($avg, $list, $isSwatch = FALSE) {
$arrayCount = count($list);
if($arrayCount == 1 && $isSwatch == TRUE){
@@ -58,6 +58,7 @@
}
return str;
}},
{field: 'update_time', title: '更新时间 ', minWidth:100,sort: true},
{field: 'id', title: '操作',toolbar: '#barDemo',minWidth:140}
]];
options.url = "{:url('ajaxaddinfo')}";
Loaded 3 of 4 files, more files were not shown because too many files have changed in this diff. Show more