Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
a0e628f7
Commit
a0e628f7
authored
Jun 12, 2012
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
private methods start with _ (in capa_problem)
parent
4366529a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
common/lib/capa/capa_problem.py
+8
-8
No files found.
common/lib/capa/capa_problem.py
View file @
a0e628f7
...
...
@@ -113,12 +113,12 @@ class LoncapaProblem(object):
self
.
tree
=
etree
.
XML
(
file_text
)
# parse problem XML file into an element tree
# construct script processor context (eg for customresponse problems)
self
.
context
=
self
.
extract_context
(
self
.
tree
,
seed
=
self
.
seed
)
self
.
context
=
self
.
_
extract_context
(
self
.
tree
,
seed
=
self
.
seed
)
# pre-parse the XML tree: modifies it to add ID's and perform some in-place transformations
# this also creates the dict (self.responders) of Response instances for each question in the problem.
# the dict has keys = xml subtree of Response, values = Response instance
self
.
preprocess_problem
(
self
.
tree
)
self
.
_
preprocess_problem
(
self
.
tree
)
def
do_reset
(
self
):
'''
...
...
@@ -238,11 +238,11 @@ class LoncapaProblem(object):
'''
Main method called externally to get the HTML to be rendered for this capa Problem.
'''
return
contextualize_text
(
etree
.
tostring
(
self
.
extract_html
(
self
.
tree
)),
self
.
context
)
return
contextualize_text
(
etree
.
tostring
(
self
.
_
extract_html
(
self
.
tree
)),
self
.
context
)
# ======= Private Methods Below ========
def
extract_context
(
self
,
tree
,
seed
=
struct
.
unpack
(
'i'
,
os
.
urandom
(
4
))[
0
]):
# private
def
_
extract_context
(
self
,
tree
,
seed
=
struct
.
unpack
(
'i'
,
os
.
urandom
(
4
))[
0
]):
# private
'''
Extract content of <script>...</script> from the problem.xml file, and exec it in the
context of this problem. Provides ability to randomize problems, and also set
...
...
@@ -273,7 +273,7 @@ class LoncapaProblem(object):
log
.
exception
(
"Error while execing code: "
+
code
)
return
context
def
extract_html
(
self
,
problemtree
):
# private
def
_
extract_html
(
self
,
problemtree
):
# private
'''
Main (private) function which converts Problem XML tree to HTML.
Calls itself recursively.
...
...
@@ -320,11 +320,11 @@ class LoncapaProblem(object):
return
render_object
.
get_html
()
# function(problemtree, value, status, msg) # render the special response (textline, schematic,...)
if
problemtree
in
self
.
responders
:
# let each Response render itself
return
self
.
responders
[
problemtree
]
.
render_html
(
self
.
extract_html
)
return
self
.
responders
[
problemtree
]
.
render_html
(
self
.
_
extract_html
)
tree
=
etree
.
Element
(
problemtree
.
tag
)
for
item
in
problemtree
:
item_xhtml
=
self
.
extract_html
(
item
)
# nothing special: recurse
item_xhtml
=
self
.
_
extract_html
(
item
)
# nothing special: recurse
if
item_xhtml
is
not
None
:
tree
.
append
(
item_xhtml
)
...
...
@@ -339,7 +339,7 @@ class LoncapaProblem(object):
return
tree
def
preprocess_problem
(
self
,
tree
):
# private
def
_
preprocess_problem
(
self
,
tree
):
# private
'''
Assign IDs to all the responses
Assign sub-IDs to all entries (textline, schematic, etc.)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment