Permalink
Browse files

testing for huge gradebook files

  • Loading branch information...
1 parent 7834579 commit 62f8c1decbe11f317ed02bc566bf4a7ba857f223 Ben Crowell committed Jan 24, 2009
Showing with 68 additions and 7 deletions.
  1. +1 −1 Browser.pm
  2. +1 −1 BrowserWindow.pm
  3. +3 −2 GradeBook.pm
  4. +9 −3 opengrade.pl
  5. +30 −0 test_suite/blank.gb
  6. +24 −0 test_suite/make_huge_gb.pl
View
@@ -30,7 +30,7 @@ use English;
use Tk;
use Tk ':variables';
-require Tk::ErrorDialog; # show errors in dialog boxes, rather than printing to console
+require Tk::ErrorDialog; # show errors in dialog boxes, rather than printing to console
use BrowserData;
use BrowserWindow;
use ExtraGUI;
View
@@ -657,7 +657,7 @@ sub new_file {
INPUTS=>[
Input->new(KEY=>"title",PROMPT=>w("title"),TYPE=>'string',BLANK_ALLOWED=>0),
Input->new(KEY=>"staff",PROMPT=>w("staff_gui"),
- DEFAULT=>UtilOG::guess_username(),TYPE=>'string',BLANK_ALLOWED=>0),
+ DEFAULT=>UtilOG::guess_username(),TYPE=>'string',BLANK_ALLOWED=>1),
Input->new(KEY=>"days_of_week",PROMPT=>w("days_of_week"),
DEFAULT=>"MTWRF",TYPE=>'string',BLANK_ALLOWED=>1),
Input->new(KEY=>"time",PROMPT=>w("time"),
View
@@ -1404,6 +1404,7 @@ Add new grades. Any preexisting ones are retained.
CATEGORY => "",
ASS => "",
GRADES => {},
+The hash reference in GRADES has student keys as its keys, scores as its values.
=cut
@@ -1862,7 +1863,7 @@ sub category_name_singular {
my $n = get_property($h->{$which},"catname");
$n =~ m/([^\,]+),(.*)/;
my ($sing,$pl) = ($1,$2);
- return $sing;
+ return $sing || $which;
}
=head3 category_name_plural()
@@ -1879,7 +1880,7 @@ sub category_name_plural {
my $n = get_property($h->{$which},"catname");
$n =~ m/([^\,]+),(.*)/;
my ($sing,$pl) = ($1,$2);
- return $pl;
+ return $pl || $which;
}
=head3 category_exists()
View
@@ -55,6 +55,7 @@ BEGIN
'undo'=>0,
'identical'=>0,
'version'=>0,
+ 'verbose'=>0,
);
our %command_line_options = (
't'=>\$options{'t'},
@@ -70,6 +71,7 @@ BEGIN
'undo=i'=>\$options{'undo'},
'identical'=>\$options{'identical'},
'version'=>\$options{'version'},
+ 'verbose!'=>\$options{'verbose'},
);
GetOptions(%command_line_options); # from Getopt::Long
my ($command_line_file_argument,$gui);
@@ -79,6 +81,7 @@ BEGIN
# scripting:
#----------------------------------------------------------------
+if ($options{'verbose'}) {STDERR->autoflush(1)}
if ($options{'help'}) {
do_help();
exit;
@@ -93,7 +96,7 @@ BEGIN
}
if ($options{'copy'}) {
do_copy($command_line_file_argument,$options{'output'},$options{'output_format'},$options{'input_password'},$options{'output_password'},$options{'authenticate'},
- $options{'modify'},$options{'undo'});
+ $options{'modify'},$options{'undo'},$options{'verbose'});
exit;
}
if ($options{'identical'}) {
@@ -199,7 +202,7 @@ sub do_query {
# If $out is logically false, write to stdout.
# Format can be old, json, or default, as defined in the comments at the top of GradeBook::write.
sub do_copy {
- my ($in,$out,$format,$in_pwd,$out_pwd,$auth,$modify,$undo) = @_;
+ my ($in,$out,$format,$in_pwd,$out_pwd,$auth,$modify,$undo,$verbose) = @_;
if (!$in) {die "no input file specified on command line for --copy"}
my $to_stdout = 0;
my $describe_out = $out;
@@ -224,11 +227,14 @@ sub do_copy {
else {
push @commands,$modify;
}
- $gb->{PREVENT_UNDO}=0;
+ if ($undo>0) { # If we're not going to need to undo, performance is better with undo turned off.
+ $gb->{PREVENT_UNDO}=0;
+ }
foreach my $modify(@commands) {
$modify =~ /^(\w+),(.*)$/ or die "syntax error in command '$modify'";
my ($method,$args_json) = ($1,$2);
my $err = $gb->user_write_api($method,$args_json);
+ print STDERR "$method,$args_json\n" if $verbose;
die $err if $err;
}
if ($undo>0) {
View
@@ -0,0 +1,30 @@
+ {
+ "class": {
+ "days":"",
+ "dir":"",
+ "online_grades":{"cltext":"","course_code":"","section_number":"","term":""},
+ "staff":"",
+ "standards":{},
+ "term":"2009-1",
+ "time":"",
+ "title":""
+ },
+ "types": {
+ "data":{"attendance":{"description":"attendance","descriptions":{"a":"absent","e":"excused","p":"present","t":"tardy"},"order":["p","a","e","t"],"value":{"a":0,"e":1,"p":1,"t":1}},"numerical":{"description":"numerical"}},
+ "order":["numerical","attendance"]
+ },
+ "category_order":[],
+ "categories": {
+
+ },
+ "roster": {
+
+ },
+ "assignment_order":[],
+ "assignments": {
+
+ },
+ "grades": {
+
+ }
+ }
View
@@ -0,0 +1,24 @@
+use strict;
+
+my $n = 10; # number of assignments
+
+open(F,">commands_temp");
+print F qq(add_category,["e","",null]),"\n";
+foreach my $i(1..$n) {
+ print F qq(add_assignment,["CATEGORY","e","ASS",$i]),"\n";
+}
+foreach my $i(ord('a')..ord('z')) {
+ foreach my $j(ord('a')..ord('z')) {
+ my $c1 = chr($i);
+ my $c2 = chr($j);
+ print F qq(add_student,["LAST","$c1$c2","FIRST","joe"]),"\n";
+ foreach my $k(1..$n) {
+ print F qq(set_grades_on_assignment,["CATEGORY","e","ASS",$k,"GRADES",{"$c1$c2":1}]),"\n";
+ }
+ }
+}
+close F;
+system(qq(opengrade --verbose --copy --modify='<commands_temp' blank.gb >a.gb))==0 or die "error, $!";
+print STDERR "Output was written to a.gb\n";
+
+unlink("commands_temp");

0 comments on commit 62f8c1d

Please sign in to comment.