[LON-CAPA-cvs] cvs: loncom /homework essayresponse.pm imageresponse.pm inputtags.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 09 Mar 2006 01:11:17 -0000


albertel		Wed Mar  8 20:11:17 2006 EDT

  Modified files:              
    /loncom/homework	inputtags.pm essayresponse.pm imageresponse.pm 
  Log:
  - consolidating the 'leave blank on scoring form code'
  - image response gets blank lines in exam mode
  - imageresponse can be scored in exam mode
  
  
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.189 loncom/homework/inputtags.pm:1.190
--- loncom/homework/inputtags.pm:1.189	Wed Mar  8 19:43:05 2006
+++ loncom/homework/inputtags.pm	Wed Mar  8 20:11:12 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.189 2006/03/09 00:43:05 albertel Exp $
+# $Id: inputtags.pm,v 1.190 2006/03/09 01:11:12 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -222,21 +222,32 @@
     return $result;
 }
 
-sub exam_box {
+sub exam_score_line {
     my ($target) = @_;
-    my $result;
 
+    my $result;
     if ($target eq 'tex') {
-	$result.='\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}';
 	my $repetition = &Apache::response::repetition();
 	$result.='\begin{enumerate}';
+	if ($env{'request.state'} eq "construct" ) {$result.='\item[\strut]';}
 	foreach my $i (0..$repetition-1) {
 	    $result.='\item[\textbf{'.
 		($Apache::lonxml::counter+$i).
 		'}.]\textit{Leave blank on scoring form}\vskip 0 mm';
 	}
 	$result.= '\end{enumerate}';
+    }
+
+    return $result;
+}
+
+sub exam_box {
+    my ($target) = @_;
+    my $result;
 
+    if ($target eq 'tex') {
+	$result .= '\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}';
+	$result .= &exam_score_line($target);
     } elsif ($target eq 'web') {
 	my $id=$Apache::inputtags::response[-1];
 	$result.= '<br /><br />
@@ -252,7 +263,6 @@
 		'stringresponse',
 		'reactionresponse',
 		'organicresponse',
-		'imageresponse',
 		);
 
     foreach my $tag (@tags) {
Index: loncom/homework/essayresponse.pm
diff -u loncom/homework/essayresponse.pm:1.70 loncom/homework/essayresponse.pm:1.71
--- loncom/homework/essayresponse.pm:1.70	Wed Mar  8 20:07:04 2006
+++ loncom/homework/essayresponse.pm	Wed Mar  8 20:11:12 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # essay (ungraded) style responses
 #
-# $Id: essayresponse.pm,v 1.70 2006/03/09 01:07:04 albertel Exp $
+# $Id: essayresponse.pm,v 1.71 2006/03/09 01:11:12 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -129,24 +129,17 @@
 	} 
     } elsif ($target eq 'edit') {
 	$result.=&Apache::edit::end_table();
-    } elsif ($target eq 'tex') {
-	if ($Apache::lonhomework::type eq 'exam') {
-	    my $repetition=&Apache::response::repetition();
-	    $result.='\begin{enumerate}';
-	    if ($env{'request.state'} eq "construct" ) {$result.='\item[\strut]';}
-	    for (my $i=0;$i<$repetition;$i++) {
-		$result.='\item[\textbf{'.($Apache::lonxml::counter+$i).
-		    '}.]\textit{'.&mt('Leave blank on scoring form').
-		    '}\vskip 0 mm';
-	    }
-	    $result.= '\end{enumerate}';
-	    $increment=$repetition;
-	}
+
+    } elsif ($target eq 'tex'
+	     && $Apache::lonhomework::type eq 'exam') {
+	$result .= &Apache::inputtags::exam_score_line($target);
+
     } elsif ($target eq 'answer') {
 	$result.=&Apache::response::answer_header($$tagstack[-1]);
 	$result.=&Apache::response::answer_part($$tagstack[-1],'');
 	$result.=&Apache::response::answer_footer($$tagstack[-1]);
     }
+
     if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
 	$target eq 'tex' || $target eq 'analyze') {
 	&Apache::lonxml::increment_counter($increment);
Index: loncom/homework/imageresponse.pm
diff -u loncom/homework/imageresponse.pm:1.73 loncom/homework/imageresponse.pm:1.74
--- loncom/homework/imageresponse.pm:1.73	Thu Dec  1 13:46:31 2005
+++ loncom/homework/imageresponse.pm	Wed Mar  8 20:11:12 2006
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # image click response style
 #
-# $Id: imageresponse.pm,v 1.73 2005/12/01 18:46:31 albertel Exp $
+# $Id: imageresponse.pm,v 1.74 2006/03/09 01:11:12 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -63,12 +63,25 @@
 
 sub end_imageresponse {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
-    &Apache::response::end_response;
-    pop @Apache::lonxml::namespace;
+
+    pop(@Apache::lonxml::namespace);
     &Apache::lonxml::deregister('Apache::imageresponse',('foilgroup','foil','text','image','rectangle','conceptgroup'));
+
     my $result;
-    if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
+    if ($target eq 'edit') {
+	$result=&Apache::edit::end_table();
+    } elsif ($target eq 'tex') {
+	$result=&Apache::inputtags::exam_score_line($target);
+    }
+
     undef(%Apache::response::foilnames);
+    
+    if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || 
+	$target eq 'tex' || $target eq 'analyze') {
+	&Apache::lonxml::increment_counter(&Apache::response::repetition());
+    }
+    &Apache::response::end_response();
+
     return $result;
 }
 
@@ -238,10 +251,18 @@
 
 sub gradefoils {
     my (@whichopt) = @_;
+
+    my $partid = $Apache::inputtags::part;
+    my $id     = $Apache::inputtags::response['-1'];
+
+    if ($Apache::lonhomework::type eq 'exam') {
+	&Apache::response::scored_response($partid,$id);
+	return;
+    }
+    
     my $x;
     my $y;
     my $result;
-    my $id=$Apache::inputtags::response['-1'];
     my $temp=1;
     foreach my $name (@whichopt) {
 	$x=$env{"form.HWVAL_$id:$temp.x"};
@@ -280,7 +301,7 @@
     &Apache::response::handle_previous(\%previous,$result);
     $Apache::lonhomework::results{"resource.$part.$id.submission"}=$responsestr;
     $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$result;
-    return '';
+    return;
 }
 
 sub end_foilgroup {