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
6deeb602
Commit
6deeb602
authored
Apr 10, 2013
by
Vasyl Nakvasiuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update template for word_cloud, refactor empty json answer
parent
ed23aef6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
10 deletions
+25
-10
common/lib/xmodule/xmodule/js/src/word_cloud/word_cloud_main.js
+1
-1
common/lib/xmodule/xmodule/tests/test_logic.py
+8
-5
common/lib/xmodule/xmodule/word_cloud_module.py
+10
-3
lms/templates/word_cloud.html
+6
-1
No files found.
common/lib/xmodule/xmodule/js/src/word_cloud/word_cloud_main.js
View file @
6deeb602
...
@@ -149,7 +149,7 @@ function WordCloudMain(el) {
...
@@ -149,7 +149,7 @@ function WordCloudMain(el) {
return
;
return
;
}
}
if
(
this
.
configJson
.
hasOwnProperty
(
'status'
)
&&
this
.
configJson
.
status
===
'success'
)
{
if
(
this
.
configJson
.
submitted
)
{
this
.
showWordCloud
(
this
.
configJson
);
this
.
showWordCloud
(
this
.
configJson
);
return
;
return
;
...
...
common/lib/xmodule/xmodule/tests/test_logic.py
View file @
6deeb602
...
@@ -72,18 +72,21 @@ class ConditionalModuleTest(LogicTest):
...
@@ -72,18 +72,21 @@ class ConditionalModuleTest(LogicTest):
class
WordCloudModuleTest
(
LogicTest
):
class
WordCloudModuleTest
(
LogicTest
):
descriptor_class
=
WordCloudDescriptor
descriptor_class
=
WordCloudDescriptor
raw_model_data
=
{
raw_model_data
=
{
'all_words'
:
{
'
Yes'
:
1
,
'Dont_know'
:
0
,
'No'
:
0
},
'all_words'
:
{
'
cat'
:
10
,
'dog'
:
5
,
'mom'
:
1
,
'dad'
:
2
},
'top_words'
:
{
'
Yes'
:
1
,
'Dont_know'
:
0
,
'No'
:
0
},
'top_words'
:
{
'
cat'
:
10
,
'dog'
:
5
,
'dad'
:
2
},
'submitted'
:
False
,
'submitted'
:
False
,
'student_words'
:
[
'mom'
,
'dad'
,
'cat'
]
'student_words'
:
[
'mom'
,
'dad'
,
'cat'
]
}
}
def
test_bad_ajax_request
(
self
):
def
test_bad_ajax_request
(
self
):
# TODO: move top global test.
response
=
self
.
ajax_request
(
'bad_dispatch'
,
{})
response
=
self
.
ajax_request
(
'bad_dispatch'
,
{})
self
.
assertDictEqual
(
response
,
{
self
.
assertDictEqual
(
response
,
{
'status'
:
'fail'
,
'status'
:
'fail'
,
'error'
:
'Unknown Command!'
'error'
:
'Unknown Command!'
})
})
# TODO
# def test_good_ajax_request(self):
# def test_good_ajax_request(self):
# response = self.ajax_request('submit', {})
# response = self.ajax_request('submit', {})
common/lib/xmodule/xmodule/word_cloud_module.py
View file @
6deeb602
...
@@ -27,7 +27,7 @@ class WordCloudFields(object):
...
@@ -27,7 +27,7 @@ class WordCloudFields(object):
# Name of poll to use in links to this poll
# Name of poll to use in links to this poll
display_name
=
String
(
help
=
"Display name for this module"
,
scope
=
Scope
.
settings
)
display_name
=
String
(
help
=
"Display name for this module"
,
scope
=
Scope
.
settings
)
num_inputs
=
Integer
(
help
=
"Number of inputs"
,
scope
=
Scope
.
settings
,
default
=
5
)
num_inputs
=
Integer
(
help
=
"Number of inputs"
,
scope
=
Scope
.
settings
,
default
=
5
)
num_top_words
=
Integer
(
help
=
"
TODO
"
,
scope
=
Scope
.
settings
,
default
=
250
)
num_top_words
=
Integer
(
help
=
"
Number of max words, which will be displayed.
"
,
scope
=
Scope
.
settings
,
default
=
250
)
submitted
=
Boolean
(
help
=
"Whether this student has posted words to the cloud"
,
scope
=
Scope
.
user_state
,
default
=
False
)
submitted
=
Boolean
(
help
=
"Whether this student has posted words to the cloud"
,
scope
=
Scope
.
user_state
,
default
=
False
)
student_words
=
List
(
help
=
"Student answer"
,
scope
=
Scope
.
user_state
,
default
=
[])
student_words
=
List
(
help
=
"Student answer"
,
scope
=
Scope
.
user_state
,
default
=
[])
...
@@ -53,6 +53,7 @@ class WordCloudModule(WordCloudFields, XModule):
...
@@ -53,6 +53,7 @@ class WordCloudModule(WordCloudFields, XModule):
if
self
.
submitted
:
if
self
.
submitted
:
return
json
.
dumps
({
return
json
.
dumps
({
'status'
:
'success'
,
'status'
:
'success'
,
'submitted'
:
True
,
'student_words'
:
{
'student_words'
:
{
word
:
self
.
all_words
[
word
]
for
word
:
self
.
all_words
[
word
]
for
word
in
self
.
student_words
word
in
self
.
student_words
...
@@ -61,7 +62,13 @@ class WordCloudModule(WordCloudFields, XModule):
...
@@ -61,7 +62,13 @@ class WordCloudModule(WordCloudFields, XModule):
'top_words'
:
self
.
prepare_words
(
self
.
top_words
)
'top_words'
:
self
.
prepare_words
(
self
.
top_words
)
})
})
else
:
else
:
return
json
.
dumps
({})
return
json
.
dumps
({
'status'
:
'success'
,
'submitted'
:
False
,
'student_words'
:
{},
'total_count'
:
0
,
'top_words'
:
{}
})
def
good_word
(
self
,
word
):
def
good_word
(
self
,
word
):
"""Convert raw word to suitable word."""
"""Convert raw word to suitable word."""
...
@@ -102,7 +109,6 @@ class WordCloudModule(WordCloudFields, XModule):
...
@@ -102,7 +109,6 @@ class WordCloudModule(WordCloudFields, XModule):
})
})
# Student words from client.
# Student words from client.
raw_student_words
=
post
.
getlist
(
'student_words[]'
)
raw_student_words
=
post
.
getlist
(
'student_words[]'
)
student_words
=
filter
(
None
,
map
(
self
.
good_word
,
raw_student_words
))
student_words
=
filter
(
None
,
map
(
self
.
good_word
,
raw_student_words
))
...
@@ -141,6 +147,7 @@ class WordCloudModule(WordCloudFields, XModule):
...
@@ -141,6 +147,7 @@ class WordCloudModule(WordCloudFields, XModule):
'ajax_url'
:
self
.
system
.
ajax_url
,
'ajax_url'
:
self
.
system
.
ajax_url
,
'configuration_json'
:
self
.
get_state
(),
'configuration_json'
:
self
.
get_state
(),
'num_inputs'
:
int
(
self
.
num_inputs
),
'num_inputs'
:
int
(
self
.
num_inputs
),
'submitted'
:
self
.
submitted
}
}
self
.
content
=
self
.
system
.
render_template
(
'word_cloud.html'
,
params
)
self
.
content
=
self
.
system
.
render_template
(
'word_cloud.html'
,
params
)
return
self
.
content
return
self
.
content
...
...
lms/templates/word_cloud.html
View file @
6deeb602
...
@@ -6,7 +6,12 @@
...
@@ -6,7 +6,12 @@
<section
id=
"input-cloud-section"
>
<section
id=
"input-cloud-section"
>
% for row in range(num_inputs):
% for row in range(num_inputs):
<input
class=
"input-cloud"
type=
"text"
size=
"40"
/>
<input
class=
"input-cloud"
${'
style=
"display: none;"
'
if
submitted
else
''}
type=
"text"
size=
"40"
/>
% endfor
% endfor
<section
class=
"action"
>
<section
class=
"action"
>
...
...
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