--- loncom/interface/loncommon.pm 2003/08/26 17:20:45 1.113 +++ loncom/interface/loncommon.pm 2003/09/16 19:23:47 1.117 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.113 2003/08/26 17:20:45 bowersj2 Exp $ +# $Id: loncommon.pm,v 1.117 2003/09/16 19:23:47 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -68,6 +68,8 @@ use POSIX qw(strftime mktime); use Apache::Constants qw(:common :http :methods); use Apache::lonmsg(); use Apache::lonmenu(); +use Apache::lonlocal; + my $readit; =pod @@ -1631,6 +1633,18 @@ sub display_languages { return %languages; } +sub preferred_languages { + my @languages=(); + if ($ENV{'environment.languages'}) { + @languages=split(/\s*(\,|\;|\:)\s*/,$ENV{'environment.languages'}); + } + if ($ENV{'course.'.$ENV{'request.course.id'}.'.languages'}) { + @languages=(@languages,split(/\s*(\,|\;|\:)\s*/, + $ENV{'course.'.$ENV{'request.course.id'}.'.languages'})); + } + return (@languages,'en-US'); +} + ############################################################### ## Student Answer Attempts ## ############################################################### @@ -1780,7 +1794,7 @@ show a snapshot of what student was look sub get_student_view { my ($symb,$username,$domain,$courseid,$target) = @_; - my ($map,$id,$feedurl) = split(/___/,$symb); + my ($map,$id,$feedurl) = &Apache::lonnet::decode_symb($symb); my (%old,%moreenv); my @elements=('symb','courseid','domain','username'); foreach my $element (@elements) { @@ -1816,7 +1830,7 @@ show a snapshot of how student was answe sub get_student_answers { my ($symb,$username,$domain,$courseid,%form) = @_; - my ($map,$id,$feedurl) = split(/___/,$symb); + my ($map,$id,$feedurl) = &Apache::lonnet::decode_symb($symb); my (%old,%moreenv); my @elements=('symb','courseid','domain','username'); foreach my $element (@elements) { @@ -1835,6 +1849,30 @@ sub get_student_answers { =pod +=item * &submlink() + +Inputs: $text $uname $udom $symb + +Returns: A link to grades.pm such as to see the SUBM view of a student + +=cut + +############################################### +sub submlink { + my ($text,$uname,$udom,$symb)=@_; + if (!($uname && $udom)) { + (my $cursymb, my $courseid,$udom,$uname)= + &Apache::lonxml::whichuser($symb); + if (!$symb) { $symb=$cursymb; } + } + if (!$symb) { $symb=&symbread(); } + return ''.$text.''; +} +############################################## + +=pod + =back =cut @@ -2035,6 +2073,7 @@ other decorations will be returned. sub bodytag { my ($title,$function,$addentries,$bodyonly,$domain,$forcereg)=@_; + $title=&mt($title); unless ($function) { $function='student'; if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) { @@ -2542,6 +2581,23 @@ sub csv_samples_select_table { } =pod + +=item clean_excel_name($name) + +Returns a replacement for $name which does not contain any illegal characters. + +=cut + +sub clean_excel_name { + my ($name) = @_; + $name =~ s/[:\*\?\/\\]//g; + if (length($name) > 31) { + $name = substr($name,0,31); + } + return $name; +} + +=pod =item * check_if_partid_hidden($id,$symb,$udom,$uname)