2 Commits

Author SHA1 Message Date
Piotr Marynczak
a61c52fe1c [WZUW-194] adding function to get uplodaed files info 2023-08-01 12:46:16 +02:00
Piotr Marynczak
06fcaf07a8 [WZUW-194] survey answers prototype 2023-07-28 13:45:59 +02:00
3 changed files with 56 additions and 3 deletions

View File

@@ -57,9 +57,14 @@ class Result
* class constants.
* @param array $rawData Raw data returned by the LimeSurvey's API
*/
public function __construct($method, array $rawData)
public function __construct($method, $rawData)
{
$this->method = MethodType::getValidatedMethod($method);
if (true === is_string($rawData)) {
$rawData = base64_decode($rawData);
$rawData = json_decode($rawData, true);
}
$this->setRawDataAndStatus($rawData);
}

View File

@@ -23,7 +23,6 @@ use Meritoo\LimeSurvey\ApiClient\Result\Item\Survey;
use Meritoo\LimeSurvey\ApiClient\Result\Item\SurveySummary;
use Meritoo\LimeSurvey\ApiClient\Type\MethodType;
use Meritoo\LimeSurvey\ApiClient\Type\ReasonType;
use Meritoo\Common\Utilities\Date;
/**
* Service that serves surveys and participants of surveys
@@ -302,7 +301,6 @@ class SurveyService
'firstname' => $firstName,
'lastname' => $lastName,
'email' => $email,
'validfrom' => date('Y-m-d H:i:s'),
],
];
@@ -460,4 +458,45 @@ class SurveyService
return false;
}
public function getResponseIds($surveyId, $token)
{
$arguments = [
$surveyId,
$token,
];
return $this
->client
->run('get_response_ids', $arguments)
->getData(true);
}
public function exportResponsesByToken($surveyId, $token)
{
$arguments = [
$surveyId,
'json',
$token,
];
return $this
->client
->run('export_responses_by_token', $arguments)
->getData(true);
}
public function exportUploadedFilesByToken($surveyId, $token)
{
$arguments = [
$surveyId,
'json',
$token,
];
return $this
->client
->run('get_uploaded_files', $arguments)
->getData(true);
}
}

View File

@@ -93,6 +93,12 @@ class MethodType extends BaseType
*/
const LIST_USERS = 'list_users';
const EXPORT_RESPONSES_BY_TOKEN = 'export_responses_by_token';
const GET_RESPONSE_IDS = 'get_response_ids';
const EXPORT_UPLOADED_FILES_BY_TOKEN = 'get_uploaded_files';
/**
* Returns validated name of method to call or throws an exception (if method is incorrect)
*
@@ -126,6 +132,9 @@ class MethodType extends BaseType
static::LIST_QUESTIONS,
static::LIST_SURVEYS,
static::LIST_USERS,
static::EXPORT_RESPONSES_BY_TOKEN,
static::GET_RESPONSE_IDS,
static::EXPORT_UPLOADED_FILES_BY_TOKEN
]);
}
}