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
e489e061
Commit
e489e061
authored
Apr 04, 2017
by
Jesse Shapiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enforcing XBlock variable types
parent
34b145ad
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 @
e489e061
...
...
@@ -63,6 +63,7 @@ class DragAndDropBlock(
help
=
_
(
"The title of the drag and drop problem. The title is displayed to learners."
),
scope
=
Scope
.
settings
,
default
=
_
(
"Drag and Drop"
),
enforce_type
=
True
,
)
mode
=
String
(
...
...
@@ -78,7 +79,8 @@ class DragAndDropBlock(
{
"display_name"
:
_
(
"Standard"
),
"value"
:
Constants
.
STANDARD_MODE
},
{
"display_name"
:
_
(
"Assessment"
),
"value"
:
Constants
.
ASSESSMENT_MODE
},
],
default
=
Constants
.
STANDARD_MODE
default
=
Constants
.
STANDARD_MODE
,
enforce_type
=
True
,
)
max_attempts
=
Integer
(
...
...
@@ -89,6 +91,7 @@ class DragAndDropBlock(
),
scope
=
Scope
.
settings
,
default
=
None
,
enforce_type
=
True
,
)
show_title
=
Boolean
(
...
...
@@ -96,6 +99,7 @@ class DragAndDropBlock(
help
=
_
(
"Display the title to the learner?"
),
scope
=
Scope
.
settings
,
default
=
True
,
enforce_type
=
True
,
)
question_text
=
String
(
...
...
@@ -103,6 +107,7 @@ class DragAndDropBlock(
help
=
_
(
"The description of the problem or instructions shown to the learner."
),
scope
=
Scope
.
settings
,
default
=
""
,
enforce_type
=
True
,
)
show_question_header
=
Boolean
(
...
...
@@ -110,6 +115,7 @@ class DragAndDropBlock(
help
=
_
(
'Display the heading "Problem" above the problem text?'
),
scope
=
Scope
.
settings
,
default
=
True
,
enforce_type
=
True
,
)
weight
=
Float
(
...
...
@@ -117,6 +123,7 @@ class DragAndDropBlock(
help
=
_
(
"Defines the number of points the problem is worth."
),
scope
=
Scope
.
settings
,
default
=
1
,
enforce_type
=
True
,
)
item_background_color
=
String
(
...
...
@@ -124,6 +131,7 @@ class DragAndDropBlock(
help
=
_
(
"The background color of draggable items in the problem (example: 'blue' or '#0000ff')."
),
scope
=
Scope
.
settings
,
default
=
""
,
enforce_type
=
True
,
)
item_text_color
=
String
(
...
...
@@ -131,13 +139,15 @@ class DragAndDropBlock(
help
=
_
(
"Text color to use for draggable items (example: 'white' or '#ffffff')."
),
scope
=
Scope
.
settings
,
default
=
""
,
enforce_type
=
True
,
)
max_items_per_zone
=
Integer
(
display_name
=
_
(
"Maximum items per zone"
),
help
=
_
(
"This setting limits the number of items that can be dropped into a single zone."
),
scope
=
Scope
.
settings
,
default
=
None
default
=
None
,
enforce_type
=
True
,
)
data
=
Dict
(
...
...
@@ -149,24 +159,28 @@ class DragAndDropBlock(
),
scope
=
Scope
.
content
,
default
=
DEFAULT_DATA
,
enforce_type
=
True
,
)
item_state
=
Dict
(
help
=
_
(
"Information about current positions of items that a learner has dropped on the target image."
),
scope
=
Scope
.
user_state
,
default
=
{},
enforce_type
=
True
,
)
attempts
=
Integer
(
help
=
_
(
"Number of attempts learner used"
),
scope
=
Scope
.
user_state
,
default
=
0
default
=
0
,
enforce_type
=
True
,
)
completed
=
Boolean
(
help
=
_
(
"Indicates whether a learner has completed the problem at least once"
),
scope
=
Scope
.
user_state
,
default
=
False
,
enforce_type
=
True
,
)
grade
=
Float
(
...
...
@@ -178,7 +192,8 @@ class DragAndDropBlock(
raw_earned
=
Float
(
help
=
_
(
"Keeps maximum score achieved by student as a raw value between 0 and 1."
),
scope
=
Scope
.
user_state
,
default
=
0
default
=
0
,
enforce_type
=
True
,
)
block_settings_key
=
'drag-and-drop-v2'
...
...
pylintrc
View file @
e489e061
...
...
@@ -3,6 +3,7 @@ reports=no
[FORMAT]
max-line-length=120
max-module-lines=1500
[MESSAGES CONTROL]
disable=
...
...
tests/unit/test_basics.py
View file @
e489e061
...
...
@@ -236,6 +236,17 @@ class BasicTests(TestCaseMixin, unittest.TestCase):
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
):
""" Test the expand_static_url handler needed in Studio when changing the image """
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