How to use the runestone.server.componentdb.addHTMLToDB function in runestone

To help you get started, we’ve selected a few runestone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RunestoneInteractive / RunestoneComponents / runestone / dragndrop / dragndrop.py View on Github external
res = ""
    # Add all of the possible answers
    okeys = list(node.dnd_options.keys())
    okeys.sort()
    for k in okeys:
        if "match" in k:
            x, label = k.split("_")
            node.dnd_options["dnd_label"] = label
            dragE, dropE = node.dnd_options[k].split("|||")
            node.dnd_options["dragText"] = dragE
            node.dnd_options["dropText"] = dropE
            res += node.template_option % node.dnd_options
    res += node.template_end % node.dnd_options
    self.body.append(res)

    addHTMLToDB(
        node.dnd_options["divid"],
        node.dnd_options["basecourse"],
        "".join(self.body[self.body.index(node.delimiter) + 1 :]),
    )

    self.body.remove(node.delimiter)
github RunestoneInteractive / RunestoneComponents / runestone / clickableArea / clickable.py View on Github external
def depart_ca_node(self, node):
    res = ""
    res = TEMPLATE_END % node.ca_options
    self.body.append(res)

    addHTMLToDB(
        node.ca_options["divid"],
        node.ca_options["basecourse"],
        "".join(self.body[self.body.index(node.delimiter) + 1 :]),
    )

    self.body.remove(node.delimiter)
github RunestoneInteractive / RunestoneComponents / runestone / poll / poll.py View on Github external
res = res % node.poll_content

    if node.poll_content["scale"] == "":
        okeys = list(node.poll_content.keys())
        okeys.sort()
        for k in okeys:
            if "option_" in k:
                node.poll_content["optiontext"] = node.poll_content[k]
                res += TEMPLATE_OPTION % node.poll_content
    else:
        for i in range(node.poll_content["scale"]):
            node.poll_content["optiontext"] = i + 1
            res += TEMPLATE_OPTION % node.poll_content
    res += TEMPLATE_END

    addHTMLToDB(node.poll_content["divid"], node.poll_content["basecourse"], res)
    self.body.append(res)
github RunestoneInteractive / RunestoneComponents / runestone / external / external.py View on Github external
def depart_external_node(self, node):
    # Set options and format templates accordingly
    res = TEMPLATE_END % node.external_options

    self.body.append(res)

    addHTMLToDB(
        node.external_options["divid"], node.external_options["basecourse"], "".join("")
    )

    self.body.remove(node.delimiter)
github RunestoneInteractive / RunestoneComponents / runestone / parsons / parsons.py View on Github external
def visit_parsons_node(self, node):
    div_id = node.parsonsnode_components["divid"]
    components = dict(node.parsonsnode_components)
    components.update({"divid": div_id})
    res = TEMPLATE % components
    addHTMLToDB(div_id, components["basecourse"], res)

    self.body.append(res)
github RunestoneInteractive / RunestoneComponents / runestone / fitb / fitb.py View on Github external
json_feedback = json.dumps(node.feedbackArray)
    # Some nodes (for example, those in a timed node) have their ``document == None``. Find a valid ``document``.
    node_with_document = node
    while not node_with_document.document:
        node_with_document = node_with_document.parent
    # Supply client-side grading info if we're not grading on the server.
    node.fitb_options["json"] = (
        "false"
        if node_with_document.document.settings.env.config.runestone_server_side_grading
        else json_feedback
    )
    res = node.template_end % node.fitb_options
    self.body.append(res)

    # add HTML to the Database and clean up
    addHTMLToDB(
        node.fitb_options["divid"],
        node.fitb_options["basecourse"],
        "".join(self.body[self.body.index(node.delimiter) + 1 :]),
        json_feedback,
    )

    self.body.remove(node.delimiter)
github RunestoneInteractive / RunestoneComponents / runestone / video / video.py View on Github external
def run(self):
        super(IframeVideo, self).run()
        self.options['video_id'] = directives.uri(self.arguments[0])
        if not self.options.get('width'):
            self.options['width'] = self.default_width
        if not self.options.get('height'):
            self.options['height'] = self.default_height
        if not self.options.get('align'):
            self.options['align'] = 'left'
        if not self.options.get('http'):
            self.options['http'] = 'https'
        if not self.options.get('divid'):
            self.options['divid'] = self.arguments[0]
        
        res = self.html % self.options
        addHTMLToDB(self.options['divid'], self.options['basecourse'], res)
        raw_node = nodes.raw(self.block_text, res, format='html')
        raw_node.source, raw_node.line = self.state_machine.get_source_and_line(self.lineno)
        return [raw_node]
github RunestoneInteractive / RunestoneComponents / runestone / showeval / showeval.py View on Github external
for line in self.content:
            if step == True:
                if line != "":
                    if is_dynamic:
                        esc_line = str(line).replace("{", "\{")
                    else:
                        esc_line = str(line)
                    self.options["steps"].append(esc_line)
            elif "~~~~" in line:
                step = True
            else:
                self.options["preReqLines"] += line + "<br>\n"

        res = (CODE + SCRIPT) % self.options

        addHTMLToDB(self.options["divid"], self.options["basecourse"], res)
        return [nodes.raw(self.block_text, res, format="html")]
github RunestoneInteractive / RunestoneComponents / runestone / video / video.py View on Github external
def run(self):
        super(IframeVideo, self).run()
        self.options["video_id"] = directives.uri(self.arguments[0])
        if not self.options.get("width"):
            self.options["width"] = self.default_width
        if not self.options.get("height"):
            self.options["height"] = self.default_height
        if not self.options.get("align"):
            self.options["align"] = "left"
        if not self.options.get("http"):
            self.options["http"] = "https"
        if not self.options.get("divid"):
            self.options["divid"] = self.arguments[0]

        res = self.html % self.options
        addHTMLToDB(self.options["divid"], self.options["basecourse"], res)
        raw_node = nodes.raw(self.block_text, res, format="html")
        raw_node.source, raw_node.line = self.state_machine.get_source_and_line(
            self.lineno
        )
        return [raw_node]
github RunestoneInteractive / RunestoneComponents / runestone / activecode / activecode.py View on Github external
def depart_ac_node(self, node):
    """ This is called at the start of processing an activecode node.  If activecode had recursive nodes
        etc and did not want to do all of the processing in visit_ac_node any finishing touches could be
        added here.
    """
    res = TEMPLATE_END % node.ac_components
    self.body.append(res)

    addHTMLToDB(
        node.ac_components["divid"],
        node.ac_components["basecourse"],
        "".join(self.body[self.body.index(node.delimiter) + 1 :]),
    )

    self.body.remove(node.delimiter)