[LON-CAPA-cvs] cvs: loncom /homework lonhomework.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 18 Sep 2003 20:32:29 -0000
This is a MIME encoded message
--albertel1063917149
Content-Type: text/plain
albertel Thu Sep 18 16:32:29 2003 EDT
Modified files:
/loncom/homework lonhomework.pm
Log:
- getting in on the localization thing
- it compiles, and runs for the most part
--albertel1063917149
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20030918163229.txt"
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.145 loncom/homework/lonhomework.pm:1.146
--- loncom/homework/lonhomework.pm:1.145 Thu Sep 18 15:59:15 2003
+++ loncom/homework/lonhomework.pm Thu Sep 18 16:32:29 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.145 2003/09/18 19:59:15 albertel Exp $
+# $Id: lonhomework.pm,v 1.146 2003/09/18 20:32:29 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -54,6 +54,7 @@
use Apache::Constants qw(:common);
use HTML::Entities();
use Apache::loncommon();
+use Apache::lonlocal;
#use Time::HiRes qw( gettimeofday tv_interval );
BEGIN {
@@ -161,7 +162,7 @@
if ($ENV{'request.state'} eq "construct") {
&Apache::lonxml::debug("in construction ignoring dates");
$status='CAN_ANSWER';
- $datemsg='is in under construction';
+ $datemsg=&mt('is in under construction');
return ($status,$datemsg);
}
@@ -174,7 +175,7 @@
if ($thistype =~ /^(con_lost|no_such_host)/ ||
$date =~ /^(con_lost|no_such_host)/) {
$status='UNAVAILABLE';
- $date="may open later.";
+ $date=&mt("may open later.");
return($status,$date);
}
if ($thistype eq 'date_interval') {
@@ -187,9 +188,9 @@
}
&Apache::lonxml::debug("found :$date: for :$temp:");
if ($date eq '') {
- $date = "an unknown date"; $passed = 0;
+ $date = &mt("an unknown date"); $passed = 0;
} elsif ($date eq 'con_lost') {
- $date = "an indeterminate date"; $passed = 0;
+ $date = &mt("an indeterminate date"); $passed = 0;
} else {
if (time < $date) { $passed = 0; } else { $passed = 1; }
$date = localtime $date;
@@ -202,13 +203,13 @@
$datemsg=$date;
} elsif ($type eq 'opendate') {
$status='CLOSED';
- $datemsg = "will open on $date";
+ $datemsg = &mt("will open on")." $date";
} elsif ($type eq 'duedate') {
$status='CAN_ANSWER';
- $datemsg = "is due at $date";
+ $datemsg = &mt("is due at")." $date";
} elsif ($type eq 'answerdate') {
$status='CLOSED';
- $datemsg = "was due on $lastdate, and answers will be available on $date";
+ $datemsg = &mt("was due on")." $lastdate".&mt(", and answers will be available on")." $date";
}
if ($status eq 'CAN_ANSWER') {
#check #tries, and if correct.
@@ -237,7 +238,7 @@
if (($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED')) {
&Apache::lonxml::debug("should be allowed to browse a resource when closed");
$status='CAN_ANSWER';
- $datemsg='is closed but you are allowed to view it';
+ $datemsg=&mt('is closed but you are allowed to view it');
}
return ($status,$datemsg);
@@ -332,26 +333,29 @@
if ((!$error) && (!copy($filebak,$file))) { $error=1; }
if ((!$error) && (!move($filetmp,$filebak))) { $error=1; }
if (!$error) {
- $request->print("<p><b>Undid changes, Switched $filebak and $file</b></p>");
+ $request->print("<p><b>".&mt("Undid changes, Switched")." $filebak ".&mt("and")." $file</b></p>");
} else {
- $request->print("<p><font color=\"red\" size=\"+1\"><b>Unable to undo, unable to switch $filebak and $file</b></font></p>");
+ $request->print("<p><font color=\"red\" size=\"+1\"><b>".&mt("Unable to undo, unable to switch")." $filebak ".&mt("and")." $file</b></font></p>");
$error=1;
}
} else {
my $fs=Apache::File->new(">$filebak");
if (defined($fs)) {
print $fs $$problem;
- $request->print("<b>Making Backup to $filebak</b><br />");
+ $request->print("<b>".&mt("Making Backup to").
+ " $filebak</b><br />");
} else {
- $request->print("<font color=\"red\" size=\"+1\"><b>Unable to make backup $filebak</b></font>");
+ $request->print("<font color=\"red\" size=\"+1\"><b>".&mt("Unable to make backup")." $filebak</b></font>");
$error=2;
}
my $fh=Apache::File->new(">$file");
if (defined($fh)) {
print $fh $$result;
- $request->print("<b>Saving Modifications to $file</b><br />");
+ $request->print("<b>".&mt("Saving Modifications to").
+ " $file</b><br />");
} else {
- $request->print("<font color=\"red\" size=\"+1\"><b>Unable to write to $file</b></font>");
+ $request->print("<font color=\"red\" size=\"+1\"><b>".
+ &mt("Unable to write to")." $file</b></font>");
$error|=4;
}
}
@@ -361,16 +365,16 @@
sub analyze_header {
my ($request) = @_;
my $result.='<html>
- <head><title>Analyzing a problem</title></head>
+ <head><title>'.&mt("Analyzing a problem").'</title></head>
<body bgcolor="#FFFFFF">
<form name="lonhomework" method="POST" action="'.
$ENV{'request.uri'}.'">
- <input type="submit" name="problemmode" value="EditXML" />
- <input type="submit" name="problemmode" value="Edit" />
+ <input type="submit" name="problemmode" value="'.&mt("EditXML").'" />
+ <input type="submit" name="problemmode" value="'.&mt('Edit').'" />
<hr />
- <input type="submit" name="submit" value="View" />
+ <input type="submit" name="submit" value="'.&mt("View").'" />
<hr />
- List of possible answers:
+ '.&mt('List of possible answers').':
</form>';
$request->print($result);
$request->rflush();
@@ -392,12 +396,12 @@
my $rndseed=$ENV{'form.rndseed'};
&analyze_header($request);
my %prog_state=
- &Apache::lonhtmlcommon::Create_PrgWin($request,'Analyze Progress',
- 'Getting Problem Variants',
+ &Apache::lonhtmlcommon::Create_PrgWin($request,&mt('Analyze Progress'),
+ &mt('Getting Problem Variants'),
$ENV{'form.numtoanalyze'});
for(my $i=1;$i<$ENV{'form.numtoanalyze'}+1;$i++) {
&Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state,
- 'last problem');
+ &mt('last problem'));
my $subresult=&Apache::lonnet::ssi($request->uri,
('grade_target' => 'analyze'),
('rndseed' => $i+$rndseed));
@@ -418,16 +422,16 @@
}
}
&Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state,
- 'Analyzing Results');
+ &mt('Analyzing Results'));
foreach my $part (sort(keys(%allparts))) {
if (defined(@{ $overall{$part.'.answer'} })) {
my $num_cols=scalar(@{ $overall{$part.'.answer'}->[0] });
- $request->print('<table><tr><td colspan="'.($num_cols+1).'">Part '.$part.'</td></tr>');
+ $request->print('<table><tr><td colspan="'.($num_cols+1).'">'.&mt('Part').' '.$part.'</td></tr>');
my %frequency;
foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) {
$frequency{join("\0",@{ $answer })}++;
}
- $request->print('<tr><td colspan="'.($num_cols).'">Answer</td><td>Frequency</td></tr>');
+ $request->print('<tr><td colspan="'.($num_cols).'">'.&mt('Answer').'</td><td>'.&mt('Frequency').'</td></tr>');
foreach my $answer (sort {(split("\0",$a))[0] <=> (split("\0",$b))[0]} (keys(%frequency))) {
$request->print('<tr><td align="right">'.
join('</td><td align="right">',split("\0",$answer)).
@@ -436,14 +440,14 @@
}
$request->print('</table>');
} else {
- $request->print('<p>Part '.$part.
- ' is not analyzable at this time</p>');
+ $request->print('<p>'.&mt('Part').' '.$part.' '.
+ &mt('is not analyzable at this time').'</p>');
}
}
if (scalar(keys(%allparts)) == 0 ) {
- $request->print('<p>Found no analyzable parts in this problem,
+ $request->print('<p>'.&mt('Found no analyzable parts in this problem,
currently only Numerical, Formula and String response
- styles are supported.</p>');
+ styles are supported.').'</p>');
}
&Apache::lonhtmlcommon::Close_PrgWin($request,\%prog_state);
&analyze_footer($request);
@@ -456,7 +460,8 @@
my $result;
my $problem=&Apache::lonnet::getfile($file);
if ($problem eq -1) {
- &Apache::lonxml::error("<b> Unable to find <i>$file</i></b>");
+ &Apache::lonxml::error("<b> ".&mt('Unable to find').
+ " <i>$file</i></b>");
$problem='';
}
if (defined($ENV{'form.editxmltext'}) || defined($ENV{'form.Undo'})) {
@@ -479,13 +484,13 @@
$result.='<html><body bgcolor="#FFFFFF">
<form name="lonhomework" method="POST" action="'.
$ENV{'request.uri'}.'">
- <input type="hidden" name="problemmode" value="EditXML" />
- <input type="submit" name="problemmode" value="Discard Edits and View" />
- <input type="submit" name="problemmode" value="Edit" />
+ <input type="hidden" name="problemmode" value="'.&mt('EditXML').'" />
+ <input type="submit" name="problemmode" value="'.&mt('Discard Edits and View').'" />
+ <input type="submit" name="problemmode" value="'.&mt('Edit').'" />
<hr />
- <input type="submit" name="submit" value="Submit Changes" />
- <input type="submit" name="submit" value="Submit Changes and View" />
- <input type="submit" name="Undo" value="undo" />
+ <input type="submit" name="submit" value="'.&mt('Submit Changes').'" />
+ <input type="submit" name="submit" value="'.&mt('Submit Changes and View').'" />
+ <input type="submit" name="Undo" value="'.&mt('undo').'" />
<hr />
' . $xml_help . '
<textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'.
@@ -505,7 +510,7 @@
#my $t0 = [&gettimeofday()];
my $problem=&Apache::lonnet::getfile($file);
if ($problem eq -1) {
- &Apache::lonxml::error("<b> Unable to find <i>$file</i></b>");
+ &Apache::lonxml::error("<b> ".&mt('Unable to find')." <i>$file</i></b>");
$problem='';
}
@@ -557,7 +562,7 @@
}
}
if (@allnames && !$result) {
- $result="<option>Select a $extension template</option>\n<option>".
+ $result="<option>".&mt("Select a")." $extension ".&mt('template')."</option>\n<option>".
join('</option><option>',sort(@allnames)).'</option>';
}
return $result;
@@ -590,24 +595,32 @@
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";
+ $errormsg='<p><font color="red">'.&mt('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";}
+ if ($templatelist) { $instructions=&mt(", select a template from the pull-down menu below.").'<br />'.&mt("Then");}
+ my %lt=&texthash( 'create' => 'Creating a new',
+ 'resource' => 'resource',
+ 'requested' => 'The requested file',
+ 'not exist' => 'currently does not exist',
+ 'createnew' => 'To create a new',
+ 'click' => 'click on the',
+ 'Create' => 'Create',
+ 'button' => 'button');
$request->print(<<ENDNEWPROBLEM);
<body bgcolor="#FFFFFF">
-<h1>Creating a new $extension resource</h1>
+<h1>$lt{'create'} $extension <{'resource'}</h1>
$errormsg
-The requested file <tt>$url</tt> currently does not exist.
+$lt{'requested'} <tt>$url</tt> $lt{'not exist'}.
<p>
-<b>To create a new $extension$instructions click on the "Create $extension" button.</b>
+<b>$lt{'createnew'} $extension$instructions $lt{'click'} "$lt{'Create'} $extension" $lt{'button'}.</b>
</p>
<p><form action="$url" method="POST">
ENDNEWPROBLEM
if (defined($templatelist)) {
$request->print("<select name=\"template\">$templatelist</select>");
}
- $request->print("<br /><input type=\"submit\" name=\"newfile\" value=\"Create $extension\" />");
+ $request->print("<br /><input type=\"submit\" name=\"newfile\" value=\"".&mt('Create')." $extension\" />");
$request->print("</form></p></body>");
}
return '';
@@ -616,11 +629,17 @@
sub view_or_edit_menu {
my ($request) = @_;
my $url=$request->uri;
+ my %lt=&texthash( 'would' => 'Would you like to',
+ 'view' => 'View',
+ 'Edit' => 'edit',
+ 'or' => 'or',
+ 'the problem' => 'the problem');
$request->print(<<EDITMENU);
<body bgcolor="#FFFFFF">
<form action="$url" method="POST">
-Would you like to <input type="submit" name="problemmode" value="View"> or
-<input type="submit" name="problemmode" value="Edit"> the problem.
+$lt{'would'} <input type="submit" name="problemmode" value="<{'view'}">
+<{'or'} <input type="submit" name="problemmode" value="<{'Edit'}">
+<{'the problem'}.
</form>
</body>
EDITMENU
--albertel1063917149--