version 1.113, 2003/08/26 17:20:45
|
version 1.130, 2003/10/16 19:59:00
|
Line 68 use POSIX qw(strftime mktime);
|
Line 68 use POSIX qw(strftime mktime);
|
use Apache::Constants qw(:common :http :methods); |
use Apache::Constants qw(:common :http :methods); |
use Apache::lonmsg(); |
use Apache::lonmsg(); |
use Apache::lonmenu(); |
use Apache::lonmenu(); |
|
use Apache::lonlocal; |
|
|
my $readit; |
my $readit; |
|
|
=pod |
=pod |
Line 78 my $readit;
|
Line 80 my $readit;
|
|
|
# ----------------------------------------------- Filetypes/Languages/Copyright |
# ----------------------------------------------- Filetypes/Languages/Copyright |
my %language; |
my %language; |
|
my %supported_language; |
my %cprtag; |
my %cprtag; |
my %fe; my %fd; |
my %fe; my %fd; |
my %category_extensions; |
my %category_extensions; |
Line 144 BEGIN {
|
Line 147 BEGIN {
|
while (<$fh>) { |
while (<$fh>) { |
next if /^\#/; |
next if /^\#/; |
chomp; |
chomp; |
my ($key,$two,$country,$three,$enc,$val)=(split(/\t/,$_)); |
my ($key,$two,$country,$three,$enc,$val,$sup)=(split(/\t/,$_)); |
$language{$key}=$val.' - '.$enc; |
$language{$key}=$val.' - '.$enc; |
|
if ($sup) { |
|
$supported_language{$key}=$sup; |
|
} |
} |
} |
} |
} |
} |
} |
Line 346 sub selectstudent_link {
|
Line 352 sub selectstudent_link {
|
return ''; |
return ''; |
} |
} |
return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele. |
return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele. |
'","'.$udomele.'");'."'>Select User</a>"; |
'","'.$udomele.'");'."'>".&mt('Select User')."</a>"; |
} |
} |
if ($ENV{'request.role'}=~/^(au|dc|su)/) { |
if ($ENV{'request.role'}=~/^(au|dc|su)/) { |
return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele. |
return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele. |
'","'.$udomele.'",1);'."'>Select User</a>"; |
'","'.$udomele.'",1);'."'>".&mt('Select User')."</a>"; |
} |
} |
return ''; |
return ''; |
} |
} |
|
|
sub coursebrowser_javascript { |
sub coursebrowser_javascript { |
return (<<'ENDSTDBRW'); |
my ($domainfilter)=@_; |
|
return (<<ENDSTDBRW); |
<script type="text/javascript" language="Javascript" > |
<script type="text/javascript" language="Javascript" > |
var stdeditbrowser; |
var stdeditbrowser; |
function opencrsbrowser(formname,uname,udom) { |
function opencrsbrowser(formname,uname,udom) { |
Line 367 sub coursebrowser_javascript {
|
Line 374 sub coursebrowser_javascript {
|
url += 'filter='+filter+'&'; |
url += 'filter='+filter+'&'; |
} |
} |
} |
} |
|
var domainfilter='$domainfilter'; |
|
if (domainfilter != null) { |
|
if (domainfilter != '') { |
|
url += 'domainfilter='+domainfilter+'&'; |
|
} |
|
} |
url += 'form=' + formname + '&cnumelement='+uname+ |
url += 'form=' + formname + '&cnumelement='+uname+ |
'&cdomelement='+udom; |
'&cdomelement='+udom; |
var title = 'Course_Browser'; |
var title = 'Course_Browser'; |
Line 382 ENDSTDBRW
|
Line 395 ENDSTDBRW
|
sub selectcourse_link { |
sub selectcourse_link { |
my ($form,$unameele,$udomele)=@_; |
my ($form,$unameele,$udomele)=@_; |
return "<a href='".'javascript:opencrsbrowser("'.$form.'","'.$unameele. |
return "<a href='".'javascript:opencrsbrowser("'.$form.'","'.$unameele. |
'","'.$udomele.'");'."'>Select Course</a>"; |
'","'.$udomele.'");'."'>".&mt('Select Course')."</a>"; |
} |
} |
|
|
=pod |
=pod |
Line 514 END
|
Line 527 END
|
foreach my $value (sort(keys(%$hashref))) { |
foreach my $value (sort(keys(%$hashref))) { |
$result.=" <option value=\"$value\" "; |
$result.=" <option value=\"$value\" "; |
$result.=" selected=\"true\" " if ($value eq $firstdefault); |
$result.=" selected=\"true\" " if ($value eq $firstdefault); |
$result.=">$hashref->{$value}->{'text'}</option>\n"; |
$result.=">".&mt($hashref->{$value}->{'text'})."</option>\n"; |
} |
} |
$result .= "</select>\n"; |
$result .= "</select>\n"; |
my %select2 = %{$hashref->{$firstdefault}->{'select2'}}; |
my %select2 = %{$hashref->{$firstdefault}->{'select2'}}; |
Line 524 END
|
Line 537 END
|
foreach my $value (sort(keys(%select2))) { |
foreach my $value (sort(keys(%select2))) { |
$result.=" <option value=\"$value\" "; |
$result.=" <option value=\"$value\" "; |
$result.=" selected=\"true\" " if ($value eq $seconddefault); |
$result.=" selected=\"true\" " if ($value eq $seconddefault); |
$result.=">$select2{$value}</option>\n"; |
$result.=">".&mt($select2{$value})."</option>\n"; |
} |
} |
$result .= "</select>\n"; |
$result .= "</select>\n"; |
# return $debug; |
# return $debug; |
Line 762 See lonrights.pm for an example invocati
|
Line 775 See lonrights.pm for an example invocati
|
sub select_form { |
sub select_form { |
my ($def,$name,%hash) = @_; |
my ($def,$name,%hash) = @_; |
my $selectform = "<select name=\"$name\" size=\"1\">\n"; |
my $selectform = "<select name=\"$name\" size=\"1\">\n"; |
foreach (sort keys %hash) { |
my @keys; |
|
if (exists($hash{'select_form_order'})) { |
|
@keys=@{$hash{'select_form_order'}}; |
|
} else { |
|
@keys=sort(keys(%hash)); |
|
} |
|
foreach (@keys) { |
$selectform.="<option value=\"$_\" ". |
$selectform.="<option value=\"$_\" ". |
($_ eq $def ? 'selected' : ''). |
($_ eq $def ? 'selected' : ''). |
">".$hash{$_}."</option>\n"; |
">".&mt($hash{$_})."</option>\n"; |
} |
} |
$selectform.="</select>"; |
$selectform.="</select>"; |
return $selectform; |
return $selectform; |
Line 1503 returns description of a specified langu
|
Line 1522 returns description of a specified langu
|
=cut |
=cut |
|
|
sub languagedescription { |
sub languagedescription { |
return $language{shift(@_)}; |
my $code=shift; |
|
return ($supported_language{$code}?'* ':''). |
|
$language{$code}. |
|
($supported_language{$code}?' ('.&mt('interface available').')':''); |
} |
} |
|
|
=pod |
=pod |
Line 1611 sub fileextensions {
|
Line 1633 sub fileextensions {
|
|
|
sub display_languages { |
sub display_languages { |
my %languages=(); |
my %languages=(); |
if ($ENV{'environment.languages'}) { |
foreach (&preferred_languages()) { |
foreach (split(/\s*(\,|\;|\:)\s*/,$ENV{'environment.languages'})) { |
$languages{$_}=1; |
$languages{$_}=1; |
|
} |
|
} |
|
if ($ENV{'course.'.$ENV{'request.course.id'}.'.languages'}) { |
|
foreach (split(/\s*(\,|\;|\:)\s*/, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.languages'})) { |
|
$languages{$_}=1; |
|
} |
|
} |
} |
&get_unprocessed_cgi($ENV{'QUERY_STRING'},['displaylanguage']); |
&get_unprocessed_cgi($ENV{'QUERY_STRING'},['displaylanguage']); |
if ($ENV{'form.displaylanguage'}) { |
if ($ENV{'form.displaylanguage'}) { |
Line 1631 sub display_languages {
|
Line 1645 sub display_languages {
|
return %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]); |
|
} |
|
} |
|
return @genlanguages; |
|
} |
|
|
############################################################### |
############################################################### |
## Student Answer Attempts ## |
## Student Answer Attempts ## |
############################################################### |
############################################################### |
Line 1780 show a snapshot of what student was look
|
Line 1833 show a snapshot of what student was look
|
|
|
sub get_student_view { |
sub get_student_view { |
my ($symb,$username,$domain,$courseid,$target) = @_; |
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 (%old,%moreenv); |
my @elements=('symb','courseid','domain','username'); |
my @elements=('symb','courseid','domain','username'); |
foreach my $element (@elements) { |
foreach my $element (@elements) { |
Line 1816 show a snapshot of how student was answe
|
Line 1869 show a snapshot of how student was answe
|
|
|
sub get_student_answers { |
sub get_student_answers { |
my ($symb,$username,$domain,$courseid,%form) = @_; |
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 (%old,%moreenv); |
my @elements=('symb','courseid','domain','username'); |
my @elements=('symb','courseid','domain','username'); |
foreach my $element (@elements) { |
foreach my $element (@elements) { |
Line 1835 sub get_student_answers {
|
Line 1888 sub get_student_answers {
|
|
|
=pod |
=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 '<a href="/adm/grades?symb='.$symb.'&student='.$uname. |
|
'&userdom='.$udom.'&command=submission">'.$text.'</a>'; |
|
} |
|
############################################## |
|
|
|
=pod |
|
|
=back |
=back |
|
|
=cut |
=cut |
Line 2035 other decorations will be returned.
|
Line 2112 other decorations will be returned.
|
|
|
sub bodytag { |
sub bodytag { |
my ($title,$function,$addentries,$bodyonly,$domain,$forcereg)=@_; |
my ($title,$function,$addentries,$bodyonly,$domain,$forcereg)=@_; |
|
$title=&mt($title); |
unless ($function) { |
unless ($function) { |
$function='student'; |
$function='student'; |
if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) { |
if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) { |
Line 2263 sub no_cache {
|
Line 2341 sub no_cache {
|
#$r->header_out("Expires" => $date); |
#$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 |
=pod |
|
|
=item * add_to_env($name,$value) |
=item * add_to_env($name,$value) |
Line 2543 sub csv_samples_select_table {
|
Line 2629 sub csv_samples_select_table {
|
|
|
=pod |
=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) |
=item * check_if_partid_hidden($id,$symb,$udom,$uname) |
|
|
Returns either 1 or undef |
Returns either 1 or undef |
Line 2569 sub check_if_partid_hidden {
|
Line 2672 sub check_if_partid_hidden {
|
return undef; |
return undef; |
} |
} |
|
|
|
############################################################ |
|
############################################################ |
|
|
|
=pod |
|
|
|
=item DrawGraph |
|
|
|
Returns a link to cgi-bin/graph |
|
|
|
=cut |
|
|
|
############################################################ |
|
############################################################ |
|
sub DrawGraph { |
|
my ($Title,$xlabel,$ylabel,$Max,$colors,@Values)=@_; |
|
# |
|
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{$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($identifier.'.title' => $Title, |
|
$identifier.'.xlabel' => $xlabel, |
|
$identifier.'.ylabel' => $ylabel, |
|
$identifier.'.Max' => $Max, |
|
$identifier.'.NumBars' => $NumBars, |
|
$identifier.'.NumSets' => $NumSets, |
|
$identifier.'.Colors' => join(',',@{$colors}), |
|
%ValuesHash); |
|
return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />'; |
|
} |
|
|
|
############################################################ |
|
############################################################ |
|
|
=pod |
=pod |
|
|
=back |
=back |