Annotation of loncom/interface/loncommon.pm, revision 1.5
1.1 albertel 1: # The LearningOnline Network
2: # a pile of common routines
3: # 2/13 Guy Albertelli
4:
5: # Makes a table out of the previous attempts
1.2 albertel 6: # Inputs result_from_symbread, user, domain, course_id
1.1 albertel 7:
8: package Apache::loncommon;
9:
10: use strict;
11: use Apache::Constants qw(:common);
12: use Apache::lonmsg();
13:
14: sub get_previous_attempt {
1.2 albertel 15: my ($symb,$username,$domain,$course)=@_;
1.1 albertel 16: my $prevattempts='';
17: if ($symb) {
1.3 albertel 18: my (%returnhash)=
19: &Apache::lonnet::restore($symb,$course,$domain,$username);
1.1 albertel 20: if ($returnhash{'version'}) {
21: my %lasthash=();
22: my $version;
23: for ($version=1;$version<=$returnhash{'version'};$version++) {
24: map {
25: $lasthash{$_}=$returnhash{$version.':'.$_};
1.4 albertel 26: } sort(split(/\:/,$returnhash{$version.':keys'}));
1.1 albertel 27: }
28: $prevattempts='<table border=2></tr><th>History</th>';
29: map {
30: $prevattempts.='<th>'.$_.'</th>';
1.4 albertel 31: } sort(keys %lasthash);
1.1 albertel 32: for ($version=1;$version<=$returnhash{'version'};$version++) {
33: $prevattempts.='</tr><tr><th>Attempt '.$version.'</th>';
34: map {
1.5 ! albertel 35: my $value;
! 36: if ($_ =~ /timestamp/) {
! 37: $value=scalar(localtime($returnhash{$version.':'.$_}));
! 38: } else {
! 39: $value=$returnhash{$version.':'.$_};
! 40: }
! 41: $prevattempts.='<td>'.$value.'</td>';
1.4 albertel 42: } sort(keys %lasthash);
1.1 albertel 43: }
44: $prevattempts.='</tr><tr><th>Current</th>';
45: map {
1.5 ! albertel 46: my $value;
! 47: if ($_ =~ /timestamp/) {
! 48: $value=scalar(localtime($lasthash{$_}));
! 49: } else {
! 50: $value=$lasthash{$_};
! 51: }
! 52: $prevattempts.='<td>'.$value.'</td>';
1.4 albertel 53: } sort(keys %lasthash);
1.1 albertel 54: $prevattempts.='</tr></table>';
55: } else {
56: $prevattempts='Nothing submitted - no attempts.';
57: }
58: } else {
59: $prevattempts='No data.';
60: }
61: }
62:
63: 1;
64: __END__;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>