service = $this->getClassService(); } protected function returnFailure(Exception $exception) { $data = []; $data['success'] = false; $data['errorCode'] = $exception->getCode(); $data['errorMsg'] = ($exception instanceof common_exception_UserReadableException) ? $exception->getUserMessage() : $exception->getMessage(); $data['version'] = TAO_VERSION; echo json_encode($data); exit(0); } protected function returnSuccess($rawData = "") { $data = []; $data['success'] = true; $data['data'] = $rawData; $data['version'] = TAO_VERSION; echo json_encode($data); exit(0); } /** * @author "Patrick Plichart, " */ public function storeItemVariableSet() { $variables = []; $item = $this->hasRequestParameter("itemId") ? $this->getRequestParameter("itemId") : "undefined"; $callIdItem = $this->hasRequestParameter("serviceCallId") ? $this->getRequestParameter("serviceCallId") : "undefined"; $test = $this->hasRequestParameter("testId") ? $this->getRequestParameter("testId") : "undefined"; if ($this->hasRequestParameter("outcomeVariables")) { $outcomeVariables = $this->getRequestParameter("outcomeVariables"); foreach ($outcomeVariables as $variableName => $outcomeValue) { $outComeVariable = new taoResultServer_models_classes_OutcomeVariable(); //$outComeVariable->setBaseType("int"); $outComeVariable->setCardinality("single"); $outComeVariable->setIdentifier($variableName); $outComeVariable->setValue($outcomeValue); $variables[] = $outComeVariable; } } if ($this->hasRequestParameter("responseVariables")) { $responseVariables = $this->getRequestParameter("responseVariables"); foreach ($responseVariables as $variableName => $responseValue) { $responseVariable = new taoResultServer_models_classes_ResponseVariable(); //$responseVariable->setBaseType("int"); //$responseVariable->setCardinality("single"); $responseVariable->setIdentifier($variableName); $responseVariable->setCandidateResponse($responseValue); //$responseVariable->setCorrectResponse(true); $variables[] = $responseVariable; } } if ($this->hasRequestParameter("traceVariables")) { $traceVariables = $this->getRequestParameter("outcomeVariables"); foreach ($traceVariables as $variableName => $traceValue) { $traceVariable = new taoResultServer_models_classes_TraceVariable(); //$outComeVariable->setBaseType("int"); $traceVariable->setIdentifier($variableName); $traceVariable->setTrace($traceValue); $variables[] = $traceVariable; } } try { $data = $this->service->storeItemVariableSet($test, $item, $variables, $callIdItem); } catch (exception $e) { $this->returnFailure($e); } return $this->returnSuccess($data); } }