Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions GUI/sign-in/signin.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will test this file and come back to you...since github seems to reject this file

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is unneeded... since it is already implemented by kareem in app.py, and the sign-up and sign-in functions will be parts of users, teachers, and supervisors classes, not that it will have a file on its own

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from flask import Flask, render_template, request, redirect, url_for, flash
import datetime
app = Flask(__name__)
app.secret_key = 'super_secret_key'

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

@app.route('/signin', methods=['POST'])
def sign_in():
username = request.form['username']
password = request.form['password']

if username == "Test" and password == "K.test":
flash('Sign In successful!', 'success')
else:
flash('Invalid username or password', 'error')

return redirect(url_for('index'))

# users must choose whether they are students or teachers
# it must be able to insert the data into the database
# it must be able to check if the data is valid (username must be unique, password must be strong using regex, email must be valid using regex)
# it must store the account creation date and time
@app.route('/signup', methods=['GET', 'POST'])
def sign_up():
if request.method == 'POST':
username = request.form['username']
email = request.form['email']
password = request.form['password']

flash(f'Username: {username}, Email: {email},Password: {password} created successfully!', 'success')
return redirect(url_for('index'))

return render_template('signup.html')

if __name__ == '__main__':
app.run(debug=True)
Empty file added classes/COURSIZ.db
Empty file.
Empty file added classes/Coursiz V2.db
Empty file.
Binary file not shown.
Binary file added classes/__pycache__/students.cpython-311.pyc
Binary file not shown.
Binary file added classes/__pycache__/supervisors.cpython-311.pyc
Binary file not shown.
Binary file added classes/__pycache__/users.cpython-311.pyc
Binary file not shown.
40 changes: 40 additions & 0 deletions classes/courses.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helpful stuff

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import databaseConnection
import students
import professors
query = connection.cursor()


class courses(students, professors):
def __init__(self, courseName, yearTeached, Semester, Course_Code, Capacity, Number_enrolled):
self.courseName = courseName
self.yearTeached = yearTeached
self.Semester = Semester
self.Course_Code = Course_Code
self.Capacity = Capacity
self.Number_enrolled = Number_enrolled

def createCourse(self, courseName, yearTeached, Semester, Course_Code, Capacity, Number_enrolled):
query.excute('''insert into Courses(courseName, yearTeached, Semester, Course_Code, Capacity, Number_enrolled)
values (?, ?, ?, ?, ?, ?)''', (courseName, yearTeached, Semester, Course_Code, Capacity, Number_enrolled))
query.commit()

def deleteCourse(self, courseName, yearTeached, Semester, Course_Code, Capacity, Number_enrolled):
query.excute('''delete from Courses where courseName = ? and yearTeached = ? and Semester = ? and Course_Code = ? and Capacity = ? and Number_enrolled = ?''', (courseName, yearTeached, Semester, Course_Code, Capacity, Number_enrolled))
query.commit()

def addStudentToCourse(self, student, Course_Code):
query.excute('''update Courses set Number_enrolled = ? where Course_Code = ?''', (Number_enrolled + 1 , Course_Code))
query.commit()
query.excute('''insert into Enroll_in set Student_ID = ?, Course_Code = ?, grade = ?''', (student.studentID, Course_Code, NULL))
query.commit()

def removeStudentFromCourse(self, student, Course_Code):
query.excute('''update Courses set Number_enrolled = ? where Course_Code = ?''', (Number_enrolled - 1 , Course_Code))
query.commit()
query.excute('''delete from Enroll_in where Student_ID = ? and Course_Code = ?''', (student.studentID, Course_Code))
query.commit()





13 changes: 4 additions & 9 deletions classes/databaseConnection.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import pyodbc

# first install pyodbc using pip install pyodbc
# get the server name SQL Server
# create a new database in SQL Server
# then execute sql commands in the "SQL code.sql" file
# replace the server with your server name
# replace the database with your database name

connectionString = (
r'DRIVER={SQL Server};'
r'SERVER= server;'
r'DATABASE= databaseName;'
r'SERVER=DESKTOP-0TH5VGS\SQLEXPRESS;'
r'DATABASE=Coursiz;'
r'Trusted_Connection=yes;'
)
connection = pyodbc.connect(connectionString)
cursor = connection.cursor()
22 changes: 22 additions & 0 deletions classes/interface.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the role of this file?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to merge this anymore......

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from flask import Flask
from users import *
# Flask constructor takes the name of
# current module (__name__) as argument.
app = Flask(__name__)

# The route() function of the Flask class is a decorator,
# which tells the application which URL should call
# the associated function.
@app.route('/')
# ‘/’ URL is bound with hello_world() function.
def hello_world():
test = users()
x = input('Enter role: ')
return test.roleSelection('x')

# main driver function
if __name__ == '__main__':

# run() method of Flask class runs the application
# on the local development server.
app.run()
27 changes: 12 additions & 15 deletions classes/professors.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with users, this class is wrong And I will take care of it...so drop it

Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
from users import *

import databaseConnection
c = connection.cursor()
class professors(users):
def sign_in(self, username, password):
if username == "1" and password == "1":
return true
else:
return false

def sign_up(self, username, email, password):
return username, email, password

def studentsEntry(self, choice):
if choice == "Sign in":
self.sign_in(username, password)
elif choice == "Sign up":
self.sign_up(username, email, password)
def __init__(self, name, email, password, professorID):
super().__init__(name, email, password)
self.professorID = professorID

# Will allow teachers to send to each student their grade
def sendGrade(self, student, course, grade):
c.execute('''insert into Enroll_in(Student_ID, Course_Code, grade)
values (?, ?, ?)''', (student.studentID, course.courseCode, grade))
c.commit()
c.close()
121 changes: 121 additions & 0 deletions classes/stream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
class StreamItem:
def __init__(self, title):
self.title = title

def display(self):
print(f"Stream : {self.title}")


class Upload(StreamItem):
def __init__(self, title, file):
super().__init__(title)
self.file = file

def display(self):
print(f"Upload: {self.title} - File: {self.file}")


class Announce(StreamItem):
def __init__(self, title, message):
super().__init__(title)
self.message = message

def display(self):
print(f"Announcement: {self.title} - Message: {self.message}")


class Submit(StreamItem):
def __init__(self, title, assignment):
super().__init__(title)
self.assignment = assignment

def display(self):
print(f"Submission: {self.title} - Assignment: {self.assignment}")


class Attendance(StreamItem):
def __init__(self, title, student_name, present):
super().__init__(title)
self.student_name = student_name
self.present = present

def display(self):
status = "Yes" if self.present else "No"
print(f"Attendance: {self.title} - Student: {self.student_name} - Present: {status}")


class Stream:
MAX_ITEMS = 10

def __init__(self):
self.items = []
self.size = 0

def add_item(self, item):
if self.size < self.MAX_ITEMS:
self.items.append(item)
self.size += 1
else:
print("Stream is full. Cannot add more items.")

def display_stream(self):
for item in self.items:
item.display()


class Teacher:
def alert_submission(self, title, student_name, assignment_title):
print(f"Alert: Teacher {title} - Student {student_name} submitted {assignment_title}.")

def post_on_stream(self, item):
item.display()

def submit_attendance(self, title, student_name, present):
attendance = Attendance(title, student_name, present)
attendance.display()
# Logic to store attendance record


def main():
stream = Stream()
teacher = Teacher()

upload_type = input("Uploading? (Document, Announcement, Assignment): ")

if upload_type == "Document" or upload_type == "Lecture":
doc_title = input("Document title: ")
doc_content = input("Document content: ")
stream.add_item(Upload(doc_title, doc_content))
elif upload_type == "Announcement":
announce_title = input("Announcement title: ")
announce_content = input("Announcement content: ")
stream.add_item(Announce(announce_title, announce_content))
elif upload_type == "Assignment":
asg_title = input("Assignment title: ")
asg_type = input("Assignment type: ")
stream.add_item(Submit(asg_title, asg_type))
else:
print("Invalid upload type.")

stream.display_stream()
print("________________________________________")
print("alert submittion ")
teacher_name = input("Teacher name: ")
student_name = input("Student name you want to alert: ")
alert_sub = input("Assessment reminded: ")
teacher.alert_submission(teacher_name, student_name, alert_sub)
print("_____________________________________________")

print("attendance tracker ")
class_name = input("Class name: ")
student_name = input("Student name: ")
attended = input("Attended? (True/False): ").lower() == "true"
teacher.submit_attendance(class_name, student_name, attended)


if __name__ == "__main__":
main()


if __name__ == "__main__":
main()
41 changes: 41 additions & 0 deletions classes/students.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from users import users
import pyodbc
connection=pyodbc.connect('Driver={SQL Server};SERVER=DESKTOP-9IHIA03;DATABASE=Coursiz;Trusted_Connection=yes')
query = connection.cursor()
class students(users):
def __init__(self,id):
self.id=id
def addStudentToCourse(self,Course_Code):
query.execute("SELECT Course_Code FROM Courses WHERE Course_Code = ?", (Course_Code))
fetched=query.fetchone()
if fetched is None:
return False
else:
query.execute("select Capacity,Number_enrolled from Courses where Course_Code = ?", (Course_Code))
fetched=query.fetchone()
if fetched[0] is None:
self.Number_enrolled=0
else: self.Number_enrolled=fetched[0]
# self.Capacity=fetched[1]
# if self.Number_enrolled >= self.Capacity:
# return False
# else:
query.execute("update Courses set Number_enrolled = ? where Course_Code = ?", (self.Number_enrolled + 1 , Course_Code))
query.commit()
query.execute("insert into Enroll_in(Student_ID,Course_Code) values(?,?)", (self.id, Course_Code))
query.commit()
return True

def removeStudentFromCourse(self,Course_Code):
query.execute('''update Courses set Number_enrolled = ? where Course_Code = ?''', (self.Number_enrolled - 1 , Course_Code))
query.commit()
query.execute('''delete from Enroll_in where Student_ID = ? and Course_Code = ?''', (self.id, Course_Code))
query.commit()

def get_courses(self):
query.execute("select Course_Code from Enroll_in where Student_ID = ?", (self.id))
fetched=[]
for i in query.fetchall():
i=i[0]
fetched.append(i)
return fetched
53 changes: 53 additions & 0 deletions classes/submissions.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really promising work!! would make it alot easier for me to integrate

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from students import students
from databaseConnection import *
import random
import time

c = connection.cursor()
class submissions():
def __init__(self, submissionLink, studentID, uploadID):
self.submissionLink = submissionLink
self.studentID = studentID
self.uploadID = uploadID
pass

class assignmentsHandler(submissions):
def submitAssignment(self, assignmentLink, student):
submissionID = random.randint(1 , 10000)
if assignmentLink.startswith("https://docs.google.com/") or assignmentLink.startswith("https://drive.google.com/") and assignmentLink.endswith("sharing"):
try:
# student id and upload id are hardcoded until edible population for the database
c.execute('''insert into Submissions(Submission_ID, Document_link, Student_ID, Upload_ID)
values (?, ?, ?, ?)''', (submissionID , assignmentLink , 1, 1))
c.commit()
c.close()
print("Work submitted successfully")
except pyodbc.IntegrityError:
self.submitWork(assignmentLink, student)
else:
print("Invalid link")
self.submitAssignment(input("Enter a valid link: "), student)


class quizHandler(submissions):
# when the student enter the link of the quiz, the setTimeForQuiz function will be called using get method linked by clicking on the link
def setTimeForQuiz(self, durationInMinutes):
# setting timer on
isStarted = True
isFinished = False
isEnded = False
# using google sheets api, when the student submit the quiz, the isFinished will be set to True
isFinished = True
if isFinished:
isStarted = False
print("Quiz has ended")
# when the durationInMinutes is over, the isEnded will be set to True
isEnded = True
if not isFinished and isEnded:
# close the forms using google forms API
print("Quiz has ended")
# add the grade to the database from the google sheets using google sheets API
c.execute('''insert into Enroll_in(Student_ID, Course_Code, grade)
values (?, ?, ?, ?)''', (random.randint(1,10000), EnrollIn.courseID,))
c.commit()
c.close()
4 changes: 4 additions & 0 deletions classes/supervisors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from users import *

class supervisors(users.users):
pass
Loading