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

raeburn raeburn@source.lon-capa.org
Mon, 18 Oct 2010 01:43:08 -0000


raeburn		Mon Oct 18 01:43:08 2010 EDT

  Modified files:              
    /modules/raeburn	neutrinoharvest.pl 
  Log:
  - Bug 5531.
    - If single course specified as an argument when script is called:
      prompt for specific student records to search for instances
      where student resubmitted previous answer (+/- control characters)
      for case sensitive stringreponse item and award change to EXACT_ANS.
  
  
Index: modules/raeburn/neutrinoharvest.pl
diff -u modules/raeburn/neutrinoharvest.pl:1.2 modules/raeburn/neutrinoharvest.pl:1.3
--- modules/raeburn/neutrinoharvest.pl:1.2	Mon Oct 18 00:26:11 2010
+++ modules/raeburn/neutrinoharvest.pl	Mon Oct 18 01:43:08 2010
@@ -43,6 +43,7 @@
 
 my $hasdelta = 0;
 my $now = time;
+my $students;
 if (@ARGV > 0) {
     if (@ARGV == 1) {
         if ($ARGV[0] =~ /^\d+$/) {
@@ -60,7 +61,11 @@
             my $dir = $Apache::lonnet::perlvar{lonUsersDir}.'/'.$dom;
             &recurse_courses($dom,$dir,0,\%courseshash,\%currhash,\%lastaccess,$fh,\@okcourses,$delta);
         }
-    } else {
+    } elsif (@ARGV == 1) {
+        print STDOUT "Enter username:domain for specific student(s) - space separated if > 1 ,\n or leave blank to check all students in the course ... ";
+        $students = <STDIN>;
+        chomp($students);
+        $students =~ s/(^s+|\s$)//g;
         foreach my $cid (@ARGV) {
             my ($cdom,$cnum) = split(/_/,$cid);
             if (grep(/^\Q$cdom\E/,@domains)) {
@@ -79,7 +84,7 @@
 
 if (@okcourses) {
     foreach my $cid (@okcourses) {
-        &log_neutrinos($cid,$fh);
+        &log_neutrinos($cid,$fh,$students);
     }
 } else {
     print("No valid courses to check on this library server\n");
@@ -139,7 +144,7 @@
 }
 
 sub log_neutrinos {
-    my ($cid,$fh) = @_;
+    my ($cid,$fh,$students) = @_;
     my ($cdom,$cnum) = split(/_/,$cid);
     return unless ($cdom && $cnum);
     my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
@@ -150,8 +155,22 @@
     &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
     # check course contents
     my %strings = &coursecontent_constraints($cnum,$cdom);
+    my @okstudents;
     my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum);
-    foreach my $stu (sort(keys(%{$classlist}))) {
+    if ($students ne '') {
+        my @students = split(/[,\s]+/,$students); 
+        foreach my $stu (sort(@students)) {
+            print "stu is ||$stu||\n";
+            if (ref($classlist->{$stu})) {
+                push(@okstudents,$stu);
+            } else {
+                print "$stu not in classlist\n";
+            }
+        }
+    } else {
+        @okstudents = sort(keys(%{$classlist}));
+    }
+    foreach my $stu (@okstudents) {
         my ($stuname,$studom) = split(/:/,$stu);
         my $firstcorrect;
         foreach my $symb (sort(keys(%strings))) {