Esempio n. 1
0
    def run(self):
        self.assert_has_content()

        hidden_until = self.arguments[0]
        try:
            hidden_until = parse_date(hidden_until)
        except:
            raise self.error('Unknown date format in the "%s" directive; '
                             '%s' % (self.name, hidden_until))

        force_show = self.state.document.settings.force_show_hidden_until
        translation = _get_inginious_translation()

        after_deadline = hidden_until <= datetime.now()
        if after_deadline or force_show:
            output = []

            # Add a warning for teachers/tutors/...
            if not after_deadline and force_show:
                node = nodes.caution()
                self.add_name(node)
                text = translation.gettext(
                    "The feedback below will be hidden to the students until {}."
                ).format(hidden_until.strftime("%d/%m/%Y %H:%M:%S"))
                self.state.nested_parse(StringList(text.split("\n")), 0, node)
                output.append(node)

            text = '\n'.join(self.content)
            node = nodes.compound(text)
            self.add_name(node)
            self.state.nested_parse(self.content, self.content_offset, node)
            output.append(node)

            return output
        else:
            node = nodes.caution()
            self.add_name(node)
            text = translation.gettext(
                "A part of this feedback is hidden until {}. Please come back later and reload the submission to see the full feedback."
            ).format(hidden_until.strftime("%d/%m/%Y %H:%M:%S"))
            self.state.nested_parse(StringList(text.split("\n")), 0, node)
            return [node]
Esempio n. 2
0
    def run(self):
        self.assert_has_content()

        hidden_until = self.arguments[0]
        try:
            hidden_until = parse_date(hidden_until)
        except:
            raise self.error('Unknown date format in the "%s" directive; '
                             '%s' % (self.name, hidden_until))

        force_show = self.state.document.settings.force_show_hidden_until

        after_deadline = hidden_until <= datetime.now()
        if after_deadline or force_show:
            output = []

            # Add a warning for teachers/tutors/...
            if not after_deadline and force_show:
                node = nodes.caution()
                self.add_name(node)
                text = "The feedback below will be hidden to the students until %s." % hidden_until.strftime("%d/%m/%Y %H:%M:%S")
                self.state.nested_parse(StringList(text.split("\n")), 0, node)
                output.append(node)

            text = '\n'.join(self.content)
            node = nodes.compound(text)
            self.add_name(node)
            self.state.nested_parse(self.content, self.content_offset, node)
            output.append(node)

            return output
        else:
            node = nodes.caution()
            self.add_name(node)
            text = "A part of this feedback is hidden until %s. Please come back later and reload the submission to see the full feedback." % \
                   hidden_until.strftime("%d/%m/%Y %H:%M:%S")
            self.state.nested_parse(StringList(text.split("\n")), 0, node)
            return [node]
Esempio n. 3
0
    def run(self):
        self.assert_has_content()

        hidden_until = self.arguments[0]
        try:
            hidden_until = parse_date(hidden_until)
        except:
            raise self.error('Unknown date format in the "%s" directive; '
                             '%s' % (self.name, hidden_until))

        if hidden_until <= datetime.now():
            text = '\n'.join(self.content)
            node = nodes.compound(text)
            self.add_name(node)

            self.state.nested_parse(self.content, self.content_offset, node)
            return [node]
        else:
            node = nodes.caution()
            self.add_name(node)
            text = "A part of this feedback is hidden until %s. Please come back later and reload the submission to see the full feedback." % \
                   hidden_until.strftime("%d/%m/%Y %H:%M:%S")
            self.state.nested_parse(StringList(text.split("\n")), 0, node)
            return [node]