dever 6 năm trước cách đây
mục cha
commit
20fc3a31db
2 tập tin đã thay đổi với 19 bổ sung3 xóa
  1. 12 0
      database/user_answer.php
  2. 7 3
      src/Api.php

+ 12 - 0
database/user_answer.php

@@ -116,5 +116,17 @@ return array
 			'type' => 'all',
 			'col' => 'info_id,uid,user_id,id|info_id',
 		),
+
+		'getNew' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'col' => 'info_id,uid,user_id,id|info_id',
+		),
 	)
 );

+ 7 - 3
src/Api.php

@@ -37,7 +37,6 @@ class Api
 				$answer = Dever::db('survey/user_answer')->one(array('info_id' => $v['id'], 'uid' => $uid));
 				if ($answer) {
 					$result['info'][$k]['answer'] = $answer['value'];
-					$user['index'] = $v['page_number'];
 				} else {
 					$result['info'][$k]['answer'] = '';
 				}
@@ -87,10 +86,15 @@ class Api
 				}
 			}
 
-			if ($num == $total) {
+			if ($num == $total || $page_number > 0) {
 				$user = Dever::db('survey/user')->one(array('uid' => $uid));
 				if ($user) {
-					Dever::db('survey/user')->update(array('where_id' => $user['id'], 'index' => $user['index'] + 1));
+
+					$user['index'] = $user['index'] + 1;
+					if ($page_number) {
+						$user['index'] = $page_number;
+					}
+					Dever::db('survey/user')->update(array('where_id' => $user['id'], 'index' => $user['index']));
 				}
 			}
 		}