PHP Classes

File: test3.php

Recommend this page to a friend!
  Classes of Pierre FAUQUE   QCM Class   test3.php   Download  
File: test3.php
Role: Example script
Content type: text/plain
Description: Demo: test 3
Class: QCM Class
Load, display and correct online questionnaires
Author: By
Last change: new example of test page
Date: 12 years ago
Size: 2,221 bytes
 

Contents

Class file image Download
<?php
$idQCM
= 3; // Identifier, number of the questionnaire (3 -> qcm3.txt)
require("QCM.php"); // Insertion of the class

// This following informations about the student are written but they can have been read in a database
// This array is optional. (askfor=supplied)
$student[] = 146; // ID of the student. Not yet used
$student[] = "FAUQUE"; // Last name of the student
$student[] = "Pierre"; // First name of the student
$student[] = "M."; // Sex of the student (M. Mme Mlle). Can be unused
$student[] = "pierre@fauque.net"; // Mail of the student
$test = new qcm($idQCM,$student); // Instanciation of the test. Student informations are supplied

// No array is supplied to the class, but informations asked (askfor=name,mail)
// $test = new qcm($idQCM); // Instanciation of the test. Student informations are asked to him
?>
<html>

<head>
<title><? echo $test->title; ?></title>
<link rel="stylesheet" href="test.css" type="text/css">
</head>

<body>
<?php
if (!$_POST['submit']) {

    echo
"<form method='post' name='test' action='" . $_SERVER['PHP_SELF'] . "'>\n";
   
$test->display(); // Display the test
   
echo "</form>\n";

   
// ------------------------------------------------------
    // These lines can be commented or deleted.
    // They have been written to show attributes before correction
    // echo "<hr>";
    // $test->showVars(); // Show the properties of the class (for debugging)
    // ------------------------------------------------------

} else {

   
$test->correction(); // Correct of the test

    // ------------------------------------------------------
    // These lines can be commented or deleted.
    // They have been written to show how the class works
    // echo "<hr>";
    // $test->showResponses(); // Show on the web to the student his responses
    // $test->showGoodResponses(); // Show on the web to the student the correction
    // ------------------------------------------------------

}
// $test->showVars(); // Show the properties of the class (for debugging)
?>
</body>

</html>