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
a30f1a1e
Commit
a30f1a1e
authored
Dec 27, 2011
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explain works
parent
a7b5433c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
courseware/capa_module.py
+15
-1
courseware/html_module.py
+12
-2
No files found.
courseware/capa_module.py
View file @
a30f1a1e
...
@@ -80,6 +80,16 @@ class LoncapaModule(XModule):
...
@@ -80,6 +80,16 @@ class LoncapaModule(XModule):
if
self
.
max_attempts
!=
None
:
if
self
.
max_attempts
!=
None
:
attempts_str
=
" ({a}/{m})"
.
format
(
a
=
self
.
attempts
,
m
=
self
.
max_attempts
)
attempts_str
=
" ({a}/{m})"
.
format
(
a
=
self
.
attempts
,
m
=
self
.
max_attempts
)
# Check if explanation is available, and if so, give a link
explain
=
""
if
self
.
lcp
.
done
and
self
.
explain_available
==
'attempted'
:
explain
=
self
.
explanation
if
self
.
closed
()
and
self
.
explain_available
==
'closed'
:
explain
=
self
.
explanation
if
len
(
explain
)
==
0
:
explain
=
False
html
=
render_to_string
(
'problem.html'
,
html
=
render_to_string
(
'problem.html'
,
{
'problem'
:
content
,
{
'problem'
:
content
,
'id'
:
self
.
filename
,
'id'
:
self
.
filename
,
...
@@ -88,7 +98,8 @@ class LoncapaModule(XModule):
...
@@ -88,7 +98,8 @@ class LoncapaModule(XModule):
'save_button'
:
save_button
,
'save_button'
:
save_button
,
'answer_available'
:
self
.
answer_available
(),
'answer_available'
:
self
.
answer_available
(),
'ajax_url'
:
self
.
ajax_url
,
'ajax_url'
:
self
.
ajax_url
,
'attempts'
:
attempts_str
'attempts'
:
attempts_str
,
'explain'
:
explain
})
})
if
encapsulate
:
if
encapsulate
:
html
=
'<div id="main_{id}">'
.
format
(
id
=
self
.
item_id
)
+
html
+
"</div>"
html
=
'<div id="main_{id}">'
.
format
(
id
=
self
.
item_id
)
+
html
+
"</div>"
...
@@ -104,6 +115,9 @@ class LoncapaModule(XModule):
...
@@ -104,6 +115,9 @@ class LoncapaModule(XModule):
dom2
=
etree
.
fromstring
(
xml
)
dom2
=
etree
.
fromstring
(
xml
)
self
.
explanation
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@explain'
))
self
.
explain_available
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@explain_available'
))
self
.
due_date
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@due'
))
self
.
due_date
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@due'
))
if
len
(
self
.
due_date
)
>
0
:
if
len
(
self
.
due_date
)
>
0
:
self
.
due_date
=
dateutil
.
parser
.
parse
(
self
.
due_date
)
self
.
due_date
=
dateutil
.
parser
.
parse
(
self
.
due_date
)
...
...
courseware/html_module.py
View file @
a30f1a1e
...
@@ -17,8 +17,18 @@ class HtmlModule(XModule):
...
@@ -17,8 +17,18 @@ class HtmlModule(XModule):
return
"html"
return
"html"
def
get_html
(
self
):
def
get_html
(
self
):
return
render_to_string
(
self
.
item_id
,
{
'id'
:
self
.
item_id
})
if
self
.
filename
!=
None
:
return
render_to_string
(
self
.
filename
,
{
'id'
:
self
.
item_id
})
else
:
xmltree
=
etree
.
fromstring
(
self
.
xml
)
textlist
=
[
xmltree
.
text
]
+
[
etree
.
tostring
(
i
)
for
i
in
xmltree
]
+
[
xmltree
.
tail
]
textlist
=
[
i
for
i
in
textlist
if
type
(
i
)
==
str
]
return
""
.
join
(
textlist
)
def
__init__
(
self
,
xml
,
item_id
,
ajax_url
=
None
,
track_url
=
None
,
state
=
None
):
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
)
XModule
.
__init__
(
self
,
xml
,
item_id
,
ajax_url
,
track_url
,
state
)
print
xml
xmltree
=
etree
.
fromstring
(
xml
)
self
.
filename
=
None
filename_l
=
xmltree
.
xpath
(
"/html/@filename"
)
if
len
(
filename_l
)
>
0
:
self
.
filename
=
str
(
filename_l
[
0
])
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