--- loncom/xml/lonxml.pm 2002/01/30 16:04:04 1.151 +++ loncom/xml/lonxml.pm 2002/03/08 18:32:55 1.156 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.151 2002/01/30 16:04:04 albertel Exp $ +# $Id: lonxml.pm,v 1.156 2002/03/08 18:32:55 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -316,6 +316,8 @@ sub fontsettings() { sub registerurl { my $forcereg=shift; + my $target = shift; + my $result = ''; if ($ENV{'request.publicaccess'}) { return ''; @@ -347,7 +349,7 @@ ENDGRDS ENDPARM } } - return (< // BEGIN LON-CAPA Internal @@ -399,7 +401,7 @@ ENDPARM ENDREGTHIS } else { - return (< // BEGIN LON-CAPA Internal @@ -426,8 +428,52 @@ ENDREGTHIS // END LON-CAPA Internal ENDDONOTREGTHIS - } + if ($target eq 'edit') { + # Javascript routines for construction space: + # openbrowser and opensearcher will start the file browser + # (lonindexer) and searcher (lonsearchcat) respectively. + # Inputs are the name of the html form being used + # and the name of the element the selected URL should + # be placed in. + $result .=<<"ENDBROWSERSCRIPT"; + +ENDBROWSERSCRIPT + } + return $result; } sub loadevents() { @@ -538,7 +584,7 @@ sub inner_xmlparse { &Apache::lonxml::warning('Using tag </'.$token->[1].'> as end tag to <'.$$stack[-1].'>'); last; } else { - &Apache::lonxml::warning('Found tag </'.$$stack[-1].'> when looking for </'.$token->[1].'> in file'); + &Apache::lonxml::warning('Found tag </'.$token->[1].'> when looking for </'.$$stack[-1].'> in file'); &end_tag($stack,$parstack,$token); } } @@ -626,7 +672,7 @@ sub recurse { &Apache::lonxml::warning('Using tag </'.$tokenpat->[1].'> as end tag to <'.$innerstack[-1].'>'); last; } else { - &Apache::lonxml::warning('Found tag </'.$innerstack[-1].'> when looking for </'.$tokenpat->[1].'> in file'); + &Apache::lonxml::warning('Found tag </'.$tokenpat->[1].'> when looking for </'.$innerstack[-1].'> in file'); &end_tag(\@innerstack,\@innerparstack,$tokenpat); } } @@ -689,13 +735,13 @@ sub callsub { } if (!$deleted) { if ($space) { - #&Apache::lonxml::debug("Calling sub $sub in $space $metamode
\n"); + #&Apache::lonxml::debug("Calling sub $sub in $space $metamode"); $sub1="$space\:\:$sub"; ($currentstring,$nodefault) = &$sub1($target,$token,$tagstack, $parstack,$parser,$safeeval, $style); } else { - #&Apache::lonxml::debug("NOT Calling sub $sub in $space $metamode
\n"); + #&Apache::lonxml::debug("NOT Calling sub $sub in $space $metamode"); if ($metamode <1) { if (defined($token->[4]) && ($metamode < 1)) { $currentstring = $token->[4]; @@ -978,16 +1024,8 @@ sub writeallows { # sub afterburn { my $result=shift; - foreach (split(/&/,$ENV{'QUERY_STRING'})) { - my ($name, $value) = split(/=/,$_); - $value =~ tr/+/ /; - $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; - if (($name eq 'highlight')||($name eq 'anchor')||($name eq 'link')) { - unless ($ENV{'form.'.$name}) { - $ENV{'form.'.$name}=$value; - } - } - } + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['highlight','anchor','link']); if ($ENV{'form.highlight'}) { foreach (split(/\,/,$ENV{'form.highlight'})) { my $anchorname=$_; @@ -1069,10 +1107,37 @@ ENDFOOTER return $result; } +sub get_target { + my $viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'}); + if ( $ENV{'request.state'} eq 'published') { + if ( defined($ENV{'form.grade_target'}) + && ($viewgrades == 'F' )) { + return ($ENV{'form.grade_target'}); + } elsif (defined($ENV{'form.grade_target'})) { + if (($ENV{'form.grade_target'} eq 'web') || + ($ENV{'form.grade_target'} eq 'tex') ) { + return $ENV{'form.grade_target'} + } else { + return 'web'; + } + } else { + return 'web'; + } + } elsif ($ENV{'request.state'} eq 'construct') { + if ( defined($ENV{'form.grade_target'})) { + return ($ENV{'form.grade_target'}); + } else { + return 'web'; + } + } else { + return 'web'; + } +} + sub handler { my $request=shift; - my $target='web'; + my $target=&get_target(); $Apache::lonxml::debug=0;