def is_released(self, step=None): """ Check if a question has been released. Keyword Arguments: step (str): The step in the workflow to check. None: check whether the problem as a whole is open. "submission": check whether the submission section is open. "peer-assessment": check whether the peer-assessment section is open. "self-assessment": check whether the self-assessment section is open. Returns: bool """ # By default, assume that we're published, in case the runtime doesn't support publish date. if hasattr(self.runtime, 'modulestore'): is_published = self.runtime.modulestore.has_published_version(self) else: is_published = True is_closed, reason, __, __ = self.is_closed(step=step) is_released = is_published and (not is_closed or reason == 'due') if self.start: is_released = is_released and dt.datetime.now( pytz.UTC) > parse_date_value(self.start, self._) return is_released
def is_released(self, step=None): """ Check if a question has been released. Keyword Arguments: step (str): The step in the workflow to check. None: check whether the problem as a whole is open. "submission": check whether the submission section is open. "peer-assessment": check whether the peer-assessment section is open. "self-assessment": check whether the self-assessment section is open. Returns: bool """ # By default, assume that we're published, in case the runtime doesn't support publish date. if hasattr(self.runtime, 'modulestore'): is_published = self.runtime.modulestore.has_published_version(self) else: is_published = True try: is_closed, reason, __, __ = self.is_closed(step=step) # pylint: disable=redeclared-assigned-name except DateValidationError: # Workaround so that studio_mixin workflow wil still work in the case that we have invalid dates is_closed = False reason = '' is_released = is_published and (not is_closed or reason == 'due') if self.start: is_released = is_released and dt.datetime.now(pytz.UTC) > parse_date_value(self.start, self._) return is_released
def is_released(self, step=None): """ Check if a question has been released. Keyword Arguments: step (str): The step in the workflow to check. None: check whether the problem as a whole is open. "submission": check whether the submission section is open. "peer-assessment": check whether the peer-assessment section is open. "self-assessment": check whether the self-assessment section is open. Returns: bool """ # By default, assume that we're published, in case the runtime doesn't support publish date. if hasattr(self.runtime, 'modulestore'): is_published = self.runtime.modulestore.has_published_version(self) else: is_published = True is_closed, reason, __, __ = self.is_closed(step=step) is_released = is_published and (not is_closed or reason == 'due') if self.start: is_released = is_released and dt.datetime.now(pytz.UTC) > parse_date_value(self.start, self._) return is_released
def _parse_date_safe(date): try: return parse_date_value(date, self._) except InvalidDateFormat: return ''