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

raeburn raeburn at source.lon-capa.org
Sat Mar 10 16:24:59 EST 2012


raeburn		Sat Mar 10 21:24:59 2012 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - More compact display for randompick chooser for folders.
  - Consistence use/behavior of checkboxes for randompick, randomorder,
    hidden, and encrypturl.
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.477 loncom/interface/londocs.pm:1.478
--- loncom/interface/londocs.pm:1.477	Tue Feb 28 02:02:16 2012
+++ loncom/interface/londocs.pm	Sat Mar 10 21:24:59 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.477 2012/02/28 02:02:16 raeburn Exp $
+# $Id: londocs.pm,v 1.478 2012/03/10 21:24:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1181,7 +1181,7 @@
     $renametitle=~s/\&quot\;/\\\"/g;
     $renametitle=~s/ /%20/g;
     my $line=&Apache::loncommon::start_data_table_row();
-    my ($form_start,$form_end);
+    my ($form_start,$form_end,$form_common);
 # Edit commands
     my ($container, $type, $esc_path, $path, $symb);
     if ($env{'form.folderpath'}) {
@@ -1272,8 +1272,10 @@
 <a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a>
 ENDCUT
         }
-	$form_start = (<<END);
-   <form  action="/adm/coursedocs" method="post">
+	$form_start = '
+   <form action="/adm/coursedocs" method="post">
+';
+        $form_common=(<<END);
    <input type="hidden" name="${type}path" value="$path" />
    <input type="hidden" name="${type}symb" value="$symb" />
    <input type="hidden" name="setparms" value="$orderidx" />
@@ -1295,6 +1297,7 @@
 </td>
 <td>
    $form_start
+   $form_common
    $selectbox
    $form_end
 </td>
@@ -1378,7 +1381,7 @@
 	    $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
 	}
     }
-    my ($parameterset,$rand_order_text) = (' ', ' ');
+    my ($rand_pick_text,$rand_order_text);
     if ($isfolder || $extension eq 'sequence') {
 	my $foldername=&escape($foldertitle);
 	my $folderpath=$env{'form.folderpath'};
@@ -1394,16 +1397,27 @@
                                                .':'.((&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="'.
-	    (&LONCAPA::map::getparameter($orderidx,
-                                              'parameter_randompick'))[0].
-                                              '" />'.
-'<a href="javascript:void(0)">'.&mt('Save').'</a></label>';
+        my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
+                                                   'parameter_randompick'))[0];
+        my $rpckchk;
+        if ($rpicknum) {
+            $rpckchk = ' checked="checked"';
+        }
+        my $formname = 'edit_rpick_'.$orderidx;
+	$rand_pick_text = 
+'<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
+$form_common."\n".
+'<span class="LC_nobreak"><label><input type="checkbox" name="randpickon_'.$orderidx.'" id="rpick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="randompick_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" />';
+        if ($rpicknum ne '') {
+            $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
+        }
+        $rand_pick_text .= '</span></form>';
     	my $ro_set=
 	    ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
-	$rand_order_text ='
-<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onclick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></span>';
+	$rand_order_text = 
+$form_start.
+$form_common.'
+<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onclick="'."this.form.changeparms.value='randomorder';this.form.submit()".'" '.$ro_set.' /> '.&mt('Random Order').' </label></span></form>';
     }
     if ($ispage) {
         my $pagename=&escape($pagetitle);
@@ -1454,6 +1468,8 @@
        $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
     }
     $line.=$external."</td>";
+    $rand_pick_text = ' ' if ($rand_pick_text eq '');
+    $rand_order_text = ' ' if ($rand_order_text eq '');
     if (($allowed) && ($folder!~/^supplemental/)) {
  	my %lt=&Apache::lonlocal::texthash(
  			      'hd' => 'Hidden',
@@ -1465,15 +1481,17 @@
 	$line.=(<<ENDPARMS);
   <td class="LC_docs_entry_parameter">
     $form_start
+    $form_common
     <label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
     $form_end
     <br />
     $form_start
+    $form_common
     <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 $parameterset $form_end<br />
-                                      $form_start $rand_order_text $form_end</td>
+  <td class="LC_docs_entry_parameter">$rand_pick_text<br />
+                                      $rand_order_text</td>
 ENDPARMS
     }
     $line.=&Apache::loncommon::end_data_table_row();
@@ -3162,7 +3180,8 @@
                                           p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
                                           p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
                                           p_ctr2a => 'Cut[_98]',
-                                          p_ctr2b => '?[_98]'
+                                          p_ctr2b => '?[_98]',
+                                          rpck    => 'Enter number to pick (e.g., 3)',
                                         );
 
     my $crstype = &Apache::loncommon::course_type();
@@ -3356,6 +3375,37 @@
 this.document.forms.renameform.submit();
 }
 
+function updatePick(targetform,index,caller) {
+    var pickitem = document.getElementById('rpick_'+index);
+    var picknumitem = document.getElementById('rpicknum_'+index);
+    if (pickitem.checked) {
+        var picknum=prompt('$lt{"rpck"}',picknumitem.value);
+        if (picknum == '' || picknum == null) {
+            if (caller == 'check') {
+                pickitem.checked=false;
+                return;
+            }
+        } else {
+            picknum.toString();
+            var regexdigit=/^\\d+\$/;
+            if (regexdigit.test(picknum)) {
+                picknumitem.value = picknum;
+                targetform.changeparms.value='randompick';
+                targetform.submit();
+            } else {
+                if (caller == 'check') {
+                    pickitem.checked=false;
+                }
+                return;
+            }
+        }
+    } else {
+        picknumitem.value = 0;
+        targetform.changeparms.value='randompick';
+        targetform.submit();
+    }
+}
+
 function unselectInactive(nav) {
 currentNav = document.getElementById(nav);
 currentLis = currentNav.getElementsByTagName('LI');




More information about the LON-CAPA-cvs mailing list