當前位置: 首頁>>代碼示例>>Python>>正文


Python Course.add_to_week_average方法代碼示例

本文整理匯總了Python中course.Course.add_to_week_average方法的典型用法代碼示例。如果您正苦於以下問題:Python Course.add_to_week_average方法的具體用法?Python Course.add_to_week_average怎麽用?Python Course.add_to_week_average使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在course.Course的用法示例。


在下文中一共展示了Course.add_to_week_average方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: load_from_file

# 需要導入模塊: from course import Course [as 別名]
# 或者: from course.Course import add_to_week_average [as 別名]

#.........這裏部分代碼省略.........
            if complete_name in course.professors:
                professor = course.professors.get(complete_name)
                conf_interaction = professor.set_interation(timestamp)
            else:
                professor = Professor(first_name, last_name)
                conf_interaction = professor.set_interation(timestamp)
                course.professors[complete_name] = professor

        data_professor.close()
        
        #Tutors loader
        for line in data_tutors:

            data_processed = data_processed + len(line)
            self.progress_load(data_size, data_processed)

            new_line = remove_white_space(line)
            split_line = string.split(new_line, "|")

            #split_line must have 3 position
            if len(split_line) != 3:
                continue

            complete_name = split_line[0]+" "+split_line[1]
            first_name = split_line[0]
            last_name = split_line[1]
            timestamp = split_line[2]

            if complete_name in ignored_names:
                continue
            
            if not begin_date < int(timestamp) < end_date:
                continue

            if self.is_professor(complete_name, course):
                continue

            if complete_name in course.tutors:
                tutor = course.tutors.get(complete_name)
                tutor.set_interation(timestamp)
            else:
                tutor = Tutor(first_name, last_name)
                tutor.set_interation(timestamp)
                course.tutors[complete_name] = tutor

        data_tutors.close()
            
        #Students loader
        for line in data_student:

            data_processed = data_processed + len(line)
            self.progress_load(data_size, data_processed)

            new_line = remove_white_space(line)
            split_line = string.split(new_line, "|")

            #split_line must have 3 position
            if len(split_line) != 3:
                continue

            complete_name = split_line[0]+" "+split_line[1]
            first_name = split_line[0]
            last_name = split_line[1]
            timestamp = split_line[2]

            if complete_name in ignored_names:
                continue
            
            if not begin_date < int(timestamp) < end_date:
                continue

            if self.is_professor(complete_name, course):
                continue
            
            if self.is_tutor(complete_name, course):
                continue

            confirm_interaction = None
            if complete_name in course.students:
                student = course.students.get(complete_name)
                confirm_interaction = student.set_interation(timestamp)
            else:
                student = Student(first_name, last_name)
                confirm_interaction = student.set_interation(timestamp)
                course.students[complete_name] = student

            #Exclude the invalid dates
            if confirm_interaction is not None:
                course.add_to_week_average(timestamp, 1)
                count_interaction += 1

        data_student.close()
        
        for student in course.students.itervalues():
            student.set_average_by_week()

        print "\n"
        self.print_data_stats(count_interaction, course)

        return course
開發者ID:ddetoni,項目名稱:TCCTool,代碼行數:104,代碼來源:dataloader.py


注:本文中的course.Course.add_to_week_average方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。