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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Thu, 19 Jul 2007 00:08:06 -0000


albertel		Wed Jul 18 20:08:06 2007 EDT

  Modified files:              (Branch: randomize)
    /loncom/interface	londocs.pm 
  Log:
  - update random order branch for latest rev of londocs
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.293 loncom/interface/londocs.pm:1.293.2.1
--- loncom/interface/londocs.pm:1.293	Fri Jul 13 20:50:24 2007
+++ loncom/interface/londocs.pm	Wed Jul 18 20:08:04 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.293 2007/07/14 00:50:24 albertel Exp $
+# $Id: londocs.pm,v 1.293.2.1 2007/07/19 00:08:04 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -963,6 +963,7 @@
     my $randompick=-1;
     my $isencrypted=0;
     my $ishidden=0;
+    my $is_random_order=0;
     while (@folders) {
 	my $folder=shift(@folders);
 	my $foldername=shift(@folders);
@@ -970,16 +971,17 @@
 	$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 '') { 
+	    my $name=&unescape($foldername);
+# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername	
+ 	    $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
+	    if ($1 ne '') { 
                $randompick=$1;
             } else {
                $randompick=-1;
             }
             if ($2) { $ishidden=1; }
             if ($3) { $isencrypted=1; }
+	    if ($4 ne '') { $is_random_order = 1; }
 	    &Apache::lonhtmlcommon::add_breadcrumb(
 		      {'href'=>$url.$cpinfo,
 		       'title'=>$name,
@@ -991,7 +993,7 @@
     }
     $plain=~s/\&gt\;\s*$//;
     return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
-					       'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain);
+					       'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain,$is_random_order);
 }
 
 sub log_docs {
@@ -1082,6 +1084,7 @@
     my %lt=('hiddenresource' => 'Resources hidden',
 	    'encrypturl'     => 'URL hidden',
 	    'randompick'     => 'Randomly pick',
+	    'randomorder'    => 'Randomly ordered',
 	    'set'            => 'set to',
 	    'del'            => 'deleted');
     $r->print(&Apache::loncommon::display_filter().
@@ -1164,7 +1167,7 @@
 	$r->print('</ul>');
 	if ($docslog{$id}{'logentry'}{'parameter_res'}) {
 	    $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
-	    foreach my $parameter ('randompick','hiddenresource','encrypturl') {
+	    foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
 		if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
 		    $r->print('<li>'.
 			      &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
@@ -1292,7 +1295,8 @@
 
 my %parameter_type = ( 'randompick'     => 'int_pos',
 		       'hiddenresource' => 'string_yesno',
-		       'encrypturl'     => 'string_yesno',);
+		       'encrypturl'     => 'string_yesno',
+		       'randomorder'    => 'string_yesno',);
 my $valid_parameters_re = join('|',keys(%parameter_type));
 # set parameters
 sub update_parameter {
@@ -1378,7 +1382,7 @@
         $LONCAPA::map::resources[$idx]='';
     }
     
-    my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain)=
+    my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
 	&breadcrumbs($folder);
     $r->print($breadcrumbtrail);
     
@@ -1452,7 +1456,7 @@
 # ---------------------------------------------------------------- Print screen
     my $idx=0;
     my $shown=0;
-    if (($ishidden) || ($isencrypted) || ($randompick>=0)) {
+    if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
 	$r->print('<p>'.&mt('Parameters').':<ul>'.
 		  ($randompick>=0?'<li>'.&mt('randomly pick [_1] resources',$randompick).'</li>':'').
 		  ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
@@ -1462,6 +1466,9 @@
     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>');
     }
+    if ($is_random_order) {
+	$r->print('<p>'.&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.').'</p>');
+    }
     $r->print('<table class="LC_docs_editor">');
     foreach my $res (@LONCAPA::map::order) {
 	my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
@@ -1884,7 +1891,7 @@
 	    $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
 	}
     }
-    my $parameterset='&nbsp;';
+    my ($parameterset,$rand_order_text) = ('&nbsp;', '&nbsp;');
     if ($isfolder || $extension eq 'sequence') {
 	my $foldername=&escape($foldertitle);
 	my $folderpath=$env{'form.folderpath'};
@@ -1896,7 +1903,9 @@
                                                .':'.((&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='<label>'.&mt('Randomly Pick: ').
 	    '<input type="text" size="4" onChange="this.form.changeparms.value='."'randompick'".';this.form.submit()" name="randompick_'.$orderidx.'" value="'.
@@ -1904,7 +1913,10 @@
                                               'parameter_randompick'))[0].
                                               '" />'.
 '<a href="javascript:void(0)">'.&mt('Save').'</a></label>';
-       
+    	my $ro_set=
+	    ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
+	$rand_order_text ='
+<nobr><label><input type="checkbox" name="randomorder_'.$orderidx.'" onClick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></nobr>';   
     }
     if ($ispage) {
         my $pagename=&escape($pagetitle);
@@ -1956,6 +1968,7 @@
     <label><input type="checkbox" name="encrypturl_$orderidx" onClick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
     $form_end
   </td>
+  <td class="LC_docs_entry_parameter">$form_start $rand_order_text $form_end</td>
   <td class="LC_docs_entry_parameter">$form_start $parameterset $form_end</td>
 ENDPARMS
     }