--- rat/lonratedt.pm 2005/04/07 07:34:52 1.66
+++ rat/lonratedt.pm 2005/06/10 16:56:08 1.73
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Edit Handler for RAT Maps
#
-# $Id: lonratedt.pm,v 1.66 2005/04/07 07:34:52 albertel Exp $
+# $Id: lonratedt.pm,v 1.73 2005/06/10 16:56:08 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,7 +33,7 @@ package Apache::lonratedt;
=head1 NAME
-Apache::lonratedt: advanced resource assembly tool
+Apache::lonratedt: simple resource assembly tool
=head1 SYNOPSIS
@@ -173,7 +173,7 @@ use Apache::loncommon;
use Apache::lonlocal;
use File::Copy;
-use vars qw(@order @resources @resparms);
+use vars qw(@order @resources @resparms @zombies);
# Mapread read maps into global arrays @links and @resources, determines status
@@ -188,9 +188,12 @@ sub mapread {
undef @resources;
undef @order;
undef @resparms;
+ undef @zombies;
+
@resources=('');
@order=();
@resparms=();
+ @zombies=();
my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,'');
if ($errtext) { return ($errtext,2); }
@@ -199,7 +202,13 @@ sub mapread {
foreach (split(/\<\&\>/,$outtext)) {
my ($command,$number,$content)=split(/\<\:\>/,$_);
if ($command eq 'objcont') {
- $resources[$number]=$content;
+ my ($title,$src,$ext,$type)=split(/\:/,$content);
+ if ($ext eq 'cond') { next; }
+ if ($type ne 'zombie') {
+ $resources[$number]=$content;
+ } else {
+ $zombies[$number]=$content;
+ }
}
if ($command eq 'objlinks') {
$links[$number]=$content;
@@ -296,7 +305,10 @@ sub attemptread {
foreach (split(/\<\&\>/,$outtext)) {
my ($command,$number,$content)=split(/\<\:\>/,$_);
if ($command eq 'objcont') {
- $theseres[$number]=$content;
+ my ($title,$src,$ext,$type)=split(/\:/,$content);
+ unless ($type eq 'zombie') {
+ $theseres[$number]=$content;
+ }
}
if ($command eq 'objlinks') {
$links[$number]=$content;
@@ -434,6 +446,33 @@ sub buttons {
return $output.'
';
}
+# ------------------------------------- Revive zombie idx or get unused number
+
+sub getresidx {
+ my $url=shift;
+ my $max=1+($#resources>$#zombies?$#resources:$#zombies);
+ unless ($url) { return $max; }
+ for (my $i=0; $i<=$#zombies; $i++) {
+ my ($title,$src,$ext,$type)=split(/\:/,$zombies[$i]);
+ if ($src eq $url) {
+ undef $zombies[$i];
+ return $i;
+ }
+ }
+ return $max;
+}
+
+# --------------------------------------------------------------- Make a zombie
+
+sub makezombie {
+ my $idx=shift;
+ my ($name,$url,$ext)=split(/\:/,$resources[$idx]);
+ my $now=time;
+ $zombies[$idx]=$name.
+ ' [('.$now.','.$env{'user.name'}.','.$env{'user.domain'}.')]:'.
+ $url.':'.$ext.':zombie';
+}
+
# ----------------------------------------------------------- Paste into target
# modifies @order, @resources
@@ -446,7 +485,7 @@ sub pastetarget {
$name=&Apache::lonnet::unescape($name);
$url=&Apache::lonnet::unescape($url);
if ($url) {
- my $idx=$#resources+1;
+ my $idx=&getresidx($url);
$insertorder[$#insertorder+1]=$idx;
my $ext='false';
if ($url=~/^http\:\/\//) { $ext='true'; }
@@ -492,7 +531,7 @@ sub startfinish {
$resources[$order[0]]=$name.':'.$url.':'.$ext.':start:res';
# Make sure this has at least start and finish
if ($#order==0) {
- $resources[$#resources+1]='::false';
+ $resources[&getresidx()]='::false';
$order[1]=$#resources;
}
# Make the last one a finish resource
@@ -536,6 +575,11 @@ sub storemap {
}
}
}
+ for (my $i=0; $i<=$#zombies; $i++) {
+ if (defined($zombies[$i])) {
+ $output.='<&>objcont<:>'.$i.'<:>'.$zombies[$i];
+ }
+ }
$output=~s/http\&colon\;\/\///g;
$env{'form.output'}=$output;
return
@@ -645,6 +689,14 @@ function idxopen(mode) {
idx.focus();
}
+// ------------------------------------------------------ Open groupsort window
+function groupopen(url,recover) {
+ var options="scrollbars=1,resizable=1,menubar=0";
+ idxflag=1;
+ idx=open("/adm/groupsort?mode=$mode&recover="+recover+"&readfile="+url,"idxout",options);
+ idx.focus();
+}
+
// --------------------------------------------------------- Open search window
function srchopen(mode) {
var options="scrollbars=1,resizable=1,menubar=0";
@@ -661,6 +713,7 @@ function groupsearch() {
function groupimport() {
idxcheck('groupimport');
}
+
// ------------------------------------------------------- Do srch status check
function srchcheck(mode) {
if (!srch || srch.closed || srchmode!=mode) {
@@ -880,7 +933,11 @@ sub smpedt {
foreach (@targetselect) {
if ($_-1==$i) { $include=0; }
}
- if ($include) { $neworder[$#neworder+1]=$order[$i]; }
+ if ($include) {
+ $neworder[$#neworder+1]=$order[$i];
+ } else {
+ &makezombie($order[$i]);
+ }
}
@order=@neworder;
&storemap(&Apache::lonnet::filelocation('',$url));
@@ -1164,11 +1221,7 @@ sub viewmap {
'" />'.&Apache::lonratsrv::qtescape($title).
' | '.$filename.' | ');
if ($url) {
- if (-e $resfilepath) {
- $r->print(''.&mt('Resource space').'');
- } else {
- $r->print(&mt('unpublished'));
- }
+ $r->print(''.&mt('Resource space').'');
}
$r->print(' | ');
if ($url) {
|