15 Commits

Author SHA1 Message Date
Tomasz Kuter
8620426902 [UW-2934] chore(composer): switched back to "wiosna-dev/common-library", to branch "feature/UW-2934_Add_support_for_PHP_8.x" 2023-03-09 12:57:54 +01:00
Tomasz Kuter
19d1094ea6 [UW-2934] chore(composer): switched to official "meritoo/common-library" in version 1.1.x 2023-03-09 12:40:05 +01:00
Michał Frankiewicz
f0c213fb53 Merge pull request #3 from wiosna-dev/bugfix/UW-2538
[UW-2538] fixes method
2021-07-02 09:02:33 +02:00
Michał Frankiewicz
24f9a237ae [UW-2538] fixes method 2021-07-02 08:59:44 +02:00
Michał Frankiewicz
81ea8e748f Merge pull request #2 from wiosna-dev/bugfix/UW-2538
Bugfix/uw 2538
2021-06-30 08:36:41 +02:00
Michał Frankiewicz
bab7e25c85 [UW-2538] removes broken argument 2021-06-29 17:11:50 +02:00
Michał Frankiewicz
6423195cc6 [UW-2538] adds method to check survey completion 2021-06-29 17:09:27 +02:00
Michał Frankiewicz
b2d4552fb3 [UW-2538] updates docs 2021-06-29 17:01:03 +02:00
Michał Frankiewicz
53d82841e0 Merge pull request #1 from wiosna-dev/bugfix/UW-2256
Bugfix/uw 2256
2020-07-22 08:40:12 +02:00
Michał Frankiewicz
c8ffcafbd8 [UW-2256] moves token property to BaseParticipant 2020-07-08 08:55:14 +02:00
Michał Frankiewicz
7551f6db95 [UW-2256] adds criteria parameter 2020-07-08 08:54:26 +02:00
Krzysztof Nizioł
a1e681b66e Do not modify version 2018-09-07 21:30:15 +02:00
Krzysztof Nizioł
2c42a2165a Composer > use wiosna-dev/common-library instead of meritoo/common-library package 2018-09-07 21:28:28 +02:00
Krzysztof Nizioł
058eb06d4d Merge branch 'master' of github.com:meritoo/limesurvey-api-client 2018-09-07 13:58:30 +02:00
Meritoo
1389e78068 Phing > tests > missing path of directory with code coverage report 2018-09-07 13:57:19 +02:00
7 changed files with 95 additions and 26 deletions

View File

@@ -1 +1 @@
0.1.0
0.1.1

View File

@@ -12,7 +12,7 @@
"require": {
"php": ">=5.6",
"fguillot/json-rpc": "^1.2",
"meritoo/common-library": "^0.1.0"
"wiosna-dev/common-library": "dev-feature/UW-2934_Add_support_for_PHP_8.x"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.6",

View File

@@ -69,6 +69,7 @@ dir.tests = ${project.basedir}/tests
dir.build = ${project.basedir}/build
dir.reports = ${dir.build}/logs
dir.reports.pdepend = ${dir.reports}/pdepend
dir.reports.coverage = ${dir.reports}/phpunit_coverage
# Data directories
#

View File

@@ -39,6 +39,13 @@ abstract class BaseParticipant extends BaseItem
*/
protected $email;
/**
* Token of the participant
*
* @var string
*/
protected $token;
/**
* Returns ID of the participant
*
@@ -78,4 +85,14 @@ abstract class BaseParticipant extends BaseItem
{
return $this->email;
}
/**
* Returns token of the participant
*
* @return string
*/
public function getToken()
{
return $this->token;
}
}

View File

@@ -42,13 +42,6 @@ class Participant extends BaseParticipant
*/
private $emailStatus;
/**
* Token of the participant
*
* @var string
*/
private $token;
/**
* Language of the participant
*
@@ -232,16 +225,6 @@ class Participant extends BaseParticipant
return $this->emailStatus;
}
/**
* Returns token of the participant
*
* @return string
*/
public function getToken()
{
return $this->token;
}
/**
* Returns language of the participant
*

View File

@@ -28,6 +28,10 @@ class ParticipantShort extends BaseParticipant
$this->id = (int)$value;
break;
case 'token':
$this->token = trim($value);
break;
case 'participant_info':
$this->firstName = trim($value['firstname']);
$this->lastName = trim($value['lastname']);
@@ -52,6 +56,7 @@ class ParticipantShort extends BaseParticipant
$data = [
'tid' => $participant->getId(),
'token' => $participant->getToken(),
'participant_info' => $info,
];

View File

@@ -12,6 +12,8 @@ use Meritoo\Common\Collection\Collection;
use Meritoo\LimeSurvey\ApiClient\Client\Client;
use Meritoo\LimeSurvey\ApiClient\Exception\CannotProcessDataException;
use Meritoo\LimeSurvey\ApiClient\Exception\MissingSurveySummaryException;
use Meritoo\LimeSurvey\ApiClient\Exception\UnknownInstanceOfResultItem;
use Meritoo\LimeSurvey\ApiClient\Exception\UnknownMethodException;
use Meritoo\LimeSurvey\ApiClient\Result\Collection\Participants;
use Meritoo\LimeSurvey\ApiClient\Result\Collection\Surveys;
use Meritoo\LimeSurvey\ApiClient\Result\Collection\SurveysSummaries;
@@ -126,6 +128,8 @@ class SurveyService
* @return Surveys
*
* @throws CannotProcessDataException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/
public function getAllSurveys($onlyActive = false)
{
@@ -160,10 +164,13 @@ class SurveyService
/**
* Returns information if survey with given ID exists
*
* @param int $surveyId ID of survey to verify
* @param int $surveyId ID of survey to verify
* @param bool $shouldBeActive (optional) If is set to true, survey should be active. If it's not, it shouldn't
* be returned, even if exists. Otherwise - it doesn't matter (default behaviour).
* @return bool
* @throws CannotProcessDataException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/
public function isExistingSurvey($surveyId, $shouldBeActive = false)
{
@@ -221,12 +228,15 @@ class SurveyService
/**
* Returns participants of given survey
*
* @param int $surveyId ID of survey
* @param int $surveyId ID of survey
* @param bool $onlyCompleted (optional) If is set to true, participants who completed survey are returned only.
* Otherwise - all (default behaviour).
* @return Collection
*
* @throws CannotProcessDataException
* @throws MissingSurveySummaryException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/
public function getSurveyParticipants($surveyId, $onlyCompleted = false)
{
@@ -275,11 +285,14 @@ class SurveyService
/**
* Adds participant with given data to survey with given ID
*
* @param int $surveyId ID of survey
* @param int $surveyId ID of survey
* @param string $firstName First name of the participant to add
* @param string $lastName Last ame of the participant to add
* @param string $email E-mail address of the participant to add
* @param string $lastName Last ame of the participant to add
* @param string $email E-mail address of the participant to add
* @return Participant
* @throws CannotProcessDataException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/
public function addParticipant($surveyId, $firstName, $lastName, $email)
{
@@ -318,9 +331,13 @@ class SurveyService
/**
* Returns short data of one participant with given e-mail (participant of given survey)
*
* @param int $surveyId ID of survey
* @param string $email E-mail address of the participant
* @param int $surveyId ID of survey
* @param string $email E-mail address of the participant
* @return ParticipantShort|null
* @throws CannotProcessDataException
* @throws MissingSurveySummaryException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/
public function getParticipant($surveyId, $email)
{
@@ -343,7 +360,10 @@ class SurveyService
* @param int $surveyId ID of survey
* @return int
*
* @throws CannotProcessDataException
* @throws MissingSurveySummaryException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/
public function getSurveyTokenCount($surveyId)
{
@@ -374,6 +394,9 @@ class SurveyService
*
* @param int $surveyId ID of survey
* @return SurveySummary|null
* @throws CannotProcessDataException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/
private function getSurveySummary($surveyId)
{
@@ -395,4 +418,44 @@ class SurveyService
return $surveySummary;
}
/**
* @param $surveyId
* @param $email
* @return bool
* @throws CannotProcessDataException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/
public function hasSurveyBeenCompletedByEmail($surveyId, $email)
{
$arguments = [
$surveyId,
$offset = 0,
$limit = 10,
$includeUnused = false,
['completed'],
['email' => $email]
];
try {
/** @var Collection $participants */
$participants = $this
->client
->run(MethodType::LIST_PARTICIPANTS, $arguments)
->getData(true);
foreach ($participants as $participant) {
if ('N' !== $participant['completed']) {
return true;
}
}
} catch (CannotProcessDataException $exception) {
if (ReasonType::NO_PARTICIPANTS_FOUND !== $exception->getReason()) {
throw $exception;
}
}
return false;
}
}