lqmac 7 months ago
parent a07704fd30
commit 949eddd5ca
  1. 44
      application/admin/controller/questions/TestPaper.php
  2. 18
      application/admin/model/questions/TestPaper.php
  3. 27
      application/admin/model/questions/TestPaperQuestions.php
  4. 160
      application/admin/model/questions/paper.php
  5. 389
      application/admin/view/questions/test_paper/add.php
  6. 6
      application/common.php
  7. 4
      application/wap/controller/Special.php
  8. 6
      application/wap/controller/Topic.php
  9. 8
      application/wap/model/topic/TestPaperQuestions.php

@ -34,6 +34,7 @@ use app\admin\model\merchant\Merchant;
use app\admin\model\system\WebRecommend;
use app\admin\model\system\WebRecommendRelation;
use app\admin\model\user\User;
/**
* 试卷
* Class TestPaper
@ -181,6 +182,7 @@ class TestPaper extends AuthController
return Json::fail('操作失败!');
}
}
/**
* 用户答题记录
*/
@ -218,6 +220,7 @@ class TestPaper extends AuthController
// $this->assign(['record_id' => $record_id, 'test_id' => $test_id, 'type' => $type]);
return $this->fetch();
}
/**答题信息
* @param $uid
* @return void
@ -231,6 +234,7 @@ class TestPaper extends AuthController
$data = User::where(['uid' => $uid])->field('nickname,name,uid,avatar')->find();
return Json::successful($data);
}
/**成绩
* @param int $record_id
* @param int $test_id
@ -252,6 +256,7 @@ class TestPaper extends AuthController
$data['start_time'] = date('Y-m-d H:i', $record['start_time']);
return Json::successful($data);
}
/**试卷中的试题答题情况
* @param int $id
* @param int $type
@ -303,6 +308,13 @@ class TestPaper extends AuthController
return $this->fetch('questions');
}
public function paper($id = 1)
{
$this->assign(['id' => $id, 'question_type' => 5, 'cateList' => QuestionsCategpry::taskCategoryAll(2)]);
return $this->fetch('paper');
}
/**
* 获取题库列表
*/
@ -312,14 +324,28 @@ class TestPaper extends AuthController
['page', 1],
['limit', 20],
['pid', 0],
['title', '']
['title', ''],
['type', 1],
]);
$where['type'] = $question_type;
$arrays = [];
if ($id) {
$arrays = TestPaperQuestions::where(['test_id' => $id])->column('questions_id');
// if ($question_type == 5) {
//// $where['ids'] = TestPaperQuestions::where(['test_id' => $id,])->where('pid', '>',0)->column('test_id');
// } else {
//
// }
}
if ($question_type == 5) {
$where['type'] = 1;
$where['status'] = 1;
$list = \app\admin\model\questions\TestPaper::testPaperExercisesList($where);
} else {
$list = Questions::questionsList($where, $arrays);
}
return Json::successlayui($list);
}
@ -368,11 +394,13 @@ class TestPaper extends AuthController
$many_tmp_list = TestPaperQuestions::gettestPaperQuestions($id, 2);
$judge_tmp_list = TestPaperQuestions::gettestPaperQuestions($id, 3);
$answer_tmp_list = TestPaperQuestions::gettestPaperQuestions($id, 4);
$paper_tmp_list = TestPaperQuestions::gettestPaperQuestions($id, 5)->toArray();
if ($type == 2) $grade = TestPaperScoreGrade::testPaperScoreGradeList($id);
} else {
$single_tmp_list = [];
$many_tmp_list = [];
$judge_tmp_list = [];
$paper_tmp_list = [];
$answer_tmp_list = [];
}
$this->assign([
@ -383,6 +411,7 @@ class TestPaper extends AuthController
'single_tmp_list' => json_encode($single_tmp_list),
'many_tmp_list' => json_encode($many_tmp_list),
'judge_tmp_list' => json_encode($judge_tmp_list),
'paper_tmp_list' => json_encode($paper_tmp_list),
'answer_tmp_list' => json_encode($answer_tmp_list)
]);
return $this->fetch();
@ -439,12 +468,15 @@ class TestPaper extends AuthController
['judgeIds', ''],
['answerIds', ''],
['grade', ''],
['sort', 0]
['sort', 0],
['paperIds', ""]
]);
if ($data['tid'] <= 0) return Json::fail('请选择试题分类');
if (!$data['title']) return Json::fail('请输入试卷标题');
if ($type == 2 && !$data['image']) return Json::fail('请添加试卷封面图');
if($data['paperIds'] == '') {
if ($data['single_number'] < 0 || $data['many_number'] < 0 || $data['judge_number'] < 0) return Json::fail('各类型题目数量不能小于0');
}
$data['item_number'] = bcadd($data['single_number'], bcadd($data['many_number'], $data['judge_number'] + $data['answer_number'], 0), 0);
$total_single_score = bcmul($data['single_number'], $data['single_score'], 0);
$total_many_score = bcmul($data['many_number'], $data['many_score'], 0);
@ -466,6 +498,7 @@ class TestPaper extends AuthController
$manyIds = json_decode($data['manyIds']);
$judgeIds = json_decode($data['judgeIds']);
$answerIds = json_decode($data['answerIds']);
$paperIds = json_decode($data['paperIds'], true);
$grade = json_decode($data['grade'], true);
TestPaperModel::beginTrans();
if ($id) {
@ -480,11 +513,13 @@ class TestPaper extends AuthController
$res3 = TestPaperQuestions::addTestPaperQuestions($id, $type, (int)$data['many_number'], $manyIds ?? [], $data['many_score']);
$res4 = TestPaperQuestions::addTestPaperQuestions($id, $type, (int)$data['judge_number'], $judgeIds ?? [], $data['judge_score']);
$res4 = TestPaperQuestions::addTestPaperQuestions($id, $type, (int)$data['answer_number'], $answerIds ?? [], $data['answer_score']);
$res6 = TestPaperQuestions::addTestPaper($id, $paperIds);
} else {
$res2 = TestPaperQuestions::addRandomGroupQuestions($id, $type, 1, $data['cate_id'], (int)$data['single_number'], $data['single_score']);
$res3 = TestPaperQuestions::addRandomGroupQuestions($id, $type, 2, $data['cate_id'], (int)$data['many_number'], $data['many_score']);
$res4 = TestPaperQuestions::addRandomGroupQuestions($id, $type, 3, $data['cate_id'], (int)$data['judge_number'], $data['judge_score']);
$res4 = TestPaperQuestions::addRandomGroupQuestions($id, $type, 4, $data['cate_id'], (int)$data['answer_number'], $data['answer_score']);
$res6 = true;
}
$res5 = $this->inspectTestQuestions($id);
} else {
@ -493,6 +528,7 @@ class TestPaper extends AuthController
if (TestPaperModel::be(['title' => $data['title'], 'is_del' => 0])) {
return Json::fail('标题已存在!');
}
$res = TestPaperModel::insertGetId($data);
$res1 = true;
if ($type == 2) {
@ -503,15 +539,17 @@ class TestPaper extends AuthController
$res3 = TestPaperQuestions::addTestPaperQuestions($res, $type, (int)$data['many_number'], $manyIds, $data['many_score']);
$res4 = TestPaperQuestions::addTestPaperQuestions($res, $type, (int)$data['judge_number'], $judgeIds, $data['judge_score']);
$res4 = TestPaperQuestions::addTestPaperQuestions($res, $type, (int)$data['answer_number'], $answerIds, $data['answer_score']);
$res6 = TestPaperQuestions::addTestPaper($res, $paperIds);
} else {
$res2 = TestPaperQuestions::addRandomGroupQuestions($res, $type, 1, $data['cate_id'], (int)$data['single_number'], $data['single_score']);
$res3 = TestPaperQuestions::addRandomGroupQuestions($res, $type, 2, $data['cate_id'], (int)$data['many_number'], $data['many_score']);
$res4 = TestPaperQuestions::addRandomGroupQuestions($res, $type, 3, $data['cate_id'], (int)$data['judge_number'], $data['judge_score']);
$res4 = TestPaperQuestions::addRandomGroupQuestions($res, $type, 4, $data['cate_id'], (int)$data['answer_number'], $data['answer_score']);
$res6 = true;
}
$res5 = $this->inspectTestQuestions($res);
}
if ($res && $res1 && $res2 && $res3 && $res4 && $res5) {
if ($res && $res1 && $res2 && $res3 && $res4 && $res5 && $res6) {
TestPaperModel::commitTrans();
return Json::successful('添加/编辑成功');
} else {

@ -22,6 +22,7 @@ use service\WechatTemplateService;
use app\wap\model\routine\RoutineTemplate;
use app\admin\model\wechat\WechatUser;
use app\admin\model\system\WebRecommendRelation;
/**
* 试卷列表 Model
* Class TestPaper
@ -34,9 +35,10 @@ class TestPaper extends ModelBasic
public static function setWhere($where)
{
$model = self::order('sort desc,add_time desc')->where(['is_del' => 0]);
if (isset($where['pid']) && $where['pid']) $model = $model->where('tid', $where['pid']);
if (isset($where['pid']) && $where['pid'] > 0) $model = $model->where('tid', $where['pid']);
if (isset($where['type']) && $where['type']) $model = $model->where('type', $where['type']);
if (isset($where['is_show']) && $where['is_show'] != '') $model = $model->where('is_show', $where['is_show']);
if (isset($where['ids']) && count($where['ids']) > 0) $model = $model->whereIn('id', $where['ids']);
if ($where['title'] != '') $model = $model->where('title', 'like', "%$where[title]%");
if (isset($where['mer_id']) && $where['mer_id'] != '') {
$model = $model->where('mer_id', $where['mer_id']);
@ -55,6 +57,8 @@ class TestPaper extends ModelBasic
public static function testPaperExercisesList($where)
{
$data = self::setWhere($where)->page($where['page'], $where['limit'])->select();
foreach ($data as $key => &$value) {
$value['cate'] = TestPaperCategoryModel::where('id', $value['tid'])->value('title');
$value['recommend'] = RecommendRelation::where('a.link_id', $value['id'])->where('a.type', 'in', '11,12')->alias('a')
@ -67,10 +71,21 @@ class TestPaper extends ModelBasic
} else {
$value['mer_name'] = '总平台';
}
$ids = TestPaperQuestions::where(['test_id' => $value['id']])->column('pid');
if (count($ids) > 0) {
$papers = TestPaper::whereIn('id', $ids)->select();
$value['item_number'] = $value['item_number'] + array_sum($papers->column('item_number'));
$value['single_number'] = $value['single_number'] + array_sum($papers->column('single_number'));
$value['many_number'] = $value['many_number'] + array_sum($papers->column('many_number'));
$value['judge_number'] = $value['judge_number'] + array_sum($papers->column('judge_number'));
$value['answer_number'] = $value['answer_number'] + array_sum($papers->column('answer_number'));
$value['answer'] = $value['answer'] + array_sum($papers->column('answer'));
}
}
$count = self::setWhere($where)->count();
return compact('data', 'count');
}
/**发送试卷列表
* @param $where
*/
@ -110,6 +125,7 @@ class TestPaper extends ModelBasic
$count = self::setWhere($where)->count();
return compact('data', 'count');
}
/**试卷列表
* @param $type
* @return false|\PDOStatement|string|\think\Collection

@ -11,6 +11,8 @@
namespace app\admin\model\questions;
use think\Collection;
use think\helper\Arr;
use traits\ModelTrait;
use basic\ModelBasic;
use service\UtilService as Util;
@ -49,6 +51,22 @@ class TestPaperQuestions extends ModelBasic
return true;
}
public static function addTestPaper($id, $data)
{
foreach ($data as $v) {
$item = [];
$item['type'] = 2;
$item['question_type'] = 5;
$item['test_id'] = $id;
$item['questions_id'] = 0;
$item['pid'] = $v['id'];
if (self::be($item)) continue;
self::set($item);
}
return true;
}
/**试题列表
* @param $id
*/
@ -148,6 +166,15 @@ class TestPaperQuestions extends ModelBasic
public static function gettestPaperQuestions($id, $question_type)
{
if (!$id) return [];
if ($question_type == 5) {
$ids = self::where(['test_id' => $id, 'question_type' => $question_type])->column('pid');
return TestPaper::alias('t1')
->join('TestPaperCategory t2', 't1.tid=t2.id')
->whereIn('t1.id', $ids)
->field("t1.id,t1.title,t2.title as cate")
->select();
}
return self::alias('t')->where(['t.test_id' => $id, 't.question_type' => $question_type, 'q.is_del' => 0])->order('sort desc,id desc')
->join('Questions q', 't.questions_id=q.id')
->field('t.sort,t.test_id,q.id,q.question_type,q.pid,q.stem,q.is_del,q.is_img')

@ -0,0 +1,160 @@
{extend name="public/container"}
{block name="content"}
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">搜索条件</div>
<div class="layui-card-body">
<div class="layui-form layui-form-pane">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">试卷名称</label>
<div class="layui-input-inline">
<input type="text" name="title" id="demoReload" placeholder="请输入试卷名称" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" data-type="reload">搜索</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!--产品列表-->
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">试卷列表</div>
<div class="layui-card-body">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-normal layui-btn-sm" onclick="window.location.reload()"><i class="layui-icon layui-icon-refresh"></i> 刷新</button>
</div>
<table class="layui-hide" id="List" lay-filter="List"></table>
<script type="text/html" id="image">
<img style="cursor: pointer;width: 80px;height: 40px;" lay-event='open_image' src="{{d.image}}">
</script>
</div>
</div>
</div>
</div>
</div>
<script src="{__ADMIN_PATH}js/layuiList.js"></script>
{/block}
{block name="script"}
<script>
var table_date=new Array();//用于保存当前页数据
var ids=new Array(); //用于保存选中的数据
var id={$id}
//实例化form
layList.form.render();
var table = layui.table;
table.render({
elem: '#List'
,url:"{:Url('questions.test_paper/getTestQuestionsList')}?question_type=5"+'&id='+id
,cols: [[
{type: 'checkbox'},
{field: 'id', title: '编号',align: 'center'},
{field: 'title', title: '试卷名称', align: 'center'},
{field: 'cate', title: '分类',align: 'center'},
]]
,id: 'testReload'
,page: {
theme: '#0092dc'
}
,limit:10
,done:function (res,curr,count) {
table_date=res.data;
for(var i=0;i< res.data.length;i++){
if(ids.length>0){
for (var j = 0; j < ids.length; j++) {
if(res.data[i].id == ids[j].id) {
res.data[i]["LAY_CHECKED"]='true';/*设置勾选*/
/*找到对应数据改变勾选样式*/
var index= res.data[i]['LAY_TABLE_INDEX'];
$('tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
$('tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
}
}
}
}
var checkStatus = table.checkStatus('List');/*获得选中的值 和判断是否是全选 isAll true全选 isAlL false 没有全选*/
if(checkStatus.isAll){
$('.layui-table-header th[data-field="0"] input[type="checkbox"]').prop('checked', true);
$('.layui-table-header th[data-field="0"] div[class="layui-unselect layui-form-checkbox"]').addClass('layui-form-checked');
}
removeArrayRepElement(ids);
$("#check_questions_tmp_"+question_type,window.parent.document).val(JSON.stringify(ids));
}
});
var $ = layui.$, active = {
reload: function(){
var demoReload = $('#demoReload');
//执行重载
table.reload('testReload', {
page: {
curr: 1 //重新从第 1 页开始
}
,where: {
title: demoReload.val(),
pid:$('#pids option:selected').val(),
}
}, 'data');
}
};
$('.layui-btn').on('click', function(){
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
//删除重复
function removeArrayRepElement(arr) {
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr.length; j++) {
if (arr[i].id == arr[j].id && i != j) {
arr.splice(j, 1);
}
}
}
return arr;
}
table.on('checkbox(List)', function (obj) {
if(obj.checked==true){
if(obj.type=='one'){
ids.push(obj.data);
}else{
for(var i=0;i<table_date.length;i++){
ids.push(table_date[i]);
}
}
ids=removeArrayRepElement(ids);
}else{
if(obj.type=='one'){
for(var i=0;i<ids.length;i++){
if(ids[i].id==obj.data.id){
ids.remove(i);
}
}
}else{
for(var i=0;i<ids.length;i++){
for(var j=0;j<table_date.length;j++){
if(ids[i].id==table_date[j].id){
ids.remove(i);
}
}
}
}
}
$("#check_questions_tmp_"+question_type,window.parent.document).val(JSON.stringify(ids));
});
Array.prototype.remove=function(dx){
if(isNaN(dx)||dx>this.length){return false;}
for(var i=0,n=0;i<this.length;i++)
{
if(this[i]!=this[dx]){
this[n++]=this[i];
}
}
this.length-=1;
};
</script>
{/block}

@ -47,7 +47,8 @@
background-position: -380px 0px;
}
</style>
<script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/ueditor/third-party/zeroclipboard/ZeroClipboard.js"></script>
<script type="text/javascript" charset="utf-8"
src="{__ADMIN_PATH}plug/ueditor/third-party/zeroclipboard/ZeroClipboard.js"></script>
<script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/ueditor/ueditor.all.min.js"></script>
{/block}
@ -67,7 +68,9 @@
<div class="layui-form-item">
<label class="layui-form-label required">{$type==1 ? '练习名称' : '考试名称'}:</label>
<div class="layui-input-block">
<input type="text" name="title" v-model.trim="formData.title" autocomplete="off" placeholder="请输入{$type==1 ? '练习名称' : '考试名称'}" maxlength="30" class="layui-input">
<input type="text" name="title" v-model.trim="formData.title" autocomplete="off"
placeholder="请输入{$type==1 ? '练习名称' : '考试名称'}" maxlength="30"
class="layui-input">
</div>
</div>
<div class="layui-form-item">
@ -75,17 +78,21 @@
<div class="layui-input-block">
<select name="tid" v-model="formData.tid" lay-search="" lay-filter="tid">
<option value="">请选择{$type==1 ? '练习分类' : '考试分类'}</option>
<option v-for="item in cateList" :disabled="item.pid==0 ? true : false" :value="item.id">{{item.html}}{{item.title}}</option>
<option v-for="item in cateList" :disabled="item.pid==0 ? true : false"
:value="item.id">{{item.html}}{{item.title}}
</option>
</select>
</div>
</div>
<div class="layui-form-item" v-show="type==2">
<label :class="{ required: type == 2 }" class="layui-form-label">考试封面:(710*400)</label>
<label :class="{ required: type == 2 }"
class="layui-form-label">考试封面:(710*400)</label>
<div class="layui-input-block">
<div class="upload-image-box" v-if="formData.image">
<img :src="formData.image" alt="">
<div class="mask">
<p><i class="fa fa-eye" @click="look(formData.image)"></i><i class="fa fa-trash-o" @click="delect('image')"></i></p>
<p><i class="fa fa-eye" @click="look(formData.image)"></i><i
class="fa fa-trash-o" @click="delect('image')"></i></p>
</div>
</div>
<div class="upload-image" v-show="!formData.image" @click="upload('image')">
@ -98,99 +105,115 @@
<div class="layui-inline">
<label class="layui-form-label required">单选题数量:</label>
<div class="layui-input-inline">
<input type="number" name="single_number" v-model.number="formData.single_number" min="0" autocomplete="off" class="layui-input">
<input type="number" name="single_number"
v-model.number="formData.single_number" min="0" autocomplete="off"
class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">题型排序/倒序:</label>
<div class="layui-input-inline">
<input type="number" name="single_sort" v-model="formData.single_sort" autocomplete="off" class="layui-input">
<input type="number" name="single_sort" v-model="formData.single_sort"
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline" v-show="type==2">
<!-- <div class="layui-inline" v-show="type==2">-->
<label class="layui-form-label">每题分数:</label>
<div class="layui-input-inline">
<input type="number" name="single_score" v-model="formData.single_score" autocomplete="off" class="layui-input">
</div>
<input type="number" name="single_score" v-model="formData.single_score"
autocomplete="off" class="layui-input">
</div>
<!-- </div>-->
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label required">多选题数量:</label>
<div class="layui-input-inline">
<input type="number" name="many_number" v-model.number="formData.many_number" min="0" autocomplete="off" class="layui-input">
<input type="number" name="many_number" v-model.number="formData.many_number"
min="0" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">题型排序/倒序:</label>
<div class="layui-input-inline">
<input type="number" name="many_sort" v-model="formData.many_sort" autocomplete="off" class="layui-input">
<input type="number" name="many_sort" v-model="formData.many_sort"
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline" v-show="type==2">
<!-- <div class="layui-inline" v-show="type==2">-->
<label class="layui-form-label">每题分数:</label>
<div class="layui-input-inline">
<input type="number" name="many_score" v-model="formData.many_score" autocomplete="off" class="layui-input">
</div>
<input type="number" name="many_score" v-model="formData.many_score"
autocomplete="off" class="layui-input">
</div>
<!-- </div>-->
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label required">判断题数量:</label>
<div class="layui-input-inline">
<input type="number" name="judge_number" v-model.number="formData.judge_number" min="0" autocomplete="off" class="layui-input">
<input type="number" name="judge_number" v-model.number="formData.judge_number"
min="0" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">题型排序/倒序:</label>
<div class="layui-input-inline">
<input type="number" name="judge_sort" v-model="formData.judge_sort" autocomplete="off" class="layui-input">
<input type="number" name="judge_sort" v-model="formData.judge_sort"
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline" v-show="type==2">
<!-- <div class="layui-inline" v-show="type==2">-->
<label class="layui-form-label">每题分数:</label>
<div class="layui-input-inline">
<input type="number" name="judge_score" v-model="formData.judge_score" autocomplete="off" class="layui-input">
</div>
<input type="number" name="judge_score" v-model="formData.judge_score"
autocomplete="off" class="layui-input">
</div>
<!-- </div>-->
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label required">简答题数量:</label>
<div class="layui-input-inline">
<input type="number" name="judge_number" v-model.number="formData.answer_number" min="0" autocomplete="off" class="layui-input">
<input type="number" name="judge_number" v-model.number="formData.answer_number"
min="0" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">题型排序/倒序:</label>
<div class="layui-input-inline">
<input type="number" name="answer_sort" v-model="formData.answer_sort" autocomplete="off" class="layui-input">
<input type="number" name="answer_sort" v-model="formData.answer_sort"
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline" v-show="type==2">
<!-- <div class="layui-inline" v-show="type==2">-->
<label class="layui-form-label">每题分数:</label>
<div class="layui-input-inline">
<input type="number" name="answer_score" v-model="formData.answer_score" autocomplete="off" class="layui-input">
</div>
<input type="number" name="answer_score" v-model="formData.answer_score"
autocomplete="off" class="layui-input">
</div>
<!-- </div>-->
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">试题总数:</label>
<div class="layui-input-inline">
<input type="number" name="item_number" :value="sum" min="0" disabled autocomplete="off" class="layui-input">
<input type="number" name="item_number" :value="sum" min="0" disabled
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline" v-show="type==2">
<label class="layui-form-label">总分数:</label>
<div class="layui-input-inline">
<input type="number" name="total_score" :value="total" autocomplete="off" disabled class="layui-input">
<input type="number" name="total_score" :value="total" autocomplete="off"
disabled class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">虚拟答题人数:</label>
<div class="layui-input-inline">
<input type="number" name="fake_sales" v-model="formData.fake_sales" autocomplete="off" class="layui-input">
<input type="number" name="fake_sales" v-model="formData.fake_sales"
autocomplete="off" class="layui-input">
</div>
</div>
</div>
@ -198,13 +221,15 @@
<div class="layui-inline" v-show="type==2">
<label :class="{ required: type == 2 }" class="layui-form-label">时长/分:</label>
<div class="layui-input-inline">
<input type="number" name="txamination_time" v-model="formData.txamination_time" lay-verify="number" autocomplete="off" class="layui-input" min="0">
<input type="number" name="txamination_time" v-model="formData.txamination_time"
lay-verify="number" autocomplete="off" class="layui-input" min="0">
</div>
</div>
<div class="layui-inline" v-show="type==2">
<label :class="{ required: type == 2 }" class="layui-form-label">考试次数:</label>
<div class="layui-input-inline">
<input type="number" name="frequency" v-model="formData.frequency" autocomplete="off" class="layui-input">
<input type="number" name="frequency" v-model="formData.frequency"
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline" v-show="type==2" style="color: red;">注:[0为不限制次数]</div>
@ -212,8 +237,10 @@
<div class="layui-form-item submit" v-show="type==2">
<label class="layui-form-label">分数显示:</label>
<div class="layui-input-block">
<input type="radio" name="is_score" lay-filter="is_score" v-model="formData.is_score" value="1" title="显示">
<input type="radio" name="is_score" lay-filter="is_score" v-model="formData.is_score" value="0" title="隐藏">
<input type="radio" name="is_score" lay-filter="is_score"
v-model="formData.is_score" value="1" title="显示">
<input type="radio" name="is_score" lay-filter="is_score"
v-model="formData.is_score" value="0" title="隐藏">
</div>
</div>
<div class="layui-form-item">
@ -227,36 +254,48 @@
<div class="layui-input-block">
<div class="layui-inline">
<div class="layui-input-inline">
<input v-model="item.grade_name" type="text" required lay-verify="required" maxlength="60" placeholder="名称" autocomplete="off" class="layui-input">
<input v-model="item.grade_name" type="text" required lay-verify="required"
maxlength="60" placeholder="名称" autocomplete="off"
class="layui-input">
</div>
</div>
<div class="layui-inline">
<div class="layui-input-inline">
<input v-model="item.grade_standard" type="text" required lay-verify="required" maxlength="60" placeholder="区间" autocomplete="off" class="layui-input">
<input v-model="item.grade_standard" type="text" required
lay-verify="required" maxlength="60" placeholder="区间"
autocomplete="off" class="layui-input">
</div>
</div>
<div v-if="index && index === grade.length - 1" class="layui-inline">
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" @click="onDel">删除选项</button>
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm"
@click="onDel">删除选项
</button>
</div>
</div>
</div>
<div class="layui-form-item" v-show="type==2">
<div class="layui-input-block">
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" @click="onAdd">添加选项</button>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm"
@click="onAdd">添加选项
</button>
</div>
</div>
<div class="layui-form-item submit">
<label class="layui-form-label">组题方式:</label>
<div class="layui-input-block">
<input type="radio" name="is_group" lay-filter="is_group" v-model="formData.is_group" value="1" title="手动组题">
<input type="radio" name="is_group" lay-filter="is_group" v-model="formData.is_group" value="2" title="随机组题">
<input type="radio" name="is_group" lay-filter="is_group"
v-model="formData.is_group" value="1" title="手动组题">
<input type="radio" name="is_group" lay-filter="is_group"
v-model="formData.is_group" value="2" title="随机组题">
</div>
</div>
<div class="layui-form-item submit">
<label class="layui-form-label">{$type==1 ? '练习状态' : '考试状态'}:</label>
<div class="layui-input-block">
<input type="radio" name="is_show" lay-filter="is_show" v-model="formData.is_show" value="1" title="显示">
<input type="radio" name="is_show" lay-filter="is_show" v-model="formData.is_show" value="0" title="隐藏">
<input type="radio" name="is_show" lay-filter="is_show" v-model="formData.is_show"
value="1" title="显示">
<input type="radio" name="is_show" lay-filter="is_show" v-model="formData.is_show"
value="0" title="隐藏">
</div>
</div>
</div>
@ -274,7 +313,8 @@
<label class="layui-form-label">题库展示:</label>
<div class="layui-input-block">
<input type="hidden" id="check_questions_sure_1" name="check_questions_sure_1"/>
<table class="layui-hide" id="showQuestionsList_1" lay-filter="showQuestionsList_1"></table>
<table class="layui-hide" id="showQuestionsList_1"
lay-filter="showQuestionsList_1"></table>
</div>
</div>
<div class="layui-form-item" v-show="formData.is_group==1">
@ -290,7 +330,8 @@
<label class="layui-form-label">题库展示:</label>
<div class="layui-input-block">
<input type="hidden" id="check_questions_sure_2" name="check_questions_sure_2"/>
<table class="layui-hide" id="showQuestionsList_2" lay-filter="showQuestionsList_2"></table>
<table class="layui-hide" id="showQuestionsList_2"
lay-filter="showQuestionsList_2"></table>
</div>
</div>
<div class="layui-form-item" v-show="formData.is_group==1">
@ -306,7 +347,8 @@
<label class="layui-form-label">题库展示:</label>
<div class="layui-input-block">
<input type="hidden" id="check_questions_sure_3" name="check_questions_sure_3"/>
<table class="layui-hide" id="showQuestionsList_3" lay-filter="showQuestionsList_3"></table>
<table class="layui-hide" id="showQuestionsList_3"
lay-filter="showQuestionsList_3"></table>
</div>
</div>
<div class="layui-form-item" v-show="formData.is_group==1">
@ -322,14 +364,37 @@
<label class="layui-form-label">题库展示:</label>
<div class="layui-input-block">
<input type="hidden" id="check_questions_sure_4" name="check_questions_sure_4"/>
<table class="layui-hide" id="showQuestionsList_4" lay-filter="showQuestionsList_4"></table>
<table class="layui-hide" id="showQuestionsList_4"
lay-filter="showQuestionsList_4"></table>
</div>
</div>
<div class="layui-form-item" v-show="formData.is_group==1">
<label class="layui-form-label">组合题:</label>
<div class="layui-input-block">
<input type="hidden" id="check_questions_tmp_5" name="check_questions_tmp_5"/>
<button type="button" class="layui-btn layui-btn-normal" @click='questions_paper'>
选择练习试卷
</button>
</div>
</div>
<div class="layui-form-item" v-show="formData.is_group==1">
<label class="layui-form-label">试卷展示:</label>
<div class="layui-input-block">
<input type="hidden" id="check_questions_sure_5" name="check_questions_sure_5"/>
<table class="layui-hide" id="showQuestionsList_5"
lay-filter="showQuestionsList_5"></table>
</div>
</div>
<div class="layui-form-item" v-show="formData.is_group==2">
<label class="layui-form-label">题库分类:</label>
<div class="layui-input-block">
<select name="cate_id" v-model="formData.cate_id" lay-search="" lay-filter="cate_id">
<option v-for="item in questionsCateList" :value="item.id">{{item.html}}{{item.title}}</option>
<select name="cate_id" v-model="formData.cate_id" lay-search=""
lay-filter="cate_id">
<option v-for="item in questionsCateList" :value="item.id">
{{item.html}}{{item.title}}
</option>
</select>
</div>
</div>
@ -339,38 +404,49 @@
<div class="layui-form-item">
<label class="layui-form-label">付费方式:</label>
<div class="layui-input-block">
<input type="radio" name="pay_type" lay-filter="pay_type" v-model="formData.pay_type" value="1" title="付费">
<input type="radio" name="pay_type" lay-filter="pay_type" v-model="formData.pay_type" value="0" title="免费">
<input type="radio" name="pay_type" lay-filter="pay_type"
v-model="formData.pay_type" value="1" title="付费">
<input type="radio" name="pay_type" lay-filter="pay_type"
v-model="formData.pay_type" value="0" title="免费">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="padding: 9px 0;">人工阅卷金额:</label>
<div class="layui-input-block">
<input style="width: 300px" type="number" name="manual_grading_price" lay-verify="number" v-model="formData.manual_grading_price" autocomplete="off" class="layui-input" min="0">
<input style="width: 300px" type="number" name="manual_grading_price"
lay-verify="number" v-model="formData.manual_grading_price"
autocomplete="off" class="layui-input" min="0">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="padding: 9px 0;">直播阅卷金额:</label>
<div class="layui-input-block">
<input style="width: 300px" type="number" name="live_grading_price" lay-verify="number" v-model="formData.live_grading_price" autocomplete="off" class="layui-input" min="0">
<input style="width: 300px" type="number" name="live_grading_price"
lay-verify="number" v-model="formData.live_grading_price" autocomplete="off"
class="layui-input" min="0">
</div>
</div>
<div class="layui-form-item" v-show="formData.pay_type == 1">
<label class="layui-form-label">购买金额:</label>
<div class="layui-input-block">
<input style="width: 300px" type="number" name="money" lay-verify="number" v-model="formData.money" autocomplete="off" class="layui-input">
<input style="width: 300px" type="number" name="money" lay-verify="number"
v-model="formData.money" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="padding: 9px 0;">会员付费方式:</label>
<div class="layui-input-block">
<input type="radio" name="member_pay_type" lay-filter="member_pay_type" v-model="formData.member_pay_type" value="1" title="付费">
<input type="radio" name="member_pay_type" lay-filter="member_pay_type" v-model="formData.member_pay_type" value="0" title="免费">
<input type="radio" name="member_pay_type" lay-filter="member_pay_type"
v-model="formData.member_pay_type" value="1" title="付费">
<input type="radio" name="member_pay_type" lay-filter="member_pay_type"
v-model="formData.member_pay_type" value="0" title="免费">
</div>
</div>
<div class="layui-form-item" v-show="formData.member_pay_type == 1">
<label class="layui-form-label" style="padding: 9px 0;">会员购买金额:</label>
<div class="layui-input-block">
<input style="width: 300px" type="number" name="member_money" lay-verify="number" v-model="formData.member_money" autocomplete="off" class="layui-input" min="0">
<input style="width: 300px" type="number" name="member_money"
lay-verify="number" v-model="formData.member_money" autocomplete="off"
class="layui-input" min="0">
</div>
</div>
</div>
@ -380,9 +456,15 @@
<div class="layui-form-item">
<div class="layui-input-block">
<button type="button" class="layui-btn layui-btn-primary" @click="clone_form">取消</button>
<button v-show="tabIndex" type="button" class="layui-btn layui-btn-primary" @click="tabChange(-1)">上一步</button>
<button v-show="(tabIndex != 1 && type == 1) || (tabIndex != 2 && type == 2)" type="button" class="layui-btn layui-btn-normal" @click="tabChange(1)">下一步</button>
<button v-show="(tabIndex == 1 && type == 1) || (tabIndex == 2 && type == 2)" type="button" class="layui-btn layui-btn-normal" @click="save">{$id ?'确认修改':'立即提交'}</button>
<button v-show="tabIndex" type="button" class="layui-btn layui-btn-primary"
@click="tabChange(-1)">上一步
</button>
<button v-show="(tabIndex != 1 && type == 1) || (tabIndex != 2 && type == 2)" type="button"
class="layui-btn layui-btn-normal" @click="tabChange(1)">下一步
</button>
<button v-show="(tabIndex == 1 && type == 1) || (tabIndex == 2 && type == 2)" type="button"
class="layui-btn layui-btn-normal" @click="save">{$id ?'确认修改':'立即提交'}
</button>
</div>
</div>
</form>
@ -398,6 +480,7 @@
many_tmp_list = <?= isset($many_tmp_list) ? $many_tmp_list : "{}"?>,
judge_tmp_list = <?= isset($judge_tmp_list) ? $judge_tmp_list : "{}"?>;
answer_tmp_list = <?= isset($answer_tmp_list) ? $answer_tmp_list : "{}"?>;
paper_tmp_list = <?= isset($paper_tmp_list) ? $paper_tmp_list : "{}"?>;
require(['vue', 'helper', 'zh-cn', 'request', 'plupload', 'aliyun-oss', 'OssUpload'], function (Vue, $h) {
new Vue({
el: "#app",
@ -405,6 +488,7 @@
cateList: [],
questionsCateList: [],
single_list: [],//用于子页父业选中素材传值的临时变量
paper_list: [],//用于子页父业选中素材传值的临时变量
many_list: [],//用于子页父业选中素材传值的临时变量
judge_list: [],//用于子页父业选中素材传值的临时变量
answer_list: [],//用于子页父业选中素材传值的临时变量
@ -413,6 +497,7 @@
manyIds: '',
judgeIds: '',
answerIds: '',
paperIds: '',
title: test.title || '',
image: test.image || '',
tid: test.tid || 0,
@ -420,6 +505,7 @@
item_number: Number(test.item_number) || 0,
total_score: Number(test.total_score) || 0,
single_number: Number(test.single_number) || 0,
paper_number: Number(test.paper_number) || 0,
single_score: Number(test.single_score) || 0,
many_number: Number(test.many_number) || 0,
many_score: Number(test.many_score) || 0,
@ -442,6 +528,7 @@
many_tmp_list: many_tmp_list ? many_tmp_list : {},
judge_tmp_list: judge_tmp_list ? judge_tmp_list : {},
answer_tmp_list: answer_tmp_list ? answer_tmp_list : {},
paper_tmp_list: paper_tmp_list ? paper_tmp_list : {},
is_score: test.is_score || 0,
frequency: test.frequency > 0 ? test.frequency : (id > 0 ? 0 : 1),
sort: Number(test.sort) || 0,
@ -545,7 +632,10 @@
},
//上传图片
upload: function (key, count) {
ossUpload.createFrame('请选择图片', {fodder: key, max_count: count === undefined ? 0 : count},{w:800,h:550});
ossUpload.createFrame('请选择图片', {
fodder: key,
max_count: count === undefined ? 0 : count
}, {w: 800, h: 550});
},
get_subject_list: function () {
var that = this;
@ -565,6 +655,32 @@
})
});
},
questions_paper: function () {
var that = this;
var url = "{:Url('questions.test_paper/paper')}?id=" + id;
layer.open({
type: 2 //Page层类型
, area: ['80%', '90%']
, title: '关联试卷'
, shade: 0.6 //遮罩透明度
, maxmin: true //允许全屏最小化
, anim: 1 //0-6的动画形式,-1不开启
, content: url,
btn: '确定',
btnAlign: 'c', //按钮居中
closeBtn: 1,
yes: function () {
layer.closeAll();
var questions_tmp = $("#check_questions_tmp_5").val();
console.log(questions_tmp)
that.paper_list = JSON.parse(questions_tmp);
var array = that.formData.paper_tmp_list;
that.formData.paper_tmp_list = array.concat(JSON.parse(questions_tmp));
console.log(that.formData.paper_tmp_list)
that.show_paper_list();
}
});
},
questions_task: function (question_type) {
var that = this;
var url = "{:Url('questions.test_paper/questions')}?question_type=" + question_type + '&id=' + id;
@ -611,16 +727,27 @@
var table = layui.table, form = layui.form;
table.render({
elem: '#showQuestionsList_1'
,cols: [[
,
cols: [[
{field: 'id', title: '编号', align: 'center', width: 200},
{field: 'stem', title: '题干', align: 'center'},
{field: 'sort', title: '排序/倒序(以整套试卷排列)',edit:'sort',align: 'center',width:200},
{field: 'right', title: '操作',align: 'center',width:200,templet:function(d){
{
field: 'sort',
title: '排序/倒序(以整套试卷排列)',
edit: 'sort',
align: 'center',
width: 200
},
{
field: 'right', title: '操作', align: 'center', width: 200, templet: function (d) {
return '<div><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i> 移除</a></div>';
}}
}
}
]]
,data: (Object.keys(that.formData.single_tmp_list).length > 0) ? that.formData.single_tmp_list : []
,id: 'table_1'
,
data: (Object.keys(that.formData.single_tmp_list).length > 0) ? that.formData.single_tmp_list : []
,
id: 'table_1'
});
table.on('tool(showQuestionsList_1)', function (obj) {
var data = obj.data;
@ -671,10 +798,18 @@
, cols: [[
{field: 'id', title: '编号', align: 'center', width: 200},
{field: 'stem', title: '题干', align: 'center'},
{field: 'sort', title: '排序/倒序(以整套试卷排列)',edit:'sort',align: 'center',width:200},
{field: 'right', title: '操作',align: 'center',width:200,templet:function(d){
{
field: 'sort',
title: '排序/倒序(以整套试卷排列)',
edit: 'sort',
align: 'center',
width: 200
},
{
field: 'right', title: '操作', align: 'center', width: 200, templet: function (d) {
return '<div><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i> 移除</a></div>';
}}
}
}
]]
, data: (Object.keys(that.formData.many_tmp_list).length > 0) ? that.formData.many_tmp_list : []
, id: 'table_2'
@ -725,16 +860,27 @@
var table = layui.table, form = layui.form;
table.render({
elem: '#showQuestionsList_3'
,cols: [[
,
cols: [[
{field: 'id', title: '编号', align: 'center', width: 200},
{field: 'stem', title: '题干', align: 'center'},
{field: 'sort', title: '排序/倒序(以整套试卷排列)',edit:'sort',align: 'center',width:200},
{field: 'right', title: '操作',align: 'center',width:200,templet:function(d){
{
field: 'sort',
title: '排序/倒序(以整套试卷排列)',
edit: 'sort',
align: 'center',
width: 200
},
{
field: 'right', title: '操作', align: 'center', width: 200, templet: function (d) {
return '<div><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i> 移除</a></div>';
}}
}
}
]]
,data: (Object.keys(that.formData.judge_tmp_list).length > 0) ? that.formData.judge_tmp_list : []
,id: 'table_3'
,
data: (Object.keys(that.formData.judge_tmp_list).length > 0) ? that.formData.judge_tmp_list : []
,
id: 'table_3'
});
table.on('tool(showQuestionsList_3)', function (obj) {
var data = obj.data;
@ -782,16 +928,27 @@
var table = layui.table, form = layui.form;
table.render({
elem: '#showQuestionsList_4'
,cols: [[
,
cols: [[
{field: 'id', title: '编号', align: 'center', width: 200},
{field: 'stem', title: '题干', align: 'center'},
{field: 'sort', title: '排序/倒序(以整套试卷排列)',edit:'sort',align: 'center',width:200},
{field: 'right', title: '操作',align: 'center',width:200,templet:function(d){
{
field: 'sort',
title: '排序/倒序(以整套试卷排列)',
edit: 'sort',
align: 'center',
width: 200
},
{
field: 'right', title: '操作', align: 'center', width: 200, templet: function (d) {
return '<div><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i> 移除</a></div>';
}}
}
}
]]
,data: (Object.keys(that.formData.answer_tmp_list).length > 0) ? that.formData.answer_tmp_list : []
,id: 'table_4'
,
data: (Object.keys(that.formData.answer_tmp_list).length > 0) ? that.formData.answer_tmp_list : []
,
id: 'table_4'
});
table.on('tool(showQuestionsList_4)', function (obj) {
var data = obj.data;
@ -834,6 +991,69 @@
}
});
},
show_paper_list: function () {
var that = this;
var table = layui.table, form = layui.form;
table.render({
elem: '#showQuestionsList_5'
,
cols: [[
{field: 'id', title: '编号', align: 'center', width: 200},
{field: 'title', title: '试卷名称', align: 'center'},
{field: 'cate', title: '分类', align: 'center'},
{
field: 'right', title: '操作', align: 'center', width: 200, templet: function (d) {
return '<div><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i> 移除</a></div>';
}
}
]]
,
data: (Object.keys(that.formData.paper_tmp_list).length > 0) ? that.formData.paper_tmp_list : []
,
id: 'table_5'
});
table.on('tool(showQuestionsList_5)', function (obj) {
var data = obj.data;
if (obj.event === 'del') {
if (that.formData.paper_tmp_list) {
for (var i = 0; i < that.formData.paper_tmp_list.length; i++) {
if (that.formData.paper_tmp_list[i].id == data.id) {
that.formData.paper_tmp_list.splice(i, 1);
}
}
that.formData.paper_tmp_list = that.formData.paper_tmp_list;
that.show_paper_list();
}
}
});
table.on('edit(showQuestionsList_5)', function (obj) {
var id = obj.data.id, values = Number(obj.value);
switch (obj.field) {
case 'sort':
if (that.formData.paper_tmp_list) {
$.each(that.formData.paper_tmp_list, function (index, value) {
if (value.id == id) {
that.formData.paper_tmp_list[index].sort = values;
}
})
}
break;
}
});
//监听素材是否删除
form.on('switch(delect)', function (obj) {
if (that.formData.paper_tmp_list) {
for (var i = 0; i < that.formData.paper_tmp_list.length; i++) {
if (that.formData.paper_tmp_list[i].id == obj.value) {
that.formData.paper_tmp_list.splice(i, 1);
}
}
that.formData.paper_tmp_list = that.formData.paper_tmp_list;
that.show_paper_list();
}
});
},
save: function () {
var that = this;
var grade = that.grade;
@ -850,10 +1070,13 @@
if (that.formData.image == '' && type == 2) return layList.msg('请输入' + (type === 1 ? '练习' : '考试') + '封面');
if (Number(that.formData.txamination_time) <= 0 && type == 2) return layList.msg((type === 1 ? '练习' : '考试') + '时长填写不正确');
if (Number(that.formData.frequency) < 0 && type == 2) return layList.msg((type === 1 ? '练习' : '考试') + '次数填写不正确');
console.log(that.formData)
if (Object.keys(that.formData.paper_tmp_list).length == 0) {
if (!Number(that.formData.single_number) && !Number(that.formData.many_number) && !Number(that.formData.judge_number)) {
return layList.msg('至少有一类题型数量大于0');
}
}
that.formData.grade = JSON.stringify(grade);
if (that.formData.pay_type == 1 && type == 2) {
if (Number(that.formData.money) < 0 || that.formData.money == 0.00) return layList.msg('购买金额未填或填写不正确');
@ -862,13 +1085,17 @@
if (Number(that.formData.member_money) < 0 || that.formData.member_money == 0.00) return layList.msg('会员购买金额未填或填写不正确');
}
if (that.formData.is_group == 1) {
if (Object.keys(that.formData.paper_tmp_list).length == 0) {
if (Object.keys(that.formData.single_tmp_list).length == 0 && that.formData.single_number > 0) return layList.msg('请选择单选题');
if (Object.keys(that.formData.many_tmp_list).length == 0 && that.formData.many_number > 0) return layList.msg('请选择多选题');
if (Object.keys(that.formData.judge_tmp_list).length == 0 && that.formData.judge_number > 0) return layList.msg('请选择判断题');
}
that.formData.singleIds = JSON.stringify(that.formData.single_tmp_list);
that.formData.manyIds = JSON.stringify(that.formData.many_tmp_list);
that.formData.judgeIds = JSON.stringify(that.formData.judge_tmp_list);
that.formData.answerIds = JSON.stringify(that.formData.answer_tmp_list);
that.formData.answerIds = JSON.stringify(that.formData.answer_tmp_list);
that.formData.paperIds = JSON.stringify(that.formData.paper_tmp_list);
} else {
if (that.formData.cate_id <= 0) return layList.msg('请选择随机组题的题库分类');
}
@ -921,6 +1148,7 @@
that.show_many_list();
that.show_judge_list();
that.show_answer_list();
that.show_paper_list();
if (grades && grades.length) {
that.grade = grades;
}
@ -970,6 +1198,7 @@
layui.table.resize('table_2');
layui.table.resize('table_3');
layui.table.resize('table_4');
layui.table.resize('table_5');
});
});
}

@ -249,14 +249,14 @@ function getversion()
* @param int $pid
* @return array
*/
function subTree(array $data, int $pid = 0) {
function subTree(array $data, int $pid = 0, $field = 'pid') {
// 返回的结果
$arr = [];
foreach ($data as $val) {
// 给定的PID是当前记录的上级ID
if ($pid == $val['pid']) {
if ($pid == $val[$field]) {
// 递归
$val['children'] = subTree($data,$val['id']);
$val['children'] = subTree($data,$val['id'], $field);
$arr[] = $val;
}
}

@ -66,6 +66,7 @@ use app\wap\model\topic\Relation;
use app\wap\model\user\UserRecharge;
use think\Log;
use service\AliVodServices;
use service\UtilService as Util;
/**专题
@ -131,7 +132,8 @@ class Special extends AuthController
*/
public function getSpecialSubject()
{
$category = SpecialSubject::with('children')->where(['is_show' => 1, 'is_del' => 0])->order('sort desc,id desc')->where('grade_id', 0)->select();
$category = SpecialSubject::where(['is_show' => 1, 'is_del' => 0])->order('sort desc,id desc')->select();
$category = subTree($category->toArray(), 0, 'grade_id');
$recommend = SpecialSubject::where(['is_show' => 1, 'is_del' => 0, 'is_recommend' => 1])->where('grade_id', 'neq', 0)->order('sort desc,id desc')->select();
return JsonService::successful([

@ -555,6 +555,12 @@ class Topic extends AuthController
} else if ($type == 2) {
$value['is_pay'] = (!$this->uid || $this->uid == 0) ? false : TestPaperObtain::PayTestPaper($value['id'], $this->uid, 2);
}
$ids = \app\admin\model\questions\TestPaperQuestions::where(['test_id' => $value['id']])->column('pid');
if (count($ids) > 0) {
$papers = \app\admin\model\questions\TestPaper::whereIn('id', $ids)->select();
$value['item_number'] = $value['item_number'] + array_sum($papers->column('item_number'));
}
$value['answer'] = $value['answer'] + $value['fake_sales'];
}
}

@ -36,14 +36,16 @@ class TestPaperQuestions extends ModelBasic
*/
public static function getQuestionslist($test_id, $type, $question_type = 0)
{
(array)$test_ids = self::where(['test_id' => $test_id, 'type' => $type,])->where('pid', '>', 0)->column('pid');
$model = self::alias('p')->join('Questions q', 'p.questions_id=q.id')
->where(['p.type' => $type, 'p.test_id' => $test_id, 'q.is_del' => 0]);
->where(['p.type' => $type, 'q.is_del' => 0])
->whereIn('test_id', array_merge($test_ids,[$test_id]));
if ($question_type) {
$model = $model->where('p.question_type', $question_type);
}
$list = $model->field('p.*,q.option,q.stem,q.image,q.answer,q.difficulty,q.analysis,q.relation,q.is_img,q.is_del')
->order('p.sort desc')->select();
$list = count($list) > 0 ? $list->toArray() : [];
return $list;
return count($list) > 0 ? $list->toArray() : [];
}
}

Loading…
Cancel
Save