Exemplo n.º 1
0
    def get_classtime_table(self, student_emails, dt_start_utc):

        dt_start_ctz = self.dt_to_ctz(dt_start_utc)
        dt_end_ctz = dt_start_ctz + datetime.timedelta(days=1)

        column = 0

        classtime_table = ClassTimeTable(dt_start_ctz, dt_end_ctz)

        for student_email in student_emails:
            student = users.User(email=student_email)

            problem_logs = ProblemLog.get_for_user_between_dts(
                student, self.dt_to_utc(dt_start_ctz),
                self.dt_to_utc(dt_end_ctz))
            video_logs = VideoLog.get_for_user_between_dts(
                student, self.dt_to_utc(dt_start_ctz),
                self.dt_to_utc(dt_end_ctz))

            problem_and_video_logs = []

            for problem_log in problem_logs:
                problem_and_video_logs.append(problem_log)
            for video_log in video_logs:
                problem_and_video_logs.append(video_log)

            problem_and_video_logs = sorted(problem_and_video_logs,
                                            key=lambda log: log.time_started())

            chunk_current = None

            for activity in problem_and_video_logs:

                if chunk_current is not None and self.dt_to_ctz(
                        activity.time_started()) > (chunk_current.end +
                                                    self.chunk_delta):
                    classtime_table.drop_into_column(chunk_current, column)
                    chunk_current.description()
                    chunk_current = None

                if chunk_current is None:
                    chunk_current = ClassTimeChunk()
                    chunk_current.student = student
                    chunk_current.start = self.dt_to_ctz(
                        activity.time_started())
                    chunk_current.end = self.dt_to_ctz(activity.time_ended())

                chunk_current.activities.append(activity)
                chunk_current.end = min(self.dt_to_ctz(activity.time_ended()),
                                        dt_end_ctz)

            if chunk_current is not None:
                classtime_table.drop_into_column(chunk_current, column)
                chunk_current.description()

            column += 1

        classtime_table.balance()
        return classtime_table
Exemplo n.º 2
0
    def get_classtime_table(self, student_emails, dt_start_utc):

        dt_start_ctz = self.dt_to_ctz(dt_start_utc)
        dt_end_ctz = dt_start_ctz + datetime.timedelta(days = 1)

        column = 0

        classtime_table = ClassTimeTable(dt_start_ctz, dt_end_ctz)

        for student_email in student_emails:
            student = users.User(email=student_email)

            problem_logs = ProblemLog.get_for_user_between_dts(student, self.dt_to_utc(dt_start_ctz), self.dt_to_utc(dt_end_ctz))
            video_logs = VideoLog.get_for_user_between_dts(student, self.dt_to_utc(dt_start_ctz), self.dt_to_utc(dt_end_ctz))

            problem_and_video_logs = []

            for problem_log in problem_logs:
                problem_and_video_logs.append(problem_log)
            for video_log in video_logs:
                problem_and_video_logs.append(video_log)

            problem_and_video_logs = sorted(problem_and_video_logs, key=lambda log: log.time_started())

            chunk_current = None

            for activity in problem_and_video_logs:

                if chunk_current is not None and self.dt_to_ctz(activity.time_started()) > (chunk_current.end + self.chunk_delta):
                    classtime_table.drop_into_column(chunk_current, column)
                    chunk_current.description()
                    chunk_current = None

                if chunk_current is None:
                    chunk_current = ClassTimeChunk()
                    chunk_current.student = student
                    chunk_current.start = self.dt_to_ctz(activity.time_started())
                    chunk_current.end = self.dt_to_ctz(activity.time_ended())

                chunk_current.activities.append(activity)
                chunk_current.end = min(self.dt_to_ctz(activity.time_ended()), dt_end_ctz)

            if chunk_current is not None:
                classtime_table.drop_into_column(chunk_current, column)
                chunk_current.description()

            column += 1

        classtime_table.balance()
        return classtime_table