[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm

www lon-capa-cvs-allow@mail.lon-capa.org
Mon, 19 May 2008 18:43:17 -0000


www		Mon May 19 14:43:17 2008 EDT

  Modified files:              
    /loncom/publisher	lonpublisher.pm 
  Log:
  Bug #5696: Friends don't let friends publish problems without responses
  
  
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.235 loncom/publisher/lonpublisher.pm:1.236
--- loncom/publisher/lonpublisher.pm:1.235	Sat May 17 08:08:45 2008
+++ loncom/publisher/lonpublisher.pm	Mon May 19 14:43:16 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.235 2008/05/17 12:08:45 www Exp $
+# $Id: lonpublisher.pm,v 1.236 2008/05/19 18:43:16 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -665,6 +665,7 @@
                 "Max Index: $maxindex (min 10)\n";
     }
     my $outstring='';
+    my $responsecounter=1;
     my @parser;
     $parser[0]=HTML::LCParser->new(\$content);
     $parser[-1]->xml_mode(1);
@@ -680,6 +681,10 @@
 		    next;
 		}
 		if ($lctag eq 'base') { next; }
+                if (($lctag eq 'part') || ($lctag eq 'problem')) {
+                    $responsecounter=0;
+                }
+                if ($lctag=~/response$/) { $responsecounter++; }
 		my %parms=%{$token->[2]};
 		$counter=$addid{$tag};
 		if (!$counter) { $counter=$addid{$lctag}; }
@@ -784,7 +789,12 @@
 		    unless ($token->[1] eq 'allow') {
 			$outstring.='</'.$token->[1].'>';
 		    }
-		}
+                }
+                if ((($token->[1] eq 'part') || ($token->[1] eq 'problem'))
+                    && (!$responsecounter)) {
+                    my $outstring='<span class="LC_error">'.&mt('Found [_1] without responses',$token->[1]).'</span>';
+                    return ($outstring,1);
+                }
 	    } else {
 		$outstring.=$token->[1];
 	    }