Skip to content

Commit

Permalink
Merge pull request #972 from ramsatyasai/main
Browse files Browse the repository at this point in the history
Gssoc 24v wanna add my project via #971
  • Loading branch information
Kushal997-das authored May 17, 2024
2 parents 323ef29 + 1fb6fdf commit 0b59315
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from flask import Flask, render_template, request
import pandas as pd

app = Flask(__name__, template_folder='templates')

@app.route('/')
def index():
return render_template('index.html')

@app.route('/generate_report', methods=['POST'])
def generate_report():
try:
# Get form data
students_file = request.files['students_file']
attendance_file = request.files['attendance_file']
threshold = int(request.form['threshold'])/100

def convert_to_seconds(duration_str):
h, m, s = map(int, duration_str.split(':'))
return h * 3600 + m * 60 + s

# Read CSV files
students_df = pd.read_csv(students_file)
attendance_df = pd.read_csv(attendance_file)

# Convert 'Time in Call' to total seconds
attendance_df['total_seconds'] = attendance_df['Time in Call'].apply(convert_to_seconds)

# Calculate threshold duration
max_duration = attendance_df['total_seconds'].max()
threshold_duration = max_duration * threshold

# Filter attendance data based on threshold
filtered_attendance = attendance_df[attendance_df['total_seconds'] > threshold_duration]

# Merge attendance data with student data
merged_data = pd.merge(filtered_attendance, students_df, left_on='Full Name', right_on='Student Name', how='left')

# Prepare report data
report_data = merged_data[['Roll No', 'Full Name', 'Time in Call']]
report_data.columns = ['roll_no', 'name', 'total_duration']
report_data = report_data.to_dict(orient='records')

return render_template('report.html', report_data=report_data)

except Exception as e:
error_message = f"Error: {str(e)}"
return render_template('index.html', error=error_message)

if __name__ == '__main__':
app.run(debug=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
The Virtual Classes Attendance Automation System is a web-based application developed using Flask, a Python web framework, to automate the process of generating attendance reports for virtual classes. This system allows users to upload two CSV files containing student information and attendance records, specify a minimum duration threshold for attendance, and generate a detailed report based on the provided criteria.
## Deployment

Check out the live deployment of this project [here](https://virtual-classes-attendance-automation.onrender.com).

Key features of the system include:
File Upload: Users can upload CSV files containing student information (`students_file`) and attendance records (`attendance_file`) directly through the web interface.
Threshold Setting: The system allows users to specify a minimum duration threshold (in seconds) for considering a student's attendance as valid. This threshold helps filter out short attendance durations.
Data Processing: Upon form submission, the system processes the uploaded CSV files, converts the 'Time in Call' duration to total seconds, and filters the attendance data based on the specified threshold.
Data Merge and Reporting: The system merges the filtered attendance data with student information based on matching names. It then generates a report containing relevant details such as roll number, student name, and total duration of attendance in hours, minutes, and seconds format.
User Interaction: After generating the report, users can view the attendance details in a formatted HTML table (`report.html`). The report page includes a button that allows users to reset and return to the initial form (`index.html`) for further processing.
This system streamlines the attendance tracking process for virtual classes, providing educators and administrators with a convenient tool to analyze student participation and ensure accurate attendance records. The use of Flask enables rapid development and deployment of the web application, making it accessible and user-friendly for both teachers and students.
By leveraging Python's pandas library for data manipulation and Flask for web development, the Virtual Classes Attendance Automation System offers a practical solution to enhance efficiency in managing virtual class attendance.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<!DOCTYPE html>
<html>
<head>
<title>Attendance Automation System</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f8f9fa;
color: #333;
margin: 0;
padding: 20px;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.form-container {
background-color: #ffffff;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
padding: 40px;
width: 400px;
max-width: 90%;
text-align: center;
}
h1 {
font-size: 24px;
margin-bottom: 20px;
color: #007bff;
}
form {
display: flex;
flex-direction: column;
align-items: center;
}

label {
display: block;
font-size: 16px;
margin-bottom: 10px;
color: #333;
}

input[type="file"],
input[type="number"] {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
font-size: 16px;
}

input[type="submit"],
input[type="reset"] {
background-color: #007bff;
color: #ffffff;
border: none;
padding: 12px 20px;
border-radius: 4px;
cursor: pointer;
font-size: 18px;
transition: background-color 0.3s ease;
margin-bottom: 10px;
}

input[type="submit"]:hover,
input[type="reset"]:hover {
background-color: #0056b3;
}
.error-message {
color: red;
margin-top: 10px;
font-size: 14px;
}
</style>
</head>
<body>
<div class="form-container">
<h1>Attendance Automation System</h1>
<form method="post" action="/generate_report" enctype="multipart/form-data">
<label for="students_file">Students CSV File:,<br> column names=[Student Name, Roll No]</label>
<input type="file" id="students_file" name="students_file" accept=".csv" required>

<label for="attendance_file">Attendance CSV File:<br> column names=[Full Name,First Seen,Time in Call]</label>
<input type="file" id="attendance_file" name="attendance_file" accept=".csv" required>

<label for="threshold">Minimum Duration Threshold (percentage):</label>
<input type="number" id="threshold" name="threshold" required>

<input type="submit" value="Generate Report">
<input type="reset" value="Reset Form">
</form>

{% if error %}
<p class="error-message">{{ error }}</p>
{% endif %}
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<html>
<head>
<title>Attendance Report</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f8f9fa;
color: #333;
margin: 0;
padding: 20px;
}
h1 {
text-align: center;
margin-bottom: 30px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 10px;
text-align: left;
}
th {
background-color: #007bff;
color: #fff;
}
.button-container {
text-align: center;
margin-top: 20px;
}
button {
background-color: #007bff;
color: #fff;
border: none;
padding: 12px 20px;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<h1>Attendance Report</h1>
<table>
<tr>
<th>Roll No</th>
<th>Name</th>
<th>Total Duration (hh:mm:ss)</th>
</tr>
{% for record in report_data %}
<tr>
<td>{{ record['roll_no'] }}</td>
<td>{{ record['name'] }}</td>
<td>{{ record['total_duration'] }}</td>
</tr>
{% endfor %}
</table>
<div class="button-container">
<button onclick="window.location.href='/'">Back to Form</button>
</div>
</body>
</html>

0 comments on commit 0b59315

Please sign in to comment.