find($surveyId); if (null === $survey) { api_not_allowed(true); } $surveyId = $survey->getIid(); $view = $_GET['view'] ?? 'invited'; $urlname = strip_tags( api_substr(api_html_entity_decode($survey->getTitle(), ENT_QUOTES), 0, 40) ); if (api_strlen(strip_tags($survey->getTitle())) > 40) { $urlname .= '...'; } // Breadcrumbs $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', 'name' => get_lang('Survey list'), ]; $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$surveyId, 'name' => $urlname, ]; Display::display_header($tool_name); $course_id = api_get_course_int_id(); $sessionId = api_get_session_id(); $sentInvitations = SurveyUtil::getSentInvitations($survey->getIid(), $course_id, $sessionId); // Getting all the people who have filled this survey $answered_data = SurveyManager::get_people_who_filled_survey($surveyId); $invitationsCount = count($sentInvitations); $answeredCount = count($answered_data); $unAnsweredCount = count($sentInvitations) - count($answered_data); if (1 == $survey->getAnonymous() && ('true' !== api_get_setting('survey.survey_anonymous_show_answered'))) { echo Display::return_message( get_lang('This survey is anonymous. You can\'t see who answered.').' '.$answeredCount.' '.get_lang( 'people answered' ) ); $answered_data = []; } if (1 == $survey->getAnonymous()) { if ($answeredCount < 2) { $answeredCount = 0; $unAnsweredCount = $invitationsCount; } } $url = api_get_self().'?survey_id='.$surveyId.'&'.api_get_cidreq(); echo ''; echo ''; echo ''; echo ''; echo ''; switch ($view) { case 'unanswered': echo ''; break; default: echo ''; break; } echo ''; $surveyAnonymousShowAnswered = ('true' === api_get_setting('survey.survey_anonymous_show_answered')); $hideSurveyReportingButton = ('true' === api_get_setting('survey.hide_survey_reporting_button')); foreach ($sentInvitations as $row) { $id = $row['iid']; $user = $row['user']; if ('invited' === $view || ('answered' === $view && in_array($user, $answered_data) && $answeredCount > 1) || ('unanswered' === $view && !in_array($user, $answered_data) && $answeredCount > 1) ) { echo ''; if (is_numeric($user)) { $userInfo = api_get_user_info($user); echo ''; } else { echo ''; } echo ' '; if (in_array($user, $answered_data)) { if (!$surveyAnonymousShowAnswered && !$hideSurveyReportingButton) { echo ''; } else { if (1 == $survey->getAnonymous() && $answeredCount > 1) { echo ''; } else { echo ''; } } } else { if ('unanswered' === $view) { echo ''; } else { echo ''; } } echo ''; } elseif ('unanswered' === $view && 0 == $answeredCount) { echo ''; if (is_numeric($row['user'])) { $userInfo = api_get_user_info($row['user']); echo ''; } else { echo ''; } echo ' '; echo ' '; } } echo '
'.get_lang('User').''.get_lang('Invitation date').''.get_lang('Survey invitation link').''.get_lang('Answered').'
'; echo UserManager::getUserProfileLink($userInfo); echo ''.$user.''.Display::dateToStringAgoAndLongDate($row['invitation_date']).''; echo ''. get_lang('View answers').''; echo ''.get_lang('Answered').'-'; $code = $row['invitation_code']; $link = SurveyUtil::generateFillSurveyLink($survey, $code, $course, $sessionId); $link = Display::input('text', 'copy_'.$id, $link, ['id' => 'copy_'.$id, 'class' => '']); $link .= ' '.Display::url( Display::getMdiIcon('content-copy').get_lang('Copy text'), 'javascript:void()', ['onclick' => "copyTextToClipBoard('copy_".$id."')", 'class' => 'btn btn--primary btn-sm'] ); echo $link; echo ' -
'; echo UserManager::getUserProfileLink($userInfo); echo ''.$row['user'].''.Display::dateToStringAgoAndLongDate($row['invitation_date']).''; $code = $row['invitation_code']; $link = SurveyUtil::generateFillSurveyLink($survey, $code, $course, $sessionId); $link = Display::input('text', 'copy_'.$id, $link, ['id' => 'copy_'.$id, 'class' => '']); $link .= ' '.Display::url( Display::getMdiIcon('content-copy').get_lang('Copy text'), 'javascript:void()', ['onclick' => "copyTextToClipBoard('copy_".$id."')", 'class' => 'btn btn--primary btn-sm'] ); echo $link; echo '
'; Display::display_footer();