--- loncom/homework/lonhomework.pm 2003/10/14 15:47:50 1.153 +++ loncom/homework/lonhomework.pm 2004/01/28 15:45:44 1.161 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.153 2003/10/14 15:47:50 albertel Exp $ +# $Id: lonhomework.pm,v 1.161 2004/01/28 15:45:44 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -24,11 +24,7 @@ # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ -# -# Guy Albertelli -# 11/30 Gerd Kortemeyer -# 6/1,8/17,8/18 Gerd Kortemeyer -# 7/18 Jeremy Bowers + package Apache::lonhomework; use strict; @@ -149,7 +145,7 @@ $Apache::lonxml::browse=''; sub check_ip_acc { my ($acc)=@_; - if (!defined($acc)) { return 1; } + if (!defined($acc) || $acc =~ /^\s*$/) { return 1; } my $allowed=0; my $ip=$ENV{'REMOTE_ADDR'}; my $name; @@ -174,7 +170,7 @@ sub check_ip_acc { use Socket; my $netaddr=inet_aton($ip); ($name)=gethostbyaddr($netaddr,AF_INET); - } + } if ($name =~ /\Q$pattern\E$/i) { $allowed=1; } } elsif ($pattern =~ /\d+\.\d+\.\d+\.\d+/) { #127.0.0.1 @@ -215,9 +211,9 @@ sub check_access { &Apache::lonxml::debug("time:".time); my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc")); - if (!$allowed) { + if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { $status='INVALID_ACCESS'; - $date=&mt("may be open from a different computer."); + $date=&mt("can not be accessed from your location."); return($status,$date); } @@ -379,6 +375,8 @@ sub handle_save_or_undo { my $filetmp =$file.".tmp"; my $error=0; + &Apache::lonnet::correct_line_ends($result); + if ($ENV{'form.Undo'} eq &mt('undo')) { my $error=0; if (!copy($file,$filetmp)) { $error=1; } @@ -526,8 +524,12 @@ sub editxmlmode { &renderpage($request,$file); } else { my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem); - my $xml_help = Apache::loncommon::helpLatexCheatsheet("Problem_Editor_XML_Index", - "Problem Editing Help"); + my $xml_help = '
'. + &Apache::loncommon::helpLatexCheatsheet("Problem_Editor_XML_Index", + "Problem Editing Help"). + ''. + &Apache::loncommon::help_open_faq(5). + &Apache::loncommon::help_open_bug('Authoring').'
'; if ($cols > 80) { $cols = 80; } if ($cols < 70) { $cols = 70; } if ($rows < 20) { $rows = 20; } @@ -555,6 +557,7 @@ sub renderpage { my ($request,$file) = @_; my (@targets) = &get_target(); + &Apache::lonhomework::showhashsubset(\%ENV,'form.'); &Apache::lonxml::debug("Running targets ".join(':',@targets)); foreach my $target (@targets) { #my $t0 = [&gettimeofday()]; @@ -642,12 +645,15 @@ sub newproblem { &renderpage($request,$dest); } else { my $url=$request->uri; + my $shownurl=$url; + $shownurl=~s-^/~-/priv/-; my $dest = &Apache::lonnet::filelocation("",$request->uri); my $errormsg; if ($ENV{'form.newfile'}) { $errormsg='

'.&mt('You did not select a template.').'

'."\n"; } my $instructions; + my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); if ($templatelist) { $instructions=&mt(", select a template from the pull-down menu below.").'
'.&mt("Then");} my %lt=&Apache::lonlocal::texthash( 'create' => 'Creating a new', 'resource' => 'resource', @@ -658,10 +664,10 @@ sub newproblem { 'Create' => 'Create', 'button' => 'button'); $request->print(< +$bodytag

$lt{'create'} $extension $lt{'resource'}

$errormsg -$lt{'requested'} $url $lt{'not exist'}. +$lt{'requested'} $shownurl $lt{'not exist'}.

$lt{'createnew'} $extension$instructions $lt{'click'} "$lt{'Create'} $extension" $lt{'button'}.

@@ -700,7 +706,6 @@ sub handler { my $request=$_[0]; $Apache::lonxml::debug=$ENV{'user.debug'}; - if (&setupheader($request)) { return OK; } $ENV{'request.uri'}=$request->uri;