|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
|
|
|
namespace app\admin\controller\teacher;
|
|
|
+use PhpOffice\PhpWord\PhpWord;
|
|
|
|
|
|
use app\admin\model\department\Department;
|
|
|
use app\common\controller\Backend;
|
|
@@ -17,6 +18,10 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Csv;
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xls;
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* sim-考试表/成绩总分
|
|
|
*
|
|
@@ -31,7 +36,7 @@ class Exams extends Backend
|
|
|
*/
|
|
|
protected $model = null;
|
|
|
protected $whereExtend = null;
|
|
|
- protected $noNeedRight = ['export'];
|
|
|
+ protected $noNeedRight = ['export','examslog','report'];
|
|
|
public function _initialize()
|
|
|
{
|
|
|
parent::_initialize();
|
|
@@ -181,8 +186,19 @@ class Exams extends Backend
|
|
|
$minutes = floor($diffInSeconds / 60); // 计算分钟数
|
|
|
$seconds = $diffInSeconds % 60; // 计算剩余的秒数
|
|
|
$row['shijian'] = $minutes.'分'.$seconds.'秒';
|
|
|
-
|
|
|
+
|
|
|
+ $koufen = 0;
|
|
|
+ if(!empty($other_jielun)){
|
|
|
+ foreach ($other_jielun as $key => $value) {
|
|
|
+ if(!empty($value['cx_score'])){
|
|
|
+ $koufen = $koufen+abs($value['cx_score']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $koufen = 15;
|
|
|
+ }
|
|
|
if (false === $this->request->isPost()) {
|
|
|
+ $this->assignConfig('koufen', $koufen);
|
|
|
$this->view->assign('other_jielun', $other_jielun);
|
|
|
$this->view->assign('row', $row);
|
|
|
return $this->view->fetch();
|
|
@@ -238,6 +254,7 @@ class Exams extends Backend
|
|
|
$row['user_depart_name'] = Department::where('id',$rows->user_depart_id)->value('name');
|
|
|
$row['start_time'] = $rows->start_time;
|
|
|
$row['end_time'] = $rows->end_time;
|
|
|
+ $row['exam_collection_type'] = $rows->exam_collection_type;
|
|
|
|
|
|
|
|
|
$fault_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1])->select();
|
|
@@ -262,15 +279,24 @@ class Exams extends Backend
|
|
|
|
|
|
|
|
|
$koufen = 0;
|
|
|
+ $dt_count = 0;
|
|
|
if(!empty($other_jielun)){
|
|
|
foreach ($other_jielun as $key => $value) {
|
|
|
if(!empty($value['cx_score'])){
|
|
|
$koufen = $koufen+abs($value['cx_score']);
|
|
|
}
|
|
|
+ if($value['cx_type']=='未作答'){
|
|
|
+ $dt_count = $dt_count+1;
|
|
|
+ }
|
|
|
}
|
|
|
}else{
|
|
|
$koufen = 15;
|
|
|
}
|
|
|
+ //训练,未作答。展示使用
|
|
|
+ $is_nowancheng = 0;
|
|
|
+ if($row['exam_collection_type']== 1 && $row['fault_total'] == $dt_count){
|
|
|
+ $is_nowancheng = 1;
|
|
|
+ }
|
|
|
$report_score = 15-$koufen;
|
|
|
$row['report_score'] = $report_score>0?$report_score:0;
|
|
|
|
|
@@ -282,7 +308,9 @@ class Exams extends Backend
|
|
|
$row['total'] = $total;
|
|
|
|
|
|
$this->view->assign('other_jielun', $other_jielun);
|
|
|
-
|
|
|
+ $this->view->assign('dt_count', $dt_count);
|
|
|
+ $this->view->assign('is_nowancheng', $is_nowancheng);
|
|
|
+
|
|
|
$diffInSeconds = $rows['endtime'] - $rows['starttime']; // 两个时间戳之间的差异(秒)
|
|
|
$minutes = floor($diffInSeconds / 60); // 计算分钟数
|
|
|
$seconds = $diffInSeconds % 60; // 计算剩余的秒数
|
|
@@ -321,6 +349,17 @@ class Exams extends Backend
|
|
|
return json($result);
|
|
|
}
|
|
|
|
|
|
+ //考试座次历史记录
|
|
|
+ public function examslog($ids = null)
|
|
|
+ {
|
|
|
+ $row = $this->model->get($ids);
|
|
|
+ if(!$row){
|
|
|
+ $this->error(__('No Results were found'));
|
|
|
+ }
|
|
|
+ $list = $this->model->where(['seat_id'=>$row->seat_id,'exam_collection_id'=>$row->exam_collection_id])->order('starttime asc')->select();
|
|
|
+ $this->view->assign('list', $list);
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
|
|
|
public function examing($ids = null)
|
|
|
{
|
|
@@ -338,7 +377,7 @@ class Exams extends Backend
|
|
|
|
|
|
$list = Db::name('seat')->select();
|
|
|
foreach ($list as $key => $value) {
|
|
|
- $exam = $this->model->where('exam_collection_id',$ids)->order('exam_id desc')->where('seat_id',$value['seat_num'])->find();
|
|
|
+ $exam = $this->model->where('exam_collection_id',$ids)->order('starttime desc')->where('seat_id',$value['seat_num'])->find();
|
|
|
$user_username = '';
|
|
|
$user_nickname = '';
|
|
|
$exam_status = '未登录';
|
|
@@ -403,7 +442,7 @@ class Exams extends Backend
|
|
|
}
|
|
|
$exam_ids = $this->model->where('exam_collection_id',$ids)->column('exam_id');
|
|
|
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
|
|
- $list = ExamsScore::where($where)->where('exam_id','in',$exam_ids)
|
|
|
+ $list = ExamsScore::where($where)->alias('s')->join('mx_real_exam e','s.exam_id=e.exam_id')->where('s.exam_id','in',$exam_ids)
|
|
|
->order($sort, $order)
|
|
|
->paginate($limit);
|
|
|
foreach ($list as $k => $v){
|
|
@@ -500,6 +539,7 @@ class Exams extends Backend
|
|
|
if ($this->request->request('keyField')) {
|
|
|
return $this->selectpage();
|
|
|
}
|
|
|
+ $exam_collection_id = $this->model->where($this->whereExtend)->order('exam_id desc')->value('exam_collection_id');
|
|
|
|
|
|
$filter = $this->request->get("filter", '');
|
|
|
$filter = (array)json_decode($filter, true);
|
|
@@ -507,13 +547,16 @@ class Exams extends Backend
|
|
|
$op = (array)json_decode($op, true);
|
|
|
|
|
|
if(isset($filter) &&!empty($filter['exam_collection_name'])){
|
|
|
- $this->whereExtend['exam_collection_name'] = $filter['exam_collection_name'];
|
|
|
+ unset($this->whereExtend['exam_collection_id']);
|
|
|
$this->request->get(['filter'=>json_encode($filter),'op'=>json_encode($op)]);
|
|
|
+ }else{
|
|
|
+ $this->whereExtend['exam_collection_id'] = $exam_collection_id;
|
|
|
}
|
|
|
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
|
|
$list = $this->model
|
|
|
->where($where)->where($this->whereExtend)
|
|
|
- ->order($sort, $order)
|
|
|
+// ->order($sort, $order)
|
|
|
+ ->order('user_username asc')
|
|
|
->paginate($limit);
|
|
|
|
|
|
$depart_ids = [];
|
|
@@ -676,7 +719,165 @@ class Exams extends Backend
|
|
|
die();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function report()
|
|
|
+ {
|
|
|
+ //如果发送的来源是 Selectpage,则转发到 Selectpage
|
|
|
+ if ($this->request->request('keyField')) {
|
|
|
+ return $this->selectpage();
|
|
|
+ }
|
|
|
+ $exam_collection_id = $this->model->where($this->whereExtend)->order('exam_id desc')->value('exam_collection_id');
|
|
|
+
|
|
|
+ $filter = $this->request->get("filter", '');
|
|
|
+ $filter = (array)json_decode($filter, true);
|
|
|
+ $op = $this->request->get("op", '');
|
|
|
+ $op = (array)json_decode($op, true);
|
|
|
+
|
|
|
+ $doc_name = '';
|
|
|
+ if(isset($filter) &&!empty($filter['exam_collection_name'])){
|
|
|
+ $doc_name = $filter['exam_collection_name'];
|
|
|
+ unset($this->whereExtend['exam_collection_id']);
|
|
|
+ $this->request->get(['filter'=>json_encode($filter),'op'=>json_encode($op)]);
|
|
|
+ }else{
|
|
|
+ $doc_name = $this->model->where('exam_collection_id',$exam_collection_id)->value('exam_collection_name');
|
|
|
+ $this->whereExtend['exam_collection_id'] = $exam_collection_id;
|
|
|
+ }
|
|
|
+ [$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
|
|
+ $list = $this->model
|
|
|
+ ->where($where)->where($this->whereExtend)
|
|
|
+ ->order('user_username asc')
|
|
|
+ ->paginate($limit);
|
|
|
|
|
|
+ $languageEnGb = new \PhpOffice\PhpWord\Style\Language(\PhpOffice\PhpWord\Style\Language::ZH_CN);
|
|
|
+ $phpWord = new \PhpOffice\PhpWord\PhpWord();
|
|
|
+ $phpWord->getSettings()->setThemeFontLang($languageEnGb);
|
|
|
+
|
|
|
+ $fancyTableStyleName = 'Fancy Table';
|
|
|
+ $fancyTableStyle = array('borderSize' => 1, 'borderColor' => '#cad9ea', 'cellMargin' => 0, 'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER, 'cellSpacing' => 0);
|
|
|
+ $fancyTableFirstRowStyle = array('borderBottomSize' => 0, 'borderBottomColor' => '#ffffff', 'bgColor' => '000000');
|
|
|
+ $fancyTableCellStyle = array('valign' => 'center');
|
|
|
+ $fancyTableFontStyle = array('bold' => true,'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER);
|
|
|
+ $phpWord-> addTableStyle($fancyTableStyleName, $fancyTableStyle, $fancyTableFirstRowStyle);
|
|
|
+
|
|
|
+ //中间学员的成绩信息 start
|
|
|
+ foreach ($list as $k=> $it) {
|
|
|
+ $section_string = 'section'.$k;
|
|
|
+ $section_string = $phpWord->addSection([
|
|
|
+ 'pageSizeH' => \PhpOffice\PhpWord\Shared\Converter::inchToTwip(12.7),
|
|
|
+ 'pageSizeW' => \PhpOffice\PhpWord\Shared\Converter::inchToTwip(8.3)
|
|
|
+ ]);
|
|
|
+ $section_string->addTextBreak(1);
|
|
|
+ $table = $section_string->addTable($fancyTableStyleName);
|
|
|
+ $section_string -> addText($it['user_nickname'].'考试详细',[
|
|
|
+ 'size' => 16,
|
|
|
+ 'name'=>'黑体',
|
|
|
+ ],['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER,
|
|
|
+ 'spaceAfter' => 500, //标题后部预留长度
|
|
|
+ 'spaceBefore' => 0]);
|
|
|
+
|
|
|
+ $TableContentStyle1 = array('size'=>10,'name'=>'宋体','lineHeight' => 1.5);
|
|
|
+
|
|
|
+ $table = $section_string->addTable($fancyTableStyleName);
|
|
|
+ $table->addRow();
|
|
|
+ $table->addCell(2000, $fancyTableCellStyle)->addText("学员账号",$TableContentStyle1, $fancyTableFontStyle);
|
|
|
+ $table->addCell(2000, $fancyTableCellStyle)->addText($it['user_username'],$TableContentStyle1, $fancyTableFontStyle);
|
|
|
+ $table->addCell(2000, $fancyTableCellStyle)->addText("学员姓名",$TableContentStyle1, $fancyTableFontStyle);
|
|
|
+ $table->addCell(2000, $fancyTableCellStyle)->addText($it['user_nickname'],$TableContentStyle1, $fancyTableFontStyle);
|
|
|
+ $table->addCell(2000, $fancyTableCellStyle)->addText("区队",$TableContentStyle1, $fancyTableFontStyle);
|
|
|
+ $table->addCell(2000, $fancyTableCellStyle)->addText($it['user_nickname'],$TableContentStyle1, $fancyTableFontStyle);
|
|
|
+
|
|
|
+ $table->addRow();
|
|
|
+ $table->addCell(2000, $fancyTableCellStyle)->addText("考试开始时间",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table->addCell(2000, $fancyTableCellStyle)->addText("详解",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table->addCell(2000, $fancyTableCellStyle)->addText("考试结束时间",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table->addCell(2000, $fancyTableCellStyle)->addText("详解",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table->addCell(2000, $fancyTableCellStyle)->addText("成绩",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table->addCell(2000, $fancyTableCellStyle)->addText("详解",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+
|
|
|
+ $table2 = $section_string->addTable($fancyTableStyleName);
|
|
|
+ $table2->addRow();
|
|
|
+ $table2->addCell(2500, $fancyTableCellStyle)->addText("序号",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table2->addCell(2500, $fancyTableCellStyle)->addText("评分标准",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table2->addCell(2000, $fancyTableCellStyle)->addText("扣分",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table2->addCell(2500, $fancyTableCellStyle)->addText("维修情况",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table2->addCell(2500, $fancyTableCellStyle)->addText("题目",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+
|
|
|
+ $table3 = $section_string->addTable($fancyTableStyleName);
|
|
|
+ $table3->addRow();
|
|
|
+ $table3->addCell(12000, $fancyTableCellStyle)->addText("一.故障排除(75分)(本题得分:0)",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+
|
|
|
+ //4
|
|
|
+ $table4 = $section_string->addTable($fancyTableStyleName);
|
|
|
+ $table4->addRow();
|
|
|
+
|
|
|
+
|
|
|
+ $table5 = $section_string->addTable($fancyTableStyleName);
|
|
|
+ $table5->addRow();
|
|
|
+ $table5->addCell(12000, $fancyTableCellStyle)->addText("二.修理报告表(15分)(本题得分:0)",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table5->addRow();
|
|
|
+ $table5->addCell(12000, $fancyTableCellStyle)->addText("学员答作答情况",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+
|
|
|
+ $table6 = $section_string->addTable($fancyTableStyleName);
|
|
|
+ $table6->addRow();
|
|
|
+ $table6->addCell(600, $fancyTableCellStyle)->addText("序号",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table6->addCell(2000, $fancyTableCellStyle)->addText("故障现象",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table6->addCell(2000, $fancyTableCellStyle)->addText("可能原因",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table6->addCell(2000, $fancyTableCellStyle)->addText("故障部位",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table6->addCell(2000, $fancyTableCellStyle)->addText("排除方法",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table6->addCell(2000, $fancyTableCellStyle)->addText("扣分原因",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table6->addCell(1400, $fancyTableCellStyle)->addText("扣分情况",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+
|
|
|
+ //7
|
|
|
+ $table8 = $section_string->addTable($fancyTableStyleName);
|
|
|
+ $table8->addRow();
|
|
|
+ $table8->addCell(12000, $fancyTableCellStyle)->addText("故障现象少写或错写1条扣5分;可能原因少写或错写1条扣1分;故障部位少写或错写1条扣1分;排除方法少写或错写1条扣1分。",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table8->addRow();
|
|
|
+ $table8->addCell(12000, $fancyTableCellStyle)->addText("三.维修时间(10分)(本题得分:0)",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+
|
|
|
+
|
|
|
+ $table9 = $section_string->addTable($fancyTableStyleName);
|
|
|
+ $table9->addRow();
|
|
|
+ $table9->addCell(4500, $fancyTableCellStyle)->addText("按没超过1分钟扣1分的比例扣分",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table9->addCell(3000, $fancyTableCellStyle)->addText("考试时长:291分55秒",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table9->addCell(1500, $fancyTableCellStyle)->addText("扣分:10",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+
|
|
|
+
|
|
|
+ $table10 = $section_string->addTable($fancyTableStyleName);
|
|
|
+ $table10->addRow();
|
|
|
+ $table10->addCell(6000, $fancyTableCellStyle)->addText("五.成绩",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ $table10->addCell(6000, $fancyTableCellStyle)->addText("",['name'=>'宋体','size'=>10], $fancyTableFontStyle);
|
|
|
+ }
|
|
|
+ //中间学员的成绩信息 end
|
|
|
+
|
|
|
+ $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
|
|
|
+
|
|
|
+ $file_name = $doc_name.'.docx';//''uploads/'.date('Ymd').'/'.$userInfo['grade'].'年级'.$userInfo['classed'].'班级'.$userInfo['nickname'].'.docx';
|
|
|
+
|
|
|
+ $tmpPath ='uploads/'.date('Ymd').'/';
|
|
|
+ if(!file_exists($tmpPath)){
|
|
|
+ mkdir($tmpPath, 0777, true);
|
|
|
+ }
|
|
|
+ $objWriter->save($file_name);
|
|
|
+ //以只读和二进制模式打开文件
|
|
|
+ $file = fopen ( $file_name, "rb" );
|
|
|
+
|
|
|
+ //告诉浏览器这是一个文件流格式的文件
|
|
|
+ Header ( "Content-type: application/octet-stream" );
|
|
|
+ //请求范围的度量单位
|
|
|
+ Header ( "Accept-Ranges: bytes" );
|
|
|
+ //Content-Length是指定包含于请求或响应中数据的字节长度
|
|
|
+ Header ( "Accept-Length: " . filesize ( $file_name ) );
|
|
|
+ //用来告诉浏览器,文件是可以当做附件被下载,下载后的文件名称为$file_name该变量的值。
|
|
|
+ Header ( "Content-Disposition: attachment; filename=".$doc_name.'.docx' );
|
|
|
+
|
|
|
+ //读取文件内容并直接输出到浏览器
|
|
|
+ echo fread ( $file, filesize ( $file_name ) );
|
|
|
+ fclose ( $file );
|
|
|
+ exit ();
|
|
|
+ }
|
|
|
|
|
|
public function multi($ids = null)
|
|
|
{
|