Merge branch 'master' of https://gitlab.sarwar.cloud/hamza.sarwar/Lachenzelg
This commit is contained in:
commit
b4c925f6aa
@ -22,7 +22,8 @@
|
||||
<div class="col-7">
|
||||
<a href="categories.php" class="btn ms-2 btn-light float-end"> <i class="ti ti-arrow-left"></i> Zurück zur Übersicht</a>
|
||||
<a href="categories-registrations.php?id=<?= $category['data']['id']; ?>" class="btn ms-2 btn-secondary float-end"> <i class="ti ti-chart-candle"></i> Kursanmeldungen</a>
|
||||
<a href="categories-reports.php?id=<?= $category['data']['id']; ?>" class="btn btn-danger float-end disabled"> <i class="ti ti-chart-area"></i> Auswertung</a>
|
||||
<a href="categories-reports-course.php?id=<?= $category['data']['id']; ?>" class="btn btn-danger ms-2 float-end"> <i class="ti ti-chart-area"></i> Statistik nach Kurs</a>
|
||||
<a href="categories-reports-class.php?id=<?= $category['data']['id']; ?>" class="btn btn-warning float-end"> <i class="ti ti-chart-area"></i> Statistik nach Klasse</a>
|
||||
</div>
|
||||
</div>
|
||||
<form action="code.php" method="POST">
|
||||
|
67
admin/categories-reports-class.php
Normal file
67
admin/categories-reports-class.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php include('includes/header.php'); ?>
|
||||
<div>
|
||||
<?php
|
||||
$paramResult = checkParamId('id');
|
||||
if(!is_numeric($paramResult)){
|
||||
echo '<div class="alert alert-danger" role="alert">'.$paramResult.'</div>';
|
||||
return false;
|
||||
}
|
||||
|
||||
$category = getById('tbl_categories', checkParamId('id'));
|
||||
if($category['status'] == 200) {
|
||||
?>
|
||||
<div class="card card-body p-4">
|
||||
<?= alertMessage(); ?>
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<h3 class="fw-semibold mb-4">Statistik nach Klasse zu <?=$category['data']['name'];?></h3>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<a href="categories-edit.php?id=<?=$category['data']['id'];?>" class="btn btn-light float-end">
|
||||
<i class="ti ti-arrow-left"></i> Zurück zur Übersicht
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover" id="sortTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="cursor: pointer;" onclick="sortTable(0)">Klasse</th>
|
||||
<th style="cursor: pointer;" onclick="sortTable(1)">Schüler</th>
|
||||
<th style="cursor: pointer;" onclick="sortTable(2)">Mit Auswahl</th>
|
||||
<th style="cursor: pointer;" onclick="sortTable(3)">Nichts ausgewählt</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$classes = mysqli_query($conn, "
|
||||
SELECT
|
||||
c.id AS classID,
|
||||
CONCAT(c.sek, ' ', c.type, ' - ', c.name) AS classDisplayName
|
||||
FROM tbl_classes c
|
||||
");
|
||||
|
||||
while ($class = mysqli_fetch_assoc($classes)) {
|
||||
$classID = $class['classID'];
|
||||
$classDisplayName = $class['classDisplayName'];
|
||||
|
||||
$totalStudents = countStudentsInClass($classID);
|
||||
$studentsWithSelection = countStudentsWithSelection($classID, $category['data']['id']);
|
||||
$studentsWithoutSelection = $totalStudents - $studentsWithSelection;
|
||||
?>
|
||||
<tr>
|
||||
<td><?= $classDisplayName; ?></td>
|
||||
<td><?= $totalStudents; ?></td>
|
||||
<td><?= $studentsWithSelection; ?></td>
|
||||
<td><?= $studentsWithoutSelection; ?></td>
|
||||
</tr>
|
||||
<?php }
|
||||
} ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('includes/footer.php'); ?>
|
74
admin/categories-reports-course.php
Normal file
74
admin/categories-reports-course.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php include('includes/header.php'); ?>
|
||||
<div>
|
||||
<?php
|
||||
$paramResult = checkParamId('id');
|
||||
if(!is_numeric($paramResult)){
|
||||
echo '<div class="alert alert-danger" role="alert">'.$paramResult.'</div>';
|
||||
return false;
|
||||
}
|
||||
|
||||
$category = getById('tbl_categories',checkParamId('id'));
|
||||
if($category['status'] == 200)
|
||||
{
|
||||
?>
|
||||
<div class="card card-body p-4">
|
||||
<?= alertMessage(); ?>
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<h3 class="fw-semibold mb-4">Statistik nach Kurs zu <?=$category['data']['name'] ;?> </h3>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<a href="categories-edit.php?id=<?=$category['data']['id'] ;?>" class="btn btn-light float-end"> <i class="ti ti-arrow-left"></i> Zurück zur Übersicht</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover" id="sortTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="cursor: pointer;" onclick="sortTable(0)">Kursname</th>
|
||||
<th style="cursor: pointer;" onclick="sortTable(1)">Anzahl der Schüler</th>
|
||||
<th style="cursor: pointer;" onclick="sortTable(2)">Angemeldet</th>
|
||||
<th style="cursor: pointer;" onclick="sortTable(3)">Genehmigt</th>
|
||||
<th style="cursor: pointer;" onclick="sortTable(4)">Abgelehnt</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$category_id = $category['data']['id'];
|
||||
$courses = getAll('id,name', 'tbl_courses', "WHERE category_id='$category_id'");
|
||||
|
||||
if(mysqli_num_rows($courses) > 0) {
|
||||
foreach($courses as $courseEntry) {
|
||||
$studentCount = countAllStudentsInCourse($courseEntry['id']);
|
||||
$registeredCount = countStudentsByStatus($courseEntry['id'], 'Angemeldet');
|
||||
$selectedCount = countStudentsByStatus($courseEntry['id'], 'Genehmigt');
|
||||
$rejectedCount = countStudentsByStatus($courseEntry['id'], 'Abgelehnt');
|
||||
?>
|
||||
<tr>
|
||||
<td><?= $courseEntry['name']; ?></td>
|
||||
<td><?= $studentCount; ?></td>
|
||||
<td><?= $registeredCount; ?></td>
|
||||
<td><?= $selectedCount; ?></td>
|
||||
<td><?= $rejectedCount; ?></td>
|
||||
<td>
|
||||
<a href="courses-edit.php?id=<?= $courseEntry['id']; ?>" class="btn btn-light btn-sm float-end mx-1"> <i class="ti ti-pencil"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="7">Keine Kurse vorhanden</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('includes/footer.php'); ?>
|
@ -1,101 +0,0 @@
|
||||
<?php include('includes/header.php'); ?>
|
||||
<div>
|
||||
<div class="card card-body p-4">
|
||||
<?= alertMessage(); ?>
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<h3 class="fw-semibold mb-4">Administrator bearbeiten</h3>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<a href="admins.php" class="btn btn-light float-end"> <i class="ti ti-arrow-left"></i> Zurück zur Übersicht</a>
|
||||
</div>
|
||||
</div>
|
||||
<form action="code.php" method="POST">
|
||||
<?php
|
||||
$paramResult = checkParamId('id');
|
||||
if(!is_numeric($paramResult)){
|
||||
echo '<div class="alert alert-danger" role="alert">'.$paramResult.'</div>';
|
||||
return false;
|
||||
}
|
||||
|
||||
$admin = getById('tbl_admins',checkParamId('id'));
|
||||
if($admin['status'] == 200)
|
||||
{
|
||||
?>
|
||||
<input type="hidden" name="id" value="<?= $admin['data']['id'] ;?>" required>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Vorname</label>
|
||||
<input type="text" name="firstname" value="<?= $admin['data']['firstname'] ;?>" required class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Nachname</label>
|
||||
<input type="text" name="lastname" value="<?= $admin['data']['lastname'] ;?>" required class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Benutzer-ID</label>
|
||||
<input type="text" name="user-id" value="<?= $admin['data']['userid'] ;?>" required pattern="[A-Za-z0-9\-]+" onkeydown="if(['Space'].includes(arguments[0].code)){return false;}" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Kennwort</label>
|
||||
<input type="password" name="password" value="<?= $admin['data']['password'] ;?>" required class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Status</label>
|
||||
<select name="status" class="form-select">
|
||||
<?php
|
||||
$enumValueLabels = [
|
||||
'active' => 'Aktiv',
|
||||
'disabled' => 'Inaktiv'
|
||||
];
|
||||
createEnumSelect('tbl_admins', 'status', $admin['data']['status'],$enumValueLabels); ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<button type="submit" name="updateadmin" class="btn btn-info float-end mx-1"> <i class="ti ti-check"></i> Änderungen speichern</button>
|
||||
<a type="button" class="btn btn-danger float-end mx-1" data-bs-toggle="modal" data-bs-target="#deleteAdmin"><i class="ti ti-trash"></i> Löschen</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<div class="alert alert-danger" role="alert">'.$admin['message'].'</div>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="deleteAdmin" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="staticBackdropLabel">Administrator entfernen</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Sind Sie sicher, dass Sie <b><?= $admin['data']['firstname'] . ' ' . $admin['data']['lastname']?></b> entfernen möchten?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Abbrechen</button>
|
||||
<a href="admins-delete.php?id=<?= $admin['data']['id']; ?>" class="btn btn-danger"><i class="ti ti-trash"></i> Löschen</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal Ende -->
|
||||
<?php include('includes/footer.php'); ?>
|
@ -962,7 +962,7 @@ function isStudentRegisteredForCourse($studentId, $courseId) {
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
|
||||
return $count > 0;
|
||||
return $count = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -1001,4 +1001,132 @@ function getAllAssignedCoursesByCategory($studentID, $categoryID) {
|
||||
return $assignedCourses;
|
||||
}
|
||||
|
||||
// Funktion, die alle Schüler zählt, die einer Klasse zugewiesen sind, die der Kategorie und dem Kurs zugeordnet ist
|
||||
function countAllStudentsInCourse($courseID) {
|
||||
global $conn;
|
||||
|
||||
// Abfrage, um alle Schüler zu zählen, deren Klasse der Kategorie und dem Kurs zugeordnet ist
|
||||
$query = "
|
||||
SELECT COUNT(DISTINCT s.id)
|
||||
FROM tbl_students s
|
||||
INNER JOIN tbl_assign_categories_classes acc ON s.class = acc.class_id
|
||||
INNER JOIN tbl_assign_courses_classes acc_courses ON acc.class_id = acc_courses.class_id
|
||||
WHERE acc_courses.course_id = '$courseID'
|
||||
AND acc.category_id = (
|
||||
SELECT category_id FROM tbl_courses WHERE id = '$courseID'
|
||||
)
|
||||
";
|
||||
|
||||
$result = mysqli_query($conn, $query);
|
||||
|
||||
if ($result) {
|
||||
$row = mysqli_fetch_row($result);
|
||||
return $row[0]; // Gibt die Anzahl der Schüler zurück
|
||||
}
|
||||
|
||||
return 0; // Falls keine Schüler gefunden wurden
|
||||
}
|
||||
|
||||
|
||||
// Funktion, um Schüler nach Status zu zählen
|
||||
function countStudentsByStatus($courseID, $status) {
|
||||
global $conn;
|
||||
|
||||
// SQL-Abfrage, um die Anzahl der Schüler mit einem bestimmten Status zu zählen
|
||||
$query = "
|
||||
SELECT COUNT(DISTINCT s.id)
|
||||
FROM tbl_students s
|
||||
INNER JOIN tbl_assign_categories_classes acc ON s.class = acc.class_id
|
||||
INNER JOIN tbl_assign_courses_classes acc_courses ON acc.class_id = acc_courses.class_id
|
||||
INNER JOIN tbl_assign_students_courses asc_tbl ON asc_tbl.student_id = s.id
|
||||
WHERE acc_courses.course_id = '$courseID'
|
||||
AND acc.category_id = (
|
||||
SELECT category_id FROM tbl_courses WHERE id = '$courseID'
|
||||
)
|
||||
AND asc_tbl.status = '$status'
|
||||
";
|
||||
|
||||
$result = mysqli_query($conn, $query);
|
||||
|
||||
if ($result) {
|
||||
$row = mysqli_fetch_row($result);
|
||||
return $row[0]; // Gibt die Anzahl der Schüler mit diesem Status zurück
|
||||
}
|
||||
|
||||
return 0; // Falls keine Schüler gefunden wurden
|
||||
}
|
||||
|
||||
function countStudentsWithoutSelection($classID, $categoryID) {
|
||||
global $conn;
|
||||
|
||||
$query = "
|
||||
SELECT COUNT(DISTINCT s.id) AS no_selection_count
|
||||
FROM tbl_students s
|
||||
LEFT JOIN tbl_assign_students_courses asc_tbl
|
||||
ON asc_tbl.student_id = s.id
|
||||
AND asc_tbl.course_id IN (
|
||||
SELECT id
|
||||
FROM tbl_courses
|
||||
WHERE category_id = '$categoryID'
|
||||
)
|
||||
WHERE s.class = '$classID'
|
||||
AND asc_tbl.course_id IS NULL
|
||||
";
|
||||
|
||||
$result = mysqli_query($conn, $query);
|
||||
|
||||
if ($result) {
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
return $row['no_selection_count'];
|
||||
}
|
||||
|
||||
return 0; // Falls keine Schüler gefunden wurden
|
||||
}
|
||||
|
||||
function countStudentsInClass($classID) {
|
||||
global $conn;
|
||||
|
||||
$query = "
|
||||
SELECT COUNT(*) AS student_count
|
||||
FROM tbl_students
|
||||
WHERE class = '$classID'
|
||||
";
|
||||
|
||||
$result = mysqli_query($conn, $query);
|
||||
|
||||
if ($result) {
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
return $row['student_count'];
|
||||
}
|
||||
|
||||
return 0; // Falls keine Schüler in der Klasse gefunden wurden
|
||||
}
|
||||
|
||||
function countStudentsWithSelection($classID, $categoryID) {
|
||||
global $conn;
|
||||
|
||||
$query = "
|
||||
SELECT COUNT(DISTINCT s.id) AS selected_count
|
||||
FROM tbl_students s
|
||||
JOIN tbl_assign_students_courses asc_tbl
|
||||
ON s.id = asc_tbl.student_id
|
||||
WHERE s.class = '$classID'
|
||||
AND asc_tbl.course_id IN (
|
||||
SELECT id
|
||||
FROM tbl_courses
|
||||
WHERE category_id = '$categoryID'
|
||||
)
|
||||
";
|
||||
|
||||
$result = mysqli_query($conn, $query);
|
||||
|
||||
if ($result) {
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
return $row['selected_count'];
|
||||
}
|
||||
|
||||
return 0; // Falls keine Schüler mit einer Auswahl gefunden wurden
|
||||
}
|
||||
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user