Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
57bc010a
Commit
57bc010a
authored
Jul 25, 2013
by
Vasyl Nakvasiuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gst integration into studio
parent
166aea62
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
32 deletions
+94
-32
cms/djangoapps/contentstore/views/component.py
+6
-1
common/lib/xmodule/xmodule/css/gst/display.scss
+45
-0
common/lib/xmodule/xmodule/gst_module.py
+41
-30
common/lib/xmodule/xmodule/tests/test_import.py
+1
-1
common/templates/courseware_vendor_js.html
+1
-0
No files found.
cms/djangoapps/contentstore/views/component.py
View file @
57bc010a
...
...
@@ -46,7 +46,12 @@ COMPONENT_TYPES = ['discussion', 'html', 'problem', 'video']
OPEN_ENDED_COMPONENT_TYPES
=
[
"combinedopenended"
,
"peergrading"
]
NOTE_COMPONENT_TYPES
=
[
'notes'
]
ADVANCED_COMPONENT_TYPES
=
[
'annotatable'
,
'word_cloud'
,
'videoalpha'
]
+
OPEN_ENDED_COMPONENT_TYPES
+
NOTE_COMPONENT_TYPES
ADVANCED_COMPONENT_TYPES
=
[
'annotatable'
,
'word_cloud'
,
'videoalpha'
,
'graphical_slider_tool'
]
+
OPEN_ENDED_COMPONENT_TYPES
+
NOTE_COMPONENT_TYPES
ADVANCED_COMPONENT_CATEGORY
=
'advanced'
ADVANCED_COMPONENT_POLICY_KEY
=
'advanced_modules'
...
...
common/lib/xmodule/xmodule/css/gst/display.scss
0 → 100644
View file @
57bc010a
// In the LMS sliders use built-in styles from jquery-ui-1.8.22.custom.css.
// CMS uses its own sliders styles.
// These styles we use only to sure, that slider in GST module
// will be render correctly (just like a duplication some from jquery-ui-1.8.22.custom.css).
// Cause, for example, CMS overwrites many jquery-ui-1.8.22.custom.css styles,
// and we must overwrite them again.
.ui-widget-content
{
border
:
1px
solid
#dddddd
;
color
:
#333333
;
}
.ui-widget
{
font-family
:
Trebuchet
MS
,
Tahoma
,
Verdana
,
Arial
,
sans-serif
;
font-size
:
1
.1em
;
}
.ui-corner-all
,
.ui-corner-top
,
.ui-corner-left
,
.ui-corner-tl
{
-moz-border-radius-topleft
:
4px
;
-webkit-border-top-left-radius
:
4px
;
-khtml-border-top-left-radius
:
4px
;
border-top-left-radius
:
4px
;
}
.ui-corner-all
,
.ui-corner-top
,
.ui-corner-right
,
.ui-corner-tr
{
-moz-border-radius-topright
:
4px
;
-webkit-border-top-right-radius
:
4px
;
-khtml-border-top-right-radius
:
4px
;
border-top-right-radius
:
4px
;
}
.ui-corner-all
,
.ui-corner-bottom
,
.ui-corner-left
,
.ui-corner-bl
{
-moz-border-radius-bottomleft
:
4px
;
-webkit-border-bottom-left-radius
:
4px
;
-khtml-border-bottom-left-radius
:
4px
;
border-bottom-left-radius
:
4px
;
}
.ui-corner-all
,
.ui-corner-bottom
,
.ui-corner-right
,
.ui-corner-br
{
-moz-border-radius-bottomright
:
4px
;
-webkit-border-bottom-right-radius
:
4px
;
-khtml-border-bottom-right-radius
:
4px
;
border-bottom-right-radius
:
4px
;
}
\ No newline at end of file
common/lib/xmodule/xmodule/gst_module.py
View file @
57bc010a
...
...
@@ -9,17 +9,16 @@ from lxml import etree
from
lxml
import
html
import
xmltodict
from
xmodule.
mako_module
import
MakoModule
Descriptor
from
xmodule.
editing_module
import
XMLEditing
Descriptor
from
xmodule.xml_module
import
XmlDescriptor
from
xmodule.x_module
import
XModule
from
xmodule.stringify
import
stringify_children
from
pkg_resources
import
resource_string
from
xblock.core
import
String
,
Scope
log
=
logging
.
getLogger
(
__name__
)
DEFAULT_RENDER
=
"""
DEFAULT_RENDER
=
"""
<h2>Graphic slider tool: Dynamic range and implicit functions.</h2>
<p>You can make the range of the x axis (but not ticks of x axis) of
...
...
@@ -33,13 +32,19 @@ DEFAULT_RENDER="""
</div>
<plot style="margin-top:15px;margin-bottom:15px;"/>
"""
DEFAULT_CONFIGURATION
=
"""
DEFAULT_CONFIGURATION
=
"""
<parameters>
<param var="r" min="5" max="25" step="0.5" initial="12.5" />
</parameters>
<functions>
<function color="red">Math.sqrt(r * r - x * x)</function>
<function color="red">-Math.sqrt(r * r - x * x)</function>
<function color="red">Math.sqrt(r * r / 20 - Math.pow(x-r/2.5, 2)) + r/8</function>
<function color="red">-Math.sqrt(r * r / 20 - Math.pow(x-r/2.5, 2)) + r/5.5</function>
<function color="red">Math.sqrt(r * r / 20 - Math.pow(x+r/2.5, 2)) + r/8</function>
<function color="red">-Math.sqrt(r * r / 20 - Math.pow(x+r/2.5, 2)) + r/5.5</function>
<function color="red">-Math.sqrt(r * r / 5 - x * x) - r/5.5</function>
</functions>
<plot>
<xrange>
...
...
@@ -54,10 +59,13 @@ DEFAULT_CONFIGURATION="""
"""
class
GraphicalSliderToolFields
(
object
):
render
=
String
(
scope
=
Scope
.
content
,
default
=
DEFAULT_RENDER
)
configuration
=
String
(
scope
=
Scope
.
content
,
default
=
DEFAULT_CONFIGURATION
)
data
=
String
(
help
=
"Html contents to display for this module"
,
default
=
'<render>{}</render><configuration>{}</configuration>'
.
format
(
DEFAULT_RENDER
,
DEFAULT_CONFIGURATION
),
scope
=
Scope
.
content
)
class
GraphicalSliderToolModule
(
GraphicalSliderToolFields
,
XModule
):
...
...
@@ -79,9 +87,9 @@ class GraphicalSliderToolModule(GraphicalSliderToolFields, XModule):
resource_string
(
__name__
,
'js/src/graphical_slider_tool/el_output.js'
),
resource_string
(
__name__
,
'js/src/graphical_slider_tool/g_label_el_output.js'
),
resource_string
(
__name__
,
'js/src/graphical_slider_tool/gst.js'
)
]
}
css
=
{
'scss'
:
[
resource_string
(
__name__
,
'css/gst/display.scss'
)]}
js_module_name
=
"GraphicalSliderTool"
def
get_html
(
self
):
...
...
@@ -90,6 +98,13 @@ class GraphicalSliderToolModule(GraphicalSliderToolFields, XModule):
# these 3 will be used in class methods
self
.
html_id
=
self
.
location
.
html_id
()
self
.
html_class
=
self
.
location
.
category
self
.
configuration
=
html
.
fromstring
(
self
.
data
)
.
xpath
(
'configuration'
)[
0
]
self
.
configuration
=
stringify_children
(
self
.
configuration
)
self
.
render
=
html
.
fromstring
(
self
.
data
)
.
xpath
(
'render'
)[
0
]
self
.
render
=
stringify_children
(
self
.
render
)
self
.
configuration_json
=
self
.
build_configuration_json
()
params
=
{
'gst_html'
:
self
.
substitute_controls
(
self
.
render
),
...
...
@@ -98,7 +113,8 @@ class GraphicalSliderToolModule(GraphicalSliderToolFields, XModule):
'configuration_json'
:
self
.
configuration_json
}
content
=
self
.
system
.
render_template
(
'graphical_slider_tool.html'
,
params
)
'graphical_slider_tool.html'
,
params
)
return
content
def
substitute_controls
(
self
,
html_string
):
...
...
@@ -126,7 +142,8 @@ class GraphicalSliderToolModule(GraphicalSliderToolFields, XModule):
if
plot_el
:
plot_el
=
plot_el
[
0
]
plot_el
.
getparent
()
.
replace
(
plot_el
,
html
.
fromstring
(
plot_div
.
format
(
element_class
=
self
.
html_class
,
plot_div
.
format
(
element_class
=
self
.
html_class
,
element_id
=
self
.
html_id
,
style
=
plot_el
.
get
(
'style'
,
""
))))
...
...
@@ -139,7 +156,8 @@ class GraphicalSliderToolModule(GraphicalSliderToolFields, XModule):
slider_els
=
xml
.
xpath
(
'//slider'
)
for
slider_el
in
slider_els
:
slider_el
.
getparent
()
.
replace
(
slider_el
,
html
.
fromstring
(
slider_div
.
format
(
element_class
=
self
.
html_class
,
slider_div
.
format
(
element_class
=
self
.
html_class
,
element_id
=
self
.
html_id
,
var
=
slider_el
.
get
(
'var'
,
""
),
style
=
slider_el
.
get
(
'style'
,
""
))))
...
...
@@ -151,7 +169,8 @@ class GraphicalSliderToolModule(GraphicalSliderToolFields, XModule):
input_els
=
xml
.
xpath
(
'//textbox'
)
for
input_index
,
input_el
in
enumerate
(
input_els
):
input_el
.
getparent
()
.
replace
(
input_el
,
html
.
fromstring
(
input_div
.
format
(
element_class
=
self
.
html_class
,
input_div
.
format
(
element_class
=
self
.
html_class
,
element_id
=
self
.
html_id
,
var
=
input_el
.
get
(
'var'
,
""
),
style
=
input_el
.
get
(
'style'
,
""
),
...
...
@@ -170,11 +189,13 @@ class GraphicalSliderToolModule(GraphicalSliderToolFields, XModule):
"""
# <root> added for interface compatibility with xmltodict.parse
# class added for javascript's part purposes
return
json
.
dumps
(
xmltodict
.
parse
(
'<root class="'
+
self
.
html_class
+
'">'
+
self
.
configuration
+
'</root>'
))
root
=
'<root class="{}">{}</root>'
.
format
(
self
.
html_class
,
self
.
configuration
)
return
json
.
dumps
(
xmltodict
.
parse
(
root
))
class
GraphicalSliderToolDescriptor
(
GraphicalSliderToolFields
,
MakoModule
Descriptor
,
XmlDescriptor
):
class
GraphicalSliderToolDescriptor
(
GraphicalSliderToolFields
,
XMLEditing
Descriptor
,
XmlDescriptor
):
module_class
=
GraphicalSliderToolModule
@classmethod
...
...
@@ -202,24 +223,14 @@ class GraphicalSliderToolDescriptor(GraphicalSliderToolFields, MakoModuleDescrip
exactly one '{0}' tag"
.
format
(
child
))
# finished
def
parse
(
k
):
"""Assumes that xml_object has child k"""
return
stringify_children
(
xml_object
.
xpath
(
k
)[
0
])
return
{
'render'
:
parse
(
'render'
),
'configuration'
:
parse
(
'configuration'
)
'data'
:
stringify_children
(
xml_object
)
},
[]
def
definition_to_xml
(
self
,
resource_fs
):
'''Return an xml element representing this definition.'''
xml_object
=
etree
.
Element
(
'graphical_slider_tool'
)
def
add_child
(
k
):
child_str
=
'<{tag}>{body}</{tag}>'
.
format
(
tag
=
k
,
body
=
getattr
(
self
,
k
))
child_node
=
etree
.
fromstring
(
child_str
)
xml_object
.
append
(
child_node
)
for
child
in
[
'render'
,
'configuration'
]:
add_child
(
child
)
data
=
'<{tag}>{body}</{tag}>'
.
format
(
tag
=
'graphical_slider_tool'
,
body
=
self
.
data
)
xml_object
=
etree
.
fromstring
(
data
)
return
xml_object
common/lib/xmodule/xmodule/tests/test_import.py
View file @
57bc010a
...
...
@@ -445,7 +445,7 @@ class ImportTestCase(BaseCourseTestCase):
render_string_from_sample_gst_xml
=
"""
<slider var="a" style="width:400px;float:left;"/>
\
<plot style="margin-top:15px;margin-bottom:15px;"/>"""
.
strip
()
self
.
assert
Equal
(
gst_sample
.
render
,
render_string_from_sample_gst_xml
)
self
.
assert
In
(
render_string_from_sample_gst_xml
,
gst_sample
.
data
)
def
test_word_cloud_import
(
self
):
modulestore
=
XMLModuleStore
(
DATA_DIR
,
course_dirs
=
[
'word_cloud'
])
...
...
common/templates/courseware_vendor_js.html
View file @
57bc010a
...
...
@@ -8,6 +8,7 @@
<script
type=
"text/javascript"
src=
"${static.url('js/vendor/jquery.cookie.js')}"
></script>
<script
type=
"text/javascript"
src=
"${static.url('js/vendor/jquery.qtip.min.js')}"
></script>
<script
type=
"text/javascript"
src=
"${static.url('js/vendor/jquery.scrollTo-1.4.2-min.js')}"
></script>
<script
type=
"text/javascript"
src=
"${static.url('js/vendor/flot/jquery.flot.js')}"
></script>
## codemirror
<link
rel=
"stylesheet"
href=
"${static.url('js/vendor/CodeMirror/codemirror.css')}"
type=
"text/css"
media=
"all"
/>
...
...
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