<table>
	<thead>
	<tr>
		<th><?= t('ID'); ?></th>
		<th><?= t('Nazwa użytkownika'); ?></th>
		<th><?= t('Data początkowa'); ?></th>
		<th><?= t('Data końcowa'); ?></th>
		<th><?= t('Punkty'); ?></th>
		<th><?= t('Oceniony'); ?></th>
		<?php for ($ma = 0; $ma < $max_answers; $ma++):?>
			<th><?= t('Treść pytania'); ?></th>
			<th><?= t('Odpowiedź użytkownika'); ?></th>
			<th><?= t('Poprawna odpowiedź'); ?></th>
		<?php endfor; ?>
	</tr>
	</thead>
	<tbody>
	<?php $i = 0;
	foreach ($quiz_export as $quiz): ?>
		<tr>
			<td><?= $i ?></td>
			<td><?= $quiz['user_name'] ?></td>
			<td><?= $quiz['start_date'] ?></td>
			<?php if (isset($quiz['end_date'])): ?>
			<td><?= $quiz['end_date'] ?></td><?php else: ?><td>X</td><?php endif; ?>
			<td><?= $quiz['score'] ?></td>
			<td><?= $quiz['is_evaluated'] ?></td>
			<?php $a = count($quiz['answer']); ?>

			<?php foreach ($quiz['answer'] as $answer):?>
				<td><?= trim(preg_replace('/\s\s+/', ' ', $answer['question'])); ?></td>
				<?php if (!empty($answer['user_answers'][0]['answer'])): ?>
				<td><?= $answer['user_answers'][0]['answer'] ?></td>
				<?php else: ?>
					<td>X</td>
				<?php endif; ?>
				<?php if (isset($answer['correct_answer'])): ?>
				<td><?= $answer['correct_answer'] ?></td>
				<?php else: ?>
					<td>X</td>
				<?php endif; ?>	
			<?php endforeach; ?>

			<?php if ($a < $max_answers): ?>
				<?php for ($a; $a < $max_answers; $a++): ?>
					<td>X</td>
					<td>X</td>
					<td>X</td>
				<?php endfor; ?>	
			<?php endif; ?>

		</tr>
	<?php $i++;
	endforeach; ?>
	</tbody>
</table>
