| 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: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/Stats.pm,v 1.41 2004/05/10 03:22:44 gage Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/Stats.pm,v 1.42 2004/06/02 14:54:26 gage 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. |
| … | |
… | |
| 42 | my $ce = $self->{ce}; |
42 | my $ce = $self->{ce}; |
| 43 | my $authz = $self->{authz}; |
43 | my $authz = $self->{authz}; |
| 44 | my $courseName = $urlpath->arg('courseID'); |
44 | my $courseName = $urlpath->arg('courseID'); |
| 45 | my $user = $r->param('user'); |
45 | my $user = $r->param('user'); |
| 46 | |
46 | |
|
|
47 | # Check permissions |
|
|
48 | return unless $authz->hasPermissions($user, "access_instructor_tools"); |
| 47 | |
49 | |
| 48 | $self->{type} = $type; |
50 | $self->{type} = $type; |
| 49 | if ($type eq 'student') { |
51 | if ($type eq 'student') { |
| 50 | my $studentName = $r->urlpath->arg("userID") || $user; |
52 | my $studentName = $r->urlpath->arg("userID") || $user; |
| 51 | $self->{studentName } = $studentName; |
53 | $self->{studentName } = $studentName; |
| … | |
… | |
| 63 | } |
65 | } |
| 64 | |
66 | |
| 65 | |
67 | |
| 66 | sub title { |
68 | sub title { |
| 67 | my ($self) = @_; |
69 | my ($self) = @_; |
|
|
70 | my $r = $self->r; |
|
|
71 | my $authz = $r->authz; |
|
|
72 | my $user = $r->param('user'); |
|
|
73 | |
|
|
74 | return "" unless $authz->hasPermissions($user, "access_instructor_tools"); |
|
|
75 | |
| 68 | my $type = $self->{type}; |
76 | my $type = $self->{type}; |
| 69 | my $string = "Statistics for ".$self->{ce}->{courseName}." "; |
77 | my $string = "Statistics for ".$self->{ce}->{courseName}." "; |
|
|
78 | |
| 70 | if ($type eq 'student') { |
79 | if ($type eq 'student') { |
| 71 | $string .= "student ".$self->{studentName}; |
80 | $string .= "student ".$self->{studentName}; |
| 72 | } elsif ($type eq 'set' ) { |
81 | } elsif ($type eq 'set' ) { |
| 73 | $string .= "set ".$self->{setName}; |
82 | $string .= "set ".$self->{setName}; |
| 74 | $string .= ". Due ". WeBWorK::Utils::formatDateTime($self->{set_due_date}); |
83 | $string .= ". Due ". WeBWorK::Utils::formatDateTime($self->{set_due_date}); |
| … | |
… | |
| 77 | } |
86 | } |
| 78 | sub siblings { |
87 | sub siblings { |
| 79 | my ($self) = @_; |
88 | my ($self) = @_; |
| 80 | my $r = $self->r; |
89 | my $r = $self->r; |
| 81 | my $db = $r->db; |
90 | my $db = $r->db; |
|
|
91 | my $authz = $r->authz; |
|
|
92 | my $user = $r->param('user'); |
| 82 | my $urlpath = $r->urlpath; |
93 | my $urlpath = $r->urlpath; |
| 83 | |
94 | |
|
|
95 | # Check permissions |
|
|
96 | return "" unless $authz->hasPermissions($user, "access_instructor_tools"); |
| 84 | |
97 | |
| 85 | my $courseID = $urlpath->arg("courseID"); |
98 | my $courseID = $urlpath->arg("courseID"); |
| 86 | my $eUserID = $r->param("effectiveUser"); |
99 | my $eUserID = $r->param("effectiveUser"); |
| 87 | my @setIDs = sort $db->listGlobalSets; |
100 | my @setIDs = sort $db->listGlobalSets; |
| 88 | |
101 | |
| … | |
… | |
| 110 | my $self = shift; |
123 | my $self = shift; |
| 111 | my $r = $self->r; |
124 | my $r = $self->r; |
| 112 | my $urlpath = $r->urlpath; |
125 | my $urlpath = $r->urlpath; |
| 113 | my $db = $r->db; |
126 | my $db = $r->db; |
| 114 | my $ce = $r->ce; |
127 | my $ce = $r->ce; |
|
|
128 | my $authz = $r->authz; |
| 115 | my $courseName = $urlpath->arg("courseID"); |
129 | my $courseName = $urlpath->arg("courseID"); |
|
|
130 | my $user = $r->param('user'); |
| 116 | my $type = $self->{type}; |
131 | my $type = $self->{type}; |
|
|
132 | |
|
|
133 | # Check permissions |
|
|
134 | return CGI::div({class=>"ResultsWithError"}, CGI::p("You are not authorized to access instructor tools")) |
|
|
135 | unless $authz->hasPermissions($user, "access_instructor_tools"); |
| 117 | |
136 | |
| 118 | if ($type eq 'student') { |
137 | if ($type eq 'student') { |
| 119 | my $studentName = $self->{studentName}; |
138 | my $studentName = $self->{studentName}; |
| 120 | |
139 | |
| 121 | my $studentRecord = $db->getUser($studentName); # checked |
140 | my $studentRecord = $db->getUser($studentName); # checked |