--- loncom/interface/loncommon.pm 2006/07/02 12:36:08 1.412
+++ loncom/interface/loncommon.pm 2006/07/04 22:02:14 1.420
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.412 2006/07/02 12:36:08 raeburn Exp $
+# $Id: loncommon.pm,v 1.420 2006/07/04 22:02:14 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3179,7 +3179,7 @@ table#LC_title_bar td.LC_title_bar_who {
text-align: right;
}
span.LC_title_bar_title {
- font: bold xx-large $sans;
+ font: bold x-large $sans;
}
table#LC_title_bar td.LC_title_bar_domain_logo {
background: $sidebg;
@@ -3461,6 +3461,19 @@ table#LC_helpmenu_links a:hover {
color: $vlink;
}
+.LC_chrt_popup_exists {
+ border: 1px solid #339933;
+ margin: -1px;
+}
+.LC_chrt_popup_up {
+ border: 1px solid yellow;
+ margin: -1px;
+}
+.LC_chrt_popup {
+ border: 1px solid #8888FF;
+ background: #CCCCFF;
+}
+
END
}
@@ -3477,8 +3490,10 @@ Inputs: $title - optional title for the
$args - optional arguments
force_register - if is true call registerurl so the remote is
informed
- redirect -> array ref of seconds before redirect occurs
- url to redirect to
+ redirect -> array ref of
+ 1- seconds before redirect occurs
+ 2- url to redirect to
+ 3- whether the side effect should occur
(side effect of setting
$env{'internal.head.redirect'} to the url
redirected too)
@@ -3497,15 +3512,15 @@ sub headtag {
my $function = $args->{'function'} || &get_users_function();
my $domain = $args->{'domain'} || &determinedomain();
my $bgcolor = $args->{'bgcolor'} || &designparm($function.'.pgbg',$domain);
- my $url = join(':',$env{'user.name'},$env{'user.domain'},time(),
- #$env{'environment.color.timestamp'},
+ my $url = join(':',$env{'user.name'},$env{'user.domain'},
+ #time(),
+ $env{'environment.color.timestamp'},
$function,$domain,$bgcolor);
$url = '/adm/css/'.&escape($url).'.css';
my $result =
'
'.
- ''.
&font_settings().
&Apache::lonhtmlcommon::htmlareaheaders();
@@ -3514,9 +3529,11 @@ sub headtag {
}
if (ref($args->{'redirect'})) {
- my ($time,$url) = @{$args->{'redirect'}};
+ my ($time,$url,$inhibit_continue) = @{$args->{'redirect'}};
$url = &Apache::lonenc::check_encrypt($url);
- $env{'internal.head.redirect'} = $url;
+ if (!$inhibit_continue) {
+ $env{'internal.head.redirect'} = $url;
+ }
$result.=<
@@ -3526,7 +3543,9 @@ ADDMETA
$title = 'The LearningOnline Network with CAPA';
}
- $result .= ' LON-CAPA '.&mt($title).''.$head_extra;
+ $result .= ' LON-CAPA '.&mt($title).''
+ .''
+ .$head_extra;
return $result;
}
@@ -3943,20 +3962,28 @@ sub check_user_status {
Determines all the sections for a course including
sections with students and sections containing other roles.
-Incoming parameters: domain, course number,
-reference to array containing roles for which sections should
-be gathered (optional). If the third argument is undefined,
-sections are gathered for any role.
+Incoming parameters:
+
+1. domain
+2. course number
+3. reference to array containing roles for which sections should
+be gathered (optional).
+4. reference to array containing status types for which sections
+should be gathered (optional).
+
+If the third argument is undefined, sections are gathered for any role.
+If the fourth argument is undefined, sections are gathered for any status.
+Permissible values are 'active' or 'future' or 'previous'.
Returns section hash (keys are section IDs, values are
number of users in each section), subject to the
-optional roles filter.
+optional roles filter, optional status filter
=cut
###############################################
sub get_sections {
- my ($cdom,$cnum,$possible_roles) = @_;
+ my ($cdom,$cnum,$possible_roles,$possible_status) = @_;
if (!defined($cdom) || !defined($cnum)) {
my $cid = $env{'request.course.id'};
@@ -3967,16 +3994,32 @@ sub get_sections {
}
my %sectioncount;
+ my $now = time;
if (!defined($possible_roles) || (grep(/^st$/,@$possible_roles))) {
my ($classlist) = &Apache::loncoursedata::get_classlist($cdom,$cnum);
my $sec_index = &Apache::loncoursedata::CL_SECTION();
my $status_index = &Apache::loncoursedata::CL_STATUS();
+ my $start_index = &Apache::loncoursedata::CL_START();
+ my $end_index = &Apache::loncoursedata::CL_END();
+ my $status;
while (my ($student,$data) = each(%$classlist)) {
- my ($section,$status) = ($data->[$sec_index],
- $data->[$status_index]);
- unless ($section eq '-1' || $section =~ /^\s*$/) {
- $sectioncount{$section}++;
+ my ($section,$stu_status,$start,$end) = ($data->[$sec_index],
+ $data->[$status_index],
+ $data->[$start_index],
+ $data->[$end_index]);
+ if ($stu_status eq 'Active') {
+ $status = 'active';
+ } elsif ($end < $now) {
+ $status = 'previous';
+ } elsif ($start > $now) {
+ $status = 'future';
+ }
+ if ($section ne '-1' && $section !~ /^\s*$/) {
+ if ((!defined($possible_status)) || (($status ne '') &&
+ (grep/^\Q$status\E$/,@{$possible_status}))) {
+ $sectioncount{$section}++;
+ }
}
}
}
@@ -3985,14 +4028,31 @@ sub get_sections {
if ($user !~ /^(\w{2})/) { next; }
my ($role) = ($user =~ /^(\w{2})/);
if ($possible_roles && !(grep(/^$role$/,@$possible_roles))) { next; }
- my $section;
+ my ($section,$status);
if ($role eq 'cr' &&
$user =~ m-^$role/[^/]*/[^/]*/[^/]*:[^:]*:[^:]*:(\w+)-) {
$section=$1;
}
if ($user =~ /^$role:[^:]*:[^:]*:(\w+)/) { $section=$1; }
if (!defined($section) || $section eq '-1') { next; }
- $sectioncount{$section}++;
+ my ($end,$start) = ($courseroles{$user} =~ /^([^:]*):([^:]*)$/);
+ if ($end == -1 && $start == -1) {
+ next; #deleted role
+ }
+ if (!defined($possible_status)) {
+ $sectioncount{$section}++;
+ } else {
+ if ((!$end || $end >= $now) && (!$start || $start <= $now)) {
+ $status = 'active';
+ } elsif ($end < $now) {
+ $status = 'future';
+ } elsif ($start > $now) {
+ $status = 'previous';
+ }
+ if (($status ne '') && (grep/^\Q$status\E$/,@{$possible_status})) {
+ $sectioncount{$section}++;
+ }
+ }
}
return %sectioncount;
}
@@ -4031,6 +4091,7 @@ of the possibility of multiple values fo
sub get_course_users {
my ($cdom,$cnum,$types,$roles,$sections,$users,$userdata) = @_;
my %idx = ();
+ my %seclists;
$idx{udom} = &Apache::loncoursedata::CL_SDOM();
$idx{uname} = &Apache::loncoursedata::CL_SNAME();
@@ -4047,23 +4108,27 @@ sub get_course_users {
foreach my $student (keys(%{$classlist})) {
my $match = 0;
my $secmatch = 0;
+ my $section = $$classlist{$student}[$idx{section}];
+ if ($section eq '') {
+ $section = 'none';
+ }
if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) {
- if (grep/^all$/,@{$sections}) {
+ if (grep(/^all$/,@{$sections})) {
$secmatch = 1;
} elsif ($$classlist{$student}[$idx{section}] eq '') {
- if (grep/^none$/,@{$sections}) {
+ if (grep(/^none$/,@{$sections})) {
$secmatch = 1;
}
} else {
- if (grep(/^\Q$$classlist{$student}[$idx{section}]\E$/,
- @{$sections})) {
+ if (grep(/^\Q$section\E$/,@{$sections})) {
$secmatch = 1;
}
}
if (!$secmatch) {
next;
}
- }
+ }
+ push(@{$seclists{$student}},$section);
if (defined($$types{'active'})) {
if ($$classlist{$student}[$idx{status}] eq 'Active') {
push(@{$$users{st}{$student}},'active');
@@ -4097,10 +4162,10 @@ sub get_course_users {
if (($role) && (grep(/^\Q$role\E$/,@{$roles}))) {
my ($uname,$udom) = split(/:/,$user);
if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) {
- if (grep/^all$/,@{$sections}) {
+ if (grep(/^all$/,@{$sections})) {
$secmatch = 1;
} elsif ($usec eq '') {
- if (grep/^none$/,@{$sections}) {
+ if (grep(/^none$/,@{$sections})) {
$secmatch = 1;
}
} else {
@@ -4112,18 +4177,27 @@ sub get_course_users {
next;
}
}
+ if ($usec eq '') {
+ $usec = 'none';
+ }
if ($uname ne '' && $udom ne '') {
my $status = &check_user_status($udom,$uname,$cdom,$cnum,$role,
$usec);
foreach my $type (keys(%{$types})) {
if ($status eq $type) {
- @{$$users{$role}{$user}} = $type;
+ if (!grep(/^\Q$type\E$/,@{$$users{$role}{$user}})) {
+ push(@{$$users{$role}{$user}},$type);
+ }
$match = 1;
}
}
- if (($match) && (ref($userdata) eq 'HASH') &&
- (!exists($$userdata{$uname.':'.$udom}))) {
- &get_user_info($udom,$uname,\%idx,$userdata);
+ if (($match) && (ref($userdata) eq 'HASH')) {
+ if (!exists($$userdata{$uname.':'.$udom})) {
+ &get_user_info($udom,$uname,\%idx,$userdata);
+ }
+ if (!grep(/^\Q$usec\E$/,@{$seclists{$uname.':'.$udom}})) {
+ push(@{$seclists{$uname.':'.$udom}},$usec);
+ }
}
}
}
@@ -4137,10 +4211,17 @@ sub get_course_users {
if (defined($userdata) &&
!exists($$userdata{$owner.':'.$cdom})) {
&get_user_info($cdom,$owner,\%idx,$userdata);
+ if (!grep(/^none$/,@{$seclists{$owner.':'.$cdom}})) {
+ push(@{$seclists{$owner.':'.$cdom}},'none');
+ }
}
}
}
}
+ foreach my $user (keys(%seclists)) {
+ @{$seclists{$user}} = (sort {$a <=> $b} @{$seclists{$user}});
+ $$userdata{$user}[$idx{section}] = join(',',@{$seclists{$user}});
+ }
}
return;
}