Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-activetable
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
xblock-activetable
Commits
41486ac4
Commit
41486ac4
authored
Dec 07, 2015
by
Sven Marnach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address Ned's review notes.
parent
4de83756
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
9 deletions
+13
-9
activetable/activetable.py
+6
-5
activetable/cells.py
+3
-3
activetable/parsers.py
+1
-1
tests/unit/test_cells.py
+3
-0
No files found.
activetable/activetable.py
View file @
41486ac4
...
...
@@ -28,7 +28,8 @@ class ActiveTableXBlock(StudioEditableXBlockMixin, XBlock):
)
content
=
String
(
display_name
=
'Table definition'
,
help
=
'The definition of the table in Python-like syntax.'
,
help
=
'The definition of the table in Python-like syntax. Note that changing the table '
'definition of a live problem will invalidate all student answers.'
,
scope
=
Scope
.
content
,
multiline_editor
=
True
,
resettable_editor
=
False
,
...
...
@@ -53,8 +54,8 @@ class ActiveTableXBlock(StudioEditableXBlockMixin, XBlock):
column_widths
=
String
(
display_name
=
'Column widths'
,
help
=
'Set the width of the columns in pixels. The value should be a Python-like list of '
'numerical values. The total width of the table should not be more than 800.
No value
'
'will result in equal-width columns with a total width of 800 pixels.'
,
'numerical values. The total width of the table should not be more than 800.
Omitting
'
'
this value
will result in equal-width columns with a total width of 800 pixels.'
,
scope
=
Scope
.
content
,
resettable_editor
=
False
,
)
...
...
@@ -68,7 +69,7 @@ class ActiveTableXBlock(StudioEditableXBlockMixin, XBlock):
)
default_tolerance
=
Float
(
display_name
=
'Default tolerance'
,
help
=
'The tolerance in pecent that is used for numerical response cells you did not '
help
=
'The tolerance in pe
r
cent that is used for numerical response cells you did not '
'specify an explicit tolerance for.'
,
scope
=
Scope
.
content
,
default
=
1.0
,
...
...
@@ -148,7 +149,7 @@ class ActiveTableXBlock(StudioEditableXBlockMixin, XBlock):
self
.
response_cells
=
{}
for
row
,
height
in
zip
(
self
.
tbody
,
self
.
_row_heights
[
1
:]):
row
[
'height'
]
=
height
if
row
[
'index'
]
&
1
:
if
row
[
'index'
]
%
2
:
row
[
'class'
]
=
'even'
else
:
row
[
'class'
]
=
'odd'
...
...
activetable/cells.py
View file @
41486ac4
...
...
@@ -13,6 +13,8 @@ import decimal
class
Cell
(
object
):
"""Abstract base class for all cells."""
is_static
=
False
def
__eq__
(
self
,
other
):
"""Test for equality based on type and attribute values."""
return
type
(
self
)
is
type
(
other
)
and
vars
(
self
)
==
vars
(
other
)
...
...
@@ -30,7 +32,6 @@ class StaticCell(Cell):
class
NumericCell
(
Cell
):
"""A numeric response cell."""
is_static
=
False
placeholder
=
'numeric response'
def
__init__
(
self
,
answer
,
tolerance
=
None
,
...
...
@@ -65,7 +66,6 @@ class NumericCell(Cell):
class
StringCell
(
Cell
):
"""A string response cell."""
is_static
=
False
placeholder
=
'text response'
def
__init__
(
self
,
answer
):
...
...
@@ -74,4 +74,4 @@ class StringCell(Cell):
def
check_response
(
self
,
student_response
):
"""Return a Boolean value indicating whether the student response is correct."""
return
student_response
==
self
.
answer
return
student_response
.
strip
()
==
self
.
answer
.
strip
()
activetable/parsers.py
View file @
41486ac4
...
...
@@ -81,7 +81,7 @@ def _parse_response_cell(cell_node):
raise
ParseError
(
'invalid cell input type: {}'
.
format
(
cell_type
))
try
:
return
cell_class
(
**
kwargs
)
except
TypeError
as
exc
:
except
Exception
as
exc
:
raise
ParseError
(
exc
.
message
)
...
...
tests/unit/test_cells.py
View file @
41486ac4
...
...
@@ -32,4 +32,7 @@ class CellTest(unittest.TestCase):
def
test_string_cell
(
self
):
cell
=
StringCell
(
'OpenCraft'
)
self
.
assertTrue
(
cell
.
check_response
(
'OpenCraft'
))
self
.
assertTrue
(
cell
.
check_response
(
' OpenCraft
\t\r\n
'
))
self
.
assertFalse
(
cell
.
check_response
(
'giraffe'
))
cell
=
StringCell
(
'ÖpenCräft'
)
self
.
assertTrue
(
cell
.
check_response
(
'ÖpenCräft'
))
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