--- rat/lonratedt.pm 2003/10/21 20:40:10 1.48
+++ rat/lonratedt.pm 2004/11/13 21:17:55 1.61
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Edit Handler for RAT Maps
#
-# $Id: lonratedt.pm,v 1.48 2003/10/21 20:40:10 albertel Exp $
+# $Id: lonratedt.pm,v 1.61 2004/11/13 21:17:55 albertel 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;
@@ -176,7 +173,7 @@ 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
@@ -190,8 +187,10 @@ sub mapread {
undef @links;
undef @resources;
undef @order;
+ undef @resparms;
@resources=('');
@order=();
+ @resparms=();
my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,'');
if ($errtext) { return ($errtext,2); }
@@ -206,7 +205,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?
@@ -220,13 +223,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);
}
}
@@ -235,7 +238,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);
}
}
}
@@ -414,12 +417,15 @@ sub buttons {
my $adv=shift;
my $output='
';
}
@@ -511,6 +517,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.'<:>'.
@@ -525,8 +538,61 @@ 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 delparameter {
+ my ($to,$name)=@_;
+ my $newentry='';
+ my $nametype='';
+ foreach (split('&&&',$resparms[$to])) {
+ my ($thistype,$thisname,$thisvalue)=split('___',$_);
+ if ($thisname) {
+ unless ($thisname eq $name) {
+ $newentry.=$_.'&&&';
+ }
+ }
+ }
+ $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(<Saving ...
';
copy($tmpfn,&Apache::lonnet::filelocation('',$url));
unlink($tmpfn);
my ($errtext,$fatal)=
&mapread(&Apache::lonnet::filelocation('',$url),'');
+ unless ($fatal) {
+ $targetmsg=''.&mt('Saved.').'
';
+ } else {
+ $targetmsg=''.&mt('An error occured while saving.').'
';
+ }
}
if ($ENV{'form.revert'}) {
- $targetmsg='Reverting ...
';
+ $targetmsg=''.&mt('Reverted.').'
';
unlink($tmpfn);
my ($errtext,$fatal)=
&mapread(&Apache::lonnet::filelocation('',$url),'');
}
if (-e $tmpfn) {
$targetmsg=
- '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
@@ -878,7 +948,7 @@ sub smpedt {
$importdetail='&'.$importdetail;
$importdetail=~s/^\&+/\&/;
my $importwindow=
- ''.
+ ''.
join("\n",map {
$idx++;
if ($_) {
@@ -893,7 +963,7 @@ sub smpedt {
$idx=0;
$targetdetail='';
my $targetwindow=
- ''.
+ ''.
join("\n",map {
my ($name,$url)=split(/\:/,$resources[$_]);
unless ($name) { $name=(split(/\//,$url))[-1]; }
@@ -907,7 +977,9 @@ 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,
+ ($ENV{'environment.remote'} ne 'off')).
+ &Apache::loncommon::help_open_menu('','Sequence_Simple_Editor_Creation','Sequence_Simple_Editor_Creation','',6,'RAT');
my %lt=&Apache::lonlocal::texthash(
'sa' => 'Save',
'nt' => 'New Title',
@@ -923,6 +995,10 @@ sub smpedt {
'mu' => 'Move Up',
'md' => 'Move Down',
're' => 'Rename',
+ 'as' => 'after selected',
+ 'cs' => 'Cut selected',
+ 'ps' => 'Copy selected',
+ 'pas' => 'Paste after selected',
);
$r->print(<
@@ -986,7 +1062,7 @@ $buttons
-after selected
+$lt{'as'}
-after selected
+$lt{'as'}
@@ -1018,13 +1094,13 @@ $importwindow
|
-Cut selected
+$lt{'cs'}
-Copy selected
+$lt{'ps'}
-Paste after selected
+$lt{'pas'}
|
|