[LON-CAPA-cvs] cvs: modules /raeburn FIE_usage.pl

raeburn lon-capa-cvs@mail.lon-capa.org
Fri, 19 May 2006 01:57:34 -0000


This is a MIME encoded message

--raeburn1148003854
Content-Type: text/plain

raeburn		Thu May 18 21:57:34 2006 EDT

  Modified files:              
    /modules/raeburn	FIE_usage.pl 
  Log:
  Adding some normalization.
  
  
--raeburn1148003854
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060518215734.txt"

Index: modules/raeburn/FIE_usage.pl
diff -u modules/raeburn/FIE_usage.pl:1.2 modules/raeburn/FIE_usage.pl:1.3
--- modules/raeburn/FIE_usage.pl:1.2	Fri Mar 31 14:05:25 2006
+++ modules/raeburn/FIE_usage.pl	Thu May 18 21:57:31 2006
@@ -82,7 +82,7 @@
 
 my $output = '';
 open (SUMM,">/home/raeburn/fie/data/summary.txt");
-$output .= "ID,CourseCode,Enrollment,Cloned,Items,Problems,Exams,Surveys,Allproblems,Essay,Match,Numerical,Option,Radiobutton,String,Formula,Rank,Images,NumResponses,gnuplot,multipart,Scripts,Functions,Duplicates,Hidden,Encrypted,Conditional,Randompicks,Embedded-res,Embedded-upload,Scantron,Imported,Homegrown,HomeDomain,Uploaded,WithDiscussion,NoDiscussion,TotalPosts,Broadcast,Critical,UserNotes,examupload,Calendar\n";
+print SUMM "ID,CourseCode,Enrollment,Cloned,Items,Problems,Exams,Surveys,Allproblems,Essay,Match,Numerical,Option,Radiobutton,String,Formula,Rank,Images,NumResponses,gnuplot,multipart,Scripts,Functions,Duplicates,Hidden,Encrypted,Conditional,Randompicks,Embedded-res,Embedded-upload,Scantron,Imported,Homegrown,HomeDomain,Uploaded,WithDiscussion,NoDiscussion,TotalPosts,Broadcast,Critical,UserNotes,examupload,Calendar\n";
 
 # For each domain ......
 foreach my $dom (@domains) {
@@ -207,6 +207,8 @@
                 }
             }
         }
+        my $totalmaps = 0;
+        my $numparsed = 0;
 
         if ($stucount > 0 && $lastvisit > 0) {
             $summary{enrollment} = $stucount;
@@ -327,7 +329,7 @@
             my %unread = ();
             my $discussiondata = $navmap->get_discussion_data();
             my %parse_done = ();
-            my %probitem = ();  
+            my %probitem = ();
             foreach my $resource (@allres) {
                 my $src = $resource->src();
                 $crsitems{$cid} ++;
@@ -344,6 +346,8 @@
                         $numparts{$cid}{$src} = scalar(@parts);
                         if (@parts > 1) {
                             $summary{multipart} ++;
+                        } else {
+                            $summary{singlepart} ++;
                         }
                     }
                     unless(defined($probitem{$src})) {
@@ -386,6 +390,7 @@
                     if ($numpick) {
                         $numrandompicks{$cid} ++;
                     }
+                    $totalmaps ++; 
                 }
                 if ($resource->randomout()) {
                     $numhidden{$cid} ++;
@@ -437,38 +442,62 @@
                     $nodiscussion{$cid} ++;
                 }
             }
+            $numparsed = scalar(keys(%parse_done));
         }
         $summary{items} = $crsitems{$cid};
-        $summary{problem} = $prob_types{$cid}{problem};
-        $summary{exam} = $prob_types{$cid}{exam};
-        $summary{survey} = $prob_types{$cid}{survey};
-        $summary{essay} = $response_types{$cid}{essay};
-        $summary{match} = $response_types{$cid}{match};
-        $summary{numerical} = $response_types{$cid}{numerical};
-        $summary{option} = $response_types{$cid}{option};
-        $summary{radiobutton} = $response_types{$cid}{radiobutton};
-        $summary{string} = $response_types{$cid}{string};
-        $summary{formula} = $response_types{$cid}{formula};
-        $summary{rank} = $response_types{$cid}{rank};
-        $summary{images} = $response_types{$cid}{'image'};
+        if ($prob_types{$cid}{problem}+$prob_types{$cid}{exam}+$prob_types{$cid}{survey} > 0) {
+            $summary{problem} = 100*($prob_types{$cid}{problem})/($prob_types{$cid}{problem}+$prob_types{$cid}{exam}+$prob_types{$cid}{survey});
+            $summary{exam} = 100*($prob_types{$cid}{exam})/($prob_types{$cid}{problem}+$prob_types{$cid}{exam}+$prob_types{$cid}{survey});
+            $summary{survey} = 100*($prob_types{$cid}{survey})/($prob_types{$cid}{problem}+$prob_types{$cid}{exam}+$prob_types{$cid}{survey});
+        }
+        if ($numresponses{$cid} > 0) {
+            $summary{essay} = 100 * $response_types{$cid}{essay}/($numresponses{$cid});
+            $summary{match} = 100 *$response_types{$cid}{match}/($numresponses{$cid});
+            $summary{numerical} = 100 *$response_types{$cid}{numerical}/($numresponses{$cid});
+            $summary{option} = 100 *$response_types{$cid}{option}/($numresponses{$cid});
+            $summary{radiobutton} = 100 * $response_types{$cid}{radiobutton}/($numresponses{$cid});
+            $summary{string} = 100 * $response_types{$cid}{string}/($numresponses{$cid});
+            $summary{formula} = 100 * $response_types{$cid}{formula}/($numresponses{$cid});
+            $summary{rank} = 100 * $response_types{$cid}{rank}/($numresponses{$cid});
+            $summary{images} = 100 * $response_types{$cid}{'image'}/($numresponses{$cid});
+        }
         $summary{numresponses} = $numresponses{$cid};
-        $summary{gnuplot} = $alltags{$cid}{gnuplot};
-        $summary{script} = $alltags{$cid}{script}; 
+        if ($numparsed > 0) {
+            $summary{gnuplot} = 100 * $alltags{$cid}{gnuplot}/$numparsed;
+            $summary{script} = 100 * $alltags{$cid}{script}/$numparsed;
+        }
         $summary{numscantrons} = $numscantrons{$cid};
-        $summary{external} = $external{$cid};
-        $summary{homegrown} = $homegrown{$cid};
-        $summary{homedomain} = $homedomain{$cid};
-        $summary{uploaded} = $uploaded{$cid};
-        $summary{withdiscussion} = $withdiscussion{$cid};
-        $summary{nodiscussion} = $nodiscussion{$cid};
-        $summary{totalposts} = $totalposts{$cid};
+        if ($external{$cid} + $homegrown{$cid} + $homedomain{$cid} +$uploaded{$cid} > 0) {
+            $summary{external} = 100 * $external{$cid}/($external{$cid} + $homegrown{$cid} + $homedomain{$cid} +$uploaded{$cid});
+            $summary{homegrown} = 100 * $homegrown{$cid}/($external{$cid} + $homegrown{$cid} + $homedomain{$cid} +$uploaded{$cid});
+            $summary{homedomain} = 100 * $homedomain{$cid}/($external{$cid} + $homegrown{$cid} + $homedomain{$cid} +$uploaded{$cid});
+            $summary{uploaded} = 100 * $uploaded{$cid}/($external{$cid} + $homegrown{$cid} + $homedomain{$cid} +$uploaded{$cid});
+        }
+        if ($withdiscussion{$cid} + $nodiscussion{$cid} > 0) { 
+            $summary{withdiscussion} = 100 * $withdiscussion{$cid}/($withdiscussion{$cid} + $nodiscussion{$cid});
+            $summary{nodiscussion} = 100 * $nodiscussion{$cid}/($withdiscussion{$cid} + $nodiscussion{$cid});
+        }
+        if ($stucount > 0) {
+            $summary{totalposts} = $totalposts{$cid}/$stucount;
+        }
+        my $partcount = $summary{multipart} + $summary{singlepart};
+        if ($partcount > 0) {
+            $summary{multipart} = 100 * $summary{multipart}/$partcount;
+        }
+        if ($partcount > 0) {
+            $summary{singlepart} = 100 * $summary{singlepart}/$partcount;
+        }
         $summary{broadcast} = $broadcast{$cid};
         $summary{critical} = $critical{$cid};
         $summary{usernotes} = $usernotes{$cid};
-        $summary{encrypted} = $numencrypted{$cid};
-        $summary{hidden} = $numhidden{$cid};
-        $summary{conditional} = $numconditional{$cid};
-        $summary{randompicks} = $numrandompicks{$cid};
+        if ($crsitems{$cid} > 0) { 
+            $summary{encrypted} = 100 * $numencrypted{$cid}/$crsitems{$cid};
+            $summary{hidden} = 100 * $numhidden{$cid}/$crsitems{$cid};
+            $summary{conditional} = 100 * $numconditional{$cid}/$crsitems{$cid};
+        }
+        if ($totalmaps > 0) {
+            $summary{randompicks} = 100 * $numrandompicks{$cid}/$totalmaps;
+        }
         %{$savedsummary{$cid}} = %summary;
       }
     }
@@ -483,9 +512,7 @@
 foreach my $cc (@allowners) {
     foreach my $cid (@{$ownedcourses{$cc}}) {
         my ($sem) = ($cparms{$cid}{'coursecode'} =~ /^(\w{2}\d{2})/);
-        print "sem is $sem\n";
         open(FILE,">/home/raeburn/fie/data/$sem/$cid.txt");
-        print "opening /home/raeburn/fie/data/$sem/$cid.txt\n";
         print FILE "total items = $crsitems{$cid}\n";
         foreach my $key (sort(keys(%{$cparms{$cid}}))) {
             print FILE "$key = $cparms{$cid}{$key}\n";
@@ -562,6 +589,10 @@
             print FILE "$num - $duplicates{$cid}{$num} ";
             $savedsummary{$cid}{duplicates} += $duplicates{$cid}{$num};  
         }
+        my $numsrc = scalar(keys %{$src_counts{$cid}});
+        if ($numsrc > 0) {
+            $savedsummary{$cid}{duplicates} = 100 * $savedsummary{$cid}{duplicates}/$numsrc; 
+        }
         print FILE "\nFunctions: \n";
         my @filepaths = sort(keys(%function_calls));
         for (my $i=0; $i<@filepaths; $i++) {
@@ -573,6 +604,9 @@
             print FILE "$func=$allfunctions{$cid}{$func} ";
             $savedsummary{$cid}{functions} += $allfunctions{$cid}{$func};
         }
+        if ($alltags{$cid}{script} > 0) {
+            $savedsummary{$cid} = $savedsummary{$cid}{functions}/$alltags{$cid}{script};
+        }
         print FILE "\nScript Vars: \n";
         my @filepaths = sort(keys(%script_vars));
         for (my $i=0; $i<@filepaths; $i++) {
@@ -626,6 +660,7 @@
             print FILE "Course item -- $key, value is $crscount{$cid}{$key}\n";
         }
         $savedsummary{examupload} = $crscount{$cid}{examupload};
+        my $output = '';
         foreach my $item (@summaryitems) {
             if (defined($savedsummary{$cid}{$item})) {
                 if ($savedsummary{$cid}{$item} eq '') {
@@ -635,12 +670,9 @@
             } else {
                 $output .= '0,';
             }
-            if ($item eq 'images') {
-                print "value for $item is ||$savedsummary{$cid}{$item}||";
-            }
         }
         chop($output);
-        print SUMM "$output\n";  
+        print SUMM "$output\n";
     }
     close(FILE);
     my ($uname,$udom) = split/:/,$cc;

--raeburn1148003854--