Commit f1d1a3f6 by Vasyl Nakvasiuk

refactoring after Python code review

parent 7b5d5a04
......@@ -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):
"""
......
# -*- 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',
......
"""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
<conditional attempted="True" sources="i4x://HarvardX/ER22x/problem/choiceprob">
<html url_name="secret_page" />
</conditional>
<sequential>
<vertical>
<word_cloud display_name="cloud" num_inputs="5" num_top_words="250" />
<vertical name="test_vertical">
<word_cloud name="cloud1" display_name="cloud" num_inputs="5" num_top_words="250" />
</vertical>
</sequential>
......@@ -24,4 +24,5 @@
<h3>Total number of words: <span class="total_num_words"></span></h3>
<div class="word_cloud"></div>
</section>
</section>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment