--- loncom/interface/loncommon.pm 2006/05/12 02:17:50 1.370 +++ loncom/interface/loncommon.pm 2006/05/30 20:05:05 1.377 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.370 2006/05/12 02:17:50 www Exp $ +# $Id: loncommon.pm,v 1.377 2006/05/30 20:05:05 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -386,10 +386,11 @@ sub selectstudent_link { sub coursebrowser_javascript { my ($domainfilter)=@_; + my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Group - for which you wish to add/modify a user role'); return (< var stdeditbrowser; - function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag) { + function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag,crstype) { var url = '/adm/pickcourse?'; var filter; if (filter != null) { @@ -415,6 +416,18 @@ sub coursebrowser_javascript { if (multflag !=null && multflag != '') { url += '&multiple='+multflag; } + if (crstype == 'Course/Group') { + if (formname == 'cu') { + crstype = document.cu.crstype.options[document.cu.crstype.selectedIndex].value; + if (crstype == "") { + alert("$crs_or_grp_alert"); + return; + } + } + } + if (crstype !=null && crstype != '') { + url += '&type='+crstype; + } var title = 'Course_Browser'; var options = 'scrollbars=1,resizable=1,menubar=0'; options += ',width=700,height=600'; @@ -426,9 +439,9 @@ ENDSTDBRW } sub selectcourse_link { - my ($form,$unameele,$udomele,$desc,$extra_element,$multflag)=@_; + my ($form,$unameele,$udomele,$desc,$extra_element,$multflag,$selecttype)=@_; return "".&mt('Select Course').""; + '","'.$udomele.'","'.$desc.'","'.$extra_element.'","'.$multflag.'","'.$selecttype.'");'."'>".&mt('Select [_1]',$selecttype).""; } sub check_uncheck_jscript { @@ -2608,10 +2621,7 @@ sub timehash { sub utc_string { my ($date)=@_; - my @utctime=gmtime($date); - my $year=$utctime[5]+1900; - my $month=$utctime[4]+1; - return "$year$month$utctime[3]T$utctime[2]$utctime[1]$utctime[0]Z"; + return strftime("%Y%m%dT%H%M%SZ",gmtime($date)); } sub maketime { @@ -2820,6 +2830,12 @@ sub bodytag { &Apache::lonnet::plaintext((split(/\./,$env{'request.role'}))[0]); # realm if ($env{'request.course.id'}) { + my $type = $env{'course.'.$env{'request.course.id'}.'.type'}; + if ($type eq 'Group') { + if ($env{'request.role'} !~ /^cr/) { # Change role name if Group + $role = &convert_role($role,$type); + } + } $realm = $env{'course.'.$env{'request.course.id'}.'.description'}; } if (!$realm) { $realm=' '; } @@ -3131,7 +3147,7 @@ table#LC_title_bar { padding: 0px 2px 0px 2px; background: $pgbg; font-family: $sans; - border-collapse: collapse; + border-collapse: separate; } table#LC_title_bar.LC_with_remote { width: 100%; @@ -3168,7 +3184,7 @@ table#LC_menubuttons_mainmenu { background: $pgbg; border: 0px; border-spacing: 1px; - padding: 0px; + padding: 0px 1px; margin: 0px; border-collapse: separate; } @@ -3557,7 +3573,6 @@ Inputs: $args - additional optio sub end_page { my ($args) = @_; - #&Apache::lonnet::logthis("end_page ".join(':',caller(0))); $env{'internal.end_page'}++; my $result; if ($args->{'discussion'}) { @@ -3600,7 +3615,7 @@ sub js_ready { $result =~ s/[\n\r]/ /xmsg; $result =~ s/\\/\\\\/xmsg; $result =~ s/'/\\'/xmsg; - $result =~ s{}{}xmsg; + $result =~ s{new(\$groupinfo); - my $token; - my $tool = ''; - my $role = ''; - my %content=(); - while ($token=$parser->get_token) { - if ($token->[0] eq 'S') { - my $entry=$token->[1]; - if ($entry eq 'functions' || $entry eq 'autosec') { - %{$content{$entry}} = (); - $tool = $entry; - } elsif ($entry eq 'role') { - if ($tool eq 'autosec') { - $role = $token->[2]{id}; - } - } else { - my $value=$parser->get_text('/'.$entry); - if ($entry eq 'name') { - if ($tool eq 'functions') { - my $function = $token->[2]{id}; - $content{$tool}{$function} = $value; - } - } elsif ($entry eq 'groupname') { - $content{$entry}=&unescape($value); - } elsif (($entry eq 'roles') || ($entry eq 'types') || - ($entry eq 'sectionpick') || ($entry eq 'defpriv')) { - push(@{$content{$entry}},$value); - } elsif ($entry eq 'section') { - if ($tool eq 'autosec' && $role ne '') { - push(@{$content{$tool}{$role}},$value); - } - } else { - $content{$entry}=$value; - } - } - } elsif ($token->[0] eq 'E') { - if ($token->[1] eq 'functions' || $token->[1] eq 'autosec') { - $tool = ''; - } elsif ($token->[1] eq 'role') { - $role = ''; - } - - } - } - return %content; -} - -sub check_group_access { - my ($group) = @_; - my $access = 1; - my $now = time; - my ($start,$end) = split(/\./,$env{'user.role.gr/'.$env{'request.course,id'}.'/'.$group}); - if (($end!=0) && ($end<$now)) { $access = 0; } - if (($start!=0) && ($start>$now)) { $access=0; } - return $access; -} - -############################################### =pod @@ -5028,6 +4898,7 @@ a hash ref describing the data to be sto 'chartoutputmode' => 'scalar', 'chartoutputdata' => 'scalar', 'Section' => 'array', + 'Group' => 'array', 'StudentData' => 'array', 'Maps' => 'array'); @@ -5110,15 +4981,16 @@ sub restore_course_settings { ############################################################ ############################################################ -sub propath { - my ($udom,$uname)=@_; - $udom=~s/\W//g; - $uname=~s/\W//g; - my $subdir=$uname.'__'; - $subdir =~ s/(.)(.)(.).*/$1\/$2\/$3/; - my $proname="$Apache::lonnet::perlvar{'lonUsersDir'}/$udom/$subdir/$uname"; - return $proname; -} +sub convert_role { + my ($rolename,$type) = @_; + if ($type eq 'Group') { + $rolename =~ s/Course/Group/; + $rolename =~ s/Instructor/Leader/; + $rolename =~ s/Teaching Assistant/Assistant Leader/; + $rolename =~ s/Student/Member/; + } + return $rolename; +} sub icon { my ($file)=@_;