[LON-CAPA-cvs] cvs: loncom /homework grades.pm
www
lon-capa-cvs-allow@mail.lon-capa.org
Wed, 04 Jul 2007 20:28:44 -0000
www Wed Jul 4 16:28:44 2007 EDT
Modified files:
/loncom/homework grades.pm
Log:
Looks like interwrite works. Left to do:
* see how people handle numerical response
* see if the IR files also work
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.419 loncom/homework/grades.pm:1.420
--- loncom/homework/grades.pm:1.419 Wed Jul 4 14:37:30 2007
+++ loncom/homework/grades.pm Wed Jul 4 16:28:44 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.419 2007/07/04 18:37:30 www Exp $
+# $Id: grades.pm,v 1.420 2007/07/04 20:28:44 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6446,25 +6446,27 @@
my ($questiontitles,$responses)=@_;
my $number=0;
my $errormsg='';
+ my $skipline=1;
+ my $questionnumber=0;
+ my %idresponses=();
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);
+ if ($entries[1] eq 'Time') { $skipline=0; next; }
+ if ($entries[1] eq 'Response') { $skipline=1; }
+ next if $skipline;
+ if ($entries[0]!=$questionnumber) {
+ $questionnumber=$entries[0];
+ $$questiontitles[$number]=&mt('Question [_1]',$questionnumber);
+ $number++;
}
+ my $id=$entries[4];
+ $id=~s/^[\#0]+//;
+ $idresponses{$id}[$number]=$entries[6];
+ }
+ foreach my $id (keys %idresponses) {
+ $$responses{$id}=join(',',@{$idresponses{$id}});
+ $$responses{$id}=~s/^\s*\,//;
}
return ($errormsg,$number);
}
@@ -6521,8 +6523,17 @@
my $pincorrect=$env{'form.pincorrect'};
my $storecount=0;
foreach my $key (keys(%env)) {
+ my $user='';
if ($key=~/^form\.student\:(.*)$/) {
- my $user=$1;
+ $user=$1;
+ }
+ if ($key=~/^form\.unknown\:(.*)$/) {
+ my $id=$1;
+ if (($env{'form.uname'.$id}) && ($env{'form.udom'.$id})) {
+ $user=$env{'form.uname'.$id}.':'.$env{'form.udom'.$id};
+ }
+ }
+ if ($user) {
my @answer=split(/\,/,$env{$key});
my $sum=0;
for (my $i=0;$i<$number;$i++) {