= 97 && $ltr <= 122 || $ltr == 32) {
//$hsh = ($hsh*23+floor($hsh / 10000000)+$ltr)%10000000 ;
$hsh = $hsh . $hdg[floor($ltr/16)] . $hdg[$ltr%16] ;
//}
}
return $hsh ;
}
function load_exam_script($scriptFile)
{
global $config ;
$fh = fopen($scriptFile, 'r') or die("Can't open file");
$field_count = 0 ;
$answer_table= "" ;
$starter_table = "" ;
$page_count= 0 ;
echo "\n\n
\n" ;
while ($line= fgets($fh)) {
if (!preg_match("/^#/", $line)) { # ignore comment lines
# chop newlines
$line = preg_replace("/[\r\n]/", "", $line) ;
# replace titles
if (preg_match("/^\(t\s*(.*)\s*t\)\s*$/", $line, $matches)) {
$page_count++ ;
$line = preg_replace("/^\(t\s*(.*)\s*t\)\s*$/",
"\n
\n
$1
", $line) ;
$answer_table .= "\n" ;
$starter_table .= ", ".($field_count+1) ;
}
# replace images
$line = preg_replace("/\(i\s*(\S*)\s*i\)/", '

', $line) ;
# replace videos
$line = preg_replace("/\(v\s*(\S*)\s*v\)/", "\n", $line) ;
$line = preg_replace("/\(y\s*(\S*)\s*y\)/", "
", $line) ;
# replace choices ----------------------------------------
if (preg_match("/(.*)\(c\s*(.*\S)\s*c\)/", $line, $matches)) {
$field_count++ ;
$choice = '
' ;
foreach (preg_split("/\s+/",preg_quote($matches[2])) as $opt) {
if (substr($opt,0,1) == '&') {
# right option
$opt = substr($opt,1) ;
$answer_table .= ", '".answer_hash($opt)."'" ;
}
$choice .= " ".$matches[1]
. '' . $opt . "
\n" ;
}
$choice .= '
' ;
$line = preg_replace("/(.*)\(c\s*(.*\S)\s*c\)/"
, $choice
, $line) ;
}
# replace choices ----------------------------------------
/* if (preg_match("/(.*)\(c\s*(.*\S)\s*c\)/", $line, $matches)) {
$field_count++ ;
$choice = '
' ;
foreach (preg_split("/\s+/",preg_quote($matches[2])) as $opt) {
if (substr($opt,0,1) == '&') {
# right option
$opt = substr($opt,1) ;
$answer_table .= ", '".answer_hash($opt)."'" ;
}
$opt=str_replace("_"," ",$opt);
$choice .= " ".$matches[1]
. '' . $opt . "
\n" ;
}
$choice .= '
' ;
$line = preg_replace("/(.*)\(c\s*(.*\S)\s*c\)/"
, $choice
, $line) ;
}
*/
# replace textboxes ----------------------------------------
//2
/*echo "bob";
$text_boxes= explode("(b",$line);
print $text_boxes[0];
if(count($text_boxes)>0)
{
//$line="";
}
for ($i=0; $i
'
, $l) ;
$answer_table .= ", '".answer_hash($match[1])."'" ;
}
# translate whitespace
$l= preg_replace("/\s\s/", " ", $l) ;
$line.=$l;
}
echo $line."
\n";
*/
# replace textboxes ----------------------------------------
$text_matched=0;
// while($text_matched==0)
// {
$matches=true;
$max_per_line=15;
for($i=0;$i<$max_per_line;$i++)
{
// preg_match("/\(b\s*(.[^)]*\S)\s*b\)/", $line, $match)
if (preg_match("/\(b\s*(.[^)]*\S)\s*b\)/", $line, $match)) {
$match[1]=trim($match[1]," ");
$field_count++ ;
$line = str_replace("(b ".$match[1]." b)"
, '
'
, $line) ;
$answer_table .= ", '".answer_hash($match[1])."'" ;
}
}
// }
# translate whitespace
$line = preg_replace("/\s\s/", " ", $line) ;
echo $line."
\n";
}
}
fclose($fh);
echo "
\n\n" ;
echo "