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
b8548d96
Commit
b8548d96
authored
Dec 07, 2015
by
Sven Marnach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename "String" cells to "Text" cells.
parent
41486ac4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
13 deletions
+13
-13
README.md
+1
-1
activetable/activetable.py
+1
-1
activetable/cells.py
+1
-1
activetable/parsers.py
+4
-4
tests/unit/test_cells.py
+3
-3
tests/unit/test_parsers.py
+3
-3
No files found.
README.md
View file @
b8548d96
...
...
@@ -43,7 +43,7 @@ tolerance specified above. The restrictions for the number of significant digit
well. Significant digits are counted started from the first non-zero digit specified by the
student, and include trailing zeros.
String
(answer='<correct answer>')
Text
(answer='<correct answer>')
A cell that expects a string answer.
...
...
activetable/activetable.py
View file @
b8548d96
...
...
@@ -36,7 +36,7 @@ class ActiveTableXBlock(StudioEditableXBlockMixin, XBlock):
default
=
textwrap
.
dedent
(
"""
\
[
['Column header 1', 'Column header 2'],
['Enter "answer" here:',
String
(answer='answer')],
['Enter "answer" here:',
Text
(answer='answer')],
[42, Numeric(answer=42, tolerance=0.0)],
]
"""
)
...
...
activetable/cells.py
View file @
b8548d96
...
...
@@ -63,7 +63,7 @@ class NumericCell(Cell):
return
abs
(
value
-
self
.
answer
)
<=
self
.
abs_tolerance
class
String
Cell
(
Cell
):
class
Text
Cell
(
Cell
):
"""A string response cell."""
placeholder
=
'text response'
...
...
activetable/parsers.py
View file @
b8548d96
...
...
@@ -5,7 +5,7 @@ from __future__ import absolute_import, division, unicode_literals
import
ast
import
numbers
from
.cells
import
NumericCell
,
StaticCell
,
String
Cell
from
.cells
import
NumericCell
,
StaticCell
,
Text
Cell
class
ParseError
(
Exception
):
...
...
@@ -63,7 +63,7 @@ def parse_table(table_definition):
def
_parse_response_cell
(
cell_node
):
"""Parse a single student response cell definition.
Response cells are written in function call syntax, either
String
(...) or Numeric(...). All
Response cells are written in function call syntax, either
Text
(...) or Numeric(...). All
arguments must be keyword arguments.
"""
cell_type
=
_ensure_type
(
cell_node
.
func
,
ast
.
Name
)
.
id
...
...
@@ -71,8 +71,8 @@ def _parse_response_cell(cell_node):
raise
ParseError
(
'all arguments to {} must be keyword arguments of the form name=value'
.
format
(
cell_type
)
)
if
cell_type
==
'
String
'
:
cell_class
=
String
Cell
if
cell_type
==
'
Text
'
:
cell_class
=
Text
Cell
kwargs
=
{
kw
.
arg
:
_ensure_type
(
kw
.
value
,
ast
.
Str
)
.
s
for
kw
in
cell_node
.
keywords
}
elif
cell_type
==
'Numeric'
:
cell_class
=
NumericCell
...
...
tests/unit/test_cells.py
View file @
b8548d96
...
...
@@ -3,7 +3,7 @@ from __future__ import absolute_import, division, unicode_literals
import
unittest
from
activetable.cells
import
NumericCell
,
String
Cell
from
activetable.cells
import
NumericCell
,
Text
Cell
class
CellTest
(
unittest
.
TestCase
):
...
...
@@ -30,9 +30,9 @@ class CellTest(unittest.TestCase):
self
.
assertFalse
(
cell
.
check_response
(
'6.2382'
))
def
test_string_cell
(
self
):
cell
=
String
Cell
(
'OpenCraft'
)
cell
=
Text
Cell
(
'OpenCraft'
)
self
.
assertTrue
(
cell
.
check_response
(
'OpenCraft'
))
self
.
assertTrue
(
cell
.
check_response
(
' OpenCraft
\t\r\n
'
))
self
.
assertFalse
(
cell
.
check_response
(
'giraffe'
))
cell
=
String
Cell
(
'ÖpenCräft'
)
cell
=
Text
Cell
(
'ÖpenCräft'
)
self
.
assertTrue
(
cell
.
check_response
(
'ÖpenCräft'
))
tests/unit/test_parsers.py
View file @
b8548d96
...
...
@@ -4,7 +4,7 @@ from __future__ import absolute_import, division, unicode_literals
import
ddt
import
unittest
from
activetable.cells
import
Cell
,
NumericCell
,
StaticCell
,
String
Cell
from
activetable.cells
import
Cell
,
NumericCell
,
StaticCell
,
Text
Cell
from
activetable.parsers
import
ParseError
,
parse_table
,
parse_number_list
@ddt.ddt
...
...
@@ -15,12 +15,12 @@ class ParserTest(unittest.TestCase):
[
['Event', 'Year'],
['French Revolution', Numeric(answer=1789)],
['Volcano exploded in 1883',
String
(answer='Krakatoa')],
['Volcano exploded in 1883',
Text
(answer='Krakatoa')],
[6.283, 123],
]
"""
thead
,
tbody
=
parse_table
(
table_definition
)
expected
=
eval
(
table_definition
.
strip
(),
dict
(
Numeric
=
NumericCell
,
String
=
String
Cell
))
expected
=
eval
(
table_definition
.
strip
(),
dict
(
Numeric
=
NumericCell
,
Text
=
Text
Cell
))
expected_body
=
[]
for
i
,
row
in
enumerate
(
expected
[
1
:],
1
):
cells
=
[]
...
...
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