function getValueByKey($arr, $yourkey) { foreach ($arr as $key => $value) { if ($key === $yourkey) { return $value; } else { if (!is_string($value)) { $value = (array) $value; $ss = getValueByKey($value, $yourkey); if ($ss !== 'null') { return $ss; } } } } return 'null'; }
if (empty($errors)) { //Checking is user existing in the database or not $query = "SELECT * FROM students WHERE matrikelnummer = {$matrikel} and linked_exam='{$exam}'"; $result = mysql_query($query) or die(mysql_error()); $rows = mysql_num_rows($result); if ($rows != 0) { array_push($errors, "Kombination aus Prüfung und Matrikelnummer existiert bereits!"); $success = NULL; } else { sendMail($matrikel, $exam); // array_push($errors,"Emailadresse scheint ungültig zu sein!"); // $success = NULL; // } else { $ins_query = "insert into `students`(`name`,`matrikelnummer`,`linked_exam`,`email`,`registration_date`)values('{$name}','{$matrikel}','{$exam}','{$email}',now())"; mysql_query($ins_query) or die(mysql_error()); $success = $name . ", Sie wurden erfolgreich zur Einsicht für die Prüfung " . getValueByKey($exam_db_name, "short", $exam, "name") . " angemeldet."; $numbOfStudCount_query = "SELECT * FROM students WHERE linked_exam = '{$exam}'"; $numbResult = mysql_query($numbOfStudCount_query); $numbOfStud = mysql_num_rows($numbResult); $update_counter_query = "UPDATE exams SET number_of_students = {$numbOfStud} WHERE short = '{$exam}'"; mysql_query($update_counter_query); // } } } ?> <!DOCTYPE html> <html> <?php include "header.html"; ?>
?> </td> <?php $sub_query = "Select * from `subtask` WHERE `linked_exam` = '" . $query_id . "' AND `linked_task` = '" . $row['id'] . "' ORDER BY letter;"; $sub_result = mysql_query($sub_query); while ($sub_row = mysql_fetch_assoc($sub_result)) { ?> <tr> <?php for ($x = 0; $x < count($subtask_keys); $x++) { $sub_name = $subtask_keys[$x]; if ($sub_name == "linked_phd") { ?> <td class="mdl-data-table__cell--non-numeric"> <?php echo getValueByKey($phd_db_name, "id", $sub_row[$sub_name], 'name'); ?> </td> <?php } else { ?> <td class="mdl-data-table__cell--non-numeric"> <?php echo $sub_row[$sub_name]; ?> </td> <?php } } ?> <td class="mdl-data-table__cell" >
$val++; } } } else { if ($intent == "calendar") { $query = "SELECT * from `students` WHERE matrikelnummer = " . $matrikelnummer; $result = mysql_query($query); $val = 0; while ($super_post = mysql_fetch_assoc($result)) { $query_2 = "SELECT * from `exams` WHERE short = '" . $super_post['linked_exam'] . "'"; $result_2 = mysql_query($query_2); $post = mysql_fetch_assoc($result_2); unset($post['password']); // Das Passwort wird nicht heruntergeladen! $post['date'] = date("d.m.Y", strtotime($post['date'])); $post['responsible_person'] = getValueByKey($phd_db_name, "id", $post['responsible_person'], 'name'); $posts[$val] = $post; $val++; } } else { if ($intent == "exam") { $query = "SELECT * from `task` WHERE linked_exam = '" . $exam_name . "' ORDER BY number"; $result = mysql_query($query); $val = 0; if (mysql_num_rows($result)) { while ($post = mysql_fetch_assoc($result)) { $sub_query = "SELECT * from `subtask` WHERE linked_exam = '" . $exam_name . "' AND linked_task = '" . $post['id'] . "' ORDER BY letter"; $sub_result = mysql_query($sub_query); $sub_array = array(); $sub_val = 0; if (mysql_num_rows($sub_result)) {
echo "<td class=\"mdl-data-table__cell--non-numeric\" align=\"center\">" . $p_string . "</td>"; } else { if ($name == "date") { setlocale(LC_ALL, 'de_DE@euro'); $t = strtotime($row[$name]); $date_string = date('j. F Y', $t); echo "<td class=\"mdl-data-table__cell--non-numeric\" align=\"center\">" . str_replace($english_months, $deutsch_monate, $date_string) . "</td>"; } else { if ($name == "linked_student") { echo "<td class=\"mdl-data-table__cell--non-numeric\" align=\"center\">" . getNameOfStudent($row['linked_student'], $row['linked_exam']) . "</td>"; } else { if ($name == "responsible_person") { echo "<td class=\"mdl-data-table__cell--non-numeric\" align=\"center\">" . getValueByKey($phd_db_name, "id", $row[$name], "name") . "</td>"; } else { if ($name == "linked_task") { echo "<td class=\"mdl-data-table__cell--non-numeric\" align=\"center\">" . getValueByKey($task_db_name, "id", $row[$name], "number") . getValueByKey($subtask_db_name, "id", $row['linked_subtask'], "letter") . "</td>"; } else { if ($name == "linked_subtask") { // } else { echo "<td class=\"mdl-data-table__cell--non-numeric\" align=\"center\">" . $row[$name] . "</td>"; } } } } } } } } } }
$start_time = $now; $end_time = date($date_string, strtotime($now) + 600); } else { //CHECK ob zwischen 2 Elementen noch Platz ist. $time = date($date_string, strtotime($now) + 600); while ($current_time_item = mysql_fetch_assoc($date_result_reverse)) { $current_time_item_reverse_start = date($date_string, strtotime($current_time_item['start_time'])); $current_time_item_reverse_end = date($date_string, strtotime($current_time_item['end_time'])); if (abs(strtotime($current_time_item_reverse_start) - strtotime($time)) > 10 * 60) { $start_time = date($date_string, strtotime($time)); $end_time = date($date_string, strtotime($time) + 600); break; } $time = $current_time_item_reverse_end; } } } $query = "insert into requests (`linked_subtask`,`linked_task`,`linked_exam`,`linked_phd`,`linked_student`,`submission_date`,`start_time`,`end_time`,`type_of_question`) values('{$subtask_id}','{$task_id}','{$exam_name}','{$phd}','{$matrikelnummer}',now(),'{$start_time}','{$end_time}','{$type_of_question}')"; $settings = array("result" => "true"); mysql_query($query); include 'push.php'; $res = launchPushService(getValueByKey($phd_db_name, "id", $phd, 'deviceID'), "Neue Anfrage bei SmartInsight", "Anfrage von " . getNameOfStudent($matrikelnummer, $exam_name) . " betreffs {$type_of_question}!"); } } else { $settings = array("result" => "Ein unbekannter Fehler ist aufgetreten!"); } } } } } echo json_encode($settings);