diff --git a/app/chengji/common.php b/app/chengji/common.php index d4b4c7b1..2d54210f 100644 --- a/app/chengji/common.php +++ b/app/chengji/common.php @@ -46,14 +46,14 @@ function manfenvalidate($defen,$manfen) - /** + /** * 从统计结果中获取条形统计图中需要的各项目成绩 - * - * @access public + * + * @access public * @param arr 统计结果 * @param xm 要统计的项目 * @return array 返回类型 - */ + */ function tiaoxingOnexiangmu($jg,$xm) { $chengji = array(); @@ -88,17 +88,17 @@ function manfenvalidate($defen,$manfen) } - /** + /** * 从统计结果中获取条形箱体图需要的各项目成绩 - * - * @access public + * + * @access public * @param arr 统计结果 * @param xm 要统计的项目 * @return array 返回类型 - */ + */ function xiangti($jg) { - + $data = array(); $axisData = array(); $chengji = array(); @@ -113,12 +113,6 @@ function manfenvalidate($defen,$manfen) } foreach ($value['chengji'] as $k => $val) { - // $chengji[$k][$key]['min'] = $val['sifenwei']['min']; - // $chengji[$k][$key]['q1'] = $val['sifenwei']['q1']; - // $chengji[$k][$key]['q2'] = $val['sifenwei']['q2']; - // $chengji[$k][$key]['q3'] = $val['sifenwei']['q3']; - // $chengji[$k][$key]['max'] = $val['sifenwei']['max']; - $chengji[$k][$key][0] = $val['sifenwei']['min']; $chengji[$k][$key][1] = $val['sifenwei']['q1']; $chengji[$k][$key][2] = $val['sifenwei']['q2']; @@ -146,12 +140,12 @@ function manfenvalidate($defen,$manfen) return $data; } - /** + /** * 把给定的成绩进行排序 - * @access public + * @access public * @param array $arr 要计算的一维数组成绩 * @return array $result 返回成绩排序结果 - */ + */ function tjOrder($cj,$type = 'desc') { if($type == 'desc') @@ -162,4 +156,4 @@ function manfenvalidate($defen,$manfen) } return $cj; - } \ No newline at end of file + } diff --git a/app/chengji/model/Chengji.php b/app/chengji/model/Chengji.php index 85fa2f51..2fdb1541 100644 --- a/app/chengji/model/Chengji.php +++ b/app/chengji/model/Chengji.php @@ -194,7 +194,7 @@ class Chengji extends Base { $data[$key][$col[0]] = $data[$key-1][$col[0]]; } - $data[$key][$col[1]] = ($data[$key][$col[0]]-1)/$cnt; + $data[$key][$col[1]] = 1 - ($data[$key][$col[0]]-1)/$cnt; $data[$key][$col[1]] = round($data[$key][$col[1]] * 100 , 2) ; } diff --git a/app/chengji/model/Tongji.php b/app/chengji/model/Tongji.php index ec682ee4..afee7c25 100644 --- a/app/chengji/model/Tongji.php +++ b/app/chengji/model/Tongji.php @@ -10,7 +10,7 @@ class Tongji extends Base // 统计成绩 public function tongjiCnt($cj=array(),$subject) - { + { $data = array(); // 循环统计各学科成绩 @@ -26,7 +26,7 @@ class Tongji extends Base } $data['stucnt'] = count($cj); - + return $data; } @@ -35,8 +35,8 @@ class Tongji extends Base // 统计成绩 public function tongjiSubject($cj=array(),$subject) - { - + { + // 设置默认值 $tempNull = [ 'xkcnt'=>0, @@ -66,7 +66,7 @@ class Tongji extends Base $cjcol = array_column($cj,$value['lieming']); $stucnt = count($cjcol); $cjcol = array_filter($cjcol,function($item){ - return $item !== null; + return $item !== null; }); $temp = $tempNull; @@ -100,7 +100,7 @@ class Tongji extends Base $cjcol = array_column($cj,'sum'); $stucnt = count($cjcol); $cjcol = array_filter($cjcol,function($item){ - return $item !== null; + return $item !== null; }); $temp['id'] = 0; $temp['stucnt'] = $stucnt; @@ -207,12 +207,12 @@ class Tongji extends Base } - /** + /** * 计算四分位( Quartile ) Q1、Q2、Q3的值 - * @access public + * @access public * @param array $arr 要计算的一维数组 * @return array $result 下标0-2 分别对应Q1、Q2、Q3 - */ + */ public function myquartile($arr) { // 获取数组长度 @@ -221,7 +221,7 @@ class Tongji extends Base // 如果数组为空或数组长度小于5时,返回空。 if ($arr == null || $length == 0) return $result = [0=>'',1=>'',2=>'']; if ($length < 5) return $result = [0=>'',1=>'',2=>'']; - + // 数组排序 sort($arr); @@ -246,7 +246,7 @@ class Tongji extends Base { $result[$key] = $arr[$value-1]; }else{ - # 如果位置不是整数。计算公式:大数*位置小数 + 小数*(1-位置小数) + # 如果位置不是整数。计算公式:大数*位置小数 + 小数*(1-位置小数) $tempNum = $value; $temp = intval($tempNum); $tempNum = $tempNum - $temp; @@ -257,5 +257,5 @@ class Tongji extends Base return $result; } - + } diff --git a/app/chengji/model/TongjiBj.php b/app/chengji/model/TongjiBj.php index 71a9a8a5..cc8d6f96 100644 --- a/app/chengji/model/TongjiBj.php +++ b/app/chengji/model/TongjiBj.php @@ -284,6 +284,73 @@ class TongjiBj extends Base } + /** + * 查询班级历次成绩 + */ + public function srcBanjiChengji($srcfrom) + { + // 初始化参数 + $src = array( + 'banji' => '', + 'category' => '', + 'xueqi' => '', + ); + + // 用新值替换初始值 + $src = array_cover( $srcfrom , $src ) ; + $src['xueqi'] = strToarray($src['xueqi']); + $src['category'] = strToarray($src['category']); + + if(isset($srcfrom['bfdate']) && strlen($srcfrom['bfdate'])>0) + { + $src['bfdate'] = $srcfrom['bfdate']; + }else{ + $src['bfdate'] = date("Y-m-d",strtotime("-1 year")); + } + + if(isset($srcfrom['enddate']) && strlen($srcfrom['enddate'])>0) + { + $src['enddate'] = $srcfrom['enddate']; + }else{ + $src['enddate'] = date("Y-m-d",strtotime("+1 day")); + } + + + $data = $this + ->where('banji_id',$src['banji']) + ->where('kaoshi_id','in',function($query) use($src){ + $query->name('kaoshi') + ->whereTime('bfdate|enddate','between',[ $src['bfdate'],$src['enddate'] ]) + ->when(count($src['xueqi']) > 0, function($q) use($src){ + $q->where('xueqi', 'in', function($w) use($src){ + $w->name('xueqi') + ->where('category', 'in', $src['xueqi']) + ->field('id'); + }); + }) + ->when(count($src['category']) > 0, function($q) use($src){ + $q->where('category', 'in', $src['category']); + }) + ->field('id'); + }) + ->with([ + 'bjKaoshi' => function($query){ + $query->field('id,title,bfdate'); + }, + 'bjSubject' => function($query){ + $query->field('id,title,jiancheng,paixu,lieming'); + }, + 'quJieguo' => function($query){ + $query->field('id,kaoshi_id,subject_id,defenlv'); + } + ]) + ->select(); + + return $data; + } + + + // 成绩排序 public function bjOrder($kaoshi) { @@ -353,6 +420,15 @@ class TongjiBj extends Base } + // 区成绩统计结果关联 + public function quJieguo() + { + $sbjid = $this->getAttr('subject_id'); + return $this->belongsTo('\app\chengji\model\TongjiSch','kaoshi_id','kaoshi_id') + ->where('subject_id',$sbjid); + } + + // 获取班级名称 public function getBanjiTitleAttr() { @@ -367,5 +443,4 @@ class TongjiBj extends Base } - } diff --git a/app/kaoshi/controller/Kaohao.php b/app/kaoshi/controller/Kaohao.php index ef5b2a69..6e7ceed6 100644 --- a/app/kaoshi/controller/Kaohao.php +++ b/app/kaoshi/controller/Kaohao.php @@ -40,8 +40,6 @@ class Kaohao extends BaseController 'kaoshi'=>$kaoshi ); - - // 模板赋值 $this->view->assign('list',$list); // 渲染 diff --git a/app/login/view/index/shangma_log.html b/app/login/view/index/shangma_log.html index 3f0a150f..7bb58338 100644 --- a/app/login/view/index/shangma_log.html +++ b/app/login/view/index/shangma_log.html @@ -51,9 +51,11 @@
增加表格操作是否参加考试状态,增加相对应的权限。
- 修复考号生成错误
+ 修复考号生成错误、考试成绩查看错误
env配置文件中增加session设置
+
+ 增加班级历次成绩查看