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

www lon-capa-cvs@mail.lon-capa.org
Sun, 05 Jun 2005 01:37:29 -0000


This is a MIME encoded message

--www1117935449
Content-Type: text/plain

www		Sat Jun  4 21:37:29 2005 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  Saving my work for the day - nothing to write home about.
  
  
--www1117935449
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20050604213729.txt"

Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.208 loncom/interface/lonparmset.pm:1.209
--- loncom/interface/lonparmset.pm:1.208	Sat Jun  4 13:35:19 2005
+++ loncom/interface/lonparmset.pm	Sat Jun  4 21:37:26 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.208 2005/06/04 17:35:19 www Exp $
+# $Id: lonparmset.pm,v 1.209 2005/06/05 01:37:26 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -440,6 +440,8 @@
             $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
         }
     }
+
+
     return 
 	'<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
 	    .$marker."','".$return."','".$call."'".');">'.
@@ -447,22 +449,13 @@
 }
 
 sub startpage {
-    my ($r,$id,$udom,$csec,$uname,$have_assessments)=@_;
+    my $r=shift;
 
     my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','',
                                             'onUnload="pclose()"');
     my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table Mode Parameter Setting');
-    my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
-        &Apache::loncommon::selectstudent_link('parmform','uname','udom');
     my $selscript=&Apache::loncommon::studentbrowser_javascript();
     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
-    my %lt=&Apache::lonlocal::texthash(
-                    'captm' => "Course Assessments Parameters - Table Mode",
-		    'sg'    => "Section/Group",
-		    'fu'    => "For User",
-		    'oi'    => "or ID",
-		    'ad'    => "at Domain"
-				       );
     my $html=&Apache::lonxml::xmlbegin();
     $r->print(<<ENDHEAD);
 $html
@@ -513,46 +506,15 @@
 </head>
 $bodytag
 $breadcrumbs
-ENDHEAD
-    my %sectionhash=();
-    my $sections='';
-    if (&Apache::loncommon::get_sections(
-                 $env{'course.'.$env{'request.course.id'}.'.domain'},
-                 $env{'course.'.$env{'request.course.id'}.'.num'},
-					 \%sectionhash)) {
-        $sections=$lt{'sg'}.': <select name="csec">';
-	foreach ('',sort keys %sectionhash) {
-	    $sections.='<option value="'.$_.'"'.
-		($_ eq $csec?'selected="selected"':'').'>'.$_.'</option>';
-        }
-        $sections.='</select>';
-     }
-     $r->print(<<ENDHEAD3);
 <form method="post" action="/adm/parmset?action=settable" name="parmform">
-<h4>$lt{'captm'}</h4>
-ENDHEAD3
-
-    if (!$have_assessments) {
-	$r->print('<font color="red">'.&mt('There are no assessment parameters in this course to set.').'</font><br />');	
-    } else {
-	$r->print(<<ENDHEAD);
-<b>
-$sections
-<br />
-$lt{'fu'} 
-<input type="text" value="$uname" size="12" name="uname" />
-$lt{'oi'}
-<input type="text" value="$id" size="12" name="id" /> 
-$lt{'ad'}
-$chooseopt
-</b>
 <input type="hidden" value='' name="pres_value">
 <input type="hidden" value='' name="pres_type">
 <input type="hidden" value='' name="pres_marker">
+<input type="hidden" value='1' name="prevvisit">
 ENDHEAD
-    }
 }
 
+
 sub print_row {
     my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
 	$defbgtwo,$parmlev,$uname,$udom,$csec)=@_;
@@ -700,10 +662,7 @@
     my $keyp = shift;
     my $allparms = shift;
     my $allparts = shift;
-    my $allkeys = shift;
     my $allmaps = shift;
-    my $fcat = shift;
-    my $defp = shift;
     my $mapp = shift;
     my $symbp = shift;
     my $maptitles=shift;
@@ -725,25 +684,26 @@
 	foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
 	    if ($_=~/^parameter\_(.*)/) {
 		my $key=$_;
-		my $allkey=$1;
-		$allkey=~s/\_/\./g;
-		if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 
-		    'parm') {
-		    next; #hide hidden things
+# Hidden parameters
+		if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm') {
+		    next;
 		}
 		my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
 		my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
 		my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
+#
+# allparms is a hash of parameter names
+#
 		my $parmdis = $display;
-		$parmdis =~ s|(\[Part.*)$||g;
-		my $partkey = $part;
-		$partkey =~ tr|_|.|;
-		$$allparms{$name} = $parmdis;
-		$$allparts{$part} = "[Part $part]";
-		$$allkeys{$allkey}=$display;
-		if ($allkey eq $fcat) {
-		    $$defp{$id}= &Apache::lonnet::metadata($srcf,$key);
-		}
+		$parmdis =~ s/\[Part.*$//g;
+                $$allparms{$name}=$parmdis;
+#
+# allparts is a hash of all parts
+#
+		$$allparts{$part} = "Part: $part";
+#
+# Remember all keys going with this resource
+#
 		if ($$keyp{$id}) {
 		    $$keyp{$id}.=','.$key;
 		} else {
@@ -785,44 +745,42 @@
     }
 </script>
 ENDSCRIPT
-    $r->print(&mt('Select Parameters to View'));
+    $r->print();
     $r->print("\n<table><tr>");
     my $cnt=0;
     foreach $tempkey (sort { $$allparms{$a} cmp $$allparms{$b} }
                       keys %{$allparms} ) {
-	++$cnt;
-	$r->print("</tr>\n<tr>") if ($cnt%2);
-	$r->print("\n<td><input type='checkbox' name='pscat' ");
+	$r->print("\n<td><font size='-1'><input type='checkbox' name='pscat' ");
 	$r->print('value="'.$tempkey.'"');
 	if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
 	    $r->print(' checked');
 	}
-	$r->print('>'.$$allparms{$tempkey}.'</td>');
+	$r->print('>'.$$allparms{$tempkey}.'</font></td>');
+ 	$cnt++;
+        if ($cnt==3) {
+	    $r->print("</tr>\n<tr>");
+	    $cnt=0;
+	}
     }
     $r->print('
 </tr><tr><td>
 <input type="button" onclick="checkall(true, \'pscat\')" value="Select All" />
-</td><td>
+</td><td></td><td>
 <input type="button" onclick="checkall(false, \'pscat\')" value="Unselect All" />
 </td>
 ');
     $r->print('</tr></table>');
 }
 
-sub menu {
-    my ($r,$allparms,$allparts,$allkeys,$pscat,$psprt,$fcat)=@_;
-    my $tempkey;
-    
-    &parmmenu($r,$allkeys,$pscat);
-
-    $r->print('<table><tr>');    
-    $r->print('<td><select multiple name="psprt" size="5">');
+sub partmenu {
+    my ($r,$allparts,$psprt)=@_;
+    $r->print('<select multiple name="psprt" size="5">');
     $r->print('<option value="all"');
     $r->print(' selected') unless (@{$psprt});
     $r->print('>'.&mt('All Parts').'</option>');
     my %temphash=();
     foreach (@{$psprt}) { $temphash{$_}=1; }
-    foreach $tempkey (sort keys %{$allparts}) {
+    foreach my $tempkey (sort keys %{$allparts}) {
 	unless ($tempkey =~ /\./) {
 	    $r->print('<option value="'.$tempkey.'"');
 	    if ($$psprt[0] eq "all" ||  $temphash{$tempkey}) {
@@ -831,20 +789,83 @@
 	    $r->print('>'.$$allparts{$tempkey}.'</option>');
 	}
     }
-    $r->print('</select></td></tr><tr><td colspan="3"><hr /></td></tr>');
-    
-    $r->print('<tr><td>'.&mt('Sort list by').'</td><td>');
-    $r->print('<select name="fcat">');
-    $r->print('<option value="">'.&mt('Enclosing Map or Folder').'</option>');
-    foreach (sort keys %{$allkeys}) {
+    $r->print('</select>');
+}
+
+sub usermenu {
+    my ($r,$uname,$id,$udom,$csec)=@_;
+    my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
+        &Apache::loncommon::selectstudent_link('parmform','uname','udom');
+    my $selscript=&Apache::loncommon::studentbrowser_javascript();
+    my %lt=&Apache::lonlocal::texthash(
+		    'sg'    => "Section/Group",
+		    'fu'    => "For User",
+		    'oi'    => "or ID",
+		    'ad'    => "at Domain"
+				       );
+    my %sectionhash=();
+    my $sections='';
+    if (&Apache::loncommon::get_sections(
+                 $env{'course.'.$env{'request.course.id'}.'.domain'},
+                 $env{'course.'.$env{'request.course.id'}.'.num'},
+					 \%sectionhash)) {
+        $sections=$lt{'sg'}.': <select name="csec">';
+	foreach ('',sort keys %sectionhash) {
+	    $sections.='<option value="'.$_.'"'.
+		($_ eq $csec?'selected="selected"':'').'>'.$_.'</option>';
+        }
+        $sections.='</select>';
+     }
+     $r->print(<<ENDMENU);
+<b>
+$sections
+<br />
+$lt{'fu'} 
+<input type="text" value="$uname" size="12" name="uname" />
+$lt{'oi'}
+<input type="text" value="$id" size="12" name="id" /> 
+$lt{'ad'}
+$chooseopt
+</b>
+ENDMENU
+}
+
+sub displaymenu {
+    my ($r,$allparms,$allparts,$pscat,$psprt)=@_;
+    $r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'.
+	     &mt('Select Parts to View').'</th></tr><tr><td>');  
+    &parmmenu($r,$allparms,$pscat);
+    $r->print('</td><td>');
+    &partmenu($r,$allparts,$psprt);
+    $r->print('</td></tr></table>');
+}
+
+sub mapmenu {
+    my ($r,$allmaps,$pschp,$maptitles)=@_;
+    $r->print(&mt('Select Enclosing Map or Folder').' ');
+    $r->print('<select name="pschp">');
+    $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
+    foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) {
 	$r->print('<option value="'.$_.'"');
-	if ($fcat eq $_) { $r->print(' selected'); }
-	$r->print('>'.$$allkeys{$_}.'</option>');
+	if (($pschp eq $_)) { $r->print(' selected'); }
+	$r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').'</option>');
     }
-    $r->print('</select></td>');
-    
-    $r->print('</tr><tr><td colspan="3"><hr /></td></tr></table>');
-    
+    $r->print("</select>");
+}
+
+sub levelmenu {
+    my ($r,$alllevs,$parmlev)=@_;
+    $r->print(&mt('Select Parameter Level').
+	      &Apache::loncommon::help_open_topic('Course_Parameter_Levels').' ');
+    $r->print('<select name="parmlev">');
+    foreach (reverse sort keys %{$alllevs}) {
+	$r->print('<option value="'.$$alllevs{$_}.'"');
+	if ($parmlev eq $$alllevs{$_}) {
+	    $r->print(' selected'); 
+	}
+	$r->print('>'.$_.'</option>');
+    }
+    $r->print("</select>");
 }
 
 ##################################################
@@ -890,7 +911,7 @@
     my %maptitles=();
 
 # -------------------------------------------------------- Variable declaration
-    my %allkeys=();
+
     my %allmaps=();
     my %alllevs=();
 
@@ -908,8 +929,6 @@
     my %allparms;
     my %allparts;
 
-    my %defp;
-
     @ids=();
     %symbp=();
     %typep=();
@@ -932,7 +951,6 @@
 
     my $pssymb='';
     my $parmlev='';
-    my $prevvisit=$env{'form.prevvisit'};
  
     unless ($env{'form.parmlev'}) {
         $parmlev = 'map';
@@ -1003,11 +1021,8 @@
 
     unless ($csec) { $csec=''; }
 
-    my $fcat=$env{'form.fcat'};
-    unless ($fcat) { $fcat=''; }
-
 # --------------------------------------------------------- Get all assessments
-    &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles,\%uris);
+    &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, \%mapp, \%symbp,\%maptitles,\%uris);
 
     $mapp{'0.0'} = '';
     $symbp{'0.0'} = '';
@@ -1026,27 +1041,13 @@
 # ---------------------------------------------------------------- Done storing
 	$message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';
     }
-# ------------------------------------------------------------------- Sort this
-
-    @ids=sort  {
-	if ($fcat eq '') {
-	    $a<=>$b;
-	} else {
-	    my ($result,@outpar)=&parmval($fcat,$a,$defp{$a},$uname,$udom,$csec);
-	    my $aparm=$outpar[$result];
-	    ($result,@outpar)=&parmval($fcat,$b,$defp{$b},$uname,$udom,$csec);
-	    my $bparm=$outpar[$result];
-	    1*$aparm<=>1*$bparm;
-	}
-    } @ids;
 #----------------------------------------------- if all selected, fill in array
-    if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);}
+    if ($pscat[0] eq "all") {@pscat = (keys %allparms);}
+    if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') }; 
     if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
 # ------------------------------------------------------------------ Start page
 
-    &startpage($r,$id,$udom,$csec,$uname,scalar(keys(%allkeys)));
-
-    $r->print('<input type="hidden" value="true" name="prevvisit">');
+    &startpage($r);
 
     foreach ('tolerance','date_default','date_start','date_end',
 	     'date_interval','int','float','string') {
@@ -1054,54 +1055,26 @@
 		  $env{'form.recent_'.$_}.'" name="recent_'.$_.'">');
     }
 
-    $r->print('<h2>'.$message.'</h2><table>');
+    $r->print('<h2>'.$message.'</h2>');
                         
-    my $submitmessage = &mt('Update Section or Specific User');
     if (!$pssymb) {
-        $r->print('<tr><td>'.&mt('Select Parameter Level').
-       &Apache::loncommon::help_open_topic('Course_Parameter_Levels').
-		  '</td><td colspan="2">');
-        $r->print('<select name="parmlev">');
-        foreach (reverse sort keys %alllevs) {
-            $r->print('<option value="'.$alllevs{$_}.'"');
-            if ($parmlev eq $alllevs{$_}) {
-               $r->print(' selected'); 
-            }
-            $r->print('>'.$_.'</option>');
-        }
-        $r->print("</select></td>\n");
-
-        $r->print('</tr>');
+        $r->print('<table border="1"><tr><td>');
+        &levelmenu($r,\%alllevs,$parmlev);
 	if ($parmlev ne 'general') {
-	    $r->print('<tr><td>'.&mt('Select Enclosing Map or Folder').'</td>');
-	    $r->print('<td colspan="2"><select name="pschp">');
-	    $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
-	    foreach (sort {$allmaps{$a} cmp $allmaps{$b}} keys %allmaps) {
-		$r->print('<option value="'.$_.'"');
-		if (($pschp eq $_)) { $r->print(' selected'); }
-		$r->print('>'.$maptitles{$_}.($allmaps{$_}!~/^uploaded/?'  ['.$allmaps{$_}.']':'').'</option>');
-	    }
-	    $r->print("</select></td></tr>\n");
+            $r->print('<td>');
+	    &mapmenu($r,\%allmaps,$pschp,\%maptitles);
+	    $r->print('</td>');
 	}
+        $r->print('</td></tr></table>');
+	&displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt);
     } else {
         my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
-        $r->print("<tr><td>".&mt('Specific Resource')."</td><td>$resource</td>");
-        $r->print('<td><input type="hidden" value="'.
-		  $pssymb.'" name="symb"><input type="submit" name="dis" value="'.
-		  $submitmessage.'"></td>');
-        $r->print('</tr>');
+        $r->print(&mt('Specific Resource').": ".$resource.
+                  '<input type="hidden" value="'.$pssymb.'" name="symb">');
     }
-    $r->print('</table><br />');
-
+    &usermenu($r,$uname,$id,$udom,$csec);    
 
-    &menu($r,\%allparms,\%allparts,\%allkeys,\@pscat,\@psprt,$fcat);
-
-    if (($prevvisit) || ($pschp) || ($pssymb)) {
-        $submitmessage = &mt("Update Course Assessment Parameter Display");
-    } else {
-        $submitmessage = &mt("Set/Modify Course Assessment Parameters");
-    }
-    $r->print('<input type="submit" name="dis" value="'.$submitmessage.'">');
+    $r->print('<br /><input type="submit" name="dis" value="'.&mt("Update Parameter Display").'" />');
 
     my @temp_pscat;
     map {
@@ -1111,7 +1084,7 @@
 
     @pscat = @temp_pscat;
 
-    if (($prevvisit) || ($pschp) || ($pssymb)) {
+    if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
 # ----------------------------------------------------------------- Start Table
         my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
         my $csuname=$env{'user.name'};

--www1117935449--