Sfoglia il codice sorgente

一次答多个题

lizhen_gitee 4 mesi fa
parent
commit
d4516f7665

+ 11 - 1
application/api/controller/Demo.php

@@ -83,7 +83,17 @@ class Demo extends Api
      */
     public function test2()
     {
-        $this->success('返回成功', ['action' => 'test2']);
+        $data = [
+            [
+                'id'     => 1,
+                'answer' => 'A',
+            ],
+            [
+                'id'     => 2,
+                'answer' => 'B',
+            ],
+        ];
+        echo json_encode($data);
     }
 
     /**

+ 2 - 2
application/api/controller/Question.php

@@ -90,7 +90,7 @@ class Question extends Api
         }
 
         //答题
-        $user_questions = input('questions','','trim');
+        $user_questions = input('questions','','htmlspecialchars_decode');
         $user_questions = json_decode($user_questions,true);
         if (!$user_questions) {
             $this->error('提交数据有误');
@@ -153,7 +153,7 @@ class Question extends Api
             'right_number' => $is_right_number,
             'remain'       => $exam_times_user_eday - $count,
         ];
-        $this->success(1,$result);
+        $this->success('答题完毕',$result);
     }
 
     /**