--- loncom/interface/loncommon.pm 2003/08/26 17:20:45 1.113
+++ loncom/interface/loncommon.pm 2003/09/17 16:50:58 1.119
@@ -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.119 2003/09/17 16:50:58 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
@@ -346,11 +348,11 @@ sub selectstudent_link {
return '';
}
return "Select User";
+ '","'.$udomele.'");'."'>".&mt('Select User')."";
}
if ($ENV{'request.role'}=~/^(au|dc|su)/) {
return "Select User";
+ '","'.$udomele.'",1);'."'>".&mt('Select User')."";
}
return '';
}
@@ -382,7 +384,7 @@ ENDSTDBRW
sub selectcourse_link {
my ($form,$unameele,$udomele)=@_;
return "Select Course";
+ '","'.$udomele.'");'."'>".&mt('Select Course')."";
}
=pod
@@ -514,7 +516,7 @@ END
foreach my $value (sort(keys(%$hashref))) {
$result.=" \n";
+ $result.=">".&mt($hashref->{$value}->{'text'})."\n";
}
$result .= "\n";
my %select2 = %{$hashref->{$firstdefault}->{'select2'}};
@@ -524,7 +526,7 @@ END
foreach my $value (sort(keys(%select2))) {
$result.=" \n";
+ $result.=">".&mt($select2{$value})."\n";
}
$result .= "\n";
# return $debug;
@@ -765,7 +767,7 @@ sub select_form {
foreach (sort keys %hash) {
$selectform.="\n";
+ ">".&mt($hash{$_})."\n";
}
$selectform.="";
return $selectform;
@@ -1611,16 +1613,8 @@ sub fileextensions {
sub display_languages {
my %languages=();
- if ($ENV{'environment.languages'}) {
- foreach (split(/\s*(\,|\;|\:)\s*/,$ENV{'environment.languages'})) {
- $languages{$_}=1;
- }
- }
- if ($ENV{'course.'.$ENV{'request.course.id'}.'.languages'}) {
- foreach (split(/\s*(\,|\;|\:)\s*/,
- $ENV{'course.'.$ENV{'request.course.id'}.'.languages'})) {
- $languages{$_}=1;
- }
+ foreach (&preferred_languages()) {
+ $languages{$_}=1;
}
&get_unprocessed_cgi($ENV{'QUERY_STRING'},['displaylanguage']);
if ($ENV{'form.displaylanguage'}) {
@@ -1631,6 +1625,46 @@ 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'}));
+ }
+ my $browser=(split(/\;/,$ENV{'HTTP_ACCEPT_LANGUAGE'}))[0];
+ if ($browser) {
+ @languages=(@languages,split(/\s*(\,|\;|\:)\s*/,$browser));
+ }
+ if ($Apache::lonnet::domain_lang_def{$ENV{'user.domain'}}) {
+ @languages=(@languages,
+ $Apache::lonnet::domain_lang_def{$ENV{'user.domain'}});
+ }
+ if ($Apache::lonnet::domain_lang_def{$ENV{'request.role.domain'}}) {
+ @languages=(@languages,
+ $Apache::lonnet::domain_lang_def{$ENV{'request.role.domain'}});
+ }
+ if ($Apache::lonnet::domain_lang_def{
+ $Apache::lonnet::perlvar{'lonDefDomain'}}) {
+ @languages=(@languages,
+ $Apache::lonnet::domain_lang_def{
+ $Apache::lonnet::perlvar{'lonDefDomain'}});
+ }
+# turn "en-ca" into "en-ca,en"
+ my @genlanguages;
+ foreach (@languages) {
+ unless ($_=~/\w/) { next; }
+ push (@genlanguages,$_);
+ if ($_=~/(\-|\_)/) {
+ push (@genlanguages,(split(/(\-|\_)/,$_))[0]);
+ }
+ }
+ &Apache::lonnet::logthis('Lang: '.join(',',@genlanguages));
+ return @genlanguages;
+}
+
###############################################################
## Student Answer Attempts ##
###############################################################
@@ -1780,7 +1814,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 +1850,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 +1869,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 +2093,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 +2601,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)