[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm lonviewclasslist.pm doc/loncapafiles loncapafiles.lpml

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 19 Jul 2004 17:57:25 -0000


This is a MIME encoded message

--matthew1090259845
Content-Type: text/plain

matthew		Mon Jul 19 13:57:25 2004 EDT

  Added files:                 
    /loncom/interface	lonviewclasslist.pm 

  Modified files:              
    /doc/loncapafiles	loncapafiles.lpml 
    /loncom/interface	lonparmset.pm 
  Log:
  Bug 3220: Student view of class roster.  Added lonviewclasslist.pm and modified
  lonparmset to provide the required course parameter.
  
  
--matthew1090259845
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20040719135725.txt"

Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.379 doc/loncapafiles/loncapafiles.lpml:1.380
--- doc/loncapafiles/loncapafiles.lpml:1.379	Thu Jul 15 17:36:47 2004
+++ doc/loncapafiles/loncapafiles.lpml	Mon Jul 19 13:57:24 2004
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.379 2004/07/15 21:36:47 albertel Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.380 2004/07/19 17:57:24 matthew Exp $ -->
 
 <!--
 
@@ -3488,6 +3488,15 @@
 <status>works/unverified</status>
 </file>
 <file>
+<source>loncom/interface/lonviewclasslist.pm</source>
+<target dist='default'>home/httpd/lib/perl/Apache/lonviewclasslist.pm</target>
+<categoryname>handler</categoryname>
+<description>
+Allows users (including students) to view the classlist of their course.
+</description>
+<status>works/unverified</status>
+</file>
+<file>
 <source>loncom/interface/lonmsg.pm</source>
 <target dist='default'>home/httpd/lib/perl/Apache/lonmsg.pm</target>
 <categoryname>handler</categoryname>
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.168 loncom/interface/lonparmset.pm:1.169
--- loncom/interface/lonparmset.pm:1.168	Thu Jul 15 15:42:24 2004
+++ loncom/interface/lonparmset.pm	Mon Jul 19 13:57:25 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.168 2004/07/15 19:42:24 matthew Exp $
+# $Id: lonparmset.pm,v 1.169 2004/07/19 17:57:25 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1553,6 +1553,7 @@
              'pageseparators'  => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'.
                                  '('.&mt('"[_1]" for visible separation','<tt>yes</tt>').', '.
                                  &mt('changes will not show until next login').')',
+             'student_classlist_view' => '<b>'.&mt('Allow students to view classlist.').'</b>'.&mt('("all":students can view all sections,"section":students can only view their own section.blank or "disabled" prevents student view.'),
 
              'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').
                                   '</b><br />"<tt>st</tt>": '.
@@ -1629,6 +1630,7 @@
         my @Display_Order = ('url','description','courseid','grading',
                              'default_xml_style','pageseparators',
                              'question.email','comment.email','policy.email',
+                             'student_classlist_view',
                              'plc.roles.denied','plc.users.denied',
                              'pch.roles.denied','pch.users.denied',
                              'allow_limited_html_in_feedback',

Index: loncom/interface/lonviewclasslist.pm
+++ loncom/interface/lonviewclasslist.pm
# The LearningOnline Network with CAPA
# Handler to display the classlist 
#
# $Id: lonviewclasslist.pm,v 1.1 2004/07/19 17:57:25 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
###############################################################
##############################################################

package Apache::lonviewclasslist;

use strict;
use Apache::loncoursedata();
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::Constants qw(:common :http REDIRECT);
use Apache::lonlocal;


###################################################################
###################################################################

=pod

=item &handler

The typical handler you see in all these modules.  Takes $r, the
http request, as an argument.  

=cut

###################################################################
###################################################################
sub handler {
    my $r=shift;
    if ($r->header_only) {
        &Apache::loncommon::content_type($r,'text/html');
        $r->send_http_header;
        return OK;
    }
#    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
#                                            ['action','state']);
    &Apache::lonhtmlcommon::clear_breadcrumbs();
    &Apache::lonhtmlcommon::add_breadcrumb
        ({href=>"/adm/viewclasslist",
          text=>"View Classlist",
          faq=>9,bug=>'Instructor Interface',});
    #  Needs to be in a course
    if (! ($ENV{'request.course.fn'})) {
        $ENV{'user.error.msg'}=
            "/adm/viewclasslist:not in course role";
        return HTTP_NOT_ACCEPTABLE; 
    }
    &Apache::loncommon::content_type($r,'text/html');
    $r->send_http_header;
    #
    my $bodytag=&Apache::loncommon::bodytag('Classlist');
    my $breadcrumbs=&Apache::lonhtmlcommon::breadcrumbs(undef,
                                                        'Enrollment Manager');

    $r->print(<<ENDHEADER);
<html>
<head>
<title>Classlist</title>
</head>
$bodytag
$breadcrumbs
ENDHEADER

    #
    # Print classlist
    my $cid = $ENV{'request.course.id'};
    my $viewpermission = 'course.'.$cid.'.student_classlist_view';
    if (&allowed_to_view_classlist()) {
        $r->print(&html_classlist());
    } else {
        $r->print('<h2>'.
                  &mt("You are not authorized to view the classlist for your course.").
                  '</h2>');
    }
    #
    # Finish up
    $r->print('</body></html>');
    return OK;
}

sub allowed_to_view_classlist {
    return 0 if (! exists($ENV{'request.course.id'}));
    my $cid = $ENV{'request.course.id'};
    my $viewpermission = 'course.'.$cid.'.student_classlist_view';
    if (exists($ENV{$viewpermission}) &&
        $ENV{$viewpermission} =~ /^(all|section)$/) {
        return $ENV{$viewpermission};
    } else {
        return 0;
    }

}

sub html_classlist {
    my $limit_to_section = (&allowed_to_view_classlist()=~ /^section$/i);
    my $Str;
    if ($limit_to_section) {
        if ($ENV{'request.course.sec'} eq '') {
            $Str .= '<h2>'.
                &mt('Students with no section').'</h2>';
        } else {
            $Str.='<h2>'.
                &mt('Students in section "[_1]"',
                    $ENV{'request.course.sec'}).
                    '</h2>';
        }
    }
    # 
    my $classlist = &Apache::loncoursedata::get_classlist();
    #
    # Set up a couple variables.
    my $usernameidx = &Apache::loncoursedata::CL_SNAME();
    my $domainidx   = &Apache::loncoursedata::CL_SDOM();
    my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME();
    my $sectionidx  = &Apache::loncoursedata::CL_SECTION();
    my $statusidx   = &Apache::loncoursedata::CL_STATUS();
    #
    # Sort the students
    my $sortby = $fullnameidx;
    my @Sorted_Students = sort {
        lc($classlist->{$a}->[$sortby])  cmp lc($classlist->{$b}->[$sortby])
        } (keys(%$classlist));
    $Str .= '<table>'.$/.
        '<tr>'.
        '<th></th>'. # for the count
        '<th>'.&mt('Student').'</th>'.
        '<th>'.&mt('Username').'</th>';
    if (! $limit_to_section) {
        $Str .= '<th>'.&mt('Section').'</th>';
    }
    $Str .='</tr>'.$/;
    my $count ++;
    foreach my $student (@Sorted_Students) {
        my $username = $classlist->{$student}->[$usernameidx];
        my $domain   = $classlist->{$student}->[$domainidx];
        my $fullname = $classlist->{$student}->[$fullnameidx];
        if ($fullname =~ /^\s*$/) {
            $fullname = &mt('Name not given');
        }
        my $section  = $classlist->{$student}->[$sectionidx];
        my $status   = $classlist->{$student}->[$statusidx];
#        next if (lc($status) ne 'active');
        if ($limit_to_section) {
            if ($section ne $ENV{'request.course.sec'}) {
                next;
            }
        }

        $Str .= '<tr>'.
            '<td>'.$count++.'</td>'.
            '<td>'.&Apache::loncommon::aboutmewrapper($fullname,
                                                      $username,
                                                      $domain).'</td>'.
            '<td>'.('&nbsp;'x2).
            &Apache::loncommon::messagewrapper
            ('<img src="/adm/lonIcons/mailto.gif" />&nbsp;'.
             $username.'@'.$domain,$username,$domain).'</td>';
        if (! $limit_to_section) {
            $Str .= '<td>'.$section.'</td>';
        }
        $Str .= '</tr>'.$/;
    }
    $Str .= '</table>';
    return $Str;
}

###################################################################
###################################################################

1;
__END__



--matthew1090259845--