--- loncom/interface/lonpreferences.pm 2006/03/21 21:06:35 1.78 +++ loncom/interface/lonpreferences.pm 2006/06/26 18:56:50 1.93 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.78 2006/03/21 21:06:35 albertel Exp $ +# $Id: lonpreferences.pm,v 1.93 2006/06/26 18:56:50 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,6 +33,7 @@ package Apache::lonpreferences; use strict; +use LONCAPA; use Apache::Constants qw(:common); use Apache::File; use Crypt::DES; @@ -107,7 +108,7 @@ sub wysiwygchanger { my $switchoff=&mt('Disable WYSIWYG editor'); my $switchon=&mt('Enable WYSIWYG editor'); $r->print(< +


@@ -147,7 +148,7 @@ sub languagechanger { my $selectionbox=&Apache::loncommon::select_form($language,'language', %langchoices); $r->print(< +
$pref: $selectionbox ENDLSCREEN @@ -201,14 +202,14 @@ sub texenginechanger { $r->print(< - +

$pref: $selectionbox

Examples:

TeX to HTML
- +

jsMath
$jsMath_start @@ -228,12 +229,12 @@ if (jsMath.nofonts == 1) { +''); } - +

Convert to Images

- +

ENDLSCREEN if ($env{'environment.texengine'} ne 'jsMath') { @@ -297,25 +298,92 @@ sub rolesprefchanger { $options .= "\n"; } - $r->print(<Some LON-CAPA users have a long list of roles. The Recent Roles Hotlist -feature keeps track of the last N roles which have been -visited and places a table of these at the top of the roles page. -People with very few roles should leave this feature disabled. -

+# Get list of recent roles and display with checkbox in front + my $roles_check_list = ''; + my $role_key=''; + if ($env{'environment.recentroles'}) { + my %recent_roles = + &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'}); + my %frozen_roles = + &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'}); + + my %role_text = &rolespref_get_role_text([keys(%recent_roles)]); + my @sorted_roles = sort {$role_text{$a} cmp $role_text{$b}} keys(%role_text); + + $roles_check_list .= + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + "".&mt('Freeze Role')."". + "".&mt('Role')."". + &Apache::loncommon::end_data_table_header_row(). + "\n"; + my $count; + foreach $role_key (@sorted_roles) { + my $checked = ""; + my $value = $recent_roles{$role_key}; + if ($frozen_roles{$role_key}) { + $checked = "checked=\"checked\""; + } + $count++; + $roles_check_list .= + &Apache::loncommon::start_data_table_row(). + ''. + "". + "". + &Apache::loncommon::end_data_table_row(). "\n"; + } + $roles_check_list .= "\n"; + } + $r->print(' +

'.&mt('Some LON-CAPA users have a long list of roles. The Recent Roles Hotlist feature keeps track of the last N roles which have been visited and places a table of these at the top of the roles page. People with very few roles should leave this feature disabled.').' +

-
Enable Recent Roles Hotlist: - -
Number of roles in Hotlist: +
+
'.&mt('Number of roles in Hotlist:').' +

'.&mt('This list below can be used to freeze roles on your screen. Those marked as frozen will not be removed from the list, even if they have not been used recently.').' +

+'.$roles_check_list.'
- -
-ENDSCREEN + +'); +} + +sub rolespref_get_role_text { +# Get a line of text for each role + my ($roles) = @_; + my %roletext = (); + + foreach my $item (@$roles) { +# get course information + my ($role,$rest) = split(/\./, $item); + my $trole = ""; + $trole = &Apache::lonnet::plaintext($role); + my ($tdomain,$other,$tsection)= split(/\//,Apache::lonnet::declutter($rest)); + my $tother = '-'; + if ($role =~ /^(cc|st|in|ta|ep|cr)/ ) { + my %newhash=&Apache::lonnet::coursedescription($tdomain."_".$other); + $tother = " - ".$newhash{'description'}; + } elsif ($role =~ /dc/) { + $tother = ""; + } else { + $tother = " - $other"; + } + + my $section=""; + if ($tsection) { + $section = " - Section/Group: $tsection"; + } + $roletext{$item} = $tdomain." - ".$trole.$tother.$section; + } + return %roletext; } sub verify_and_change_rolespref { @@ -325,24 +393,58 @@ sub verify_and_change_rolespref { # Recent Roles Hotlist Flag my $hotlist_flag = $env{'form.recentroles'}; my $hotlist_n = $env{'form.recentrolesn'}; - my $message=''; + my $message='
'; if ($hotlist_flag) { &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag}); &Apache::lonnet::appenv('environment.recentroles' => $hotlist_flag); - $message='Recent Roles Hotlist is Enabled'; + $message=&mt('Recent Roles Hotlist is Enabled'); } else { &Apache::lonnet::del('environment',['recentroles']); &Apache::lonnet::delenv('environment\.recentroles'); - $message='Recent Roles Hotlist is Disabled'; + $message=&mt('Recent Roles Hotlist is Disabled'); } if ($hotlist_n) { &Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n}); &Apache::lonnet::appenv('environment.recentrolesn' => $hotlist_n); if ($hotlist_flag) { - $message.="
Display $hotlist_n Most Recent Roles\n"; + $message.="
". + &mt('Display [_1] Most Recent Roles',$hotlist_n)."\n"; + } + } + +# Get list of froze roles and list of recent roles + my @freeze_list = &Apache::loncommon::get_env_multiple('form.freezeroles'); + my %freeze = (); + my %roletext = (); + + foreach my $key (@freeze_list) { + $freeze{$key}='1'; + } + + my %recent_roles = + &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'}); + my %frozen_roles = + &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'}); + my %role_text = &rolespref_get_role_text([keys(%recent_roles)]); + +# Unset any roles that were previously frozen but aren't in list + foreach my $role_key (sort(keys(%recent_roles))) { + if (($frozen_roles{$role_key}) && (!exists($freeze{$role_key}))) { + $message .= "
".&mt('Unfreezing Role: [_1]',$role_text{$role_key})."\n"; + &Apache::lonhtmlcommon::store_recent('roles',$role_key,' ',0); } } +# Freeze selected roles + foreach my $role_key (@freeze_list) { + if (!$frozen_roles{$role_key}) { + $message .= "
".&mt('Freezing Role: [_1]',$role_text{$role_key})."\n"; + &Apache::lonhtmlcommon::store_recent('roles', + $role_key,' ',1); + } + } + $message .= "

\n"; + $r->print(<print(< +

New screenname (shown if you post anonymously): @@ -430,7 +532,7 @@ sub msgforwardchanger { $r->print(< - + New Forwarding Address(es) (user:domain,user:domain,...):
@@ -505,17 +607,7 @@ ENDVCMSG sub colorschanger { my $r = shift; # figure out colors - my $function='student'; - if ($env{'request.role'}=~/^(cc|in|ta|ep)/) { - $function='coordinator'; - } - if ($env{'request.role'}=~/^(su|dc|ad|li)/) { - $function='admin'; - } - if (($env{'request.role'}=~/^(au|ca)/) || - ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) { - $function='author'; - } + my $function=&Apache::loncommon::get_users_function(); my $domain=&Apache::loncommon::determinedomain(); my %colortypes=('pgbg' => 'Page Background', 'tabbg' => 'Header Background', @@ -524,19 +616,23 @@ sub colorschanger { 'link' => 'Un-Visited Link', 'vlink' => 'Visited Link', 'alink' => 'Active Link'); + my $start_data_table = &Apache::loncommon::start_data_table(); my $chtable=''; foreach my $item (sort(keys(%colortypes))) { my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain); - $chtable.=''.$colortypes{$item}.'      Select'; + .$item."','parmform.pres','psub'".');">Select'. + &Apache::loncommon::end_data_table_row()."\n"; } + my $end_data_table = &Apache::loncommon::end_data_table(); my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); $r->print(< +