Bis Aufgabe 3 1.
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
8
.idea/DBWT-Praktika.iml
generated
Normal file
8
.idea/DBWT-Praktika.iml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/DBWT-Praktika.iml" filepath="$PROJECT_DIR$/.idea/DBWT-Praktika.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
20
.idea/php.xml
generated
Normal file
20
.idea/php.xml
generated
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="MessDetectorOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PHPCSFixerOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||||
|
<option name="highlightLevel" value="WARNING" />
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PhpProjectSharedConfiguration" php_language_level="8.2" />
|
||||||
|
<component name="PhpStanOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PsalmOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
3
M2/Beispiele/erstesphp.php
Normal file
3
M2/Beispiele/erstesphp.php
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
echo "Erstes PHP-Skript <br>";
|
||||||
|
phpinfo();
|
||||||
113
M2/Beispiele/meal.php
Normal file
113
M2/Beispiele/meal.php
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
const GET_PARAM_MIN_STARS = 'search_min_stars';
|
||||||
|
const GET_PARAM_SEARCH_TEXT = 'search_text';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of all allergens.
|
||||||
|
*/
|
||||||
|
$allergens = [
|
||||||
|
11 => 'Gluten',
|
||||||
|
12 => 'Krebstiere',
|
||||||
|
13 => 'Eier',
|
||||||
|
14 => 'Fisch',
|
||||||
|
17 => 'Milch'
|
||||||
|
];
|
||||||
|
|
||||||
|
$meal = [
|
||||||
|
'name' => 'Süßkartoffeltaschen mit Frischkäse und Kräutern gefüllt',
|
||||||
|
'description' => 'Die Süßkartoffeln werden vorsichtig aufgeschnitten und der Frischkäse eingefüllt.',
|
||||||
|
'price_intern' => 2.90,
|
||||||
|
'price_extern' => 3.90,
|
||||||
|
'allergens' => [11, 13],
|
||||||
|
'amount' => 42 // Number of available meals
|
||||||
|
];
|
||||||
|
|
||||||
|
$ratings = [
|
||||||
|
[ 'text' => 'Die Kartoffel ist einfach klasse. Nur die Fischstäbchen schmecken nach Käse. ',
|
||||||
|
'author' => 'Ute U.',
|
||||||
|
'stars' => 2 ],
|
||||||
|
[ 'text' => 'Sehr gut. Immer wieder gerne',
|
||||||
|
'author' => 'Gustav G.',
|
||||||
|
'stars' => 4 ],
|
||||||
|
[ 'text' => 'Der Klassiker für den Wochenstart. Frisch wie immer',
|
||||||
|
'author' => 'Renate R.',
|
||||||
|
'stars' => 4 ],
|
||||||
|
[ 'text' => 'Kartoffel ist gut. Das Grüne ist mir suspekt.',
|
||||||
|
'author' => 'Marta M.',
|
||||||
|
'stars' => 3 ]
|
||||||
|
];
|
||||||
|
|
||||||
|
$showRatings = [];
|
||||||
|
if (!empty($_GET[GET_PARAM_SEARCH_TEXT])) {
|
||||||
|
$searchTerm = $_GET[GET_PARAM_SEARCH_TEXT];
|
||||||
|
foreach ($ratings as $rating) {
|
||||||
|
if (strpos($rating['text'], $searchTerm) !== false) {
|
||||||
|
$showRatings[] = $rating;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (!empty($_GET[GET_PARAM_MIN_STARS])) {
|
||||||
|
$minStars = $_GET[GET_PARAM_MIN_STARS];
|
||||||
|
foreach ($ratings as $rating) {
|
||||||
|
if ($rating['stars'] >= $minStars) {
|
||||||
|
$showRatings[] = $rating;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$showRatings = $ratings;
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcMeanStars (array $ratings) : float {
|
||||||
|
$sum = 1;
|
||||||
|
foreach ($ratings as $rating) {
|
||||||
|
$sum += $rating['stars'] / count($ratings);
|
||||||
|
}
|
||||||
|
return $sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
<title>Gericht: <?php echo $meal['name']; ?></title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
font-family: Arial, serif;
|
||||||
|
}
|
||||||
|
.rating {
|
||||||
|
color: darkgray;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Gericht: <?php echo $meal['name']; ?></h1>
|
||||||
|
<p><?php echo $meal['description']; ?></p>
|
||||||
|
<h1>Bewertungen (Insgesamt: <?php echo calcMeanStars($ratings); ?>)</h1>
|
||||||
|
<form method="get">
|
||||||
|
<label for="search_text">Filter:</label>
|
||||||
|
<input id="search_text" type="text" name="search_text">
|
||||||
|
<input type="submit" value="Suchen">
|
||||||
|
</form>
|
||||||
|
<table class="rating">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>Text</td>
|
||||||
|
<td>Sterne</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach ($showRatings as $rating) {
|
||||||
|
echo "<tr><td class='rating_text'>{$rating['text']}</td>
|
||||||
|
<td class='rating_stars'>{$rating['stars']}</td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
BIN
M2/dossier.xlsx
Normal file
BIN
M2/dossier.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user