Location: PHPKode > projects > Ps and Qs: Processing QTI using PHP > qti-eb/index.php
<?php

error_reporting(E_ALL & (~E_NOTICE));

require_once('qti-eb.php');

$action = $_REQUEST['action'];
$processorfile = $_REQUEST['processorfile'];

// Translate the "showquestions" action into the processorfile instruction, if present
if($action=='showquestions')
{
  $action = 'process';
  $processorfile = 'displayqs.inc.php';
}
elseif($processorfile=='xml')
{
  $action = 'viewsource';
}


if($action=='process')
{
  global $showviewsource;
  $qtifilename = $_REQUEST['filetoload'];
  $funcfilename = './functionsfiles/' . $processorfile;
  include_once($funcfilename);
  processQtiFile($qtifilename);
  if($showviewsource !== false)
    echo "<p>&nbsp;</p><p align=\"right\"><a href=\"./?action=viewsource&filetoload=$_REQUEST[filetoload]\">View XML source</a></p>";
}
elseif($action=='viewsource')
{
  $qtifilename = $_REQUEST['filetoload'];
  header('Content-type: text/plain');
  readfile($qtifilename);
}
else
{
 ?>
 <form action="./" method="post">
 <h4>PHP QTI processor demonstration</h4>
 <p>File: 
   <select name="filetoload">
     <?php
   $dh = opendir('./qtifiles/');
   while (($file = readdir($dh)) !== false) {
     if(preg_match('/.xml$/', strtolower($file)))
     echo "<option value=\"./qtifiles/$file\">$file</option>";
   }
   closedir($dh); 
  ?>
   </select>
   </p>
   <p>I'd like to see 
   <select name="processorfile">
     <option value="overview.inc.php">an overview</option>
     <option value="displayqs.inc.php">all the questions!</option>
     <option value="comments.inc.php">qticomments only</option>
     <option value="xml">the raw XML</option>
     <option value="tolaptlite.inc.php">a conversion to LAPTlite format</option>
<!--     <option value="./functionsfiles/overview.inc.php"></option> -->
   </select>
 <!--
 <p>Choose a file to load: </p>
 <p>Choose a function file to use for processing:
 <select name="processorfile">
 <?php /*
   $dh = opendir('./functionsfiles/');
   while (($file = readdir($dh)) !== false) {
     if(preg_match('/(?<!template).inc.php$/', strtolower($file)))
     echo "<option>$file</option>";
   }
   closedir($dh);  */
  ?>
 </select>
 </p> -->
 <input name="action" type="hidden" value="process" />
 <input type="submit" value="     Go     " />
 </p>
 </form>
 <?php
}
?>
Return current item: Ps and Qs: Processing QTI using PHP