Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 377... Línea 377...
377
     *              Tags: 'subcat', 'foo'
377
     *              Tags: 'subcat', 'foo'
378
     *          Question: subcatq2
378
     *          Question: subcatq2
379
     *          Parent: cat1
379
     *          Parent: cat1
380
     *      Category: emptycat
380
     *      Category: emptycat
381
     *
381
     *
382
     * @dataProvider get_questions_test_cases()
382
     * @dataProvider get_questions_test_cases
383
     * @param string $categoryindex The named index for the category to use
383
     * @param string $categoryindex The named index for the category to use
384
     * @param bool $includesubcategories If the search should include subcategories
384
     * @param bool $includesubcategories If the search should include subcategories
385
     * @param string[] $usetagnames The tag names to include in the search
385
     * @param string[] $usetagnames The tag names to include in the search
386
     * @param string[] $expectedquestionindexes The questions expected in the result
386
     * @param string[] $expectedquestionindexes The questions expected in the result
387
     */
387
     */
Línea 587... Línea 587...
587
     *              Tags: 'subcat', 'foo'
587
     *              Tags: 'subcat', 'foo'
588
     *          Question: subcatq2
588
     *          Question: subcatq2
589
     *          Parent: cat1
589
     *          Parent: cat1
590
     *      Category: emptycat
590
     *      Category: emptycat
591
     *
591
     *
592
     * @dataProvider count_questions_test_cases()
592
     * @dataProvider count_questions_test_cases
593
     * @param string $categoryindex The named index for the category to use
593
     * @param string $categoryindex The named index for the category to use
594
     * @param bool $includesubcategories If the search should include subcategories
594
     * @param bool $includesubcategories If the search should include subcategories
595
     * @param string[] $usetagnames The tag names to include in the search
595
     * @param string[] $usetagnames The tag names to include in the search
596
     * @param int $expectedcount The number of questions expected in the result
596
     * @param int $expectedcount The number of questions expected in the result
597
     */
597
     */
Línea 678... Línea 678...
678
            \core_tag_tag::set_item_tags('core_question', 'question', $questions[0]->id, $context, $tagnames);
678
            \core_tag_tag::set_item_tags('core_question', 'question', $questions[0]->id, $context, $tagnames);
679
        }
679
        }
Línea 680... Línea 680...
680
 
680
 
681
        return [$category, $questions];
681
        return [$category, $questions];
-
 
682
    }
-
 
683
 
-
 
684
    /**
-
 
685
     * Test that the random question loader excludes questions with invalid types.
-
 
686
     * @return void
-
 
687
     * @throws \dml_exception
-
 
688
     */
-
 
689
    public function test_invalid_questions_are_excluded(): void {
-
 
690
 
-
 
691
        global $DB;
-
 
692
 
-
 
693
        $this->resetAfterTest();
-
 
694
 
-
 
695
        [$category, $questions] = $this->create_category_and_questions(4);
-
 
696
        $loader = new random_question_loader(new qubaid_list([]));
-
 
697
        $filters = question_filter_test_helper::create_filters([$category->id], false, []);
-
 
698
 
-
 
699
        // Update one of the questions to have an invalid type.
-
 
700
        $invalid = $questions[0];
-
 
701
        $invalid->qtype = 'invalid';
-
 
702
        $DB->update_record('question', $invalid);
-
 
703
 
-
 
704
        // Assert that we get 1 less result back because the invalid type is excluded.
-
 
705
        $result = $loader->get_filtered_questions($filters);
-
 
706
        $this->assertEquals(count($questions) - 1, count($result));
-
 
707
 
-
 
708
    }
682
    }
709