Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-drag-and-drop-v2
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
xblock-drag-and-drop-v2
Commits
93fbea44
Commit
93fbea44
authored
Apr 06, 2017
by
Jesse Shapiro
Committed by
GitHub
Apr 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #104 from open-craft/haikuginger/enforce-types
Enforcing XBlock variable types
parents
c4ff2512
e489e061
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
4 deletions
+31
-4
drag_and_drop_v2/drag_and_drop_v2.py
+19
-4
pylintrc
+1
-0
tests/unit/test_basics.py
+11
-0
No files found.
drag_and_drop_v2/drag_and_drop_v2.py
View file @
93fbea44
...
@@ -63,6 +63,7 @@ class DragAndDropBlock(
...
@@ -63,6 +63,7 @@ class DragAndDropBlock(
help
=
_
(
"The title of the drag and drop problem. The title is displayed to learners."
),
help
=
_
(
"The title of the drag and drop problem. The title is displayed to learners."
),
scope
=
Scope
.
settings
,
scope
=
Scope
.
settings
,
default
=
_
(
"Drag and Drop"
),
default
=
_
(
"Drag and Drop"
),
enforce_type
=
True
,
)
)
mode
=
String
(
mode
=
String
(
...
@@ -78,7 +79,8 @@ class DragAndDropBlock(
...
@@ -78,7 +79,8 @@ class DragAndDropBlock(
{
"display_name"
:
_
(
"Standard"
),
"value"
:
Constants
.
STANDARD_MODE
},
{
"display_name"
:
_
(
"Standard"
),
"value"
:
Constants
.
STANDARD_MODE
},
{
"display_name"
:
_
(
"Assessment"
),
"value"
:
Constants
.
ASSESSMENT_MODE
},
{
"display_name"
:
_
(
"Assessment"
),
"value"
:
Constants
.
ASSESSMENT_MODE
},
],
],
default
=
Constants
.
STANDARD_MODE
default
=
Constants
.
STANDARD_MODE
,
enforce_type
=
True
,
)
)
max_attempts
=
Integer
(
max_attempts
=
Integer
(
...
@@ -89,6 +91,7 @@ class DragAndDropBlock(
...
@@ -89,6 +91,7 @@ class DragAndDropBlock(
),
),
scope
=
Scope
.
settings
,
scope
=
Scope
.
settings
,
default
=
None
,
default
=
None
,
enforce_type
=
True
,
)
)
show_title
=
Boolean
(
show_title
=
Boolean
(
...
@@ -96,6 +99,7 @@ class DragAndDropBlock(
...
@@ -96,6 +99,7 @@ class DragAndDropBlock(
help
=
_
(
"Display the title to the learner?"
),
help
=
_
(
"Display the title to the learner?"
),
scope
=
Scope
.
settings
,
scope
=
Scope
.
settings
,
default
=
True
,
default
=
True
,
enforce_type
=
True
,
)
)
question_text
=
String
(
question_text
=
String
(
...
@@ -103,6 +107,7 @@ class DragAndDropBlock(
...
@@ -103,6 +107,7 @@ class DragAndDropBlock(
help
=
_
(
"The description of the problem or instructions shown to the learner."
),
help
=
_
(
"The description of the problem or instructions shown to the learner."
),
scope
=
Scope
.
settings
,
scope
=
Scope
.
settings
,
default
=
""
,
default
=
""
,
enforce_type
=
True
,
)
)
show_question_header
=
Boolean
(
show_question_header
=
Boolean
(
...
@@ -110,6 +115,7 @@ class DragAndDropBlock(
...
@@ -110,6 +115,7 @@ class DragAndDropBlock(
help
=
_
(
'Display the heading "Problem" above the problem text?'
),
help
=
_
(
'Display the heading "Problem" above the problem text?'
),
scope
=
Scope
.
settings
,
scope
=
Scope
.
settings
,
default
=
True
,
default
=
True
,
enforce_type
=
True
,
)
)
weight
=
Float
(
weight
=
Float
(
...
@@ -117,6 +123,7 @@ class DragAndDropBlock(
...
@@ -117,6 +123,7 @@ class DragAndDropBlock(
help
=
_
(
"Defines the number of points the problem is worth."
),
help
=
_
(
"Defines the number of points the problem is worth."
),
scope
=
Scope
.
settings
,
scope
=
Scope
.
settings
,
default
=
1
,
default
=
1
,
enforce_type
=
True
,
)
)
item_background_color
=
String
(
item_background_color
=
String
(
...
@@ -124,6 +131,7 @@ class DragAndDropBlock(
...
@@ -124,6 +131,7 @@ class DragAndDropBlock(
help
=
_
(
"The background color of draggable items in the problem (example: 'blue' or '#0000ff')."
),
help
=
_
(
"The background color of draggable items in the problem (example: 'blue' or '#0000ff')."
),
scope
=
Scope
.
settings
,
scope
=
Scope
.
settings
,
default
=
""
,
default
=
""
,
enforce_type
=
True
,
)
)
item_text_color
=
String
(
item_text_color
=
String
(
...
@@ -131,13 +139,15 @@ class DragAndDropBlock(
...
@@ -131,13 +139,15 @@ class DragAndDropBlock(
help
=
_
(
"Text color to use for draggable items (example: 'white' or '#ffffff')."
),
help
=
_
(
"Text color to use for draggable items (example: 'white' or '#ffffff')."
),
scope
=
Scope
.
settings
,
scope
=
Scope
.
settings
,
default
=
""
,
default
=
""
,
enforce_type
=
True
,
)
)
max_items_per_zone
=
Integer
(
max_items_per_zone
=
Integer
(
display_name
=
_
(
"Maximum items per zone"
),
display_name
=
_
(
"Maximum items per zone"
),
help
=
_
(
"This setting limits the number of items that can be dropped into a single zone."
),
help
=
_
(
"This setting limits the number of items that can be dropped into a single zone."
),
scope
=
Scope
.
settings
,
scope
=
Scope
.
settings
,
default
=
None
default
=
None
,
enforce_type
=
True
,
)
)
data
=
Dict
(
data
=
Dict
(
...
@@ -149,24 +159,28 @@ class DragAndDropBlock(
...
@@ -149,24 +159,28 @@ class DragAndDropBlock(
),
),
scope
=
Scope
.
content
,
scope
=
Scope
.
content
,
default
=
DEFAULT_DATA
,
default
=
DEFAULT_DATA
,
enforce_type
=
True
,
)
)
item_state
=
Dict
(
item_state
=
Dict
(
help
=
_
(
"Information about current positions of items that a learner has dropped on the target image."
),
help
=
_
(
"Information about current positions of items that a learner has dropped on the target image."
),
scope
=
Scope
.
user_state
,
scope
=
Scope
.
user_state
,
default
=
{},
default
=
{},
enforce_type
=
True
,
)
)
attempts
=
Integer
(
attempts
=
Integer
(
help
=
_
(
"Number of attempts learner used"
),
help
=
_
(
"Number of attempts learner used"
),
scope
=
Scope
.
user_state
,
scope
=
Scope
.
user_state
,
default
=
0
default
=
0
,
enforce_type
=
True
,
)
)
completed
=
Boolean
(
completed
=
Boolean
(
help
=
_
(
"Indicates whether a learner has completed the problem at least once"
),
help
=
_
(
"Indicates whether a learner has completed the problem at least once"
),
scope
=
Scope
.
user_state
,
scope
=
Scope
.
user_state
,
default
=
False
,
default
=
False
,
enforce_type
=
True
,
)
)
grade
=
Float
(
grade
=
Float
(
...
@@ -178,7 +192,8 @@ class DragAndDropBlock(
...
@@ -178,7 +192,8 @@ class DragAndDropBlock(
raw_earned
=
Float
(
raw_earned
=
Float
(
help
=
_
(
"Keeps maximum score achieved by student as a raw value between 0 and 1."
),
help
=
_
(
"Keeps maximum score achieved by student as a raw value between 0 and 1."
),
scope
=
Scope
.
user_state
,
scope
=
Scope
.
user_state
,
default
=
0
default
=
0
,
enforce_type
=
True
,
)
)
block_settings_key
=
'drag-and-drop-v2'
block_settings_key
=
'drag-and-drop-v2'
...
...
pylintrc
View file @
93fbea44
...
@@ -3,6 +3,7 @@ reports=no
...
@@ -3,6 +3,7 @@ reports=no
[FORMAT]
[FORMAT]
max-line-length=120
max-line-length=120
max-module-lines=1500
[MESSAGES CONTROL]
[MESSAGES CONTROL]
disable=
disable=
...
...
tests/unit/test_basics.py
View file @
93fbea44
...
@@ -236,6 +236,17 @@ class BasicTests(TestCaseMixin, unittest.TestCase):
...
@@ -236,6 +236,17 @@ class BasicTests(TestCaseMixin, unittest.TestCase):
self
.
assertIsNone
(
self
.
block
.
max_items_per_zone
)
self
.
assertIsNone
(
self
.
block
.
max_items_per_zone
)
def
test_studio_submit_coerce_to_integer
(
self
):
# Validate that numbers submitted as strings are being
# coerced to integers rather than being saved as strings
def
modify_submission
(
submission
):
submission
[
'max_attempts'
]
=
'1234567890'
body
=
self
.
_make_submission
(
modify_submission
)
self
.
call_handler
(
'studio_submit'
,
body
)
self
.
assertEqual
(
self
.
block
.
max_attempts
,
1234567890
)
self
.
assertEqual
(
type
(
self
.
block
.
max_attempts
),
int
)
def
test_expand_static_url
(
self
):
def
test_expand_static_url
(
self
):
""" Test the expand_static_url handler needed in Studio when changing the image """
""" Test the expand_static_url handler needed in Studio when changing the image """
res
=
self
.
call_handler
(
'expand_static_url'
,
'/static/blah.png'
)
res
=
self
.
call_handler
(
'expand_static_url'
,
'/static/blah.png'
)
...
...
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