--- loncom/interface/Attic/londropadd.pm 2002/05/09 15:56:02 1.42
+++ loncom/interface/Attic/londropadd.pm 2002/09/25 16:16:19 1.53
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.42 2002/05/09 15:56:02 matthew Exp $
+# $Id: londropadd.pm,v 1.53 2002/09/25 16:16:19 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -31,49 +31,35 @@
#
# (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 $bodytag=&Apache::loncommon::bodytag('Enrollment Manager');
return(<
-
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}
-Enrollment Manager
+$bodytag
+ + Enroll a single student + +
+ + Modify student data + +
+ + View Classlist + +
+ + Drop Students + +
+END } -sub phase_two_header { +############################################################### +############################################################### +sub print_upload_manager_header { my ($r,$datatoken,$distotal,$krbdefdom)=@_; my $javascript; + if (! exists($ENV{'form.upfile_associate'})) { + $ENV{'form.upfile_associate'} = 'forward'; + } + if ($ENV{'form.associate'} eq 'Reverse Association') { + if ( $ENV{'form.upfile_associate'} ne 'reverse' ) { + $ENV{'form.upfile_associate'} = 'reverse'; + } else { + $ENV{'form.upfile_associate'} = 'forward'; + } + } if ($ENV{'form.upfile_associate'} eq 'reverse') { - $javascript=&phase_two_javascript_reverse_associate(); + $javascript=&upload_manager_javascript_reverse_associate(); } else { - $javascript=&phase_two_javascript_forward_associate(); + $javascript=&upload_manager_javascript_forward_associate(); } my $javascript_validations=&javascript_validations($krbdefdom); $r->print(<Disable ID/Student Number Safeguard and Force Change of Conflicting IDs (only do if you know what you are doing)
-Note: for large courses, this operation might be time consuming.
+Note: for large courses, this operation may be time consuming.
ENDPICK
}
# ======================================================= Menu Phase Two Upload
-sub menu_phase_two_upload {
+sub print_upload_manager_form {
my $r=shift;
my $datatoken;
@@ -488,14 +526,18 @@ sub menu_phase_two_upload {
my $today=time;
my $halfyear=$today+15552000;
my $defdom=$r->dir_config('lonDefDomain');
- &phase_two_header($r,$datatoken,$distotal,$krbdefdom);
+ &print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom);
my $i;
my $keyfields;
if ($total>=0) {
- my @d=(['username','Username'],['names','Last Name, First Names'],
- ['fname','First Name'],['mname','Middle Names/Initials'],
- ['lname','Last Name'],['gen','Generation'],
- ['id','ID/Student Number'],['sec','Group/Section'],
+ my @d=(['username','Username'],
+ ['names','Last Name, First Names'],
+ ['fname','First Name'],
+ ['mname','Middle Names/Initials'],
+ ['lname','Last Name'],
+ ['gen','Generation'],
+ ['id','ID/Student Number'],
+ ['sec','Group/Section'],
['ipwd','Initial Password']);
if ($ENV{'form.upfile_associate'} eq 'reverse') {
&Apache::loncommon::csv_print_samples($r,\@records);
@@ -509,7 +551,7 @@ sub menu_phase_two_upload {
$keyfields=join(',',sort(keys(%sone)));
}
}
- &phase_two_end($r,$i,$keyfields,$defdom,$today,$halfyear);
+ &print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear);
}
# ======================================================= Enroll single student
@@ -526,7 +568,7 @@ sub enroll_single_student {
if (lc($desiredhost) eq 'default') {
$desiredhost = undef;
} else {
- my %home_servers = &Apache::loncommon::get_home_servers($domain);
+ my %home_servers =&Apache::loncommon::get_library_servers($domain);
if (! exists($home_servers{$desiredhost})) {
$r->print('Error:'.
'Invalid home server specified');
@@ -538,7 +580,8 @@ sub enroll_single_student {
my $amode='';
my $genpwd='';
if ($ENV{'form.login'} eq 'krb') {
- $amode='krb4';
+ $amode='krb';
+ $amode.=$ENV{'form.krbver'};
$genpwd=$ENV{'form.krbarg'};
} elsif ($ENV{'form.login'} eq 'int') {
$amode='internal';
@@ -573,7 +616,7 @@ sub enroll_single_student {
}
# ======================================================= Menu Phase Two Enroll
-sub menu_phase_two_enroll {
+sub print_enroll_single_student_form {
my $r=shift;
$r->print("
ID/Student Number:
- -Group/Section:
+First Name: | |
Middle Name: | |
Last Name: | |
Generation: |
Username:
@@ -648,12 +692,17 @@ $intform$locform
-
Group/Section: +
+ + + + + +
+
+ID/Student Number: +
Disable ID/Student Number Safeguard and Force Change of Conflicting IDs -(only do if you know what you are doing)
-
-
+(only do if you know what you are doing)
+
+
-ENDSENROLL +END + return; } # =================================================== get the current classlist sub get_current_classlist { - my ($domain,$identifier) = @_; - # domain is the domain the class is being run in - # identifier is the internal, unique identifier for the class. - my %currentlist=(); - my $now=time; - my %results=&Apache::lonnet::dump('classlist',$domain,$identifier); - my ($tmp) = keys(%results); - if ($tmp !~ /^(con_lost|error|no_such_host)/i) { - foreach my $student (keys(%results)) { - # Extract the start and end dates - my ($end,$start)=split(/\:/,$results{$student}); - # If the class isn't over, put it in the list - unless (($end) && ($now>$end)) { - $currentlist{$student}=1; - } - } - return (undef,%currentlist); - } else { - $tmp =~ s/^error://; - return ($tmp,undef); - } + my $r = shift; + # Call DownloadClasslist + my $cid = $ENV{'request.course.id'}; + my $c = $r->connection; + my $classlisthash = &Apache::loncoursedata::DownloadClasslist + ($cid,'Not downloaded',$c); + # Call ProcessClasslist + my %cache; + my @students = &Apache::loncoursedata::ProcessClasslist(\%cache, + $classlisthash, + $cid,$c); + return (\@students,\%cache); } # ========================================================= Menu Phase Two Drop -sub menu_phase_two_drop { +sub print_drop_menu { my $r=shift; $r->print("ERROR:$error"); - } - } elsif (!defined(%currentlist)) { + 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 - &show_drop_list($r,%currentlist); + return; } + # Print out the available choices + &show_drop_list($student_array,$student_data,$r); + return; } # ============================================== view classlist -sub menu_phase_two_view { +sub print_html_classlist { my $r=shift; - $r->print("
ERROR:$error"); - } - } elsif (!defined(%currentlist)) { + 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 - &show_class_list($r,'view',%currentlist); + if ($ENV{'form.action'} eq 'modifystudent') { + &show_class_list($r,'view','modify','modifystudent', + 'any',$student_array,$student_data); + } else { + &show_class_list($r,'view','aboutme','classlist', + 'any',$student_array,$student_data); + } } } # ============================================== view classlist -sub menu_phase_two_viewcsv { +sub print_csv_classlist { my $r=shift; my $cid=$ENV{'request.course.id'}; - my ($error,%currentlist)=&get_current_classlist - ($ENV{'course.'.$cid.'.domain'},$ENV{'course.'.$cid.'.num'}); - if (defined($error)) { - if ($error =~ /^No such file or directory/) { - $r->print("There are no students currently enrolled.\n"); - } else { - $r->print("
ERROR:$error"); - } - } elsif (!defined(%currentlist)) { + 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',%currentlist); + &show_class_list($r,'csv','nolink','any',$student_array,$student_data); } } # =================================================== Show student list to drop sub show_class_list { - my ($r,$mode,%currentlist)=@_; + my ($r,$mode,$linkto,$action,$statusmode,$students,$s_data)=@_; my $cid=$ENV{'request.course.id'}; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['sortby']); + my $sortby = $ENV{'form.sortby'}; + if ($sortby !~ /^(username|domain|section|fullname|id)$/) { + $sortby = 'username'; + } # 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 | generation | section |
---|---|---|---|---|---|
+ username + | + domain + | + ID + | + student name + | + section + | +|
'. + 'Error'. + 'Error retrieving data for '. + join('@',split(/:/,$student)). + ', '.$error.' | |||||
\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 | +|
' :''). - 'Internal error: unable to get environment '. - 'for '.$sname.' in domain '.$sdom. - ( $mode eq 'view' ?' |
'. + 'Unable to retrieve environment data for '.$sname. + 'in domain '.$sdom.'
'. + 'Please contact your LON-CAPA administrator '. + 'regarding this situation.