--- rat/lonratedt.pm 2002/05/13 19:38:32 1.14 +++ rat/lonratedt.pm 2002/05/14 15:19:13 1.16 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Edit Handler for RAT Maps # -# $Id: lonratedt.pm,v 1.14 2002/05/13 19:38:32 www Exp $ +# $Id: lonratedt.pm,v 1.16 2002/05/14 15:19:13 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -126,6 +126,48 @@ sub mapread { return $errtext; } +# ---------------------------------------------- Read a map as well as possible + +sub attemptread { + my $fn=shift; + + my @links; + undef @links; + my @theseres; + undef @theseres; + + my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,''); + if ($errtext) { return @theseres } + +# -------------------------------------------------------------------- Read map + foreach (split(/\<\&\>/,$outtext)) { + my ($command,$number,$content)=split(/\<\:\>/,$_); + if ($command eq 'objcont') { + $theseres[$number]=$content; + } + if ($command eq 'objlinks') { + $links[$number]=$content; + } + } + +# --------------------------------------------------------------- Sort, sort of + + my $startidx=0; + my $endidx=0; + for (my $i=0; $i<=$#theseres; $i++) { + if (defined($theseres[$i])) { + my ($title,$url,$ext,$type)=split(/\:/,$theseres[$i]); + if ($type eq 'start') { $startidx=$i; } + if ($type eq 'finish') { $endidx=$i; } + } + } + + + return @theseres; + +} + + # --------------------------------------------------------- Build up RAT screen sub ratedt { my ($r,$url)=@_; @@ -193,7 +235,7 @@ sub smpedt { my $importdetail=$ENV{'form.curimpdetail'}; # ---------------------------------------------------- Importing from groupsort - if ($ENV{'form.importdetail'}) { + if (($ENV{'form.importdetail'}) && (!$ENV{'form.impfortarget'})) { $importdetail=''; my @curimport=split(/\&/,$ENV{'form.curimpdetail'}); @@ -252,8 +294,9 @@ sub smpedt { my $importwindow=join("\n",map { $idx++; if ($_) { - my ($name)=split(/\=/,$_); - unless ($name) { $name='UNKNOWN'; } + my ($name,$url)=split(/\=/,$_); + unless ($name) { $name=(split(/\//,$url))[-1]; } + unless ($name) { $name='EMPTY'; } ''; } @@ -262,7 +305,8 @@ sub smpedt { $idx=0; my $targetwindow=join("\n",map { my ($name,$url)=split(/\:/,$resources[$_]); - unless ($name) { $name='UNKNOWN'; } + unless ($name) { $name=(split(/\//,$url))[-1]; } + unless ($name) { $name='EMPTY'; } $targetdetail.='&'.&Apache::lonnet::escape($name).'='. &Apache::lonnet::escape($url); $idx++; @@ -352,6 +396,30 @@ function idxcheck(mode) { } idx.focus(); } + + + var editbrowser; + function openbrowser(formname,elementname,only,omit) { + var url = '/res/?'; + if (editbrowser == null) { + url += 'launch=1&'; + } + url += 'catalogmode=interactive&'; + url += 'mode=edit&'; + url += 'form=' + formname + '&'; + if (only != null) { + url += 'only=' + only + '&'; + } + if (omit != null) { + url += 'omit=' + omit + '&'; + } + url += 'element=' + elementname + ''; + var title = 'Browser'; + var options = 'scrollbars=1,resizable=1,menubar=0'; + options += ',width=700,height=600'; + editbrowser = open(url,title,options,'1'); + editbrowser.focus(); + } @@ -366,14 +434,26 @@ $buttons -
after selected +after selected
+ +
+   - + + + +after selected +
+ @@ -392,6 +472,7 @@ $targetwindow + ENDSMPHEAD @@ -423,7 +504,8 @@ sub viewmap { my ($title,$url)=split(/\:/,$_); $title=~s/\&colon\;/\:/g; $url=~s/\&colon\;/\:/g; - unless ($title) { $title='Unknown'; } + unless ($title) { $title=(split(/\//,$url))[-1] }; + unless ($title) { $title='Empty'; } if ($url) { $r->print(''); }