作者 何书鹏
1 个管道 的构建 通过 耗费 3 秒

合并分支 'heshupeng' 到 'master'

Heshupeng



查看合并请求 !302
... ... @@ -72,6 +72,7 @@ class Study extends Backend
*/
public function pass_list($ids = null,$type = null)
{
@ini_set('memory_limit', '512M'); //过滤导出报错
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags']);
... ...
... ... @@ -34,7 +34,10 @@ class Questionnaire extends Api
"list": [{ //题目列表
"id": 1, //题目ID
"title": "测定混凝土立方体抗压强度时,标准试件的尺寸是( )㎜。", //题目
"option": "[{\"name\":\"A\",\"gender\":\"100\\u00d7100\\u00d7100\"},{\"name\":\"B\",\"gender\":\"150\\u00d7150\\u00d7150\"},{\"name\":\"C\",\"gender\":\"200\\u00d7200\\u00d7200\"},{\"name\":\"D\",\"gender\":\"70.7\\u00d770.7\\u00d770.7\"}]", //题目选项
"option": [{ //题目选项
"key": "A", //选项
"value": "1" //选项内容
}],
"type": "1", //题目类型:1=单选题,2=多选题,3=判断题,4=简答题
}]
}
... ... @@ -43,6 +46,9 @@ class Questionnaire extends Api
public function questionList()
{
$list = QuestionnaireQuestion::field('id,title,option,type')->select();
foreach ($list as $v){
$v->option = json_decode($v['option'],true);
}
$this->success('成功',compact('list'));
}
... ... @@ -53,7 +59,7 @@ class Questionnaire extends Api
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="content", type="string", required=true, description="{问题ID:回答内容}")
* @ApiParams (name="content", type="string", required=true, description="[{id: 问题ID,value: 回答选项或内容}]")
*
* @ApiReturn({
"code": 1,
... ... @@ -66,9 +72,15 @@ class Questionnaire extends Api
{
$content = $this->request->post('content');
empty($content) && $this->error('缺少必要参数');
$answer_list = array_filter(json_decode(htmlspecialchars_decode($content),true));
$no_answer = QuestionnaireQuestion::where('id','not in', array_keys($answer_list))->find();
!empty($no_answer) && $this->error('还有问题没有回答');
if(is_string($content)){
$content = htmlspecialchars_decode($content);
}
$answer_list = json_decode($content,true);
$no_answer = QuestionnaireQuestion::where('id','not in', array_column($answer_list,'id'))->field('id')->find();
!empty($no_answer) && $this->error('请回答第'.$no_answer['id'].'题');
foreach ($answer_list as $v){
empty($v['value']) && $this->error('请回答第'.$v['id'].'题');
}
Db::startTrans();
try{
$result_id = db('mobile_questionnaire_result')->insertGetId([
... ... @@ -77,12 +89,12 @@ class Questionnaire extends Api
'updatetime' => time()
]);
$insertAll = [];
foreach($answer_list as $id => $answer){
foreach($answer_list as $val){
$insertAll[] = [
'user_id' => $this->auth->id,
'result_id' => $result_id,
'question_id' => $id,
'content' => $answer,
'question_id' => $val['id'],
'content' => $val['value'],
];
}
(new QuestionnaireAnswer)->saveAll($insertAll);
... ...
... ... @@ -3517,7 +3517,10 @@
"list": [{ //题目列表
"id": 1, //题目ID
"title": "测定混凝土立方体抗压强度时,标准试件的尺寸是( )㎜。", //题目
"option": "[{\"name\":\"A\",\"gender\":\"100\\u00d7100\\u00d7100\"},{\"name\":\"B\",\"gender\":\"150\\u00d7150\\u00d7150\"},{\"name\":\"C\",\"gender\":\"200\\u00d7200\\u00d7200\"},{\"name\":\"D\",\"gender\":\"70.7\\u00d770.7\\u00d770.7\"}]", //题目选项
"option": [{ //题目选项
"key": "A", //选项
"value": "1" //选项内容
}],
"type": "1", //题目类型:1=单选题,2=多选题,3=判断题,4=简答题
}]
}
... ... @@ -3593,7 +3596,7 @@
<td>content</td>
<td>string</td>
<td></td>
<td>{问题ID:回答内容}</td>
<td>[{id: 问题ID,value: 回答选项或内容}]</td>
</tr>
</tbody>
</table>
... ... @@ -3626,7 +3629,7 @@
<form enctype="application/x-www-form-urlencoded" role="form" action="/mobile/questionnaire/submit" method="POST" name="form81" id="form81">
<div class="form-group">
<label class="control-label" for="content">content</label>
<input type="string" class="form-control input-sm" id="content" required placeholder="{问题ID:回答内容}" name="content">
<input type="string" class="form-control input-sm" id="content" required placeholder="[{id: 问题ID,value: 回答选项或内容}]" name="content">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="81">提交</button>
... ... @@ -24366,7 +24369,7 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2021-04-27 13:29:02 </div>
Generated on 2021-04-29 16:06:13 </div>
<div class="col-md-6" align="right">
<a href="./" target="_blank">企智帮</a>
</div>
... ...