增加单位中项目字段

This commit is contained in:
小松树 committed 2019-06-17 09:06:26 +08:00
1 parent cde37e905d
commit 65e8460b59
10 files changed
+119 -45

No files matched your search

+1 -1
View File
@@ -625,7 +625,7 @@ class Index extends Base
->only([
'page'=>'1',
'limit'=>'10',
'field'=>'subject_id',
'field'=>'banji',
'type'=>'desc',
'kaohao'=>''
],'POST');
+88
View File
@@ -15,6 +15,94 @@ class Chengji extends Base
return $this->belongsTo('\app\teach\model\Subject');
}
// /**
// * 根据考试ID和班级获取学生各学科成绩、平均分、总分
// *
// * @access public
// * @param mixed $kaoshi 当前考试ID
// * @param array $banji 学生所在班级
// * @return array 返回类型
// */
// public function srcChengji($kaoshi=0,$banji=array())
// {
// $kh = new \app\kaoshi\model\Kaohao;
// $khlist = $kh->where('kaoshi',$kaoshi)
// ->field('id,school,student,nianji,banji')
// ->when(count($banji)>0,function($query) use($banji){
// $query->where('banji','in',$banji);
// })
// ->with([
// 'ksChengji'=>function($query){
// $query->field('kaohao_id,subject_id,defen');
// }
// ,'cjBanji'=>function($query){
// $query->field('id,paixu,ruxuenian')
// ->append(['numTitle','banjiTitle']);
// }
// ,'cjSchool'=>function($query){
// $query->field('id,jiancheng');
// }
// ,'cjStudent'=>function($query){
// $query->field('id,xingming,sex');
// }
// ])
// ->select();
// // 获取参考学科
// $ks = new \app\kaoshi\model\Kaoshi;
// $ksinfo = $ks->where('id',$kaoshi)
// ->with([
// 'ksSubject'=>function($query){
// $query->field('kaoshiid,subjectid,lieming');
// }
// ])
// ->find();
// $xk = array();
// foreach ($ksinfo->ks_subject as $key => $value) {
// $xk[$value->subjectid] = $value->lieming;
// }
// // 整理数据
// $data = array();
// foreach ($khlist as $key => $value) {
// $data[$key]['id'] = $value->id;
// $data[$key]['school'] = $value->cj_school->jiancheng;
// if(isset($value->cj_student)){
// $data[$key]['student'] = $value->cj_student->xingming;
// $data[$key]['sex'] = $value->cj_student->sex;
// }else{
// $stu = new \app\renshi\model\Student;
// $stuname = $stu::withTrashed()->where('id',$value->student)->field('id,xingming,sex')->find();
// $data[$key]['student'] = $stuname->xingming;
// $data[$key]['sex'] = $stuname->sex;
// }
// $data[$key]['nianji'] = $value->nianji;
// $data[$key]['banji'] = $value->cj_banji->banji_title;
// $dfsum = 0;
// $sbjcnt = 0;
// foreach ($value->ks_chengji as $k => $val) {
// $data[$key][$xk[$val->subject_id]] = $val->defen*1;
// $dfsum = $dfsum + $val->defen*1;
// $sbjcnt ++;
// }
// $data[$key]['sum'] = $dfsum;
// if($sbjcnt>0){
// $data[$key]['avg'] = round($dfsum/$sbjcnt,1);
// }else{
// $data[$key]['avg'] = 0;
// }
// }
// // // 按条件排序
// // if(count($data)>0){
// // $data = arraySequence($data,$src['field'],$src['type']); //排序
// // }
// return $data;
// }
// 学科关联
public function subjectName()
{
+14 -35
View File
@@ -82,15 +82,7 @@ class Tongji extends Model
/**
* 统计全样本成绩
* 包括:数量、合计、标准差、平均、优秀、及格、四分位
* 全科及格率、全科平均分
* @access public
* @param array $cj 成绩
* @param number $kaoshi 考试ID
* @return array 返回类型
*/
// 统计成绩
public function tongji($cj=array(),$kaoshi)
{
@@ -100,9 +92,20 @@ class Tongji extends Model
->with('ksSubject')
->find();
$data = array();
$allcj = array();
foreach ($ksinfo->ks_subject as $key => $value) {
$cjcol = array_column($cj,$value->lieming);
$data[$value->lieming] = $this->tj($cjcol,$value->youxiu,$value->jige);
$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;
}
$cjcol = array_column($cj,'sum');
$data['cnt'] = count($cjcol);
@@ -118,30 +121,6 @@ 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)
{
@@ -201,7 +180,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){
Loaded 3 of 10 files, more files were not shown because too many files have changed in this diff. Show more