--- loncom/interface/loncommon.pm 2007/04/16 22:50:44 1.523
+++ loncom/interface/loncommon.pm 2007/08/31 03:21:27 1.576
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.523 2007/04/16 22:50:44 albertel Exp $
+# $Id: loncommon.pm,v 1.576 2007/08/31 03:21:27 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -334,10 +334,12 @@ sub studentbrowser_javascript {
return (<<'ENDSTDBRW');
+RESIZE
+
+}
+
+=pod
+
+=back
+
=head1 Excel and CSV file utility routines
=over 4
@@ -1212,7 +1266,7 @@ sub create_workbook {
=item * create_text_file
-Create a file to write to and eventually make available to the usre.
+Create a file to write to and eventually make available to the user.
If file creation fails, outputs an error message on the request object and
return undefs.
@@ -1262,8 +1316,10 @@ sub domain_select {
} &Apache::lonnet::all_domains();
if ($multiple) {
$domains{''}=&mt('Any domain');
+ $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))];
return &multiple_select_form($name,$value,4,\%domains);
} else {
+ $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))];
return &select_form($name,$value,%domains);
}
}
@@ -1415,7 +1471,7 @@ sub select_level_form {
=pod
-=item * select_dom_form($defdom,$name,$includeempty)
+=item * select_dom_form($defdom,$name,$includeempty,$showdomdesc)
Returns a string containing a form to
allow a user to select the domain to preform an operation in.
@@ -1424,18 +1480,28 @@ See loncreateuser.pm for an example invo
If the $includeempty flag is set, it also includes an empty choice ("no domain
selected");
+If the $showdomdesc flag is set, the domain name is followed by the domain description.
+
=cut
#-------------------------------------------
sub select_dom_form {
- my ($defdom,$name,$includeempty) = @_;
- my @domains = sort(&Apache::lonnet::all_domains());
+ my ($defdom,$name,$includeempty,$showdomdesc) = @_;
+ my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());
if ($includeempty) { @domains=('',@domains); }
my $selectdomain = "\n";
foreach my $dom (@domains) {
$selectdomain.="$dom \n";
+ ($dom eq $defdom ? 'selected="selected" ' : '').'>'.$dom;
+ if ($showdomdesc) {
+ if ($dom ne '') {
+ my $domdesc = &Apache::lonnet::domain($dom,'description');
+ if ($domdesc ne '') {
+ $selectdomain .= ' ('.$domdesc.')';
+ }
+ }
+ }
+ $selectdomain .= "\n";
}
$selectdomain.=" ";
return $selectdomain;
@@ -1467,6 +1533,8 @@ sub home_server_option_list {
=pod
+=back
+
=cut
###############################################################
@@ -2052,6 +2120,7 @@ if $first is set to 'lastname' then it r
###############################################################
sub plainname {
my ($uname,$udom,$first)=@_;
+ return if (!defined($uname) || !defined($udom));
my %names=&getnames($uname,$udom);
my $name=&Apache::lonnet::format_name($names{'firstname'},
$names{'middlename'},
@@ -2083,6 +2152,7 @@ if the user does not
sub nickname {
my ($uname,$udom)=@_;
+ return if (!defined($uname) || !defined($udom));
my %names=&getnames($uname,$udom);
my $name=$names{'nickname'};
if ($name) {
@@ -2098,6 +2168,7 @@ sub nickname {
sub getnames {
my ($uname,$udom)=@_;
+ return if (!defined($uname) || !defined($udom));
if ($udom eq 'public' && $uname eq 'public') {
return ('lastname' => &mt('Public'));
}
@@ -2114,6 +2185,19 @@ sub getnames {
}
}
+# -------------------------------------------------------------------- getemails
+=pod
+
+=item * getemails($uname,$udom)
+
+Gets a user's email information and returns it as a hash with keys:
+notification, critnotification, permanentemail
+
+For notification and critnotification, values are comma-separated lists
+of e-mail address(es); for permanentemail, value is a single e-mail address.
+
+=cut
+
sub getemails {
my ($uname,$udom)=@_;
if ($udom eq 'public' && $uname eq 'public') {
@@ -2135,6 +2219,15 @@ sub getemails {
}
}
+sub flush_email_cache {
+ my ($uname,$udom)=@_;
+ if (!$udom) { $udom =$env{'user.domain'}; }
+ if (!$uname) { $uname=$env{'user.name'}; }
+ return if ($udom eq 'public' && $uname eq 'public');
+ my $id=$uname.':'.$udom;
+ &Apache::lonnet::devalidate_cache_new('emailscache',$id);
+}
+
# ------------------------------------------------------------------ Screenname
=pod
@@ -2208,7 +2301,8 @@ sub track_student_link {
$target = '';
}
if ($start) { $link.='&start='.$start; }
-
+ $title = &mt($title);
+ $linktext = &mt($linktext);
return qq{$linktext }.
&help_open_topic('View_recent_activity');
}
@@ -2661,7 +2755,6 @@ sub get_student_answers {
$moreenv{'grade_target'}='answer';
%moreenv=(%form,%moreenv);
$feedurl = &Apache::lonnet::clutter($feedurl);
- &Apache::lonenc::check_encrypt(\$feedurl);
my $userview=&Apache::lonnet::ssi($feedurl,%moreenv);
return $userview;
}
@@ -2912,7 +3005,7 @@ sub blockcheck {
}
my $no_ownblock = 0;
my $no_userblock = 0;
- if ($otheruser) {
+ if ($otheruser && $activity ne 'com') {
# Check if current user has 'evb' priv for this
if (defined($own_courses{$course})) {
foreach my $sec (keys(%{$own_courses{$course}})) {
@@ -3165,7 +3258,7 @@ Returns: Determines which domain should
###############################################
sub determinedomain {
my $domain=shift;
- if (! $domain) {
+ if (! $domain) {
# Determine domain if we have not been given one
$domain = $Apache::lonnet::perlvar{'lonDefDomain'};
if ($env{'user.domain'}) { $domain=$env{'user.domain'}; }
@@ -3248,8 +3341,12 @@ sub domainlogo {
# See if there is a logo
if ($designhash{$domain.'.login.domlogo'} ne '') {
my $imgsrc = $designhash{$domain.'.login.domlogo'};
- if ($imgsrc =~ /^\/(adm|res)/) {
- $imgsrc = &lonhttpdurl($imgsrc);
+ if ($imgsrc =~ m{^/(adm|res)/}) {
+ if ($imgsrc =~ m{^/res/}) {
+ my $local_name = &Apache::lonnet::filelocation('',$imgsrc);
+ &Apache::lonnet::repcopy($local_name);
+ }
+ $imgsrc = &lonhttpdurl($imgsrc);
}
return ' ';
} elsif (defined(&Apache::lonnet::domain($domain,'description'))) {
@@ -3298,7 +3395,11 @@ sub designparm {
}
if (($which =~ /^(student|coordinator|author|admin)\.img$/) ||
($which =~ /login\.(img|logo|domlogo)/)) {
- if ($output =~ /^\/(adm|res)\//) {
+ if ($output =~ m{^/(adm|res)/}) {
+ if ($output =~ m{^/res/}) {
+ my $local_name = &Apache::lonnet::filelocation('',$output);
+ &Apache::lonnet::repcopy($local_name);
+ }
$output = &lonhttpdurl($output);
}
}
@@ -3312,7 +3413,7 @@ sub designparm {
=back
-=head1 HTTP Helpers
+=head1 HTML Helpers
=over 4
@@ -3353,6 +3454,9 @@ Inputs:
=item * $args, optional argument valid values are
no_auto_mt_title -> prevents &mt()ing the title arg
+ inherit_jsmath -> when creating popup window in a page,
+ should it have jsmath forced on by the
+ current page
=back
@@ -3401,19 +3505,14 @@ sub bodytag {
if (!$realm) { $realm=' '; }
# Set messages
my $messages=&domainlogo($domain);
-# Port for miniserver
- my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
- if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
my $extra_body_attr = &make_attr_string($forcereg,\%design);
# construct main body tag
my $bodytag = "".
- &Apache::lontexconvert::init_math_support();
+ &Apache::lontexconvert::init_math_support($args->{'inherit_jsmath'});
- if ($bodyonly
- || ($env{'request.state'} eq 'construct'
- && $env{'environment.remote'} ne 'off' )) {
+ if ($bodyonly) {
return $bodytag;
} elsif ($env{'browser.interface'} eq 'textual') {
# Accessibility
@@ -3523,7 +3622,7 @@ ENDROLE
my $imgsrc = $img;
if ($img =~ /^\/adm/) {
- $imgsrc = 'http://'.$ENV{'HTTP_HOST'}.':'.$lonhttpdPort.$img;
+ $imgsrc = &lonhttpdurl($img);
}
my $upperleft=' ';
@@ -3608,20 +3707,12 @@ sub make_attr_string {
=pod
-=back
-
-=head1 HTML Helpers
-
-=over 4
-
=item * &endbodytag()
Returns a uniform footer for LON-CAPA web pages.
Inputs: none
-=back
-
=cut
sub endbodytag {
@@ -3638,8 +3729,6 @@ sub endbodytag {
=pod
-=over 4
-
=item * &standard_css()
Returns a style sheet
@@ -3650,8 +3739,6 @@ Inputs: (all optional)
function -> force usage of a specific rolish color scheme
bgcolor -> override the default page bgcolor
-=back
-
=cut
sub standard_css {
@@ -3717,13 +3804,32 @@ form, .inline { display: inline; }
.LC_diff_removed {
color: red;
}
+
+.LC_info,
.LC_success,
.LC_diff_added {
color: green;
}
+.LC_unknown {
+ color: yellow;
+}
+
.LC_icon {
border: 0px;
}
+.LC_indexer_icon {
+ border: 0px;
+ height: 22px;
+}
+.LC_docs_spacer {
+ width: 25px;
+ height: 1px;
+ border: 0px;
+}
+
+.LC_internal_info {
+ color: #999;
+}
table.LC_pastsubmission {
border: 1px solid black;
@@ -3786,7 +3892,7 @@ table#LC_title_bar td.LC_title_bar_role_
}
table#LC_menubuttons_mainmenu {
- background: $pgbg;
+ width: 100%;
border: 0px;
border-spacing: 1px;
padding: 0px 1px;
@@ -3851,20 +3957,27 @@ table#LC_mainmenu td.LC_mainmenu_column
font-size: smaller;
}
+.LC_menubuttons_link {
+ text-decoration: none;
+}
+
.LC_menubuttons_category {
color: $font;
+ background: $pgbg;
font-family: $sans;
font-size: larger;
font-weight: bold;
}
td.LC_menubuttons_text {
+ width: 90%;
color: $font;
font-family: $sans;
}
+
td.LC_menubuttons_img {
- background: $tabbg;
}
+
.LC_current_location {
font-family: $sans;
background: $tabbg;
@@ -3874,6 +3987,45 @@ td.LC_menubuttons_img {
font-weight: bold;
}
+.LC_rolesmenu_is {
+ font-family: $sans;
+}
+
+.LC_rolesmenu_selected {
+ font-family: $sans;
+}
+
+.LC_rolesmenu_future {
+ font-family: $sans;
+}
+
+
+.LC_rolesmenu_will {
+ font-family: $sans;
+}
+
+.LC_rolesmenu_will_not {
+ font-family: $sans;
+}
+
+.LC_rolesmenu_expired {
+ font-family: $sans;
+}
+
+.LC_rolesinfo {
+ font-family: $sans;
+}
+
+.LC_dropadd_labeltext {
+ font-family: $sans;
+ text-align: right;
+}
+
+.LC_preferences_labeltext {
+ font-family: $sans;
+ text-align: right;
+}
+
table.LC_aboutme_port {
border: 0px;
border-collapse: collapse;
@@ -4278,21 +4430,13 @@ span.LC_feedback_link {
}
table.LC_prior_tries {
- border-width: 1px;
- border-style: solid;
- border-color: gray;
- border-collapse: collapse;
+ border: 1px solid #000000;
+ border-collapse: separate;
+ border-spacing: 1px;
}
table.LC_prior_tries td {
- border-width: 1px;
- border-style: solid;
- border-color: gray;
- padding: 3px;
-}
-table.LC_prior_tries tr.LC_correct {
- font-weight: bold;
- background: #aaffaa;
+ padding: 2px;
}
.LC_answer_correct {
@@ -4323,7 +4467,16 @@ table.LC_prior_tries tr.LC_correct {
}
-span.LC_prior_numerical {
+span.LC_prior_numerical,
+span.LC_prior_string,
+span.LC_prior_custom,
+span.LC_prior_reaction,
+span.LC_prior_math {
+ font-family: monospace;
+ white-space: pre;
+}
+
+span.LC_prior_string {
font-family: monospace;
white-space: pre;
}
@@ -4332,13 +4485,88 @@ table.LC_prior_option {
width: 100%;
border-collapse: collapse;
}
-table.LC_prior_option tr td {
- border-style: solid;
- border-width: 1px
+table.LC_prior_rank, table.LC_prior_match {
+ border-collapse: collapse;
+}
+table.LC_prior_option tr td,
+table.LC_prior_rank tr td,
+table.LC_prior_match tr td {
+ border: 1px solid #000000;
}
span.LC_nobreak {
- white-space: nowrap;
+ white-space: nowrap;
+}
+
+span.LC_cusr_emph {
+ font-style: italic;
+}
+
+table.LC_docs_documents {
+ background: #BBBBBB;
+ border-width: 0px;
+ border-collapse: collapse;
+}
+
+table.LC_docs_documents td.LC_docs_document {
+ border: 2px solid black;
+ padding: 4px;
+}
+
+.LC_docs_course_commands div {
+ float: left;
+ border: 4px solid #AAAAAA;
+ padding: 4px;
+ background: #DDDDCC;
+}
+
+.LC_docs_entry_move {
+ border: 0px;
+ border-collapse: collapse;
+}
+
+.LC_docs_entry_move td {
+ border: 2px solid #BBBBBB;
+ background: #DDDDDD;
+}
+
+.LC_docs_editor td.LC_docs_entry_commands {
+ background: #DDDDDD;
+ font-size: x-small;
+}
+.LC_docs_copy {
+ color: #000099;
+}
+.LC_docs_cut {
+ color: #550044;
+}
+.LC_docs_rename {
+ color: #009900;
+}
+.LC_docs_remove {
+ color: #990000;
+}
+
+.LC_docs_reinit_warn,
+.LC_docs_ext_edit {
+ font-size: x-small;
+}
+
+.LC_docs_editor td.LC_docs_entry_title,
+.LC_docs_editor td.LC_docs_entry_icon {
+ background: #FFFFBB;
+}
+.LC_docs_editor td.LC_docs_entry_parameter {
+ background: #BBBBFF;
+ font-size: x-small;
+ white-space: nowrap;
+}
+
+table.LC_docs_adddocs td,
+table.LC_docs_adddocs th {
+ border: 1px solid #BBBBBB;
+ padding: 4px;
+ background: #DDDDDD;
}
END
@@ -4346,8 +4574,6 @@ END
=pod
-=over 4
-
=item * &headtag()
Returns a uniform footer for LON-CAPA web pages.
@@ -4371,8 +4597,6 @@ Inputs: $title - optional title for the
no_auto_mt_title
-> prevent &mt()ing the title arg
-=back
-
=cut
sub headtag {
@@ -4428,16 +4652,12 @@ ADDMETA
=pod
-=over 4
-
=item * &font_settings()
Returns neccessary to set the proper encoding
Inputs: none
-=back
-
=cut
sub font_settings {
@@ -4454,16 +4674,12 @@ sub font_settings {
=pod
-=over 4
-
=item * &xml_begin()
Returns the needed doctype and
Inputs: none
-=back
-
=cut
sub xml_begin {
@@ -4488,16 +4704,12 @@ sub xml_begin {
=pod
-=over 4
-
=item * &endheadtag()
Returns a uniform for LON-CAPA web pages.
Inputs: none
-=back
-
=cut
sub endheadtag {
@@ -4506,8 +4718,6 @@ sub endheadtag {
=pod
-=over 4
-
=item * &head()
Returns a uniform complete .. section for LON-CAPA web pages.
@@ -4515,8 +4725,6 @@ Returns a uniform complete ..
-=back
-
=cut
sub head {
@@ -4526,8 +4734,6 @@ sub head {
=pod
-=over 4
-
=item * &start_page()
Returns a complete .. section for LON-CAPA web pages.
@@ -4566,7 +4772,9 @@ Inputs: $title - optional title for the
no_auto_mt_title -> prevent &mt()ing the title arg
-=back
+ inherit_jsmath -> when creating popup window in a page,
+ should it have jsmath forced on by the
+ current page
=cut
@@ -4619,8 +4827,6 @@ sub start_page {
=pod
-=over 4
-
=item * &head()
Returns a complete section for LON-CAPA web pages.
@@ -4778,10 +4984,61 @@ sub simple_error_page {
}
}
+=pod
+
+=item * &inhibit_menu_check($arg)
+
+Checks for a inhibitmenu state and generates output to preserve it
+
+Inputs: $arg - can be any of
+ - undef - in which case the return value is a string
+ to add into arguments list of a uri
+ - 'input' - in which case the return value is a HTML
+
';
+ my $krb_msg = &mt('As you did not include the default Kerberos domain to be used for authentication in this class, the institutional data used by the automated enrollment process must include the Kerberos domain for each new student');
+ if ($context eq 'auto') {
+ $outcome .= $krb_msg;
+ } else {
+ $outcome .= ''.$krb_msg.' ';
+ }
+ $outcome .= $linefeed;
}
}
if (($args->{'ccdomain'}) && ($args->{'ccuname'})) {
@@ -6638,8 +7302,8 @@ sub construct_course {
# By default, use standard grading
if (!defined($cenv{'grading'})) { $cenv{'grading'} = 'standard'; }
- $outcome .= (' '.&mt('Setting environment').': '.
- &Apache::lonnet::put('environment',\%cenv,$$crsudom,$$crsunum).' ');
+ $outcome .= $linefeed.&mt('Setting environment').': '.
+ &Apache::lonnet::put('environment',\%cenv,$$crsudom,$$crsunum).$linefeed;
#
# Open all assignments
#
@@ -6649,7 +7313,7 @@ sub construct_course {
$storeunder.'.type' => 'date_start');
$outcome .= &mt('Opening all assignments').': '.&Apache::lonnet::cput
- ('resourcedata',\%storecontent,$$crsudom,$$crsunum).' ';
+ ('resourcedata',\%storecontent,$$crsudom,$$crsunum).$linefeed;
}
#
# Set first page
@@ -6676,9 +7340,10 @@ sub construct_course {
(my $outtext,$errtext) = &LONCAPA::map::storemap($map,1);
if ($errtext) { $fatal=2; }
- $outcome .= ($fatal?$errtext:'write ok').' ';
+ $outcome .= ($fatal?$errtext:'write ok').$linefeed;
}
- return $outcome;
+
+ return (1,$outcome);
}
############################################################
@@ -6721,10 +7386,27 @@ sub icon {
return &lonhttpdurl($iconname);
}
-sub lonhttpdurl {
- my ($url)=@_;
+sub lonhttpd_port {
my $lonhttpd_port=$Apache::lonnet::perlvar{'lonhttpdPort'};
if (!defined($lonhttpd_port)) { $lonhttpd_port='8080'; }
+ # IE doesn't like a secure page getting images from a non-secure
+ # port (when logging we haven't parsed the browser type so default
+ # back to secure
+ if ((!exists($env{'browser.type'}) || $env{'browser.type'} eq 'explorer')
+ && $ENV{'SERVER_PORT'} == 443) {
+ return 443;
+ }
+ return $lonhttpd_port;
+
+}
+
+sub lonhttpdurl {
+ my ($url)=@_;
+
+ my $lonhttpd_port = &lonhttpd_port();
+ if ($lonhttpd_port == 443) {
+ return 'https://'.$ENV{'SERVER_NAME'}.$url;
+ }
return 'http://'.$ENV{'SERVER_NAME'}.':'.$lonhttpd_port.$url;
}