[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm /xml lonxml.pm
www
lon-capa-cvs-allow@mail.lon-capa.org
Tue, 10 Jun 2008 16:20:40 -0000
www Tue Jun 10 12:20:40 2008 EDT
Modified files:
/loncom/homework default_homework.lcpm
/loncom/xml lonxml.pm
Log:
The &due_date, etc, functions now return correct timezones and languages.
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.134 loncom/homework/default_homework.lcpm:1.135
--- loncom/homework/default_homework.lcpm:1.134 Thu May 29 21:16:04 2008
+++ loncom/homework/default_homework.lcpm Tue Jun 10 12:20:29 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
#
-# $Id: default_homework.lcpm,v 1.134 2008/05/30 01:16:04 www Exp $
+# $Id: default_homework.lcpm,v 1.135 2008/06/10 16:20:29 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1024,46 +1024,28 @@
return $sec;
}
+sub eval_time {
+ my ($timestamp)=@_;
+ unless ($timestamp) { return ''; }
+ return &locallocaltime($timestamp);
+}
+
sub open_date {
my ($partid)=@_;
unless ($partid) { $partid=0; }
- my @dc = split(/\s+/,localtime(&EXT('resource.'.$partid.'.opendate')));
- return '' if ($dc[0] eq "Wed" and $dc[2] == 31 and $dc[4] == 1969);
- my @hm = split(/:/,$dc[3]);
- my $ampm = " am";
- if ($hm[0] > 12) {
- $hm[0]-=12;
- $ampm = " pm";
- }
- return $dc[0].', '.$dc[1].' '.$dc[2].', '.$dc[4].' at '.$hm[0].':'.$hm[1].$ampm;
+ return &eval_time(&EXT('resource.'.$partid.'.opendate'));
}
sub due_date {
my ($partid)=@_;
unless ($partid) { $partid=0; }
- my @dc = split(/\s+/,localtime(&EXT('resource.'.$partid.'.duedate')));
- return '' if ($dc[0] eq "Wed" and $dc[2] == 31 and $dc[4] == 1969);
- my @hm = split(/:/,$dc[3]);
- my $ampm = " am";
- if ($hm[0] > 12) {
- $hm[0]-=12;
- $ampm = " pm";
- }
- return $dc[0].', '.$dc[1].' '.$dc[2].', '.$dc[4].' at '.$hm[0].':'.$hm[1].$ampm;
+ return &eval_time(&EXT('resource.'.$partid.'.duedate'));
}
sub answer_date {
my ($partid)=@_;
unless ($partid) { $partid=0; }
- my @dc = split(/\s+/,localtime(&EXT('resource.'.$partid.'.answerdate')));
- return '' if ($dc[0] eq "Wed" and $dc[2] == 31 and $dc[4] == 1969);
- my @hm = split(/:/,$dc[3]);
- my $ampm = " am";
- if ($hm[0] > 12) {
- $hm[0]-=12;
- $ampm = " pm";
- }
- return $dc[0].', '.$dc[1].' '.$dc[2].', '.$dc[4].' at '.$hm[0].':'.$hm[1].$ampm;
+ return &eval_time(&EXT('resource.'.$partid.'.answerdate'));
}
sub array_moments {
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.479 loncom/xml/lonxml.pm:1.480
--- loncom/xml/lonxml.pm:1.479 Thu May 29 11:43:01 2008
+++ loncom/xml/lonxml.pm Tue Jun 10 12:20:39 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.479 2008/05/29 15:43:01 bisitz Exp $
+# $Id: lonxml.pm,v 1.480 2008/06/10 16:20:39 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -718,6 +718,7 @@
$safeeval->permit(":base_math");
$safeeval->permit("sort");
$safeeval->permit("time");
+ $safeeval->permit("caller");
$safeeval->deny("rand");
$safeeval->deny("srand");
$safeeval->deny(":base_io");
@@ -737,6 +738,9 @@
$safehole->wrap(\&Apache::caparesponse::capa_formula_fix,$safeeval,
'&capa_formula_fix');
+ $safehole->wrap(\&Apache::lonlocal::locallocaltime,$safeeval,
+ '&locallocaltime');
+
$safehole->wrap(\&Math::Cephes::asin,$safeeval,'&asin');
$safehole->wrap(\&Math::Cephes::acos,$safeeval,'&acos');
$safehole->wrap(\&Math::Cephes::atan,$safeeval,'&atan');