--- loncom/homework/response.pm	2004/02/09 19:38:00	1.90
+++ loncom/homework/response.pm	2004/03/08 22:59:12	1.93
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.90 2004/02/09 19:38:00 albertel Exp $
+# $Id: response.pm,v 1.93 2004/03/08 22:59:12 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -28,6 +28,7 @@
 
 package Apache::response;
 use strict;
+use Apache::lonlocal;
 
 BEGIN {
     &Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse'));
@@ -45,6 +46,16 @@ sub start_response {
     push (@Apache::inputtags::response,$id);
     push (@Apache::inputtags::responselist,$id);
     @Apache::inputtags::inputlist=();
+    if ($Apache::inputtags::part eq '') {
+	&Apache::lonxml::error(&HTML::Entities::encode(&mt("Found a <*response> outside of a <part> in a <part>ed problem")));
+    }
+    if ($Apache::inputtags::response_with_no_part &&
+	$Apache::inputtags::part ne '0') {
+	&Apache::lonxml::error(&HTML::Entities::encode(&mt("<*response>s are both inside of <part> and outside of <part>, this is not a valid problem, errors in grading may occur.")).'<br />');
+    }
+    if ($Apache::inputtags::part eq '0') {
+	$Apache::inputtags::response_with_no_part=1;
+    }
     return $id;
 }
 
@@ -502,6 +513,7 @@ sub scored_response {
 	if ($increase ne '') { $score+=$increase+1; }
     }
     my $weight = &Apache::lonnet::EXT("resource.$part.weight");
+    if (!defined($weight) || $weight eq '' || $weight eq 0) { $weight = 1; }
     my $pcr=$score/$weight;
     $Apache::lonhomework::results{"resource.$part.$id.awarded"}=$pcr;
     $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=