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