Survey: Allow tutors to access doodle past end date and cosmetic changes - BT#21622

pull/5474/head
christianbeeznst 1 year ago
parent 764d93aef3
commit e457b0e297
  1. 35
      public/main/survey/meeting.php
  2. 35
      public/main/survey/survey.lib.php

@ -50,8 +50,6 @@ if (null === $survey) {
} }
$surveyId = $survey->getIid(); $surveyId = $survey->getIid();
SurveyManager::checkTimeAvailability($survey);
$invitations = SurveyUtil::get_invited_users($survey); $invitations = SurveyUtil::get_invited_users($survey);
$students = $invitations['course_users'] ?? []; $students = $invitations['course_users'] ?? [];
@ -65,6 +63,10 @@ $interbreadcrumb[] = [
$url = api_get_self().'?survey_id='.$surveyId.'&invitationcode='.$invitationcode.'&'.api_get_cidreq(); $url = api_get_self().'?survey_id='.$surveyId.'&invitationcode='.$invitationcode.'&'.api_get_cidreq();
$urlEdit = $url.'&action=edit'; $urlEdit = $url.'&action=edit';
if (!api_is_allowed_to_edit()) {
SurveyManager::checkTimeAvailability($survey);
}
$questions = $survey->getQuestions(); $questions = $survey->getQuestions();
if (isset($_POST) && !empty($_POST)) { if (isset($_POST) && !empty($_POST)) {
@ -110,10 +112,13 @@ if (isset($_POST) && !empty($_POST)) {
$template = new Template(); $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; $row = 0;
$column = 1; $column = 0;
$answerList = []; $answerList = [];
$table->setHeaderContents($row, $column, "");
$column++;
foreach ($questions as $item) { foreach ($questions as $item) {
$questionId = $item->getIid(); $questionId = $item->getIid();
$answers = SurveyUtil::get_answers_of_question_by_user($surveyId, $questionId); $answers = SurveyUtil::get_answers_of_question_by_user($surveyId, $questionId);
@ -142,18 +147,18 @@ foreach ($questions as $item) {
} }
$mainDate = api_format_date($mainDate, DATE_FORMAT_SHORT); $mainDate = api_format_date($mainDate, DATE_FORMAT_SHORT);
$table->setHeaderContents($row, $column, "<h4>$mainDate</h4> $startTime <br >$endTime"); $table->setHeaderContents($row, $column, "<h4>$mainDate</h4> <span class='text-lg'>$startTime <br >$endTime</span>");
$column++; $column++;
} }
$row = 1; $row = 0;
$column = 0; $column = 0;
// Total counter // Total counter
$table->setHeaderContents( $table->setCellContents(
$row, $row,
0, 0,
get_lang('Number of users').': '.count($students) '<span class="text-bold font-extrabold text-xl">'.get_lang('Number of users').': '.count($students).'</span>'
); );
foreach ($questions as $item) { foreach ($questions as $item) {
@ -166,8 +171,8 @@ foreach ($questions as $item) {
$questionsWithAnswer++; $questionsWithAnswer++;
} }
} }
$count = '<p style="color:cornflowerblue" > $count = '<p class="text-info text-center p-2 text-bold font-extrabold text-2xl">
<span class="fa fa-check fa-2x"></span>'.$questionsWithAnswer.'</p>'; <span class="mdi mdi-check text-3xl"></span>'.$questionsWithAnswer.'</p>';
} }
$table->setCellContents( $table->setCellContents(
$row, $row,
@ -176,7 +181,7 @@ foreach ($questions as $item) {
); );
} }
$row = 2; $row = 1;
$column = 0; $column = 0;
$availableIcon = Display::getMdiIcon(StateIcon::ACTIVE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Available')); $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')); $notAvailableIcon = Display::getMdiIcon(StateIcon::INACTIVE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Not available'));
@ -210,7 +215,7 @@ foreach ($students as $studentId) {
} }
if ('edit' === $action) { if ('edit' === $action) {
$html = '<div class="alert alert-info"><input $html = '<div class="alert alert-info text-center"><input
id="'.$questionId.'" id="'.$questionId.'"
name="options['.$questionId.']" name="options['.$questionId.']"
class="question" '.$checked.' class="question" '.$checked.'
@ -220,7 +225,7 @@ foreach ($students as $studentId) {
$html = $checked; $html = $checked;
} }
$table->setHeaderContents( $table->setCellContents(
$row, $row,
$rowColumn, $rowColumn,
$html $html
@ -238,7 +243,7 @@ foreach ($students as $studentId) {
$checked = $notAvailableIcon; $checked = $notAvailableIcon;
} }
} }
$table->setHeaderContents( $table->setCellContents(
$row, $row,
$rowColumn, $rowColumn,
$checked $checked
@ -247,7 +252,7 @@ foreach ($students as $studentId) {
} }
} }
$column = 0; $column = 0;
$table->setCellContents($row, $column, $name); $table->setCellContents($row, $column, '<span class="text-bold font-extrabold text-lg">'.$name.'</span>');
$row++; $row++;
} }
if ('edit' === $action) { if ('edit' === $action) {

@ -2121,7 +2121,7 @@ class SurveyManager
/** /**
* Check whether this survey has ended. If so, display message and exit this script. * 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) { if (null === $survey) {
api_not_allowed(true); api_not_allowed(true);
@ -2133,27 +2133,32 @@ class SurveyManager
$currentDate = new DateTime('now', $utcZone); $currentDate = new DateTime('now', $utcZone);
$currentDate->modify('today'); $currentDate->modify('today');
$returnMessage = false;
if ($currentDate < $startDate) { if ($currentDate < $startDate) {
api_not_allowed( $returnMessage = Display:: return_message(
true, get_lang('This survey is not yet available. Please try again later. Thank you.'),
Display:: return_message( 'warning',
get_lang('This survey is not yet available. Please try again later. Thank you.'), false
'warning',
false
)
); );
} }
if ($currentDate > $endDate) { if ($currentDate > $endDate) {
api_not_allowed( $returnMessage = Display:: return_message(
true, get_lang('Sorry, this survey is not available anymore. Thank you for trying.'),
Display:: return_message( 'warning',
get_lang('Sorry, this survey is not available anymore. Thank you for trying.'), false
'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;
}
} }
/** /**

Loading…
Cancel
Save