Skip to content

Commit 55909ad

Browse files
committed
final version
1 parent 000d1b9 commit 55909ad

11 files changed

+14
-16
lines changed

__pycache__/app.cpython-37.pyc

5 Bytes
Binary file not shown.

app.py

+10-13
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
47: "11:30pm"
145145
}
146146

147+
# Handles user registration
147148
@app.route("/register", methods = ["GET", "POST"])
148149
def register():
149150
if request.method == "POST":
@@ -180,6 +181,7 @@ def register():
180181
return render_template("register.html")
181182

182183

184+
# Handles user login
183185
@app.route("/login", methods=["GET", "POST"])
184186
def index():
185187
session.clear()
@@ -208,6 +210,7 @@ def index():
208210
# Return the login page
209211
return render_template("login.html")
210212

213+
# Handles user logout
211214
@app.route("/logout")
212215
@login_required
213216
def logout():
@@ -270,7 +273,7 @@ def courses():
270273
# Set the homepage for our website to "main.html"
271274
@app.route("/")
272275
def home():
273-
return render_template("main.html")#f courses():s():
276+
return render_template("main.html")
274277

275278
@app.route("/prefs", methods=["GET", "POST"])
276279
@login_required
@@ -284,7 +287,7 @@ def prefs():
284287
# Assume that locationlist is the single location they enter into the form
285288
course = request.form.get("course")
286289
# Check that course as submitted is an integer with six digits
287-
if course % 1 != 0 or len(str(course))!=6:
290+
if not course.isdigit() or len(str(course))!=6:
288291
error = "Make sure you are submitting a six number course ID, not the course name!"
289292
return render_template("prefs.html", locations = locations, daysoftheweek = daysoftheweek, time_to_index = time_to_index, error = error)
290293
# Obtain email from the session id for the currently signed in user
@@ -320,8 +323,9 @@ def prefs():
320323
# Format the prefs html, sending the list of locations, days of week, and times
321324
return render_template("prefs.html", locations=locations, daysoftheweek = daysoftheweek, time_to_index = time_to_index)
322325

326+
# Handles emailing the matched study groups
323327
def matchemail(people, locations, timeblock, day, uniqueCourse, matched):
324-
# We looked at this resource to count values: https://www.programiz.com/python-programming/methods/string/count'''
328+
# We looked at this resource to count values: https://www.programiz.com/python-programming/methods/string/count
325329
# Create a dictionary whose keys are the locations and whose initial values are zero
326330
places = {
327331
"Cabot Library": 0,
@@ -446,6 +450,7 @@ def matchemail(people, locations, timeblock, day, uniqueCourse, matched):
446450
mail.send(msg)
447451
return 'Sent'
448452

453+
# This is the match algorithm that matches people into study groups
449454
def match():
450455
# Runs timematch on every unique course in the prefs table
451456
uniqueCourses = db.execute("SELECT DISTINCT course FROM prefs;")
@@ -475,6 +480,7 @@ def match():
475480
matchemail(people, locations, None, None, uniqueCourse["course"], 0)
476481

477482
# Prrereq = the sorting has already been filtered by course
483+
# This handles finding the timeblocks where the most people can be matched into study groups
478484
def timematch(uniqueCourse, day):
479485
# stackedTimelines stores how many people are available at each time represented by each index of
480486
# stackedTimelines
@@ -555,22 +561,18 @@ def timematch(uniqueCourse, day):
555561
am_timeblock.sort()
556562
pm_timeblock.sort()
557563
timeblock = am_timeblock+pm_timeblock
558-
#contained = any(elem in people for elem in duplicates)
559564
for person in people:
560565
if person in duplicates:
561566
break
562567
if not person in duplicates:
563-
564-
#if not contained:
565568
grouper(uniqueCourse, timeblock, people, day)
566569
for r in people:
567570
duplicates.append(r)
568571
key += 1
569572
key += count
570-
# Handle left over people
571573

572574

573-
# prereq = the sorting has already been filtered by course and time
575+
# Prereq = the sorting has already been filtered by course and time
574576
# Grouping algorithm for people for a particular time interval by group size
575577
def grouper(uniqueCourse, timeblock, emails, day):
576578
timestring = ""
@@ -595,11 +597,6 @@ def grouper(uniqueCourse, timeblock, emails, day):
595597
medium = sizeCount(course_entries, "m")
596598
small = number_of_people - large - medium
597599
if small > (medium + large):
598-
#remainder = number_of_people % 3
599-
#if remainder == 0:
600-
# matchemail(emails[], locationstring, timeblock, day, uniqueCourse, True)
601-
#elif remainder == 1:
602-
#else:
603600
if number_of_people == 4:
604601
matchemail(emails[0:2], locationstring, timeblock, day, uniqueCourse, True)
605602
matchemail(emails[2:4], locationstring, timeblock, day, uniqueCourse, True)
0 Bytes
Binary file not shown.
64 Bytes
Binary file not shown.
64 Bytes
Binary file not shown.
64 Bytes
Binary file not shown.
64 Bytes
Binary file not shown.
64 Bytes
Binary file not shown.

readme.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
documentation and youtube link
1+
2+
YouTube link to video: https://youtu.be/OM6oV4jEoAI

templates/layout.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
{% if session["user_id"] %}
1515
<!-- tabs that will display if user is logged in -->
1616
<ul>
17-
<li><a href="/main">Home</a></li>
17+
<li><a href="/">Home</a></li>
1818
<li><a href="/logout">Logout</a></li>
1919
<li><a href="/prefs">Preferences</a></li>
2020
<li><a href="/courses">Course Resources</a></li>
2121
</ul>
2222
{% else %}
2323
<!-- tabs that will display if user is not logged in -->
2424
<ul>
25-
<li><a href="/main">Home</a></li>
25+
<li><a href="/">Home</a></li>
2626
<li><a href="/register">Register</a></li>
2727
<li><a href="/login">Login</a></li>
2828
</ul>

users.db

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)