19 Commits
0.1.1 ... 0.1.5

Author SHA1 Message Date
petermarynczak
7d1cc5384e Merge pull request #7 from wiosna-dev/feature/WZUW-1498-Lime_misinterpretation_of_time
[WZUW-1498] [prod] Using 24-hour format to set validfrom date_time
2025-09-12 12:57:49 +02:00
petermarynczak
e74f2e1a51 Merge pull request #8 from wiosna-dev/feature/WZUW-1267-Lime_surveys
[WZUW-1267] [master] Update version of wiosna-dev/common-library
2025-09-12 12:54:26 +02:00
Piotr Marynczak
4f7a72dc0b [WZUW-1498] feat: Using 24-hour format to set validfrom date_time 2025-09-11 13:42:26 +02:00
Piotr Marynczak
13886da84d [WZUW-1267] package: Update version of wiosna-dev/common-library 2025-05-20 16:33:06 +02:00
petermarynczak
7c1ee7dfb8 Merge pull request #6 from wiosna-dev/feature/WZUW-781-from-tag-0.1.3
[WZUW-781] chore: added validfrom key upon creating a participant
2024-07-03 14:44:10 +02:00
Piotr Marynczak
59ebe2d236 [WZUW-781] chore: added validfrom key upon creating a participant 2024-07-03 12:59:09 +02:00
xevolic
e025b71059 Merge pull request #4 from wiosna-dev/fix/UW-2934_Add_support_for_PHP_8.2
[UW-2934] add support for PHP 8.2
2023-03-09 16:57:33 +01:00
Tomasz Kuter
b658e04445 [UW-2934] chore(composer): updated base version of "wiosna-dev/common-library" 2023-03-09 15:29:22 +01:00
Tomasz Kuter
d4e74bc270 [UW-2934] chore(composer): restored previous repository for wiosna-dev/common-library 2023-02-16 16:39:25 +01:00
Tomasz Kuter
8127330642 [UW-2934] chore(composer): temporarily switched to clone of repo wiosna-dev/common-library 2023-02-15 11:04:55 +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
5 changed files with 95 additions and 25 deletions

View File

@@ -12,7 +12,7 @@
"require": { "require": {
"php": ">=5.6", "php": ">=5.6",
"fguillot/json-rpc": "^1.2", "fguillot/json-rpc": "^1.2",
"wiosna-dev/common-library": "^0.1.0" "wiosna-dev/common-library": "^0.2.0"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^2.6", "friendsofphp/php-cs-fixer": "^2.6",

View File

@@ -39,6 +39,13 @@ abstract class BaseParticipant extends BaseItem
*/ */
protected $email; protected $email;
/**
* Token of the participant
*
* @var string
*/
protected $token;
/** /**
* Returns ID of the participant * Returns ID of the participant
* *
@@ -78,4 +85,14 @@ abstract class BaseParticipant extends BaseItem
{ {
return $this->email; 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; private $emailStatus;
/**
* Token of the participant
*
* @var string
*/
private $token;
/** /**
* Language of the participant * Language of the participant
* *
@@ -232,16 +225,6 @@ class Participant extends BaseParticipant
return $this->emailStatus; return $this->emailStatus;
} }
/**
* Returns token of the participant
*
* @return string
*/
public function getToken()
{
return $this->token;
}
/** /**
* Returns language of the participant * Returns language of the participant
* *

View File

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

View File

@@ -12,6 +12,8 @@ use Meritoo\Common\Collection\Collection;
use Meritoo\LimeSurvey\ApiClient\Client\Client; use Meritoo\LimeSurvey\ApiClient\Client\Client;
use Meritoo\LimeSurvey\ApiClient\Exception\CannotProcessDataException; use Meritoo\LimeSurvey\ApiClient\Exception\CannotProcessDataException;
use Meritoo\LimeSurvey\ApiClient\Exception\MissingSurveySummaryException; 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\Participants;
use Meritoo\LimeSurvey\ApiClient\Result\Collection\Surveys; use Meritoo\LimeSurvey\ApiClient\Result\Collection\Surveys;
use Meritoo\LimeSurvey\ApiClient\Result\Collection\SurveysSummaries; use Meritoo\LimeSurvey\ApiClient\Result\Collection\SurveysSummaries;
@@ -21,6 +23,7 @@ use Meritoo\LimeSurvey\ApiClient\Result\Item\Survey;
use Meritoo\LimeSurvey\ApiClient\Result\Item\SurveySummary; use Meritoo\LimeSurvey\ApiClient\Result\Item\SurveySummary;
use Meritoo\LimeSurvey\ApiClient\Type\MethodType; use Meritoo\LimeSurvey\ApiClient\Type\MethodType;
use Meritoo\LimeSurvey\ApiClient\Type\ReasonType; use Meritoo\LimeSurvey\ApiClient\Type\ReasonType;
use Meritoo\Common\Utilities\Date;
/** /**
* Service that serves surveys and participants of surveys * Service that serves surveys and participants of surveys
@@ -126,6 +129,8 @@ class SurveyService
* @return Surveys * @return Surveys
* *
* @throws CannotProcessDataException * @throws CannotProcessDataException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/ */
public function getAllSurveys($onlyActive = false) public function getAllSurveys($onlyActive = false)
{ {
@@ -164,6 +169,9 @@ class SurveyService
* @param bool $shouldBeActive (optional) If is set to true, survey should be active. If it's not, it shouldn't * @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). * be returned, even if exists. Otherwise - it doesn't matter (default behaviour).
* @return bool * @return bool
* @throws CannotProcessDataException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/ */
public function isExistingSurvey($surveyId, $shouldBeActive = false) public function isExistingSurvey($surveyId, $shouldBeActive = false)
{ {
@@ -227,6 +235,9 @@ class SurveyService
* @return Collection * @return Collection
* *
* @throws CannotProcessDataException * @throws CannotProcessDataException
* @throws MissingSurveySummaryException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/ */
public function getSurveyParticipants($surveyId, $onlyCompleted = false) public function getSurveyParticipants($surveyId, $onlyCompleted = false)
{ {
@@ -280,6 +291,9 @@ class SurveyService
* @param string $lastName Last ame 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 $email E-mail address of the participant to add
* @return Participant * @return Participant
* @throws CannotProcessDataException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/ */
public function addParticipant($surveyId, $firstName, $lastName, $email) public function addParticipant($surveyId, $firstName, $lastName, $email)
{ {
@@ -288,6 +302,7 @@ class SurveyService
'firstname' => $firstName, 'firstname' => $firstName,
'lastname' => $lastName, 'lastname' => $lastName,
'email' => $email, 'email' => $email,
'validfrom' => date('Y-m-d H:i:s'),
], ],
]; ];
@@ -321,6 +336,10 @@ class SurveyService
* @param int $surveyId ID of survey * @param int $surveyId ID of survey
* @param string $email E-mail address of the participant * @param string $email E-mail address of the participant
* @return ParticipantShort|null * @return ParticipantShort|null
* @throws CannotProcessDataException
* @throws MissingSurveySummaryException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/ */
public function getParticipant($surveyId, $email) public function getParticipant($surveyId, $email)
{ {
@@ -343,7 +362,10 @@ class SurveyService
* @param int $surveyId ID of survey * @param int $surveyId ID of survey
* @return int * @return int
* *
* @throws CannotProcessDataException
* @throws MissingSurveySummaryException * @throws MissingSurveySummaryException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/ */
public function getSurveyTokenCount($surveyId) public function getSurveyTokenCount($surveyId)
{ {
@@ -374,6 +396,9 @@ class SurveyService
* *
* @param int $surveyId ID of survey * @param int $surveyId ID of survey
* @return SurveySummary|null * @return SurveySummary|null
* @throws CannotProcessDataException
* @throws UnknownInstanceOfResultItem
* @throws UnknownMethodException
*/ */
private function getSurveySummary($surveyId) private function getSurveySummary($surveyId)
{ {
@@ -395,4 +420,44 @@ class SurveyService
return $surveySummary; 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;
}
} }