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
a7b5433c
Commit
a7b5433c
authored
Dec 27, 2011
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor cleanups. Javascript only called once. Hidden sections now work
parent
e21b9191
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
16 deletions
+4
-16
courseware/capa_module.py
+1
-12
courseware/content_parser.py
+1
-2
courseware/html_module.py
+1
-0
courseware/module_render.py
+1
-2
No files found.
courseware/capa_module.py
View file @
a7b5433c
...
...
@@ -102,34 +102,26 @@ class LoncapaModule(XModule):
self
.
max_attempts
=
None
self
.
due_date
=
None
#dom=parseString(xml)
#dom2 = libxml2.parseMemory(xml, len(xml))
dom2
=
etree
.
fromstring
(
xml
)
#node=dom.childNodes[0]
#self.due_date=node.getAttribute("due")
self
.
due_date
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@due'
))
#dom2.xpathEval('/problem/@due'))
self
.
due_date
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@due'
))
if
len
(
self
.
due_date
)
>
0
:
self
.
due_date
=
dateutil
.
parser
.
parse
(
self
.
due_date
)
else
:
self
.
due_date
=
None
#self.max_attempts=node.getAttribute("attempts")
self
.
max_attempts
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@attempts'
))
if
len
(
self
.
max_attempts
)
>
0
:
self
.
max_attempts
=
int
(
self
.
max_attempts
)
else
:
self
.
max_attempts
=
None
#self.show_answer=node.getAttribute("showanswer")
self
.
show_answer
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@showanswer'
))
if
self
.
show_answer
==
""
:
self
.
show_answer
=
"closed"
self
.
rerandomize
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@rerandomize'
))
#self.rerandomize=node.getAttribute("rerandomize")
if
self
.
rerandomize
==
""
:
self
.
rerandomize
=
True
elif
self
.
rerandomize
==
"false"
:
...
...
@@ -145,10 +137,7 @@ class LoncapaModule(XModule):
self
.
attempts
=
state
[
'attempts'
]
self
.
filename
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@filename'
))
#self.filename=node.getAttribute("filename")
#print self.filename
filename
=
settings
.
DATA_DIR
+
"problems/"
+
self
.
filename
+
".xml"
#self.name=node.getAttribute("name")
self
.
name
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@name'
))
self
.
lcp
=
LoncapaProblem
(
filename
,
self
.
item_id
,
state
)
...
...
courseware/content_parser.py
View file @
a7b5433c
...
...
@@ -27,7 +27,6 @@ def course_file(user):
def
module_xml
(
coursefile
,
module
,
id_tag
,
module_id
):
''' Get XML for a module based on module and module_id. Assumes
module occurs once in courseware XML file.. '''
#doc = libxml2.parseFile(coursefile)
doc
=
etree
.
parse
(
coursefile
)
# Sanitize input
...
...
@@ -35,7 +34,7 @@ def module_xml(coursefile, module, id_tag, module_id):
raise
Exception
(
"Module is not alphanumeric"
)
if
not
module_id
.
isalnum
():
raise
Exception
(
"Module ID is not alphanumeric"
)
xpath_search
=
'//*/{module}[
@{id_tag} = "{id}"
]'
.
format
(
module
=
module
,
xpath_search
=
'//*/{module}[
(@{id_tag} = "{id}") or (@id = "{id}")
]'
.
format
(
module
=
module
,
id_tag
=
id_tag
,
id
=
module_id
)
#result_set=doc.xpathEval(xpath_search)
...
...
courseware/html_module.py
View file @
a7b5433c
...
...
@@ -21,3 +21,4 @@ class HtmlModule(XModule):
def
__init__
(
self
,
xml
,
item_id
,
ajax_url
=
None
,
track_url
=
None
,
state
=
None
):
XModule
.
__init__
(
self
,
xml
,
item_id
,
ajax_url
,
track_url
,
state
)
print
xml
courseware/module_render.py
View file @
a7b5433c
...
...
@@ -51,7 +51,6 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
ajax_url
=
'/modx/'
+
module
+
'/'
+
id
+
'/'
id_tag
=
modx_modules
[
module
]
.
id_attribute
#print "X",s.xml, "Y",content_parser.module_xml(module, id_tag, id)
xml
=
content_parser
.
module_xml
(
content_parser
.
course_file
(
request
.
user
),
module
,
id_tag
,
id
)
...
...
@@ -97,7 +96,7 @@ def seq_module(request, module):
for
e
in
module
.
childNodes
\
if
e
.
nodeType
==
1
]
js
=
""
.
join
([
e
[
1
][
'init_js'
]
for
e
in
contents
if
'init_js'
in
e
[
1
]])
js
=
""
iid
=
uuid
.
uuid1
()
.
hex
...
...
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