refactoring after Python code review

This commit is contained in:
Vasyl Nakvasiuk
2013-04-22 19:20:06 +03:00
parent 7b5d5a0499
commit f1d1a3f606
8 changed files with 37 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
.input-cloud {
margin: 5px;
margin: 5px;
}
.result_cloud_section {

View File

@@ -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):
"""

View File

@@ -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',

View File

@@ -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

View File

@@ -1,3 +0,0 @@
<conditional attempted="True" sources="i4x://HarvardX/ER22x/problem/choiceprob">
<html url_name="secret_page" />
</conditional>

View File

@@ -1,5 +1,5 @@
<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>

View File

@@ -24,4 +24,5 @@
<h3>Total number of words: <span class="total_num_words"></span></h3>
<div class="word_cloud"></div>
</section>
</section>