--- loncom/interface/loncommon.pm 2006/06/26 21:54:34 1.397 +++ loncom/interface/loncommon.pm 2006/07/03 00:44:21 1.414 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.397 2006/06/26 21:54:34 albertel Exp $ +# $Id: loncommon.pm,v 1.414 2006/07/03 00:44:21 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -707,7 +707,7 @@ sub helpLatexCheatsheet { } sub help_open_menu { - my ($color,$topic,$component_help,$function,$faq,$bug,$stayOnPage,$width,$height,$text) = @_; + my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height,$text) = @_; $text = "" if (not defined $text); $stayOnPage = 0 if (not defined $stayOnPage); if ($env{'browser.interface'} eq 'textual' || @@ -721,8 +721,7 @@ sub help_open_menu { my $origurl = $ENV{'REQUEST_URI'}; $origurl=~s|^/~|/priv/|; my $timestamp = time; - foreach my $datum (\$color,\$function,\$topic,\$component_help,\$faq, - \$bug,\$origurl) { + foreach my $datum (\$topic,\$component_help,\$faq,\$bug,\$origurl) { $$datum = &escape($$datum); } if (!$stayOnPage) { @@ -730,8 +729,8 @@ sub help_open_menu { } else { $link = "javascript:helpMenu('display')"; } - my $banner_link = "/adm/helpmenu?page=banner&color=$color&function=$function&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp&stayonpage=$stayOnPage"; - my $details_link = "/adm/helpmenu?page=body&color=$color&function=$function&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp"; + my $banner_link = "/adm/helpmenu?page=banner&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp&stayonpage=$stayOnPage"; + my $details_link = "/adm/helpmenu?page=body&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp"; my $template; if ($text ne "") { $template .= @@ -2726,16 +2725,8 @@ Returns: value of designparamter $which =cut -sub designparm { - my ($which,$domain)=@_; - my $result = &designparm_real(@_); - &Apache::lonnet::logthis(" $which $domain reulted in $result"); - return $result; -} - - ############################################## -sub designparm_real { +sub designparm { my ($which,$domain)=@_; if ($env{'browser.blackwhite'} eq 'on') { if ($which=~/\.(font|alink|vlink|link)$/) { @@ -2805,7 +2796,6 @@ Inputs: =item * $no_inline_link, if true and in remote mode, don't show the 'Switch To Inline Menu' link - =back Returns: A uniform header for LON-CAPA web pages. @@ -2876,15 +2866,12 @@ sub bodytag { return $bodytag; } - + my $name = &plainname($env{'user.name'},$env{'user.domain'}); my $roleinfo=(<
- $env{'environment.firstname'} - $env{'environment.middlename'} - $env{'environment.lastname'} - $env{'environment.generation'} + $name  
@@ -2935,7 +2922,7 @@ ENDROLE $lastitem = $thisdisfn; } $titleinfo = - &Apache::loncommon::help_open_menu('','','','',3,'Authoring'). + &Apache::loncommon::help_open_menu('','',3,'Authoring'). 'Construction Space: '. '
' @@ -3156,10 +3143,11 @@ table#LC_top_nav, table#LC_menubuttons { width: 100%; background: $pgbg; border: 2px; - border-collapse: seperate; + border-collapse: separate; + padding: 0px; } -table#LC_title_bar, table#LC_breadcrumbs, table#LC_nav_location, +table#LC_title_bar, table.LC_breadcrumbs, table#LC_nav_location, table#LC_title_bar.LC_with_remote { width: 100%; border-color: $pgbg; @@ -3169,10 +3157,19 @@ table#LC_title_bar.LC_with_remote { background: $pgbg; font-family: $sans; border-collapse: collapse; + padding: 0px; +} + +table.LC_docs_path { + width: 100%; + border: 0; + background: $pgbg; + font-family: $sans; + border-collapse: collapse; + padding: 0px; } table#LC_title_bar td { - padding: 3px; background: $tabbg; } table#LC_title_bar td.LC_title_bar_who { @@ -3208,6 +3205,7 @@ table#LC_menubuttons img, table#LC_menub table#LC_top_nav td { background: $tabbg; border: 0px; + font-size: small; } table#LC_top_nav td a, div#LC_top_nav a { color: $font; @@ -3216,14 +3214,21 @@ table#LC_top_nav td a, div#LC_top_nav a table#LC_top_nav td.LC_top_nav_logo { background: $tabbg; text-align: right; + white-space: nowrap; + font-weight: bold; } -table#LC_breadcrumbs td { +table#LC_top_nav td.LC_top_nav_logo img { + margin-left: 0.2em; + vertical-align: bottom; +} +table.LC_breadcrumbs td, table.LC_docs_path td { background: $tabbg; color: $font; font-family: $sans; font-size: smaller; } -table#LC_breadcrumbs td.LC_breadcrumb_component { +table.LC_breadcrumbs td.LC_breadcrumbs_component, +table.LC_docs_path td.LC_docs_path_component { background: $tabbg; color: $font; font-family: $sans; @@ -3258,7 +3263,7 @@ td.LC_menubuttons_img { table.LC_data_table, table.LC_mail_list { border: 1px solid #000000; - border-collapse: seperate; + border-collapse: separate; } table.LC_data_table tr th, table.LC_calendar tr th, table.LC_mail_list tr th { font-weight: bold; @@ -3422,6 +3427,16 @@ table.LC_parm_overview_restrictions th { border-style: solid; border-color: $pgbg; } +table#LC_helpmenu { + border: 0px; + height: 55px; + border-spacing: 0px; +} + +table#LC_helpmenu fieldset legend { + font-size: larger; + font-weight: bold; +} table#LC_helpmenu_links { width: 100%; border: 1px solid black; @@ -3432,6 +3447,8 @@ table#LC_helpmenu_links { table#LC_helpmenu_links tr td { padding: 1px; background: $tabbg; + text-align: center; + font-weight: bold; } table#LC_helpmenu_links a:link, table#LC_helpmenu_links a:visited, @@ -3488,7 +3505,6 @@ sub headtag { my $result = ''. - ''. &font_settings(). &Apache::lonhtmlcommon::htmlareaheaders(); @@ -3497,9 +3513,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.=< @@ -3509,7 +3527,9 @@ ADDMETA $title = 'The LearningOnline Network with CAPA'; } - $result .= ' LON-CAPA '.&mt($title).''.$head_extra; + $result .= ' LON-CAPA '.&mt($title).'' + .'' + .$head_extra; return $result; } @@ -3601,6 +3621,7 @@ Returns a uniform complete .. + =back =cut @@ -3714,7 +3735,6 @@ Inputs: $args - additional optio a html attribute frameset -> if true will start with a rather than -=back =cut @@ -3839,9 +3859,7 @@ sub simple_error_page { =pod -=over 4 - -=item get_users_function +=item * &get_users_function() Used by &bodytag to determine the current users primary role. Returns either 'student','coordinator','admin', or 'author'. @@ -3868,7 +3886,7 @@ sub get_users_function { =pod -=item check_user_status +=item * &check_user_status Determines current status of supplied role for a specific user. Roles can be active, previous or future. @@ -3883,33 +3901,35 @@ role status: active, previous or future. =cut sub check_user_status { - my ($udom,$uname,$cdom,$crs,$role,$secgrp) = @_; + my ($udom,$uname,$cdom,$crs,$role,$sec) = @_; my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname); my @uroles = keys %userinfo; my $srchstr; my $active_chk = 'none'; + my $now = time; if (@uroles > 0) { - if (($role eq 'cc') || ($secgrp eq '') || (!defined($secgrp))) { + if (($role eq 'cc') || ($sec eq '') || (!defined($sec))) { $srchstr = '/'.$cdom.'/'.$crs.'_'.$role; } else { - $srchstr = '/'.$cdom.'/'.$crs.'/'.$secgrp.'_'.$role; } - if (grep/^$srchstr$/,@uroles) { + $srchstr = '/'.$cdom.'/'.$crs.'/'.$sec.'_'.$role; + } + if (grep/^\Q$srchstr\E$/,@uroles) { my $role_end = 0; my $role_start = 0; $active_chk = 'active'; - if ($userinfo{$srchstr} =~ m/^($role)_(\d+)/) { - $role_end = $2; - if ($userinfo{$srchstr} =~ m/^($role)_($role_end)_(\d+)$/) { - $role_start = $3; + if ($userinfo{$srchstr} =~ m/^\Q$role\E_(\d+)/) { + $role_end = $1; + if ($userinfo{$srchstr} =~ m/^\Q$role\E_\Q$role_end\E_(\d+)$/) { + $role_start = $1; } } if ($role_start > 0) { - if (time < $role_start) { + if ($now < $role_start) { $active_chk = 'future'; } } if ($role_end > 0) { - if (time > $role_end) { + if ($now > $role_end) { $active_chk = 'previous'; } } @@ -3922,7 +3942,7 @@ sub check_user_status { =pod -=item get_sections +=item * &get_sections() Determines all the sections for a course including sections with students and sections containing other roles. @@ -3983,9 +4003,9 @@ sub get_sections { ############################################### =pod - -=item get_course_users - + +=item * &get_course_users() + Retrieves usernames:domains for users in the specified course with specific role(s), and access status. @@ -4008,9 +4028,9 @@ Entries for end, start, section and stat of the possibility of multiple values for non-student roles. =cut - + ############################################### - + sub get_course_users { my ($cdom,$cnum,$types,$roles,$sections,$users,$userdata) = @_; my %idx = (); @@ -4029,11 +4049,23 @@ sub get_course_users { my $now = time; foreach my $student (keys(%{$classlist})) { my $match = 0; + my $secmatch = 0; if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) { - unless(grep(/^\Q$$classlist{$student}[$idx{section}]\E$/, + if (grep/^all$/,@{$sections}) { + $secmatch = 1; + } elsif ($$classlist{$student}[$idx{section}] eq '') { + if (grep/^none$/,@{$sections}) { + $secmatch = 1; + } + } else { + if (grep(/^\Q$$classlist{$student}[$idx{section}]\E$/, @{$sections})) { - next; + $secmatch = 1; + } } + if (!$secmatch) { + next; + } } if (defined($$types{'active'})) { if ($$classlist{$student}[$idx{status}] eq 'Active') { @@ -4053,35 +4085,47 @@ sub get_course_users { $match = 1; } } - if ($match && defined($userdata)) { + if ($match && ref($userdata) eq 'HASH') { $$userdata{$student} = $$classlist{$student}; } } } - if ((@{$roles} > 0) && (@{$roles} ne "st")) { + if ((@{$roles} > 1) || ((@{$roles} == 1) && ($$roles[0] ne "st"))) { my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$cdom,$cnum); foreach my $person (@coursepersonnel) { my $match = 0; - my ($role,$user) = ($person =~ /^([^:]*):([^:]+:[^:]+)/); + my $secmatch = 0; + my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/); $user =~ s/:$//; if (($role) && (grep(/^\Q$role\E$/,@{$roles}))) { - my ($uname,$udom,$usec) = split(/:/,$user); - if ($usec ne '' && (ref($sections) eq 'ARRAY') && - @{$sections} > 0) { - unless(grep(/^\Q$usec\E$/,@{$sections})) { - next; - } + my ($uname,$udom) = split(/:/,$user); + if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) { + if (grep/^all$/,@{$sections}) { + $secmatch = 1; + } elsif ($usec eq '') { + if (grep/^none$/,@{$sections}) { + $secmatch = 1; + } + } else { + if (grep(/^\Q$usec\E$/,@{$sections})) { + $secmatch = 1; + } + } + if (!$secmatch) { + next; + } } if ($uname ne '' && $udom ne '') { - my $status = &check_user_status($udom,$uname,$cdom,$cnum,$role); + my $status = &check_user_status($udom,$uname,$cdom,$cnum,$role, + $usec); foreach my $type (keys(%{$types})) { if ($status eq $type) { @{$$users{$role}{$user}} = $type; $match = 1; } } - if ($match && defined($userdata) && - !exists($$userdata{$uname.':'.$udom})) { + if (($match) && (ref($userdata) eq 'HASH') && + (!exists($$userdata{$uname.':'.$udom}))) { &get_user_info($udom,$uname,\%idx,$userdata); } } @@ -5170,13 +5214,22 @@ sub course_type { if (!defined($cid)) { $cid = $env{'request.course.id'}; } - if (defined($env{'course.'.$cid.'type'})) { - return $env{'course.'.$cid.'type'}; + if (defined($env{'course.'.$cid.'.type'})) { + return $env{'course.'.$cid.'.type'}; } else { return 'Course'; } } +sub group_term { + my $crstype = &course_type(); + my %names = ( + 'Course' => 'group', + 'Group' => 'team', + ); + return $names{$crstype}; +} + sub icon { my ($file)=@_; my $curfext = (split(/\./,$file))[-1];