Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
ConceptXBlock
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
ConceptXBlock
Commits
439fc82d
Commit
439fc82d
authored
Mar 20, 2014
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Relay to server works
parent
2e4c7ace
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
13 deletions
+47
-13
xoncept/static/css/xoncept.css
+2
-0
xoncept/static/html/xoncept.html
+1
-1
xoncept/static/js/xoncept.js
+28
-6
xoncept/xoncept.py
+16
-6
No files found.
xoncept/static/css/xoncept.css
View file @
439fc82d
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
p
{
p
{
color
:
#222222
;
color
:
#222222
;
margin-top
:
0
;
padding-top
:
0
;
}
}
ul
.obj_drop
{
ul
.obj_drop
{
...
...
xoncept/static/html/xoncept.html
View file @
439fc82d
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
<
div
class
=
"obj_icons"
>
<
a
href
=
"/wiki/{{{{title}}}}"
><
span
style
=
"display:inline-block;"
class
=
"ui-icon ui-icon-pencil"
><
/span></
a
>
<
span
style
=
"display:inline-block;"
class
=
"ui-icon ui-icon-close lo_close"
><
/span> </
div
>
<
div
class
=
"obj_icons"
>
<
a
href
=
"/wiki/{{{{title}}}}"
><
span
style
=
"display:inline-block;"
class
=
"ui-icon ui-icon-pencil"
><
/span></
a
>
<
span
style
=
"display:inline-block;"
class
=
"ui-icon ui-icon-close lo_close"
><
/span> </
div
>
<
/div
>
<
/div
>
<
div
class
=
"objective_desc"
>
<
div
class
=
"objective_desc"
>
{{{{
render
}}}}
{{{{
{{
render
}}
}}}}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
</script>
</script>
...
...
xoncept/static/js/xoncept.js
View file @
439fc82d
var
lo_source
=
$
(
"#lo-template"
).
html
();
var
lo_source
=
$
(
"#lo-template"
).
html
();
var
template
=
Handlebars
.
compile
(
lo_source
);
var
template
=
Handlebars
.
compile
(
lo_source
);
var
xblock_runtime
=
null
;
var
xblock_element
=
null
;
function
ConceptXBlock
(
runtime
,
element
)
{
xblock_runtime
=
runtime
;
xblock_element
=
element
;
console
.
log
(
runtime
);
init
();
//console.log( element );
}
function
update_item
(
item
,
slug
,
full
)
function
update_item
(
item
,
slug
,
full
)
{
{
item
.
data
(
'slug'
,
slug
);
item
.
data
(
'slug'
,
slug
);
...
@@ -49,18 +61,22 @@ function dump_state()
...
@@ -49,18 +61,22 @@ function dump_state()
function
refresh_search
(
search_string
)
function
refresh_search
(
search_string
)
{
{
$
.
getJSON
(
"http://pmitros.edx.org:8000/get_concept_list"
,
{
'q'
:
search_string
},
function
(
data
)
{
url
=
xblock_runtime
.
handlerUrl
(
xblock_element
,
'relay_handler'
)
//$.getJSON("http://pmitros.edx.org:8000/get_concept_list", {'q':search_string}, function(data) {
$
.
post
(
url
,
JSON
.
stringify
({
'suffix'
:
'get_concept_list'
,
'q'
:
search_string
}),
function
(
data
)
{
$
(
".search_results"
).
text
(
""
);
$
(
".search_results"
).
text
(
""
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
add_search_item
(
data
[
i
],
"Hello World"
);
var
slug
=
data
[
i
];
url
=
xblock_runtime
.
handlerUrl
(
xblock_element
,
'relay_handler'
)
$
.
post
(
url
,
JSON
.
stringify
({
'suffix'
:
'get_concept/'
+
slug
}),
function
(
render
)
{
//$.getJSON("http://pmitros.edx.org:8000/get_concept/"+slug, function(render) {
add_search_item
(
slug
,
render
.
article
);
})
}
}
})
})
}
}
$
(
function
()
{
function
init
()
{
//var html = template({title:"Hello", render:"Hello world example"});
//$("#foo").html(html);
$
(
".obj_drop"
).
sortable
({
$
(
".obj_drop"
).
sortable
({
connectWith
:
".obj_drop"
,
connectWith
:
".obj_drop"
,
update
:
function
(
event
,
ui
)
{
dump_state
();
},
update
:
function
(
event
,
ui
)
{
dump_state
();
},
...
@@ -78,4 +94,10 @@ $(function() {
...
@@ -78,4 +94,10 @@ $(function() {
$
(
".search_input"
).
change
(
function
(){
$
(
".search_input"
).
change
(
function
(){
refresh_search
(
$
(
".search_input"
).
val
());
refresh_search
(
$
(
".search_input"
).
val
());
});
});
}
$
(
function
()
{
//var html = template({title:"Hello", render:"Hello world example"});
//$("#foo").html(html);
// init();
});
});
xoncept/xoncept.py
View file @
439fc82d
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
import
pkg_resources
import
pkg_resources
import
json
,
requests
from
xblock.core
import
XBlock
from
xblock.core
import
XBlock
from
xblock.fields
import
Scope
,
Integer
,
String
from
xblock.fields
import
Scope
,
Integer
,
String
from
xblock.fragment
import
Fragment
from
xblock.fragment
import
Fragment
...
@@ -14,11 +16,19 @@ class XonceptXBlock(XBlock):
...
@@ -14,11 +16,19 @@ class XonceptXBlock(XBlock):
# Fields are defined on the class. You can access them in your code as
# Fields are defined on the class. You can access them in your code as
# self.<fieldname>.
# self.<fieldname>.
s
rc
=
String
(
s
erver
=
String
(
scope
=
Scope
.
settings
,
scope
=
Scope
.
settings
,
help
=
"
URL for MP3 file to play
"
help
=
"
Concept map server URL
"
)
)
@XBlock.json_handler
def
relay_handler
(
self
,
request
,
suffix
):
print
request
,
type
(
request
),
dict
(
request
)
url
=
self
.
server
+
request
[
'suffix'
]
r
=
requests
.
get
(
url
,
params
=
request
)
print
url
,
":"
,
r
.
text
[:
80
]
return
json
.
loads
(
r
.
text
)
def
resource_string
(
self
,
path
):
def
resource_string
(
self
,
path
):
"""Handy helper for getting resources from our kit."""
"""Handy helper for getting resources from our kit."""
data
=
pkg_resources
.
resource_string
(
__name__
,
path
)
data
=
pkg_resources
.
resource_string
(
__name__
,
path
)
...
@@ -31,9 +41,9 @@ class XonceptXBlock(XBlock):
...
@@ -31,9 +41,9 @@ class XonceptXBlock(XBlock):
when viewing courses.
when viewing courses.
"""
"""
html
=
self
.
resource_string
(
"static/html/xoncept.html"
)
html
=
self
.
resource_string
(
"static/html/xoncept.html"
)
print
self
.
s
rc
print
self
.
s
erver
print
html
.
format
print
html
.
format
frag
=
Fragment
(
html
.
format
(
s
rc
=
self
.
src
))
frag
=
Fragment
(
html
.
format
(
s
erver
=
self
.
server
))
frag
.
add_css_url
(
"https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css"
)
frag
.
add_css_url
(
"https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css"
)
frag
.
add_css
(
self
.
resource_string
(
"static/css/xoncept.css"
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/xoncept.css"
))
...
@@ -43,7 +53,7 @@ class XonceptXBlock(XBlock):
...
@@ -43,7 +53,7 @@ class XonceptXBlock(XBlock):
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/xoncept.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/xoncept.js"
))
#frag.initialize_js('X
onceptXBlock')
frag
.
initialize_js
(
'C
onceptXBlock'
)
print
self
.
xml_text_content
()
print
self
.
xml_text_content
()
return
frag
return
frag
...
@@ -55,7 +65,7 @@ class XonceptXBlock(XBlock):
...
@@ -55,7 +65,7 @@ class XonceptXBlock(XBlock):
return
[
return
[
(
"XonceptXBlock"
,
(
"XonceptXBlock"
,
"""<vertical_demo>
"""<vertical_demo>
<Xoncept s
rc="http://localhost/Ikea.mp3
"> </Xoncept>
<Xoncept s
erver="http://pmitros.edx.org:8000/
"> </Xoncept>
</vertical_demo>
</vertical_demo>
"""
),
"""
),
]
]
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