--- loncom/interface/loncommon.pm 2002/06/25 17:09:38 1.41 +++ loncom/interface/loncommon.pm 2002/07/05 16:12:31 1.44 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.41 2002/06/25 17:09:38 ng Exp $ +# $Id: loncommon.pm,v 1.44 2002/07/05 16:12:31 bowersj2 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 <(Help: $topic) +ENDTEMPLATE + } + else + { + $template = <<"ENDTEMPLATE"; +(Help: $topic) +ENDTEMPLATE + } + + return $template; + +} + =item csv_translate($text) Translate $text to allow it to be output as a 'comma seperated values' @@ -778,13 +908,16 @@ sub filedescriptionex { # $username,$domain - that of the student # $course - course name # $getattempt - leave blank if want all attempts, else put something. +# $regexp - regular expression. If string matches regexp send to +# $gradesub - routine that process the string if it matches regexp # # output # formatted as a table all the attempts, if any. # sub get_previous_attempt { - my ($symb,$username,$domain,$course,$getattempt)=@_; + my ($symb,$username,$domain,$course,$getattempt,$regexp,$gradesub)=@_; my $prevattempts=''; + no strict 'refs'; if ($symb) { my (%returnhash)= &Apache::lonnet::restore($symb,$course,$domain,$username); @@ -796,7 +929,7 @@ sub get_previous_attempt { $lasthash{$_}=$returnhash{$version.':'.$_}; } } - $prevattempts='
'; + $prevattempts='
'; $prevattempts.=''; foreach (sort(keys %lasthash)) { my ($ign,@parts) = split(/\./,$_); @@ -834,6 +967,7 @@ sub get_previous_attempt { } else { $value=$lasthash{$_}; } + if ($_ =~/$regexp$/) {$value = &$gradesub($value)} $prevattempts.=''; } $prevattempts.='
History'.$value.' 
';