Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
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
OpenEdx
problem-builder
Commits
d2577cd2
Commit
d2577cd2
authored
Dec 16, 2013
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use lazy attribute instead of unsupported __init__() on answer block
parent
972015f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
mentoring/answer.py
+15
-7
No files found.
mentoring/answer.py
View file @
d2577cd2
...
...
@@ -5,6 +5,8 @@
import
logging
from
lazy
import
lazy
from
xblock.core
import
XBlock
from
xblock.fields
import
Boolean
,
Scope
,
String
from
xblock.fragment
import
Fragment
...
...
@@ -27,22 +29,28 @@ class AnswerBlock(XBlock):
Must be included as a child of a mentoring block. Answers are persisted as django model instances
to make them searchable and referenceable across xblocks.
"""
student_input
=
String
(
help
=
"Last input submitted by the student"
,
default
=
""
,
scope
=
Scope
.
user_state
)
read_only
=
Boolean
(
help
=
"Display as a read-only field"
,
default
=
False
,
scope
=
Scope
.
content
)
default_from
=
String
(
help
=
"If specified, the name of the answer to get the default value from"
,
default
=
None
,
scope
=
Scope
.
content
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
AnswerBlock
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
@lazy
def
student_input
(
self
):
"""
Use lazy property instead of XBlock field, as __init__() doesn't support
overwriting field values
"""
student_input
=
''
# Only attempt to locate a model object for this block when the answer has a name
if
self
.
name
:
s
elf
.
s
tudent_input
=
self
.
get_model_object
()
.
student_input
student_input
=
self
.
get_model_object
()
.
student_input
# Default value can be set from another answer's current value
if
not
self
.
student_input
and
self
.
default_from
:
self
.
student_input
=
self
.
get_model_object
(
name
=
self
.
default_from
)
.
student_input
if
not
student_input
and
self
.
default_from
:
student_input
=
self
.
get_model_object
(
name
=
self
.
default_from
)
.
student_input
return
student_input
def
student_view
(
self
,
context
=
None
):
# pylint: disable=W0613
"""Returns default student view."""
return
Fragment
(
u"<p>I can only appear inside mentoring blocks.</p>"
)
...
...
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