Annotation of loncom/interface/loncommon.pm, revision 1.3
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.':'.$_};
26: } split(/\:/,$returnhash{$version.':keys'});
27: }
28: $prevattempts='<table border=2></tr><th>History</th>';
29: map {
30: $prevattempts.='<th>'.$_.'</th>';
31: } keys %lasthash;
32: for ($version=1;$version<=$returnhash{'version'};$version++) {
33: $prevattempts.='</tr><tr><th>Attempt '.$version.'</th>';
34: map {
35: $prevattempts.='<td>'.$returnhash{$version.':'.$_}.'</td>';
36: } keys %lasthash;
37: }
38: $prevattempts.='</tr><tr><th>Current</th>';
39: map {
40: $prevattempts.='<td>'.$lasthash{$_}.'</td>';
41: } keys %lasthash;
42: $prevattempts.='</tr></table>';
43: } else {
44: $prevattempts='Nothing submitted - no attempts.';
45: }
46: } else {
47: $prevattempts='No data.';
48: }
49: }
50:
51: 1;
52: __END__;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>