--- loncom/interface/londocs.pm 2006/08/11 22:00:07 1.244 +++ loncom/interface/londocs.pm 2006/11/02 21:06:06 1.245 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.244 2006/08/11 22:00:07 albertel Exp $ +# $Id: londocs.pm,v 1.245 2006/11/02 21:06:06 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,7 +33,8 @@ use Apache::Constants qw(:common :http); use Apache::imsexport; use Apache::lonnet; use Apache::loncommon; -use Apache::lonratedt; +use LONCAPA::map(); +use Apache::lonratedt(); use Apache::lonratsrv; use Apache::lonxml; use Apache::lonclonecourse; @@ -57,7 +58,7 @@ my $hadchanges; my %help=(); -# Mapread read maps into lonratedt::global arrays +# Mapread read maps into LONCAPA::map:: global arrays # @order and @resources, determines status # sets @order - pointer to resources in right order # sets @resources - array with the resources with correct idx @@ -66,15 +67,15 @@ my %help=(); sub mapread { my ($coursenum,$coursedom,$map)=@_; return - &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'. - $map); + &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'. + $map); } sub storemap { my ($coursenum,$coursedom,$map)=@_; my ($outtext,$errtext)= - &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. - $map,1); + &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. + $map,1); if ($errtext) { return ($errtext,2); } $hadchanges=1; @@ -930,13 +931,13 @@ sub group_import { } } if ($url) { - my $idx = &Apache::lonratedt::getresidx($url); - $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx; + my $idx = &LONCAPA::map::getresidx($url); + $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; my $ext = 'false'; if ($url=~/^http:\/\//) { $ext = 'true'; } $url =~ s/:/\:/g; $name =~ s/:/\:/g; - $Apache::lonratedt::resources[$idx] = + $LONCAPA::map::resources[$idx] = join ':', ($name, $url, $ext, 'normal', 'res'); } } @@ -1001,15 +1002,15 @@ sub editor { } ($errtext,$fatal)= &mapread($coursenum,$coursedom,$folder.'.'.$container); - if ($#Apache::lonratedt::order<1) { - my $idx=&Apache::lonratedt::getresidx(); + if ($#LONCAPA::map::order<1) { + my $idx=&LONCAPA::map::getresidx(); if ($idx<=0) { $idx=1; } - $Apache::lonratedt::order[0]=$idx; - $Apache::lonratedt::resources[$idx]=''; + $LONCAPA::map::order[0]=$idx; + $LONCAPA::map::resources[$idx]=''; } if (defined($env{'form.markcopy'})) { # Mark for copying - my ($title,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$env{'form.markcopy'}]]); + my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]); $env{'form.markedcopy_title'}=$title; $env{'form.markedcopy_url'}=$url; } @@ -1027,19 +1028,19 @@ sub editor { my $idx=$env{'form.setparms'}; # set parameters if ($env{'form.randpick_'.$idx}) { - &Apache::lonratedt::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos'); + &LONCAPA::map::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos'); } else { - &Apache::lonratedt::delparameter($idx,'parameter_randompick'); + &LONCAPA::map::delparameter($idx,'parameter_randompick'); } if ($env{'form.hidprs_'.$idx}) { - &Apache::lonratedt::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno'); + &LONCAPA::map::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno'); } else { - &Apache::lonratedt::delparameter($idx,'parameter_hiddenresource'); + &LONCAPA::map::delparameter($idx,'parameter_hiddenresource'); } if ($env{'form.encprs_'.$idx}) { - &Apache::lonratedt::storeparameter($idx,'parameter_encrypturl','yes','string_yesno'); + &LONCAPA::map::storeparameter($idx,'parameter_encrypturl','yes','string_yesno'); } else { - &Apache::lonratedt::delparameter($idx,'parameter_encrypturl'); + &LONCAPA::map::delparameter($idx,'parameter_encrypturl'); } if ($env{'form.newpos'}) { @@ -1052,29 +1053,29 @@ sub editor { if ($newpos>$currentpos) { # moving stuff up for ($i=0;$i<$currentpos;$i++) { - $neworder[$i]=$Apache::lonratedt::order[$i]; + $neworder[$i]=$LONCAPA::map::order[$i]; } for ($i=$currentpos;$i<$newpos;$i++) { - $neworder[$i]=$Apache::lonratedt::order[$i+1]; + $neworder[$i]=$LONCAPA::map::order[$i+1]; } - $neworder[$newpos]=$Apache::lonratedt::order[$currentpos]; - for ($i=$newpos+1;$i<=$#Apache::lonratedt::order;$i++) { - $neworder[$i]=$Apache::lonratedt::order[$i]; + $neworder[$newpos]=$LONCAPA::map::order[$currentpos]; + for ($i=$newpos+1;$i<=$#LONCAPA::map::order;$i++) { + $neworder[$i]=$LONCAPA::map::order[$i]; } } else { # moving stuff down for ($i=0;$i<$newpos;$i++) { - $neworder[$i]=$Apache::lonratedt::order[$i]; + $neworder[$i]=$LONCAPA::map::order[$i]; } - $neworder[$newpos]=$Apache::lonratedt::order[$currentpos]; + $neworder[$newpos]=$LONCAPA::map::order[$currentpos]; for ($i=$newpos+1;$i<$currentpos+1;$i++) { - $neworder[$i]=$Apache::lonratedt::order[$i-1]; + $neworder[$i]=$LONCAPA::map::order[$i-1]; } - for ($i=$currentpos+1;$i<=$#Apache::lonratedt::order;$i++) { - $neworder[$i]=$Apache::lonratedt::order[$i]; + for ($i=$currentpos+1;$i<=$#LONCAPA::map::order;$i++) { + $neworder[$i]=$LONCAPA::map::order[$i]; } } - @Apache::lonratedt::order=@neworder; + @LONCAPA::map::order=@neworder; } # store the changed version @@ -1109,10 +1110,10 @@ sub editor { if ($url=~/^http\:\/\//) { $ext='true'; } $url=~s/\:/\:/g; # Now insert the URL at the bottom - my $newidx=&Apache::lonratedt::getresidx($url); - $Apache::lonratedt::resources[$newidx]= + my $newidx=&LONCAPA::map::getresidx($url); + $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res'; - $Apache::lonratedt::order[1+$#Apache::lonratedt::order]=$newidx; + $LONCAPA::map::order[1+$#LONCAPA::map::order]=$newidx; # Store the result ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); if ($fatal) { @@ -1125,54 +1126,48 @@ sub editor { if ($env{'form.cmd'}) { my ($cmd,$idx)=split(/\_/,$env{'form.cmd'}); if ($cmd eq 'del') { - my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]); + my (undef,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]); if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) { &Apache::lonnet::removeuploadedurl($url); } else { - &Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]); + &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); } - for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) { - $Apache::lonratedt::order[$i]= - $Apache::lonratedt::order[$i+1]; + for (my $i=$idx;$i<$#LONCAPA::map::order;$i++) { + $LONCAPA::map::order[$i] = $LONCAPA::map::order[$i+1]; } - $#Apache::lonratedt::order--; + $#LONCAPA::map::order--; } elsif ($cmd eq 'cut') { - my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]); - &Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]); - for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) { - $Apache::lonratedt::order[$i]= - $Apache::lonratedt::order[$i+1]; + my (undef,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]); + &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); + for (my $i=$idx;$i<$#LONCAPA::map::order;$i++) { + $LONCAPA::map::order[$i] = $LONCAPA::map::order[$i+1]; } - $#Apache::lonratedt::order--; + $#LONCAPA::map::order--; } elsif ($cmd eq 'up') { - if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) { - my $i=$Apache::lonratedt::order[$idx-1]; - $Apache::lonratedt::order[$idx-1]= - $Apache::lonratedt::order[$idx]; - $Apache::lonratedt::order[$idx]=$i; + if (($idx) && (defined($LONCAPA::map::order[$idx-1]))) { + my $i=$LONCAPA::map::order[$idx-1]; + $LONCAPA::map::order[$idx-1] = $LONCAPA::map::order[$idx]; + $LONCAPA::map::order[$idx] = $i; } } elsif ($cmd eq 'down') { - if (defined($Apache::lonratedt::order[$idx+1])) { - my $i=$Apache::lonratedt::order[$idx+1]; - $Apache::lonratedt::order[$idx+1]= - $Apache::lonratedt::order[$idx]; - $Apache::lonratedt::order[$idx]=$i; + if (defined($LONCAPA::map::order[$idx+1])) { + my $i=$LONCAPA::map::order[$idx+1]; + $LONCAPA::map::order[$idx+1] = $LONCAPA::map::order[$idx]; + $LONCAPA::map::order[$idx] = $i; } } elsif ($cmd eq 'rename') { - my $ratstr = $Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]; + my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; my ($rtitle,@rrest)=split(/\:/, - $Apache::lonratedt::resources[ - $Apache::lonratedt::order[$idx]]); + $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]); my $comment= &HTML::Entities::decode($env{'form.title'}); $comment=~s/\\<\;/g; $comment=~s/\>/\>\;/g; $comment=~s/\:/\:/g; if ($comment=~/\S/) { - $Apache::lonratedt::resources[ - $Apache::lonratedt::order[$idx]]= - $comment.':'.join(':',@rrest); + $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]= + $comment.':'.join(':',@rrest); } # Devalidate title cache my $renamed_url=$rrest[0]; @@ -1213,10 +1208,9 @@ sub editor { if ($env{'form.importmap'}=~/\w/) { foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { my ($title,$url,$ext,$type)=split(/\:/,$_); - my $idx=&Apache::lonratedt::getresidx($url); - $Apache::lonratedt::resources[$idx]=$_; - $Apache::lonratedt::order - [$#Apache::lonratedt::order+1]=$idx; + my $idx=&LONCAPA::map::getresidx($url); + $LONCAPA::map::resources[$idx]=$_; + $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; } # Store the changed version ($errtext,$fatal)=&storemap($coursenum,$coursedom, @@ -1245,8 +1239,8 @@ sub editor { $r->print('
'.&mt('Caution: this folder is set to randomly pick a subset of resources. Adding or removing resources from this folder will change the set of resources that the students see, resulting in spurious or missing credit for completed problems, not limited to ones you modify. Do not modify the contents of this folder if it is in active student use.').'
'); } $r->print('