Beispiel #1
0
 def setup_quiz(self, p_min=10, p_max=90, length=8):
     """
     A helper function to start a quiz.
     """
     wwg = WordwallsGame()
     user = User.objects.get(username='******')
     lex = Lexicon.objects.get(lexiconName='America')
     search = SearchDescription.probability_range(p_min, p_max, length, lex)
     table_id = wwg.initialize_by_search_params(user, search, 240)
     return table_id, user
 def test_tag_search(self):
     self.create_some_tags()
     t = time.time()
     qs = word_search([
         SearchDescription.lexicon(self.america),
         SearchDescription.length(8, 8),
         SearchDescription.probability_range(5001, 7500),
         SearchDescription.has_tags(['D4'], self.cesar),
     ])
     logger.debug('Tag search completed in %s seconds', time.time() - t)
     self.assertEqual(qs.size(), 2500)
    def test_probability_word_search(self):
        qs = word_search([SearchDescription.lexicon(self.america),
                          SearchDescription.length(8, 8),
                          SearchDescription.probability_range(200, 203)])

        self.assertEqual(qs.size(), 4)

        self.assertEqual(
            ['ADEEGNOR', 'EEGILNOR', 'ADEEGORT', 'AEEGLNOT'],
            qs.alphagram_string_list())
        self.assertTrue(len(qs.questions_array()[0].answers[0].definition) > 0)
    def test_probability_and_points(self):
        qs = word_search([
            SearchDescription.lexicon(self.america),
            SearchDescription.length(8, 8),
            SearchDescription.probability_range(3000, 3010),
            SearchDescription.point_value(14, 30)
        ])

        self.assertEqual(qs.size(), 4)
        self.assertEqual(
            ['EHILORTY', 'DEHIOPRT', 'DEINORVW', 'CDEINORV'],
            qs.alphagram_string_list())
        self.assertTrue(len(qs.questions_array()[0].answers[0].definition) > 0)
Beispiel #5
0
    def get_questions_for_probability_range(self, p_min, p_max, length):
        """
        Use a single query to return alphagrams and words for a
        probability range, fully populated.

        """

        configs = {
            'search_descriptions': [
                SearchDescription.length(length, length),
                SearchDescription.probability_range(p_min, p_max)
            ]
        }
        return self.get_questions_from_configs(configs)
    def create_some_tags(self):
        self.america = Lexicon.objects.get(lexiconName='America')
        self.cesar = User.objects.get(username='******')
        t = time.time()

        qs = word_search([
            SearchDescription.lexicon(self.america),
            SearchDescription.length(8, 8),
            SearchDescription.probability_range(5001, 8500),
        ])
        logger.debug('Initial word search completed in %s seconds',
                     time.time() - t)
        self.assertEqual(qs.size(), 3500)
        # Create hella tags.
        for q in qs.questions_array():
            AlphagramTag.objects.create(user=self.cesar, lexicon=self.america,
                                        tag='D4',
                                        alphagram=q.alphagram.alphagram)
        logger.debug('And time elapsed after tag creation: %s',
                     time.time() - t)
Beispiel #7
0
def searchForAlphagrams(data, lex):
    """ Searches for alphagrams using form data """
    length = int(data['wordLength'])
    return SearchDescription.probability_range(data['probabilityMin'],
                                               data['probabilityMax'],
                                               length, lex)