def progress(request): if request.user.is_authenticated(): profile = request.user.get_profile() progress = [] records = dict([(r.course.id, r) for r in profile.records.all()]) credit_records = [(r.date, r.course.credits) for r in profile.records.all()] credit_records.sort() credit_count = 0 graph_entries = [] if credit_records: for entry in credit_records: credit_count += entry[1] graph_entries.append([entry[0], credit_count]) for degree in profile.degrees.all(): evaluator = parse_degree(degree) print evaluator.credit_worth() evaluator.eval(records) completion = (float(evaluator.creditcount) / float(evaluator.credit_worth())) * 100 progress.append({ 'degree': degree, 'evaluator': evaluator, 'completion': completion }) return render_to(request, 'student/progress.html', { 'progress': progress, 'graph_entries': graph_entries }) else: return render_to(request, 'student/anon.html')
def xml_to_json(self): evaluator = parse_degree(self) valid_attrs = ['node_type', 'mincredits', 'maxcredits', 'minsub', 'id', 'section', 'minnumber', 'prereqs'] def mk_node(req): node = {} for key in valid_attrs: if hasattr(req, key): node[key] = getattr(req, key) if isinstance(node[key], set): node[key] = list(node[key]) if hasattr(req, 'subreqs'): node['children'] = [mk_node(subreq) for subreq in req.subreqs] #if hasattr(req, 'prereqs'): # node['prereqs'] = [mk_node(prereq) for prereq in req.prereqs] return node return mk_node(evaluator)