--- rat/lonratedt.pm 2002/05/10 18:58:04 1.8 +++ rat/lonratedt.pm 2002/05/10 19:46:52 1.9 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Edit Handler for RAT Maps # -# $Id: lonratedt.pm,v 1.8 2002/05/10 18:58:04 www Exp $ +# $Id: lonratedt.pm,v 1.9 2002/05/10 19:46:52 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -52,21 +52,35 @@ sub mapread { my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,''); if ($errtext) { return ($errtext,2); } +# -------------------------------------------------------------------- Read map foreach (split(/\<\&\>/,$outtext)) { - my ($command,$parms)=split(/\<\:\>/,$_); - my @item=split(/\:/,$parms); + my ($command,$number,$content)=split(/\<\:\>/,$_); if ($command eq 'objcont') { + $resources[$number]=$content; } if ($command eq 'objlinks') { - if (defined($links[$item[0]])) { + $links[$number]=$content; + } + } +# ------------------------------------------------------- Is this a linear map? + my @starters=(); + my @endings=(); + undef @starters; + undef @endings; + + foreach (@links) { + if (defined($_)) { + my ($start,$end,$cond)=split(/\:/,$_); + if ((defined($starters[$start])) || (defined($endings[$end]))) { return ('Map too complex, has branchings. Use advanced editor.',1); } - if ($links[$item[2]]) { + $starters[$start]=1; + $endings[$end]=1; + if ($cond) { return ('Map too complex, has conditions. Use advanced editor.',1); } - $links[$item[0]]=$item[1]; } } @@ -227,7 +241,20 @@ ENDNODIR sub viewmap { my ($r,$adv)=@_; $r->print('
'.&buttons($adv)); - + foreach (@resources) { + if (defined($_)) { + my ($title,$url)=split(/\:/,$_); + $title=~s/\&colon\;/\:/g; + $url=~s/\&colon\;/\:/g; + unless ($title) { $title='Unknown'; } + if ($url) { + $r->print(''); + } + $r->print(&Apache::lonratsrv::qtescape($title)); + if ($url) { $r->print(''); } + $r->print('