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
9b974916
Commit
9b974916
authored
Apr 09, 2013
by
Vasyl Nakvasiuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more docstrings
parent
b2730117
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
common/lib/xmodule/xmodule/word_cloud_module.py
+5
-3
No files found.
common/lib/xmodule/xmodule/word_cloud_module.py
View file @
9b974916
...
...
@@ -11,13 +11,11 @@ Stunent can change his answer.
import
json
import
logging
import
re
from
collections
import
OrderedDict
from
lxml
import
etree
from
pkg_resources
import
resource_string
from
xmodule.x_module
import
XModule
from
xmodule.stringify
import
stringify_children
from
xmodule.mako_module
import
MakoModuleDescriptor
from
xmodule.xml_module
import
XmlDescriptor
from
xblock.core
import
Scope
,
String
,
Object
,
Boolean
,
List
,
Integer
...
...
@@ -51,6 +49,7 @@ class WordCloudModule(WordCloudFields, XModule):
js_module_name
=
"WordCloud"
def
get_state_json
(
self
):
"""Return success json answer for client."""
if
self
.
submitted
:
return
json
.
dumps
({
'status'
:
'success'
,
...
...
@@ -65,6 +64,7 @@ class WordCloudModule(WordCloudFields, XModule):
return
json
.
dumps
({})
def
good_word
(
self
,
word
):
"""Convert raw word to suitable word."""
return
word
.
strip
()
.
lower
()
# TODO: use or remove
...
...
@@ -78,6 +78,7 @@ class WordCloudModule(WordCloudFields, XModule):
word
,
count
in
words
.
iteritems
()]
def
top_dict
(
self
,
dict_obj
,
amount
):
"""Return new dict: top of dict using dict value."""
return
dict
(
sorted
(
dict_obj
.
iteritems
(),
...
...
@@ -129,10 +130,11 @@ class WordCloudModule(WordCloudFields, XModule):
else
:
temp_all_words
[
word
]
=
1
# Update top_words
# Update top_words
.
self
.
top_words
=
self
.
top_dict
(
temp_all_words
,
int
(
self
.
num_top_words
))
# Save all_words in database.
self
.
all_words
=
temp_all_words
return
self
.
get_state_json
()
...
...
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