Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite student_search_table query #153

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions classes/output/student_search_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,28 +513,41 @@ public function query_db($pagesize, $useinitialsbar = false) {
}

$sql = "SELECT u.*,
COALESCE(qo.timeopen, $quizobj->timestampopen) AS timeopen,
COALESCE(qo.timeclose, $quizobj->timestampclose) AS timeclose,
COALESCE(qo.timelimit, $quizobj->timestamplimit) AS timelimit,
COALESCE(qa.state, (CASE
WHEN us.userid > 0 THEN 'loggedin'
ELSE 'notloggedin'
END)) AS state,
qo.timeopen AS timeopen,
qo.timeclose AS timeclose,
qo.timelimit AS timelimit,
COALESCE(
qa.state,
(
CASE
WHEN us.userid > 0 THEN 'loggedin'
ELSE 'notloggedin'
END
)
) AS state,
qa.attemptid,
qa.timestart,
qa.timefinish,
$quizobj->assessid AS quiz,
$context->instanceid as quizinstance,
$quizobj->timestampopen AS quiztimeopen,
$quizobj->timestampclose AS quiztimeclose,
$quizobj->timestamplimit AS quiztimelimit,
'$quizobj->name' AS quizname
qa.timefinish
FROM {user} u
$finaljoin->joins
WHERE $finaljoin->wheres";

$records = $DB->get_records_sql($sql, $params);
$allrecords = array_merge($allrecords, $records);
$records = $DB->get_records_sql($sql, $params);
$quizdata = [
'quiz' => $quizobj->assessid,
'quizinstance' => $context->instanceid,
'quiztimeopen' => $quizobj->timestampopen,
'quiztimeclose' => $quizobj->timestampclose,
'quiztimelimit' => $quizobj->timestamplimit,
'quizname' => $quizobj->name,
];
foreach ($records as &$record) {
$record->timeopen = $record->timeopen ?? $quizobj->timestampopen;
$record->timeclose = $record->timeclose ?? $quizobj->timestampclose;
$record->timelimit = $record->timelimit ?? $quizobj->timestampopen;
$record = (object)array_merge((array)$record, $quizdata);
}
$allrecords = array_merge($allrecords, $records);
}

if (!empty($this->get_sql_sort())) {
Expand Down
1 change: 1 addition & 0 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
$plugin->release = '2021101500';
$plugin->version = 2021101500;
$plugin->requires = 2018051712;
$plugin->supported = [311, 311];
$plugin->maturity = MATURITY_BETA;
Loading