[LON-CAPA-cvs] cvs: loncom /interface londocs.pm

www lon-capa-cvs@mail.lon-capa.org
Thu, 20 Jul 2006 20:42:49 -0000


www		Thu Jul 20 16:42:49 2006 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  Bug #3899: warning in randompick folders that modifying them will cause
  randomization to change
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.241 loncom/interface/londocs.pm:1.242
--- loncom/interface/londocs.pm:1.241	Thu Jul 20 14:37:14 2006
+++ loncom/interface/londocs.pm	Thu Jul 20 16:42:48 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.241 2006/07/20 18:37:14 www Exp $
+# $Id: londocs.pm,v 1.242 2006/07/20 20:42:48 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -961,6 +961,9 @@
                '&markedcopy_title='.
                &escape($env{'form.markedcopy_title'});
     }
+    my $randompick=-1;
+    my $isencrypted=0;
+    my $ishidden=0;
     while (@folders) {
 	my $folder=shift(@folders);
 	my $foldername=shift(@folders);
@@ -968,17 +971,25 @@
 	$folderpath.=$folder.'&'.$foldername;
 	my $url='/adm/coursedocs?folderpath='.
 	    &escape($folderpath);
+            my $name=&unescape($foldername);
+# randompick number, hidden, encrypted is appended with ":"s to the foldername	
+            $name=~s/\:(\d*)\:(\w*)\:(\w*)$//;
+            if ($1 ne '') { 
+               $randompick=$1;
+            } else {
+               $randompick=-1;
+            }
+            if ($2) { $ishidden=1; }
+            if ($3) { $isencrypted=1; }
 	    &Apache::lonhtmlcommon::add_breadcrumb(
 		      {'href'=>$url.$cpinfo,
-		       'title'=>&unescape($foldername),
+		       'title'=>$name,
 		       'text'=>'<font size="+1">'.
-			   &unescape($foldername).'</font>'
+			   $name.'</font>'
 		       });
-		       
-						 
     }
-    return &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
-					       'LC_docs_path');
+    return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
+					       'LC_docs_path'),$randompick,$ishidden,$isencrypted);
 }
 
 sub editor {
@@ -1003,7 +1014,8 @@
 	$env{'form.markedcopy_title'}=$title;
 	$env{'form.markedcopy_url'}=$url;
     }
-    $r->print(&breadcrumbs($folder));
+    my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted)=&breadcrumbs($folder);
+    $r->print($breadcrumbtrail);
     if ($fatal) {
 	   $r->print('<p><font color="red">'.$errtext.'</font></p>');
     } else {
@@ -1223,6 +1235,16 @@
 # ---------------------------------------------------------------- Print screen
         my $idx=0;
 	my $shown=0;
+        if (($ishidden) || ($isencrypted) || ($randompick>=0)) {
+           $r->print('<p>'.&mt('Parameters').':<ul>'.
+                     ($randompick>=0?'<li>'.&mt('randomly pick [_1] resources',$randompick).'</li>':'').
+                     ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
+                     ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
+                     '</ul></p>');
+        }                                                                                                     
+        if ($randompick>=0) {
+           $r->print('<p>'.&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.').'</p>');
+        }
         $r->print('<table>');
         foreach (@Apache::lonratedt::order) {
            my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
@@ -1608,7 +1630,14 @@
 	my $foldername=&escape($foldertitle);
 	my $folderpath=$env{'form.folderpath'};
 	if ($folderpath) { $folderpath.='&' };
-	$folderpath.=$folderarg.'&'.$foldername;
+# Append randompick number, hidden, and encrypted with ":" to foldername, 
+# so it gets transferred between levels
+	$folderpath.=$folderarg.'&'.$foldername.':'.(&Apache::lonratedt::getparameter($orderidx,
+                                              'parameter_randompick'))[0]
+                                               .':'.((&Apache::lonratedt::getparameter($orderidx,
+                                              'parameter_hiddenresource'))[0]=~/^yes$/i)
+                                               .':'.((&Apache::lonratedt::getparameter($orderidx,
+                                              'parameter_encrypturl'))[0]=~/^yes$/i);
 	$url.='folderpath='.&escape($folderpath).$cpinfo;
 	$parameterset='<label>'.&mt('Randomly Pick: ').
 	    '<input type="text" size="4" onChange="this.form.submit()" name="randpick_'.$orderidx.'" value="'.