Esempio n. 1
0
 def get_courses(self,students):
     for row in range(self.header_row+1,self.s.get_highest_row()+1):
         rowID = 0 
         val1 = self.s.cell(row=row,column=self.id_column).value
         if self.s.cell(row=row,column=self.id_column).data_type == 's':
             # remove hyphens
             val1 = val1.replace('-','')
             rowID = atoi(val1)
         else:
             rowID = int(val1)
         
         student = find_by_id(students,rowID)
         if student is not None:
             title = str(self.s.cell(row=row,column=self.title_column).value)
             if 'Enrolled' in title: continue
             if 'Creative Reading' in title: continue
             course = Course()
             # Get Grade
             course.title = title 
             course.numAvg  = float(self.s.cell(row=row,column=self.grade_column).value)
             course.nCredits = float(self.s.cell(row=row,column=self.credits_column).value)
             course.year = int(self.s.cell(row=row,column=self.year_column).value)
             course.level = int(self.s.cell(row=row,column=self.level_column).value)
             course.PassSummer = False
             if 'yes' in str(self.s.cell(row=row,column=self.summer_column).value).lower():
                 course.PassSummer = True
             student.add_course(course)
Esempio n. 2
0
    def get_courses(self,students,final_term):
        now = datetime.datetime.now()
        year = now.year
        if now.month < 8:
            year = year - 1
        print 'Reading current courses and setting year as',year

        # For 2012-2013 here are the course credit aslottments
        # This is used to determine the number of credits for 
        # current-year courses on-the-fly
        #courses_3credit = {
        #'Biology','Integrated Algebra','Korean I',
        #'Chemistry','Geometry','Global History II: Enlightenment to Present Day',
        #'Physics','Algebra II','U.S. History','Korean III','Algebra II/Trigonometry',
        #'AP Biology','Intro to Calculus','Pre-Calculus','Senior Literature','AP Eng Lang \& Comp',

        #'Literature I','Writing I','Global History I: Mesopotamia to Renaissance',
        #'Literature II','Writing II','Korean II','American Literature',
        #'Literature III','Writing III','AP Physics',
        #'Korean Literature & Culture','Korean IV - Regents Prep',
        #'Korean Lit. \& Culture'
        #}
        #courses_2credit = [
        #'Applied Civics II: Seminar in American Democracy',
        #'Sem in Amer Democ'
        #]
        #courses_1credit = [
        #'Physics Topics','Scientific Literacy',
        #'Topics in Physics','Economics'
        #]
        #courses_5credit = [
        #'Theatre for Social Change with The Laramie Project','Physical Education','Advanced Theatre'
        #]

        for row in range(self.header_row+1,self.s.get_highest_row()+1):
            term = str(self.s.cell(row=row,column=self.term_column).value)
            # Check that this row corresponds to requested term
            if term not in ['F1','F2','F3']:
            #if term not in ['T1','T2','T3']:
                continue
                
            rowID = 0 
            val1 = self.s.cell(row=row,column=self.id_column).value
            if self.s.cell(row=row,column=self.id_column).data_type == 's':
                # remove hyphens
                val1 = val1.replace('-','')
                rowID = atoi(val1)
            else:
                rowID = int(val1)
            
            student = find_by_id(students,rowID)
            #if student is None:
                #print 'Warning: Missing student with ID =',rowID  
            #else:
            if student is not None:
                title = str(self.s.cell(row=row,column=self.title_column).value)
                #title = title.replace('&','\&')  # Protect against naughty character
                #title = title.replace('Korean Literature','Korean Lit.')  # Shorten Kor Lit Title
                #title = title.replace('Korean IV - Regents Prep','Korean IV')  # Shorten Kor IV Title
                #title = title.replace('Applied Civics II: ','')  # Shorten Civics Seminar
                #title = title.replace('Seminar in American Democracy','Sem in Amer Democ')  # Shorten Civics Seminar
                #title = title.replace('AP English Language and Composition','AP Eng Lang \& Comp')  # Shorten AP English

                if self.s.cell(row=row,column=self.grade_column).value == None:
                    continue
                course = Course()
                # Check if Course already in for different term
                for c in student.get_courses(year):
                    if c.title == title:
                        course = c
                    
                # Fill course information
                if len(course.term_grades) == 0:
                    course.title = title 
                    course.current = True
                    course.year = year
                    if 'Hon' in title:
                        course.level = 2
                    elif 'AP' in title:
                        course.level = 3
                    else:
                        course.level = 1
                
                # Fill grade
                course.term_grades[term] = float(self.s.cell(row=row,column=self.grade_column).value)
                if term == final_term:
                    course.numAvg  = float(self.s.cell(row=row,column=self.grade_column).value)

                #stripTitle = title.replace(' (Hon)','')
                #stripTitle = stripTitle.replace(' Accelerated','')
                #if stripTitle in courses_3credit:
                #    course.nCredits = 3
                #elif stripTitle in courses_2credit:
                #    course.nCredits = 2
                #elif stripTitle in courses_1credit:
                #    course.nCredits = 1
                #elif stripTitle in courses_5credit:
                #    course.nCredits = 0.5
                #else:
                #    course.nCredits = 0
                    
                
                if len(course.term_grades) == 1:
                    student.add_course(course)