version 1.14, 2004/03/31 19:31:56
|
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) ) { |
# Delete from roles.db for current section |
# Delete from roles.db for current section |
my $expiretime = time; |
my $expiretime = time; |
Line 194 sub update_LC {
|
Line 227 sub update_LC {
|
} |
} |
my $expire_role_result = &Apache::lonnet::assignrole($dom,$uname,$uurl,'st',$expiretime); |
my $expire_role_result = &Apache::lonnet::assignrole($dom,$uname,$uurl,'st',$expiretime); |
if ($expire_role_result eq 'ok') { |
if ($expire_role_result eq 'ok') { |
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); |
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/) { |
if ($modify_section_result =~ /^ok/) { |
$$logmsg .= "Section for $uname switched from old section: ".$$currlist{$uname}[$sec] ." to new section: ".$stuinfo[ $place{groupID} ].".".$linefeed; |
$$logmsg .= "Section for $uname switched from old section: ".$$currlist{$uname}[$sec] ." to new section: ".$stuinfo[ $place{groupID} ].".".$access.$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 section change for $uname from old section ".$$currlist{$uname}[$sec]." to new section: ".$stuinfo[ $place{groupID} ]." -error: $modify_section_result".$linefeed; |
} |
} |
Line 285 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 380 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 406 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 463 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"; |