diff --git a/app/ToolsBase.php b/app/ToolsBase.php new file mode 100644 index 00000000..e6b01ba7 --- /dev/null +++ b/app/ToolsBase.php @@ -0,0 +1,19 @@ + ['规则1','规则2'...] - * - * @var array - */ - protected $rule = []; - - /** - * 定义错误信息 - * 格式:'字段名.规则名' => '错误信息' - * - * @var array - */ - protected $message = []; -} diff --git a/app/common.php b/app/common.php index 2b61af50..c57049a0 100644 --- a/app/common.php +++ b/app/common.php @@ -185,63 +185,7 @@ } - /** - * 获取文件信息并保存 - * - * @param file对象 $file - * @param array() $list 文件信息 - * str $list['text'] 文件分类标识 - * str $list['serurl'] 文件存储位置 - * file $file 文件对象 - * @return array $data - * str $data['msg'] 返回信息提示 - * str $data['val'] 返回信息 - * str $data['url'] 文件路径 - */ - function saveFileInfo($file, $list, $isSave = false) - { - $hash = $file->hash('sha1'); - $f = new \app\system\model\Fields; - $serFile = $f::where('hash', $hash)->find(); - - if($serFile) - { - $serFile->user_id = session('userid'); - $serFile->save(); - $data['msg'] = '文件已经存在'; - $data['val'] = true; - $data['url'] = $serFile->url; - return $data; - } - - // 上传文件到本地服务器 - $savename = \think\facade\Filesystem::disk('public') - ->putFile($list['serurl'], $file); - // 重新组合文件路径 - $savename = str_replace("/", "\\", $savename); - - if($isSave==true){ - $list['url'] = $savename; - $list['newname'] = substr($savename - ,strripos($savename, '\\') + 1 - ,strlen($savename) - strripos($savename - ,'\\')); - $list['hash'] = $file->hash('sha1'); - $list['user_id'] = session('userid'); - $list['oldname'] = $file->getOriginalName(); - $list['fieldsize'] = $file->getSize(); - $list['category_id'] = $list['category_id']; - $list['bianjitime'] = $file->getMTime( ); - $list['extension'] = $file->getOriginalExtension(); - $saveinfo = $f::create($list); - } - - $data['msg'] = '上传成功'; - $data['val'] = true; - $data['url'] = $savename; - - return $data; - } + // 给数组按多条件排序 diff --git a/app/facade/Ck.php b/app/facade/Ck.php deleted file mode 100644 index f2ae93e9..00000000 --- a/app/facade/Ck.php +++ /dev/null @@ -1,12 +0,0 @@ -srcSubject($srcfrom); diff --git a/app/kaohao/model/Search.php b/app/kaohao/model/Search.php deleted file mode 100644 index dc288363..00000000 --- a/app/kaohao/model/Search.php +++ /dev/null @@ -1,508 +0,0 @@ - '0' - ,'banji_id' => array() - ,'searchval' => '' - ); - // 用新值替换初始值 - $src = array_cover($srcfrom, $src); - - $kh = new kh; - $khlist = $kh->search($src); - if($khlist->isEmpty()) - { - return $data = array(); - } - - // 获取参考学科 - $ksset = new \app\kaoshi\model\KaoshiSet; - $ksSubject = $ksset->srcSubject($src['kaoshi_id'], '', ''); - if(count($ksSubject)==0) - { - return $data = array(); - } - $xk = array(); - foreach ($ksSubject as $key => $value) { - $xk[$value['id']] = $value['lieming']; - } - - // 实例化学生数据模型 - $stu = new \app\student\model\Student; - $data = array(); - foreach ($khlist as $key => $value) { - $data[$key]['id'] = $value->id; - $data[$key]['school_jiancheng'] = $value->cjSchool->jiancheng; - if($value->cjStudent != Null){ - $data[$key]['student_xingming'] = $value->cjStudent->xingming; - $data[$key]['sex'] = $value->cjStudent->sex; - }else{ - $stuinfo = $stu::withTrashed() - ->where('id', $value->student_id) - ->field('id, xingming, sex') - ->find(); - $data[$key]['student_xingming'] = $stuinfo->xingming; - $data[$key]['sex'] = $stuinfo->sex; - } - - $data[$key]['ban_title'] = $value->banjiTitle; - $data[$key]['banji_title'] = $value->banTitle; - $dfsum = 0; - $sbjcnt = 0; - - if (!$value->ksChengji->isEmpty()) { - foreach ($xk as $k => $val) { - if(isset($value->ksChengji[$val])) - { - $data[$key][$val]=$value->ksChengji[$val]->defen * 1; - $dfsum = $dfsum + $data[$key][$val]; - $sbjcnt++; - }else{ - $data[$key][$val]= null; - } - } - }else{ - foreach ($xk as $k => $val) { - $data[$key][$val]= null; - } - } - - if($sbjcnt>0){ - $data[$key]['sum'] = $dfsum; - $data[$key]['avg'] = round($dfsum / $sbjcnt, 1); - }else{ - $data[$key]['sum'] = null; - $data[$key]['avg'] = null; - } - } - - return $data; - } - - - // 查询各班级考号,并以班级进行分组 - public function srcBanjiKaohao($srcfrom) - { - // 初始化参数 - $src = array( - 'kaoshi_id' => '0' - ,'banji_id' => array() - ); - // 用新值替换初始值 - $src = array_cover($srcfrom, $src); - $src['banji_id'] = strToArray($src['banji_id']); - - // 获取考试标签 - $kh = new kh; - $data = $kh->where('kaoshi_id', $src['kaoshi_id']) - ->where('banji_id', 'in', $src['banji_id']) - ->field('banji_id, school_id') - ->order(['banji_id']) - ->group('banji_id, school_id') - ->with([ - 'cjBanji' => function($query){ - $query->field('id, school_id, ruxuenian, paixu') - ->append(['banjiTitle', 'numTitle']); - } - , - 'cjSchool' => function($query){ - $query->field('id, jiancheng'); - } - , - 'banjiKaohao' => function($query) use($src){ - $query->field('id, student_id, banji_id') - ->where('kaoshi_id', $src['kaoshi_id']) - ->order(['banji_id', 'id']) - ->with([ - 'cjStudent' => function($q){ - $q->field('id, xingming, sex'); - } - ]); - } - ]) - ->select(); - - $stu = new \app\student\model\Student; - // 找出已经被删除学生,并添加该学生信息 - foreach ($data as $key => $value) { - foreach ($value->banjiKaohao as $k => $val) { - if($val->cjStudent == Null) - { - $stuinof = $stu::onlyTrashed() - ->where('id', $val->student_id) - ->field('id, xingming') - ->find(); - $data[$key]->banjiKaohao[$key]->cjStudent = array('id' => $stuinof->id, 'xingming' => $stuinof->xingming); - } - } - } - return $data; - } - - - // 查询各学科成绩精简版 - public function srcChengjiSubject($srcfrom) - { - // 初始化参数 - $src = array( - 'kaoshi_id' => '0' - ,'banji_id' => array() - ,'searchval' => '' - ); - $src = array_cover($srcfrom, $src); - - $kh = new kh; - $khlist = $kh->search($src); - - // 成绩整理 - if($khlist->isEmpty()) - { - return $data = array(); - } - $data = array(); - foreach ($khlist as $kh_k => $kh_val) { - foreach ($kh_val->ksChengji as $cj_k => $cj_val) { - $data[$cj_val->subject_id][$cj_val->id] = $cj_val->defen; - } - } - - return $data; - } - - - // 获取单个学生历次考试成绩 - public function srcOneStudentChengji($srcfrom) - { - // 初始化参数 - $src = array( - 'student_id' => '', - 'category_id' => '', - 'xueqi_id' => '', - 'kaoshi_id' => '', - ); - $src = array_cover($srcfrom, $src); - $src['category_id'] = strToArray($src['category_id']); - $src['xueqi_id'] = strToArray($src['xueqi_id']); - $src['kaoshi_id'] = strToArray($src['kaoshi_id']); - - 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")); - } - - $kh = new kh; - $stuCj = $kh->where('student_id',$src['student_id']) - ->when(count($src['category_id'])>0, function($query) use($src){ - $query->where('kaoshi_id','in',function($q) use($src){ - $q->name('kaoshi') - ->where('category_id','in',$src['category_id']) - ->field('id'); - }); - }) - ->when(count($src['xueqi_id'])>0, function($query) use($src){ - $query->where('kaoshi_id','in',function($q) use($src){ - $q->name('kaoshi') - ->where('xueqi_id','in',function($w) use($src){ - $w->name('xueqi') - ->where('category_id','in',$src['xueqi_id']) - ->field('id'); - }) - ->field('id'); - }); - }) - ->when(count($src['kaoshi_id'])>0, function($query) use($src){ - $query->where('kaoshi_id', 'in', $src['kaoshi_id']); - }) - ->where('kaoshi_id', 'in', function($query) use($src){ - $query->name('kaoshi') - ->whereTime('bfdate|enddate', 'between', [ $src['bfdate'],$src['enddate'] ]) - ->field('id'); - }) - ->with([ - 'ksChengji'=>function($query){ - $query->field('id, kaohao_id, subject_id, defen, defenlv, bweizhi, xweizhi, qweizhi'); - } - ,'cjSchool' => function($query){ - $query->field('id, jiancheng'); - } - ,'cjKaoshi' => function($query){ - $query->field('id, title, zuzhi_id, xueqi_id, category_id, bfdate, enddate') - ->with([ - 'ksCategory' => function($q){ - $q->field('id, title'); - } - ,'ksZuzhi' => function($q) - { - $q->field('id, title, jiancheng'); - } - ]); - } - ]) - ->field('id ,kaoshi_id, student_id, ruxuenian, nianji, banji_id, paixu') - ->append(['banjiTitle']) - ->select(); - - return $stuCj; - } - - - // 根据考号查询成绩 - public function khSrcChengji($id) - { - $kh = new kh; - $stuCj = $kh::where('id', $id) - ->with([ - 'ksChengji'=>function($query){ - $query - ->with([ - 'subjectName'=>function($q){ - $q->field('id, title'); - } - ]) - ->field('id, kaohao_id, subject_id, defen, defenlv, bweizhi, xweizhi, qweizhi'); - } - ,'cjBanji' => function($q){ - $q->field('id, paixu, ruxuenian') - ->append(['numTitle', 'banjiTitle']); - } - ,'cjSchool' => function($q){ - $q->field('id, jiancheng'); - } - ,'cjStudent' => function($q){ - $q->field('id, xingming'); - } - ]) - ->field('id, kaoshi_id, student_id, ruxuenian, nianji, banji_id, paixu') - ->append(['banjiTitle']) - ->find(); - - return $stuCj; - } - - - // 根据考号查询成绩 - public function khSrcOneSubjectChengji($id, $subject_id) - { - $kh = new kh; - $stuCj = $kh::where('id', $id) - ->field('id ,banji_id, school_id, student_id') - ->with([ - 'cjBanji' => function($q){ - $q->field('id, paixu, ruxuenian') - ->append(['numTitle', 'banjiTitle']); - } - ,'cjSchool' => function($q){ - $q->field('id, jiancheng'); - } - ,'cjStudent' => function($q){ - $q->field('id, xingming'); - } - ]) - ->find(); - - if($stuCj->cjStudent->isEmpty()) - { - $stu = new \app\student\model\Student; - $stuinfo = $stu::withTrashed() - ->where('id', $cjlist->student) - ->field('id, xingming, sex') - ->find(); - $stuCj->cjStudent = array( - 'id' => $stuinfo->id - ,'xingming' => $stuinfo->xingming - ); - } - - $sbj = new \app\teach\model\Subject; - $sbjinfo = $sbj - ->where('id', $subject_id) - ->field('id, title, jiancheng') - ->find(); - $stuCj->subjectName = $sbjinfo; - - $cj = new \app\chengji\model\Chengji; - $cjinfo = $cj->where('kaohao_id', $id) - ->where('subject_id', $subject_id) - ->field('id,subject_id,kaohao_id,defen') - ->find(); - $stuCj->chengji = $cjinfo; - - return $stuCj; - } - - - // 获取考试成绩最后更新时间 - public function lastUpdateTime($kaoshi_id) - { - // 获取考号 - $kh = new kh; - $kaohaoids = $kh->where('kaoshi_id', $kaoshi_id) - ->cache(true) - ->column('id'); - - $cj = new \app\chengji\model\Chengji; - $lastcj = $cj->where('kaohao_id', 'in', $kaohaoids) - ->order(['update_time' => 'desc']) - ->find(); - - return $lastcj; - } - - - // 获取参加考试学校 - public function cySchool($srcfrom) - { - // 初始化参数 - $src = array( - 'kaoshi_id' => '' - ,'ruxuenian' => '' - ); - $src = array_cover($srcfrom, $src); - $src['ruxuenian'] = strToarray($src['ruxuenian']); - - $kh = new kh; - $schoolList = $kh->where('kaoshi_id', $src['kaoshi_id']) - ->when(count($src['ruxuenian']) > 0, function($query) use($src){ - $query->where('ruxuenian', 'in', $src['ruxuenian']); - }) - ->with(['cjSchool' => function($query){ - $query->field('id, jiancheng, paixu, title') - ->order(['paixu' => 'asc']); - } - ]) - ->group('school_id') - ->field('school_id') - ->select() - ->toArray(); - - // 重新整理参加学校信息 - $data = array(); - foreach ($schoolList as $key => $value) { - $data[] = [ - 'paixu' => $value['cjSchool']['paixu'], - 'id' => $value['cjSchool']['id'], - 'title' => $value['cjSchool']['title'], - 'jiancheng' => $value['cjSchool']['jiancheng'], - ]; - } - - if(count($data) > 0) - { - $data = sortArrByManyField($data, 'paixu', SORT_ASC); - } - - return $data; - } - - - /** - * 获取参加考试的班级 - * @access public - * @param number $kaoshi 考试id - * @param number $ruxuenian 入学年 - * @return array 返回班级数据模型 - */ - public function cyBanji($srcfrom) - { - // 初始化参数 - $src = array( - 'kaoshi_id' => '' - ,'ruxuenian' => array() - ,'school_id' => array() - ,'banji_id' => array() - ); - $src = array_cover($srcfrom, $src); - $src['school_id'] = strToarray($src['school_id']); - $src['banji_id'] = strToarray($src['banji_id']); - $src['ruxuenian'] = strToarray($src['ruxuenian']); - - // 通过给定参数,从考号表中获取参加考试的班级 - $kh = new kh; - $bjids = $kh - ->where('kaoshi_id', $src['kaoshi_id']) - ->when(count($src['ruxuenian'] ) > 0, function($query) use($src){ - $query->where('ruxuenian', 'in', $src['ruxuenian'] ); - }) - ->when(count($src['school_id']) > 0, function($query) use($src){ - $query->where('school_id', 'in', $src['school_id']); - }) - ->when(count($src['banji_id']) > 0, function($query) use($src){ - $query->where('banji_id', 'in', $src['banji_id']); - }) - ->with([ - 'cjSchool' => function($query){ - $query->field('id, jiancheng, title, paixu'); - } - ]) - ->field('banji_id - ,any_value(id) as id - ,any_value(nianji) as nianji - ,any_value(paixu) as paixu - ,any_value(school_id) as school_id') - ->group('banji_id') - ->append(['banjiTitle', 'banTitle']) - ->select(); - - $bj = new \app\teach\model\Banji; - $data = array(); - foreach ($bjids as $key => $value) { - $data[] = [ - 'id'=>$value->banji_id, - 'paixu'=>$value->paixu, - 'schTitle'=>$value->cjSchool->title, - 'schJiancheng'=>$value->cjSchool->jiancheng, - 'schPaixu'=>$value->cjSchool->paixu, - 'banTitle'=>$value->banTitle, - 'banjiTitle'=>$value->banjiTitle, - // 'numTitle'=>$value->numTitle, - ]; - } - if(count($data) > 0) - { - $data = sortArrByManyField($data, 'schPaixu', SORT_ASC, 'paixu', SORT_ASC); - } - - return $data; - } - - - // 转置成绩数组 - private function zzcj($array = array()) - { - $arr = array(); - foreach ($array as $key => $value) { - $array[$value->subjectName->lieming] = $value; - unset($array[$key]); - } - return $array; - } - -} - - - - - diff --git a/app/searchtools/common.php b/app/searchtools/common.php deleted file mode 100644 index d433d0cb..00000000 --- a/app/searchtools/common.php +++ /dev/null @@ -1,2 +0,0 @@ -setInputEncoding('GBK'); + $excelReader->setDelimiter(','); + } + $phpexcel = $excelReader->load($path); + $activeSheet = $phpexcel->getActiveSheet(); + $sheet = $activeSheet->toArray(); + return $sheet; + } + + + /** + * 获取文件信息并保存 + * + * @param file对象 $file + * @param array() $list 文件信息 + * str $list['text'] 文件分类标识 + * str $list['serurl'] 文件存储位置 + * file $file 文件对象 + * @return array $data + * str $data['msg'] 返回信息提示 + * str $data['val'] 返回信息 + * str $data['url'] 文件路径 + */ + function saveFileInfo($file, $list, $isSave = false) + { + $hash = $file->hash('sha1'); + $f = new \app\system\model\Fields; + $serFile = $f::where('hash', $hash)->find(); + + if($serFile) + { + $serFile->user_id = session('userid'); + $serFile->save(); + $data['msg'] = '文件已经存在'; + $data['val'] = true; + $data['url'] = $serFile->url; + return $data; + } + + // 上传文件到本地服务器 + $savename = \think\facade\Filesystem::disk('public') + ->putFile($list['serurl'], $file); + // 重新组合文件路径 + $savename = str_replace("/", "\\", $savename); + + if($isSave==true){ + $list['url'] = $savename; + $list['newname'] = substr($savename + ,strripos($savename, '\\') + 1 + ,strlen($savename) - strripos($savename + ,'\\')); + $list['hash'] = $file->hash('sha1'); + $list['user_id'] = session('userid'); + $list['oldname'] = $file->getOriginalName(); + $list['fieldsize'] = $file->getSize(); + $list['category_id'] = $list['category_id']; + $list['bianjitime'] = $file->getMTime( ); + $list['extension'] = $file->getOriginalExtension(); + $saveinfo = $f::create($list); + } + + $data['msg'] = '上传成功'; + $data['val'] = true; + $data['url'] = $savename; + + return $data; + } + + +} diff --git a/app/searchtools/controller/Kaoshi.php b/app/searchtools/controller/Kaoshi.php index 9e1a5326..7371eb9a 100644 --- a/app/searchtools/controller/Kaoshi.php +++ b/app/searchtools/controller/Kaoshi.php @@ -3,10 +3,12 @@ declare (strict_types = 1); namespace app\searchtools\controller; +// 引用基类 +use \app\base\ToolsBase; // 引用考试设置 use app\kaoshi\model\KoashiSet as ksset; -class Kaoshi +class Kaoshi extends ToolsBase { // 查询参加考试的学科 public function subject($src) @@ -24,4 +26,7 @@ class Kaoshi $data = $ksset->srcGrade($kaoshi_id); return $data; } + + + } diff --git a/app/searchtools/event.php b/app/searchtools/event.php deleted file mode 100644 index ec349f1b..00000000 --- a/app/searchtools/event.php +++ /dev/null @@ -1,5 +0,0 @@ - '' - ,'category_id' => '' - ,'xueqi_id' => '' - ,'bfdate' => '' - ,'enddate' => '' - ); - $src = array_cover($srcfrom, $src); - - // 查询成绩 - $khSrc = new \app\kaohao\model\Search; - $stuCj = $khSrc->srcOneStudentChengji($src); - - // 获取可以参加考试的学科 - $sbj = new \app\teach\model\Subject; - $sbjList = $sbj->where('kaoshi', 1) - ->where('status', 1) - ->field('id, lieming') - ->column('lieming', 'id'); - - // 整理数据 - $data = array(); - foreach ($stuCj as $key => $value) { - $data[$key] = [ - 'kaoshi_id' => $value->kaoshi_id, - 'kaoshiTitle' => $value->cjKaoshi->title, - 'kaohao_id' => $value->id, - 'banjiTitle' => $value->banjiTitle, - 'zuzhi_id' => $value->cjKaoshi->ksZuzhi->jiancheng, - 'category_id' => $value->cjKaoshi->ksCategory->title, - 'bfdate' => $value->cjKaoshi->bfdate, - 'enddate' => $value->cjKaoshi->enddate, - ]; - - $cjcnt = count($value->ksChengji); - - if($cjcnt > 0) - { - $sbj = $value->ksChengji->column('subject_id'); - foreach ($sbjList as $sbj_k => $sbj_val) { - // 通过学科ID获取这个学科成绩对应的成绩下标。 - // 这个地方需要再核实。 - $xb = array_search($sbj_k, $sbj); # ksChengji下标 - if($xb === false) - { - $data[$key][$sbj_val] = ''; - }else{ - $data[$key][$sbj_val] = $value->ksChengji[$xb]->defen; - } - } - $defen = array_column($value->ksChengji->toArray(), 'defen'); - $sum = array_sum($defen ); - $avg = $sum / $cjcnt; - $data[$key]['sum'] = $sum; - $data[$key]['avg'] = round($avg,2); - }else{ - foreach ($sbjList as $sbj_k => $sbj_val) { - $data[$key][$sbj_val] = ''; - } - $data[$key]['sum'] = ''; - $data[$key]['avg'] = ''; - } - } - return $data; - } - - - // 一个学生一个学科历次成绩 - public function oneStudentSubjectChengji($srcfrom) - { - // 初始化参数 - $src = array( - 'student_id' => '' - ,'kaoshi_id' => array() - ,'subject_id' => '' - ,'category_id' => '' - ,'xueqi_id' => '' - ,'bfdate' => '' - ,'enddate' => '' - ); - $src = array_cover( $srcfrom , $src ); - - $khSrc = new \app\kaohao\model\Search; - $stuCj = $khSrc->srcOneStudentChengji($src); - - - // 获取可以参加考试的学科 - $sbj = new \app\teach\model\Subject; - $sbjList = $sbj->where('kaoshi',1) - ->where('status',1) - ->field('id,lieming') - ->column('lieming','id'); - - // 整理数据 - $data = array(); - $xAxis = array(); - $series = [ - 0 => [ - 'name'=>'得分率%', - 'type'=>'line', - 'data'=>array(), - ], - 1 => [ - 'name'=>'班级位置%', - 'type'=>'line', - 'data'=>array(), - ], - 2 => [ - 'name'=>'学校位置%', - 'type'=>'line', - 'data'=>array(), - ], - 3 => [ - 'name'=>'全部位置%', - 'type'=>'line', - 'data'=>array(), - ], - ]; - foreach ($stuCj as $key => $value) { - $cjcnt = count($value->ksChengji); - if($cjcnt > 0) - { - foreach ($value->ksChengji as $sbj_k => $sbj_val) { - if($src['subject_id'] == $sbj_val->subject_id) - { - $xAxis[] = $value->cjKaoshi->title; - $series['0']['data'][] = $sbj_val->defenlv; - $series['1']['data'][] = round($sbj_val->bweizhi,0); - $series['2']['data'][] = round($sbj_val->xweizhi,0); - $series['3']['data'][] = round($sbj_val->qweizhi,0); - } - } - } - } - - $data = [ - 'xAxis' => $xAxis - ,'series' => $series - ,'legend' => [ - '得分率%' - ,'班级位置%' - ,'学校位置%' - ,'全部位置%' - ] - ]; - - return $data; - } - - - // 该学生本次考试各学科成绩雷达图 - public function oneStudentLeiDa($srcfrom) - { - // 初始化参数 - $src = array( - 'kaohao_id' => '', - ); - - // 用新值替换初始值 - $src = array_cover($srcfrom, $src); - - $kh = new \app\kaohao\model\Kaohao; - // 考号信息 - $khInfo = $kh->where('id', $src['kaohao_id']) - ->with([ - 'ksChengji'=>function($query){ - $query->field('id, kaohao_id, subject_id, defen'); - } - ]) - ->find(); - - // 参加考试学科 - $subject = subjectList(1,1); - // 获取参加考试学科满分 - $ksset = new \app\kaoshi\model\KaoshiSet; - $manfen = $ksset->srcSubject($khInfo->kaoshi_id, '', $khInfo->ruxuenian); - - // 查询区成绩 - $SchoolChengji = new \app\chengji\model\TongjiSch; - $schcj = $SchoolChengji - ->where('kaoshi_id',$khInfo->kaoshi_id) - ->where('ruxuenian',$khInfo->ruxuenian) - ->select(); - - // 循环写入成绩 - $indicator = array(); - $legend = ['得分','全体平均分']; - $bjcj = array(); - $bjcj['name'] = '得分'; - $qcj = array(); - $qcj['name'] = '全体平均分'; - $i = 0; - - foreach ($subject as $sbj_k => $sbj_val) { - - // 试卷满分 - if(isset($indicator[$i]) == false) - { - $indicator[$i]['name'] = $sbj_val->title; - foreach ($manfen as $mf_k => $mf_val) { - if($sbj_val['id'] == $mf_val['id']) - { - $indicator[$i]['max'] = $mf_val['fenshuxian']['manfen']; - continue; - } - if(isset($indicator[$i]) == false) - { - $indicator[$i]['max'] = null; - } - } - } - - // 学生成绩 - if(isset($bjcj['value'][$i]) == false) - { - foreach ($khInfo->ksChengji as $cj_k => $cj_val) { - if($sbj_val['id'] == $cj_val->subject_id) - { - $bjcj['value'][$i] = $cj_val->defen; - unset($khInfo->ksChengji[$cj_k]); - continue; - } - } - } - if(isset($bjcj['value'][$i]) == false) - { - $bjcj['value'][$i] = null; - } - - // 班级成绩 - if(isset($qcj['value'][$i]) == false) - { - foreach ($schcj as $sch_k => $sch_val) { - if($sbj_val['id'] == $sch_val->subject_id) - { - $qcj['value'][$i] = $sch_val->avg; - unset($schcj[$sch_k]); - continue; - } - - } - } - if(isset($qcj['value'][$i]) == false) - { - $qcj['value'][$i] = null; - } - - $i++; - } - - $data = [ - 'title' => '学生成绩' - ,'legend' => $legend - ,'indicator' => $indicator - ,'series' => [ - 'name'=>'成绩' - ,'type' => 'radar' - ,'data' => [$bjcj, $qcj] - ] - ]; - - return $data; - } - - - // 该学生本次考试各学科成绩仪表图 - public function oneStudentYiBiao($srcfrom) - { - // 初始化参数 - $src = array( - 'kaohao_id' => '', - ); - - // 用新值替换初始值 - $src = array_cover($srcfrom, $src); - - // 成绩查询信息 - $kh = new \app\kaohao\model\Kaohao; #该考号对应的考试信息。 - $khInfo = $kh->where('id', $src['kaohao_id']) - ->find(); - $src['ruxuenian'] = $khInfo->ruxuenian; #设置查询条件 - $src['kaoshi_id'] = $khInfo->kaoshi_id; - $khSrc = new \app\kaohao\model\Search; - $src['banji_id'] = array_column($khSrc->cyBanji($src), 'id'); - - // 实例化并查询成绩 - $cj = new \app\chengji\model\Chengji; - $data = $cj->search($src); - if (count($data)>0) { - $data = sortArrByManyField($data, 'sum', SORT_DESC); - $data = array_column($data, 'id'); - $rank = array_search($src['kaohao_id'], $data); - $rank = round(($rank + 1) / count($data) * 100, 0); - - $data = [ - 'title' => '学生成绩' - ,'series' => [ - 'name'=>'总成绩位置' - ,'type' => 'gauge' - // ,'detail' => $rank . '%' - ,'data' => [['value'=>$rank, 'name'=>'位置']] - ] - ]; - } else { - $data = [ - 'title' => '学生成绩' - ,'series' => [ - 'name'=>'总成绩位置' - ,'type' => 'gauge' - // ,'detail' => $rank . '%' - ,'data' => [['value'=>0, 'name'=>'位置']] - ] - ]; - } - - - - - - return $data; - } - -} diff --git a/app/teacher/controller/Index.php b/app/teacher/controller/Index.php index 0406a7e2..bd40be1a 100644 --- a/app/teacher/controller/Index.php +++ b/app/teacher/controller/Index.php @@ -442,7 +442,6 @@ class Index extends BaseController public function downloadXls() { $url = public_path() . 'uploads\\teacher\\TeacherInfo.xlsx'; - halt($url); return download($url, '教师名单模板.xlsx'); }