From e457b0e2971cd30ce0cbd11ad56f18065d9a07fc Mon Sep 17 00:00:00 2001 From: christianbeeznst Date: Thu, 2 May 2024 23:38:46 -0500 Subject: [PATCH] Survey: Allow tutors to access doodle past end date and cosmetic changes - BT#21622 --- public/main/survey/meeting.php | 35 ++++++++++++++++++------------- public/main/survey/survey.lib.php | 35 ++++++++++++++++++------------- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/public/main/survey/meeting.php b/public/main/survey/meeting.php index 7d43e215992..296569eaf81 100644 --- a/public/main/survey/meeting.php +++ b/public/main/survey/meeting.php @@ -50,8 +50,6 @@ } $surveyId = $survey->getIid(); - -SurveyManager::checkTimeAvailability($survey); $invitations = SurveyUtil::get_invited_users($survey); $students = $invitations['course_users'] ?? []; @@ -65,6 +63,10 @@ $url = api_get_self().'?survey_id='.$surveyId.'&invitationcode='.$invitationcode.'&'.api_get_cidreq(); $urlEdit = $url.'&action=edit'; +if (!api_is_allowed_to_edit()) { + SurveyManager::checkTimeAvailability($survey); +} + $questions = $survey->getQuestions(); if (isset($_POST) && !empty($_POST)) { @@ -110,10 +112,13 @@ $template = new Template(); -$table = new HTML_Table(['class' => 'table']); +$table = new HTML_Table(['class' => 'table table-hover table-striped data_table mt-5']); $row = 0; -$column = 1; +$column = 0; $answerList = []; + +$table->setHeaderContents($row, $column, ""); +$column++; foreach ($questions as $item) { $questionId = $item->getIid(); $answers = SurveyUtil::get_answers_of_question_by_user($surveyId, $questionId); @@ -142,18 +147,18 @@ } $mainDate = api_format_date($mainDate, DATE_FORMAT_SHORT); - $table->setHeaderContents($row, $column, "

$mainDate

$startTime
$endTime"); + $table->setHeaderContents($row, $column, "

$mainDate

$startTime
$endTime
"); $column++; } -$row = 1; +$row = 0; $column = 0; // Total counter -$table->setHeaderContents( +$table->setCellContents( $row, 0, - get_lang('Number of users').': '.count($students) + ''.get_lang('Number of users').': '.count($students).'' ); foreach ($questions as $item) { @@ -166,8 +171,8 @@ $questionsWithAnswer++; } } - $count = '

- '.$questionsWithAnswer.'

'; + $count = '

+ '.$questionsWithAnswer.'

'; } $table->setCellContents( $row, @@ -176,7 +181,7 @@ ); } -$row = 2; +$row = 1; $column = 0; $availableIcon = Display::getMdiIcon(StateIcon::ACTIVE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Available')); $notAvailableIcon = Display::getMdiIcon(StateIcon::INACTIVE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Not available')); @@ -210,7 +215,7 @@ } if ('edit' === $action) { - $html = '
setHeaderContents( + $table->setCellContents( $row, $rowColumn, $html @@ -238,7 +243,7 @@ class="question" '.$checked.' $checked = $notAvailableIcon; } } - $table->setHeaderContents( + $table->setCellContents( $row, $rowColumn, $checked @@ -247,7 +252,7 @@ class="question" '.$checked.' } } $column = 0; - $table->setCellContents($row, $column, $name); + $table->setCellContents($row, $column, ''.$name.''); $row++; } if ('edit' === $action) { diff --git a/public/main/survey/survey.lib.php b/public/main/survey/survey.lib.php index d5040dffc19..3a3b779e13b 100644 --- a/public/main/survey/survey.lib.php +++ b/public/main/survey/survey.lib.php @@ -2121,7 +2121,7 @@ public static function getCountPages(CSurvey $survey) /** * Check whether this survey has ended. If so, display message and exit this script. */ - public static function checkTimeAvailability(?CSurvey $survey) + public static function checkTimeAvailability(?CSurvey $survey): void { if (null === $survey) { api_not_allowed(true); @@ -2133,27 +2133,32 @@ public static function checkTimeAvailability(?CSurvey $survey) $currentDate = new DateTime('now', $utcZone); $currentDate->modify('today'); + $returnMessage = false; if ($currentDate < $startDate) { - api_not_allowed( - true, - Display:: return_message( - get_lang('This survey is not yet available. Please try again later. Thank you.'), - 'warning', - false - ) + $returnMessage = Display:: return_message( + get_lang('This survey is not yet available. Please try again later. Thank you.'), + 'warning', + false ); } if ($currentDate > $endDate) { - api_not_allowed( - true, - Display:: return_message( - get_lang('Sorry, this survey is not available anymore. Thank you for trying.'), - 'warning', - false - ) + $returnMessage = Display:: return_message( + get_lang('Sorry, this survey is not available anymore. Thank you for trying.'), + 'warning', + false ); } + + if (false !== $returnMessage) { + $content = Display::page_header($survey->getTitle()); + $content .= $returnMessage; + $template = new Template(); + $template->assign('actions', Display::toolbarAction('toolbar', [])); + $template->assign('content', $content); + $template->display_one_col_template(); + exit; + } } /**