Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
process the clickablearea directive and generate html for output.
:param self:
:return:
.. clickablearea:: identifier
:question: Question text
:feedback: Optional feedback for incorrect answer
:iscode: Boolean that if present will put the content into a <pre> :table: Boolean that indicates that the content is a table.
:correct: An array of the indices of the correct elements, separated by semicolons--if this is a table, each item in the array is a tuple
with the first number being the row and the second number being the column--use a column number of 0 to make the whole row correct (ex: 1,2;3,0 makes the 2nd data cell in the first row correct as well as the entire 3rd row)
:incorrect: An array of the indices of the incorrect elements--same format as the correct elements.
--Content--
"""
super(ClickableArea, self).run()
addQuestionToDB(self)
self.assert_has_content()
if "iscode" in self.options:
source = "\n".join(self.content)
source = source.replace(":click-correct:", "<span data-correct="">")
source = source.replace(":click-incorrect:", "<span data-incorrect="">")
source = source.replace(":endclick:", "</span>")
source = "<pre>" + source + "</pre>"
self.options["clickcode"] = source
else:
self.options["clickcode"] = ""
clickNode = ClickableAreaNode(self.options, rawsource=self.block_text)
clickNode.source, clickNode.line = self.state_machine.get_source_and_line(
self.lineno
)
clickNode.template_start = TEMPLATE</span></pre>
def run(self):
raw_node = super(Youtube, self).run()
addQuestionToDB(self)
return raw_node
def run(self):
super(_LpBuildButtonDirective, self).run()
_assert_has_no_content(self)
addQuestionToDB(self)
# Gather arguments.
id_ = self.options["divid"]
# Process options
##===============
self.options["include"] = [x.strip() for x in self.options.get("include", "")]
# If a language isn't provided, derive it from the file's name.
env = self.state.document.settings.env
self.options.setdefault("language", get_lexer(filename=env.docname).name)
self.options.setdefault("timelimit", 25000)
self.options.setdefault("builder", "JOBE")
# Generate HTML for the lp build directive. Pass the language, so client-side JS can use the correct syntax highligher.
html = """<div class="runestone">
<input id="{}" data-lang="{}" data-component="lp_build" class="btn btn-success" value="Save and run" type="button">
<br></div>
def run(self):
super(ActiveCode, self).run()
addQuestionToDB(self)
env = self.state.document.settings.env
# keep track of how many activecodes we have....
# could be used to automatically make a unique id for them.
if not hasattr(env, "activecodecounter"):
env.activecodecounter = 0
env.activecodecounter += 1
self.options["name"] = self.arguments[0].strip()
explain_text = None
if self.content:
if "~~~~" in self.content:
idx = self.content.index("~~~~")
explain_text = self.content[:idx]
self.content = self.content[idx + 1 :]
source = "\n".join(self.content)
def run(self):
"""
process the video directive and generate html for output.
:param self:
:return:
"""
super(Video, self).run()
addQuestionToDB(self)
mimeMap = {'mov':'mp4','webm':'webm', 'm4v':'m4v'}
sources = [SOURCE % (directives.uri(line),mimeMap[line[line.rindex(".")+1:]]) for line in self.content]
if 'controls' in self.options:
self.options['controls'] = 'controls'
if 'loop' in self.options:
self.options['loop'] = 'loop'
else:
self.options['loop'] = ''
if 'preload' in self.options:
self.options['preload'] = 'preload="auto"'
else:
self.options['preload'] = 'preload="none"'
def run(self):
"""
process the video directive and generate html for output.
:param self:
:return:
"""
super(Video, self).run()
addQuestionToDB(self)
mimeMap = {"mov": "mp4", "webm": "webm", "m4v": "m4v"}
sources = [
SOURCE % (directives.uri(line), mimeMap[line[line.rindex(".") + 1 :]])
for line in self.content
]
if "controls" in self.options:
self.options["controls"] = "controls"
if "loop" in self.options:
self.options["loop"] = "loop"
else:
self.options["loop"] = ""
if "preload" in self.options:
self.options["preload"] = 'preload="auto"'
def run(self):
"""
process the multiplechoice directive and generate html for output.
:param self:
:return:
.. dragndrop:: identifier
:feedback: Feedback that is displayed if things are incorrectly matched--is optional
:match_1: Draggable element text|||Dropzone to be matched with text
:match_2: Drag to Answer B|||Answer B
:match_3: Draggable text|||Text of dropzone
...etc...(up to 20 matches)
The question goes here.
"""
super(DragNDrop, self).run()
addQuestionToDB(self)
if self.content:
source = "\n".join(self.content)
else:
source = "\n"
self.options["question"] = source
env = self.state.document.settings.env
self.options["divclass"] = env.config.dragndrop_div_class
dndNode = DragNDropNode(self.options, rawsource=self.block_text)
dndNode.source, dndNode.line = self.state_machine.get_source_and_line(
self.lineno
)
dndNode.template_start = TEMPLATE_START
dndNode.template_option = TEMPLATE_OPTION
TEMPLATE_START = """
<div class="%(divclass)s">
<div id="%(divid)s" data-component="fillintheblank">
"""
TEMPLATE_END = """
</div>
</div>
"""
addQuestionToDB(self)
fitbNode = FITBNode(self.options, rawsource=self.block_text)
fitbNode.source, fitbNode.line = self.state_machine.get_source_and_line(
self.lineno
)
fitbNode.template_start = TEMPLATE_START
fitbNode.template_end = TEMPLATE_END
self.updateContent()
self.state.nested_parse(self.content, self.content_offset, fitbNode)
env = self.state.document.settings.env
self.options["divclass"] = env.config.fitb_div_class
# Expected _`structure`, with assigned variable names and transformations made:
#
def run(self):
if not self.options.get("start"):
self.options["start"] = 0
if not self.options.get("end"):
self.options["end"] = -1
raw_node = super(Youtube, self).run()
addQuestionToDB(self)
return raw_node
return None
=====
curmax = alist[0]
for item in alist:
=====
if item > curmax:
=====
curmax = item
=====
return curmax
"""
super(ParsonsProblem, self).run()
addQuestionToDB(self)
env = self.state.document.settings.env
self.options["instructions"] = ""
self.options["code"] = self.content
self.options["divclass"] = env.config.parsons_div_class
if "numbered" in self.options:
self.options["numbered"] = (
' data-numbered="' + self.options["numbered"] + '"'
) #' data-numbered="true"'
else:
self.options["numbered"] = ""
if "maxdist" in self.options:
self.options["maxdist"] = ' data-maxdist="' + self.options["maxdist"] + '"'
else: