예제 #1
0
    def forum_posts_allowed(self):
        try:
            blackout_periods = [(parse_time(start), parse_time(end))
                                for start, end
                                in self.discussion_blackouts]
            now = time.gmtime()
            for start, end in blackout_periods:
                if start <= now <= end:
                    return False
        except:
            log.exception("Error parsing discussion_blackouts for course {0}".format(self.id))

        return True
예제 #2
0
    def forum_posts_allowed(self):
        try:
            blackout_periods = [(parse_time(start), parse_time(end))
                                for start, end
                                in self.discussion_blackouts]
            now = time.gmtime()
            for start, end in blackout_periods:
                if start <= now <= end:
                    return False
        except:
            log.exception(
                "Error parsing discussion_blackouts for course {0}".format(self.id))

        return True
예제 #3
0
 def _try_parse_time(self, key):
     """
     Parse an optional metadata key containing a time: if present, complain
     if it doesn't parse.
     Return None if not present or invalid.
     """
     if key in self.exam_info:
         try:
             return parse_time(self.exam_info[key])
         except ValueError as e:
             msg = "Exam {0} in course {1} loaded with a bad exam_info key '{2}': '{3}'".format(self.exam_name, self.course_id, self.exam_info[key], e)
             log.warning(msg)
         return None
예제 #4
0
 def _try_parse_time(self, key):
     """
     Parse an optional metadata key containing a time: if present, complain
     if it doesn't parse.
     Return None if not present or invalid.
     """
     if key in self.exam_info:
         try:
             return parse_time(self.exam_info[key])
         except ValueError as e:
             msg = "Exam {0} in course {1} loaded with a bad exam_info key '{2}': '{3}'".format(
                 self.exam_name, self.course_id, self.exam_info[key], e)
             log.warning(msg)
         return None