diff --git a/common/lib/xmodule/xmodule/css/word_cloud/display.scss b/common/lib/xmodule/xmodule/css/word_cloud/display.scss index 391ccafc07..a9e2c549b0 100644 --- a/common/lib/xmodule/xmodule/css/word_cloud/display.scss +++ b/common/lib/xmodule/xmodule/css/word_cloud/display.scss @@ -1,5 +1,5 @@ .input-cloud { - margin: 5px; + margin: 5px; } .result_cloud_section { diff --git a/common/lib/xmodule/xmodule/tests/test_import.py b/common/lib/xmodule/xmodule/tests/test_import.py index 5e2513d2d6..5fe57892be 100644 --- a/common/lib/xmodule/xmodule/tests/test_import.py +++ b/common/lib/xmodule/xmodule/tests/test_import.py @@ -393,12 +393,31 @@ class ImportTestCase(BaseCourseTestCase): self.assertEqual(len(sections), 1) location = course.location - location = Location( + + conditional_location = Location( location.tag, location.org, location.course, - 'sequential', 'Problem_Demos' + 'conditional', 'condone' + ) + module = modulestore.get_instance(course.id, conditional_location) + self.assertEqual(len(module.children), 1) + + poll_location = Location( + location.tag, location.org, location.course, + 'poll_question', 'first_poll' + ) + module = modulestore.get_instance(course.id, poll_location) + self.assertEqual(len(module.get_children()), 0) + self.assertEqual(module.voted, False) + self.assertEqual(module.poll_answer, '') + self.assertEqual(module.poll_answers, {}) + self.assertEqual( + module.answers, + [ + {'text': u'Yes', 'id': 'Yes'}, + {'text': u'No', 'id': 'No'}, + {'text': u"Don't know", 'id': 'Dont_know'} + ] ) - module = modulestore.get_instance(course.id, location) - self.assertEqual(len(module.children), 2) def test_error_on_import(self): '''Check that when load_error_module is false, an exception is raised, rather than returning an ErrorModule''' @@ -437,10 +456,12 @@ class ImportTestCase(BaseCourseTestCase): location = course.location location = Location( location.tag, location.org, location.course, - 'sequential', 'Problem_Demos' + 'word_cloud', 'cloud1' ) module = modulestore.get_instance(course.id, location) - self.assertEqual(len(module.children), 1) + self.assertEqual(len(module.get_children()), 0) + self.assertEqual(module.num_inputs, '5') + self.assertEqual(module.num_top_words, '250') def test_cohort_config(self): """ diff --git a/common/lib/xmodule/xmodule/tests/test_logic.py b/common/lib/xmodule/xmodule/tests/test_logic.py index c977758e6c..715575d76b 100644 --- a/common/lib/xmodule/xmodule/tests/test_logic.py +++ b/common/lib/xmodule/xmodule/tests/test_logic.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""Test for Xmodule functional logic.""" import json import unittest @@ -89,7 +90,7 @@ class WordCloudModuleTest(LogicTest): def test_bad_ajax_request(self): - # TODO: move top global test. Formalize all Xmodule errors. + # TODO: move top global test. Formalize all our Xmodule errors. response = self.ajax_request('bad_dispatch', {}) self.assertDictEqual(response, { 'status': 'fail', diff --git a/common/lib/xmodule/xmodule/word_cloud_module.py b/common/lib/xmodule/xmodule/word_cloud_module.py index 1a2c99f59a..efb5dc755e 100644 --- a/common/lib/xmodule/xmodule/word_cloud_module.py +++ b/common/lib/xmodule/xmodule/word_cloud_module.py @@ -1,11 +1,9 @@ """Word cloud is ungraded xblock used by students to -generate and view word cloud.. +generate and view word cloud. On the client side we show: -If student does not yet anwered - five text inputs. +If student does not yet anwered - `num_inputs` numbers of text inputs. If student have answered - words he entered and cloud. - -Stunent can change his answer. """ import json @@ -108,6 +106,7 @@ class WordCloudModule(WordCloudFields, XModule): }) # Student words from client. + # FIXME: we must use raw JSON, not a post data (multipart/form-data) raw_student_words = post.getlist('student_words[]') student_words = filter(None, map(self.good_word, raw_student_words)) @@ -185,5 +184,6 @@ class WordCloudDescriptor(WordCloudFields, MakoModuleDescriptor, XmlDescriptor): xml_object = etree.fromstring(xml_str) xml_object.set('display_name', self.display_name) xml_object.set('num_inputs', self.num_inputs) + xml_object.set('num_top_words', self.num_top_words) return xml_object diff --git a/common/test/data/word_cloud/conditional/condone.xml b/common/test/data/word_cloud/conditional/condone.xml deleted file mode 100644 index 80b061e244..0000000000 --- a/common/test/data/word_cloud/conditional/condone.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/common/test/data/word_cloud/sequential/Problem_Demos.xml b/common/test/data/word_cloud/sequential/Problem_Demos.xml index cabf1be6f6..21568128a4 100644 --- a/common/test/data/word_cloud/sequential/Problem_Demos.xml +++ b/common/test/data/word_cloud/sequential/Problem_Demos.xml @@ -1,5 +1,5 @@ - - + + diff --git a/common/test/data/word_cloud/word_cloud/cloud.xml b/common/test/data/word_cloud/word_cloud/cloud.xml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lms/templates/word_cloud.html b/lms/templates/word_cloud.html index 633e8bf168..7ff90ee6d6 100644 --- a/lms/templates/word_cloud.html +++ b/lms/templates/word_cloud.html @@ -24,4 +24,5 @@

Total number of words:

+