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

Development #26

Open
wants to merge 140 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
2106977
testing out commits to Codecrafters
JervalThomas Sep 23, 2023
18e99a6
testing
Sep 28, 2023
50303f7
Staff and Student Classes
JervalThomas Sep 28, 2023
616cfa3
test commit
ashleyjacob Sep 28, 2023
32a60e4
Staff and Student Classes redone
JervalThomas Sep 28, 2023
49ecbf2
Program 90% completed
Sep 29, 2023
d62bcfb
Created Admin & Course Plan models
ashleyjacob Sep 29, 2023
c3570d1
Created Admin & Course Plan Controllers
ashleyjacob Sep 29, 2023
7e180d4
added course with some features not all
Sep 29, 2023
b676c14
Merge branch 'uwidcit:main' into Kyle
Kyle-McIntosh Sep 29, 2023
bc01e4a
updated the program code
Sep 30, 2023
175b169
Did some more updates
Sep 30, 2023
d331181
Staff and Student Classes redone
JervalThomas Oct 1, 2023
dcff403
Staff and Student Classes redone
JervalThomas Oct 1, 2023
4bbeb2b
Staff and Student Controllers
JervalThomas Oct 1, 2023
7da7270
Staff and Student Controllers
JervalThomas Oct 1, 2023
e502c7b
Staff and Student Controllers
JervalThomas Oct 1, 2023
e08a8e2
Staff and Student Controllers
JervalThomas Oct 1, 2023
bc83913
Updates Course Plan controllers
ashleyjacob Oct 1, 2023
3c654fe
Staff and Student Controllers
JervalThomas Oct 2, 2023
0a8224b
Staff and Student Controllers
JervalThomas Oct 2, 2023
6300223
mergeed ashley's branch to test our controllers
Oct 2, 2023
87c2928
Updates to course plan
ashleyjacob Oct 2, 2023
7d025e2
Updated Course Plan model
ashleyjacob Oct 2, 2023
111820f
Updated controllers
ashleyjacob Oct 2, 2023
887be0a
Staff and Student Controllers
JervalThomas Oct 2, 2023
e1f2600
Staff and Student Controllers
JervalThomas Oct 2, 2023
d743e71
Staff and Student Controllers
JervalThomas Oct 2, 2023
bb63319
Staff and Student Controllers
JervalThomas Oct 2, 2023
ce66916
Merge pull request #1 from CodeCraftersUWI/Jerval
jerrelle9 Oct 2, 2023
2069ce7
Merge branch 'development' of github.com:CodeCraftersUWI/flaskmvc int…
Oct 2, 2023
21968e1
Merge branch 'development' into Kyle
JervalThomas Oct 2, 2023
39bffce
changing controllers methods for stuuden to suit app concept
JervalThomas Oct 3, 2023
7e90192
Updated course plan
ashleyjacob Oct 3, 2023
5193ffc
Merge branch 'Jerval' of https://github.com/CodeCraftersUWI/flaskmvc …
ashleyjacob Oct 3, 2023
f508844
Updated admin and cli commands
ashleyjacob Oct 3, 2023
2c8b02c
updated init files
ashleyjacob Oct 3, 2023
81138f3
Merge branch 'Kyle' of https://github.com/CodeCraftersUWI/flaskmvc in…
ashleyjacob Oct 3, 2023
11bf532
Updated course plan controller-addCourse()
ashleyjacob Oct 3, 2023
06ed450
scaled the course code to read larger files
Oct 4, 2023
0a7c0d4
changed offeredCourses and added staff view
Oct 4, 2023
4412442
Updated admin - remove all courses
ashleyjacob Oct 4, 2023
cae3802
Merged jerellebranch into Ashley
ashleyjacob Oct 4, 2023
999e985
adjusted code to be compatable with other classes
ashleyjacob Oct 4, 2023
004494a
updated relationship between student & course plan
ashleyjacob Oct 4, 2023
a1cbd57
updated student controller to work w/ courseplan
ashleyjacob Oct 4, 2023
3c6e8ed
updated course plan - merge lvl 1&2 cores
ashleyjacob Oct 4, 2023
56a3017
Updated requirements, wsgi, coursePlan controller and model, student …
Kyle-McIntosh Oct 4, 2023
3730291
added kyle's changes to code
Oct 4, 2023
fb66afb
Merge pull request #2 from CodeCraftersUWI/jerrellebranch
jerrelle9 Oct 4, 2023
23ea812
merge conflicts
JervalThomas Oct 4, 2023
a3a8fb5
merge conflicts
JervalThomas Oct 4, 2023
11ab32c
merge conflicts
JervalThomas Oct 4, 2023
7eb3da9
merge conflicts
JervalThomas Oct 4, 2023
77ca95f
Merge development into Ashley's branch
ashleyjacob Oct 4, 2023
8de83a3
merged updated files
ashleyjacob Oct 4, 2023
17e9697
Merge branch 'development' of https://github.com/CodeCraftersUWI/flas…
Kyle-McIntosh Oct 5, 2023
cfbf387
Created prerequisite model
Kyle-McIntosh Oct 5, 2023
b8e3d21
added bridge tables prerequisites and programCourses
Oct 5, 2023
94d8094
Merge pull request #3 from CodeCraftersUWI/jerrellebranch
JervalThomas Oct 5, 2023
e9e29f9
added alot of bridge tables
Oct 5, 2023
3116ce6
Merge branch 'development' into Jerval
JervalThomas Oct 5, 2023
39d2101
updateing changes from develpment branch
JervalThomas Oct 5, 2023
7e26955
Merge branch 'development' of https://github.com/CodeCraftersUWI/flas…
Kyle-McIntosh Oct 6, 2023
47be079
Merge branch 'Kyle' of https://github.com/CodeCraftersUWI/flaskmvc in…
Kyle-McIntosh Oct 6, 2023
b6fe38d
more udpates
Oct 6, 2023
6b95859
Merge pull request #4 from CodeCraftersUWI/jerrellebranch
JervalThomas Oct 6, 2023
e37f292
Merge branch 'development' of into Ashley
ashleyjacob Oct 6, 2023
ab026cb
created staff views
ashleyjacob Oct 6, 2023
2df598b
updated staff view
ashleyjacob Oct 6, 2023
c4eacc8
Merge branch 'development' of https://github.com/CodeCraftersUWI/flas…
Kyle-McIntosh Oct 6, 2023
e1ffeec
Development merge
Kyle-McIntosh Oct 6, 2023
9d9fca8
Code not breaking at this point, just to test courseplan controller
Oct 6, 2023
bd6d813
Student views created
Kyle-McIntosh Oct 6, 2023
a565898
Merge branch 'jerrellebranch' into Ashley
ashleyjacob Oct 7, 2023
7b552af
created staff views
ashleyjacob Oct 7, 2023
c028a70
addCourseToPlan method works now, but there is a bug in generate
Oct 7, 2023
487f2b4
Merge branch 'jerrellebranch' into Ashley
ashleyjacob Oct 7, 2023
7ed1085
all controllers done
Oct 7, 2023
d5a0100
Merge pull request #5 from CodeCraftersUWI/jerrellebranch
jerrelle9 Oct 7, 2023
2a8f64d
all staff views are functional
ashleyjacob Oct 7, 2023
a69a01f
Merge branch 'development' into Ashley
ashleyjacob Oct 7, 2023
1a324dc
updated staff urls
ashleyjacob Oct 7, 2023
661a6a6
Merge branch 'development' of https://github.com/CodeCraftersUWI/flas…
Kyle-McIntosh Oct 8, 2023
70da3d6
updated status codes and error responses
ashleyjacob Oct 8, 2023
a21975b
Updated student views
Kyle-McIntosh Oct 8, 2023
4271299
Merge pull request #6 from CodeCraftersUWI/Kyle
jerrelle9 Oct 8, 2023
c4ba4ed
updates to programcourses and coursesoffered model
Oct 8, 2023
08408a3
corrected file paths in wsgi
Oct 8, 2023
6366744
Student view status codes added
Kyle-McIntosh Oct 8, 2023
fd7e3c6
Merge branch 'development' into Ashley
jerrelle9 Oct 9, 2023
2ed993d
Merge pull request #7 from CodeCraftersUWI/Ashley
jerrelle9 Oct 9, 2023
47518eb
Merge branch 'development' of https://github.com/CodeCraftersUWI/flas…
Kyle-McIntosh Oct 9, 2023
5922046
Merge pull request #8 from CodeCraftersUWI/Kyle
jerrelle9 Oct 9, 2023
19ad4f3
Merge pull request #9 from CodeCraftersUWI/jerrellebranch
jerrelle9 Oct 9, 2023
e8ff463
last sttretch
Oct 9, 2023
cf45a73
Merge branch 'main' into development
jerrelle9 Oct 9, 2023
c1f8028
Merge pull request #10 from CodeCraftersUWI/development
jerrelle9 Oct 9, 2023
703c142
merge conflicts
JervalThomas Oct 9, 2023
ff833f2
removed adminfile and course file from views
Oct 9, 2023
f6d7d81
Student views auth
Kyle-McIntosh Oct 9, 2023
aedbb25
added create staff to index init
Oct 9, 2023
cb978d2
updates
Oct 9, 2023
ebe17fd
Student auth changes
Kyle-McIntosh Oct 9, 2023
9c44a7b
updates
Oct 9, 2023
a973a7f
Merge pull request #11 from CodeCraftersUWI/Kyle
jerrelle9 Oct 9, 2023
f7ce90b
Merge pull request #12 from CodeCraftersUWI/development
jerrelle9 Oct 9, 2023
84c73ff
added create courses to idex views
Oct 10, 2023
150ba6d
Merge pull request #13 from CodeCraftersUWI/development
jerrelle9 Oct 10, 2023
cc1cce1
Merge branch 'main' into Jerval
JervalThomas Oct 16, 2023
cfd609c
merge conflicts
JervalThomas Oct 16, 2023
24c80e2
merge conflicts
JervalThomas Oct 16, 2023
61e3d8c
lastest pull from main
Oct 16, 2023
f48b1bd
Student unit test
JervalThomas Oct 16, 2023
187b3c9
did program and course tests
Oct 17, 2023
2a075bc
unit tests for program courses and prerequisites
ashleyjacob Oct 17, 2023
c2ed419
Student unit and integration test
JervalThomas Oct 17, 2023
f74cd68
staff unit tests
Oct 17, 2023
f69d901
int. tests for prereqs & program requirements
ashleyjacob Oct 18, 2023
7e5474f
Student unit and integration test
JervalThomas Oct 18, 2023
ce068e7
Student course history unit and integration test
JervalThomas Oct 18, 2023
61b3d4d
finished staff program and course tests
Oct 19, 2023
eb8bad0
Merge pull request #14 from CodeCraftersUWI/jerrellebranch
jerrelle9 Oct 19, 2023
9ec6d46
separated programCourse tests from test_app
ashleyjacob Oct 19, 2023
d291b8a
Merged jerrellebranch
ashleyjacob Oct 19, 2023
eafcd59
all programCourse and prereq tests working
ashleyjacob Oct 19, 2023
098aa74
Merge branch 'development' into Jerval
JervalThomas Oct 19, 2023
7bed6e7
adjusted views so postman tests match api spec
ashleyjacob Oct 19, 2023
369cb61
Merge branch 'development' of https://github.com/CodeCraftersUWI/flas…
ashleyjacob Oct 19, 2023
7c9ced1
Student and student course history unit and integration test finished
JervalThomas Oct 19, 2023
a51d5ac
Student and student course history unit and integration test finished
JervalThomas Oct 19, 2023
f6d9e09
Merge pull request #15 from CodeCraftersUWI/Jerval
jerrelle9 Oct 19, 2023
d2d8bf1
updates
Oct 19, 2023
e054a20
updates
Oct 19, 2023
3ecc40f
merged dev changes with Ashley's branch
ashleyjacob Oct 19, 2023
8f3f62c
merged tests -
ashleyjacob Oct 20, 2023
4a16730
updated login view
ashleyjacob Oct 20, 2023
c31253a
Merge pull request #16 from CodeCraftersUWI/Ashley
jerrelle9 Oct 22, 2023
010a931
Courses and CoursesOffered unit and int test
Kyle-McIntosh Oct 24, 2023
a370922
Merge pull request #17 from CodeCraftersUWI/Kyle
Kyle-McIntosh Oct 25, 2023
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
Binary file added .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.testing.unittestArgs": ["-v", "-s", "./App", "-p", "test_*.py"],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}
Binary file added App/.DS_Store
Binary file not shown.
12 changes: 11 additions & 1 deletion App/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
from .user import *
from .auth import *
from .auth import *
from .courses import *
from .program import *
from .staff import *
from .student import *
from .prerequistes import *
from .programCourses import *
from .studentCourseHistory import *
from .coursePlanCourses import *
from .coursesOfferedPerSem import *
from .coursePlan import *
278 changes: 278 additions & 0 deletions App/controllers/coursePlan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
from App.models import CoursePlan
from App.database import db
from App.controllers import (
get_program_by_id,
get_course_by_courseCode,
get_credits,
getPrereqCodes,
getCompletedCourses,
createPlanCourse,
deleteCourseFromCoursePlan,
get_allCore,
get_allFoun,
get_allElectives,
getCompletedCourseCodes,
convertToList,
get_all_OfferedCodes,
isCourseOffered,
programCourses_SortedbyRating,
programCourses_SortedbyHighestCredits,
get_all_courses_by_planid,

)



def create_CoursePlan(id):
plan = CoursePlan(id)
db.session.add(plan)
db.session.commit()
return plan

def getCoursePlan(studentid):
return CoursePlan.query.filter_by(studentId=studentid).first()

def possessPrereqs(Student, course):
preqs = getPrereqCodes(course.courseName)
completed = getCompletedCourseCodes(Student.id)
for course in preqs:
if course not in completed:
return False

return True

def addCourseToPlan(Student, courseCode):
course = get_course_by_courseCode(courseCode)
if course:
offered = isCourseOffered(courseCode)
if offered:
haveAllpreqs = possessPrereqs(Student, course)
if haveAllpreqs:
plan = getCoursePlan(Student.id)
if plan:
createPlanCourse(plan.planId, courseCode)
print("Course successfully added to course plan")
return plan
else:
plan = create_CoursePlan(Student.id)
createPlanCourse(plan.planId, courseCode)
print("Plan successfully created and Course was successfully added to course plan")
return plan
else:
print("Course is not offered")
else:
print("Course does not exist")


def removeCourse(Student, courseCode):
plan=getCoursePlan(Student.id)
if plan:
deleteCourseFromCoursePlan(plan.planId, courseCode)

def getRemainingCourses(completed, required):
# Check if either 'completed' or 'required' is None
if completed is None or required is None:
return [] # Return an empty list or handle it in a way that makes sense for your application

completedCodes = []
for c in completed:
completedCodes.append(c.code)

remainingCodes = []
for r in required:
remainingCodes.append(r.code)


notCompleted = remainingCodes.copy()
for a in completedCodes:
if a in notCompleted:
notCompleted.remove(a)

return notCompleted


def getRemainingCore(Student):
programme=get_program_by_id(Student.program_id)
remaining = []

if programme:
reqCore=get_allCore(programme.name)
completed = getCompletedCourses(Student.id)
remaining=getRemainingCourses(completed,reqCore)

return remaining


def getRemainingFoun(Student):
programme = get_program_by_id(Student.program_id)
remaining =[]

if programme:
reqFoun = get_allFoun(programme.name)
completed = getCompletedCourses(Student.id)
remaining=getRemainingCourses(completed,reqFoun)

return remaining


def getRemainingElec(Student):
programme = get_program_by_id(Student.program_id) # Get the student's program
remaining = []

if programme:
reqElec = get_allElectives(programme.name) # Use the instance method to get elective courses
completed = getCompletedCourses(Student.id)
remaining = getRemainingCourses(completed, reqElec)

return remaining


def remElecCredits(Student):
programme = get_program_by_id(Student.program_id) # Get the student's program
completedcourses = getCompletedCourseCodes(Student.id)
requiredCreds = 0

if programme:
requiredCreds = programme.elective_credits # Access the elective_credits attribute
elective_courses = get_allElectives(programme.name) # Use the instance method to get elective courses
electCodes = convertToList(elective_courses)
if electCodes:
for code in electCodes:
if code in completedcourses:
c = get_course_by_courseCode(code) # Get course
if c:
requiredCreds = requiredCreds - c.credits # Subtract credits
return requiredCreds


def findAvailable(courseList):
listing=get_all_OfferedCodes()
available=[]

for code in courseList:
if code in listing:
available.append(code)

return available #returns an array of course codes


def checkPrereq(Student, recommnded):
validCourses=[]
for course in recommnded:
c = get_course_by_courseCode(course)
satisfied = possessPrereqs(Student, c)
if satisfied:
validCourses.append(c.courseCode)

return validCourses

def getTopfive(list):
return list[:5]

def prioritizeElectives(Student):
#get available electives
electives=findAvailable(getRemainingElec(Student))
credits=remElecCredits(Student)
courses=[]

#select courses to satisfy the programme's credit requirements
for c in electives:
if credits>0:
courses.append(c)
credits = credits - get_credits(c)

#merge available, required core and foundation courses
courses = courses + findAvailable(getRemainingCore(Student)) + findAvailable(getRemainingFoun(Student))

courses = checkPrereq(Student,courses)
return getTopfive(courses)


def removeCoursesFromList(list1,list2):
newlist = list2.copy()
for a in list1:
if a in newlist:
newlist.remove(a)
return newlist


def easyCourses(Student):
program = get_program_by_id(Student.program_id)
completed = getCompletedCourseCodes(Student.id)
codesSortedbyRating = programCourses_SortedbyRating(Student.program_id)

coursesToDo = removeCoursesFromList(completed, codesSortedbyRating)

elecCredits = remElecCredits(Student)

if elecCredits == 0:
allElectives = convertToList(get_allElectives(program.name))
coursesToDo = removeCoursesFromList(allElectives, coursesToDo)

coursesToDo = findAvailable(coursesToDo)

ableToDo = checkPrereq(Student, coursesToDo)
# for a in ableToDo:
# print(a)

return getTopfive(ableToDo)


def fastestGraduation(Student):
program = get_program_by_id(Student.program_id)
sortedCourses = programCourses_SortedbyHighestCredits(Student.program_id)
completed = getCompletedCourseCodes(Student.id)

coursesToDo = removeCoursesFromList(completed, sortedCourses)

elecCredits = remElecCredits(Student)

if elecCredits == 0:
allElectives = convertToList(get_allElectives(program.name))
coursesToDo = removeCoursesFromList(allElectives, coursesToDo)

coursesToDo = findAvailable(coursesToDo)
ableToDo = checkPrereq(Student, coursesToDo)

return getTopfive(ableToDo)

def commandCall(Student, command):
courses = []

if command == "electives":
courses = prioritizeElectives(Student)

elif command == "easy":
courses = easyCourses(Student)

elif command == "fastest":
courses = fastestGraduation(Student)

else:
print("Invalid command")

return courses


def generator(Student, command):
courses = []

plan = getCoursePlan(Student.id)

if plan is None:
plan = plan = create_CoursePlan(Student.id)


courses = commandCall(Student, command)

existingPlanCourses = get_all_courses_by_planid(plan.planId)

planCourses = []
for q in existingPlanCourses:
planCourses.append(q.code)

for c in courses:
if c not in planCourses:
createPlanCourse(plan.planId, c)

return courses
25 changes: 25 additions & 0 deletions App/controllers/coursePlanCourses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from App.models import CoursePlanCourses
from App.database import db

def createPlanCourse(planid, code):
course = CoursePlanCourses(planid, code)
db.session.add(course)
db.session.commit()

def getCourseFromCoursePlan(planid, coursecode):
return CoursePlanCourses.query.filter_by(
planId = planid,
code = coursecode
).first()

def get_all_courses_by_planid(id):
return CoursePlanCourses.query.filter_by(planId=id).all()

def deleteCourseFromCoursePlan(planid, coursecode):
course = getCourseFromCoursePlan(planid, coursecode)
if course:
db.session.delete(course)
db.session.commit()
print("Course succesfully removed from course plan")
else:
print("Course is not in Course Plan")
Loading