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

raeburn lon-capa-cvs@mail.lon-capa.org
Fri, 31 Mar 2006 19:05:27 -0000


This is a MIME encoded message

--raeburn1143831927
Content-Type: text/plain

raeburn		Fri Mar 31 14:05:27 2006 EDT

  Modified files:              
    /modules/raeburn	FIE_usage.pl 
  Log:
  Gather summary data.
  
  
--raeburn1143831927
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060331140527.txt"

Index: modules/raeburn/FIE_usage.pl
diff -u modules/raeburn/FIE_usage.pl:1.1 modules/raeburn/FIE_usage.pl:1.2
--- modules/raeburn/FIE_usage.pl:1.1	Fri Mar 31 11:52:57 2006
+++ modules/raeburn/FIE_usage.pl	Fri Mar 31 14:05:25 2006
@@ -74,17 +74,22 @@
 my %library = ();
 my %numscantrons = ();
 my %studentphotos = ();
-@domains = ('northwood5');
+my %savedsummary = ();
+@domains = ('msu');
 
 # Determine the present time;
 my $timenow = time();
 
+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";
+
 # For each domain ......
 foreach my $dom (@domains) {
     open(LOG,">/home/raeburn/fie/data/domain_$dom.txt");
     my $dc = 'fietester';
     my $lonidsdir='/home/httpd/lonIDs';
-    my $handle = 'fietester_1142656989_northwood5_northwood5l1';
+    my $handle = 'fietester_1142872930_msu_msul1';
     $env{'user.name'} = $dc;
     my $authhost = &Apache::lonnet::homeserver($dc,$dom);
     $env{'user.home'} = $authhost;
@@ -93,14 +98,16 @@
     &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
     my $now=time;
     my $then=$env{'user.login.time'};
-    my @instcodes = ('ss06');
+    my @instcodes = ('fs05');
     my %courses = ();
     foreach my $code (@instcodes) {
-#      %{$courses{$code}} = &Apache::lonnet::courseiddump($dom,'.',1,$code,'.','.',1,\@hostids);
+      %{$courses{$code}} = &Apache::lonnet::courseiddump($dom,'.',1,$code,'.','.',1,\@hostids);
 #    %courses = ('northwood5_1w268410c6d0744e2northwood5l1' => 'Some course'); 
-      %{$courses{$code}} = ('northwood5_3e24151fbf51a4411northwood5l1' => 'Other course');
+#      %{$courses{$code}} = ('msu_153926ccad542e6msul1' => 'phy');
       foreach my $cid (sort keys %{$courses{$code}}) {
+        my %summary = (); 
         print "course is $cid\n";
+        $summary{id} = $cid;
         $env{'request.course.id'} = $cid;
         $env{'request.course.sec'} = '';
         my ($cdom,$crs) = split/_/,$cid;
@@ -146,6 +153,12 @@
                       languages => $crsenv{'languages'},
                       clonedfrom => $crsenv{'clonedfrom'},
         );
+        $summary{coursecode} = $cparms{$cid}{coursecode};
+        if ($cparms{$cid}{clonedfrom}) {
+            $summary{cloned} = 1;
+        } else {
+            $summary{cloned} = 0;
+        }  
         my %roles = &Apache::lonnet::get_course_adv_roles($cdom.'_'.$crs);
         foreach my $role (sort keys %roles) {
             if ($role eq 'Course Coordinator') {
@@ -195,7 +208,8 @@
             }
         }
 
-#        if ($stucount > 0 && $lastvisit > 0) {
+        if ($stucount > 0 && $lastvisit > 0) {
+            $summary{enrollment} = $stucount;
             $crsitems{$cid} = 0;
             &Apache::lonroles::set_privileges($dom,$crs);
             print LOG "$cid =".&Apache::lonnet::unescape($courses{$code}{$cid})."\n";
@@ -313,18 +327,13 @@
             my %unread = ();
             my $discussiondata = $navmap->get_discussion_data();
             my %parse_done = ();
+            my %probitem = ();  
             foreach my $resource (@allres) {
                 my $src = $resource->src();
                 $crsitems{$cid} ++;
                 &course_items($src,$cid,$cdom,$crs,$crsdir,$ownerdom,$owner,\%homegrown,\%homedomain,\%crscount,\%external,\%folders,\%pages,\%uploaded,\%uploadtotal,$allembedded{$cid},$codebase{$cid},\$studentphotos{$cid});
                 my $symb = $resource->symb();
                 if ($resource->is_problem()) {
-                    my $responses = $resource->countResponses();
-                    my %responseTypes = $resource->responseTypes();
-                    foreach my $resptype (keys(%responseTypes)) {
-                        $response_types{$cid}{$resptype} ++; 
-                    }
-                    $numresponses{$cid} ++;
                     my @parts = @{$resource->parts()};
                     foreach my $part (@parts) {
                        my $type = $resource->type($part);
@@ -333,6 +342,18 @@
                     }
                     unless(defined($numparts{$cid}{$src})) {
                         $numparts{$cid}{$src} = scalar(@parts);
+                        if (@parts > 1) {
+                            $summary{multipart} ++;
+                        }
+                    }
+                    unless(defined($probitem{$src})) {
+                        my %responseTypes = $resource->responseTypes();
+                        foreach my $resptype (keys(%responseTypes)) {
+                            $response_types{$cid}{$resptype} += $responseTypes{$resptype};
+                        }
+                        my $responses = $resource->countResponses();
+                        $numresponses{$cid} += $responses;
+                        $probitem{$src} = 1;   
                     }
                     my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
                     my $respath =  $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
@@ -348,6 +369,7 @@
                         }
                         $parse_done{$filepath} = 1;
                     }
+                    $summary{allproblems} ++;
                 }
                 $src_counts{$cid}{$src} ++;
                 if ($resource->encrypted()) {
@@ -415,7 +437,39 @@
                     $nodiscussion{$cid} ++;
                 }
             }
-#        }
+        }
+        $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'};
+        $summary{numresponses} = $numresponses{$cid};
+        $summary{gnuplot} = $alltags{$cid}{gnuplot};
+        $summary{script} = $alltags{$cid}{script}; 
+        $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};
+        $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};
+        %{$savedsummary{$cid}} = %summary;
       }
     }
     delete($env{'user.name'});
@@ -425,17 +479,20 @@
 }
 
 # For each course owner..
-
+my @summaryitems = ('id','coursecode','enrollment','cloned','items','problem','exam','survey','allproblems','essay','match','numerical','option','radiobutton','string','formula','rank','images','numresponses','gnuplot','multipart','script','functions','duplicates','hidden','encrypted','conditional','randompicks','embedded-res','embedded-upload','numscantrons','external','homegrown','homedomain','uploaded','withdiscussion','nodiscussion','totalposts','broadcast','critical','usernotes','examupload','calendar');
 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";
         }
         print FILE "chat entries = $chatcount{$cid}\n";
         print FILE "calendar entries - $calcount{$cid}\n";
+        $savedsummary{$cid}{calendar} = $calcount{$cid};   
         foreach my $src (sort keys %{$src_counts{$cid}}) {
             if ($src_counts{$cid}{$src} > 1) {
                 $duplicates{$cid}{$src_counts{$cid}{$src}} ++;
@@ -503,6 +560,7 @@
         print FILE "\nDuplicates: ";
         foreach my $num (sort(keys(%{$duplicates{$cid}}))) {
             print FILE "$num - $duplicates{$cid}{$num} ";
+            $savedsummary{$cid}{duplicates} += $duplicates{$cid}{$num};  
         }
         print FILE "\nFunctions: \n";
         my @filepaths = sort(keys(%function_calls));
@@ -513,6 +571,7 @@
         print FILE "Total functions: ";
         foreach my $func (sort(keys(%{$allfunctions{$cid}}))) {
             print FILE "$func=$allfunctions{$cid}{$func} ";
+            $savedsummary{$cid}{functions} += $allfunctions{$cid}{$func};
         }
         print FILE "\nScript Vars: \n";
         my @filepaths = sort(keys(%script_vars));
@@ -537,6 +596,7 @@
             print FILE "Embedded items in html files in $item ";
             foreach my $ext (sort(keys(%embedcount))) {
                  print FILE "$ext=$embedcount{$ext} ";
+                 $savedsummary{cid}{'embedded-'.$item} += $embedcount{$ext};   
             }
             print FILE "\n";
         }
@@ -565,6 +625,22 @@
         foreach my $key (sort keys %{$crscount{$cid}}) {
             print FILE "Course item -- $key, value is $crscount{$cid}{$key}\n";
         }
+        $savedsummary{examupload} = $crscount{$cid}{examupload};
+        foreach my $item (@summaryitems) {
+            if (defined($savedsummary{$cid}{$item})) {
+                if ($savedsummary{$cid}{$item} eq '') {
+                    $savedsummary{$cid}{$item} = '0';
+                }   
+                $output .= $savedsummary{$cid}{$item}.',';
+            } else {
+                $output .= '0,';
+            }
+            if ($item eq 'images') {
+                print "value for $item is ||$savedsummary{$cid}{$item}||";
+            }
+        }
+        chop($output);
+        print SUMM "$output\n";  
     }
     close(FILE);
     my ($uname,$udom) = split/:/,$cc;
@@ -588,6 +664,7 @@
     }
     close(OWNER);
 }
+close(SUMM);
 
 sub supp_docs_tree {
     my ($cid,$crs,$cdom,$crsdir,$folder,$owner,$ownerdom) = @_;
@@ -825,7 +902,7 @@
         if ($content == -1) {
             print "$filepath had no contents\n";
         } elsif ($content) {
-            &Apache::lonnet::extract_embedded_items(undef,undef,$$allembeddea{$origin},$$codebase{$origin},\$content);
+            &Apache::lonnet::extract_embedded_items(undef,undef,$$allembedded{$origin},$$codebase{$origin},\$content);
             if ($content =~ m-<displaystudentphoto\s*/>-i) {
                 $$studentphotos ++;
             }

--raeburn1143831927--