Skip to content

Commit

Permalink
Retrieve resume link when importing survey responses.
Browse files Browse the repository at this point in the history
  • Loading branch information
sten committed Apr 8, 2024
1 parent 6401ea6 commit 3c57791
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="documentation/img/banner-laravel-surveyhero.png" alt="Laravel Surveyhero"></p>
<p style="text-align: center;"><img src="documentation/img/banner-laravel-surveyhero.png" alt="Laravel Surveyhero"></p>

# Import Surveyhero responses into the Laravel database

Expand Down Expand Up @@ -50,6 +50,7 @@ SURVEY {
json collector_ids
json question_mapping
datetime survey_last_imported
boolean use_resume_link
}
SURVEY_QUESTIONS {
Expand Down Expand Up @@ -78,6 +79,7 @@ SURVEY_RESPONSE {
string survey_language
bool survey_completed
json surveyhero_link_parameters
string resume_link
num survey_id FK
}
SURVEY_QUESTION_RESPONSE {
Expand Down Expand Up @@ -197,6 +199,7 @@ To do this, add `questions` to the question_mapping in your config file and incl
[
'survey_id' => 1234567,
'collectors' => [986362,524948],
'use_resume_link' => true,
'questions' => [
#example numeric input
1000005 => [
Expand Down
1 change: 1 addition & 0 deletions src/Contracts/SurveyResponseContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @property string $survey_language
* @property bool $survey_completed
* @property int $survey_id
* @property string $resume_link
* @property SurveyContract $survey
* @property Collection $surveyQuestionResponses
*/
Expand Down
6 changes: 6 additions & 0 deletions src/Services/SurveyResponseImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ private function createOrUpdateSurveyResponse(\stdClass $surveyheroResponse, Sur
}
}

//add resume link if configured:
if($survey->use_resume_link) {
$resumeLink = $this->client->getResumeLink($survey->surveyhero_id, $surveyheroResponse->response_id);
$responseData['resume_link'] = $resumeLink;
}

return app(SurveyheroRegistrar::class)->getSurveyResponseClass()::updateOrCreate([
'id' => $existingResponse->id ?? null,
], $responseData);
Expand Down

0 comments on commit 3c57791

Please sign in to comment.