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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 12 Oct 2006 17:16:54 -0000


albertel		Thu Oct 12 13:16:54 2006 EDT

  Modified files:              
    /loncom/homework	response.pm 
  Log:
  - adding ability for multiple answer for 1 response
  
  
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.146 loncom/homework/response.pm:1.147
--- loncom/homework/response.pm:1.146	Tue Aug  1 10:41:46 2006
+++ loncom/homework/response.pm	Thu Oct 12 13:16:53 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.146 2006/08/01 14:41:46 albertel Exp $
+# $Id: response.pm,v 1.147 2006/10/12 17:16:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -686,9 +686,10 @@
 
 {
     my @answer_bits;
+    my $need_row_start;
 
 sub answer_header {
-    my ($type,$increment) = @_;
+    my ($type,$increment,$rows) = @_;
     my $result;
     if ($env{'form.answer_output_mode'} eq 'tex') {
 	undef(@answer_bits);
@@ -701,13 +702,28 @@
 	}
 	push(@answer_bits,$bit);
     } else {
+	my $td = '<td '.(defined($rows)?'rowspan="'.$rows.'"':'').'>';
 	$result  = '<table border="1"><tr>';
 	if ($Apache::lonhomework::type eq 'exam') {
-	    $result .= '<td>'.($Apache::lonxml::counter+$increment). ')</td>';
+	    $result .= $td.($Apache::lonxml::counter+$increment). ')</td>';
 	} else {
-	    $result .= '<td>Answer for Part:'.$Apache::inputtags::part.'</td>';
+	    $result .= $td.&mt('Answer for Part: [_1]',
+			       $Apache::inputtags::part).'</td>';
 	}
 	$result .= "\n";
+	$need_row_start = 0;
+    }
+    return $result;
+}
+
+sub next_answer {
+    my ($type) = @_;
+    my $result;
+    if ($env{'form.answer_output_mode'} eq 'tex') {
+	# FIXME ... need to do something with tex mode
+    } else {
+	$result .= "</tr>";
+	$need_row_start = 1;
     }
     return $result;
 }
@@ -728,7 +744,11 @@
 	    push(@answer_bits,'\verb'.$to_use.$answer.$to_use);
 	}
     } else {
-	$result = '<td>'.$answer.'</td>';
+	if ($need_row_start) {
+	    $result .= '<tr>';
+	    $need_row_start = 0;
+	}
+	$result .= '<td>'.$answer.'</td>';
     }
     return $result;
 }