Commit b342160b authored by Daniel W Bond's avatar Daniel W Bond

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

parents 660aba7a 7fc46c43
from mainapp.models import Course, Semester, Trajectory # import more
from mainapp.models import Course, CourseGroup, Semester, Trajectory # import more
### common functionality
......@@ -10,6 +10,24 @@ def programCourses(program):
for course in requirement.courses.all():
courses.append(course)
repeat = True
while repeat:
repeat = False
for course in courses:
try:
course = Course.objects.get(title=course.title)
except:
coursegroup = CourseGroup.objects.get(title=course.title)
repeat = True
courses.remove(course)
numadded = 0
for newcourse in coursegroup.courses.all():
if numadded < coursegroup.numneeded:
courses.append(newcourse)
numadded+=1
else:
break
return courses
def genDepTree(course):
......@@ -97,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)
......@@ -134,7 +152,7 @@ def nextCourses(remainingReqCourses, taken):
try:
c = Course.objects.get(title=course)
except:
pass
c = CourseGroup.objects.get(title=course)
for prereq in c.prerequisites.all():
reqs.add(prereq)
#for coreq in course.coreq:
......@@ -144,7 +162,7 @@ def nextCourses(remainingReqCourses, taken):
nextcourses.append(course)
return nextCourses
return nextcourses
# IMPLEMENT THIS IN JS!
#def maxCreditsAllowed():
......@@ -185,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:
......@@ -206,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
......
......@@ -39,6 +39,7 @@ def build_trajectory(request):
trac = genTrajectories(taken=taken,programs=programs,user=user_in)
#majors = form.fie
return render_to_response('build.html', {
'trac' : trac,
})
class StartTrajectoryView(FormView):
template_name = 'new.html'
......
......@@ -17,16 +17,16 @@ Search | YourSchool Advisor
</div>
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="col-lg-12 col-lg-offset-2">
<form class="form-horizontal" role="form" method="get">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-search"></span>
</span>
{{ form.q }}
</div>
</div>
</form>
</div>
</div>
......
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