Commit 1009923d authored by Daniel W Bond's avatar Daniel W Bond

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

parents 5be00b59 115a9404
......@@ -32,7 +32,7 @@ class Semester(models.Model):
number = models.IntegerField("Semester Number")
user = models.ForeignKey(Student)
courses = models.ManyToManyField('Course', blank=True)
programs = models.ManyToManyField('Program')
programs = models.ManyToManyField('Program', related_name="progs+")
nextsemester = models.ForeignKey('self', blank=True, null=True)
requirementssatisfied = models.ManyToManyField('Requirement',
related_name="reqssatisfied+", blank=True,
......@@ -43,7 +43,7 @@ class Semester(models.Model):
class Trajectory(TimeStampedModel):
user = models.OneToOneField(User, related_name="trajectory")
user = models.OneToOneField(Student, related_name="trajectory-user")
semesters = models.ManyToManyField(Semester)
......@@ -78,6 +78,9 @@ class Concentration(Program):
verbose_name="Associated Major")
class RequirementManager(models.Manager):
pass
class Requirement(TimeStampedModel):
name = models.CharField(max_length=50)
courses = models.ManyToManyField('MetaCourse')
......
......@@ -6,10 +6,9 @@ def programCourses(program):
courses = []
requirements = program.requirements
for requirement in requirements:
for coursegroup in requirement.coursegroup:
for course in coursegroup.courses:
courses.append(course)
for requirement in requirements.all():
for course in requirement.courses.all():
courses.append(course)
return courses
......@@ -132,7 +131,11 @@ def nextCourses(remainingReqCourses, taken):
nextcourses = []
for course in remainingReqCourses:
reqs = set()
for prereq in course.preq:
try:
c = Course.objects.get(title=course)
except:
pass
for prereq in c.prerequisites.all():
reqs.add(prereq)
#for coreq in course.coreq:
# reqs.add(coreq)
......@@ -182,13 +185,23 @@ def genTrajectories(taken, programs, user):
if not taken:
taken = ['']
taken = set(taken)
sem = Semester(number=0, user=user, courses=taken,
programs=programs)
tj = Trajectory(user=user, semesters=[sem])
programCourses = []
print taken
sem = Semester(number=0, user=user)
sem.save()
for takencourse in taken:
takencourse.semester=sem
sem.courses = taken
sem.programs = programs
try:
tj = Trajectory.objects.get(user=user)
except:
tj = Trajectory(user=user)
tj.save()
tj.semesters=[sem]
programcourses = []
for program in programs:
programcourses+=programCourses(program)
remainingCourses=remainingReqCourses(taken, programCourses)
programcourses = programcourses + programCourses(program)
remainingCourses=remainingReqCourses(taken, programcourses)
while True:
availableCourses=nextCourses(remainingCourses, taken)
semclasses=[]
......
......@@ -4,6 +4,8 @@
<head>
{% load staticfiles %}
<meta charset="utf-8">
<link rel="icon" type="{% static 'image/ico' %}" href="{% static
'img/academic.ico' %}">
<link href="/static/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="/static/css/flat-ui.css" rel="stylesheet" media="screen">
<link href="/static/css/jquery.gridster.min.css" rel="stylesheet" media="screen">
......
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