--- loncom/interface/loncommon.pm 2002/06/24 20:17:55 1.39
+++ loncom/interface/loncommon.pm 2002/06/25 17:09:38 1.41
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.39 2002/06/24 20:17:55 matthew Exp $
+# $Id: loncommon.pm,v 1.41 2002/06/25 17:09:38 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -772,8 +772,18 @@ sub filedescriptionex {
return '.'.$ex.' '.$fd{lc($ex)};
}
+# ---- Retrieve attempts by students
+# input
+# $symb - problem including path
+# $username,$domain - that of the student
+# $course - course name
+# $getattempt - leave blank if want all attempts, else put something.
+#
+# output
+# formatted as a table all the attempts, if any.
+#
sub get_previous_attempt {
- my ($symb,$username,$domain,$course)=@_;
+ my ($symb,$username,$domain,$course,$getattempt)=@_;
my $prevattempts='';
if ($symb) {
my (%returnhash)=
@@ -786,13 +796,14 @@ sub get_previous_attempt {
$lasthash{$_}=$returnhash{$version.':'.$_};
}
}
- $prevattempts='
History | ';
+ $prevattempts='';
+ $prevattempts.='History | ';
foreach (sort(keys %lasthash)) {
my ($ign,@parts) = split(/\./,$_);
if ($#parts > 0) {
my $data=$parts[-1];
pop(@parts);
- $prevattempts.='Part '.join('.',@parts).' '.$data.' | ';
+ $prevattempts.='Part '.join('.',@parts).' '.$data.' | ';
} else {
if ($#parts == 0) {
$prevattempts.=''.$parts[0].' | ';
@@ -801,19 +812,21 @@ sub get_previous_attempt {
}
}
}
- for ($version=1;$version<=$returnhash{'version'};$version++) {
- $prevattempts.='
---|
Attempt '.$version.' | ';
- foreach (sort(keys %lasthash)) {
- my $value;
- if ($_ =~ /timestamp/) {
- $value=scalar(localtime($returnhash{$version.':'.$_}));
- } else {
- $value=$returnhash{$version.':'.$_};
- }
- $prevattempts.=''.$value.' | ';
- }
+ if ($getattempt eq '') {
+ for ($version=1;$version<=$returnhash{'version'};$version++) {
+ $prevattempts.='
---|
Transaction '.$version.' | ';
+ foreach (sort(keys %lasthash)) {
+ my $value;
+ if ($_ =~ /timestamp/) {
+ $value=scalar(localtime($returnhash{$version.':'.$_}));
+ } else {
+ $value=$returnhash{$version.':'.$_};
+ }
+ $prevattempts.=''.$value.' | ';
+ }
+ }
}
- $prevattempts.=' Current | ';
+ $prevattempts.='
---|
Current | ';
foreach (sort(keys %lasthash)) {
my $value;
if ($_ =~ /timestamp/) {
@@ -821,9 +834,9 @@ sub get_previous_attempt {
} else {
$value=$lasthash{$_};
}
- $prevattempts.=''.$value.' | ';
+ $prevattempts.=''.$value.' | ';
}
- $prevattempts.=' ';
+ $prevattempts.=' |
';
} else {
$prevattempts='Nothing submitted - no attempts.';
}