Providing a public test web frontend

To provide a frontend for RSTPublicTests that automatically updates public test availability in a form for you, you could use the following php script:

#!/usr/bin/env php-cgi


function cond_include($path_minus_ext) {
   if (file_exists($path_minus_ext.'.php')) {
   } else if (file_exists($path_minus_ext.'.shtml')) {
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="" xml:lang="en" lang="en">
      <title><?php echo $me ?>: Public Test System</title>
      <?php cond_include('/u/' . $me . '/public_html/standard_style'); ?>

      <?php cond_include('/u/' . $me . '/public_html/standard_init'); ?>

      <h2><?php echo $me ?> Public Test Request</h2>

      <p>Select the assignment number and press the button to request that the
      files for the specified assignment be tested.  This facility is here to
      allow you to ensure that you have written code which passes some trivial
      tests.  You receive no extra marks for using this, though we encourage it
      as otherwise trivial mistakes could cost you all the marks for an

      <p>This does not in any way guarantee correctness - be sure to perform
      your own tests!</p>

      <p>The results of the public tests are emailed to your student.cs email
      <br />

      echo '<form action="' . $me .
         '/cgi-bin/requestPublicTest.cgi" method="post">';
         <p>Select assignment to test:
         <select name="assign">
            $basemarking = "/u/" . $me . "/marking";
            $dir_handle = @opendir($basemarking) or die("Unable to open $basemarking");

            $subdir_list = array();
            while ($subdir = readdir($dir_handle)) {
            if (file_exists("$basemarking/$subdir/") ||
            file_exists("$basemarking/$subdir/")) {
            $subdir_list[] = $subdir;

            foreach ($subdir_list as $thedir) {
            echo "<option value=\"$thedir\">$thedir</option>\n";


         <input type="submit" name="statusrequest" value="Request Public Test" />

      <?php cond_include('/u/' . $me . '/public_html/standard_fini'); ?>

WARNING: If an assignment is named 0, this PHP script appears to interpret that directory read as "false" and abort the while loop. This needs to be fixed; in the meantime, naming the assignment "a00" or something similar avoids this problem.

This script would require permissions 700, along with a world-readable .htaccess with an appropriate instruction such as AddHandler cgi-script .php There are references to SSI files that may or may not exist on your course's website, and may need to be modified accordingly.

Please note that you must also RequireUseridsForSecureWebAccess for this program, as the form contains information that is passed to a supplementary CGI program, but the CAS login will block information from a form on a non-secure page.

The form references a CGI script that has been partially centralized. In order for the CGI script to run as the course account, it must be located in the course account's web space; as such, you must provide a stub there. So, the contents of requestPublicTest.cgi may be:


exec /u/isg/bin/pub_test_web

Again, the .htaccess file must give directions that this is a CGI script

<Files requestPublicTest.cgi>
    SetHandler cgi-script
Topic revision: r2 - 2010-09-22 - TerryVaskor
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback