--- loncom/interface/Attic/londropadd.pm 2002/04/15 23:37:37 1.24
+++ loncom/interface/Attic/londropadd.pm 2002/09/24 18:24:43 1.52
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.24 2002/04/15 23:37:37 albertel Exp $
+# $Id: londropadd.pm,v 1.52 2002/09/24 18:24:43 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -31,167 +31,223 @@
#
# (TeX Content Handler
#
-# YEAR=2000
-# 05/29/00,05/30,10/11 Gerd Kortemeyer)
-#
-# 10/11,10/12,10/16 Gerd Kortemeyer)
-#
-# 11/20,11/21,11/22,11/23,11/24,11/25,11/27,11/28,
-# 12/08,12/12 Gerd Kortemeyer)
-#
-# 12/26,12/27,12/28,
-# YEAR=2001
-# 01/01/01,01/15,02/10,02/13,02/14,02/22 Gerd Kortemeyer
-# 8/6 Scott Harrison
-# Guy Albertelli
-# 9/25 Gerd Kortemeyer
-# 12/19 Guy Albertelli
-# YEAR=2002
-# 1/4 Gerd Kortemeyer
+###############################################################
+###############################################################
package Apache::londropadd;
use strict;
use Apache::lonnet();
use Apache::loncommon();
+use Apache::lonhtmlcommon();
use Apache::Constants qw(:common :http REDIRECT);
-# ================================================================ Print header
-
+###############################################################
+###############################################################
sub header {
- my $r=shift;
- $r->print(<
-LON-CAPA Student Drop/Add
+LON-CAPA Enrollment Manager
-
-
-Drop/Add Students
-
+END
my $cid=$ENV{'request.course.id'};
- my $classlst=&Apache::lonnet::reply
- ('dump:'.$ENV{'course.'.$cid.'.domain'}.':'.
- $ENV{'course.'.$cid.'.num'}.':classlist',
- $ENV{'course.'.$cid.'.home'});
- my %currentlist=();
- my $now=time;
- unless ($classlst=~/^error\:/) {
- foreach (split(/\&/,$classlst)) {
- my ($name,$value)=split(/\=/,$_);
- my ($end,$start)=split(/\:/,
- &Apache::lonnet::unescape($value));
- my $active=1;
- if (($end) && ($now>$end)) { $active=0; }
- if ($active) {
- $currentlist{&Apache::lonnet::unescape($name)}=1;
- }
- }
-# ----------------------------------------------------------- Print out choices
- &show_drop_list($r,%currentlist);
- } else {
- $r->print(
- 'Could not access classlist: '.$classlst.
- '
');
- }
+ my ($student_array,$student_data)=&get_current_classlist($r);
+ if (! scalar(@$student_array)) {
+ $r->print("There are no students currently enrolled.\n");
+ } else {
+ # Print out the available choices
+ if ($ENV{'form.action'} eq 'modifystudent') {
+ &show_class_list($r,'view','modify','any',$student_array,$student_data);
+ } else {
+ &show_class_list($r,'view','aboutme','any',$student_array,$student_data);
+ }
+ }
+}
+
+# ============================================== view classlist
+sub print_csv_classlist {
+ my $r=shift;
+ my $cid=$ENV{'request.course.id'};
+ my ($student_array,$student_data)=&get_current_classlist($r);
+ if (! scalar(@$student_array)) {
+ $r->print("There are no students currently enrolled.\n");
+ } else {
+ &show_class_list($r,'csv','nolink','any',$student_array,$student_data);
+ }
}
# =================================================== Show student list to drop
+sub show_class_list {
+ my ($r,$mode,$linkto,$statusmode,$students,$student_data)=@_;
+ my $cid=$ENV{'request.course.id'};
+ # Print out header
+ if ($mode eq 'view') {
+ if ($linkto eq 'aboutme') {
+ $r->print('Select a user name to view the users page.');
+ } elsif ($linkto eq 'modify') {
+ $r->print('Select a user name to modify the students information');
+ }
+ $r->print(<
+
+username | domain | ID |
+ student name | section |
+END
+ } elsif ($mode eq 'csv') {
+ $r->print('"'.join('","',("username","domain","ID","student name",
+ "section")).'"'."\n");
+ }
+ foreach my $student (@$students) {
+ my $error;
+ if (exists($student_data->{$student.':error'})) {
+ $error = $student_data->{$student.':error'};
+ }
+ if ($error) {
+ $r->print(''.
+ 'Error'.
+ 'Error retrieving data for '.
+ join('@',split(/:/,$student)).
+ ', '.$error.' |
'."\n");
+ next;
+ }
+ my $username = $student_data->{$student.':username'};
+ my $domain = $student_data->{$student.':domain'};
+ my $section = $student_data->{$student.':section'};
+ my $name = $student_data->{$student.':fullname'};
+ my $status = $student_data->{$student.':Status'};
+ my $id = $student_data->{$student.':id'};
+ next if (($statusmode ne 'any') && ($status ne $statusmode));
+ if ($mode eq 'view') {
+ $r->print("\n \n ");
+ if ($linkto eq 'nothing') {
+ $r->print($username);
+ } elsif ($linkto eq 'aboutme') {
+ $r->print(&Apache::loncommon::aboutmewrapper($username,
+ $username,
+ $domain));
+ } elsif ($linkto eq 'modify') {
+ $r->print(''.$username."\n");
+ }
+ $r->print(<<"END");
+ |
+ $domain |
+ $id |
+ $name |
+ $section |
+
+END
+ } elsif ($mode eq 'csv') {
+ # no need to bother with $linkto
+ my @line = ();
+ foreach ($username,$domain,$id,$name,$section) {
+ push @line,&Apache::loncommon::csv_translate($_);
+ }
+ my $tmp = $";
+ $" = '","';
+ $r->print("\"@line\"\n");
+ $" = $tmp;
+ }
+ }
+ $r->print('
') if ($mode eq 'view');
+}
+
+#
+# print out form for modification of a single students data
+#
+sub print_modify_student_form {
+ my $r = shift();
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['sdom','sname']);
+
+ my $sname = $ENV{'form.sname'};
+ my $sdom = $ENV{'form.sdom'};
+ # determine the students name information
+ my %info=&Apache::lonnet::get('environment',
+ ['firstname','middlename',
+ 'lastname','generation','id'],
+ $sdom, $sname);
+ my ($tmp) = keys(%info);
+ if ($tmp =~ /^(con_lost|error|no_such_host)/i) {
+ $r->print('Error'.
+ ''.
+ 'Unable to retrieve environment data for '.$sname.
+ 'in domain '.$sdom.'
'.
+ 'Please contact your LON-CAPA administrator '.
+ 'regarding this situation.