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
36c8af61
Commit
36c8af61
authored
Apr 09, 2013
by
Vasyl Nakvasiuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use user_state, add test_logic test
parent
9b974916
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
common/lib/xmodule/xmodule/tests/test_logic.py
+23
-0
common/lib/xmodule/xmodule/word_cloud_module.py
+3
-3
No files found.
common/lib/xmodule/xmodule/tests/test_logic.py
View file @
36c8af61
...
@@ -3,8 +3,11 @@
...
@@ -3,8 +3,11 @@
import
json
import
json
import
unittest
import
unittest
from
django.http
import
QueryDict
from
xmodule.poll_module
import
PollDescriptor
from
xmodule.poll_module
import
PollDescriptor
from
xmodule.conditional_module
import
ConditionalDescriptor
from
xmodule.conditional_module
import
ConditionalDescriptor
from
xmodule.word_cloud_module
import
WordCloudDescriptor
class
LogicTest
(
unittest
.
TestCase
):
class
LogicTest
(
unittest
.
TestCase
):
...
@@ -64,3 +67,23 @@ class ConditionalModuleTest(LogicTest):
...
@@ -64,3 +67,23 @@ class ConditionalModuleTest(LogicTest):
html
=
response
[
'html'
]
html
=
response
[
'html'
]
self
.
assertEqual
(
html
,
[])
self
.
assertEqual
(
html
,
[])
class
WordCloudModuleTest
(
LogicTest
):
descriptor_class
=
WordCloudDescriptor
raw_model_data
=
{
'all_words'
:
{
'Yes'
:
1
,
'Dont_know'
:
0
,
'No'
:
0
},
'top_words'
:
{
'Yes'
:
1
,
'Dont_know'
:
0
,
'No'
:
0
},
'submitted'
:
False
,
'student_words'
:
[
'mom'
,
'dad'
,
'cat'
]
}
def
test_bad_ajax_request
(
self
):
response
=
self
.
ajax_request
(
'bad_dispatch'
,
{})
self
.
assertDictEqual
(
response
,
{
'status'
:
'fail'
,
'error'
:
'Unknown Command!'
})
# def test_good_ajax_request(self):
# response = self.ajax_request('submit', {})
common/lib/xmodule/xmodule/word_cloud_module.py
View file @
36c8af61
...
@@ -29,8 +29,8 @@ class WordCloudFields(object):
...
@@ -29,8 +29,8 @@ class WordCloudFields(object):
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
=
"Number of inputs"
,
scope
=
Scope
.
settings
,
default
=
250
)
num_top_words
=
Integer
(
help
=
"Number of inputs"
,
scope
=
Scope
.
settings
,
default
=
250
)
submitted
=
Boolean
(
help
=
"Whether this student has posted words to the cloud"
,
scope
=
Scope
.
student
_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
.
student
_state
,
default
=
[])
student_words
=
List
(
help
=
"Student answer"
,
scope
=
Scope
.
user
_state
,
default
=
[])
all_words
=
Object
(
help
=
"All possible words from other students"
,
scope
=
Scope
.
content
)
all_words
=
Object
(
help
=
"All possible words from other students"
,
scope
=
Scope
.
content
)
top_words
=
Object
(
help
=
"Top N words for word cloud"
,
scope
=
Scope
.
content
)
top_words
=
Object
(
help
=
"Top N words for word cloud"
,
scope
=
Scope
.
content
)
...
@@ -57,7 +57,7 @@ class WordCloudModule(WordCloudFields, XModule):
...
@@ -57,7 +57,7 @@ class WordCloudModule(WordCloudFields, XModule):
word
:
self
.
all_words
[
word
]
for
word
:
self
.
all_words
[
word
]
for
word
in
self
.
student_words
word
in
self
.
student_words
},
},
'total_count'
:
sum
(
self
.
all_words
.
values
())
'total_count'
:
sum
(
self
.
all_words
.
values
())
,
'top_words'
:
self
.
prepare_words
(
self
.
top_words
)
'top_words'
:
self
.
prepare_words
(
self
.
top_words
)
})
})
else
:
else
:
...
...
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