Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
4e236fd6cd |
@ -1,17 +0,0 @@
|
||||
<form action="/auftakt/" method="POST">
|
||||
<h1>Was ist 2·3</h1>
|
||||
<label>Deine Antwort:
|
||||
<input type="number" placeholder="nummer" name="number" required>
|
||||
</label>
|
||||
<button type="submit">Abgeben</button>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
if (isset($_POST['number'])) {
|
||||
$number = $_POST['number'];
|
||||
if ($number === '6') {
|
||||
echo "richtig";
|
||||
} else {
|
||||
echo "falsch";
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<form method="post" action="loesung.php">
|
||||
|
||||
<h2>Welches Tier bellt?</h2>
|
||||
Hund: <input type="radio" name="frage-1" value="Hund">
|
||||
<br>
|
||||
Katze: <input type="radio" name="frage-1" value="Katze">
|
||||
<br>
|
||||
Biene: <input type="radio" name="frage-1" value="Biene">
|
||||
<br>
|
||||
|
||||
<h2>Welche Farbe ist der Himmel bei gutem Wetter?</h2>
|
||||
Rot: <input type="radio" name="frage-2" value="Rot">
|
||||
<br>
|
||||
Blau: <input type="radio" name="frage-2" value="Blau">
|
||||
<br>
|
||||
Grün: <input type="radio" name="frage-2" value="Grün">
|
||||
<br>
|
||||
|
||||
<h2>Welche Frucht ist Gelb?</h2>
|
||||
Banane: <input type="radio" name="frage-3" value="Banane">
|
||||
<br>
|
||||
Birne: <input type="radio" name="frage-3" value="Birne">
|
||||
<br>
|
||||
Kiwi: <input type="radio" name="frage-3" value="Kiwi">
|
||||
<br>
|
||||
|
||||
<button type="submit">Absenden</button>
|
||||
</form>
|
||||
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
$antwort1 = $_POST['frage-1'];
|
||||
$antwort2 = $_POST['frage-2'];
|
||||
$antwort3 = $_POST['frage-3'];
|
||||
|
||||
function zeigeErgebnis(string $gegebeneAntwort, string $richtigeAntwort): void
|
||||
{
|
||||
if ($gegebeneAntwort === $richtigeAntwort) {
|
||||
echo 'richtig';
|
||||
} else {
|
||||
echo "falsch ($richtigeAntwort)";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<h2>Antwort 1 ist <?php zeigeErgebnis($antwort1, 'Hund') ?>
|
||||
</h2>
|
||||
<h2>Antwort 2 ist <?php zeigeErgebnis($antwort2, 'Blau'); ?>
|
||||
</h2>
|
||||
<h2>Antwort 3 ist <?php zeigeErgebnis($antwort3, 'Banane'); ?>
|
||||
</h2>
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
readonly class Frage implements Stringable
|
||||
{
|
||||
public function __construct(
|
||||
private string $frage,
|
||||
private string $richtigeAntwort,
|
||||
private array $antworten,
|
||||
private string $frageNr,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getFrageNr(): string
|
||||
{
|
||||
return $this->frageNr;
|
||||
}
|
||||
|
||||
public function istRichtig(string $antwort): bool
|
||||
{
|
||||
return $antwort === $this->richtigeAntwort;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$fragen = '';
|
||||
|
||||
foreach ($this->antworten as $antwort) {
|
||||
$fragen .= '<br>';
|
||||
$fragen .= sprintf('<input type="radio" name="%s" value="%s">%s</input>', $this->frageNr, $antwort, $antwort);
|
||||
}
|
||||
|
||||
$fragen .= '<hr>';
|
||||
|
||||
return $this->frage . '<br>' . $fragen;
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
require 'Frage.php';
|
||||
|
||||
return [
|
||||
new Frage('Welches Tier bellt?', 'Hund', ['Hund', 'Katze', 'Biene'], 'frage-1'),
|
||||
new Frage('Welche Farbe ist der Himmel bei gutem Wetter?', 'Blau', ['Rot', 'Grün', 'Blau'], 'frage-2'),
|
||||
new Frage('Welche Frucht ist Gelb?', 'Banane', ['Banane', 'Birne', 'Kiwi'], 'frage-3'),
|
||||
];
|
@ -1,12 +0,0 @@
|
||||
<h1>Fragen</h1>
|
||||
<form method="post" action="loesung.php">
|
||||
<?php
|
||||
$fragen = require 'holeFragen.php';
|
||||
foreach ($fragen as $frage) {
|
||||
echo $frage;
|
||||
}
|
||||
?>
|
||||
|
||||
<input type="submit" value="Absenden">
|
||||
</form>
|
||||
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
$fragen = require 'holeFragen.php';
|
||||
foreach ($fragen as $frage) {
|
||||
if ($frage->istRichtig($_POST[$frage->getFrageNr()])) {
|
||||
echo $frage->getFrageNr() . ' ist Richtig';
|
||||
} else {
|
||||
echo $frage->getFrageNr() . ' ist Falsch';
|
||||
}
|
||||
echo "<hr>";
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<form method="post" action="loesung.php">
|
||||
|
||||
<h2>Welches Tier bellt?</h2>
|
||||
Hund: <input type="radio" name="frage-1" value="Hund">
|
||||
<br>
|
||||
Katze: <input type="radio" name="frage-1" value="Katze">
|
||||
<br>
|
||||
Biene: <input type="radio" name="frage-1" value="Biene">
|
||||
<br>
|
||||
|
||||
<h2>Welche Farbe ist der Himmel bei gutem Wetter?</h2>
|
||||
Rot: <input type="radio" name="frage-2" value="Rot">
|
||||
<br>
|
||||
Blau: <input type="radio" name="frage-2" value="Blau">
|
||||
<br>
|
||||
Grün: <input type="radio" name="frage-2" value="Grün">
|
||||
<br>
|
||||
|
||||
<h2>Welche Frucht ist Gelb?</h2>
|
||||
Banane: <input type="radio" name="frage-3" value="Banane">
|
||||
<br>
|
||||
Birne: <input type="radio" name="frage-3" value="Birne">
|
||||
<br>
|
||||
Kiwi: <input type="radio" name="frage-3" value="Kiwi">
|
||||
<br>
|
||||
|
||||
<button type="submit">Absenden</button>
|
||||
</form>
|
||||
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
$antwort1 = $_POST['frage-1'];
|
||||
$antwort2 = $_POST['frage-2'];
|
||||
$antwort3 = $_POST['frage-3'];
|
||||
|
||||
?>
|
||||
<h2>Antwort 1 ist <?php
|
||||
if ($antwort1 === 'Hund') {
|
||||
echo 'richtig';
|
||||
} else {
|
||||
echo 'falsch';
|
||||
}
|
||||
?>
|
||||
</h2>
|
||||
<h2>Antwort 2 ist <?php
|
||||
if ($antwort2 === 'Blau') {
|
||||
echo 'richtig';
|
||||
} else {
|
||||
echo 'falsch';
|
||||
}
|
||||
?>
|
||||
</h2>
|
||||
<h2>Antwort 3 ist <?php
|
||||
if ($antwort3 === 'Banane') {
|
||||
echo 'richtig';
|
||||
} else {
|
||||
echo 'falsch';
|
||||
}
|
||||
?>
|
||||
</h2>
|
Loading…
Reference in New Issue
Block a user