$courseId, 'session_id' => $sessionId, 'user' => $invitation_code, 'survey_code' => $survey_data['code'], 'invitation_code' => $invitation_code, 'invitation_date' => api_get_utc_datetime(), ]; $invitation_id = SurveyUtil::save_invitation($params); if ($invitation_id) { $link = SurveyUtil::generateFillSurveyLink($invitation_code, $courseInfo['code'], $sessionId); header('Location: '.$link); exit; } } else { api_not_allowed(true); }