version 1.33, 2002/09/20 22:33:54
|
version 1.39, 2002/10/22 16:34:24
|
Line 487 sub ProcessTopResourceMap {
|
Line 487 sub ProcessTopResourceMap {
|
} |
} |
my @titleLength=split(//,$cache->{$currentSequence. |
my @titleLength=split(//,$cache->{$currentSequence. |
':title'}); |
':title'}); |
# $extra is 3 for problems correct and 3 for space |
# $extra is 5 for problems correct and 3 for space |
# between problems correct and problem output |
# between problems correct and problem output |
my $extra = 6; |
my $extra = 8; |
if(($totalProblems + $extra) > (scalar @titleLength)) { |
if(($totalProblems + $extra) > (scalar @titleLength)) { |
$cache->{$currentSequence.':columnWidth'}= |
$cache->{$currentSequence.':columnWidth'}= |
$totalProblems + $extra; |
$totalProblems + $extra; |
Line 1084 sub ProcessFullName {
|
Line 1084 sub ProcessFullName {
|
my ($lastname, $generation, $firstname, $middlename)=@_; |
my ($lastname, $generation, $firstname, $middlename)=@_; |
my $Str = ''; |
my $Str = ''; |
|
|
|
# Strip whitespace preceeding & following name components. |
|
$lastname =~ s/(\s+$|^\s+)//g; |
|
$generation =~ s/(\s+$|^\s+)//g; |
|
$firstname =~ s/(\s+$|^\s+)//g; |
|
$middlename =~ s/(\s+$|^\s+)//g; |
|
|
if($lastname ne '') { |
if($lastname ne '') { |
$Str .= $lastname.' '; |
$Str .= $lastname; |
if($generation ne '') { |
$Str .= ' '.$generation if ($generation ne ''); |
$Str .= $generation; |
$Str .= ','; |
} else { |
$Str .= ' '.$firstname if ($firstname ne ''); |
chop($Str); |
$Str .= ' '.$middlename if ($middlename ne ''); |
} |
|
$Str .= ', '; |
|
if($firstname ne '') { |
|
$Str .= $firstname.' '; |
|
} |
|
if($middlename ne '') { |
|
$Str .= $middlename; |
|
} else { |
|
chop($Str); |
|
if($firstname eq '') { |
|
chop($Str); |
|
} |
|
} |
|
} else { |
} else { |
if($firstname ne '') { |
$Str .= $firstname if ($firstname ne ''); |
$Str .= $firstname.' '; |
$Str .= ' '.$middlename if ($middlename ne ''); |
} |
$Str .= ' '.$generation if ($generation ne ''); |
if($middlename ne '') { |
|
$Str .= $middlename.' '; |
|
} |
|
if($generation ne '') { |
|
$Str .= $generation; |
|
} else { |
|
chop($Str); |
|
} |
|
} |
} |
|
|
return $Str; |
return $Str; |
Line 1402 sub CheckForResidualDownload {
|
Line 1387 sub CheckForResidualDownload {
|
return 'OK'; |
return 'OK'; |
} |
} |
|
|
|
################################################ |
|
################################################ |
|
|
|
=pod |
|
|
|
=item &get_classlist(); |
|
|
|
Retrieve the classist of a given class or of the current class. Student |
|
information is returned from the classlist.db file and, if needed, |
|
from the students environment. |
|
|
|
Optional arguments are $cid, $cdom, and $cnum (course id, course domain, |
|
and course number, respectively). Any omitted arguments will be taken |
|
from the current environment ($ENV{'request.course.id'}, |
|
$ENV{'course.'.$cid.'.domain'}, and $ENV{'course.'.$cid.'.num'}). |
|
|
|
Returns a reference to a hash which contains: |
|
keys '$sname:$sdom' |
|
values [$end,$start,$id,$section,$fullname] |
|
|
|
=cut |
|
|
|
################################################ |
|
################################################ |
|
|
|
sub get_classlist { |
|
my ($cid,$cdom,$cnum) = @_; |
|
$cid = $cid || $ENV{'request.course.id'}; |
|
$cdom = $cdom || $ENV{'course.'.$cid.'.domain'}; |
|
$cnum = $cnum || $ENV{'course.'.$cid.'.num'}; |
|
my $now = time; |
|
# |
|
my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum); |
|
while (my ($student,$info) = each(%classlist)) { |
|
return undef if ($student =~ /^(con_lost|error|no_such_host)/i); |
|
my ($sname,$sdom) = split(/:/,$student); |
|
my @Values = split(/:/,$info); |
|
my ($end,$start,$id,$section,$fullname); |
|
if (@Values > 2) { |
|
($end,$start,$id,$section,$fullname) = @Values; |
|
} else { # We have to get the data ourselves |
|
($end,$start) = @Values; |
|
$section = &Apache::lonnet::getsection($sdom,$sname,$cid); |
|
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) { |
|
$fullname = 'not available'; |
|
$id = 'not available'; |
|
&Apache::lonnet::logthis('unable to retrieve environment '. |
|
'for '.$sname.':'.$sdom); |
|
} else { |
|
$fullname = &ProcessFullName(@info{qw/lastname generation |
|
firstname middlename/}); |
|
$id = $info{'id'}; |
|
} |
|
# Update the classlist with this students information |
|
if ($fullname ne 'not available') { |
|
my $enrolldata = join(':',$end,$start,$id,$section,$fullname); |
|
my $reply=&Apache::lonnet::cput('classlist', |
|
{$student => $enrolldata}, |
|
$cdom,$cnum); |
|
if ($reply !~ /^(ok|delayed)/) { |
|
&Apache::lonnet::logthis('Unable to update classlist for '. |
|
'student '.$sname.':'.$sdom. |
|
' error:'.$reply); |
|
} |
|
} |
|
} |
|
my $status='Expired'; |
|
if(((!$end) || $now < $end) && ((!$start) || ($now > $start))) { |
|
$status='Active'; |
|
} |
|
$classlist{$student} = |
|
[$sdom,$sname,$end,$start,$id,$section,$fullname,$status]; |
|
} |
|
if (wantarray()) { |
|
return (\%classlist,['domain','username','end','start','id', |
|
'section','fullname','status']); |
|
} else { |
|
return \%classlist; |
|
} |
|
} |
|
|
# ----- END HELPER FUNCTIONS -------------------------------------------- |
# ----- END HELPER FUNCTIONS -------------------------------------------- |
|
|
1; |
1; |
__END__ |
__END__ |
|
|
|
|