Compare commits
No commits in common. "bare" and "main" have entirely different histories.
17
auftakt/index.php
Normal file
17
auftakt/index.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<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";
|
||||||
|
}
|
||||||
|
}
|
29
demo/fortgeschritten/index.php
Normal file
29
demo/fortgeschritten/index.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<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>
|
||||||
|
|
22
demo/fortgeschritten/loesung.php
Normal file
22
demo/fortgeschritten/loesung.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?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>
|
37
demo/oop/Frage.php
Normal file
37
demo/oop/Frage.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
}
|
9
demo/oop/holeFragen.php
Normal file
9
demo/oop/holeFragen.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?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'),
|
||||||
|
];
|
12
demo/oop/index.php
Normal file
12
demo/oop/index.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<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>
|
||||||
|
|
11
demo/oop/loesung.php
Normal file
11
demo/oop/loesung.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?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>";
|
||||||
|
}
|
29
demo/simpel/index.php
Normal file
29
demo/simpel/index.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<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>
|
||||||
|
|
31
demo/simpel/loesung.php
Normal file
31
demo/simpel/loesung.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?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