?? ex3grader.pl
字號:
$handindir = "C:\\cygwin\\home\\veerasam\\CTEGrader\\Fall 2004\\SSD6\\TAFE-TRAIN\\Exercise 3 Debugging Malloc Lab\\SSD6v1.2normal_ssd6v1.1-ex3handout";
$outputfile = "feedback.txt";
sub cleanup_grading {
`del debugmalloc.c 2> nul`;
`devenv debugmalloc-grading.sln /clean Debug 2> nul`;
}
sub grade {
my ($student, $feedback, $userdir) = @_;
my $output;
`del debugmalloc.c 2> nul`;
`devenv debugmalloc-grading.sln /clean Debug 2> nul`;
$output = `copy /Y "$userdir"\\debugmalloc.c . 2> nul`;
if($? != 0) {
print $feedback "Could not copy debugmalloc.c from student submission, while copying:\n";
print $feedback $output;
return;
}
$output = `devenv debugmalloc-grading.sln /rebuild Debug 2> nul`;
if($? != 0) {
print $feedback "Could not make project from student source, nmake said:\n";
print $feedback $output;
return;
}
@output = `perl .\\grader.pl`;
print $feedback @output;
}
sub writeheader {
my ($student, $instance, $output) = @_;
my $time = localtime();
if($student ne "") {
print $output "Student name: $student\n";
print $output "Time of grading: $time\n";
print $output "Instance: $instance\n";
print $output "--------------------\n";
}
}
opendir(DIR, $handindir) or die "Couldn't open $handindir\n";
@userdirs = grep(!/^\.\.?$/, readdir(DIR)); # elide . and .. from the list
@userdirs = sort(@userdirs);
closedir(DIR);
USER: foreach my $handin (@userdirs) {
$handin =~ /^([a-zA-Z0-9]*)_(\d)$/;
if((($student = $1) eq "") || (($instance = $2) == 0)) {
next USER;
}
if( -e "$handindir\\$handin\\$outputfile") {
print "User $student, instance $instance already graded, remove $outputfile to regrade\n";
next USER;
}
if(!open($feedback, ">$handindir\\$handin\\$outputfile")) {
print "Unable to open $handindir\\$handin\\$outputfile for writing\n";
next USER;
}
writeheader($student, $instance, $feedback);
print "Grading submission from $student, instance $instance\n";
grade($student, $feedback, "$handindir\\$handin");
close($filehandle);
}
cleanup_grading();
print "Press enter to quit...";
<STDIN>;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -