Selaa lähdekoodia

修改面试题

dongxiaoqin 1 vuosi sitten
vanhempi
commit
db0bc25bd1
1 muutettua tiedostoa jossa 11 lisäystä ja 9 poistoa
  1. 11 9
      app/workerapi/controller/InterviewController.php

+ 11 - 9
app/workerapi/controller/InterviewController.php

@@ -113,7 +113,7 @@ class InterviewController extends BaseApiController
         if ($step > 1 && (empty($data) || !is_array($data))) {
             return $this->fail('答案不可为空');
         }
-
+         
         $worker_register_id = MasterWorkerRegister::where('id',$worker_register_id)->value('id');
         if (!$worker_register_id) {
             return $this->fail('ID有误');
@@ -225,15 +225,17 @@ class InterviewController extends BaseApiController
             $rights = 0;
             foreach($data as &$item) {
                 $answer = $answers[$item['id']];
-                $item['options'] = preg_replace('/[^a-zA-Z]/', '', $item['options']);
-
-                //用户选项排序
-                $options = str_split($item['options']);
-                sort($options);
-                $item['options'] = implode('', $options);
+                if (!in_array($item['options'],['对','错'])) {
+                    $item['options'] = preg_replace('/[^a-zA-Z]/', '', $item['options']);
 
-                if ($answer == '对' || $answer == '错') {
-                    $item['options'] = $item['options'] == 'A' ? '对' : '错';
+                    //用户选项排序
+                    $options = str_split($item['options']);
+                    sort($options);
+                    $item['options'] = implode('', $options);
+    
+                    if (($answer == '对' || $answer == '错')) {
+                        $item['options'] = $item['options'] == 'A' ? '对' : '错';
+                    }
                 }
                 if ($item['options'] == $answer) {
                     $rights ++;