diff --git a/main/survey/survey_invitation.php b/main/survey/survey_invitation.php index 10965f233b..9a308adc2b 100755 --- a/main/survey/survey_invitation.php +++ b/main/survey/survey_invitation.php @@ -25,6 +25,7 @@ $table_course = Database::get_main_table(TABLE_MAIN_COURSE); $table_user = Database::get_main_table(TABLE_MAIN_USER); $table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); $tool_name = get_lang('SurveyInvitations'); +$courseInfo = api_get_course_info(); // Getting the survey information $survey_id = Security::remove_XSS($_GET['survey_id']); @@ -33,6 +34,8 @@ if (empty($survey_data)) { api_not_allowed(true); } +$view = isset($_GET['view']) ? $_GET['view'] : 'invited'; + $urlname = strip_tags( api_substr(api_html_entity_decode($survey_data['title'], ENT_QUOTES), 0, 40) ); @@ -65,20 +68,20 @@ if ($survey_data['anonymous'] == 1 && !api_get_configuration_value('survey_anony } $url = api_get_self().'?survey_id='.$survey_id.'&'.api_get_cidreq(); -if (!isset($_GET['view']) || $_GET['view'] == 'invited') { +if ($view == 'invited') { echo get_lang('ViewInvited').' | '; } else { echo ' '. get_lang('ViewInvited').' |'; } -if ($_GET['view'] == 'answered') { +if ($view == 'answered') { echo get_lang('ViewAnswered').' | '; } else { echo ' '. get_lang('ViewAnswered').' |'; } -if ($_GET['view'] == 'unanswered') { +if ($view == 'unanswered') { echo get_lang('ViewUnanswered'); } else { echo ' '. @@ -91,8 +94,13 @@ echo ' '; echo ' '.get_lang('User').''; echo ' '.get_lang('InvitationDate').''; -if ($_GET['view'] != 'answered') { - echo ' '.get_lang('Answered').''; +switch ($view) { + case 'unanswered': + echo ' '.get_lang('SurveyInviteLink').''; + break; + case 'invited': + echo ' '.get_lang('Answered').''; + break; } echo ' '; @@ -103,9 +111,10 @@ $sessionId = api_get_session_id(); $sentIntitations = SurveyUtil::getSentInvitations($survey_data['code'], $course_id, $sessionId); foreach ($sentIntitations as $row) { - if (!$_GET['view'] || $_GET['view'] == 'invited' || - ($_GET['view'] == 'answered' && in_array($row['user'], $answered_data) && count($answered_data) > 1) || - ($_GET['view'] == 'unanswered' && !in_array($row['user'], $answered_data) && count($answered_data) > 1) + $id = $row['iid']; + if ($view == 'invited' || + ($view == 'answered' && in_array($row['user'], $answered_data) && count($answered_data) > 1) || + ($view == 'unanswered' && !in_array($row['user'], $answered_data) && count($answered_data) > 1) ) { echo ''; if (is_numeric($row['user'])) { @@ -131,14 +140,33 @@ foreach ($sentIntitations as $row) { if (in_array($row['user'], $answered_data)) { $answered = Display::url( get_lang('ViewAnswers'), - api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&survey_id='.$survey_id.'&user='.$row['user'].'&'.api_get_cidreq() + api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&survey_id='.$survey_id.'&user='.$row['user'].'&'.api_get_cidreq(), + ['class' => 'btn btn-primary'] ); } - - if ($_GET['view'] != 'answered') { - echo ' '; - echo $answered; - echo ' '; + switch ($view) { + case 'unanswered': + echo ' '; + $code = $row['invitation_code']; + + $link = api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?'; + $link .= 'id_session='.$sessionId.'&course='.$courseInfo['code'].'&invitationcode='.$code; + + $link = Display::input('text', 'copy_'.$id, $link, ['id' => 'copy_'.$id, 'class' => '']); + $link .= ' '.Display::url( + Display::returnFontAwesomeIcon('copy').get_lang('CopyTextToClipboard'), + 'javascript:void()', + ['onclick' => "copyTextToClipBoard('copy_".$id."')", 'class' => 'btn btn-primary btn-sm'] + ); + + echo $link; + echo ' '; + break; + case 'invited': + echo ' '; + echo $answered; + echo ' '; + break; } echo '';