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

www lon-capa-cvs-allow@mail.lon-capa.org
Wed, 04 Jul 2007 18:37:30 -0000


www		Wed Jul  4 14:37:30 2007 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  Starting work on interwrite PRS
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.418 loncom/homework/grades.pm:1.419
--- loncom/homework/grades.pm:1.418	Fri Jun 22 19:45:19 2007
+++ loncom/homework/grades.pm	Wed Jul  4 14:37:30 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.418 2007/06/22 23:45:19 albertel Exp $
+# $Id: grades.pm,v 1.419 2007/07/04 18:37:30 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6211,7 +6211,8 @@
     my $pcorrect=&mt("Percentage points for correct solution");
     my $pincorrect=&mt("Percentage points for incorrect solution");
     my $selectform=&Apache::loncommon::select_form($env{'form.upfiletype'},'upfiletype',
-						   ('iclicker' => 'i>clicker'));
+						   ('iclicker' => 'i>clicker',
+                                                    'interwrite' => 'interwrite PRS'));
     $symb = &Apache::lonenc::check_encrypt($symb);
     $result.=<<ENDUPFORM;
 <script type="text/javascript">
@@ -6359,6 +6360,9 @@
     if ($env{'form.upfiletype'} eq 'iclicker') {
 	($errormsg,$number)=&iclicker_eval(\@questiontitles,\%responses);
     }
+    if ($env{'form.upfiletype'} eq 'interwrite') {
+        ($errormsg,$number)=&interwrite_eval(\@questiontitles,\%responses);
+    }
     $result.='<br />'.&mt('Found [_1] question(s)',$number).'<br />'.
              '<input type="hidden" name="number" value="'.$number.'" />'.
              &mt('Awarding [_1] percent for correct and [_2] percent for incorrect responses',
@@ -6438,6 +6442,33 @@
     return ($errormsg,$number);
 }
 
+sub interwrite_eval {
+    my ($questiontitles,$responses)=@_;
+    my $number=0;
+    my $errormsg='';
+    foreach my $line (split(/[\n\r]/,$env{'form.upfile'})) {
+        my %components=&Apache::loncommon::record_sep($line);
+        my @entries=map {$components{$_}} (sort(keys(%components)));
+        if ($entries[0] eq 'Question') {
+            for (my $i=3;$i<$#entries;$i+=6) {
+                $$questiontitles[$number]=$entries[$i];
+                $number++;
+            }
+        }
+        if ($entries[0]=~/^\#/) {
+            my $id=$entries[0];
+            my @idresponses;
+            $id=~s/^[\#0]+//;
+            for (my $i=0;$i<$number;$i++) {
+                my $idx=3+$i*6;
+                push(@idresponses,$entries[$idx]);
+            }
+            $$responses{$id}=join(',',@idresponses);
+        }
+    }
+    return ($errormsg,$number);
+}
+
 sub assign_clicker_grades {
     my ($r)=@_;
     my ($symb)=&get_symb($r);