Skip to content

Commit e457b0e

Browse files
Survey: Allow tutors to access doodle past end date and cosmetic changes - BT#21622
1 parent 764d93a commit e457b0e

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

public/main/survey/meeting.php

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050
}
5151

5252
$surveyId = $survey->getIid();
53-
54-
SurveyManager::checkTimeAvailability($survey);
5553
$invitations = SurveyUtil::get_invited_users($survey);
5654
$students = $invitations['course_users'] ?? [];
5755

@@ -65,6 +63,10 @@
6563
$url = api_get_self().'?survey_id='.$surveyId.'&invitationcode='.$invitationcode.'&'.api_get_cidreq();
6664
$urlEdit = $url.'&action=edit';
6765

66+
if (!api_is_allowed_to_edit()) {
67+
SurveyManager::checkTimeAvailability($survey);
68+
}
69+
6870
$questions = $survey->getQuestions();
6971

7072
if (isset($_POST) && !empty($_POST)) {
@@ -110,10 +112,13 @@
110112

111113
$template = new Template();
112114

113-
$table = new HTML_Table(['class' => 'table']);
115+
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table mt-5']);
114116
$row = 0;
115-
$column = 1;
117+
$column = 0;
116118
$answerList = [];
119+
120+
$table->setHeaderContents($row, $column, "");
121+
$column++;
117122
foreach ($questions as $item) {
118123
$questionId = $item->getIid();
119124
$answers = SurveyUtil::get_answers_of_question_by_user($surveyId, $questionId);
@@ -142,18 +147,18 @@
142147
}
143148

144149
$mainDate = api_format_date($mainDate, DATE_FORMAT_SHORT);
145-
$table->setHeaderContents($row, $column, "<h4>$mainDate</h4> $startTime <br >$endTime");
150+
$table->setHeaderContents($row, $column, "<h4>$mainDate</h4> <span class='text-lg'>$startTime <br >$endTime</span>");
146151
$column++;
147152
}
148153

149-
$row = 1;
154+
$row = 0;
150155
$column = 0;
151156

152157
// Total counter
153-
$table->setHeaderContents(
158+
$table->setCellContents(
154159
$row,
155160
0,
156-
get_lang('Number of users').': '.count($students)
161+
'<span class="text-bold font-extrabold text-xl">'.get_lang('Number of users').': '.count($students).'</span>'
157162
);
158163

159164
foreach ($questions as $item) {
@@ -166,8 +171,8 @@
166171
$questionsWithAnswer++;
167172
}
168173
}
169-
$count = '<p style="color:cornflowerblue" >
170-
<span class="fa fa-check fa-2x"></span>'.$questionsWithAnswer.'</p>';
174+
$count = '<p class="text-info text-center p-2 text-bold font-extrabold text-2xl">
175+
<span class="mdi mdi-check text-3xl"></span>'.$questionsWithAnswer.'</p>';
171176
}
172177
$table->setCellContents(
173178
$row,
@@ -176,7 +181,7 @@
176181
);
177182
}
178183

179-
$row = 2;
184+
$row = 1;
180185
$column = 0;
181186
$availableIcon = Display::getMdiIcon(StateIcon::ACTIVE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Available'));
182187
$notAvailableIcon = Display::getMdiIcon(StateIcon::INACTIVE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Not available'));
@@ -210,7 +215,7 @@
210215
}
211216

212217
if ('edit' === $action) {
213-
$html = '<div class="alert alert-info"><input
218+
$html = '<div class="alert alert-info text-center"><input
214219
id="'.$questionId.'"
215220
name="options['.$questionId.']"
216221
class="question" '.$checked.'
@@ -220,7 +225,7 @@ class="question" '.$checked.'
220225
$html = $checked;
221226
}
222227

223-
$table->setHeaderContents(
228+
$table->setCellContents(
224229
$row,
225230
$rowColumn,
226231
$html
@@ -238,7 +243,7 @@ class="question" '.$checked.'
238243
$checked = $notAvailableIcon;
239244
}
240245
}
241-
$table->setHeaderContents(
246+
$table->setCellContents(
242247
$row,
243248
$rowColumn,
244249
$checked
@@ -247,7 +252,7 @@ class="question" '.$checked.'
247252
}
248253
}
249254
$column = 0;
250-
$table->setCellContents($row, $column, $name);
255+
$table->setCellContents($row, $column, '<span class="text-bold font-extrabold text-lg">'.$name.'</span>');
251256
$row++;
252257
}
253258
if ('edit' === $action) {

public/main/survey/survey.lib.php

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ public static function getCountPages(CSurvey $survey)
21212121
/**
21222122
* Check whether this survey has ended. If so, display message and exit this script.
21232123
*/
2124-
public static function checkTimeAvailability(?CSurvey $survey)
2124+
public static function checkTimeAvailability(?CSurvey $survey): void
21252125
{
21262126
if (null === $survey) {
21272127
api_not_allowed(true);
@@ -2133,27 +2133,32 @@ public static function checkTimeAvailability(?CSurvey $survey)
21332133
$currentDate = new DateTime('now', $utcZone);
21342134
$currentDate->modify('today');
21352135

2136+
$returnMessage = false;
21362137
if ($currentDate < $startDate) {
2137-
api_not_allowed(
2138-
true,
2139-
Display:: return_message(
2140-
get_lang('This survey is not yet available. Please try again later. Thank you.'),
2141-
'warning',
2142-
false
2143-
)
2138+
$returnMessage = Display:: return_message(
2139+
get_lang('This survey is not yet available. Please try again later. Thank you.'),
2140+
'warning',
2141+
false
21442142
);
21452143
}
21462144

21472145
if ($currentDate > $endDate) {
2148-
api_not_allowed(
2149-
true,
2150-
Display:: return_message(
2151-
get_lang('Sorry, this survey is not available anymore. Thank you for trying.'),
2152-
'warning',
2153-
false
2154-
)
2146+
$returnMessage = Display:: return_message(
2147+
get_lang('Sorry, this survey is not available anymore. Thank you for trying.'),
2148+
'warning',
2149+
false
21552150
);
21562151
}
2152+
2153+
if (false !== $returnMessage) {
2154+
$content = Display::page_header($survey->getTitle());
2155+
$content .= $returnMessage;
2156+
$template = new Template();
2157+
$template->assign('actions', Display::toolbarAction('toolbar', []));
2158+
$template->assign('content', $content);
2159+
$template->display_one_col_template();
2160+
exit;
2161+
}
21572162
}
21582163

21592164
/**

0 commit comments

Comments
 (0)