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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 28 Jan 2005 09:48:53 -0000


albertel		Fri Jan 28 04:48:53 2005 EDT

  Modified files:              
    /loncom/homework	lonhomework.pm 
  Log:
  - some cleanup of crappy old code 
  
  
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.192 loncom/homework/lonhomework.pm:1.193
--- loncom/homework/lonhomework.pm:1.192	Tue Jan 11 14:38:53 2005
+++ loncom/homework/lonhomework.pm	Fri Jan 28 04:48:53 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.192 2005/01/11 19:38:53 albertel Exp $
+# $Id: lonhomework.pm,v 1.193 2005/01/28 09:48:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -377,10 +377,11 @@
     my ($array)=@_;
     my $string="(";
     foreach my $elm (@{ $array }) {
-	if (ref($elm)) {
-	    if ($elm =~ /ARRAY/ ) {
-		$string.=&showarray($elm);
-	    }
+	if (ref($elm) eq 'ARRAY') {
+	    $string.=&showarray($elm);
+	} elsif (ref($elm) eq 'HASH') {
+	    $string.= "HASH --- \n<br />";
+	    $string.= &showhashsubset($elm,'.');
 	} else {
 	    $string.="$elm,"
 	}
@@ -394,20 +395,15 @@
     my ($hash,$keyre) = @_;
     my $resultkey;
     foreach $resultkey (sort keys %$hash) {
-	if ($resultkey =~ /$keyre/) {
-	    if (ref($$hash{$resultkey})) {
-		if ($$hash{$resultkey} =~ /ARRAY/ ) {
-		    &Apache::lonxml::debug("$resultkey ---- ".
-					   &showarray($$hash{$resultkey}));
-		} elsif ($$hash{$resultkey} =~ /HASH/ ) {
-		    &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");
-		    &showhashsubset($$hash{$resultkey},'.');
-		} else {
-		    &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");
-		}
-	    } else {
-		&Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");
-	    }
+	if ($resultkey !~ /$keyre/) { next; }
+	if (ref($$hash{$resultkey})  eq 'ARRAY' ) {
+	    &Apache::lonxml::debug("$resultkey ---- ".
+				   &showarray($$hash{$resultkey}));
+	} elsif (ref($$hash{$resultkey}) eq 'HASH' ) {
+	    &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");
+	    &showhashsubset($$hash{$resultkey},'.');
+	} else {
+	    &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");
 	}
     }
     &Apache::lonxml::debug("\n<br />restored values^</br>\n");
@@ -818,18 +814,14 @@
     $Apache::lonxml::debug=$ENV{'user.debug'};
     $ENV{'request.uri'}=$request->uri;
     &setuppermissions();
-    &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:");
     # some times multiple problemmodes are submitted, need to select
     # the last one
-    &Apache::lonxml::debug("Problem Mode ".$ENV{'form.problemmode'});
-    if ( defined($ENV{'form.problemmode'}) &&
-	 ref($ENV{'form.problemmode'}) ) {
-	&Apache::lonxml::debug("Problem Mode ".join(",",@$ENV{'form.problemmode'}));
+    if ( defined($ENV{'form.problemmode'}) && ref($ENV{'form.problemmode'}) ) {
 	my $mode=$ENV{'form.problemmode'}->[-1];
 	undef $ENV{'form.problemmode'};
 	$ENV{'form.problemmode'}=$mode;
     }
-    &Apache::lonxml::debug("Problem Mode ".$ENV{'form.problemmode'});
+
     my $file=&Apache::lonnet::filelocation("",$request->uri);
 
     #check if we know where we are
@@ -846,7 +838,8 @@
 	}
     }
     if (&setupheader($request)) { return OK; }
-
+    &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:");
+    &Apache::lonxml::debug("Problem Mode ".$ENV{'form.problemmode'});
     my ($symb) = &Apache::lonxml::whichuser();
     &Apache::lonxml::debug('symb is '.$symb);
     if ($ENV{'request.state'} eq "construct" || $symb eq '') {