[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm /publisher packages.tab rat/client parameter.html

albertel lon-capa-cvs-allow@mail.lon-capa.org
Wed, 17 Oct 2007 00:27:52 -0000


albertel		Tue Oct 16 20:27:52 2007 EDT

  Modified files:              
    /rat/client	parameter.html 
    /loncom/interface	lonparmset.pm 
    /loncom/publisher	packages.tab 
  Log:
  - BUG#5395 update selectors to support all 3 problem status modes
  
  
Index: rat/client/parameter.html
diff -u rat/client/parameter.html:1.46 rat/client/parameter.html:1.47
--- rat/client/parameter.html:1.46	Wed Aug 29 20:02:20 2007
+++ rat/client/parameter.html	Tue Oct 16 20:27:19 2007
@@ -3,7 +3,7 @@
 The LearningOnline Network with CAPA
 Parameter Input Window
 //
-// $Id: parameter.html,v 1.46 2007/08/30 00:02:20 albertel Exp $
+// $Id: parameter.html,v 1.47 2007/10/17 00:27:19 albertel Exp $
 //
 // Copyright Michigan State University Board of Trustees
 //
@@ -556,6 +556,22 @@
            if (svalue=='no') { choicewrite(' checked'); }
            choicewrite('> No</label><br />');
         }
+        if (pscat=='problemstatus') {
+           tablestart('Problem Status');
+	   choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
+           choicewrite('<label><input name="stringval" value="yes"'+
+                  ' type="radio" '+callradiostringeval('yes'));
+           if (svalue=='yes') { choicewrite(' checked'); }
+           choicewrite('> Yes</label><br />');
+           choicewrite('<label><input name="stringval" value="no"'+
+                  ' type="radio" '+callradiostringeval('no'));
+           if (svalue=='no') { choicewrite(' checked'); }
+           choicewrite('> No, don\'t show correct/incorrect feedback.</label><br />');
+           choicewrite('<label><input name="stringval" value="no_feedback_ever"'+
+                  ' type="radio" '+callradiostringeval('no_feedback_ever'));
+           if (svalue=='no_feedback_ever') { choicewrite(' checked'); }
+           choicewrite('> No, show no feedback at all.</label><br />');
+        }
         if (pscat=='examtype') {
            tablestart('Exam Type');
 	   choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
@@ -848,6 +864,7 @@
   if (ptype=='string') {
      //sopt('default','Default');
      if (pscat == 'yesno')        { sopt('yesno','Yes/No'); }
+     else if (pscat == 'problemstatus'){ sopt('problemstatus','Problem Status'); }
      else if (pscat == 'examtype')     { sopt('examtype','Exam Type'); }
      else if (pscat == 'questiontype') { sopt('questiontype','Question Type'); }
      else if (pscat == 'ip')           { sopt('ip','IP Number/Name'); }
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.382 loncom/interface/lonparmset.pm:1.383
--- loncom/interface/lonparmset.pm:1.382	Sat Oct  6 00:32:49 2007
+++ loncom/interface/lonparmset.pm	Tue Oct 16 20:27:44 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.382 2007/10/06 04:32:49 raeburn Exp $
+# $Id: lonparmset.pm,v 1.383 2007/10/17 00:27:44 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2739,30 +2739,11 @@
 '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
 &date_sanity_info($$resourcedata{$thiskey})
 			  );
-	    } elsif ($thistype eq 'string_yesno') {
-		my $showval;
-		if (defined($$resourcedata{$thiskey})) {
-		    $showval=$$resourcedata{$thiskey};
-		}
-		$r->print('<label><input type="radio" name="set_'.$thiskey.
-			  '" value="yes"');
-		if ($showval eq 'yes') {
-		    $r->print(' checked="checked"');
-		}
-                $r->print(' />'.&mt('Yes').'</label> ');
-		$r->print('<label><input type="radio" name="set_'.$thiskey.
-			  '" value="no"');
-		if ($showval eq 'no') {
-		    $r->print(' checked="checked"');
-		}
-                $r->print(' />'.&mt('No').'</label>');
+	    } elsif ($thistype =~ m/^string/) {
+		$r->print(&string_selector($thistype,$thiskey,
+					   $$resourcedata{$thiskey}));
 	    } else {
-		my $showval;
-		if (defined($$resourcedata{$thiskey})) {
-		    $showval=$$resourcedata{$thiskey};
-		}
-		$r->print('<input type="text" name="set_'.$thiskey.'" value="'.
-			  $showval.'">');
+		$r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
 	    }
 	    $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
 		      $thistype.'">');
@@ -2772,6 +2753,43 @@
     return $foundkeys;
 }
 
+sub default_selector {
+    my ($thiskey, $showval) = @_;
+    return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'">' ;
+}
+
+my %strings = 
+    (
+     'string_yesno'
+             => [[ 'yes', 'Yes' ],
+		 [ 'no', 'No' ]],
+     'string_problemstatus'
+             => [[ 'yes', 'Yes' ],
+		 [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
+		 [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
+     );
+
+
+sub string_selector {
+    my ($thistype, $thiskey, $showval) = @_;
+    
+    if (!exists($strings{$thistype})) {
+	return &default_selector($thiskey,$showval);
+    }
+
+    my $result;
+    foreach my $possibilities (@{ $strings{$thistype} }) {
+	my ($name, $description) = @{ $possibilities };
+	$result .= '<label><input type="radio" name="set_'.$thiskey.
+		  '" value="'.$name.'"';
+	if ($showval eq $name) {
+	    $result .= ' checked="checked"';
+	}
+	$result .= ' />'.&mt($description).'</label> ';
+    }
+    return $result;
+}
+
 sub newoverview {
     my ($r) = @_;
 
@@ -3002,8 +3020,8 @@
 	next if (!exists($resourcedata->{$thiskey.'.type'})
 		 && $thiskey=~/\.type$/);
 	my %data = &parse_key($thiskey);
-	if (exists($data{'realm_exists'})
-	    && !$data{'realm_exists'}) {
+	if (1) { #exists($data{'realm_exists'})
+	    #&& !$data{'realm_exists'}) {
 	    $r->print(&Apache::loncommon::start_data_table_row().
 		      '<tr>'.
 		      '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>'		      );
Index: loncom/publisher/packages.tab
diff -u loncom/publisher/packages.tab:1.52 loncom/publisher/packages.tab:1.53
--- loncom/publisher/packages.tab:1.52	Thu Sep  6 17:42:16 2007
+++ loncom/publisher/packages.tab	Tue Oct 16 20:27:51 2007
@@ -21,7 +21,7 @@
 part&type&type:string_questiontype
 part&acc&display:Client IP/Name Access Control
 part&acc&type:string_ip
-part&problemstatus&type:string_yesno
+part&problemstatus&type:string_problemstatus
 part&problemstatus&default:yes
 part&problemstatus&display:Show Problem Status
 part&display&display:Part Description