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
e5fa0c5d
Commit
e5fa0c5d
authored
May 08, 2014
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add max-attempts to inheritance.py (LMS-2130)
parent
d9817117
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
12 deletions
+24
-12
common/lib/xmodule/xmodule/modulestore/inheritance.py
+10
-2
common/lib/xmodule/xmodule/tests/test_xml_module.py
+14
-10
No files found.
common/lib/xmodule/xmodule/modulestore/inheritance.py
View file @
e5fa0c5d
...
...
@@ -5,7 +5,7 @@ Support for inheritance of fields down an XBlock hierarchy.
from
datetime
import
datetime
from
pytz
import
UTC
from
xblock.fields
import
Scope
,
Boolean
,
String
,
Float
,
XBlockMixin
,
Dict
from
xblock.fields
import
Scope
,
Boolean
,
String
,
Float
,
XBlockMixin
,
Dict
,
Integer
from
xblock.runtime
import
KeyValueStore
,
KvsFieldData
from
xmodule.fields
import
Date
,
Timedelta
...
...
@@ -78,7 +78,15 @@ class InheritanceMixin(XBlockMixin):
use_latex_compiler
=
Boolean
(
help
=
"Enable LaTeX templates?"
,
default
=
False
,
scope
=
Scope
.
settings
)
scope
=
Scope
.
settings
)
max_attempts
=
Integer
(
display_name
=
"Maximum Attempts"
,
help
=
(
"Defines the number of times a student can try to answer this problem. "
"If the value is not set, infinite attempts are allowed."
),
values
=
{
"min"
:
0
},
scope
=
Scope
.
settings
)
def
compute_inherited_metadata
(
descriptor
):
...
...
common/lib/xmodule/xmodule/tests/test_xml_module.py
View file @
e5fa0c5d
...
...
@@ -538,14 +538,14 @@ class TestXmlAttributes(XModuleXmlImportTest):
# name)
assert_in
(
'attempts'
,
seq
.
xml_attributes
)
def
test_inheritable_attribute
(
self
):
#
days_early_for_beta
isn't a basic attribute of Sequence
assert_false
(
hasattr
(
SequenceDescriptor
,
'days_early_for_beta'
))
def
check_inheritable_attribute
(
self
,
attribute
,
value
):
#
`attribute`
isn't a basic attribute of Sequence
assert_false
(
hasattr
(
SequenceDescriptor
,
attribute
))
#
days_early_for_beta
is added by InheritanceMixin
assert_true
(
hasattr
(
InheritanceMixin
,
'days_early_for_beta'
))
#
`attribute`
is added by InheritanceMixin
assert_true
(
hasattr
(
InheritanceMixin
,
attribute
))
root
=
SequenceFactory
.
build
(
policy
=
{
'days_early_for_beta'
:
'2'
})
root
=
SequenceFactory
.
build
(
policy
=
{
attribute
:
str
(
value
)
})
ProblemFactory
.
build
(
parent
=
root
)
# InheritanceMixin will be used when processing the XML
...
...
@@ -556,10 +556,14 @@ class TestXmlAttributes(XModuleXmlImportTest):
assert_equals
(
seq
.
unmixed_class
,
SequenceDescriptor
)
assert_not_equals
(
type
(
seq
),
SequenceDescriptor
)
#
days_early_for_beta
is added to the constructed sequence, because
#
`attribute`
is added to the constructed sequence, because
# it's in the InheritanceMixin
assert_equals
(
2
,
seq
.
days_early_for_beta
)
assert_equals
(
value
,
getattr
(
seq
,
attribute
)
)
#
days_early_for_beta
is a known attribute, so we shouldn't include it
#
`attribute`
is a known attribute, so we shouldn't include it
# in xml_attributes
assert_not_in
(
'days_early_for_beta'
,
seq
.
xml_attributes
)
assert_not_in
(
attribute
,
seq
.
xml_attributes
)
def
test_inheritable_attributes
(
self
):
self
.
check_inheritable_attribute
(
'days_early_for_beta'
,
2
)
self
.
check_inheritable_attribute
(
'max_attempts'
,
5
)
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