[LON-CAPA-cvs] cvs: rat / lonpage.pm lonratedt.pm lonuserstate.pm loncom/auth lonroles.pm
www
lon-capa-cvs@mail.lon-capa.org
Tue, 30 May 2006 17:15:11 -0000
This is a MIME encoded message
--www1149009311
Content-Type: text/plain
www Tue May 30 13:15:11 2006 EDT
Modified files:
/loncom/auth lonroles.pm
/rat lonpage.pm lonratedt.pm lonuserstate.pm
Log:
Bug #4370: better warning if there are errors during course initialization,
e.g., a map included more than once.
--www1149009311
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20060530131511.txt"
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.149 loncom/auth/lonroles.pm:1.150
--- loncom/auth/lonroles.pm:1.149 Tue May 30 08:45:24 2006
+++ loncom/auth/lonroles.pm Tue May 30 13:15:00 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.149 2006/05/30 12:45:24 www Exp $
+# $Id: lonroles.pm,v 1.150 2006/05/30 17:15:00 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -77,6 +77,21 @@
return;
}
+sub error_page {
+ my ($r,$error,$dest)=@_;
+ &Apache::loncommon::content_type($r,'text/html');
+ &Apache::loncommon::no_cache($r);
+ $r->send_http_header;
+ return OK if $r->header_only;
+ $r->print(&Apache::loncommon::start_page('Problems during Course Initialization').
+ '<script type="text/javascript">'.
+ &Apache::lonmenu::rawconfig().'</script>'.
+ '<p>'.&mt('The following problems occurred:').
+ $error.
+ '</p><br /><a href="'.$dest.'>'.&mt('Continue').'</a>'.
+ &Apache::loncommon::end_page());
+}
+
sub handler {
my $r = shift;
@@ -242,7 +257,11 @@
my $dest=$env{'form.orgurl'};
if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
&Apache::lonnet::appenv('request.role.adv'=>$tadv);
- $r->internal_redirect($dest);
+ if (($ferr) && ($tadv)) {
+ &error_page($r,$ferr,$dest);
+ } else {
+ $r->internal_redirect($dest);
+ }
return OK;
} else {
unless ($env{'request.course.id'}) {
@@ -256,38 +275,41 @@
}
if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
&Apache::lonnet::appenv('request.role.adv'=>$tadv);
-
- # Check to see if the user is a CC entering a course
- # for the first time
- my (undef, undef, $role, $courseid) = split(/\./, $envkey);
- if (substr($courseid, 0, 1) eq '/') {
- $courseid = substr($courseid, 1);
- }
- $courseid =~ s/\//_/;
- if ($role eq 'cc' && $env{'course.' . $courseid .
- '.course.helper.not.run'}) {
- $furl = "/adm/helper/course.initialization.helper";
- # Send the user to the course they selected
- } elsif ($env{'request.course.id'}) {
- if (&Apache::lonnet::allowed('whn',
- $env{'request.course.id'})
- || &Apache::lonnet::allowed('whn',
- $env{'request.course.id'}.'/'
- .$env{'request.course.sec'})
- ) {
- my $startpage = &courseloadpage($courseid);
- unless ($startpage eq 'firstres') {
- $msg = &mt('Entering course ....');
- &redirect_user($r,&mt('New in course'),
- '/adm/whatsnew?refpage=start',$msg,
- $env{'environment.remotenavmap'});
- return OK;
- }
- }
+ if (($ferr) && ($tadv)) {
+ &error_page($r,$ferr,$furl);
+ } else {
+ # Check to see if the user is a CC entering a course
+ # for the first time
+ my (undef, undef, $role, $courseid) = split(/\./, $envkey);
+ if (substr($courseid, 0, 1) eq '/') {
+ $courseid = substr($courseid, 1);
+ }
+ $courseid =~ s/\//_/;
+ if ($role eq 'cc' && $env{'course.' . $courseid .
+ '.course.helper.not.run'}) {
+ $furl = "/adm/helper/course.initialization.helper";
+ # Send the user to the course they selected
+ } elsif ($env{'request.course.id'}) {
+ if (&Apache::lonnet::allowed('whn',
+ $env{'request.course.id'})
+ || &Apache::lonnet::allowed('whn',
+ $env{'request.course.id'}.'/'
+ .$env{'request.course.sec'})
+ ) {
+ my $startpage = &courseloadpage($courseid);
+ unless ($startpage eq 'firstres') {
+ $msg = &mt('Entering course ....');
+ &redirect_user($r,&mt('New in course'),
+ '/adm/whatsnew?refpage=start',$msg,
+ $env{'environment.remotenavmap'});
+ return OK;
+ }
+ }
+ }
+ &redirect_user($r,&mt('Entering Course'),
+ $furl,$msg,
+ $env{'environment.remotenavmap'});
}
- &redirect_user($r,&mt('Entering Course'),
- $furl,$msg,
- $env{'environment.remotenavmap'});
return OK;
}
}
@@ -395,20 +417,10 @@
}
# -------------------------------------------------------- Choice or no choice?
if ($nochoose) {
- if ($advanced) {
- $r->print("<h2>".&mt('Assigned User Roles')."</h2>\n");
- } else {
- $r->print("<h2>".&mt('Sorry ...')."</h2>\n".
- &mt('This resource might be part of'));
- if ($env{'request.course.id'}) {
- $r->print(&mt(' another'));
- } else {
- $r->print(&mt(' a certain'));
- }
- $r->print(&mt(' course.').
- &Apache::loncommon::end_page());
- return OK;
- }
+ $r->print("<h2>".&mt('Sorry ...')."</h2>\n".
+ &mt('This action is currently not authorized.').
+ &Apache::loncommon::end_page());
+ return OK;
} else {
if ($advanced) {
$r->print(&mt("Your home server is ").
Index: rat/lonpage.pm
diff -u rat/lonpage.pm:1.74 rat/lonpage.pm:1.75
--- rat/lonpage.pm:1.74 Tue Apr 4 15:54:51 2006
+++ rat/lonpage.pm Tue May 30 13:15:10 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Page Handler
#
-# $Id: lonpage.pm,v 1.74 2006/04/04 19:54:51 albertel Exp $
+# $Id: lonpage.pm,v 1.75 2006/05/30 17:15:10 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,6 +39,9 @@
use HTML::TokeParser;
use GDBM_File;
use Apache::lonsequence;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+
# -------------------------------------------------------------- Module Globals
my %hash;
@@ -426,13 +429,13 @@
$esrc=&Apache::lonenc::encrypted($esrc);
}
unless ($hash{'src_'.$rid} =~ m-^/uploaded/-) {
- $metainfo ='<a name="'.&Apache::lonnet::escape($symb).'" />'.
+ $metainfo ='<a name="'.&escape($symb).'" />'.
'<a href="'.$metalink{$rid}.'" target="LONcatInfo">'.
'<img src="/adm/lonMisc/cat_button.gif" border=0>'.
'</img></a>';
}
$metainfo .= '<a href="/adm/evaluate?postdata='.
- &Apache::lonnet::escape($esrc).
+ &escape($esrc).
'" target="LONcatInfo">'.
'<img src="/adm/lonMisc/eval_button.gif" border=0>'.
'</img></a>';
@@ -446,17 +449,17 @@
'___'.$resid.'___'.
&Apache::lonnet::declutter($hash{'src_'.$rid});
$metainfo.=
- '<a href="/adm/grades?symb='.&Apache::lonnet::escape($symb).
+ '<a href="/adm/grades?symb='.&escape($symb).
# '&command=submission" target="LONcatInfo">'.
'&command=submission">'.
'<img src="/adm/lonMisc/subm_button.gif" border=0>'.
'</img></a>'.
- '<a href="/adm/grades?symb='.&Apache::lonnet::escape($symb).
+ '<a href="/adm/grades?symb='.&escape($symb).
# '&command=gradingmenu" target="LONcatInfo">'.
'&command=gradingmenu">'.
'<img src="/adm/lonMisc/pgrd_button.gif" border=0>'.
'</img></a>'.
- '<a href="/adm/parmset?symb='.&Apache::lonnet::escape($symb).
+ '<a href="/adm/parmset?symb='.&escape($symb).
# '" target="LONcatInfo">'.
'" >'.
'<img src="/adm/lonMisc/pprm_button.gif" border=0>'.
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.77 rat/lonratedt.pm:1.78
--- rat/lonratedt.pm:1.77 Tue May 23 14:31:13 2006
+++ rat/lonratedt.pm Tue May 30 13:15:10 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Edit Handler for RAT Maps
#
-# $Id: lonratedt.pm,v 1.77 2006/05/23 18:31:13 albertel Exp $
+# $Id: lonratedt.pm,v 1.78 2006/05/30 17:15:10 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -172,6 +172,9 @@
use Apache::loncommon;
use Apache::lonlocal;
use File::Copy;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+
use vars qw(@order @resources @resparms @zombies);
@@ -488,8 +491,8 @@
foreach (@which) {
if (defined($_)) {
my ($name,$url)=split(/\=/,$_);
- $name=&Apache::lonnet::unescape($name);
- $url=&Apache::lonnet::unescape($url);
+ $name=&unescape($name);
+ $url=&unescape($url);
if ($url) {
my $idx=&getresidx($url);
$insertorder[$#insertorder+1]=$idx;
@@ -871,8 +874,8 @@
&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
my ($name,$url)=split(/\:/,$_);
if ($url) {
- $importdetail.='&'.&Apache::lonnet::escape($name).'='.
- &Apache::lonnet::escape($url);
+ $importdetail.='&'.&escape($name).'='.
+ &escape($url);
}
}
@@ -918,8 +921,8 @@
foreach (@targetselect) {
my ($name,$url)=split(/\:/,$resources[$order[$_-1]]);
if ($url) {
- $importdetail.='&'.&Apache::lonnet::escape($name).'='.
- &Apache::lonnet::escape($url);
+ $importdetail.='&'.&escape($name).'='.
+ &escape($url);
}
}
@@ -1006,7 +1009,7 @@
my ($name,$url)=split(/\=/,$_);
unless ($name) { $name=(split(/\//,$url))[-1]; }
unless ($name) { $name='EMPTY'; }
- '<option value="'.$idx.'">'.&Apache::lonnet::unescape($name).
+ '<option value="'.$idx.'">'.&unescape($name).
'</option>';
}
} split(/\&/,$importdetail));
@@ -1019,8 +1022,8 @@
my ($name,$url)=split(/\:/,$resources[$_]);
unless ($name) { $name=(split(/\//,$url))[-1]; }
unless ($name) { $name='EMPTY'; }
- $targetdetail.='&'.&Apache::lonnet::escape($name).'='.
- &Apache::lonnet::escape($url);
+ $targetdetail.='&'.&escape($name).'='.
+ &escape($url);
$idx++;
$name=~s/\:/\:/g;
'<option value="'.$idx.'">'.$name.'</option>';
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.113 rat/lonuserstate.pm:1.114
--- rat/lonuserstate.pm:1.113 Thu May 25 17:09:45 2006
+++ rat/lonuserstate.pm Tue May 30 13:15:10 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Construct and maintain state and binary representation of course for user
#
-# $Id: lonuserstate.pm,v 1.113 2006/05/25 21:09:45 albertel Exp $
+# $Id: lonuserstate.pm,v 1.114 2006/05/30 17:15:10 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,6 +33,7 @@
use strict;
use HTML::TokeParser;
use Apache::lonnet;
+use Apache::lonlocal;
use Apache::loncommon();
use GDBM_File;
use Apache::lonmsg;
@@ -41,6 +42,9 @@
use Opcode;
use Apache::lonenc;
use Fcntl qw(:flock);
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+
# ---------------------------------------------------- Globals for this package
@@ -103,8 +107,10 @@
sub loadmap {
my $uri=shift;
- if ($hash{'map_pc_'.$uri}) { return; }
-
+ if ($hash{'map_pc_'.$uri}) {
+ $errtext.=&mt('<br />Multiple use of sequence/page <tt>[_1]</tt>! The course will not function properly.',$uri);
+ return;
+ }
$pc++;
my $lpc=$pc;
$hash{'map_pc_'.$uri}=$lpc;
@@ -117,7 +123,7 @@
unless (($fn=~/\.sequence$/) ||
($fn=~/\.page$/)) {
- $errtext.="Invalid map: $fn\n";
+ $errtext.=&mt("<br />Invalid map: <tt>[_1]</tt>",$fn);
return;
}
@@ -277,9 +283,9 @@
}
$name=~s/^.*_([^_]*)$/$1/;
my $newparam=
- &Apache::lonnet::escape($token->[2]->{'type'}).':'.
- &Apache::lonnet::escape($part.'.'.$name).'='.
- &Apache::lonnet::escape($token->[2]->{'value'});
+ &escape($token->[2]->{'type'}).':'.
+ &escape($part.'.'.$name).'='.
+ &escape($token->[2]->{'value'});
if (defined($hash{'param_'.$referid})) {
$hash{'param_'.$referid}.='&'.$newparam;
} else {
@@ -310,7 +316,7 @@
}
} else {
- $errtext.='Map not loaded: The file ('.$fn.') does not exist. ';
+ $errtext.=&mt('<br />Map not loaded: The file <tt>[_1]</tt> does not exist.',$fn);
}
}
@@ -390,8 +396,7 @@
$further=simplify('('.'_'.$rid.')&('.
$hash{'condid_'.$hash{'undercond_'.$id}}.')');
} else {
- $errtext.='Undefined condition ID: '
- .$hash{'undercond_'.$id}.'. ';
+ $errtext.=&mt('<br />Undefined condition ID: [_1]',$hash{'undercond_'.$id});
}
}
$newsofar=&traceroute($further,$hash{'goesto_'.$id},$beenhere,
@@ -438,10 +443,10 @@
foreach my $param (split(/\&/,$hash{$key})) {
my ($typename,$value)=split(/\=/,$param);
my ($type,$name)=split(/\:/,$typename);
- $parmhash{$prefix.'.'.&Apache::lonnet::unescape($name)}=
- &Apache::lonnet::unescape($value);
- $parmhash{$prefix.'.'.&Apache::lonnet::unescape($name).'.type'}=
- &Apache::lonnet::unescape($type);
+ $parmhash{$prefix.'.'.&unescape($name)}=
+ &unescape($value);
+ $parmhash{$prefix.'.'.&unescape($name).'.type'}=
+ &unescape($type);
}
}
}
@@ -552,7 +557,7 @@
unless ($uri=$cenv{'url'}) {
&Apache::lonnet::logthis("<font color=blue>WARNING: ".
"Could not load course $short.</font>");
- return 'No course data available.';
+ return ('',&mt('No course data available.'));;
}
@cond=('true:normal');
--www1149009311--