[LON-CAPA-cvs] cvs: loncom /interface lonchart.pm

stredwic lon-capa-cvs@mail.lon-capa.org
Mon, 08 Jul 2002 16:50:03 -0000


stredwic		Mon Jul  8 12:50:03 2002 EDT

  Modified files:              
    /loncom/interface	lonchart.pm 
  Log:
  Add some comments in the code.
  
  
Index: loncom/interface/lonchart.pm
diff -u loncom/interface/lonchart.pm:1.57 loncom/interface/lonchart.pm:1.58
--- loncom/interface/lonchart.pm:1.57	Mon Jul  8 11:03:25 2002
+++ loncom/interface/lonchart.pm	Mon Jul  8 12:50:03 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonchart.pm,v 1.57 2002/07/08 15:03:25 stredwic Exp $
+# $Id: lonchart.pm,v 1.58 2002/07/08 16:50:03 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -245,6 +245,8 @@
 	    my $problem = $CacheData{$problemID.':problem'};
 	    my $LatestVersion = $CacheData{$name.":version:$problem"};
 
+            # Output blanks for all the parts of this problem if there
+            # is no version information about the current problem.
             if(!$LatestVersion) {
                 foreach my $part (split(/\:/,$CacheData{$sequence.':'.
                                                         $problemID.
@@ -257,13 +259,19 @@
             }
 
             my %partData=undef;
-            #initialize data, displays skips correctly
+            # Initialize part data, display skips correctly
+            # Skip refers to when a student made no submissions on that
+            # part/problem.
             foreach my $part (split(/\:/,$CacheData{$sequence.':'.
                                                     $problemID.
                                                     ':parts'})) {
                 $partData{$part.':tries'}=0;
                 $partData{$part.':code'}=' ';
             }
+
+            # Looping through all the versions of each part, starting with the
+            # oldest version.  Basically, it gets the most recent 
+            # set of grade data for each part.
 	    for(my $Version=1; $Version<=$LatestVersion; $Version++) {
                 foreach my $part (split(/\:/,$CacheData{$sequence.':'.
                                                         $problemID.
@@ -271,6 +279,7 @@
 
                     if(!defined($CacheData{$name.":$Version:$problem".
                                                ":resource.$part.solved"})) {
+                        # No grade for this submission, so skip
                         next;
                     }
 
@@ -294,6 +303,9 @@
                 }
             }
 
+            # All grades (except for versionless parts) are displayed as links
+            # to their submission record.  Loop through all the parts for the
+            # current problem in the correct order and prepare the output links
             $Str.='<a href="/adm/grades?symb='.
                 &Apache::lonnet::escape($problem).
                 '&student='.$sname.'&domain='.$sdom.'&command=submission">'; 
@@ -319,6 +331,9 @@
             $Str.='</a>';
         }
 
+        # Output the number of correct answers for the current sequence.
+        # This part takes up 6 character slots, but is formated right 
+        # justified.
         my $spacesNeeded=$CacheData{$sequence.':columnWidth'}-$characterCount;
         $spacesNeeded -= 3;
         $Str .= (' 'x$spacesNeeded);
@@ -331,6 +346,9 @@
         $Str .= $spacePadding;
     }
 
+    # Output the total correct problems over the total number of problems.
+    # I don't like this type of formatting, but it is a solution.  Need
+    # a way to dynamically determine the space requirements.
     my $outputProblemsSolved = sprintf( "%4d", $problemsSolved );
     my $outputTotalProblems  = sprintf( "%4d", $totalProblems );
     $Str .= '<font color="#000088">'.$outputProblemsSolved.
@@ -843,6 +861,7 @@
 	return 'Could not tie cache hash.';
     }
 
+    # Initialize state machine.  Set information pointing to top level map.
     my (@sequences, @currentResource, @finishResource);
     my ($currentSequence, $currentResourceID, $lastResourceID);
 
@@ -911,7 +930,7 @@
 		    ':'.$currentResourceID;
 	    }
 
-            #Get Parts for problem
+            # Get Parts for problem
 	    my $meta=$hash{'src_'.$currentResourceID};
 	    foreach (split(/\,/,&Apache::lonnet::metadata($meta,'keys'))) {
 		if($_=~/^stores\_(\d+)\_tries$/) {
@@ -928,9 +947,9 @@
 	    }
 	}
 
-	#if resource == finish resource
+	# if resource == finish resource, then it is the end of a sequence/page
 	if($currentResourceID eq $lastResourceID) {
-	    #pop off last resource of sequence
+	    # pop off last resource of sequence
 	    $currentResourceID=pop(@currentResource);
 	    $lastResourceID=pop(@finishResource);
 
@@ -962,6 +981,8 @@
                         (scalar @titleLength);
 		}
 	    } else {
+                # Remove sequence from list, if it contains no problems to
+                # display.
                 $CacheData{'orderedSequences'}=~s/$currentSequence//;
                 $CacheData{'orderedSequences'}=~s/::/:/g;
                 $CacheData{'orderedSequences'}=~s/^:|:$//g;
@@ -974,7 +995,7 @@
 	}
 
 	# MOVE!!!
-	#move to next resource
+	# move to next resource
 	unless(defined($hash{'to_'.$currentResourceID})) {
 	    # big problem, need to handle.  Next is probably wrong
 	    last;
@@ -1302,26 +1323,29 @@
 
 =cut
 
+# For all data, if ENV data doesn't exist for it, default values is used.
 sub ProcessFormData {
     my ($ChartDB, $isCached)=@_;
     my %CacheData;
 
     if(tie(%CacheData,'GDBM_File',$ChartDB,&GDBM_WRCREAT,0640)) {
+        # Ignore $ENV{'form.refresh'}
+        # Ignore $ENV{'form.recalculate'}
+
         if(defined($ENV{'form.sort'})) {
             $CacheData{'form.sort'}=$ENV{'form.sort'};
         } elsif(!defined($CacheData{'form.sort'})) {
             $CacheData{'form.sort'}='username';
         }
 
-        # Ignore $ENV{'form.refresh'}
-        # Ignore $ENV{'form.recalculate'}
-
         if(defined($ENV{'form.status'})) {
             $CacheData{'form.status'}=$ENV{'form.status'};
         } elsif(!defined($CacheData{'form.status'})) {
             $CacheData{'form.status'}='Active';
         }
 
+        # $found checks for any instances of form data in the ENV.  If it is
+        # missing I assume the chrt button on the remote has been pressed.
         my @headings=();
         my @sequences=();
         my $found=0;
@@ -1355,6 +1379,8 @@
             }
         }
 
+        # !$found and !$isCached are how I determine if the chrt button
+        # on the remote was pressed and needs to reset all the selections
         if(defined($ENV{'form.reset'}) || (!$found && !$isCached)) {
             $CacheData{'form.reset'}='true';
             $CacheData{'form.status'}='Active';
@@ -1442,7 +1468,8 @@
 =item &ProcessFullName()
 
 Takes lastname, generation, firstname, and middlename (or some partial
-set of this data) and returns the full name version as a string.
+set of this data) and returns the full name version as a string.  Format
+is Lastname generation, firstname middlename or a subset of this.
 
 =cut
 
@@ -1870,7 +1897,7 @@
         $r->send_http_header;
         return OK;
     }
-    
+
     unless($ENV{'request.course.fn'}) {
         my $requrl=$r->uri;
         $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";