$kov++; } $_POST["teszt_kerdes"] = $kov; break; case "kerdes-szerkeszt-elozo": teszt_ment(); $_POST["teszt_kerdes"] = elozo_kerdes($_POST["kivalasztott_teszt"], $_POST["teszt_kerdes"], true); break; case "teszt-megold-kovetkezo": valaszt_ment(); $kov = kovetkezo_kerdes($_POST["kivalasztott_teszt"], $_POST["teszt_kerdes"], true); $_POST["teszt_kerdes"] = $kov; break; case "teszt-megold-elozo": valaszt_ment(); $_POST["teszt_kerdes"] = elozo_kerdes($_POST["kivalasztott_teszt"], $_POST["teszt_kerdes"], true); break; case "teszt-megold-vege": valaszt_ment(); break; } ?> <html> <head> <title>Tesztek</title> <link href="stilus.css" rel="stylesheet" type="text/css"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body>
function teszt_megjelenites() { global $host, $user, $pass, $db; $tesztId = $_POST["kivalasztott_teszt"]; $tesztKerdes = $_POST["teszt_kerdes"]; if (!isset($tesztKerdes)) { $tesztKerdes = -1; } $tesztKerdes = kovetkezo_kerdes($tesztId, $tesztKerdes, false); if ($tesztKerdes == -1) { print "Ez a teszt nem tartalmaz kérdést.<br>"; return; } $van_kovetkezo = kovetkezo_kerdes($tesztId, $tesztKerdes, true) != $tesztKerdes; $van_elozo = elozo_kerdes($tesztId, $tesztKerdes, true) != $tesztKerdes; $con = mysql_connect($host, $user, $pass); if (!mysql_select_db($db, $con)) { echo "Nemletezo adatbazis!<br/>\n"; } $sql = "SELECT * FROM kerdesek WHERE tesztkod=" . $tesztId . " AND kerdesszam=" . $tesztKerdes; $res = mysql_query($sql); $sor = array(); if (mysql_num_rows($res) != 0) { $sor = mysql_fetch_array($res); } mysql_close($con); ?> <form name="tesztszerkeszt" action="index.php" method="post"> <h2>Kérdés:<?php echo $tesztKerdes; ?> </h2> <?php echo $sor["kerdes"]; ?> <h2>Válaszok:</h2> A. <input type="checkbox" name="helyes_a"/> <?php echo $sor["valasz_a"]; ?> <br/> B. <input type="checkbox" name="helyes_b"/> <?php echo $sor["valasz_b"]; ?> <br/> C. <input type="checkbox" name="helyes_c"/> <?php echo $sor["valasz_c"]; ?> <br/> D. <input type="checkbox" name="helyes_d"/> <?php echo $sor["valasz_d"]; ?> <br/> <input type="hidden" name="menupont" value="teszt-megold"/> <input type="hidden" name="teszt_kerdes" value=<?php echo "\"" . $tesztKerdes . "\""; ?> /> <input type="hidden" name="kivalasztott_teszt" value=<?php echo "\"" . $tesztId . "\""; ?> /> <br /> <input type="submit" name="elozo" value="Előző" <?php if (!$van_elozo) { print "\"disabled\"=\"disabled\""; } ?> > <?php if ($van_kovetkezo == true) { ?> <input type="submit" name="kovetkezo" value="Következő" > <?php } else { ?> <input type="submit" name="vege" value="Vége" > <?php } ?> </form> <?php }