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

Split exams and summaries on course page #1722

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
20 changes: 15 additions & 5 deletions module/Application/language/en.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions module/Application/language/gewisweb.pot

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 18 additions & 7 deletions module/Application/language/nl.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion module/Education/src/Model/Course.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OrderBy;
use Laminas\Permissions\Acl\Resource\ResourceInterface;

/**
Expand All @@ -33,13 +34,14 @@ class Course implements ResourceInterface

/**
* Exams (and summaries) in this course.
*
* Ordered by date, from old to recent since documents are not necessarily uploaded in chronological order
* @var Collection<array-key, CourseDocument>
*/
#[OneToMany(
targetEntity: CourseDocument::class,
mappedBy: 'course',
)]
#[OrderBy(value: ['date' => 'ASC'])]
BHenkemans marked this conversation as resolved.
Show resolved Hide resolved
protected Collection $documents;

public function __construct()
Expand Down
84 changes: 59 additions & 25 deletions module/Education/view/education/education/course.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ $this->headTitle(sprintf(
$this->escapeHtml($course->getName()),
));
$this->headTitle($this->translate('Education'));
$documents = $course->getDocuments();
$exams = [];
$summaries = [];

foreach ($documents as $document) {
if ($document instanceof SummaryModel) {
$summaries[] = $document;
} else {
$exams[] = $document;
}
}

?>
<section class="section">
<div class="container">
Expand All @@ -29,37 +41,59 @@ $this->headTitle($this->translate('Education'));
</div>
<hr>
<div class="row">
<div class="col-md-8">
<h2><?= $this->translate('Exams and summaries') ?></h2>
<ul>
<?php foreach ($course->getDocuments() as $document): ?>
<li>
<a href="<?= $this->url('education/course/download', [
'code' => $course->getCode(),
'id' => $document->getId()
]) ?>">
<?php if ($document instanceof SummaryModel): ?>
<?php if (null !== ($author = $document->getauthor())): ?>
<div class="col-md-6">
<h2><?= $this->translate('Summaries') ?></h2>
<?php if (count($summaries) === 0): ?>
<p><?= $this->translate(
// phpcs:ignore Generic.Files.LineLength.TooLong -- user-visible strings should not be split
'There are currently no summaries available. Consider submitting one yourself by sending an email to'
) ?> <a href="mailto:[email protected]">[email protected]</a>!</p>
<?php else: ?>
<ul>
<?php foreach ($summaries as $summary): ?>
<li>
<a href="<?= $this->url('education/course/download', [
'code' => $course->getCode(),
'id' => $summary->getId()
]) ?>">
<?php if (null !== ($author = $summary->getauthor())): ?>
<?= sprintf(
$this->translate('Summary by %s on %s (%s)'),
$this->escapeHtml($document->getAuthor()),
$document->getDate()->format('Y-m-d'),
$document->getLanguage()->getName(
$this->escapeHtml($summary->getAuthor()),
$summary->getDate()->format('Y-m-d'),
$summary->getLanguage()->getName(
$this->plugin('translate')->getTranslator()
),
) ?>
<?php else: ?>
<?= sprintf(
$this->translate('Summary on %s (%s)'),
$document->getDate()->format('Y-m-d'),
$document->getLanguage()->getName(
$summary->getDate()->format('Y-m-d'),
$summary->getLanguage()->getName(
$this->plugin('translate')->getTranslator()
),
) ?>
<?php endif; ?>
<?php else: ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
<div class="col-md-6">
<h2><?= $this->translate('Exams &amp; Solutions') ?></h2>
<?php if (count($exams) === 0):?>
<p><?= $this->translate('There are currently no exams or solutions available.') ?></p>
<?php else: ?>
<ul>
<?php foreach ($exams as $exam): ?>
<li>
<a href="<?= $this->url('education/course/download', [
'code' => $course->getCode(),
'id' => $exam->getId()
]) ?>">
<?php
switch ($document->getExamType()) {
switch ($exam->getExamType()) {
case ExamTypes::Final:
$name = $this->translate('Final test from %s (%s)');
break;
Expand All @@ -77,17 +111,17 @@ $this->headTitle($this->translate('Education'));
<?= $this->escapeHtml(
sprintf(
$name,
$document->getDate()->format('Y-m-d'),
$document->getLanguage()->getName(
$exam->getDate()->format('Y-m-d'),
$exam->getLanguage()->getName(
$this->plugin('translate')->getTranslator()
),
)
) ?>
<?php endif ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
</div>
Expand Down
Loading