Skip to content

Commit

Permalink
Handle terms with missing attendences correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Dec 29, 2015
1 parent 4e4062c commit f11e760
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Kinza/lib/Kinza/Reports.pm
Expand Up @@ -27,7 +27,7 @@ get '/form' => sub {
header 'Content-Disposition' => 'attachment; filename="form.csv"';

my $csv;
my $terms = join ',', map { $_->name } $rs{Term}->all;
my $terms = join ',', map { $_->name } $rs{Term}->search({}, { order_by => 'seq' })->all;

foreach my $y (schema->resultset('Year')->search({}, {
order_by => 'id',
Expand All @@ -40,9 +40,12 @@ get '/form' => sub {

foreach my $s ($f->students->search({}, { order_by => 'name' })) {
$csv .= $s->name;
my $term_seq = 1;
foreach my $a ($s->sorted_attendances) {
for (1 .. $a->presentation->number_of_terms) {
if ($a->presentation->term->seq == $term_seq++) {
$csv .= ',"' . $a->presentation->course->title . '"';
} else {
$csv .= ',';
}
}
$csv .= "\n";
Expand Down

0 comments on commit f11e760

Please sign in to comment.