Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 49 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
taoResultServer_actions_ResultServerStateFull | |
0.00% |
0 / 49 |
|
0.00% |
0 / 4 |
240 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
returnFailure | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
returnSuccess | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
storeItemVariableSet | |
0.00% |
0 / 32 |
|
0.00% |
0 / 1 |
132 |
1 | <?php |
2 | |
3 | /** |
4 | * This program is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU General Public License |
6 | * as published by the Free Software Foundation; under version 2 |
7 | * of the License (non-upgradable). |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write to the Free Software |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | * |
18 | * Copyright (c) 2013 Open Assessment Technologies |
19 | * |
20 | * |
21 | */ |
22 | |
23 | use oat\tao\model\routing\AnnotationReader\security; |
24 | |
25 | /** |
26 | * |
27 | * A session for a particular delivery execution/session on the corresponding result server |
28 | * Statefull api for results submission from the client |
29 | * |
30 | * |
31 | * @package taoResultServer |
32 | * @license GPLv2 http://www.opensource.org/licenses/gpl-2.0.php |
33 | */ |
34 | class taoResultServer_actions_ResultServerStateFull extends tao_actions_SaSModule |
35 | { |
36 | protected $service; |
37 | |
38 | /** |
39 | * constructor: initialize the service and the default data |
40 | * @security("hide"); |
41 | */ |
42 | public function __construct() |
43 | { |
44 | parent::__construct(); |
45 | $this->service = $this->getClassService(); |
46 | } |
47 | |
48 | protected function returnFailure(Exception $exception) |
49 | { |
50 | $data = []; |
51 | $data['success'] = false; |
52 | $data['errorCode'] = $exception->getCode(); |
53 | $data['errorMsg'] = ($exception instanceof common_exception_UserReadableException) |
54 | ? $exception->getUserMessage() |
55 | : $exception->getMessage(); |
56 | $data['version'] = TAO_VERSION; |
57 | echo json_encode($data); |
58 | exit(0); |
59 | } |
60 | |
61 | protected function returnSuccess($rawData = "") |
62 | { |
63 | $data = []; |
64 | $data['success'] = true; |
65 | $data['data'] = $rawData; |
66 | $data['version'] = TAO_VERSION; |
67 | |
68 | echo json_encode($data); |
69 | exit(0); |
70 | } |
71 | |
72 | /** |
73 | * @author "Patrick Plichart, <patrick@taotesting.com>" |
74 | */ |
75 | public function storeItemVariableSet() |
76 | { |
77 | $variables = []; |
78 | $item = $this->hasRequestParameter("itemId") ? $this->getRequestParameter("itemId") : "undefined"; |
79 | $callIdItem = $this->hasRequestParameter("serviceCallId") |
80 | ? $this->getRequestParameter("serviceCallId") |
81 | : "undefined"; |
82 | $test = $this->hasRequestParameter("testId") ? $this->getRequestParameter("testId") : "undefined"; |
83 | if ($this->hasRequestParameter("outcomeVariables")) { |
84 | $outcomeVariables = $this->getRequestParameter("outcomeVariables"); |
85 | foreach ($outcomeVariables as $variableName => $outcomeValue) { |
86 | $outComeVariable = new taoResultServer_models_classes_OutcomeVariable(); |
87 | //$outComeVariable->setBaseType("int"); |
88 | $outComeVariable->setCardinality("single"); |
89 | $outComeVariable->setIdentifier($variableName); |
90 | $outComeVariable->setValue($outcomeValue); |
91 | $variables[] = $outComeVariable; |
92 | } |
93 | } |
94 | if ($this->hasRequestParameter("responseVariables")) { |
95 | $responseVariables = $this->getRequestParameter("responseVariables"); |
96 | foreach ($responseVariables as $variableName => $responseValue) { |
97 | $responseVariable = new taoResultServer_models_classes_ResponseVariable(); |
98 | //$responseVariable->setBaseType("int"); |
99 | //$responseVariable->setCardinality("single"); |
100 | $responseVariable->setIdentifier($variableName); |
101 | $responseVariable->setCandidateResponse($responseValue); |
102 | //$responseVariable->setCorrectResponse(true); |
103 | $variables[] = $responseVariable; |
104 | } |
105 | } |
106 | if ($this->hasRequestParameter("traceVariables")) { |
107 | $traceVariables = $this->getRequestParameter("outcomeVariables"); |
108 | foreach ($traceVariables as $variableName => $traceValue) { |
109 | $traceVariable = new taoResultServer_models_classes_TraceVariable(); |
110 | //$outComeVariable->setBaseType("int"); |
111 | $traceVariable->setIdentifier($variableName); |
112 | $traceVariable->setTrace($traceValue); |
113 | $variables[] = $traceVariable; |
114 | } |
115 | } |
116 | |
117 | try { |
118 | $data = $this->service->storeItemVariableSet($test, $item, $variables, $callIdItem); |
119 | } catch (exception $e) { |
120 | $this->returnFailure($e); |
121 | } |
122 | return $this->returnSuccess($data); |
123 | } |
124 | } |