Commit 7fc46c43 authored by Ben Waters's avatar Ben Waters

Merge branch 'master' of https://github.com/srct/advisor

parents 5d8af680 171858f7
......@@ -20,8 +20,13 @@ def programCourses(program):
coursegroup = CourseGroup.objects.get(title=course.title)
repeat = True
courses.remove(course)
for newcourse in coursegroup.courses:
courses.append(newcourse)
numadded = 0
for newcourse in coursegroup.courses.all():
if numadded < coursegroup.numneeded:
courses.append(newcourse)
numadded+=1
else:
break
return courses
......@@ -110,8 +115,8 @@ def requirementsFulfilled(taken, program):
taken = set(taken)
requirements = program.requirements
for requirement in requirements:
for coursegroup in requirement.coursegroup:
for requirement in requirements.all():
for courses in requirement.courses.all():
courseRequirements = set(coursegroup.courses)
requirementCoursesTaken = courseRequirements.intersection(alreadyTaken)
......@@ -157,7 +162,7 @@ def nextCourses(remainingReqCourses, taken):
nextcourses.append(course)
return nextCourses
return nextcourses
# IMPLEMENT THIS IN JS!
#def maxCreditsAllowed():
......@@ -198,7 +203,6 @@ def genTrajectories(taken, programs, user):
if not taken:
taken = ['']
taken = set(taken)
print taken
sem = Semester(number=0, user=user)
sem.save()
for takencourse in taken:
......@@ -219,20 +223,29 @@ def genTrajectories(taken, programs, user):
availableCourses=nextCourses(remainingCourses, taken)
semclasses=[]
for i in xrange(5):
doneclass = availableCourses.pop()
semclasses.append(doneclass)
taken.add(doneclass)
newsem = Semester(number=sem.number+1, user=user, courses=semclasses,
programs=programs)
tj.semesters.append(newsem)
try:
doneclass = availableCourses.pop()
semclasses.append(doneclass)
taken.add(doneclass)
except:
break
newsem = Semester(number=sem.number+1, user=user)
newsem.save()
newsem.courses = semclasses
newsem.programs = programs
newsem.save()
sem.nextsemester = newsem
#tj.semesters+=[newsem]
sem = newsem
failed=False
for program in programs:
if requirementsFulfilled(program, taken) != program.requirements:
failed=True
if not failed:
break
#for program in programs:
# if requirementsFulfilled(taken, program) != program.requirements:
# failed=True
#if not failed:
# break
if enoughCredits(taken, 120) or sem.number > 10:
break
return tj
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment