Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
Hooks | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
onParserFirstCallInit | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
renderQuiz | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
onParserAfterTidy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\Quiz; |
4 | |
5 | use MediaWiki\Hook\ParserAfterTidyHook; |
6 | use MediaWiki\Hook\ParserFirstCallInitHook; |
7 | use MediaWiki\Parser\Parser; |
8 | |
9 | class Hooks implements |
10 | ParserFirstCallInitHook, |
11 | ParserAfterTidyHook |
12 | { |
13 | |
14 | /** |
15 | * Register the extension with the WikiText parser. |
16 | * The tag used is <quiz> |
17 | * @param Parser $parser the wikitext parser |
18 | */ |
19 | public function onParserFirstCallInit( $parser ) { |
20 | $parser->setHook( 'quiz', [ self::class, 'renderQuiz' ] ); |
21 | } |
22 | |
23 | /** |
24 | * Call the quiz parser on an input text. |
25 | * |
26 | * @param string $input text between <quiz> and </quiz> tags, in quiz syntax. |
27 | * @param array $argv an array containing any arguments passed to the extension |
28 | * @param Parser $parser the wikitext parser. |
29 | * |
30 | * @return string An HTML quiz. |
31 | */ |
32 | public static function renderQuiz( $input, $argv, $parser ) { |
33 | $parser->getOutput()->updateCacheExpiry( 0 ); |
34 | $quiz = new Quiz( $argv, $parser ); |
35 | return $quiz->parseQuiz( $input ); |
36 | } |
37 | |
38 | /** |
39 | * @param Parser $parser |
40 | * @param string &$text |
41 | */ |
42 | public function onParserAfterTidy( $parser, &$text ) { |
43 | Quiz::resetQuizID(); |
44 | } |
45 | } |