--- rat/lonratsrv.pm 2000/07/04 16:24:17 1.2 +++ rat/lonratsrv.pm 2000/07/05 21:05:28 1.3 @@ -58,16 +58,53 @@ sub loadmap { if ($token->[1] eq 'map') { $graphmode=($token->[2]->{'mode'} eq 'rat/graphical'); } elsif ($token->[1] eq 'resource') { +# -------------------------------------------------------------------- Resource + $outstr.='<&>objcont'; + if ($token->[2]->{'id'}) { + $outstr.='<:>'.$token->[2]->{'id'}; + if ($obj[$token->[2]->{'id'}]==1) { + $errtext.='Error: multiple use of ID '. + $token->[2]->{'id'}.'. '; + } + $obj[$token->[2]->{'id'}]=1; + } else { + my $i=1; + while (($i<=$#obj) && ($obj[$i]!=0)) { $i++; } + $outstr.='<:>'.$i; + $obj[$i]=1; + } + $outstr.='<:>'; } elsif ($token->[1] eq 'condition') { +# ------------------------------------------------------------------- Condition + $outstr.='<&>objcont'; + if ($token->[2]->{'id'}) { + $outstr.='<:>'.$token->[2]->{'id'}; + if ($obj[$token->[2]->{'id'}]==1) { + $errtext.='Error: multiple use of ID '. + $token->[2]->{'id'}.'. '; + } + $obj[$token->[2]->{'id'}]=1; + } else { + my $i=1; + while (($i<=$#obj) && ($obj[$i]!=0)) { $i++; } + $outstr.='<:>'.$i; + $obj[$i]=1; + } + $outstr.='<:>'; } elsif ($token->[1] eq 'link') { +# ----------------------------------------------------------------------- Links $outstr.='<&>objlinks'; if ($graphmode) { + if ($token->[2]->{'index'}) { + $errtext.='Error: multiple use of link index '. + $token->[2]->{'index'}.'. '; $outstr.='<:>'.$token->[2]->{'index'}; - @links[$token->[2]->{'index'}]=1; + $links[$token->[2]->{'index'}]=1; } else { my $i=1; while (($i<=$#links) && ($links[$i]==1)) { $i++; } $outstr.='<:>'.$i; + $links[$i]=1; } $outstr.='<:>'.$token->[2]->{'from'}. '<:>'.$token->[2]->{'to'}; @@ -77,12 +114,21 @@ sub loadmap { $outstr.='<:>0'; } } elsif ($graphmode) { +# --------------------------------------------- All other tags (graphical only) + $outstr.='<&>'.$token->[1]; + if ($token->[2]->{'index'}) { + $outstr.='<:>'.$token->[2]->{'index'}; + if ($token->[1] eq 'obj') { + $obj[$token->[2]->{'index'}]=2; + } + } + $outstr.='<:>'.$token->[2]->{'value'}; } } } } else { - $errtext.='Map not loaded: The file does not exist.'; + $errtext.='Map not loaded: The file does not exist. '; } return($outstr,$errtext); } @@ -165,14 +211,14 @@ sub savemap { my $fh; if ($fh=Apache::File->new(">$fn")) { print $fh $outstr; - $errtext.="Map saved as $fn."; + $errtext.="Map saved as $fn. "; } else { - $errtext.='Could not write file $fn. Map not saved.'; + $errtext.='Could not write file $fn. Map not saved. '; } } } else { # -------------------------------------------- Cannot write to that file, error - $errtext.='Map not saved: The specified path does not exist.'; + $errtext.='Map not saved: The specified path does not exist. '; } return $errtext; }