Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routes #25

Open
wants to merge 126 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
e946c25
Updated travis-ci badge
BillSpyro Apr 6, 2020
949834d
Updated travis-ci badge
BillSpyro Apr 6, 2020
a3743e2
Completed User Story #1: As a user, I want to log in to the app to se…
BillSpyro Apr 7, 2020
7dc0d5b
Merge pull request #1 from BillSpyro/user_login
BillSpyro Apr 7, 2020
8dd4e0f
Completed User Story #2: As a user, I want my password to be hashed s…
BillSpyro Apr 7, 2020
379803f
Cleaned a test
BillSpyro Apr 7, 2020
f2d5a4e
Merge pull request #2 from BillSpyro/password_hash
BillSpyro Apr 7, 2020
20dc358
Fixed issues in the first two pull requests
BillSpyro Apr 8, 2020
70decbf
Updated tests to utilize post requests
BillSpyro Apr 8, 2020
14cfacf
Merge pull request #3 from BillSpyro/bugfix
BillSpyro Apr 8, 2020
65a3bed
Finished user story #3 imported the csv and hashed all the passwords
PKCRY Apr 8, 2020
6c3e914
Merge pull request #4 from BillSpyro/csv_file
BillSpyro Apr 8, 2020
c6a9b1f
Completed User Story #2: As a teacher, I want to create and edit cour…
BillSpyro Apr 8, 2020
a29bb87
Merge pull request #5 from BillSpyro/create_course
BillSpyro Apr 8, 2020
57e6611
fixed the db.py file to have less spaces in the code and to not add a…
PKCRY Apr 9, 2020
68a3fff
added comments to make sure anyone reviewing the code knows what the …
PKCRY Apr 9, 2020
de728be
Merge pull request #6 from BillSpyro/bugfix
BillSpyro Apr 9, 2020
84da7e0
create session and roster table
EthanKubistek Apr 9, 2020
7e506b8
Created foundation for creating sessions and rosters
BillSpyro Apr 9, 2020
a8168f1
Created a create session page which allows teachers to create session…
BillSpyro Apr 9, 2020
41e3ac5
added the test data for the courses in the data.sql file
PKCRY Apr 9, 2020
667e527
Added a button to view the sessions of a course and a button to view …
BillSpyro Apr 9, 2020
d376d4b
Merge branch 'course_data' into roster_session
BillSpyro Apr 9, 2020
3d4f0b2
Fixed an issue with updating courses
BillSpyro Apr 9, 2020
3bb2a68
Updated test to select checkboxes
BillSpyro Apr 9, 2020
7f598aa
Restructured tests to have a test file for each module
BillSpyro Apr 10, 2020
3feff76
Fixed a bug in sessions
BillSpyro Apr 10, 2020
97cac0a
Merge pull request #7 from BillSpyro/roster_session
BillSpyro Apr 10, 2020
9a7e08a
You can no longer create duplicate courses
BillSpyro Apr 14, 2020
d029ec7
You can no longer create a duplicate session name in the same course
BillSpyro Apr 14, 2020
40655dc
You can now see the course description when viewing courses and sessions
BillSpyro Apr 14, 2020
eac62f6
You can now see the course description when viewing courses and sessions
BillSpyro Apr 14, 2020
fb84842
Merge branch 'roster_session' of https://github.com/BillSpyro/tsct-po…
BillSpyro Apr 14, 2020
7d80839
Merge pull request #8 from BillSpyro/create_course
BillSpyro Apr 15, 2020
5440fcc
Merge pull request #9 from BillSpyro/roster_session
BillSpyro Apr 15, 2020
7497c23
added the basic tables for assignments and a join table for assignmen…
PKCRY Apr 15, 2020
553eb16
added answer into the assingments table and made a foundation for stu…
PKCRY Apr 15, 2020
de1ff79
teachers have the ability to create assignments for each session
PKCRY Apr 15, 2020
f4d8fd8
Updated assignment html pages
BillSpyro Apr 15, 2020
0e4b9b3
Updated tests
BillSpyro Apr 15, 2020
c1694fa
updated tests for the assignments and sessions and updated the data.s…
PKCRY Apr 15, 2020
a2a5d30
added css to all pages and fixed the html of the nav bar
EthanKubistek Apr 15, 2020
177cd07
Merge remote-tracking branch 'origin/css' into assignments
BillSpyro Apr 15, 2020
a4d09e5
Merge pull request #11 from BillSpyro/css
BillSpyro Apr 15, 2020
3b05766
Merge pull request #10 from BillSpyro/assignments
BillSpyro Apr 15, 2020
d1a1708
Changed an input tag in create-assignments.html to be a textarea tag
BillSpyro Apr 16, 2020
7f91ed7
Merge pull request #12 from BillSpyro/assignments
BillSpyro Apr 16, 2020
2da3c39
Updated html for pages to allow students to view appriote courses and…
BillSpyro Apr 16, 2020
2773e06
fixed the routing so create-assignments go back to the view-assignments
PKCRY Apr 16, 2020
7e13dd0
added some more css to the pages to make it look cleaner with the na…
EthanKubistek Apr 16, 2020
ba13e6a
Updated tests
BillSpyro Apr 16, 2020
6fa959a
Merge pull request #13 from BillSpyro/student_sessions
BillSpyro Apr 16, 2020
61fd325
Merge branch 'master' into css
BillSpyro Apr 16, 2020
8c75e4c
Merge branch 'master' into css
BillSpyro Apr 16, 2020
c7ee2a8
Merge branch 'css' of https://github.com/BillSpyro/tsct-portal into css
BillSpyro Apr 16, 2020
20bc758
Merge pull request #14 from BillSpyro/css
WilnelysR Apr 16, 2020
aac0622
Students can now submit answers to assignments
BillSpyro Apr 17, 2020
5103379
Teachers can now view an assignment and see all student submissions
BillSpyro Apr 17, 2020
104d65a
Added tests for submissions
BillSpyro Apr 17, 2020
f6f455c
made the routing for assignments
PKCRY Apr 20, 2020
1bc9605
Merge pull request #15 from BillSpyro/submissions
BillSpyro Apr 20, 2020
67e101b
minor changes to routing
PKCRY Apr 21, 2020
7fb076c
Added a generic error html page for displaying an error and a method …
BillSpyro Apr 21, 2020
20730bf
Updated tests to check error pages when a problem occurs
BillSpyro Apr 21, 2020
740a43e
addeda after updating a course to go back to the view courses page
PKCRY Apr 21, 2020
d540441
finished routing changes for courses, sessions, and assignments
PKCRY Apr 21, 2020
81a23cb
started working a search for the session to making finding a name eas…
EthanKubistek Apr 21, 2020
6b06dab
Merge pull request #16 from BillSpyro/error_handling
BillSpyro Apr 21, 2020
5eb983f
Revert "addeda after updating a course to go back to the view courses…
PKCRY Apr 22, 2020
b49afa2
Merge branch 'master' into routes
PKCRY Apr 22, 2020
7c92248
Added a new table for grades
BillSpyro Apr 22, 2020
162429d
Merge branch 'routes' of github.com:BillSpyro/tsct-portal into routes
PKCRY Apr 22, 2020
7ca9626
As a teacher you can now grade each submission in an assignment
BillSpyro Apr 22, 2020
4430b63
Added a new test file for grading submissions
BillSpyro Apr 22, 2020
1979ee8
worked on the searching of students and it only works with one search…
EthanKubistek Apr 23, 2020
3902396
Updated error routes to allow subpaths to be checked and redirected i…
BillSpyro Apr 23, 2020
7cfae3d
Merge branch 'master' into error_handling
BillSpyro Apr 23, 2020
aa6a74b
Merge pull request #17 from BillSpyro/teacher_grading
BillSpyro Apr 23, 2020
f817e46
Merge branch 'master' into error_handling
BillSpyro Apr 23, 2020
9034e29
making the merging easier to make sure everything works together
PKCRY Apr 23, 2020
0014fed
Merge branch 'master' into routes
PKCRY Apr 23, 2020
0ff9900
Merge branch 'master' into routes
PKCRY Apr 23, 2020
8bcaca4
Merge pull request #19 from BillSpyro/routes
PKCRY Apr 23, 2020
ee5ce9b
made the changes to the url for to return back to the view assignment…
PKCRY Apr 23, 2020
bcf1e24
Merge branch 'routes' of github.com:BillSpyro/tsct-portal into routes
PKCRY Apr 23, 2020
22fadc8
Merge branch 'master' into error_handling
BillSpyro Apr 23, 2020
001c26e
Merge pull request #18 from BillSpyro/error_handling
BillSpyro Apr 23, 2020
005ff65
added it so we can look up students by number and name so teachers ca…
EthanKubistek Apr 24, 2020
e51c205
Added view-gradebook.html page
BillSpyro Apr 24, 2020
7d72044
fixed html for grade assignments and worked on organizing the forms w…
EthanKubistek Apr 24, 2020
d5e92f6
Merge branch 'master' into css
BillSpyro Apr 24, 2020
7506092
Merge pull request #20 from BillSpyro/css
BillSpyro Apr 24, 2020
e797b8c
added the names and the emails to the student ids in the sessions
PKCRY Apr 24, 2020
a2afbca
made sure the session has the students name and changed the html to l…
PKCRY Apr 27, 2020
f330cb1
Updated gradebook HTML page to show the courses, and all student grad…
BillSpyro Apr 27, 2020
2f6770d
Merge branch 'master' into gradebook
BillSpyro Apr 27, 2020
d02be34
Begun work on tests for gradebook
BillSpyro Apr 27, 2020
17a301a
Merge branch 'gradebook' of https://github.com/BillSpyro/tsct-portal …
BillSpyro Apr 27, 2020
7346436
Changed gradebook route to avoid repeats in url
BillSpyro Apr 27, 2020
7c69ce0
added some comments to make moving around a little easier
PKCRY Apr 28, 2020
f18fa4a
Updated forms to only accept appropriate values
BillSpyro Apr 28, 2020
7fd6ca8
Merge branch 'gradebook' into bugfix
BillSpyro Apr 28, 2020
5aec251
Fixed merge conflict
BillSpyro Apr 28, 2020
5ca8d87
Merge pull request #21 from BillSpyro/gradebook
BillSpyro Apr 28, 2020
82e8bb4
Merge branch 'master' into bugfix
BillSpyro Apr 28, 2020
dc010f2
added all the names of the students rather than the ids for the teach…
PKCRY Apr 28, 2020
4a67585
Merge pull request #22 from BillSpyro/bugfix
BillSpyro Apr 28, 2020
980d950
got flash message working on the login page and added some css to mak…
EthanKubistek Apr 28, 2020
b9e3f26
finished the routing for all the pages
PKCRY Apr 28, 2020
848ae6c
Merge branch 'master' into student_search
BillSpyro Apr 28, 2020
0d871c8
Merge branch 'master' into flash
BillSpyro Apr 28, 2020
60ae2e5
Finished up adding students seperately
BillSpyro Apr 28, 2020
b8ae307
fixed the tests and added the proper return statement for the students
PKCRY Apr 29, 2020
a4c6257
Updated tests for the new way of adding students to a session
BillSpyro Apr 29, 2020
d693409
Merge branch 'master' into improvements
PKCRY Apr 29, 2020
427d758
Merge pull request #23 from BillSpyro/flash
PKCRY Apr 29, 2020
c298710
Merge branch 'master' into student_search
BillSpyro Apr 29, 2020
b9f231c
Merge branch 'master' into improvements
BillSpyro Apr 29, 2020
ab50cee
Merge pull request #25 from BillSpyro/student_search
BillSpyro Apr 29, 2020
c3db153
Merge branch 'master' into improvements
BillSpyro Apr 29, 2020
da64474
Merge pull request #24 from BillSpyro/improvements
BillSpyro Apr 29, 2020
22e1643
Merge branch 'master' into Routes
PKCRY Apr 29, 2020
ddb0ea7
Merge branch 'master' into routes
PKCRY Apr 29, 2020
04fa44a
Updated gradebook url and tests
BillSpyro Apr 30, 2020
f2a4c50
Merge pull request #28 from BillSpyro/error_handling
BillSpyro Apr 30, 2020
6fb158b
Merge branch 'master' into routes
EthanKubistek Apr 30, 2020
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
Prev Previous commit
Next Next commit
Updated forms to only accept appropriate values
  • Loading branch information
BillSpyro committed Apr 28, 2020
commit f18fa4a60451d4ab824a3d3944b1af076749e2a3
8 changes: 4 additions & 4 deletions portal/assignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ def create_assignment(session_id):

cur.execute("""SELECT session.courses_id FROM courses
JOIN session ON session.courses_id = courses_id
Where session.id = %s;""",
Where session.id = %s;""",
(session_id,))
courses = cur.fetchone()
course_id = courses[0]
print('course id HI IM RIGHT HERE GOD DAMN IT', course_id)


cur.execute("""
SELECT id FROM assignments
WHERE name = %s and session_id = %s;
Expand All @@ -141,7 +141,7 @@ def create_assignment(session_id):
assignment_id = assignments[0]

cur.close()

return redirect(url_for('assignments.view_assignment', course_id=course_id, session_id=session_id, assignment_id=assignment_id))
else:
return redirect(url_for('assignments.create_assignment', session_id=session_id))
Expand Down
12 changes: 6 additions & 6 deletions portal/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ def create_course():
""",
(course_number, g.users['major'], name, description, credits, g.users['id']))
db.get_db().commit()



#routing

#routing
cur.execute("""
SELECT id FROM courses WHERE name = %s AND course_number = %s;
""",
(name, course_number))
courses_tuple = cur.fetchone()
course_id = courses_tuple[0]





Expand Down Expand Up @@ -152,10 +152,10 @@ def update_course(course_id):
""",
(course_number, g.users['major'], name, description, credits, g.users['id'], course_id))
db.get_db().commit()


#START OF NEW CODE


#START OF NEW CODE

cur.execute("""
SELECT id FROM courses WHERE name = %s AND course_number = %s;
""",
Expand Down
93 changes: 93 additions & 0 deletions portal/gradebook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
from flask import (
Blueprint, flash, g, redirect, render_template, request, session, url_for
)
from portal.auth import (login_required, teacher_required)
from . import db

bp = Blueprint('gradebook', __name__, url_prefix='/gradebook')

@bp.route('/')
@login_required
def gradebook():
if g.users['role'] == 'teacher':
cur = db.get_db().cursor()
cur.execute("""SELECT * FROM courses""")
courses = cur.fetchall()
cur.execute("""SELECT courses.id AS c_id, session.* FROM session
JOIN courses ON courses.id = session.courses_id""")
sessions = cur.fetchall()
cur.execute("""SELECT session.id AS s_id, users.id AS u_id, SUM(submissions.points) AS s_points, SUM(assignments.points) AS a_points, '' as grade FROM users
JOIN roster ON roster.users_id = users.id
JOIN session ON roster.session_id = session.id
JOIN assignments ON assignments.session_id=session.id
JOIN submissions ON submissions.assignments_id = assignments.id and users.id = submissions.users_id
GROUP BY session.id, users.id
ORDER BY session.id""")
grades = cur.fetchall()
else:
cur = db.get_db().cursor()
cur.execute("""
SELECT DISTINCT ON (courses.id) roster.*, users.*, session.*, courses.* FROM roster
JOIN users ON users.id = roster.users_id
JOIN session ON session.id = roster.session_id
JOIN courses ON courses.id = session.courses_id
WHERE users.id = %s;""",
(g.users['id'],))
courses = cur.fetchall()
cur.execute("""
SELECT DISTINCT ON (session.id) session.*, roster.id AS r_id, users.id AS u_id, courses.id AS c_id FROM roster
JOIN users ON users.id = roster.users_id
JOIN session ON session.id = roster.session_id
JOIN courses ON courses.id = session.courses_id
WHERE users.id = %s;""",
(g.users['id'],))
sessions = cur.fetchall()
cur.execute("""SELECT session.id AS s_id, users.id AS u_id, SUM(submissions.points) AS s_points, SUM(assignments.points) AS a_points, '' as grade FROM users
JOIN roster ON roster.users_id = users.id
JOIN session ON roster.session_id = session.id
JOIN assignments ON assignments.session_id=session.id
JOIN submissions ON submissions.assignments_id = assignments.id and users.id = submissions.users_id
WHERE users.id = %s
GROUP BY session.id, users.id
ORDER BY session.id""",
(g.users['id'],))
grades = cur.fetchall()

for grade in grades:
grade[4] = grade[2]/grade[3]

if grade[4] >= 0.98:
grade[4] = 'A+'
elif grade[4] >= 0.93:
grade[4] = 'A'
elif grade[4] >= 0.90:
grade[4] = 'A-'
elif grade[4] >= 0.87:
grade[4] = 'B+'
elif grade[4] >= 0.83:
grade[4] = 'B'
elif grade[4] >= 0.80:
grade[4] = 'B-'
elif grade[4] >= 0.77:
grade[4] = 'C+'
elif grade[4] >= 0.73:
grade[4] = 'C'
elif grade[4] >= 0.70:
grade[4] = 'C-'
elif grade[4] >= 0.67:
grade[4] = 'D+'
elif grade[4] >= 0.63:
grade[4]= 'D'
elif grade[4] >= 0.60:
grade[4] = 'D-'
else:
grade[4] = 'F'

cur.close()
return render_template('portal/gradebook/view-gradebook.html', courses=courses, sessions=sessions, grades=grades)

@bp.route('/<path:subpath>/')
@login_required
def gradebook_error(subpath=None):
error = "404 Not found"
return render_template('error.html', error=error)
4 changes: 2 additions & 2 deletions portal/templates/portal/courses/create-course.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<h2>Create a Course</h2>
<form method="post">
<label for="course_number">Course Number
<input name="course_number" required/>
<input name="course_number" type="number" required/>
</label>
<label for="name">Name
<input name="name" required/>
Expand All @@ -15,7 +15,7 @@ <h2>Create a Course</h2>
<textarea name="description"></textarea>
</label>
<label for="credits">Credits
<input name="credits" required/>
<input name="credits" type="number" required/>
</label>
<input type="submit" value="Create Course" />
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ <h2>Create an Assignment</h2>
<input name="name" required/>
</label>
<label for="date">Due Date
<input name="date" />
<input name="date" type="date" required/>
</label>
<label for="description">Description
<textarea name="description"></textarea>
<textarea name="description" required></textarea>
</label>
<label for="points">Points
<input name="points"/>
<input name="points" type="number"required/>
</label>
<input type="submit" value="Create Assignment" />
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h2>Grade Assignment</h2>
<li>
<p>Student: {{ submission['users_id'] }} Answer: {{ submission['answer'] }}</p>
<label for="points">Points
<input name="points" required />
<input name="points" type="number" required/>
</label>
<p>/{{ assignment['points'] }}</p>
</li>
Expand Down
4 changes: 2 additions & 2 deletions portal/templates/portal/courses/update-course.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<h2>Update a Course</h2>
<form method="post">
<label for="course_number">Course Number
<input name="course_number" required/>
<input name="course_number" type="number" required/>
</label>
<label for="name">Name
<input name="name" required/>
Expand All @@ -15,7 +15,7 @@ <h2>Update a Course</h2>
<textarea name="description"></textarea>
</label>
<label for="credits">Credits
<input name="credits" required/>
<input name="credits" type="number" required/>
</label>
<input type="submit" value="Update Course" />
</form>
Expand Down
34 changes: 34 additions & 0 deletions portal/templates/portal/gradebook/view-gradebook.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% extends "layouts/base.html" %}

{% block title %}TSCT Portal{% endblock %}

{% block content %}
{% for course in courses %}
<h2>Course</h2>
<ul>
<li>
<p>{{course['major'] }} {{ course['course_number'] }}-{{ course['name'] }}</p>
</li>
</ul>
{% for session in sessions %}
{% if session['courses_id'] == course['id'] %}
<h3>Session</h3>
<ul>
<li>
<p>Name: {{ session['name'] }}, Times: {{ session['times'] }}</p>
</li>
</ul>
<h4>Student Grades</h4>
{% for grade in grades %}
{% if grade['s_id'] == session['id'] %}
<ul>
<li>
<p>{{ grade['u_id'] }} {{ grade['grade'] }}</p>
</li>
</ul>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
{% endblock %}
18 changes: 18 additions & 0 deletions tests/test_gradebook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from portal import create_app

def test_gradebook(client):
response = client.post(
'/auth/login', data={'email': '[email protected]', 'password':'qwerty'}
)
response = client.get('/gradebook/')
assert b'CSET 101-Web Design' in response.data
assert b'43784 F' in response.data

def test_gradebook_student(client):
response = client.post(
'/auth/login', data={'email': '[email protected]', 'password':'asdfgh'}
)
response = client.get('/gradebook/')
assert b'CSET 101-Web Design' in response.data
assert b'43784 F' in response.data
assert b'GENEDS 301-Public Speaking' not in response.data