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
7dca95f7
Commit
7dca95f7
authored
Jul 03, 2014
by
Filippo Valsorda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic support for the builder in Studio
parent
bfd34fef
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
485 additions
and
29 deletions
+485
-29
drag_and_drop_v2/drag_and_drop_v2.py
+8
-4
drag_and_drop_v2/public/css/drag_and_drop_edit.css
+417
-0
drag_and_drop_v2/public/js/drag_and_drop_edit.js
+0
-0
drag_and_drop_v2/templates/html/drag_and_drop.html
+0
-3
drag_and_drop_v2/templates/html/drag_and_drop_edit.html
+60
-22
No files found.
drag_and_drop_v2/drag_and_drop_v2.py
View file @
7dca95f7
...
...
@@ -43,7 +43,7 @@ class DragAndDropBlock(XBlock):
display_name
=
"Drag and Drop"
,
help
=
"JSON spec as generated by the builder"
,
scope
=
Scope
.
content
,
default
=
'{"feedback":{"start":"Intro","finish":"Final"},"items":[{"displayName":"A","zone":"Uno","id":0,"feedback":{"correct":"Si","incorrect":"No"},"size":{"width":"190px","height":"auto"},"backgroundImage":""},{"displayName":"B","zone":"none","id":1,"feedback":{"correct":"","incorrect":""},"size":{"width":"190px","height":"auto"},"backgroundImage":""}],"zones":[{"title":"Uno","id":"zone-1","active":true,"index":1,"width":200,"height":100,"x":0,"y":0},{"title":"Due","id":"zone-2","active":true,"index":2,"width":200,"height":100,"x":"300","y":"210"}],"targetImg":"http
://i0.kym-cdn.com/photos/images/newsfeed/000/030/404/1260585284155.png?1318992465
"}'
default
=
'{"feedback":{"start":"Intro","finish":"Final"},"items":[{"displayName":"A","zone":"Uno","id":0,"feedback":{"correct":"Si","incorrect":"No"},"size":{"width":"190px","height":"auto"},"backgroundImage":""},{"displayName":"B","zone":"none","id":1,"feedback":{"correct":"","incorrect":""},"size":{"width":"190px","height":"auto"},"backgroundImage":""}],"zones":[{"title":"Uno","id":"zone-1","active":true,"index":1,"width":200,"height":100,"x":0,"y":0},{"title":"Due","id":"zone-2","active":true,"index":2,"width":200,"height":100,"x":"300","y":"210"}],"targetImg":"http
s://i.imgur.com/PoI27ox.png
"}'
# default=textwrap.dedent("""
# {
# feedback: {},
...
...
@@ -79,10 +79,14 @@ class DragAndDropBlock(XBlock):
"""
Editing view in Studio
"""
context
=
{}
fragment
=
Fragment
()
fragment
.
add_content
(
render_template
(
'/templates/html/drag_and_drop_edit.html'
,
{
'self'
:
self
,
}))
fragment
.
add_content
(
render_template
(
'/templates/html/drag_and_drop_edit.html'
,
context
))
fragment
.
add_css
(
load_resource
(
'public/css/drag_and_drop_edit.css'
))
fragment
.
add_javascript
(
load_resource
(
'public/js/vendor/jquery.html5-placeholder-shim.js'
))
fragment
.
add_javascript
(
load_resource
(
'public/js/vendor/underscore1.6.0.js'
))
fragment
.
add_javascript
(
load_resource
(
'public/js/drag_and_drop_edit.js'
))
fragment
.
initialize_js
(
'DragAndDropEditBlock'
)
...
...
drag_and_drop_v2/public/css/drag_and_drop_edit.css
0 → 100644
View file @
7dca95f7
/*** xBlock styles ***/
.xblock--drag-and-drop
{
width
:
100%
;
margin
:
0
;
padding
:
0
;
background
:
#fff
;
}
.xblock--drag-and-drop
h1
,
.xblock--drag-and-drop
h2
,
.xblock--drag-and-drop
h3
,
.xblock--drag-and-drop
h4
,
.xblock--drag-and-drop
h5
,
.xblock--drag-and-drop
h6
,
.xblock--drag-and-drop
p
,
.xblock--drag-and-drop
li
,
.xblock--drag-and-drop
a
{
font-family
:
Arial
;
}
.xblock--drag-and-drop
h1
{
color
:
#adadad
;
}
.xblock--drag-and-drop
h2
{
color
:
#333
;
margin
:
0
;
text-transform
:
uppercase
;
}
.xblock--drag-and-drop
header
p
,
.xblock--drag-and-drop
footer
p
{
color
:
#adadad
;
line-height
:
1.5em
;
}
.xblock--drag-and-drop
.small
{
font-size
:
0.6em
;
}
.xblock--drag-and-drop
.drag-container
{
width
:
760px
;
background
:
#ebf0f2
;
position
:
relative
;
}
/** Draggable Items **/
.xblock--drag-and-drop
.items
{
width
:
210px
;
margin
:
10px
;
padding
:
0
;
font-size
:
14px
;
position
:
relative
;
display
:
inline
;
float
:
left
;
list-style-type
:
none
;
}
.xblock--drag-and-drop
.items
.option
{
width
:
190px
;
background
:
#2e83cd
;
color
:
#fff
;
position
:
relative
;
float
:
left
;
display
:
inline
;
z-index
:
100
;
margin-bottom
:
5px
;
padding
:
10px
;
}
.xblock--drag-and-drop
.option.hover
{
background
:
#ccc
;
}
.xblock--drag-and-drop
.option.fade
{
opacity
:
0.6
;
}
/*** Drop Target ***/
.xblock--drag-and-drop
.target
{
width
:
515px
;
height
:
510px
;
position
:
relative
;
display
:
inline
;
float
:
left
;
margin
:
10px
0
15px
5px
;
background
:
#fff
;
z-index
:
1
;
}
.xblock--drag-and-drop
.target-img
{
background
:
url(../img/triangle.png)
no-repeat
;
width
:
100%
;
height
:
100%
;
}
.xblock--drag-and-drop
.zone
{
/*border: 1px solid #000;*/
position
:
absolute
;
display
:
-webkit-box
;
display
:
-moz-box
;
display
:
-ms-flexbox
;
display
:
-webkit-flex
;
display
:
flex
;
/* Internet Explorer 10 */
-ms-flex-pack
:
center
;
-ms-flex-align
:
center
;
/* Firefox */
-moz-box-pack
:
center
;
-moz-box-align
:
center
;
/* Safari, Opera, and Chrome */
-webkit-box-pack
:
center
;
-webkit-box-align
:
center
;
/* W3C */
box-pack
:
center
;
box-align
:
center
;
}
.xblock--drag-and-drop
.zone
p
{
width
:
100%
;
font-family
:
Arial
;
font-size
:
16px
;
font-weight
:
bold
;
text-align
:
center
;
text-transform
:
uppercase
;
margin-top
:
auto
;
margin-bottom
:
auto
;
}
.xblock--drag-and-drop
.zone.one
{
height
:
75px
;
width
:
115px
;
top
:
130px
;
left
:
200px
;
}
.xblock--drag-and-drop
.zone.two
{
height
:
120px
;
width
:
200px
;
top
:
220px
;
left
:
157px
;
}
.xblock--drag-and-drop
.zone.three
{
height
:
120px
;
width
:
200px
;
bottom
:
30px
;
left
:
157px
;
}
/*** IE9 alignment fix ***/
.lt-ie10
.xblock--drag-and-drop
.zone
{
display
:
table
;
}
.lt-ie10
.xblock--drag-and-drop
.zone
p
{
display
:
table-cell
;
vertical-align
:
middle
;
text-align
:
center
;
}
/*** FEEDBACK ***/
.xblock--drag-and-drop
.feedback
{
width
:
740px
;
border-top
:
#ccc
1px
solid
;
margin
:
20px
10px
;
padding-top
:
10px
;
}
.xblock--drag-and-drop
.feedback
.message
{
margin
:
5px
0
0
;
}
/** Builder **/
.xblock--drag-and-drop
.hidden
{
display
:
none
!important
;
}
.xblock--drag-and-drop
.drag-builder
{
/* TODO */
height
:
375px
;
overflow
:
scroll
;
}
.xblock--drag-and-drop
.drag-builder
.tab
{
width
:
100%
;
background
:
#eee
;
padding
:
3px
0
;
position
:
relative
;
}
.xblock--drag-and-drop
.drag-builder
.tab
:after
,
.xblock--drag-and-drop
.drag-builder
.tab-footer
:after
,
.xblock--drag-and-drop
.drag-builder
.target
:after
{
content
:
""
;
display
:
table
;
clear
:
both
;
}
.xblock--drag-and-drop
.drag-builder
.tab
h3
{
margin
:
10px
0
;
}
.xblock--drag-and-drop
.drag-builder
.tab-header
,
.xblock--drag-and-drop
.drag-builder
.tab-content
,
.xblock--drag-and-drop
.drag-builder
.tab-footer
{
width
:
96%
;
margin
:
2%
;
}
.xblock--drag-and-drop
.drag-builder
.tab-footer
{
height
:
25px
;
position
:
relative
;
display
:
block
;
float
:
left
;
}
.xblock--drag-and-drop
.drag-builder
.continue
{
position
:
absolute
;
right
:
0
;
top
:
-5px
;
}
.xblock--drag-and-drop
.drag-builder
.items
{
width
:
calc
(
100%
-
515px
);
margin
:
10px
0
0
0
;
}
.xblock--drag-and-drop
.drag-builder
.target
{
margin-left
:
0
;
}
.xblock--drag-and-drop
.zones-form
.zone-row
label
{
display
:
inline-block
;
width
:
18%
;
}
.xblock--drag-and-drop
.zones-form
.zone-row
.title
{
width
:
60%
;
margin
:
0
0
5px
;
}
.xblock--drag-and-drop
.zones-form
.zone-row
.layout
{
margin-bottom
:
15px
;
}
.xblock--drag-and-drop
.zones-form
.zone-row
.layout
.size
,
.xblock--drag-and-drop
.zones-form
.zone-row
.layout
.coord
{
width
:
15%
;
margin
:
0
19px
5px
0
;
}
.xblock--drag-and-drop
.drag-builder
.target
{
margin-bottom
:
40px
;
}
.xblock--drag-and-drop
.drag-builder
.zone
{
width
:
200px
;
height
:
100px
;
border
:
1px
dotted
#666
;
}
.xblock--drag-and-drop
.feedback-form
textarea
{
width
:
99%
;
height
:
128px
;
margin-bottom
:
30px
;
}
.xblock--drag-and-drop
.items-form
{
margin-bottom
:
30px
;
}
.xblock--drag-and-drop
.items-form
.item
{
background
:
#73bde7
;
padding
:
10px
0
1px
;
margin
:
15px
0
;
}
.xblock--drag-and-drop
.items-form
label
{
margin
:
0
1%
;
}
.xblock--drag-and-drop
.items-form
input
,
.xblock--drag-and-drop
.items-form
select
{
width
:
35%
;
}
.xblock--drag-and-drop
.items-form
.item-width
,
.xblock--drag-and-drop
.items-form
.item-height
{
width
:
40px
;
}
.xblock--drag-and-drop
.items-form
textarea
{
width
:
97%
;
margin
:
0
1%
;
}
.xblock--drag-and-drop
.items-form
.row
{
margin-bottom
:
20px
;
}
/** Buttons **/
.xblock--drag-and-drop
.btn
{
background
:
#2e83cd
;
color
:
#fff
;
border
:
1px
solid
#156ab4
;
border-radius
:
6px
;
padding
:
5px
10px
;
}
.xblock--drag-and-drop
.btn
:hover
{
opacity
:
0.8
;
cursor
:
pointer
;
}
.xblock--drag-and-drop
.btn
:focus
{
outline
:
none
;
opacity
:
0.5
;
}
.xblock--drag-and-drop
.add-element
{
text-decoration
:
none
;
color
:
#2e83cd
;
}
.xblock--drag-and-drop
.remove-zone
{
float
:
right
;
margin-top
:
2px
;
margin-right
:
16px
;
}
.xblock--drag-and-drop
.remove-item
{
display
:
inline-block
;
margin-left
:
95px
;
}
.xblock--drag-and-drop
.icon
{
width
:
14px
;
height
:
14px
;
border-radius
:
7px
;
background
:
#2e83cd
;
position
:
relative
;
float
:
left
;
margin
:
0
5px
0
0
;
}
.xblock--drag-and-drop
.add-zone
:hover
,
.xblock--drag-and-drop
.add-zone
:hover
.icon
,
.xblock--drag-and-drop
.remove-zone
:hover
,
.xblock--drag-and-drop
.remove-zone
:hover
.icon
{
opacity
:
0.7
;
}
.xblock--drag-and-drop
.icon.add
:before
{
content
:
''
;
height
:
10px
;
width
:
2px
;
background
:
#fff
;
position
:
relative
;
display
:
inline
;
float
:
left
;
top
:
2px
;
left
:
6px
;
}
.xblock--drag-and-drop
.icon.add
:after
{
content
:
''
;
height
:
2px
;
width
:
10px
;
background
:
#fff
;
position
:
relative
;
display
:
inline
;
float
:
left
;
top
:
6px
;
left
:
0
;
}
.xblock--drag-and-drop
.icon.remove
:before
{
content
:
''
;
height
:
10px
;
width
:
2px
;
background
:
#fff
;
position
:
relative
;
display
:
inline
;
float
:
left
;
top
:
2px
;
left
:
6px
;
-webkit-transform
:
rotate
(
45deg
);
-ms-transform
:
rotate
(
45deg
);
transform
:
rotate
(
45deg
);
}
.xblock--drag-and-drop
.icon.remove
:after
{
content
:
''
;
height
:
2px
;
width
:
10px
;
background
:
#fff
;
position
:
relative
;
display
:
inline
;
float
:
left
;
top
:
6px
;
left
:
0
;
-webkit-transform
:
rotate
(
45deg
);
-ms-transform
:
rotate
(
45deg
);
transform
:
rotate
(
45deg
);
}
.xblock--drag-and-drop
.remove-item
.icon.remove
{
background
:
#fff
;
}
.xblock--drag-and-drop
.remove-item
.icon.remove
:before
,
.xblock--drag-and-drop
.remove-item
.icon.remove
:after
{
background
:
#2e83cd
;
}
drag_and_drop_v2/public/js/drag_and_drop_edit.js
View file @
7dca95f7
This diff is collapsed.
Click to expand it.
drag_and_drop_v2/templates/html/drag_and_drop.html
View file @
7dca95f7
...
...
@@ -26,7 +26,4 @@
<div
class=
"clear"
></div>
</section>
<script
type=
"text/javascript"
src=
"https://code.jquery.com/jquery-1.10.2.js"
></script>
<script
type=
"text/javascript"
src=
"https://code.jquery.com/ui/1.10.4/jquery-ui.js"
></script>
</section>
drag_and_drop_v2/templates/html/drag_and_drop_edit.html
View file @
7dca95f7
{% load i18n %}
<!-- TODO: Replace by default edit view once available in Studio -->
<div
class=
"wrapper-comp-settings is-active editor-with-buttons "
id=
"settings-tab"
>
<ul
class=
"list-input settings-list"
>
<li
class=
"field comp-setting-entry is-set"
>
<div
class=
"wrapper-comp-setting"
>
<label
class=
"label setting-label"
for=
"edit_display_name"
>
Title
</label>
<input
class=
"input setting-input edit-display-name"
id=
"edit_display_name"
value=
"{{ self.display_name }}"
type=
"text"
>
<div
class=
"xblock--drag-and-drop editor-with-buttons"
>
<link
rel=
"stylesheet"
href=
"https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"
>
<section
class=
"drag-builder"
>
<div
class=
"tab feedback-tab"
>
<section
class=
"tab-content"
>
<form
class=
"feedback-form"
>
<h3>
Question title
</h3>
<input
class=
"display-name"
/>
<h3>
Question text
</h3>
<textarea
class=
"question-text"
></textarea>
<h3>
Introduction Feedback
</h3>
<textarea
class=
"intro-feedback"
></textarea>
<h3>
Final Feedback
</h3>
<textarea
class=
"final-feedback"
></textarea>
</form>
</section>
<!-- <footer class="tab-footer">
<button class="btn continue goto-zones">Continue</button>
</footer> -->
</div>
<span
class=
"tip setting-help"
>
The title of the Drag and Drop that is displayed to the user
</span>
</li>
<li
class=
"field comp-setting-entry is-set"
>
<div
class=
"wrapper-comp-setting"
>
<label
class=
"label setting-label"
for=
"edit_question_text"
>
Question text
</label>
<input
class=
"input setting-input edit-question-text"
id=
"edit_question_text"
value=
"{{ self.question_text }}"
type=
"text"
>
<div
class=
"tab zones-tab hidden"
>
<header
class=
"tab-header"
>
<h3>
Zone Positions
</h3>
</header>
<section
class=
"tab-content"
>
<div
class=
"items"
>
<form
class=
"zones-form"
></form>
<a
href=
"#"
class=
"add-zone add-element"
><div
class=
"icon add"
></div>
Add a zone
</a>
</div>
<span
class=
"tip setting-help"
>
The question text that is displayed to the user
</span>
</li>
<li
class=
"field comp-setting-entry is-set"
>
<div
class=
"wrapper-comp-setting"
>
<label
class=
"label setting-label"
for=
"edit_data"
>
Title
</label>
<input
class=
"input setting-input edit-data"
id=
"edit_data"
value=
"{{ self.data }}"
type=
"text"
>
<div
class=
"target"
>
<div
class=
"target-img"
></div>
</div>
<span
class=
"tip setting-help"
>
JSON spec as generated by the builder
</span>
</li>
</ul>
</section>
<!-- <footer class="tab-footer">
<button class="btn continue goto-items">Continue</button>
</footer> -->
</div>
<div
class=
"tab items-tab hidden"
>
<header
class=
"tab-header"
>
<h3>
Items
</h3>
</header>
<section
class=
"tab-content"
>
<form
class=
"items-form"
></form>
</section>
<footer
class=
"tab-footer"
>
<a
href=
"#"
class=
"add-item add-element"
><div
class=
"icon add"
></div>
Add an item
</a>
<!-- <button class="btn continue goto-exercise">Finish</button> -->
</footer>
</div>
</section>
<div
class=
"xblock-actions"
>
<span
class=
"xblock-editor-error-message"
></span>
<ul>
<li
class=
"action-item"
>
<a
href=
"#"
class=
"button action-primary continue-button"
>
{% trans "Continue" %}
</a>
</li>
<li
class=
"action-item hidden"
>
<a
href=
"#"
class=
"button action-primary save-button"
>
{% trans "Save" %}
</a>
</li>
...
...
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