--- loncom/interface/loncommon.pm 2003/09/17 14:30:13 1.118
+++ loncom/interface/loncommon.pm 2003/10/24 13:35:37 1.134
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.118 2003/09/17 14:30:13 www Exp $
+# $Id: loncommon.pm,v 1.134 2003/10/24 13:35:37 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -80,6 +80,7 @@ my $readit;
# ----------------------------------------------- Filetypes/Languages/Copyright
my %language;
+my %supported_language;
my %cprtag;
my %fe; my %fd;
my %category_extensions;
@@ -146,8 +147,11 @@ BEGIN {
while (<$fh>) {
next if /^\#/;
chomp;
- my ($key,$two,$country,$three,$enc,$val)=(split(/\t/,$_));
+ my ($key,$two,$country,$three,$enc,$val,$sup)=(split(/\t/,$_));
$language{$key}=$val.' - '.$enc;
+ if ($sup) {
+ $supported_language{$key}=$sup;
+ }
}
}
}
@@ -348,17 +352,18 @@ 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 '';
}
sub coursebrowser_javascript {
- return (<<'ENDSTDBRW');
+ my ($domainfilter)=@_;
+ return (<
var stdeditbrowser;
function opencrsbrowser(formname,uname,udom) {
@@ -369,6 +374,12 @@ sub coursebrowser_javascript {
url += 'filter='+filter+'&';
}
}
+ var domainfilter='$domainfilter';
+ if (domainfilter != null) {
+ if (domainfilter != '') {
+ url += 'domainfilter='+domainfilter+'&';
+ }
+ }
url += 'form=' + formname + '&cnumelement='+uname+
'&cdomelement='+udom;
var title = 'Course_Browser';
@@ -384,7 +395,7 @@ ENDSTDBRW
sub selectcourse_link {
my ($form,$unameele,$udomele)=@_;
return "Select Course";
+ '","'.$udomele.'");'."'>".&mt('Select Course')."";
}
=pod
@@ -516,7 +527,7 @@ END
foreach my $value (sort(keys(%$hashref))) {
$result.=" \n";
+ $result.=">".&mt($hashref->{$value}->{'text'})."\n";
}
$result .= "\n";
my %select2 = %{$hashref->{$firstdefault}->{'select2'}};
@@ -526,7 +537,7 @@ END
foreach my $value (sort(keys(%select2))) {
$result.=" \n";
+ $result.=">".&mt($select2{$value})."\n";
}
$result .= "\n";
# return $debug;
@@ -764,10 +775,16 @@ See lonrights.pm for an example invocati
sub select_form {
my ($def,$name,%hash) = @_;
my $selectform = "";
return $selectform;
@@ -1505,7 +1522,10 @@ returns description of a specified langu
=cut
sub languagedescription {
- return $language{shift(@_)};
+ my $code=shift;
+ return ($supported_language{$code}?'* ':'').
+ $language{$code}.
+ ($supported_language{$code}?' ('.&mt('interface available').')':'');
}
=pod
@@ -1661,7 +1681,6 @@ sub preferred_languages {
push (@genlanguages,(split(/(\-|\_)/,$_))[0]);
}
}
- &Apache::lonnet::logthis('Lang: '.join(',',@genlanguages));
return @genlanguages;
}
@@ -2322,6 +2341,14 @@ sub no_cache {
#$r->header_out("Expires" => $date);
}
+sub content_type {
+ my ($r,$type,$charset) = @_;
+ unless ($charset) {
+ $charset=&Apache::lonlocal::current_encoding;
+ }
+ $r->content_type($type.($charset?'; charset='.$charset:''));
+}
+
=pod
=item * add_to_env($name,$value)
@@ -2636,7 +2663,7 @@ $uname, optional the username of the use
sub check_if_partid_hidden {
my ($id,$symb,$udom,$uname) = @_;
- my $hiddenparts=&Apache::lonnet::EXT('resource.0.parameter_hiddenparts',
+ my $hiddenparts=&Apache::lonnet::EXT('resource.0.hiddenparts',
$symb,$udom,$uname);
my @hiddenlist=split(/,/,$hiddenparts);
foreach my $checkid (@hiddenlist) {
@@ -2645,6 +2672,68 @@ sub check_if_partid_hidden {
return undef;
}
+############################################################
+############################################################
+
+=pod
+
+=item DrawBarGraph
+
+
+=cut
+
+############################################################
+############################################################
+sub DrawBarGraph {
+ my ($Title,$xlabel,$ylabel,$Max,$colors,@Values)=@_;
+ #
+ if (! defined($colors)) {
+ $colors = ['#33ff00',
+ '#0033cc', '#990000', '#aaaa66', '#663399', '#ff9933',
+ '#66ccff', '#ff9999', '#cccc33', '#660000', '#33cc66',
+ ];
+ }
+ #
+ my $identifier = time.'_'.int(rand(1000));
+ if (! @Values || ref($Values[0]) ne 'ARRAY') {
+ return '';
+ }
+ my $NumBars = scalar(@{$Values[0]});
+ my %ValuesHash;
+ my $NumSets=1;
+ foreach my $array (@Values) {
+ next if (! ref($array));
+ $ValuesHash{'cgi.'.$identifier.'.data.'.$NumSets++} =
+ join(',',@$array);
+ }
+ #
+ $Title = '' if (! defined($Title));
+ $xlabel = '' if (! defined($xlabel));
+ $ylabel = '' if (! defined($ylabel));
+ $Title = &Apache::lonnet::escape($Title);
+ $xlabel = &Apache::lonnet::escape($xlabel);
+ $ylabel = &Apache::lonnet::escape($ylabel);
+ #
+ $Max = 1 if ($Max < 1);
+ if ( int($Max) < $Max ) {
+ $Max++;
+ $Max = int($Max);
+ }
+ #
+ &Apache::lonnet::appenv('cgi.'.$identifier.'.title' => $Title,
+ 'cgi.'.$identifier.'.xlabel' => $xlabel,
+ 'cgi.'.$identifier.'.ylabel' => $ylabel,
+ 'cgi.'.$identifier.'.Max' => $Max,
+ 'cgi.'.$identifier.'.NumBars' => $NumBars,
+ 'cgi.'.$identifier.'.NumSets' => $NumSets,
+ 'cgi.'.$identifier.'.Colors' => join(',',@{$colors}),
+ %ValuesHash);
+ return '';
+}
+
+############################################################
+############################################################
+
=pod
=back