From b20d4801d0a5422b34123098d2ce4d27e31700c9 Mon Sep 17 00:00:00 2001 From: cxdbz Date: Mon, 12 Nov 2018 08:13:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=95=E5=8D=B7=E6=BB=A1?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/teach/controller/Kaoshi.php | 19 +++++++++-- application/teach/validate/Kaoshi.php | 1 + application/teach/view/kaoshi/create.html | 34 +++++++++++++++++-- .../20181030072733_kaoshi_subject.php | 2 +- 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/application/teach/controller/Kaoshi.php b/application/teach/controller/Kaoshi.php index 72f11067..c09147e0 100644 --- a/application/teach/controller/Kaoshi.php +++ b/application/teach/controller/Kaoshi.php @@ -111,7 +111,7 @@ class Kaoshi extends Base // 获取表单数据 - $list = request()->only(['title','xueqi','category','bfdate','enddate','nianji','subject'],'post'); + $list = request()->only(['title','xueqi','category','bfdate','enddate','nianji','subject','manfen'],'post'); // 验证表单数据 @@ -144,10 +144,25 @@ class Kaoshi extends Base + // 过滤掉空值 + $delarr = array(); + foreach ($list['manfen'] as $key => $value) { + if($value == '') + { + unset($list['manfen'][$value]); + } + } + + $i = 0; // 重组参加考试学科信息 foreach ($list['subject'] as $key => $value) { - $subjectarr[]=['subjectid'=>$value]; + $subjectarr[$i]=[ + 'subjectid'=>$value, + 'manfen'=>$list['manfen'][$i] + ]; + $i++; } + // 添加考试学科信息 $xkdata = $ksdata->kaoshisubject()->saveAll($subjectarr); diff --git a/application/teach/validate/Kaoshi.php b/application/teach/validate/Kaoshi.php index 6c489c68..a6e4b117 100644 --- a/application/teach/validate/Kaoshi.php +++ b/application/teach/validate/Kaoshi.php @@ -20,6 +20,7 @@ class Kaoshi extends Validate 'enddate|考试时间' => 'require|date', 'nianji|参考年级' => 'require|array', 'subject|参考学科' => 'require|array', + 'manfen|满分' => 'require|array', ]; /** diff --git a/application/teach/view/kaoshi/create.html b/application/teach/view/kaoshi/create.html index 612bc8d9..45bece14 100644 --- a/application/teach/view/kaoshi/create.html +++ b/application/teach/view/kaoshi/create.html @@ -65,11 +65,16 @@
{foreach $sjlist as $key=>$vo } +
{/foreach} + + +
+ {/foreach} +
@@ -114,5 +119,30 @@ // 设置表单提交方式 var mytype = 'POST'; + + + // 选择学科添加满分文本框 + function xueke(obj) + { + // 当选中复选框,则添加满分,否则删除满分 + if($(obj).prop('checked') == true) + { + $(obj).parents('dd').find('input[type=text]').val(100); + }else{ + $(obj).parents('dd').find('input[type=text]').val(''); + } + } + + // 添满分后自动选复选框 + function manfenbut(obj) + { + // 当文本框输入数字时,则选中复选框,否则不选中 + if( $(obj).val() > 0 ) + { + $(obj).parents('dd').find('input[type=checkbox]').attr('checked',true); + }else{ + $(obj).parents('dd').find('input[type=checkbox]').attr('checked',false); + } + } {/block} \ No newline at end of file diff --git a/database/migrations/20181030072733_kaoshi_subject.php b/database/migrations/20181030072733_kaoshi_subject.php index edebb8e7..ecced842 100644 --- a/database/migrations/20181030072733_kaoshi_subject.php +++ b/database/migrations/20181030072733_kaoshi_subject.php @@ -34,7 +34,7 @@ class KaoshiSubject extends Migrator // 添加当前表字段 $table ->addColumn('kaoshiid','integer',['limit'=>11,'null'=>false,'comment'=>'考试id']) - ->addColumn('subjectid','integer',['limit'=>170,'null'=>false,'comment'=>'年级']) + ->addColumn('subjectid','integer',['limit'=>11,'null'=>false,'comment'=>'学科id']) ->addColumn('manfen','integer',['limit'=>3,'null'=>false,'comment'=>'满分']) ->addColumn('youxiu','integer',['limit'=>3,'null'=>false,'comment'=>'优秀']) ->addColumn('jige','integer',['limit'=>3,'null'=>false,'comment'=>'及格'])