--- loncom/interface/loncommon.pm 2004/01/02 21:00:56 1.170 +++ loncom/interface/loncommon.pm 2004/02/02 19:32:11 1.178 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.170 2004/01/02 21:00:56 www Exp $ +# $Id: loncommon.pm,v 1.178 2004/02/02 19:32:11 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -593,7 +593,7 @@ sub help_open_topic { # Add the graphic $template .= <<"ENDTEMPLATE"; - <a href="$link"><image src="/adm/help/gif/smallHelp.gif" border="0" alt="(Help: $topic)" /></a> + <a href="$link" title="Online Help"><image src="/adm/help/gif/smallHelp.gif" border="0" alt="(Help: $topic)" /></a> ENDTEMPLATE if ($text ne '') { $template.='</td></tr></table>' }; return $template; @@ -620,6 +620,92 @@ sub helpLatexCheatsheet { .'</td></tr></table>'; } +sub help_open_bug { + my ($topic, $text, $stayOnPage, $width, $height) = @_; + unless ($ENV{'user.adv'}) { return ''; } + unless ($Apache::lonnet::perlvar{'BugzillaHost'}) { return ''; } + $text = "" if (not defined $text); + $stayOnPage = 0 if (not defined $stayOnPage); + if ($ENV{'browser.interface'} eq 'textual' || + $ENV{'environment.remote'} eq 'off' ) { + $stayOnPage=1; + } + $width = 350 if (not defined $width); + $height = 400 if (not defined $height); + + $topic=~s/\W+/\+/g; + my $link=''; + my $template=''; + my $url=$Apache::lonnet::perlvar{'BugzillaHost'}.'enter_bug.cgi?product=LON-CAPA&bug_file_loc='. + &Apache::lonnet::escape($ENV{'REQUEST_URI'}).'&component='.$topic; + if (!$stayOnPage) + { + $link = "javascript:void(open('$url', 'Bugzilla', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height,resizable=yes'))"; + } + else + { + $link = $url; + } + # Add the text + if ($text ne "") + { + $template .= + "<table bgcolor='#AA3333' cellspacing='1' cellpadding='1' border='0'><tr>". + "<td bgcolor='#FF5555'><a href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>"; + } + + # Add the graphic + $template .= <<"ENDTEMPLATE"; + <a href="$link" title="Report a Bug"><image src="/adm/lonMisc/smallBug.gif" border="0" alt="(Bug: $topic)" /></a> +ENDTEMPLATE + if ($text ne '') { $template.='</td></tr></table>' }; + return $template; + +} + +sub help_open_faq { + my ($topic, $text, $stayOnPage, $width, $height) = @_; + unless ($ENV{'user.adv'}) { return ''; } + unless ($Apache::lonnet::perlvar{'FAQHost'}) { return ''; } + $text = "" if (not defined $text); + $stayOnPage = 0 if (not defined $stayOnPage); + if ($ENV{'browser.interface'} eq 'textual' || + $ENV{'environment.remote'} eq 'off' ) { + $stayOnPage=1; + } + $width = 350 if (not defined $width); + $height = 400 if (not defined $height); + + $topic=~s/\W+/\+/g; + my $link=''; + my $template=''; + my $url=$Apache::lonnet::perlvar{'FAQHost'}.'/fom/cache/'.$topic.'.html'; + if (!$stayOnPage) + { + $link = "javascript:void(open('$url', 'FAQ-O-Matic', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height,resizable=yes'))"; + } + else + { + $link = $url; + } + + # Add the text + if ($text ne "") + { + $template .= + "<table bgcolor='#337733' cellspacing='1' cellpadding='1' border='0'><tr>". + "<td bgcolor='#448844'><a href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>"; + } + + # Add the graphic + $template .= <<"ENDTEMPLATE"; + <a href="$link" title="View the FAQ"><image src="/adm/lonMisc/smallFAQ.gif" border="0" alt="(FAQ: $topic)" /></a> +ENDTEMPLATE + if ($text ne '') { $template.='</td></tr></table>' }; + return $template; + +} + =pod =item * csv_translate($text) @@ -1071,6 +1157,11 @@ END } my $radioval = "'nochange'"; + if (exists($in{'curr_authtype'}) && + defined($in{'curr_authtype'}) && + $in{'curr_authtype'} ne '') { + $radioval = "'$in{'curr_authtype'}arg'"; + } my $argfield = 'null'; if ( grep/^mode$/,(keys %in) ) { if ($in{'mode'} eq 'modifycourse') { @@ -1754,13 +1845,13 @@ sub display_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'})); } + if ($ENV{'environment.languages'}) { + @languages=split(/\s*(\,|\;|\:)\s*/,$ENV{'environment.languages'}); + } my $browser=(split(/\;/,$ENV{'HTTP_ACCEPT_LANGUAGE'}))[0]; if ($browser) { @languages=(@languages,split(/\s*(\,|\;|\:)\s*/,$browser)); @@ -2600,7 +2691,7 @@ sub record_sep { } } elsif ($ENV{'form.upfiletype'} eq 'tab') { my $i=0; - foreach (split(/\t+/,$record)) { + foreach (split(/\t/,$record)) { my $field=$_; $field=~s/^(\"|\')//; $field=~s/(\"|\')$//; @@ -2708,7 +2799,7 @@ Prints a table to create associations be $r is an Apache Request ref, $records is an arrayref from &Apache::loncommon::upfile_record_sep, -$d is an array of 2 element arrays (internal name, displayed name) +$d is an array of 2 element arrays (internal name, displayed name,defaultcol) =cut @@ -2723,14 +2814,16 @@ sub csv_print_select_table { '<th>'.&mt('Attribute').'</th>'. '<th>'.&mt('Column').'</th></tr>'."\n"); foreach (@$d) { - my ($value,$display)=@{ $_ }; + my ($value,$display,$defaultcol)=@{ $_ }; $r->print('<tr><td>'.$display.'</td>'); $r->print('<td><select name=f'.$i. ' onchange="javascript:flip(this.form,'.$i.');">'); $r->print('<option value="none"></option>'); foreach (sort({$a <=> $b} keys(%sone))) { - $r->print('<option value="'.$_.'">Column '.($_+1).'</option>'); + $r->print('<option value="'.$_.'"'. + ($_ eq $defaultcol ? ' selected ' : ''). + '>Column '.($_+1).'</option>'); } $r->print('</select></td></tr>'."\n"); $i++; @@ -2771,8 +2864,10 @@ sub csv_samples_select_table { $r->print('<tr><td><select name="f'.$i.'"'. ' onchange="javascript:flip(this.form,'.$i.');">'); foreach (@$d) { - my ($value,$display)=@{ $_ }; - $r->print('<option value="'.$value.'">'.$display.'</option>'); + my ($value,$display,$defaultcol)=@{ $_ }; + $r->print('<option value="'.$value.'"'. + ($i eq $defaultcol ? ' selected ':'').'>'. + $display.'</option>'); } $r->print('</select></td><td>'); if (defined($sone{$_})) { $r->print($sone{$_}."</br>\n"); } @@ -2897,6 +2992,8 @@ If $Max is < any data point, the graph w =item $colors: array ref holding the colors to be used for the data sets when they are plotted. If undefined, default values will be used. +=item $labels: array ref holding the labels to use on the x-axis for the bars. + =item @Values: An array of array references. Each array reference holds data to be plotted in a stacked bar chart. @@ -2912,7 +3009,7 @@ information for the plot. ############################################################ ############################################################ sub DrawBarGraph { - my ($Title,$xlabel,$ylabel,$Max,$colors,@Values)=@_; + my ($Title,$xlabel,$ylabel,$Max,$colors,$labels,@Values)=@_; # if (! defined($colors)) { $colors = ['#33ff00', @@ -2955,8 +3052,12 @@ sub DrawBarGraph { } # my @Labels; - for (my $i=0;$i<@{$Values[0]};$i++) { - push (@Labels,$i+1); + if (defined($labels)) { + @Labels = @$labels; + } else { + for (my $i=0;$i<@{$Values[0]};$i++) { + push (@Labels,$i+1); + } } # $Max = 1 if ($Max < 1); @@ -3263,7 +3364,7 @@ sub store_course_settings { my %SaveHash; my %AppHash; while (my ($setting,$type) = each(%$Settings)) { - my $basename = 'env.internal.'.$prefix.'.'.$setting; + my $basename = 'internal.'.$prefix.'.'.$setting; my $envname = 'course.'.$courseid.'.'.$basename; if (exists($ENV{'form.'.$setting})) { # Save this value away @@ -3308,7 +3409,7 @@ sub restore_course_settings { my ($prefix,$Settings) = @_; while (my ($setting,$type) = each(%$Settings)) { next if (exists($ENV{'form.'.$setting})); - my $envname = 'course.'.$courseid.'.env.internal.'.$prefix. + my $envname = 'course.'.$courseid.'.internal.'.$prefix. '.'.$setting; if (exists($ENV{$envname})) { if ($type eq 'scalar') {