This repository was archived by the owner on Apr 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevaluate.php
More file actions
73 lines (66 loc) · 2.64 KB
/
evaluate.php
File metadata and controls
73 lines (66 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace sgpublic\scit\tool;
define('SCIT_EDU_TOOL_ROOT', dirname(__FILE__));
require SCIT_EDU_TOOL_ROOT.'/base/NormalAPI.php';
require SCIT_EDU_TOOL_ROOT.'/helper/EvaluateHelper.php';
use sgpublic\scit\tool\base\NormalAPI;
use sgpublic\scit\tool\core\Debug;
use sgpublic\scit\tool\core\Verify;
use sgpublic\scit\tool\helper\EvaluateHelper;
use sgpublic\scit\tool\helper\SessionHelperException;
use sgpublic\scit\tool\helper\TokenHelper;
class evaluate extends NormalAPI {
public function __construct(array $args) {
parent::__construct($args);
}
protected function API(Verify $sign) {
try {
$helper = TokenHelper::getInterface($sign->getParameter('access_token'), 'access');
if ($helper->check() == 0){
$helper = EvaluateHelper::getInterface(
$helper->getChecker()
);
$action = $sign->getParameter("action");
$index = intval($sign->getParameter("index")) - 1;
if ($helper->open){
if ($action == "get") {
$this->result = $helper->get($index);
$this->result = array_diff_key($this->result, ['count' => array()]);
} else if ($action == "submit"){
$this->result = $helper->post($index, $sign->getParameter("data"));
$this->result = array_diff_key($this->result, ['count' => array()]);
} else {
$this->result = $helper->getTotalCount();
}
} else {
Debug::getTrack(
$this->result, 404, '教评未开放',
__DIR__, __FILE__, __LINE__, __METHOD__
);
}
} else if ($helper->check() == -4) {
Debug::getTrack(
$this->result, 504, '登录状态失效,请重新登陆',
__DIR__, __FILE__, __LINE__, __METHOD__
);
} else {
Debug::getTrack(
$this->result, 504, 'Token无效',
__DIR__, __FILE__, __LINE__, __METHOD__
);
}
} catch (SessionHelperException $e) {
Debug::getTrack(
$this->result, 500, '服务器内部错误',
__DIR__, __FILE__, __LINE__, __METHOD__,
$e->getMessage()
);
}
}
}
new evaluate([
'access_token' => isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : null,
'action' => 'check',
'index' => 1,
'data' => []
]);