version 1.53, 2004/01/15 03:18:20
|
version 1.61, 2004/11/13 21:17:55
|
Line 25
|
Line 25
|
# |
# |
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
# (TeX Content Handler |
|
# |
|
# 05/29/00,05/30 Gerd Kortemeyer) |
|
# 7/1,6/30 Gerd Kortemeyer |
|
|
|
package Apache::lonratedt; |
package Apache::lonratedt; |
|
|
Line 176 use Apache::loncommon;
|
Line 173 use Apache::loncommon;
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use File::Copy; |
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 |
# Mapread read maps into global arrays @links and @resources, determines status |
Line 190 sub mapread {
|
Line 187 sub mapread {
|
undef @links; |
undef @links; |
undef @resources; |
undef @resources; |
undef @order; |
undef @order; |
|
undef @resparms; |
@resources=(''); |
@resources=(''); |
@order=(); |
@order=(); |
|
@resparms=(); |
|
|
my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,''); |
my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,''); |
if ($errtext) { return ($errtext,2); } |
if ($errtext) { return ($errtext,2); } |
Line 206 sub mapread {
|
Line 205 sub mapread {
|
$links[$number]=$content; |
$links[$number]=$content; |
} |
} |
if ($command eq 'objparms') { |
if ($command eq 'objparms') { |
return(&mt('Map has resource parameters. Use advanced editor.'),1); |
if ($resparms[$number]) { |
|
$resparms[$number].='&&&'.$content; |
|
} else { |
|
$resparms[$number]=$content; |
|
} |
} |
} |
} |
} |
# ------------------------------------------------------- Is this a linear map? |
# ------------------------------------------------------- Is this a linear map? |
Line 514 sub storemap {
|
Line 517 sub storemap {
|
if (defined($resources[$order[$i]])) { |
if (defined($resources[$order[$i]])) { |
$output.='<&>objcont<:>'.$order[$i].'<:>'.$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($order[$i+1])) { |
if (defined($resources[$order[$i+1]])) { |
if (defined($resources[$order[$i+1]])) { |
$output.='<&>objlinks<:>'.$k.'<:>'. |
$output.='<&>objlinks<:>'.$k.'<:>'. |
Line 528 sub storemap {
|
Line 538 sub storemap {
|
&Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,'')); |
&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 { |
sub editscript { |
my $mode=shift; |
my $mode=shift; |
my $resurl=&Apache::loncommon::lastresurl(); |
my $resurl=&Apache::loncommon::lastresurl(); |
Line 644 sub smpedt {
|
Line 706 sub smpedt {
|
my $tmpfn=&Apache::lonnet::filelocation('',$url).'.tmp'; |
my $tmpfn=&Apache::lonnet::filelocation('',$url).'.tmp'; |
my $targetmsg=''; |
my $targetmsg=''; |
if ($ENV{'form.save'}) { |
if ($ENV{'form.save'}) { |
$targetmsg='<b>Saving ...</b><br>'; |
|
copy($tmpfn,&Apache::lonnet::filelocation('',$url)); |
copy($tmpfn,&Apache::lonnet::filelocation('',$url)); |
unlink($tmpfn); |
unlink($tmpfn); |
my ($errtext,$fatal)= |
my ($errtext,$fatal)= |
&mapread(&Apache::lonnet::filelocation('',$url),''); |
&mapread(&Apache::lonnet::filelocation('',$url),''); |
|
unless ($fatal) { |
|
$targetmsg='<b>'.&mt('Saved.').'</b><br />'; |
|
} else { |
|
$targetmsg='<b>'.&mt('An error occured while saving.').'</b><br />'; |
|
} |
} |
} |
if ($ENV{'form.revert'}) { |
if ($ENV{'form.revert'}) { |
$targetmsg='<b>Reverting ...</b><br>'; |
$targetmsg='<b>'.&mt('Reverted.').'</b><br />'; |
unlink($tmpfn); |
unlink($tmpfn); |
my ($errtext,$fatal)= |
my ($errtext,$fatal)= |
&mapread(&Apache::lonnet::filelocation('',$url),''); |
&mapread(&Apache::lonnet::filelocation('',$url),''); |
Line 911 sub smpedt {
|
Line 977 sub smpedt {
|
|
|
# ----------------------------------------------------- Start simple RAT screen |
# ----------------------------------------------------- Start simple RAT screen |
my $editscript=&editscript('simple'); |
my $editscript=&editscript('simple'); |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1). |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef, |
&Apache::loncommon::help_open_topic('Sequence_Simple_Editor_Creation'). |
($ENV{'environment.remote'} ne 'off')). |
&Apache::loncommon::help_open_faq(6). |
&Apache::loncommon::help_open_menu('','Sequence_Simple_Editor_Creation','Sequence_Simple_Editor_Creation','',6,'RAT'); |
&Apache::loncommon::help_open_bug('RAT'); |
|
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'sa' => 'Save', |
'sa' => 'Save', |
'nt' => 'New Title', |
'nt' => 'New Title', |
Line 1070 sub viewmap {
|
Line 1135 sub viewmap {
|
my ($r,$url,$adv,$errtext)=@_; |
my ($r,$url,$adv,$errtext)=@_; |
$r->print('<html>'. |
$r->print('<html>'. |
&Apache::loncommon::bodytag('Edit Content of a Map'). |
&Apache::loncommon::bodytag('Edit Content of a Map'). |
&Apache::loncommon::help_open_faq(6). |
&Apache::loncommon::help_open_menu('','','','',6,'RAT'). |
&Apache::loncommon::help_open_bug('RAT'). |
|
&buttons($adv)); |
&buttons($adv)); |
if ($errtext) { |
if ($errtext) { |
$r->print($errtext.'<hr />'); |
$r->print($errtext.'<hr />'); |