version 1.9, 2003/12/15 05:39:40
|
version 1.15, 2004/06/17 18:31:24
|
Line 49 sub update_LC {
|
Line 49 sub update_LC {
|
my $status=&Apache::loncoursedata::CL_STATUS; |
my $status=&Apache::loncoursedata::CL_STATUS; |
my $type=&Apache::loncoursedata::CL_TYPE; |
my $type=&Apache::loncoursedata::CL_TYPE; |
my @localstudents = (); |
my @localstudents = (); |
|
my @futurestudents = (); |
|
my @activestudents = (); |
my $currlist; |
my $currlist; |
foreach my $uname (keys %{$roster} ) { |
foreach my $uname (keys %{$roster} ) { |
if ($uname =~ m/^(.+):$dom$/) { |
if ($uname =~ m/^(.+):$dom$/) { |
if ($$roster{$uname}[$status] eq "Active") { |
if ($$roster{$uname}[$status] eq "Active") { |
|
push @activestudents, $1; |
|
@{$$currlist{$1}} = @{$$roster{$uname}}; |
push @localstudents, $1; |
push @localstudents, $1; |
|
} elsif ( ($$roster{$uname}[$cstart] > time) && ($$roster{$uname}[$cend] > time || $$roster{$uname}[$cend] == 0 || $$roster{$uname}[$cend] eq '') ) { |
|
push @futurestudents, $1; |
@{$$currlist{$1}} = @{$$roster{$uname}}; |
@{$$currlist{$1}} = @{$$roster{$uname}}; |
|
push @localstudents, $1; |
} |
} |
} |
} |
} |
} |
Line 174 sub update_LC {
|
Line 181 sub update_LC {
|
unless ($uname eq '') { |
unless ($uname eq '') { |
my %uidhash=&Apache::lonnet::idrget($dom,$uname); |
my %uidhash=&Apache::lonnet::idrget($dom,$uname); |
my @stuinfo = @{$enrollinfo{$uname}}; |
my @stuinfo = @{$enrollinfo{$uname}}; |
|
my $access = ''; |
if (grep/^$uname$/,@localstudents) { |
if (grep/^$uname$/,@localstudents) { |
# Check for studentID changes |
# Check for studentID changes |
if ( ($uidhash{$uname}) && ($uidhash{$uname} !~ /error\:/) ) { |
if ( ($uidhash{$uname}) && ($uidhash{$uname} !~ /error\:/) ) { |
Line 181 sub update_LC {
|
Line 189 sub update_LC {
|
$$logmsg .= "Change in ID for $uname. StudentID in LON-CAPA system is $uidhash{$uname}; StudentID in institutional data is $stuinfo[ $place{studentID} ]".$linefeed; |
$$logmsg .= "Change in ID for $uname. StudentID in LON-CAPA system is $uidhash{$uname}; StudentID in institutional data is $stuinfo[ $place{studentID} ]".$linefeed; |
} |
} |
} |
} |
|
|
# Check for section changes |
# Check for section changes |
unless ($$currlist{$uname}[$sec] eq $stuinfo[ $place{groupID} ]) { |
if ($$currlist{$uname}[$sec] eq $stuinfo[ $place{groupID} ]) { |
|
# Check for access date changes for students with access starting in the future. |
|
if ( (grep/^$uname$/,@futurestudents) && ($$currlist{$uname}[$type] eq "auto") && ($adds == 1) ) { |
|
my $datechange = 0; |
|
unless ($$currlist{$uname}[$cstart] eq $startdate) { |
|
$datechange = 1; |
|
} |
|
if (!$datechange) { |
|
if (!$$currlist{$uname}[$cend]) { |
|
if ($enddate) { |
|
$datechange = 1; |
|
} |
|
} elsif ($$currlist{$uname}[$cend] ne $enddate) { |
|
$datechange = 1; |
|
} |
|
} |
|
if ($datechange) { |
|
my $modify_access_result = &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$enddate,$startdate,'auto',$cid); |
|
$access = &showaccess($enddate,$startdate); |
|
if ($modify_access_result =~ /^ok/) { |
|
$$logmsg .= "Change in access dates for $uname.".$access.$linefeed; |
|
} else { |
|
$$logmsg .= "Error when attempting to change start and/or end access dates for $uname in section: ".$stuinfo[ $place{groupID} ]." -error $modify_access_result".$linefeed; |
|
} |
|
} |
|
} |
|
} else { |
if ( ($$currlist{$uname}[$type] eq "auto") && ($adds == 1) ) { |
if ( ($$currlist{$uname}[$type] eq "auto") && ($adds == 1) ) { |
my $modify_section_result = &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$$currlist{$uname}[$cend],$$currlist{$uname}[$cstart],'auto',$cid); |
# Delete from roles.db for current section |
if ($modify_section_result =~ /^ok/) { |
my $expiretime = time; |
$$logmsg .= "Section for $uname switched from old section: ".$$currlist{$uname}[$sec] ." to new section: ".$stuinfo[ $place{groupID} ].".".$linefeed; |
my $uurl='/'.$cid; |
|
$uurl=~s/\_/\//g; |
|
if ($$currlist{$uname}[$sec]) { |
|
$uurl.='/'.$$currlist{$uname}[$sec]; |
|
} |
|
my $expire_role_result = &Apache::lonnet::assignrole($dom,$uname,$uurl,'st',$expiretime); |
|
if ($expire_role_result eq 'ok') { |
|
my $modify_section_result; |
|
if (grep/^$uname$/,@activestudents) { |
|
$modify_section_result = &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$$currlist{$uname}[$cend],$$currlist{$uname}[$cstart],'auto',$cid); |
|
} else { |
|
$modify_section_result = &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$enddate,$startdate,'auto',$cid); |
|
$access = &showaccess($enddate,$startdate); |
|
} |
|
if ($modify_section_result =~ /^ok/) { |
|
$$logmsg .= "Section for $uname switched from old section: ".$$currlist{$uname}[$sec] ." to new section: ".$stuinfo[ $place{groupID} ].".".$access.$linefeed; |
|
} else { |
|
$$logmsg .= "Error when attempting section change for $uname from old section ".$$currlist{$uname}[$sec]." to new section: ".$stuinfo[ $place{groupID} ]." -error: $modify_section_result".$linefeed; |
|
} |
} else { |
} else { |
$$logmsg .= "Error when attempting section change for $uname from old section ".$$currlist{$uname}[$sec]." to new section: ".$stuinfo[ $place{groupID} ]." -error: $modify_section_result".$linefeed; |
$$logmsg .= "Error when attempting to expire role for $uname in old section" .$$currlist{$uname}[$sec]." -error: $expire_role_result".$linefeed; |
} |
} |
} |
} |
} |
} |
Line 221 sub update_LC {
|
Line 272 sub update_LC {
|
$usec =~ s/\W//g; |
$usec =~ s/\W//g; |
|
|
unless ($emailaddr =~/^[^\@]+\@[^\@]+$/) { $emailaddr =''; } |
unless ($emailaddr =~/^[^\@]+\@[^\@]+$/) { $emailaddr =''; } |
my $emailenc = &HTML::Entities::encode($emailaddr); |
my $emailenc = &HTML::Entities::encode($emailaddr,'<>&"'); |
|
|
# Use course defaults where entry is absent |
# Use course defaults where entry is absent |
if ( ($auth eq '') || (!defined($auth)) ) { |
if ( ($auth eq '') || (!defined($auth)) ) { |
Line 230 sub update_LC {
|
Line 281 sub update_LC {
|
if ( ($authparam eq '') || (!defined($authparam)) ) { |
if ( ($authparam eq '') || (!defined($authparam)) ) { |
$authparam = $autharg; |
$authparam = $autharg; |
} |
} |
if ($auth =~ m/^krb/) { |
|
$auth .= ":".$authparam; |
|
} |
|
if ( ($end eq '') || (!defined($end)) ) { |
if ( ($end eq '') || (!defined($end)) ) { |
$end = $enddate; |
$end = $enddate; |
} |
} |
Line 251 sub update_LC {
|
Line 299 sub update_LC {
|
my $authchk = ''; |
my $authchk = ''; |
unless ($authparam eq '') { $authchk = 'ok'; }; |
unless ($authparam eq '') { $authchk = 'ok'; }; |
# If no account exists and passwords should be generated |
# If no account exists and passwords should be generated |
if ($authtype eq "int") { |
if ($auth eq "internal") { |
if ($authparam eq '') { |
if ($authparam eq '') { |
($authparam) = &create_password(); |
($authparam) = &create_password(); |
if ($authparam eq '') { |
if ($authparam eq '') { |
$authchk = ''; |
$authchk = ''; |
} else { |
} else { |
$create_passwd = 1; |
$create_passwd = 1; |
|
$authchk = 'ok'; |
} |
} |
} |
} |
} elsif ($authtype eq "local") { |
} elsif ($auth eq "localauth") { |
($authparam,$create_passwd,$authchk) = &localenroll::create_password($authparam); |
($authparam,$create_passwd,$authchk) = &localenroll::create_password($authparam); |
} elsif ($authtype =~ m/^krb/) { |
} elsif ($auth =~ m/^krb/) { |
if ($authparam eq '') { |
if ($authparam eq '') { |
$$logmsg .= "No Kerberos domain was provided for the new user - $uname, so the new student was not enrolled in the course.".$linefeed; |
$$logmsg .= "No Kerberos domain was provided for the new user - $uname, so the new student was not enrolled in the course.".$linefeed; |
$authchk = 'invalid'; |
$authchk = 'invalid'; |
Line 275 sub update_LC {
|
Line 324 sub update_LC {
|
# Now create user. |
# Now create user. |
my $reply=&Apache::lonnet::modifystudent($dom,$uname,$pid,$auth,$authparam,$first,$middle,$last,$gene,$usec,$end,$start,'',undef,$emailaddr,'auto',$cid); |
my $reply=&Apache::lonnet::modifystudent($dom,$uname,$pid,$auth,$authparam,$first,$middle,$last,$gene,$usec,$end,$start,'',undef,$emailaddr,'auto',$cid); |
if ($reply eq 'ok') { |
if ($reply eq 'ok') { |
|
$access = &showaccess($end,$start); |
$enrollcount ++; |
$enrollcount ++; |
$addresult .= "$first $last ($pid) - $uname enrolled in section/group $usec.".$linefeed; |
$addresult .= "$first $last ($pid) - $uname enrolled in section/group $usec.".$access.$linefeed; |
if ($context eq 'automated') { |
if ($context eq 'automated') { |
$$logmsg .= "New $dom user $uname added successfully."; |
$$logmsg .= "New $dom user $uname added successfully."; |
} |
} |
Line 329 sub update_LC {
|
Line 379 sub update_LC {
|
} |
} |
my $krbdefdom = ''; |
my $krbdefdom = ''; |
my $currentauth=&Apache::lonnet::queryauthenticate($uname,$dom); |
my $currentauth=&Apache::lonnet::queryauthenticate($uname,$dom); |
if ($currentauth=~/^krb(4|5):/) { |
if ($currentauth=~/^(krb[45]):(.*)/) { |
$currentauth=~/^krb(4|5):(.*)/; |
$currentauth = $1; |
$krbdefdom=$1; |
$krbdefdom = $2; |
} |
} elsif ($currentauth=~ /^(unix|internal|localauth):/) { |
if ($currentauth=~/^krb(4|5):/ || |
$currentauth = $1; |
$currentauth=~/^unix:/ || |
|
$currentauth=~/^internal:/ || |
|
$currentauth=~/^localauth:/) { |
|
|
|
} else { |
} else { |
$$logmsg .= "Invalid authentication method $currentauth for $uname.".$linefeed; |
$$logmsg .= "Invalid authentication method $currentauth for $uname.".$linefeed; |
} |
} |
# Report if authentication methods are different. |
# Report if authentication methods are different. |
if ($currentauth ne $auth ) { |
if ($currentauth ne $auth) { |
$$logmsg .= "Authentication mismatch for $uname - $currentauth in system, $auth based on information in classlist or default for this course.".$linefeed; |
$$logmsg .= "Authentication type mismatch for $uname - '$currentauth' in system, '$auth' based on information in classlist or default for this course.".$linefeed; |
|
} elsif ($auth =~ m/^krb/) { |
|
if ($krbdefdom ne $authparam) { |
|
$$logmsg .= "Kerberos domain mismatch for $uname - '$krbdefdom' in system, '$authparam' based on information in classlist or default for this course.".$linefeed; |
|
} |
} |
} |
|
|
# Check user data |
# Check user data |
if ($first ne $userenv{'firstname'} || |
if ($first ne $userenv{'firstname'} || |
$middle ne $userenv{'middlename'} || |
$middle ne $userenv{'middlename'} || |
Line 369 sub update_LC {
|
Line 420 sub update_LC {
|
# Assign the role of student in the course. |
# Assign the role of student in the course. |
my $classlist_reply = &Apache::lonnet::modify_student_enrollment($dom,$uname,$pid,$first,$middle,$last,$gene,$usec,$end,$start,'auto',$cid); |
my $classlist_reply = &Apache::lonnet::modify_student_enrollment($dom,$uname,$pid,$first,$middle,$last,$gene,$usec,$end,$start,'auto',$cid); |
if ($classlist_reply eq 'ok') { |
if ($classlist_reply eq 'ok') { |
|
$access = &showaccess($end,$start); |
$enrollcount ++; |
$enrollcount ++; |
$addresult .= "$first $last ($pid) - $uname enrolled in section/group $usec.".$linefeed; |
$addresult .= "$first $last ($pid) - $uname enrolled in section/group $usec.".$access.$linefeed; |
if ($context eq 'automated') { |
if ($context eq 'automated') { |
$$logmsg .= "Existing $dom user $uname enrolled successfully.".$linefeed; |
$$logmsg .= "Existing $dom user $uname enrolled successfully.".$linefeed; |
} |
} |
Line 395 sub update_LC {
|
Line 447 sub update_LC {
|
push @saved,$uname; |
push @saved,$uname; |
} |
} |
} elsif (@saved == 0) { |
} elsif (@saved == 0) { |
my $drop_reply = &Apache::lonnet::modifystudent($dom,$uname,'','','',undef,undef,undef,undef,$$currlist{$uname}[$sec],time,undef,undef,undef,undef,undef,$cid); |
my $drop_reply = &Apache::lonnet::modifystudent($dom,$uname,'','','',undef,undef,undef,undef,$$currlist{$uname}[$sec],time,undef,undef,undef,undef,'auto',$cid); |
if ($drop_reply !~ /^ok/) { |
if ($drop_reply !~ /^ok/) { |
$$logmsg .= "An error occured during the attempt to expire the $uname from the old section $$currlist{$uname}[$sec] - $drop_reply.".$linefeed; |
$$logmsg .= "An error occured during the attempt to expire the $uname from the old section $$currlist{$uname}[$sec] - $drop_reply.".$linefeed; |
} else { |
} else { |
Line 452 sub update_LC {
|
Line 504 sub update_LC {
|
return ($changecount,$addresult.$dropresult); |
return ($changecount,$addresult.$dropresult); |
} |
} |
|
|
|
sub showaccess { |
|
my ($end,$start) = @_; |
|
my $showstart; |
|
my $showend; |
|
if ( (!$start) || ($start <= time) ) { |
|
$showstart = 'immediately'; |
|
} else { |
|
$showstart = &Apache::lonlocal::locallocaltime($start); |
|
} |
|
if (!$end) { |
|
$showend = 'no end date'; |
|
} else { |
|
$showend = &Apache::lonlocal::locallocaltime($end); |
|
} |
|
my $access_msg = " Access starts: ".$showstart.", ends: ".$showend."."; |
|
return $access_msg; |
|
} |
|
|
sub parse_classlist { |
sub parse_classlist { |
my ($tmpdir,$dom,$crs,$class,$placeref,$groupID,$studentsref) = @_; |
my ($tmpdir,$dom,$crs,$class,$placeref,$groupID,$studentsref) = @_; |
my $xmlfile = $tmpdir."/tmp/".$dom."_".$crs."_".$class."_classlist.xml"; |
my $xmlfile = $tmpdir."/tmp/".$dom."_".$crs."_".$class."_classlist.xml"; |
Line 527 sub process_date {
|
Line 597 sub process_date {
|
|
|
sub create_password { |
sub create_password { |
my $passwd = ''; |
my $passwd = ''; |
my @letts = "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"; |
my @letts = ("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); |
for (my $i=0; $i<8; $i++) { |
for (my $i=0; $i<8; $i++) { |
my $lettnum = int (rand 2); |
my $lettnum = int (rand 2); |
my $item = ''; |
my $item = ''; |