3 # under the terms of the GPL version 2, or any later version, at your
4 # option. See the file README and COPYING for more information.
5 # Copyright 2006 by Don Armstrong <don@donarmstrong.com>.
6 # $Id: perl_script 495 2006-08-10 08:02:01Z don $
24 --debug, -d debugging level (Default 0)
25 --help, -h display this help
26 --man, -m display manual
34 Debug verbosity. (Default 0)
38 Display brief useage information.
55 my %options = (debug => 0,
62 GetOptions(\%options,'debug|d+','help|h|?','man|m',
63 'gradebook=s','ilearn_gradebook|ilearn-gradebook=s',
64 'gradebook_column|gb-col=s','ilearn_column|il-col=s','multiplier|mul=s',
68 pod2usage() if $options{help};
69 pod2usage({verbose=>2}) if $options{man};
71 $DEBUG = $options{debug};
73 # read in the gradebook
75 my $gb = new IO::File $options{gradebook},'r' or
76 die "Unable to open $options{gradebook} for reading: $!";
82 my ($num,$name,$id,@columns) = split /\t/;
83 next unless defined $name;
85 die "No student id for $name at line $." if not length $id;
86 $gb_students{$id} = {name => $name,
87 score => (defined $columns[$options{gradebook_column}] and length $columns[$options{gradebook_column}])?
88 $columns[$options{gradebook_column}]*$options{multiplier}+$options{add}:$columns[$options{gradebook_column}],
92 my $il = new IO::File $options{ilearn_gradebook},'r' or
93 die "Unable to open $options{ilearn_gradebook} for reading: $!";
97 my ($name,@columns) = split /\t/;
98 my ($id) = $name =~ /\|\s+(\d+)/;
99 print $_,qq(\n) and next if not defined $id;
100 next if not exists $gb_students{$id};
101 $columns[$options{ilearn_column}] = $gb_students{$id}{score} if
102 defined $gb_students{$id}{score} and length $gb_students{$id}{score};
103 print join("\t",$name,@columns),qq(\n);