|
@@ -26,10 +26,11 @@ class SurveyUtil
|
|
|
// Table definitions
|
|
|
$tbl_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
|
|
|
$course_id = api_get_course_int_id();
|
|
|
+ $survey_id = (int) $survey_id;
|
|
|
|
|
|
// Getting the information of the question
|
|
|
$sql = "SELECT * FROM $tbl_survey_question
|
|
|
- WHERE c_id = $course_id AND survey_id='".Database::escape_string($survey_id)."'
|
|
|
+ WHERE c_id = $course_id AND survey_id='".$survey_id."'
|
|
|
ORDER BY sort ASC";
|
|
|
$result = Database::query($sql);
|
|
|
$total = Database::num_rows($result);
|
|
@@ -107,6 +108,7 @@ class SurveyUtil
|
|
|
if (empty($question_id)) {
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
// Table definition
|
|
|
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
|
|
|
|
|
@@ -709,7 +711,7 @@ class SurveyUtil
|
|
|
echo ' </tr>';
|
|
|
}
|
|
|
}
|
|
|
- // displaying the table: footer (totals)
|
|
|
+
|
|
|
$optionResult = '';
|
|
|
if (isset($option['question_id']) && isset($number_of_answers[$option['question_id']])) {
|
|
|
if ($number_of_answers[$option['question_id']] == 0) {
|
|
@@ -881,7 +883,7 @@ class SurveyUtil
|
|
|
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
|
|
|
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
|
|
|
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
|
|
|
-
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
$surveyId = isset($_GET['survey_id']) ? (int) $_GET['survey_id'] : 0;
|
|
|
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : '';
|
|
|
|
|
@@ -956,7 +958,6 @@ class SurveyUtil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $course_id = api_get_course_int_id();
|
|
|
$sql = "SELECT
|
|
|
q.question_id,
|
|
|
q.type,
|
|
@@ -968,7 +969,7 @@ class SurveyUtil
|
|
|
WHERE
|
|
|
survey_question NOT LIKE '%{{%' AND
|
|
|
q.survey_id = '".$surveyId."' AND
|
|
|
- q.c_id = $course_id
|
|
|
+ q.c_id = $course_id
|
|
|
GROUP BY q.question_id
|
|
|
ORDER BY q.sort ASC";
|
|
|
$result = Database::query($sql);
|
|
@@ -1042,7 +1043,7 @@ class SurveyUtil
|
|
|
if (!(isset($_POST['submit_question_filter']) && $_POST['submit_question_filter']) ||
|
|
|
(is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter']))
|
|
|
) {
|
|
|
- // <hub> modif 05-05-2010
|
|
|
+ // we do not show comment and pagebreak question types
|
|
|
if ($row['type'] == 'open' || $row['type'] == 'comment') {
|
|
|
echo '<th> - </th>';
|
|
|
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id'];
|
|
@@ -1229,6 +1230,8 @@ class SurveyUtil
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
+
|
|
|
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
|
|
|
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
|
|
|
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
|
|
@@ -1248,7 +1251,6 @@ class SurveyUtil
|
|
|
|
|
|
$num = count($extra_user_fields);
|
|
|
$return .= str_repeat(';', $num);
|
|
|
- $course_id = api_get_course_int_id();
|
|
|
|
|
|
$sql = "SELECT
|
|
|
questions.question_id,
|
|
@@ -1326,10 +1328,10 @@ class SurveyUtil
|
|
|
survey_question_option.sort as option_sort
|
|
|
FROM $table_survey_question survey_question
|
|
|
LEFT JOIN $table_survey_question_option survey_question_option
|
|
|
- ON
|
|
|
+ ON
|
|
|
survey_question.question_id = survey_question_option.question_id AND
|
|
|
survey_question_option.c_id = survey_question.c_id
|
|
|
- WHERE
|
|
|
+ WHERE
|
|
|
survey_question NOT LIKE '%{{%' AND
|
|
|
survey_question.type <> 'pagebreak' AND
|
|
|
survey_question.survey_id = $surveyId AND
|
|
@@ -2320,14 +2322,9 @@ class SurveyUtil
|
|
|
(!empty($params['user']) || !empty($params['group_id'])) &&
|
|
|
!empty($params['survey_code'])
|
|
|
) {
|
|
|
- $params['survey_invitation_id'] = $params['survey_invitation_id'] ?? 0;
|
|
|
- $params['reminder_date'] = $params['reminder_date'] ?? null;
|
|
|
- $params['answered'] = $params['answered'] ?? 0;
|
|
|
- $params['group_id'] = $params['group_id'] ?? 0;
|
|
|
-
|
|
|
$insertId = Database::insert($table, $params);
|
|
|
if ($insertId) {
|
|
|
- $sql = "UPDATE $table
|
|
|
+ $sql = "UPDATE $table
|
|
|
SET survey_invitation_id = $insertId
|
|
|
WHERE iid = $insertId";
|
|
|
Database::query($sql);
|
|
@@ -2350,9 +2347,9 @@ class SurveyUtil
|
|
|
public static function invitationExists($courseId, $sessionId, $groupId, $surveyCode)
|
|
|
{
|
|
|
$table = Database::get_course_table(TABLE_SURVEY_INVITATION);
|
|
|
- $courseId = intval($courseId);
|
|
|
- $sessionId = intval($sessionId);
|
|
|
- $groupId = intval($groupId);
|
|
|
+ $courseId = (int) $courseId;
|
|
|
+ $sessionId = (int) $sessionId;
|
|
|
+ $groupId = (int) $groupId;
|
|
|
$surveyCode = Database::escape_string($surveyCode);
|
|
|
|
|
|
$sql = "SELECT survey_invitation_id FROM $table
|
|
@@ -2384,11 +2381,10 @@ class SurveyUtil
|
|
|
$sessionId = api_get_session_id();
|
|
|
|
|
|
// Replacing the **link** part with a valid link for the user
|
|
|
- $link = api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?';
|
|
|
- $link .= 'id_session='.$sessionId.'&course='.$_course['code'].'&invitationcode='.$invitation_code;
|
|
|
+ $link = self::generateFillSurveyLink($invitation_code, $_course, $sessionId);
|
|
|
|
|
|
$text_link = '<a href="'.$link.'">'.get_lang('ClickHereToAnswerTheSurvey')."</a><br />\r\n<br />\r\n"
|
|
|
- .get_lang('OrCopyPasteTheFollowingUrl')." <br />\r\n ".$link;
|
|
|
+ .get_lang('OrCopyPasteTheFollowingUrl')." <br /> \r\n <br /> \r\n ".$link;
|
|
|
|
|
|
$replace_count = 0;
|
|
|
$full_invitation_text = api_str_ireplace('**link**', $text_link, $invitation_text, $replace_count);
|
|
@@ -2424,14 +2420,13 @@ class SurveyUtil
|
|
|
null,
|
|
|
null,
|
|
|
null,
|
|
|
- $sender_user_id
|
|
|
+ $sender_user_id,
|
|
|
+ true
|
|
|
);
|
|
|
} else {
|
|
|
- /** @todo check if the address is a valid email */
|
|
|
- $recipient_email = $invitedUser;
|
|
|
@api_mail_html(
|
|
|
'',
|
|
|
- $recipient_email,
|
|
|
+ $invitedUser,
|
|
|
$invitation_title,
|
|
|
$full_invitation_text,
|
|
|
$sender_name,
|
|
@@ -2457,6 +2452,10 @@ class SurveyUtil
|
|
|
*/
|
|
|
public static function update_count_invited($survey_code, $courseId = 0, $sessionId = 0)
|
|
|
{
|
|
|
+ $survey_code = Database::escape_string($survey_code);
|
|
|
+ $courseId = (int) $courseId;
|
|
|
+ $sessionId = (int) $sessionId;
|
|
|
+
|
|
|
$courseId = $courseId ?: api_get_course_int_id();
|
|
|
$sessionId = $sessionId ?: api_get_session_id();
|
|
|
$sessionCondition = api_get_session_condition($sessionId);
|
|
@@ -2470,7 +2469,7 @@ class SurveyUtil
|
|
|
FROM $table_survey_invitation
|
|
|
WHERE
|
|
|
c_id = $courseId AND
|
|
|
- survey_code = '".Database::escape_string($survey_code)."' AND
|
|
|
+ survey_code = '".$survey_code."' AND
|
|
|
user <> ''
|
|
|
$sessionCondition
|
|
|
";
|
|
@@ -2483,7 +2482,7 @@ class SurveyUtil
|
|
|
SET invited = '".Database::escape_string($total_invited)."'
|
|
|
WHERE
|
|
|
c_id = $courseId AND
|
|
|
- code = '".Database::escape_string($survey_code)."'
|
|
|
+ code = '".$survey_code."'
|
|
|
$sessionCondition
|
|
|
";
|
|
|
Database::query($sql);
|
|
@@ -2508,11 +2507,17 @@ class SurveyUtil
|
|
|
*/
|
|
|
public static function get_invited_users($survey_code, $course_code = '', $session_id = 0)
|
|
|
{
|
|
|
+ $session_id = (int) $session_id;
|
|
|
+ $survey_code = Database::escape_string($survey_code);
|
|
|
+ $course_code = Database::escape_string($course_code);
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
+
|
|
|
if (!empty($course_code)) {
|
|
|
$course_info = api_get_course_info($course_code);
|
|
|
- $course_id = $course_info['real_id'];
|
|
|
- } else {
|
|
|
- $course_id = api_get_course_int_id();
|
|
|
+ if ($course_info) {
|
|
|
+ $course_id = $course_info['real_id'];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (empty($session_id)) {
|
|
@@ -2528,7 +2533,7 @@ class SurveyUtil
|
|
|
FROM $table_survey_invitation as table_invitation
|
|
|
WHERE
|
|
|
table_invitation.c_id = $course_id AND
|
|
|
- survey_code='".Database::escape_string($survey_code)."' AND
|
|
|
+ survey_code='".$survey_code."' AND
|
|
|
session_id = $session_id
|
|
|
";
|
|
|
|
|
@@ -2841,10 +2846,16 @@ class SurveyUtil
|
|
|
if (api_is_allowed_to_edit() ||
|
|
|
api_is_element_in_the_session(TOOL_SURVEY, $survey_id)
|
|
|
) {
|
|
|
+ $editUrl = $codePath.'survey/create_new_survey.php?'.
|
|
|
+ http_build_query($params + ['action' => 'edit', 'survey_id' => $survey_id]);
|
|
|
+ if ($survey->getSurveyType() == 3) {
|
|
|
+ $editUrl = $codePath.'survey/edit_meeting.php?'.
|
|
|
+ http_build_query($params + ['action' => 'edit', 'survey_id' => $survey_id]);
|
|
|
+ }
|
|
|
+
|
|
|
$actions[] = Display::url(
|
|
|
Display::return_icon('edit.png', get_lang('Edit')),
|
|
|
- $codePath.'survey/create_new_survey.php?'
|
|
|
- .http_build_query($params + ['action' => 'edit', 'survey_id' => $survey_id])
|
|
|
+ $editUrl
|
|
|
);
|
|
|
|
|
|
if (SurveyManager::survey_generation_hash_available()) {
|
|
@@ -2863,7 +2874,7 @@ class SurveyUtil
|
|
|
$actions[] = Display::url(
|
|
|
Display::return_icon('copy.png', get_lang('DuplicateSurvey')),
|
|
|
$codePath.'survey/survey_list.php?'
|
|
|
- .http_build_query($params + ['action' => 'copy_survey', 'survey_id' => $survey_id])
|
|
|
+ .http_build_query($params + ['action' => 'copy_survey', 'survey_id' => $survey_id])
|
|
|
);
|
|
|
|
|
|
$actions[] = Display::url(
|
|
@@ -2882,7 +2893,7 @@ class SurveyUtil
|
|
|
$actions[] = Display::url(
|
|
|
Display::return_icon('clean.png', get_lang('EmptySurvey')),
|
|
|
$codePath.'survey/survey_list.php?'
|
|
|
- .http_build_query($params + ['action' => 'empty', 'survey_id' => $survey_id]),
|
|
|
+ .http_build_query($params + ['action' => 'empty', 'survey_id' => $survey_id]),
|
|
|
[
|
|
|
'onclick' => "javascript: if (!confirm('".$warning."')) return false;",
|
|
|
]
|
|
@@ -2898,9 +2909,9 @@ class SurveyUtil
|
|
|
}
|
|
|
|
|
|
$actions[] = Display::url(
|
|
|
- Display::return_icon('mail_send.png', get_lang('Publish')),
|
|
|
- $codePath.'survey/survey_invite.php?'.http_build_query($params + ['survey_id' => $survey_id])
|
|
|
- );
|
|
|
+ Display::return_icon('mail_send.png', get_lang('Publish')),
|
|
|
+ $codePath.'survey/survey_invite.php?'.http_build_query($params + ['survey_id' => $survey_id])
|
|
|
+ );
|
|
|
|
|
|
if ($type != 3) {
|
|
|
$actions[] = $hideReportingButton ? null : $reportingLink;
|
|
@@ -2909,13 +2920,15 @@ class SurveyUtil
|
|
|
if (api_is_allowed_to_edit() ||
|
|
|
api_is_element_in_the_session(TOOL_SURVEY, $survey_id)
|
|
|
) {
|
|
|
+ $actions[] = self::getAdditionalTeacherActions($survey_id);
|
|
|
+
|
|
|
$warning = addslashes(api_htmlentities(get_lang('DeleteSurvey').'?', ENT_QUOTES));
|
|
|
$actions[] = Display::url(
|
|
|
Display::return_icon('delete.png', get_lang('Delete')),
|
|
|
$codePath.'survey/survey_list.php?'
|
|
|
- .http_build_query($params + ['action' => 'delete', 'survey_id' => $survey_id]),
|
|
|
+ .http_build_query($params + ['action' => 'delete', 'survey_id' => $survey_id]),
|
|
|
[
|
|
|
- 'onclick' => "javascript: if(!confirm('".$warning."')) return false;",
|
|
|
+ 'onclick' => "javascript: if (!confirm('".$warning."')) return false;",
|
|
|
]
|
|
|
);
|
|
|
}
|
|
@@ -2923,6 +2936,33 @@ class SurveyUtil
|
|
|
return implode(PHP_EOL, $actions);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Get the additional actions added in survey_additional_teacher_modify_actions configuration.
|
|
|
+ *
|
|
|
+ * @param int $surveyId
|
|
|
+ * @param int $iconSize
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public static function getAdditionalTeacherActions($surveyId, $iconSize = ICON_SIZE_SMALL)
|
|
|
+ {
|
|
|
+ $additionalActions = api_get_configuration_value('survey_additional_teacher_modify_actions') ?: [];
|
|
|
+
|
|
|
+ if (empty($additionalActions)) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+
|
|
|
+ $actions = [];
|
|
|
+ foreach ($additionalActions as $additionalAction) {
|
|
|
+ $actions[] = call_user_func(
|
|
|
+ $additionalAction,
|
|
|
+ ['survey_id' => $surveyId, 'icon_size' => $iconSize]
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return implode(PHP_EOL, $actions);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param int $survey_id
|
|
|
*
|
|
@@ -2943,7 +2983,7 @@ class SurveyUtil
|
|
|
Display::return_icon('mail_send.png', get_lang('Publish')),
|
|
|
$codePath.'survey/survey_invite.php?'.http_build_query($params + ['survey_id' => $survey_id])
|
|
|
);
|
|
|
- $warning = addslashes(api_htmlentities(get_lang("EmptySurvey").'?', ENT_QUOTES));
|
|
|
+ $warning = addslashes(api_htmlentities(get_lang('EmptySurvey').'?', ENT_QUOTES));
|
|
|
$actions[] = Display::url(
|
|
|
Display::return_icon('clean.png', get_lang('EmptySurvey')),
|
|
|
$codePath.'survey/survey_list.php?'
|
|
@@ -3113,9 +3153,9 @@ class SurveyUtil
|
|
|
ON (survey.author = user.user_id)
|
|
|
WHERE survey.c_id = $course_id
|
|
|
$search_restriction
|
|
|
- $condition_session
|
|
|
+ $condition_session
|
|
|
GROUP BY survey.survey_id
|
|
|
- ORDER BY col$column $direction
|
|
|
+ ORDER BY col$column $direction
|
|
|
LIMIT $from,$number_of_items
|
|
|
";
|
|
|
$res = Database::query($sql);
|
|
@@ -3135,9 +3175,9 @@ class SurveyUtil
|
|
|
);
|
|
|
} else {
|
|
|
$array[1] = Display::url(
|
|
|
- $survey[1],
|
|
|
- api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey[0].'&'.api_get_cidreq()
|
|
|
- );
|
|
|
+ $survey[1],
|
|
|
+ api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey[0].'&'.api_get_cidreq()
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -3146,14 +3186,25 @@ class SurveyUtil
|
|
|
$array[2] = $survey[2].$session_img;
|
|
|
$array[3] = $survey[3];
|
|
|
$array[4] = $survey[4];
|
|
|
- $array[5] = api_convert_and_format_date(
|
|
|
- $survey[5],
|
|
|
- $allowSurveyAvailabilityDatetime ? DATE_TIME_FORMAT_LONG : DATE_FORMAT_LONG
|
|
|
- );
|
|
|
- $array[6] = api_convert_and_format_date(
|
|
|
- $survey[6],
|
|
|
- $allowSurveyAvailabilityDatetime ? DATE_TIME_FORMAT_LONG : DATE_FORMAT_LONG
|
|
|
- );
|
|
|
+
|
|
|
+ // Dates
|
|
|
+ $array[5] = '';
|
|
|
+
|
|
|
+ if (!empty($survey[5]) && $survey[5] !== '0000-00-00' && $survey[5] !== '0000-00-00 00:00:00') {
|
|
|
+ $array[5] = api_convert_and_format_date(
|
|
|
+ $survey[5],
|
|
|
+ $allowSurveyAvailabilityDatetime ? DATE_TIME_FORMAT_LONG : DATE_FORMAT_LONG
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ $array[6] = '';
|
|
|
+ if (!empty($survey[6]) && $survey[6] !== '0000-00-00' && $survey[6] !== '0000-00-00 00:00:00') {
|
|
|
+ $array[6] = api_convert_and_format_date(
|
|
|
+ $survey[6],
|
|
|
+ $allowSurveyAvailabilityDatetime ? DATE_TIME_FORMAT_LONG : DATE_FORMAT_LONG
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
$array[7] =
|
|
|
Display::url(
|
|
|
$survey['answered'],
|
|
@@ -3230,11 +3281,11 @@ class SurveyUtil
|
|
|
$efv = new ExtraFieldValue('survey');
|
|
|
|
|
|
$sql = "
|
|
|
- SELECT
|
|
|
- survey.survey_id AS col0,
|
|
|
- survey.title AS col1,
|
|
|
- survey.code AS col2,
|
|
|
- count(survey_question.question_id) AS col3,
|
|
|
+ SELECT
|
|
|
+ survey.survey_id AS col0,
|
|
|
+ survey.title AS col1,
|
|
|
+ survey.code AS col2,
|
|
|
+ count(survey_question.question_id) AS col3,
|
|
|
"
|
|
|
.(api_is_western_name_order()
|
|
|
? "CONCAT(user.firstname, ' ', user.lastname)"
|
|
@@ -3300,7 +3351,6 @@ class SurveyUtil
|
|
|
$allowSurveyAvailabilityDatetime = api_get_configuration_value('allow_survey_availability_datetime');
|
|
|
|
|
|
// Database table definitions
|
|
|
- $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
|
|
|
$table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
|
|
|
$table_survey = Database::get_course_table(TABLE_SURVEY);
|
|
|
|
|
@@ -3321,16 +3371,16 @@ class SurveyUtil
|
|
|
$filterDate = $allowSurveyAvailabilityDatetime ? $now->format('Y-m-d H:i') : $now->format('Y-m-d');
|
|
|
|
|
|
$sql = "SELECT *
|
|
|
- FROM $table_survey survey
|
|
|
+ FROM $table_survey survey
|
|
|
INNER JOIN
|
|
|
$table_survey_invitation survey_invitation
|
|
|
ON (
|
|
|
survey.code = survey_invitation.survey_code AND
|
|
|
- survey.c_id = survey_invitation.c_id AND
|
|
|
+ survey.c_id = survey_invitation.c_id AND
|
|
|
survey.session_id = survey_invitation.session_id
|
|
|
)
|
|
|
WHERE
|
|
|
- survey_invitation.user = $user_id AND
|
|
|
+ survey_invitation.user = $user_id AND
|
|
|
survey.avail_from <= '$filterDate' AND
|
|
|
survey.avail_till >= '$filterDate' AND
|
|
|
survey.c_id = $course_id AND
|
|
@@ -3351,8 +3401,7 @@ class SurveyUtil
|
|
|
[],
|
|
|
ICON_SIZE_TINY
|
|
|
);
|
|
|
- $url = api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?course='.$_course['sysCode']
|
|
|
- .'&invitationcode='.$row['invitation_code'].'&cidReq='.$_course['sysCode'].'&id_session='.$row['session_id'];
|
|
|
+ $url = self::generateFillSurveyLink($row['invitation_code'], $_course, $row['session_id']);
|
|
|
echo '<a href="'.$url.'">
|
|
|
'.$row['title']
|
|
|
.'</a></td>';
|
|
@@ -3631,9 +3680,9 @@ class SurveyUtil
|
|
|
$chartContainerId = 'chartContainer'
|
|
|
) {
|
|
|
$htmlChart = '';
|
|
|
- if (api_browser_support("svg")) {
|
|
|
- $htmlChart .= api_get_js("d3/d3.v3.5.4.min.js");
|
|
|
- $htmlChart .= api_get_js("dimple.v2.1.2.min.js").'
|
|
|
+ if (api_browser_support('svg')) {
|
|
|
+ $htmlChart .= api_get_js('d3/d3.v3.5.4.min.js');
|
|
|
+ $htmlChart .= api_get_js('dimple.v2.1.2.min.js').'
|
|
|
<script>
|
|
|
var svg = dimple.newSvg("#'.$chartContainerId.'", "100%", 400);
|
|
|
var data = [';
|
|
@@ -3794,4 +3843,64 @@ class SurveyUtil
|
|
|
|
|
|
return $pendingSurveys;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param string $surveyCode
|
|
|
+ * @param int $courseId
|
|
|
+ * @param int $sessionId
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public static function getSentInvitations($surveyCode, $courseId, $sessionId = 0)
|
|
|
+ {
|
|
|
+ $tblUser = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
+ $tblSurveyInvitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
|
|
|
+
|
|
|
+ $sessionCondition = api_get_session_condition($sessionId);
|
|
|
+ $surveyCode = Database::escape_string($surveyCode);
|
|
|
+ $courseId = (int) $courseId;
|
|
|
+
|
|
|
+ $sql = "SELECT survey_invitation.*, user.firstname, user.lastname, user.email
|
|
|
+ FROM $tblSurveyInvitation survey_invitation
|
|
|
+ LEFT JOIN $tblUser user
|
|
|
+ ON (survey_invitation.user = user.id AND survey_invitation.c_id = $courseId)
|
|
|
+ WHERE
|
|
|
+ survey_invitation.survey_code = '$surveyCode'
|
|
|
+ $sessionCondition";
|
|
|
+
|
|
|
+ $query = Database::query($sql);
|
|
|
+
|
|
|
+ return Database::store_result($query);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param string $code invitation code
|
|
|
+ * @param array $courseInfo
|
|
|
+ * @param int $sessionId
|
|
|
+ * @param string $surveyCode
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public static function generateFillSurveyLink($code, $courseInfo, $sessionId, $surveyCode = '')
|
|
|
+ {
|
|
|
+ $code = Security::remove_XSS($code);
|
|
|
+ $sessionId = (int) $sessionId;
|
|
|
+
|
|
|
+ if (empty($courseInfo)) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+
|
|
|
+ $params = [
|
|
|
+ 'invitationcode' => $code,
|
|
|
+ 'cidReq' => $courseInfo['code'],
|
|
|
+ 'course' => $courseInfo['code'],
|
|
|
+ 'id_session' => $sessionId,
|
|
|
+ ];
|
|
|
+
|
|
|
+ if (!empty($surveyCode)) {
|
|
|
+ $params['scode'] = Security::remove_XSS($surveyCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ return api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?'.http_build_query($params);
|
|
|
+ }
|
|
|
}
|