|
@@ -53,6 +53,22 @@ class Api
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 获取用户信息接口 api.getUserInfo?uid=1
|
|
|
+ *
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function getUserInfo()
|
|
|
+ {
|
|
|
+ $this->getUser();
|
|
|
+ $this->result();
|
|
|
+
|
|
|
+ $result['exam'] = $this->exam;
|
|
|
+ $result['user'] = $this->user;
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 从某个活动中抽取题目并保存下来
|
|
|
* $category 分类id
|
|
@@ -223,6 +239,12 @@ class Api
|
|
|
$id = $this->user['id'];
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ $this->result();
|
|
|
+ }
|
|
|
+
|
|
|
+ private function result()
|
|
|
+ {
|
|
|
if ($this->user['status'] >= 3) {
|
|
|
$this->exam['content'] = Dever::array_decode($this->exam['content']);
|
|
|
$this->exam['result'] = array();
|
|
@@ -409,6 +431,7 @@ class Api
|
|
|
$data['content'][$option]['score'] = 0;
|
|
|
$data['content'][$option]['title'] = '超时';
|
|
|
}
|
|
|
+
|
|
|
if (!isset($data['content'][$option])) {
|
|
|
Dever::alert('错误的选项信息');
|
|
|
}
|
|
@@ -423,33 +446,44 @@ class Api
|
|
|
}
|
|
|
|
|
|
$update['score'] = $data['score'] + $data['content'][$option]['score'];
|
|
|
- $update['index'] = $data['index'] + 1;
|
|
|
$update['where_id'] = $data['user_data_id'];
|
|
|
|
|
|
$update['status'] = 2;
|
|
|
|
|
|
- if ($update['index'] >= $data['num']) {
|
|
|
-
|
|
|
- $update['status'] = 4;
|
|
|
+ if ($this->exam['continue'] >= 2 && $data['content'][$option]['score'] == 0) {
|
|
|
+
|
|
|
+ $update['status'] = 3;
|
|
|
|
|
|
$this->setRanking($update['score']);
|
|
|
+
|
|
|
+
|
|
|
+ if ($this->exam['continue_index'] == 2) {
|
|
|
+ $update['index'] = $data['index'] + 1;
|
|
|
+ } else {
|
|
|
+ $update['index'] = $data['index'];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $update['index'] = $data['index'] + 1;
|
|
|
}
|
|
|
- if ($this->exam['continue'] >= 2 && $data['content'][$option]['score'] == 0) {
|
|
|
-
|
|
|
- $update['status'] = 3;
|
|
|
+
|
|
|
+ if ($update['index'] >= $data['num'] && $update['status'] == 2) {
|
|
|
+
|
|
|
+ $update['status'] = 4;
|
|
|
|
|
|
$this->setRanking($update['score']);
|
|
|
}
|
|
|
|
|
|
Dever::db('question/user')->update($update);
|
|
|
|
|
|
- $insert['user_id'] = $data['user_data_id'];
|
|
|
- $insert['info_id'] = $data['id'];
|
|
|
- $insert['score'] = $data['content'][$option]['score'];
|
|
|
- $insert['option'] = $option;
|
|
|
- $insert['uid'] = $this->user['uid'];
|
|
|
- $insert['option_name'] = $data['content'][$option]['title'];
|
|
|
- Dever::db('question/user_answer')->insert($insert);
|
|
|
+ if ($update['index'] > $data['index']) {
|
|
|
+ $insert['user_id'] = $data['user_data_id'];
|
|
|
+ $insert['info_id'] = $data['id'];
|
|
|
+ $insert['score'] = $data['content'][$option]['score'];
|
|
|
+ $insert['option'] = $option;
|
|
|
+ $insert['uid'] = $this->user['uid'];
|
|
|
+ $insert['option_name'] = $data['content'][$option]['title'];
|
|
|
+ Dever::db('question/user_answer')->insert($insert);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$result = array();
|
|
@@ -506,7 +540,7 @@ class Api
|
|
|
|
|
|
$update['where_id'] = $this->user['id'];
|
|
|
if ($this->user['index'] >= $this->user['num']) {
|
|
|
- $update['status'] = 2;
|
|
|
+ $update['status'] = 4;
|
|
|
} else {
|
|
|
$update['status'] = 2;
|
|
|
}
|
|
@@ -529,7 +563,7 @@ class Api
|
|
|
$update['where_id'] = $this->user['id'];
|
|
|
|
|
|
if ($this->user['index'] >= $this->user['num']) {
|
|
|
- $update['status'] = 2;
|
|
|
+ $update['status'] = 4;
|
|
|
} else {
|
|
|
$update['status'] = 2;
|
|
|
}
|