--- loncom/interface/londocs.pm 2006/11/13 17:20:29 1.251 +++ loncom/interface/londocs.pm 2007/07/18 18:36:52 1.278.2.3 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.251 2006/11/13 17:20:29 www Exp $ +# $Id: londocs.pm,v 1.278.2.3 2007/07/18 18:36:52 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,7 @@ use HTML::Entities; use GDBM_File; use Apache::lonlocal; use Cwd; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); my $iconpath; @@ -99,7 +99,7 @@ sub authorhosts { $ca=$env{'user.name'}; $cd=$env{'user.domain'}; } else { - ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/); + ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/); } my $allowed=0; my $myhome=&Apache::lonnet::homeserver($ca,$cd); @@ -147,6 +147,7 @@ sub dumpcourse { my $type = &Apache::loncommon::course_type(); $r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space'). '
'); $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row(). ''.$errtext.'
'); @@ -1184,27 +1227,42 @@ sub editor { if ($env{'form.changeparms'}) { my $idx=$env{'form.setparms'}; # set parameters - if ($env{'form.randpick_'.$idx}) { - &LONCAPA::map::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos'); - &remember_parms($idx,'randompick','set',$env{'form.randpick_'.$idx}); - } else { - &LONCAPA::map::delparameter($idx,'parameter_randompick'); - &remember_parms($idx,'randompick','del'); + if ($env{'form.changeparms'} eq 'randompick') { + if ($env{'form.randpick_'.$idx}) { + &LONCAPA::map::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos'); + &remember_parms($idx,'randompick','set',$env{'form.randpick_'.$idx}); + } else { + &LONCAPA::map::delparameter($idx,'parameter_randompick'); + &remember_parms($idx,'randompick','del'); + } + } + if ($env{'form.changeparms'} eq 'hiddenresource') { + if ($env{'form.hidprs_'.$idx}) { + &LONCAPA::map::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno'); + &remember_parms($idx,'hiddenresource','set',$env{'form.hidprs_'.$idx}); + } else { + &LONCAPA::map::delparameter($idx,'parameter_hiddenresource'); + &remember_parms($idx,'hiddenresource','del'); + } + } + if ($env{'form.changeparms'} eq 'encrypturl') { + if ($env{'form.encprs_'.$idx}) { + &LONCAPA::map::storeparameter($idx,'parameter_encrypturl','yes','string_yesno'); + &remember_parms($idx,'encrypturl','set',$env{'form.encprs_'.$idx}); + } else { + &LONCAPA::map::delparameter($idx,'parameter_encrypturl'); + &remember_parms($idx,'encrypturl','del'); + } + } + if ($env{'form.changeparms'} eq 'randomorder') { + if ($env{'form.randorder_'.$idx}) { + &LONCAPA::map::storeparameter($idx,'parameter_randomorder','yes','string_yesno'); + &remember_parms($idx,'randomorder','set',$env{'form.randorder_'.$idx}); + } else { + &LONCAPA::map::delparameter($idx,'parameter_randomorder'); + &remember_parms($idx,'randomorder','del'); + } } - if ($env{'form.hidprs_'.$idx}) { - &LONCAPA::map::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno'); - &remember_parms($idx,'hiddenresource','set',$env{'form.hidprs_'.$idx}); - } else { - &LONCAPA::map::delparameter($idx,'parameter_hiddenresource'); - &remember_parms($idx,'hiddenresource','del'); - } - if ($env{'form.encprs_'.$idx}) { - &LONCAPA::map::storeparameter($idx,'parameter_encrypturl','yes','string_yesno'); - &remember_parms($idx,'encrypturl','set',$env{'form.encprs_'.$idx}); - } else { - &LONCAPA::map::delparameter($idx,'parameter_encrypturl'); - &remember_parms($idx,'encrypturl','del'); - } # store the changed version ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); if ($fatal) { @@ -1264,18 +1322,16 @@ sub editor { $url=~/^(.+)\.(\w+)$/; my $newurl=$1.$newid.'.'.$2; my $storefn=$newurl; - $storefn=~s/^\/\w+\/\w+\/\w+\///; + $storefn=~s{^/\w+/$match_domain/$match_username/}{}; &Apache::lonclonecourse::writefile ($env{'request.course.id'},$storefn, &Apache::lonnet::getfile($url)); $url=$newurl; } - $title=~s/\\<\;/g; - $title=~s/\>/\>\;/g; - $title=~s/\:/\:/g; + $title = &LONCAPA::map::qtunescape($title); my $ext='false'; if ($url=~/^http\:\/\//) { $ext='true'; } - $url=~s/\:/\:/g; + $url = &LONCAPA::map::qtunescape($url); # Now insert the URL at the bottom my $newidx=&LONCAPA::map::getresidx($url); $LONCAPA::map::resources[$newidx]= @@ -1327,19 +1383,14 @@ sub editor { my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; my ($rtitle,@rrest)=split(/\:/, $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]); - my $comment= - &HTML::Entities::decode($env{'form.title'}); - $comment=~s/\\<\;/g; - $comment=~s/\>/\>\;/g; - $comment=~s/\:/\:/g; + my $comment=$env{'form.title'}; + $comment = &LONCAPA::map::qtunescape($comment); if ($comment=~/\S/) { $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]= $comment.':'.join(':',@rrest); } # Devalidate title cache - my $renamed_url=$rrest[0]; -# Has the :-escaping - $renamed_url=~s/\&colon\;/\:/g; + my $renamed_url=&LONCAPA::map::qtescape($rrest[0]); &Apache::lonnet::devalidate_title_cache($renamed_url); } # Store the changed version @@ -1396,24 +1447,30 @@ sub editor { # ---------------------------------------------------------------- Print screen my $idx=0; my $shown=0; - if (($ishidden) || ($isencrypted) || ($randompick>=0)) { + if (($ishidden) || ($isencrypted) || ($randompick>=0) + || ($is_random_order)) { $r->print(''.&mt('Parameters').':
'.&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.').'
'); } + if ($is_random_order) { + $r->print(''.&mt('Caution: this folder is set to randomly order its contents. Adding or removing resources from this folder will change the order of resources shown. Do not modify the contents of this folder if it is in active student use.').'
'); + } $r->print('
$lt{'rm'}
-
-$lt{'ct'}
+$cutlink
$lt{'rn'}
$copylink
END
} else {
- unless ($nocopy) {
+ if (!$nocopy) {
$copylink=(< |
ENDCOPY
}
+ if (!$nocut) {
+ $cutlink=(<
$lt{'rm'}
-
-$lt{'ct'}
+$cutlink
$lt{'rn'}
$copylink
@@ -1738,13 +1844,13 @@ END
if ($uploaded) {
if ($extension eq 'sequence') {
$icon=$iconpath.'/folder_closed.gif';
- $url=~/$coursenum\/([\/\w]+)\.sequence$/;
+ $url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/;
$url='/adm/coursedocs?';
$folderarg=$1;
$isfolder=1;
} elsif ($extension eq 'page') {
$icon=$iconpath.'/page.gif';
- $url=~/$coursenum\/([\/\w]+)\.page$/;
+ $url=~/\Q$coursenum\E\/([\/\w]+)\.page$/;
$pagearg=$1;
$url='/adm/coursedocs?';
$ispage=1;
@@ -1788,7 +1894,7 @@ END
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
}
}
- my $parameterset=' ';
+ my ($parameterset,$rand_order_text) = (' ', ' ');
if ($isfolder || $extension eq 'sequence') {
my $foldername=&escape($foldertitle);
my $folderpath=$env{'form.folderpath'};
@@ -1800,15 +1906,21 @@ END
.':'.((&LONCAPA::map::getparameter($orderidx,
'parameter_hiddenresource'))[0]=~/^yes$/i)
.':'.((&LONCAPA::map::getparameter($orderidx,
- 'parameter_encrypturl'))[0]=~/^yes$/i);
+ 'parameter_encrypturl'))[0]=~/^yes$/i)
+ .':'.((&LONCAPA::map::getparameter($orderidx,
+ 'parameter_randomorder'))[0]=~/^yes$/i);
$url.='folderpath='.&escape($folderpath).$cpinfo;
$parameterset='';
+''.&mt('Save').'';
+ my $ro_set=
+ ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
+ $rand_order_text ='
+ |
+
- |
+$rand_order_text | $parameterset | ENDPARMS } @@ -1958,6 +2072,7 @@ sub list_symbs { my ($r) = @_; $r->print(&Apache::loncommon::start_page('Symb List')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List')); my $navmap = Apache::lonnavmaps::navmap->new(); $r->print("