Esempio n. 1
0
<html>
<head>
<title>Quiz Machine</title>
</head>
<body>
<center>
<h1>Quiz Machine</h1>


<?php 
getFiles();
showTest();
showEdit();
showLog();
function getFiles()
{
    //get list of all files for use in other routines
    global $dirPtr, $theFiles;
    chdir(".");
    $dirPtr = openDir(".");
    $currentFile = readDir($dirPtr);
    while ($currentFile !== false) {
        $theFiles[] = $currentFile;
        $currentFile = readDir($dirPtr);
    }
    // end while
}
// end getFiles
function showTest()
{
    //print a list of tests for user to take
//--------------------------
$lNumCorrectPre = $lNumCorrectPost = 0;
foreach ($QandA as $QA) {
    if ($QA->bPreTestRight) {
        ++$lNumCorrectPre;
    }
    if ($QA->bPostTestRight) {
        ++$lNumCorrectPost;
    }
}
$strPreTestScore = number_format($lNumCorrectPre / $lNumQuests * 100, 1) . ' %';
$strPostTestScore = number_format($lNumCorrectPost / $lNumQuests * 100, 1) . ' %';
echoT($clsForm->strLabelRow('Pre-test score', $strPreTestScore, 1));
echoT($clsForm->strLabelRow('Post-test score', $strPostTestScore, 1));
showTest($clsForm, 'datepicker1', 'txtPretestDate', 'Pre-test Date', $txtPretestDate, 'frmEditPPTest', $QandA, true);
showTest($clsForm, 'datepicker2', 'txtPosttestDate', 'Post-test Date', $txtPosttestDate, 'frmEditPPTest', $QandA, false);
echoT($clsForm->strSubmitEntry('Save Test Results', 1, 'cmdSubmit', 'text-align: center;'));
echoT('</table>' . form_close('<br>'));
closeBlock();
function showTest(&$clsForm, $strDatePickerName, $strDateFN, $strDateLabel, $strDateVal, $strFormName, &$QandA, $bPretest)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    $strPrePostLabel = $bPretest ? 'Pre' : 'Post';
    $strDivName = 'divChk' . $strPrePostLabel;
    $strOut = '';
    //--------------------------
    // Pre/post-test date
    //--------------------------
    $clsForm->strStyleExtraLabel = 'padding-top: 8px;';