[LON-CAPA-cvs] cvs: loncom /homework radiobuttonresponse.pm

onken lon-capa-cvs-allow@mail.lon-capa.org
Fri, 05 Sep 2008 12:50:47 -0000


onken		Fri Sep  5 08:50:47 2008 EDT

  Modified files:              
    /loncom/homework	radiobuttonresponse.pm 
  Log:
  Adds PDF-formfields function to radiobutton-problems (not to exams)
  
  
Index: loncom/homework/radiobuttonresponse.pm
diff -u loncom/homework/radiobuttonresponse.pm:1.134 loncom/homework/radiobuttonresponse.pm:1.135
--- loncom/homework/radiobuttonresponse.pm:1.134	Fri Aug  8 12:37:13 2008
+++ loncom/homework/radiobuttonresponse.pm	Fri Sep  5 08:50:45 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # mutliple choice style responses
 #
-# $Id: radiobuttonresponse.pm,v 1.134 2008/08/08 16:37:13 bisitz Exp $
+# $Id: radiobuttonresponse.pm,v 1.135 2008/09/05 12:50:45 onken Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -100,7 +100,12 @@
 	} else {
 	    $result .= ' \renewcommand{\labelenumi}{\Alph{enumi}.}';
 	}
-	$result .= '\begin{enumerate}';
+        if($env{'form.pdfFormFields'} eq 'yes') {
+            $result .= &Apache::lonxml::print_pdf_hiddenfield('meta', $env{'user.name'}, $env{'user.domain'});
+            $result .= "\n\\\\\n\\\\\n";
+        } else {
+            $result .= '\begin{enumerate}';
+        }
     } elsif ($target eq 'analyze') {
 	my $part_id="$Apache::inputtags::part.$id";
         $Apache::lonhomework::analyze{"$part_id.type"} = 'radiobuttonresponse';
@@ -113,7 +118,9 @@
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;
     if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
-    if ($target eq 'tex') { $result .= '\end{enumerate}'; }
+    if ($target eq 'tex' and $env{'form.pdfFormFields'} ne 'yes') { 
+        $result .= '\end{enumerate}'; 
+    }
     &Apache::response::end_response;
     pop @Apache::lonxml::namespace;
     &Apache::lonxml::deregister('Apache::radiobuttonresponse',('foilgroup','foil','conceptgroup'));
@@ -347,13 +354,27 @@
 		    $result.="<td>";
 		} else {
 		    if ($target eq 'tex') {
-			$result .= '\item \vskip -2mm ';
-		    } else {
+		        if($env{'form.pdfFormFields'} eq 'yes') {
+                            my $fieldname = $env{'request.symb'}.
+                                           '&part_'. $Apache::inputtags::part.
+                                           '&radiobuttonresponse'.
+                                           '&HWVAL_' . $Apache::inputtags::response['-1'];
+                            my $value = $temp;
+                            my $text = $Apache::response::foilgroup{$name.'.text'};
+                            $result .= &Apache::lonxml::print_pdf_radiobutton($fieldname,
+                                                                             $value,
+                                                                             $text)."\n";
+                        } else {
+                            $result .= '\item \vskip -2mm ';
+                        }
+                    } else {
 			$result.="<br />";
 		    }
 		}
 		if ($target eq 'tex') {
-		    $result .= '$\bigcirc$'.$Apache::response::foilgroup{$name.'.text'}.'\\\\';  #' stupid emacs
+		    if($env{'form.pdfFormFields'} ne 'yes') {
+                        $result .= '$\bigcirc$'.$Apache::response::foilgroup{$name.'.text'}.'\\\\';  #' stupid emacs
+                    }
 		    $i++;
 		} else {
 		    $result .= '<label>';
@@ -632,8 +653,19 @@
 		    $i++;
 		    $bubble_number++;
 		} else {
-		    $result .= '\vspace*{-2 mm}\item '.$Apache::response::foilgroup{$name.'.text'};
-		}
+		      if($env{'form.pdfFormFields'} eq 'yes') {
+
+                         my $fieldname = $env{'request.symb'}.
+                                         '&part_'. $Apache::inputtags::part.
+                                         '&radiobuttonresponse'.
+                                         '&HWVAL_' . $Apache::inputtags::response['-1'];
+                         my $value = $temp;
+                         my $text = $Apache::response::foilgroup{$name.'.text'};
+                         $result .= &Apache::lonxml::print_pdf_radiobutton($fieldname, $value, $text).'\newline'."\n";
+                     } else { 
+                         $result .= '\vspace*{-2 mm}\item '.$Apache::response::foilgroup{$name.'.text'};
+                     }
+                }
 	    }
 	    if ($target ne 'tex' && $direction eq 'horizontal') {
 		$result.="</td>";