fetch()['minutes'] . "\""; }?>/>
+
";
+ $time_set = check_time($con, $m_id, $s_id);
+ echo "
+
+ fetch()['minutes'] . "\"";
+ }
+ echo "/>
-
-
-
fetch()['seconds'] . "\""; }?>/>
+
+
+ fetch()['seconds'] . "\""; }
+ echo"/>
-
-
/>
-
/>
-
+
";
+ } else {
+ echo "
+
+ ";
+ }?>
+ />
+ />
+
diff --git a/app/scripts/database_queries.php b/app/scripts/database_queries.php
index 6149d38..74092e5 100644
--- a/app/scripts/database_queries.php
+++ b/app/scripts/database_queries.php
@@ -469,4 +469,64 @@ function update_team_fire_department($con, $m_id, $dep) {
} catch(PDOException $e) {
handle_pdo_exception($e);
}
+}
+
+function get_direct_points($con, $s_id) {
+ try {
+ $stmt = $con->prepare("SELECT direkte_punkte FROM Station WHERE s_id = :s_id");
+ $stmt->execute(['s_id' => $s_id]);
+ $stmt->setFetchMode(PDO::FETCH_ASSOC);
+ return $stmt;
+ } catch(PDOException $e) {
+ handle_pdo_exception($e);
+ }
+}
+
+function write_result_db($con, $s_id, $m_id, $result) {
+ try {
+ $stmt = $con->prepare("INSERT INTO Ergebnisse (s_id, m_id, erg) VALUES (?, ?, ?)");
+ $stmt->bindParam(1, $s_id, PDO::PARAM_INT);
+ $stmt->bindParam(2, $m_id, PDO::PARAM_INT);
+ $stmt->bindParam(3, $result, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch(PDOException $e) {
+ handle_pdo_exception($e);
+ }
+}
+
+function get_results($con, $s_id) {
+ try {
+ $stmt = $con->prepare("SELECT * FROM Ergebnisse WHERE s_id = :s_id ORDER BY erg DESC");
+ $stmt->execute(['s_id' => $s_id]);
+ $stmt->setFetchMode(PDO::FETCH_ASSOC);
+ return $stmt;
+ } catch(PDOException $e) {
+ handle_pdo_exception($e);
+ }
+}
+
+function update_result_db($con, $s_id, $m_id, $result) {
+ try {
+ $stmt = $con->prepare("UPDATE Ergebnisse SET erg = ? WHERE s_id = ? AND m_id = ?");
+ $stmt->bindParam(1, $result, PDO::PARAM_INT);
+ $stmt->bindParam(2, $s_id, PDO::PARAM_INT);
+ $stmt->bindParam(3, $m_id, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch(PDOException $e) {
+ handle_pdo_exception($e);
+ }
+}
+
+function get_result_team_station($con, $s_id, $m_id) {
+ try {
+ $stmt = $con->prepare("SELECT * FROM Ergebnisse WHERE s_id = ? AND m_id = ?");
+ $stmt->bindParam(1, $s_id, PDO::PARAM_INT);
+ $stmt->bindParam(2, $m_id, PDO::PARAM_INT);
+ $stmt->execute();
+ $stmt->setFetchMode(PDO::FETCH_ASSOC);
+ $result = $stmt->fetch()['erg'];
+ return $result;
+ } catch( PDOException $e) {
+ handle_pdo_exception($e);
+ }
}
\ No newline at end of file
diff --git a/app/scripts/functions.php b/app/scripts/functions.php
index 9bc2dff..4283191 100644
--- a/app/scripts/functions.php
+++ b/app/scripts/functions.php
@@ -228,4 +228,24 @@ function get_time_str($con, $m_id, $s_id) {
function sanitize_input ($input) {
$return = strip_tags($input);
return htmlspecialchars($return, ENT_QUOTES);
+}
+
+function update_points($con, $s_id) {
+ $results = get_results($con, $s_id)->fetchAll();
+ $factor = $results[0]['erg']/ 15.0;
+ foreach($results as $row) {
+ $points = round($row['erg']/$factor);
+ change_points($con, $row['m_id'], $s_id, $points);
+ }
+}
+
+function write_result($con, $s_id, $m_id, $result) {
+ write_result_db($con, $s_id, $m_id, $result);
+ write_points($con, $s_id, $m_id, 0, null);
+ update_points($con, $s_id);
+}
+
+function update_result($con, $s_id, $m_id, $result) {
+ update_result_db($con, $s_id, $m_id, $result);
+ update_points($con, $s_id);
}
\ No newline at end of file