On Sat Apr 05 07:08:37 2014, VIY wrote:
Show quoted text> Global symbol "$ex2" requires explicit package name ..
sum_g12.pl was an earlier attempt at averaging the results of
2 subexams, later becoming sum_g1_g2.pl. The diff:
-# Created: 03/21/2013 10:08:14 PM
-# Last Edit: 2014 2月 16, 21時36分43秒
+# Created: 04/28/2013 04:26:17 PM
+# Last Edit: 2014 Mar 25, 08:31:30 AM
# $Id$
=head1 NAME
-sum_g12.pl - Mean of jigsaw scores and compcomp scores
+sum_g1_g2.pl - Mean of jigsaw scores and compcomp scores
=cut
use strict;
use warnings;
-use IO::All;
-use YAML qw/Dump LoadFile DumpFile/;
-use Cwd;
=head1 SYNOPSIS
-sum_g12.pl > exam/1/g.yaml
+sum_g1_g2.pl -r 3 > exam/3/g.yaml
=cut
-
-my $session = 1;
-my $dirs = '/home/drbean/022';
-
-(my $dir = getcwd) =~ s/^.*\/([^\/]*)$/$1/;
+use Cwd;
+use File::Basename;
+use List::MoreUtils qw/any/;
+use YAML qw/LoadFile DumpFile Dump/;
use Grades;
-my $l = League->new( leagues => $dirs, id => $dir );
-my $g = Grades->new({ league => $l });
-my %m = map { $_->{id} => $_ } @{ $l->members };
-my $approach = $l->approach;
-my $c = $g->classwork;
+
+my $script = Grades::Script->new_with_options;
+my $id = $script->league || basename( getcwd );
+my $exam = $script->round;
+
+my $league = League->new( id => $id );
+my $grades = Grades->new({ league => $league });
+my $co = Compcomp->new({ league => $league });
+my %m = map { $_->{id} => $_ } @{ $league->members };
=head1 DESCRIPTION
Exams are simultaneous jigsaw and compcomp activities. Average those 2 scores.
-Jigsaw scores are already in g1.yaml.
+Jigsaw scores are already in g1.yaml. We could use inspect, instead of LoadFile.
+Averages jigsaw and compComp scores. Be careful with absent players
=cut
-my $comp = Compcomp->new({ league => $l });
-my $ex1 = $l->inspect("$dirs/$dir/exam/$session/g1.yaml");
-# my $ex2 = $comp->points($session);
-# $l->save("$dirs/$dir/exam/$session/g2.yaml", $ex2);
-$ex2 = $l->inspect("$dirs/$dir/exam/$session/g2.yaml");
-my %exams = map { $_ => ( $ex1->{$_} + $ex2->{$_} ) / 2 } keys %m;
+my $leagues = $league->leagues;
+my $g1 = LoadFile "$leagues/$id/exam/$exam/g1.yaml" or die "g1.yaml?";
+my $g2 = $co->points($exam);
+DumpFile "$leagues/$id/exam/$exam/g2.yaml", $g2 or die "g2.yaml?";
+my $g2_again = $league->inspect("$leagues/$id/exam/$exam/g2.yaml");
+my %g = map {
+ die "Player $_ missing from g1.yaml" if not defined $g1->{$_};
+ die "Player $_ missing from g2.yaml" if not defined $g2_again->{$_};
+ $_ => ( $g1->{$_} + $g2_again->{$_} ) / 2
+ } keys %m;
-print Dump \%exams;
+print Dump \%g;
=head1 AUTHOR
@@ -64,7 +69,7 @@
=cut
-# End of sum_g12.pl
+# End of sum_g1_g2.pl