Skip to content

Commit

Permalink
Fixed none working filtering in Test Participants with or without Ans…
Browse files Browse the repository at this point in the history
…wers
  • Loading branch information
matheuszych committed May 10, 2024
1 parent 64f2bb5 commit 31e04f7
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions Modules/Test/classes/class.ilTestParticipantsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,43 +244,31 @@ public function showCmd(): void

protected function applyFilterCriteria(array $in_rows): array
{
$selected_pax = ilSession::get('form_tst_participants_' . $this->getTestObj()->getRefId());
$selected_pax = ilSession::get('form_tst_participants_' . $this->getTestObj()->getRefId() . '_selection');

if ($selected_pax === null || !isset($selected_pax['selection'])) {
if ($selected_pax === null) {
return $in_rows;
}

$sess_filter = $selected_pax['selection'];
$sess_filter = str_replace('"', '', $sess_filter);
$sess_filter = explode(':', $sess_filter);
$filter = substr($sess_filter[2], 0, strlen($sess_filter[2]) - 1);
$filter = unserialize($selected_pax, ['allowed_classes' => false]);

if ($filter == 'all' || $filter == false) {
return $in_rows; #unchanged - no filter.
if (!is_string($filter) || $filter === 'all') {
return $in_rows;
}

$with_result = array();
$without_result = array();
$with_result = [];
$without_result = [];
foreach ($in_rows as $row) {
$result = $this->db->query(
'SELECT count(solution_id) count
FROM tst_solutions
WHERE active_fi = ' . $this->db->quote($row['active_id'])
);
$count = $this->db->fetchAssoc($result);
$count = $count['count'];

if ($count == 0) {
$without_result[] = $row;
} else {
$with_result[] = $row;
}
$this->db->fetchAssoc($result)['count'] === 0 ? $without_result[] = $row : $with_result[] = $row;
}

if ($filter == 'withSolutions') {
return $with_result;
}
return $without_result;
return $filter === 'withSolutions' ? $with_result : $without_result;
}

protected function initToolbarControls(ilTestParticipantList $participant_list): void
Expand Down

0 comments on commit 31e04f7

Please sign in to comment.