| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader$ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/ScoringDownload.pm,v 1.2 2003/12/09 01:12:31 sh002i Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 27 | use warnings; |
27 | use warnings; |
| 28 | use Apache::Constants qw(:common); |
28 | use Apache::Constants qw(:common); |
| 29 | |
29 | |
| 30 | sub header { |
30 | sub header { |
| 31 | my ($self) = @_; |
31 | my ($self) = @_; |
| 32 | my $r = $self->{r}; |
32 | my $r = $self->r; |
| 33 | my $ce = $self->{ce}; |
33 | my $ce = $r->ce; |
| 34 | my $scoringDir = $ce->{courseDirs}->{scoring}; |
34 | my $scoringDir = $ce->{courseDirs}->{scoring}; |
| 35 | my $file = $r->param('getFile'); |
35 | my $file = $r->param('getFile'); |
| 36 | if (-f "$scoringDir/$file") { |
36 | if (-f "$scoringDir/$file") { |
| 37 | $r->content_type('text/comma-separated-values'); |
37 | $r->content_type('text/comma-separated-values'); |
| 38 | $r->header_out("Content-Disposition" => "attachment; filename=$file;"); |
38 | $r->header_out("Content-Disposition" => "attachment; filename=$file;"); |
| … | |
… | |
| 43 | return NOT_FOUND; |
43 | return NOT_FOUND; |
| 44 | } |
44 | } |
| 45 | } |
45 | } |
| 46 | |
46 | |
| 47 | sub content { |
47 | sub content { |
| 48 | my ($self) = @_; |
48 | my ($self) = @_; |
| 49 | my $r = $self->{r}; |
49 | my $r = $self->r; |
| 50 | my $ce = $self->{ce}; |
50 | my $ce = $r->ce; |
| 51 | my $authz = $self->{authz}; |
51 | my $authz = $r->authz; |
| 52 | my $scoringDir = $ce->{courseDirs}->{scoring}; |
52 | my $scoringDir = $ce->{courseDirs}->{scoring}; |
| 53 | my $user = $r->param('user'); |
53 | my $user = $r->param('user'); |
| 54 | |
54 | |
| 55 | if (!$authz->hasPermissions($user, "score_sets")) { |
55 | if (!$authz->hasPermissions($user, "score_sets")) { |
| 56 | print "You do not have permission to access scoring data"; |
56 | print "You do not have permission to access scoring data"; |
| 57 | } else { |
57 | } else { |
| 58 | my $file = $r->param('getFile'); |
58 | my $file = $r->param('getFile'); |