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
e76083e7
Commit
e76083e7
authored
Dec 25, 2011
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Textbook, Preparing for randomized
parent
e25939ac
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
courseware/capa_module.py
+33
-0
No files found.
courseware/capa_module.py
View file @
e76083e7
...
...
@@ -110,6 +110,10 @@ class LoncapaModule(XModule):
else
:
self
.
max_attempts
=
None
self
.
show_answer
=
node
.
getAttribute
(
"showanswer"
)
if
self
.
show_answer
==
""
:
self
.
show_answer
=
"closed"
if
state
!=
None
:
state
=
json
.
loads
(
state
)
if
state
!=
None
and
'attempts'
in
state
:
...
...
@@ -131,10 +135,39 @@ class LoncapaModule(XModule):
response
=
self
.
reset_problem
(
get
)
elif
dispatch
==
'problem_save'
:
response
=
self
.
save_problem
(
get
)
elif
dispatch
==
'get_answer'
:
response
=
self
.
get_answer
(
get
)
else
:
return
"Error"
return
response
def
answer_available
(
self
):
''' Is the user allowed to see an answer?
'''
if
self
.
show_answer
==
''
:
return
False
if
self
.
show_answer
==
"never"
:
return
False
if
self
.
show_answer
==
'attempted'
and
self
.
attempts
==
0
:
return
False
if
self
.
show_answer
==
'attempted'
and
self
.
attempts
>
0
:
return
True
if
self
.
show_answer
==
'answered'
and
self
.
lcp
.
done
:
return
True
if
self
.
show_answer
==
'answered'
and
not
self
.
lcp
.
done
:
return
False
if
self
.
show_answer
==
'closed'
and
self
.
closed
():
return
True
if
self
.
show_answer
==
'closed'
and
not
self
.
closed
():
return
False
raise
Http404
def
get_answer
(
self
,
get
):
if
not
self
.
answer_available
():
raise
Http404
else
:
raise
Http404
# Figure out if we should move these to capa_problem?
def
get_problem
(
self
,
get
):
...
...
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