0% found this document useful (0 votes)
9 views

Ask Ai 441208

The document describes a simple web-based marking app that allows teachers to enter student names and scores for an assignment using Flask and SQLite. It includes Python code to define a Student model, add students, calculate average scores, and basic HTML templates to display student info and average.

Uploaded by

yahyeielmasry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Ask Ai 441208

The document describes a simple web-based marking app that allows teachers to enter student names and scores for an assignment using Flask and SQLite. It includes Python code to define a Student model, add students, calculate average scores, and basic HTML templates to display student info and average.

Uploaded by

yahyeielmasry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

To create a marking app, you'll need more specific requirements.

However, I can provide a simple example of a


web-based marking app using Flask (a Python web framework) and SQLite (a lightweight disk-based
database). This app will allow teachers to enter student names and scores for a single assignment, and then
calculate the average score.
Here's a basic Python script using Flask and SQLite:
```python
from flask import Flask, request, render_template
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
class Student(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50))
score = db.Column(db.Float)
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
name = request.form.get('name')
score = request.form.get('score')
student = Student(name=name, score=score)
db.session.add(student)
db.session.commit()
students = Student.query.all()
return render_template('index.html', students=students)
@app.route('/average', methods=['GET'])
def average():
students = Student.query.all()
if students:
avg_score = sum([student.score for student in students]) / len(students)
else:
avg_score = 0
return render_template('average.html', average=avg_score)
if __name__ == '__main__':
db.create_all()
app.run(debug=True)
```
In this script, the `Student` class represents a table in the SQLite database. The `index` function creates a new
student with the name and score from the form data when a POST request is made, and retrieves all students
when a GET request is made. The `average` function calculates the average score of all students.
You'll also need two HTML templates in the templates folder:
`index.html`:
```html
<!DOCTYPE html>
<html>
<body>
<h2>Enter Student Info</h2>
<form action="/" method="post">
<label for="name">Name:</label><br>
<input type="text" id="name" name="name"><br>
<label for="score">Score:</label><br>
<input type="number" id="score" name="score"><br>
<input type="submit" value="Submit">
</form>
<h2>Student Scores</h2>
{% for student in students %}
<p>{{ student.name }}: {{ student.score }}</p>
{% endfor %}
</body>
</html>
```
`average.html`:
```html
<!DOCTYPE html>
<html>
<body>
<h2>Average Score</h2>
<p>{{ average }}</p>
</body>
</html>
```
Please note that this is a very simple example and lacks many features (like error handling) that a real-world
marking app would need. Building a full-featured marking app would require more time and resources and a
thorough understanding of the specific requirements.

You might also like