⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex3grader.pl

📁 SSD6网上教程全部练习及答案 原版的正确答案
💻 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 + -