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. 23
      public/main/survey/survey.lib.php

@ -50,8 +50,6 @@ if (null === $survey) {
}
$surveyId = $survey->getIid();
SurveyManager::checkTimeAvailability($survey);
$invitations = SurveyUtil::get_invited_users($survey);
$students = $invitations['course_users'] ?? [];
@ -65,6 +63,10 @@ $interbreadcrumb[] = [
$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 @@ if (isset($_POST) && !empty($_POST)) {
$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 @@ foreach ($questions as $item) {
}
$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++;
}
$row = 1;
$row = 0;
$column = 0;
// Total counter
$table->setHeaderContents(
$table->setCellContents(
$row,
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) {
@ -166,8 +171,8 @@ foreach ($questions as $item) {
$questionsWithAnswer++;
}
}
$count = '<p style="color:cornflowerblue" >
<span class="fa fa-check fa-2x"></span>'.$questionsWithAnswer.'</p>';
$count = '<p class="text-info text-center p-2 text-bold font-extrabold text-2xl">
<span class="mdi mdi-check text-3xl"></span>'.$questionsWithAnswer.'</p>';
}
$table->setCellContents(
$row,
@ -176,7 +181,7 @@ foreach ($questions as $item) {
);
}
$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 @@ foreach ($students as $studentId) {
}
if ('edit' === $action) {
$html = '<div class="alert alert-info"><input
$html = '<div class="alert alert-info text-center"><input
id="'.$questionId.'"
name="options['.$questionId.']"
class="question" '.$checked.'
@ -220,7 +225,7 @@ foreach ($students as $studentId) {
$html = $checked;
}
$table->setHeaderContents(
$table->setCellContents(
$row,
$rowColumn,
$html
@ -238,7 +243,7 @@ foreach ($students as $studentId) {
$checked = $notAvailableIcon;
}
}
$table->setHeaderContents(
$table->setCellContents(
$row,
$rowColumn,
$checked
@ -247,7 +252,7 @@ foreach ($students as $studentId) {
}
}
$column = 0;
$table->setCellContents($row, $column, $name);
$table->setCellContents($row, $column, '<span class="text-bold font-extrabold text-lg">'.$name.'</span>');
$row++;
}
if ('edit' === $action) {

@ -2121,7 +2121,7 @@ class SurveyManager
/**
* 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 @@ class SurveyManager
$currentDate = new DateTime('now', $utcZone);
$currentDate->modify('today');
$returnMessage = false;
if ($currentDate < $startDate) {
api_not_allowed(
true,
Display:: return_message(
$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(
$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;
}
}
/**

Loading…
Cancel
Save