1 | <?php |
||
2 | |||
3 | /* For licensing terms, see /license.txt */ |
||
4 | |||
5 | use Chamilo\CoreBundle\Framework\Container; |
||
6 | |||
7 | require_once __DIR__.'/../inc/global.inc.php'; |
||
8 | |||
9 | $surveyId = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : 0; |
||
10 | $sessionId = isset($_REQUEST['s']) ? (int) $_REQUEST['s'] : 0; |
||
11 | $courseId = isset($_REQUEST['c']) ? (int) $_REQUEST['c'] : 0; |
||
12 | |||
13 | if (empty($surveyId)) { |
||
14 | api_not_allowed(true); |
||
15 | } |
||
16 | $repo = Container::getSurveyRepository(); |
||
17 | $survey = $repo->find($surveyId); |
||
18 | if (null === $survey) { |
||
19 | api_not_allowed(true); |
||
20 | } |
||
21 | |||
22 | if (!SurveyManager::survey_generation_hash_available()) { |
||
23 | api_not_allowed(true); |
||
24 | } |
||
25 | $course = api_get_course_entity($courseId); |
||
26 | $hashIsValid = SurveyManager::validate_survey_hash( |
||
27 | $surveyId, |
||
28 | $courseId, |
||
29 | $sessionId, |
||
30 | $_REQUEST['g'], |
||
31 | $_REQUEST['h'] |
||
32 | ); |
||
33 | if ($hashIsValid && $course) { |
||
34 | $invitationCode = api_get_unique_id(); |
||
35 | $invitation = SurveyUtil::saveInvitation( |
||
36 | $invitationCode, |
||
37 | $invitationCode, |
||
38 | api_get_utc_datetime(time(), false, true), |
||
39 | $survey, |
||
40 | $course, |
||
41 | api_get_session_entity() |
||
42 | ); |
||
43 | if ($invitation) { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
44 | $link = SurveyUtil::generateFillSurveyLink($survey, $invitationCode, $course, $sessionId); |
||
45 | header('Location: '.$link); |
||
46 | exit; |
||
47 | } |
||
48 | } else { |
||
49 | api_not_allowed(true); |
||
50 | } |
||
51 |