From: Sam H. v. a. <we...@ma...> - 2005-10-11 20:46:39
|
Log Message: ----------- don't show "act as" link unless the user is actually allowed to. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator/Instructor: Stats.pm StudentProgress.pm Revision Data ------------- Index: Stats.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Instructor/Stats.pm,v retrieving revision 1.59 retrieving revision 1.60 diff -Llib/WeBWorK/ContentGenerator/Instructor/Stats.pm -Llib/WeBWorK/ContentGenerator/Instructor/Stats.pm -u -r1.59 -r1.60 --- lib/WeBWorK/ContentGenerator/Instructor/Stats.pm +++ lib/WeBWorK/ContentGenerator/Instructor/Stats.pm @@ -137,43 +137,35 @@ unless $authz->hasPermissions($user, "access_instructor_tools"); if ($type eq 'student') { - my $studentName = $self->{studentName}; + my $studentName = $self->{studentName}; + my $studentRecord = $db->getUser($studentName) # checked + or die "record for user $studentName not found"; + my $fullName = $studentRecord->full_name; + my $courseHomePage = $urlpath->new(type => 'set_list', + args => {courseID=>$courseName}); + my $email = $studentRecord->email_address; - my $studentRecord = $db->getUser($studentName); # checked - die "record for user $studentName not found" unless $studentRecord; - - my $fullName = join("", $studentRecord->first_name," ", $studentRecord->last_name); - - my $courseHomePage = $urlpath->new(type => 'set_list', - args => {courseID => $courseName} - ); - my $act_as_student_url = $self->systemLink($courseHomePage, - params => { effectiveUser => $studentName } - ); - - my $email = $studentRecord->email_address; - print - CGI::a({-href=>"mailto:$email"},$email),CGI::br(), + print CGI::a({-href=>"mailto:$email"}, $email), CGI::br(), "Section: ", $studentRecord->section, CGI::br(), - "Recitation: ", $studentRecord->recitation,CGI::br(), - 'Act as: ', - CGI::a({-href=>$act_as_student_url},$studentRecord->user_id); - WeBWorK::ContentGenerator::Grades::displayStudentStats($self,$studentName); + "Recitation: ", $studentRecord->recitation, CGI::br(); - # The table format has been borrowed from the Grades.pm module + if ($authz->hasPermissions($user, "become_student")) { + my $act_as_student_url = $self->systemLink($courseHomePage, + params => {effectiveUser=>$studentName}); + + print 'Act as: ', CGI::a({-href=>$act_as_student_url},$studentRecord->user_id); + } + + print WeBWorK::ContentGenerator::Grades::displayStudentStats($self,$studentName); } elsif( $type eq 'set') { - my $setName = $self->{setName}; $self->displaySets($self->{setName}); } elsif ($type eq '') { $self->index; } else { warn "Don't recognize statistics display type: |$type|"; - } - return ''; - } sub index { my $self = shift; Index: StudentProgress.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -Llib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm -Llib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm -u -r1.21 -r1.22 --- lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm +++ lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm @@ -136,32 +136,27 @@ unless $authz->hasPermissions($user, "access_instructor_tools"); if ($type eq 'student') { - my $studentName = $self->{studentName}; + my $studentName = $self->{studentName}; + my $studentRecord = $db->getUser($studentName) # checked + or die "record for user $studentName not found"; + my $fullName = $studentRecord->full_name; + my $courseHomePage = $urlpath->new(type => 'set_list', + args => {courseID=>$courseName}); + my $email = $studentRecord->email_address; - my $studentRecord = $db->getUser($studentName); # checked - die "record for user $studentName not found" unless $studentRecord; - - my $fullName = join("", $studentRecord->first_name," ", $studentRecord->last_name); - - my $courseHomePage = $urlpath->new(type => 'set_list', - args => {courseID => $courseName} - ); - my $act_as_student_url = $self->systemLink($courseHomePage, - params => { effectiveUser => $studentName } - ); - - my $email = $studentRecord->email_address; - print - CGI::a({-href=>"mailto:$email"},$email),CGI::br(), + print CGI::a({-href=>"mailto:$email"}, $email), CGI::br(), "Section: ", $studentRecord->section, CGI::br(), - "Recitation: ", $studentRecord->recitation,CGI::br(), - 'Act as: ', - CGI::a({-href=>$act_as_student_url},$studentRecord->user_id); - WeBWorK::ContentGenerator::Grades::displayStudentStats($self,$studentName); + "Recitation: ", $studentRecord->recitation, CGI::br(); + + if ($authz->hasPermissions($user, "become_student")) { + my $act_as_student_url = $self->systemLink($courseHomePage, + params => {effectiveUser=>$studentName}); + + print 'Act as: ', CGI::a({-href=>$act_as_student_url},$studentRecord->user_id); + } - # The table format has been borrowed from the Grades.pm module + print WeBWorK::ContentGenerator::Grades::displayStudentStats($self,$studentName); } elsif( $type eq 'set') { - my $setName = $self->{setName}; $self->displaySets($self->{setName}); } elsif ($type eq '') { |