[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm
www
lon-capa-cvs@mail.lon-capa.org
Sat, 07 Sep 2002 17:30:32 -0000
This is a MIME encoded message
--www1031419832
Content-Type: text/plain
www Sat Sep 7 13:30:32 2002 EDT
Modified files:
/loncom/interface lonparmset.pm
Log:
Toward bug 729. Also prints intervals now in &valout
--www1031419832
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20020907133032.txt"
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.65 loncom/interface/lonparmset.pm:1.66
--- loncom/interface/lonparmset.pm:1.65 Wed Aug 28 15:48:57 2002
+++ loncom/interface/lonparmset.pm Sat Sep 7 13:30:31 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.65 2002/08/28 19:48:57 albertel Exp $
+# $Id: lonparmset.pm,v 1.66 2002/09/07 17:30:31 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -201,7 +201,30 @@
if (! $value && $value ne '0') {
$result = ' ';
} else {
- if ($type=~/^date/) {
+ if ($type eq 'date_interval') {
+ my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
+ $year=$year-70;
+ $mday--;
+ if ($year) {
+ $result.=$year.' yrs ';
+ }
+ if ($mon) {
+ $result.=$mon.' mths ';
+ }
+ if ($mday) {
+ $result.=$mday.' days ';
+ }
+ if ($hour) {
+ $result.=$hour.' hrs ';
+ }
+ if ($min) {
+ $result.=$min.' mins ';
+ }
+ if ($sec) {
+ $result.=$sec.' secs ';
+ }
+ $result=~s/\s+$//;
+ } elsif ($type=~/^date/) {
$result = localtime($value);
} else {
$result = $value;
@@ -332,10 +355,27 @@
}
sub print_row {
- my ($r,$which,$part,$name,$rid,$default,$type,$display,$defbgone,
+ my ($r,$which,$part,$name,$rid,$default,$defaulttype,$display,$defbgone,
$defbgtwo,$parmlev)=@_;
+# get the values for the parameter in cascading order
+# empty levels will remain empty
my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
$rid,$$default{$which});
+# get the type for the parameters
+# problem: these may not be set for all levels
+ my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
+ $$name{$which}.'.type',
+ $rid,$$defaulttype{$which});
+# cascade down manually
+ my $cascadetype=$defaulttype;
+ for (my $i=$#typeoutpar;$i>0;$i--) {
+ if ($typeoutpar[$i]) {
+ $cascadetype=$typeoutpar[$i];
+ } else {
+ $typeoutpar[$i]=$cascadetype;
+ }
+ }
+
my $parm=$$display{$which};
if ($parmlev eq 'full' || $parmlev eq 'brief') {
@@ -354,73 +394,75 @@
if ($parmlev eq 'general') {
if ($uname) {
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
} elsif ($csec) {
- &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
} else {
- &print_td($r,9,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,9,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
}
} elsif ($parmlev eq 'map') {
if ($uname) {
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
} elsif ($csec) {
- &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
} else {
- &print_td($r,8,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,8,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
}
} else {
- &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
if ($parmlev eq 'brief') {
- &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
if ($csec) {
- &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
}
if ($uname) {
- &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
}
} else {
- &print_td($r,10,'#FFDDDD',$result,\@outpar,$mprefix,$_,$type,$display);
- &print_td($r,9,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
- &print_td($r,8,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
- &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,10,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,9,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,8,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
if ($csec) {
- &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,$type,$display);
- &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,$type,$display);
- &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
}
if ($uname) {
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
- &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,$type,$display);
+ &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
}
} # end of $brief if/else
} # end of $parmlev if/else
if ($parmlev eq 'full' || $parmlev eq 'brief') {
$r->print('<td bgcolor=#CCCCFF align="center">'.
- &valout($outpar[$result],$$type{$which}).'</td>');
+ &valout($outpar[$result],$typeoutpar[$result]).'</td>');
}
my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
'.'.$$name{$which},$symbp{$rid});
+ my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}.
+ '.'.$$name{$which}.'.type',$symbp{$rid});
$r->print('<td bgcolor=#999999 align="center"><font color=#FFFFFF>'.
- &valout($sessionval,$$type{$which}).' '.
+ &valout($sessionval,$sessionvaltype).' '.
'</font></td>');
$r->print('</tr>');
$r->print("\n");
}
sub print_td {
- my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$type,$display)=@_;
+ my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
$r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).
' align="center">'.
- &plink($$type{$value},$$display{$value},$$outpar[$which],
+ &plink($$typeoutpar[$which],$$display{$value},$$outpar[$which],
$mprefix."$which",'parmform.pres','psub').'</td>'."\n");
}
@@ -720,8 +762,8 @@
if ($snum==5) { $storeunder=$seclevelm; }
if ($snum==4) { $storeunder=$seclevelr; }
- my %storecontent = ($storeunder => $ENV{'form.pres_value'},
- $storeunder.'type' => $ENV{'form.pres_type'});
+ my %storecontent = ($storeunder => $ENV{'form.pres_value'},
+ $storeunder.'.type' => $ENV{'form.pres_type'});
my $reply='';
if ($snum>3) {
# ---------------------------------------------------------------- Store Course
--www1031419832--