--- loncom/interface/loncommon.pm 2002/06/24 20:17:55 1.39 +++ loncom/interface/loncommon.pm 2002/07/03 21:12:38 1.43 @@ -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.43 2002/07/03 21:12:38 ng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,6 +33,7 @@ # 12/25,12/28 Gerd Kortemeyer # YEAR=2002 # 1/4 Gerd Kortemeyer +# 6/24,7/2 H. K. Ng # Makes a table out of the previous attempts # Inputs result_from_symbread, user, domain, course_id @@ -190,6 +191,92 @@ BEGIN { } # ============================================================= END BEGIN BLOCK +############################################################### +## HTML and Javascript Helper Functions ## +############################################################### + +=pod + +=item browser_and_searcher_javascript + +Returns scalar containing javascript to open a browser window +or a searcher window. Also creates + +=over 4 + +=item openbrowser(formname,elementname,only,omit) [javascript] + +inputs: formname, elementname, only, omit + +formname and elementname indicate the name of the html form and name of +the element that the results of the browsing selection are to be placed in. + +Specifying 'only' will restrict the browser to displaying only files +with the given extension. Can be a comma seperated list. + +Specifying 'omit' will restrict the browser to NOT displaying files +with the given extension. Can be a comma seperated list. + +=item opensearcher(formname, elementname) [javascript] + +Inputs: formname, elementname + +formname and elementname specify the name of the html form and the name +of the element the selection from the search results will be placed in. + +=back + +=cut + +############################################################### +sub browser_and_searcher_javascript { + return < 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 +902,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 +924,10 @@ sub get_previous_attempt { } else { $value=$lasthash{$_}; } - $prevattempts.=''.$value.''; + if ($_ =~/$regexp$/) {$value = &$gradesub($value)} + $prevattempts.=''.$value.' '; } - $prevattempts.=''; + $prevattempts.=''; } else { $prevattempts='Nothing submitted - no attempts.'; }