BitterSuite Filter language: Reject files until A0 is submitted

The text below should be placed in a file on the course account; for example, in the test suite's provided folder in a file called a0_require.

#!/usr/bin/env perl

use strict;
use warnings;

require '/u/isg/bin/perl/TermCode.pm';

use constant LOGGED_ASSIGN => 'a00';
use constant ERRCODE => 51;
use constant REJMSG => 'Assignment ' . LOGGED_ASSIGN . ' has not yet received full public test marks.';


# Secret hack sauce.
# These values must come from RST, as BitterSuite doesn't know them.
# Generally we try to avoid reaching outside of a BitterSuite context...
# mais, c'est la vie.
my $course = $ENV{'course'};
my $student = $ENV{'student'};

# It's unfortunate that Perl doesn't just accept TermCode::FMT_REGISTRAR;
# it is much cleaner, less prone to breaking, etc...
#my $term = TermCode::current_termcode(TermCode::FMT_REGISTRAR);
my $term = TermCode::current_termcode(2);

my $pubtestlog = "/u/$course/course/publictests/" . $term . '/' . LOGGED_ASSIGN . '.completedrun.log';


my $passed = 0;

if ( -e $pubtestlog) {
   open( PTL, $pubtestlog ) or print "Cannot open log: $!\n" and exit ERRCODE;
   while(my $pubtestline = <PTL>) {

      # If this student has a perfect mark recorded, then the requirement
      # has been met; terminate the loop
      # NOTE: As we know the value of $student will not change for the
      # lifetime of this program, we set this regex to compile only once.
      if ($pubtestline =~ /^\s*\d+\s*${student}\s*\S*\s*([0-9.]+)\s*\/\s*([0-9.]+)\s*$/o) {
         if ($1 == $2) {
            $passed = 1;
            last;
         }
      }

   }
   close( PTL );
}

# unless the student passed the required assignment, reject all
# submission attempts
unless ($passed) {
   print REJMSG . "\n";
   exit ERRCODE;
}

exit 0;

Then the following options should be active:

(language filter)
(test-action submit-style-filter)
(external-cmd "a0_require")

This will reject all files submitted by the user unless it finds the user has obtained a perfect mark on an assignment called a00.

Topic revision: r1 - 2010-09-03 - TerryVaskor
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback

mersin escort bayan adana escort bayan izmit escort ankara escort bursa escort