[LON-CAPA-cvs] cvs: loncom /homework lonhomework.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 16 May 2003 17:41:17 -0000
albertel Fri May 16 13:41:17 2003 EDT
Modified files:
/loncom/homework lonhomework.pm
Log:
- fixes #1449, selecting no problem template throws an error message and asks again.
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.127 loncom/homework/lonhomework.pm:1.128
--- loncom/homework/lonhomework.pm:1.127 Wed May 14 13:16:20 2003
+++ loncom/homework/lonhomework.pm Fri May 16 13:41:17 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.127 2003/05/14 17:16:20 matthew Exp $
+# $Id: lonhomework.pm,v 1.128 2003/05/16 17:41:17 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -547,7 +547,7 @@
}
if (@allnames && !$result) {
$result="<option>Select a $extension template</option>\n<option>".
- join('</option><option>',sort(@allnames)).'</option>';
+ join('</option><option>',sort(@allnames)).'</option>';
}
return $result;
}
@@ -558,33 +558,29 @@
$extension=~s:^.*\.([\w]+)$:$1:;
&Apache::lonxml::debug("Looking for :$extension:");
if ($ENV{'form.template'} &&
- $ENV{'form.template'} ne "Select a $extension type") {
+ $ENV{'form.template'} ne "Select a $extension template") {
use File::Copy;
my $file = &get_template_list($ENV{'form.template'},$extension);
my $dest = &Apache::lonnet::filelocation("",$request->uri);
copy($file,$dest);
&renderpage($request,$dest);
- } elsif($ENV{'form.newfile'}) {
- # I don't like hard-coded filenames but for now, this will work.
- use File::Copy;
- my $templatefilename =
- $request->dir_config('lonIncludes').'/templates/blank.problem';
- &Apache::lonxml::debug("$templatefilename");
- my $dest = &Apache::lonnet::filelocation("",$request->uri);
- copy($templatefilename,$dest);
- &renderpage($request,$dest);
} else {
my $templatelist=&get_template_list('',$extension);
my $url=$request->uri;
my $dest = &Apache::lonnet::filelocation("",$request->uri);
+ my $errormsg;
+ if ($ENV{'form.newfile'}) {
+ $errormsg='<p><font color="red">You did not select a template.</font></p>'."\n";
+ }
my $instructions;
if ($templatelist) { $instructions=", select a template from the pull-down menu below.<br />Then";}
$request->print(<<ENDNEWPROBLEM);
<body bgcolor="#FFFFFF">
<h1>Creating a new $extension resource</h1>
+$errormsg
The requested file <tt>$url</tt> currently does not exist.
<p>
-To create a new $extension$instructions click on the "Create $extension" button.
+<b>To create a new $extension$instructions click on the "Create $extension" button.</b>
</p>
<p><form action="$url" method="POST">
ENDNEWPROBLEM