试卷下载标签doc格式换成xls格式

This commit is contained in:
cxdbz committed 2018-12-02 15:04:07 +08:00
1 parent ca8a5900a6
commit baae7c95a9
7 files changed
+195 -39

No files matched your search

+20 -6
View File
@@ -2,14 +2,28 @@
namespace app\chengji\controller;
use think\Controller;
use think\Request;
// 引用控制器基类
use app\common\controller\Base;
class Tongji extends Controller
class Tongji extends Base
{
// 成绩统计汇总表
public function list()
// 年级成绩汇总
public function nianji()
{
// 根据考试号获取成绩统计结果
// 实例化成绩数据模型
$cj = new \app\chengji\model\Chengji;
// 根据考试号和年级获取考试成绩
$cjlist = $cj->searchNianji(1,'一年级');
$tj = new \app\chengji\model\Tongji();
$yuwen = $cjlist->column('yuwen');
dump($yuwen);
$a = $tj->tongji($yuwen);
dump($a);
}
}
+20
View File
@@ -66,6 +66,12 @@ class Chengji extends Base
return $this->belongsTo('\app\renshi\model\Student','student','id');
}
// 满分
public function cjManfen()
{
return $this->belongsTo('\app\kaoshi\model\KaoshiSubject','kaoshi','kaoshiid');
}
@@ -183,10 +189,24 @@ class Chengji extends Base
->select();
}
// 查询年级成绩
public function searchNianji($kaoshiid,$nianji)
{
return $this->where('kaoshi',$kaoshiid)
->where('nianji',$nianji)
->field('id,yuwen,shuxue,waiyu')
->cache('key',180)
->select();
}
// 考试项目查询范围
public function scopeKaoshi($query,$kaoshiid)
{
$query->where('kaoshi',$kaoshiid);
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace app\chengji\model;
use think\Model;
class Tongji extends Model
{
var $avg = '';
var $sum = '';
var $youxiulv = '';#优秀率
var $jigelv = '';#及格率
//获取统计成绩
public function tongji($cjs)
{
$cnt = count($cjs);
$sum = $this->sum($cjs);
$avg = $sum/$cnt;
$data = ['cnt'=>$cnt,'avg'=>$avg,'sum'=>$sum];
return $data;
}
// 总分
public function sum($cjs)
{
$sum = array_sum($cjs);
return $sum;
}
}
Loaded 3 of 7 files, more files were not shown because too many files have changed in this diff. Show more