diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php index 951d912b..44857040 100644 --- a/application/chengji/controller/Index.php +++ b/application/chengji/controller/Index.php @@ -3,18 +3,53 @@ namespace app\chengji\controller; // 引用控制器基类 use app\common\controller\Base; -// 引用学生类 +// 引用学生数据模型 use app\renshi\model\Student; -// 引用成绩类 +// 引用成绩数据模型 use app\chengji\model\Chengji; +// 引用考试数据模型 class Index extends Base { - // 导出参加考试学生二维码 - public function erweima() + // 使用二维码录入成绩 + public function malu() { return $this->fetch(); } + // 保存使用二维码录入的成绩 + public function malusave() + { + // 获取表单数据 + $list = request()->only(['id','ziduan','defen'],'post'); + $zd = $list['ziduan']; + + // 更新成绩 + $cj = Chengji::update(['id'=>$list['id'], $zd=>$list['defen']]); + + empty($cj) ? $data = ['val' => 0] : $data = ['val' => 1]; + + return json($data); + + + } + + + + // 根据考号获取学生信息 + public function read() + { + $list = request()->only(['id','ziduan'],'post'); + $zd = $list['ziduan']; + $stuinfo = Chengji::where('id',$list['id']) + ->field('id,school,student,banji,'.$zd) + ->append(['studentname','schooljian','banjiname']) + ->find(); + return json($stuinfo->visible(['studentname','schooljian','banjiname','banji',$zd])); + } + + + + } diff --git a/application/chengji/model/Chengji.php b/application/chengji/model/Chengji.php index 40e17b36..098996a5 100644 --- a/application/chengji/model/Chengji.php +++ b/application/chengji/model/Chengji.php @@ -4,9 +4,30 @@ namespace app\chengji\model; // 引用基类 use app\common\model\Base; +// 引用班级类 +use app\teach\model\Banji; class Chengji extends Base { - // + // 学生姓名获取器 + public function getStudentnameAttr() + { + return db('student')->where('id',$this->student)->value('xingming'); + } + + // 学校简称获取器 + public function getSchooljianAttr() + { + return db('school')->where('id',$this->school)->value('jiancheng'); + } + + // 班级名称获取器 + public function getBanjinameAttr() + { + $bj = Banji::get($this->banji); + + // 返回班级名称 + return $bj->title; + } } diff --git a/application/chengji/view/index/erweima.html b/application/chengji/view/index/erweima.html deleted file mode 100644 index cac902c9..00000000 --- a/application/chengji/view/index/erweima.html +++ /dev/null @@ -1,74 +0,0 @@ -{extend name="common@create" /} -{block name="formaa"} -
-
- -
- -
-
-
- -
- -
-
-
- -
- - {php}$list = getCategory(108);{/php} - - -
-
-
- -
- - ~ - -
-
-
-
- -
-
-
-{/block} -{block name="yanzheng"} - -{/block} \ No newline at end of file diff --git a/application/chengji/view/index/malu.html b/application/chengji/view/index/malu.html new file mode 100644 index 00000000..705c9bea --- /dev/null +++ b/application/chengji/view/index/malu.html @@ -0,0 +1,137 @@ +{extend name="common@create" /} +{block name="formaa"} +
+
+ +
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
序号学校班级姓名学科 得分时间
序号学校班级姓名学科 得分得分
+ +{/block} +{block name="yanzheng"} + +{/block} \ No newline at end of file diff --git a/application/renshi/controller/Index.php b/application/renshi/controller/Index.php index c55069c0..48433b1c 100644 --- a/application/renshi/controller/Index.php +++ b/application/renshi/controller/Index.php @@ -269,7 +269,7 @@ class Index extends Base // 获取表单上传文件 例如上传了001.jpg $file = request()->file('file'); // 移动到框架应用根目录/uploads/ 目录下 - $info = $file->move( '..\uploads\teacher'); + $info = $file->move( '..\public\uploads\teacher'); if($info){ // 成功上传后 获取上传信息 $list['category'] = $info->getExtension(); @@ -279,7 +279,7 @@ class Index extends Base //将文件信息保存 $data = Fields::create($list); - $data ? $data = array('msg'=>'上传成功','val'=>true,'url'=>'..\uploads\teacher\\'.$list['url']) : $data = array('msg'=>'保存文件信息失败','val'=>false,'url'=>null); + $data ? $data = array('msg'=>'上传成功','val'=>true,'url'=>'..\public\uploads\teacher\\'.$list['url']) : $data = array('msg'=>'保存文件信息失败','val'=>false,'url'=>null); }else{ // 上传失败获取错误信息 $data = array('msg'=>$file->getError(),'val'=>false,'url'=>null); diff --git a/application/renshi/controller/Student.php b/application/renshi/controller/Student.php index c9c9f937..f22911d4 100644 --- a/application/renshi/controller/Student.php +++ b/application/renshi/controller/Student.php @@ -251,7 +251,6 @@ class Student extends Base $stuinfo = $excel->readXls($list['url']); // 删除标题行 array_splice($stuinfo,0,3); - // $upcnt = count($stuinfo); // 实例化班级数据模型 $banji = new \app\teach\model\Banji; @@ -283,17 +282,16 @@ class Student extends Base { continue; } - + // 各变量赋值 $students[$i]['banji'] = $bj; $students[$i]['xingming'] = $value[1]; $students[$i]['shenfenzhenghao'] = $value[2]; substr($value[2],16,17)%2 == 1 ? $students[$i]['sex']=1 :$students[$i]['sex']=0; $students[$i]['shengri'] = substr($value[2],6,4).'-'.substr($value[2],10,2).'-'.substr($value[2],12,2); - $students[$i]['school'] = $list['school']; $stuid = STU::where('shenfenzhenghao',$value[2])->value('id'); - $stuid > 1 ? $students[$i]['id'] = $stuid : true; + $stuid > 0 ? $students[$i]['id'] = $stuid : true; // 销毁无用变量 $i++; } @@ -326,7 +324,7 @@ class Student extends Base // 获取表单上传文件 例如上传了001.jpg $file = request()->file('file'); // 移动到框架应用根目录/uploads/ 目录下 - $info = $file->move( '..\uploads\student'); + $info = $file->move( '..\public\uploads\student'); if($info){ // 成功上传后 获取上传信息 $list['category'] = $info->getExtension(); @@ -336,7 +334,7 @@ class Student extends Base //将文件信息保存 $data = Fields::create($list); - $data ? $data = array('msg'=>'上传成功','val'=>true,'url'=>'..\uploads\student\\'.$list['url']) : $data = array('msg'=>'保存文件信息失败','val'=>false,'url'=>null); + $data ? $data = array('msg'=>'上传成功','val'=>true,'url'=>'..\public\uploads\student\\'.$list['url']) : $data = array('msg'=>'保存文件信息失败','val'=>false,'url'=>null); }else{ // 上传失败获取错误信息 $data = array('msg'=>$file->getError(),'val'=>false,'url'=>null); diff --git a/application/system/model/Fields.php b/application/system/model/Fields.php index 762f5d1e..00df4ee0 100644 --- a/application/system/model/Fields.php +++ b/application/system/model/Fields.php @@ -17,4 +17,5 @@ class Fields extends Base { return date('Y-m-d',$value); } + } diff --git a/application/teach/controller/Kaoshi.php b/application/teach/controller/Kaoshi.php index 6d14b7b3..d9b756ba 100644 --- a/application/teach/controller/Kaoshi.php +++ b/application/teach/controller/Kaoshi.php @@ -10,6 +10,10 @@ use app\teach\model\Kaoshi as KS; use app\renshi\model\Student; // 引用成绩类 use app\chengji\model\Chengji; +// 引用PhpSpreadsheet类 +use PhpOffice\PhpSpreadsheet\Spreadsheet; +// use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +// use PhpOffice\PhpSpreadsheet\IOFactory; class Kaoshi extends Base { @@ -74,7 +78,7 @@ class Kaoshi extends Base ->all(); } - $data = $data->append(['nianjinames','subjectnames','jieshu']); + $data = $data->append(['nianjinames','subjectnames','jieshu','kaishi']); $datacnt = $data->count(); @@ -327,14 +331,6 @@ class Kaoshi extends Base ->append(['nianji']) ->select(); - // 获取已有考号名单 - $kaohao = Chengji::where('kaoshi',$list['kaoshi']) - ->field('student') - ->select(); - - - $cj = $stulist->diff($kaohao); - // 组合参加考试学生信息 $stus = array(); foreach ($stulist as $key => $value) { @@ -344,7 +340,7 @@ class Kaoshi extends Base if($src->isEmpty()){ $stus[] = [ 'kaoshi' => $list['kaoshi'], - 'school' => $value->school, + 'school' => $value->getData('school'), 'ruxuenian' => $value->nianji, 'banji' => $value->banji, 'student' => $value->id @@ -363,4 +359,53 @@ class Kaoshi extends Base // 返回信息 return json($data); } + + + + + + // 生成码录表 + public function malubiao($id) + { + // $id = input('get.id'); + ini_set("memory_limit", "-1"); + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('A1', '考试号'); + $sheet->setCellValue('B1', '学科 '); + $i = 1; + $datas = Chengji::where('kaoshi',$id) + ->field('id') + ->select(); + $xks = KS::get($id); + $xks = $xks->Subjectids; + $xks = db('subject')->where('id','in',$xks)->column('id,leiming'); + foreach ($datas as $data) + { + foreach ($xks as $key => $value) { + $i++; + $sheet->setCellValue('A' . $i, $data['id']); + $sheet->setCellValue('B' . $i, $value); + } + } + // 保存文件 + // $writer = new Xlsx($spreadsheet); + // $writer->save(ROOT_PATH . "vcf/hello world.xlsx"); + // 下载文件 + $filename = '试卷标签.xlsx'; + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + header('Content-Disposition: attachment;filename="' . $filename . '"'); + header('Cache-Control: max-age=0'); + $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); + $writer->save('php://output'); + } + + + // 生成表格录入成绩表 + public function biaolubiao() + { + return '表录表'; + } + + } diff --git a/application/teach/model/Kaoshi.php b/application/teach/model/Kaoshi.php index ccc8f38f..ad77600e 100644 --- a/application/teach/model/Kaoshi.php +++ b/application/teach/model/Kaoshi.php @@ -135,4 +135,10 @@ class Kaoshi extends Base time()>$this->getData('enddate') ? $str = 1 : $str = 0; return $str; } + // 考试结束获取器 + public function getKaishiAttr() + { + time()>$this->getData('bfdate') ? $str = 1 : $str = 0; + return $str; + } } diff --git a/application/teach/view/kaoshi/index.html b/application/teach/view/kaoshi/index.html index ea7b6f35..c3b635e5 100644 --- a/application/teach/view/kaoshi/index.html +++ b/application/teach/view/kaoshi/index.html @@ -2,7 +2,7 @@ {block name="topnav"}