mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 10:11:49 +01:00
ParticipantService - getParticipant() & hasParticipantFilledSurvey() methods - returns participant of survey & information if participant has filled survey
This commit is contained in:
@@ -10,6 +10,7 @@ namespace Meritoo\LimeSurvey\ApiClient\Service;
|
||||
|
||||
use Meritoo\Common\Collection\Collection;
|
||||
use Meritoo\LimeSurvey\ApiClient\Client\Client;
|
||||
use Meritoo\LimeSurvey\ApiClient\Exception\MissingParticipantOfSurveyException;
|
||||
use Meritoo\LimeSurvey\ApiClient\Result\Collection\Participants;
|
||||
use Meritoo\LimeSurvey\ApiClient\Result\Item\Participant;
|
||||
use Meritoo\LimeSurvey\ApiClient\Type\MethodType;
|
||||
@@ -149,4 +150,38 @@ class ParticipantService
|
||||
|
||||
return $participantCollection->getFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns participant with given e-mail of given survey
|
||||
*
|
||||
* @param int $surveyId ID of survey
|
||||
* @param string $email E-mail address of the participant
|
||||
* @return Participant|null
|
||||
*/
|
||||
public function getParticipant($surveyId, $email)
|
||||
{
|
||||
return $this
|
||||
->allParticipants
|
||||
->getParticipantOfSurvey($surveyId, $email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information if participant with given e-mail has filled given survey
|
||||
*
|
||||
* @param int $surveyId ID of survey
|
||||
* @param string $email E-mail address of the participant
|
||||
* @return bool
|
||||
*
|
||||
* @throws MissingParticipantOfSurveyException
|
||||
*/
|
||||
public function hasParticipantFilledSurvey($surveyId, $email)
|
||||
{
|
||||
if ($this->hasParticipant($surveyId, $email)) {
|
||||
return true === $this
|
||||
->getParticipant($surveyId, $email)
|
||||
->isCompleted();
|
||||
}
|
||||
|
||||
throw new MissingParticipantOfSurveyException($surveyId, $email);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user