def get_series(self):
        itr = 0
        series = None
        title = 'Title'

        if self.category == 'fac' or self.category == '':
            if len(self.subsub) == 0:
                # By Faculty table
                title = 'All Faculty'
                if self.type == 'null': self.type = Graph.types[1]
                series = Series(title, 'all_faculty', self)
                series.bars = self.get_all_faculty_bars()
                itr = 4
            else:
                # selected faculty - subsub
                faculty_name = db_helper.get_faculty_name(self.subsub)
                title = faculty_name
                if self.type == 'null': self.type = Graph.types[1]
                series = self.build_faculty_ques_series(faculty_name)
                itr = 5

        elif self.category == 'class':
            if len(self.year) == 0:
                # By Class table
                title = 'All Years'
                series = Series(title, 'all_years', self)
                series.bars = self.get_all_years_bars()
                itr = 1
            elif self.year == 'all_branches':
                # By Class all years all branches
                title = 'All Years, Branches'
                if self.type == 'null': self.type = Graph.types[1]
                series = Series(title, 'all_branches', self)
                series.bars = self.get_all_branches_bars()
                itr = 2
            elif self.year == 'all_sections':
                # By Class all years all branches all sections
                title = 'All Years, Branches, Sections'
                if self.type == 'null': self.type = Graph.types[1]
                series = Series(title, 'all_sections', self)
                series.bars = self.get_all_sections_bars()
                itr = 3

        elif self.category == 'stu':
            if len(self.branch) == 0:
                # All subjects table
                title = 'All Subjects'
                if self.type == 'null': self.type = Graph.types[1]
                series = self.build_all_subjects_series()
                itr = 6
            else:
                # Selected subject graph - year, branch
                title = self.year + '-' + self.branch
                series = Series(title, title, self)
                # TODO: build subject series?
                itr = 7
        self.s_no = itr
        self.title = title

        return series.rev_sort()
    def build_section_series(self, year, branch):
        series = Series(year + ' ' + branch, year + ' ' + branch, self)
        sections = db_helper.get_sections(year, branch)
        bars = []

        for i in range(len(sections)):
            bars.append(Bar(
                sections[i],
                db_helper.get_section_value(year, branch, sections[i]),
                self.build_faculty_series(year, branch, sections[i])
            ))

        series.bars = bars
        return series.rev_sort()
    def build_class_branch_series(self, year):
        series = Series(year, year, self)
        branches = db_helper.get_branches(year)
        bars = []

        for i in range(len(branches)):
            bars.append(
                Bar(
                    branches[i],
                    db_helper.get_branch_value(year, branches[i]),
                    self.build_section_series(year, branches[i])
                )
            )
        series.bars = bars
        return series.rev_sort()
    def build_faculty_for_subject_series(self, subject):
        faculty = db_helper.get_faculty_for_subject(subject)

        bars = []
        series = Series(subject, subject, self)

        for i in range(len(faculty)):
            bars.append(Bar(
                faculty[i].name,
                db_helper.get_faculty_value_for_subject(subject, faculty[i]),
                'null'
            ))

        series.bars = bars
        return series.rev_sort()
Beispiel #5
0
    def build_faculty_ques_series(self, cfs):
        questions = db_helper.get_selected_questions()

        bars = []
        series = Series(str(cfs), str(cfs), self)

        for question in questions:
            bars.append(Bar(
                question.question,
                db_helper.get_question_value_for_cfs(cfs.cfs_id, question.question_id),
                'null'
            ))

        series.bars = bars
        return series.rev_sort()
 def build_faculty_series(self, year, branch, section):
     series = Series(year + ' ' + branch + ' ' + section, year + ' ' + branch + ' ' + section, self)
     faculty = db_helper.get_faculty(year, branch, section)
     bars = []
     for i in range(len(faculty)):
         cfss = db_helper.get_cfs(faculty[i].name, year, branch, section)
         for cfs in cfss:
             bars.append(Bar(
                 faculty[i].name + ' (' + cfs.subject_id.name + ')',
                 db_helper.get_cfs_value(cfs),
                 self.build_faculty_ques_series(faculty[i].name)
                 # TODO: build cfs series
                 # 'null'
             ))
     series.bars = bars
     return series.rev_sort()
    def build_faculty_ques_series(self, faculty):
        questions = db_helper.get_selected_questions()

        if self.type == Graphable.types[1]:
            if self.height < len(questions) * Graph.height_per_bar:
                self.height = len(questions) * Graph.height_per_bar

        bars = []
        series = Series(faculty, faculty, self)

        for question in questions:
            bars.append(Bar(
                question.question,
                db_helper.get_question_value(faculty, question.question_id),
                'null'
            ))

        series.bars = bars
        return series.rev_sort()
    def build_all_subjects_series(self):
        subjects = db_helper.get_all_subjects_all_years()

        if self.type == Graph.types[1]:
            self.height = len(subjects) * Graph.height_per_bar

        bars = []
        title = 'All Subjects'
        series = Series(title, title, self)

        for i in range(len(subjects)):
            bars.append(Bar(
                subjects[i],
                db_helper.get_subject_value(subjects[i]),
                self.build_faculty_for_subject_series(subjects[i])
            ))

        series.bars = bars
        return series.rev_sort()
Beispiel #9
0
    def build_faculty_series(self):
        cfs = db_helper.get_faculty_cfs(self.faculty)

        if self.type == Graphable.types[1]:
            if self.height < len(cfs) * self.height_per_bar:
                self.height = len(cfs) * self.height_per_bar

        bars = []
        series = Series('Classes', 'class-sub', self)

        for i in range(len(cfs)):
            bars.append(Bar(
                str(cfs[i].class_id) + ' ( ' + cfs[i].subject_id.name + ' )',
                db_helper.get_cfs_value(cfs[i]),
                self.build_faculty_ques_series(cfs[i])
            ))

        series.bars = bars
        return series.rev_sort()
Beispiel #10
0
    def build_faculty_ques_series(self):
        questions = db_helper.get_selected_questions()

        bars = []
        series = Series(self.faculty, self.faculty, self)

        for question in questions:
            bars.append(
                Bar(
                    question.question,
                    db_helper.get_question_value(self.faculty,
                                                 question.question_id),
                    'null'))

        if self.type == 'bar':
            self.height = math.sqrt(len(bars)) * 5 * self.height_per_bar

        series.bars = bars
        series.color_by_point = 'false'
        return series.rev_sort()