--- rat/lonratedt.pm 2003/07/25 04:14:32 1.46
+++ rat/lonratedt.pm 2004/04/24 15:37:30 1.56
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Edit Handler for RAT Maps
#
-# $Id: lonratedt.pm,v 1.46 2003/07/25 04:14:32 bowersj2 Exp $
+# $Id: lonratedt.pm,v 1.56 2004/04/24 15:37:30 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,10 +25,7 @@
#
# http://www.lon-capa.org/
#
-# (TeX Content Handler
-#
-# 05/29/00,05/30 Gerd Kortemeyer)
-# 7/1,6/30 Gerd Kortemeyer
+
package Apache::lonratedt;
@@ -173,9 +170,10 @@ use Apache::lonnet;
use Apache::lonratsrv;
use Apache::lonsequence;
use Apache::loncommon;
+use Apache::lonlocal;
use File::Copy;
-use vars qw(@order @resources);
+use vars qw(@order @resources @resparms);
# Mapread read maps into global arrays @links and @resources, determines status
@@ -205,7 +203,11 @@ sub mapread {
$links[$number]=$content;
}
if ($command eq 'objparms') {
- return('Map has resource parameters. Use advanced editor.',1);
+ if ($resparms[$number]) {
+ $resparms[$number].='&&&'.$content;
+ } else {
+ $resparms[$number]=$content;
+ }
}
}
# ------------------------------------------------------- Is this a linear map?
@@ -219,13 +221,13 @@ sub mapread {
my ($start,$end,$cond)=split(/\:/,$_);
if ((defined($starters[$start])) || (defined($endings[$end]))) {
return
- ('Map has branchings. Use advanced editor.',1);
+ (&mt('Map has branchings. Use advanced editor.'),1);
}
$starters[$start]=1;
$endings[$end]=1;
if ($cond) {
return
- ('Map has conditions. Use advanced editor.',1);
+ (&mt('Map has conditions. Use advanced editor.'),1);
}
}
@@ -234,7 +236,7 @@ sub mapread {
if (defined($resources[$i])) {
unless (($starters[$i]) || ($endings[$i])) {
return
- ('Map has unconnected resources. Use advanced editor.',1);
+ (&mt('Map has unconnected resources. Use advanced editor.'),1);
}
}
}
@@ -413,12 +415,15 @@ sub buttons {
my $adv=shift;
my $output='
';
}
@@ -510,6 +515,13 @@ sub storemap {
if (defined($resources[$order[$i]])) {
$output.='<&>objcont<:>'.$order[$i].'<:>'.$resources[$order[$i]];
}
+ if (defined($resparms[$order[$i]])) {
+ foreach (split('&&&',$resparms[$order[$i]])) {
+ if ($_) {
+ $output.='<&>objparms<:>'.$order[$i].'<:>'.$_;
+ }
+ }
+ }
if (defined($order[$i+1])) {
if (defined($resources[$order[$i+1]])) {
$output.='<&>objlinks<:>'.$k.'<:>'.
@@ -524,8 +536,46 @@ sub storemap {
&Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,''));
}
+# ------------------------------------------ Store and get parameters in global
+
+sub storeparameter {
+ my ($to,$name,$value,$ptype)=@_;
+ my $newentry='';
+ my $nametype='';
+ foreach (split('&&&',$resparms[$to])) {
+ my ($thistype,$thisname,$thisvalue)=split('___',$_);
+ if ($thisname) {
+ unless ($thisname eq $name) {
+ $newentry.=$_.'&&&';
+ } else {
+ $nametype=$thistype;
+ }
+ }
+ }
+ unless ($ptype) { $ptype=$nametype; }
+ unless ($ptype) { $ptype='string'; }
+ $newentry.=$ptype.'___'.$name.'___'.$value;
+ $resparms[$to]=$newentry;
+}
+
+sub getparameter {
+ my ($to,$name);
+ my $value=undef;
+ my $ptype=undef;
+ foreach (split('&&&',$resparms[$to])) {
+ my ($thistype,$thisname,$thisvalue)=split('___',$_);
+ if ($thisname eq $name) {
+ $value=$thisvalue;
+ $ptype=$thistype;
+ }
+ }
+ return ($value,$ptype);
+}
+
+# ----------------------------------------------------------------- Edit script
sub editscript {
my $mode=shift;
+ my $resurl=&Apache::loncommon::lastresurl();
return(<You are working with an unsaved version of your map.
';
+ ''.&mt('You are working with an unsaved version of your map.').'
';
my ($errtext,$fatal)=&mapread($tmpfn,'');
}
# ---------------------------------------------------------- Process form input
@@ -877,7 +927,7 @@ sub smpedt {
$importdetail='&'.$importdetail;
$importdetail=~s/^\&+/\&/;
my $importwindow=
- ''.
+ ''.
join("\n",map {
$idx++;
if ($_) {
@@ -892,7 +942,7 @@ sub smpedt {
$idx=0;
$targetdetail='';
my $targetwindow=
- ''.
+ ''.
join("\n",map {
my ($name,$url)=split(/\:/,$resources[$_]);
unless ($name) { $name=(split(/\//,$url))[-1]; }
@@ -906,7 +956,30 @@ sub smpedt {
# ----------------------------------------------------- Start simple RAT screen
my $editscript=&editscript('simple');
- my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1);
+ my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1).
+ &Apache::loncommon::help_open_topic('Sequence_Simple_Editor_Creation').
+ &Apache::loncommon::help_open_faq(6).
+ &Apache::loncommon::help_open_bug('RAT');
+ my %lt=&Apache::lonlocal::texthash(
+ 'sa' => 'Save',
+ 'nt' => 'New Title',
+ 'se' => 'Search',
+ 'im' => 'Import',
+ 'vi' => 'View',
+ 'lm' => 'Load Map',
+ 'ds' => 'Discard Selected',
+ 'ca' => 'Clear All',
+ 'ta' => 'Temporary Assembly Workspace',
+ 'rv' => 'Revert to Last Saved',
+ 'sa' => 'Save',
+ 'mu' => 'Move Up',
+ 'md' => 'Move Down',
+ 're' => 'Rename',
+ 'as' => 'after selected',
+ 'cs' => 'Cut selected',
+ 'ps' => 'Copy selected',
+ 'pas' => 'Paste after selected',
+ );
$r->print(<
@@ -943,7 +1016,7 @@ sub smpedt {
oldname=unescape(nameparts.join('"'));
nameparts=oldname.split(''');
oldname=unescape(nameparts.join("'"));
- newtitle=prompt('New Title',oldname);
+ newtitle=prompt('$lt{'nt'}',oldname);
if (newtitle) {
document.forms.simpleedit.renameres.value=1;
document.forms.simpleedit.renameidx.value=selidx;
@@ -963,37 +1036,37 @@ $buttons
- Temporary Assembly Workspace |
+
---|
$lt{'ta'} |
|
File: $url |
-
-
-after selected
+
+
+$lt{'as'}
-
-
-
+value="Select Map">
+
+
+
| |
+"javascript:impfortarget.value=1;groupsearch()" value="$lt{'se'}">
-after selected
+"javascript:impfortarget.value=1;groupimport();" value="$lt{'im'}">
+$lt{'as'}
-
-
-
+
+
+
$targetmsg
-
-
-
+
+
+
|
|
-Cut selected
+$lt{'cs'}
-Copy selected
+$lt{'ps'}
-Paste after selected
+$lt{'pas'}
|
|