Ananay has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/257831

Change subject: Bug:T87963 Perfected Code.
......................................................................

Bug:T87963 Perfected Code.

Change-Id: I041814e2788f238c8840f60132784e2bda6a04bc
---
A .DS_Store
A Quiz.hooks.php
M Quiz.php
A extension.json
4 files changed, 68 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Quiz 
refs/changes/31/257831/1

diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..f2c6039
--- /dev/null
+++ b/.DS_Store
Binary files differ
diff --git a/Quiz.hooks.php b/Quiz.hooks.php
new file mode 100644
index 0000000..0fe4f12
--- /dev/null
+++ b/Quiz.hooks.php
@@ -0,0 +1,27 @@
+<?php
+class QuizHooks {
+       /**
+        * Register the extension with the WikiText parser.
+        * The tag used is <quiz>
+        * @param $parser Parser the wikitext parser
+        * @return Boolean true to continue hook processing
+       */
+       public static function onParserFirstCallInit( &$parser ) {
+               $parser->setHook( 'quiz', 'QuizHooks::renderQuiz' );
+               return true;
+       }
+       /**
+        * Call the quiz parser on an input text.
+        *
+        * @param $input String text between <quiz> and </quiz> tags, in quiz 
syntax.
+        * @param $argv Array an array containing any arguments passed to the 
extension
+        * @param $parser Parser the wikitext parser.
+        *
+        * @return string An HTML quiz.
+       */
+       public static function renderQuiz( $input, $argv, $parser ) {
+               $parser->disableCache();
+               $quiz = new Quiz( $argv, $parser );
+               return $quiz->parseQuiz( $input );
+       }
+}
diff --git a/Quiz.php b/Quiz.php
index b92e37f..1ddcc05 100644
--- a/Quiz.php
+++ b/Quiz.php
@@ -55,10 +55,11 @@
 $dir = __DIR__ . '/';
 $wgAutoloadClasses['Quiz'] = $dir . 'Quiz.class.php';
 $wgAutoloadClasses['Question'] = $dir . 'Quiz.class.php';
+$wgAutoloadClasses['QuizHooks'] = $dir . 'Quiz.hooks.php';
 $wgMessagesDirs['QuizExtension'] = __DIR__ . '/i18n';
 $wgExtensionMessagesFiles['QuizExtension'] = $dir . 'Quiz.i18n.php';
 
-$wgHooks['ParserFirstCallInit'][] = 'wfQuizExtension';
+$wgHooks['ParserFirstCallInit'][] = 'QuizHooks::wfQuizExtension';
 $wgHooks['ParserClearState'][] = 'Quiz::resetQuizID';
 
 $commonModuleInfo = array(
@@ -72,30 +73,3 @@
        'styles' => 'ext.quiz.css',
        'position' => 'top',
 ) + $commonModuleInfo;
-
-/**
- * Register the extension with the WikiText parser.
- * The tag used is <quiz>
- *
- * @param $parser Parser the wikitext parser
- * @return Boolean true to continue hook processing
- */
-function wfQuizExtension( &$parser ) {
-       $parser->setHook( 'quiz', 'renderQuiz' );
-       return true;
-}
-
-/**
- * Call the quiz parser on an input text.
- *
- * @param $input String text between <quiz> and </quiz> tags, in quiz syntax.
- * @param $argv Array an array containing any arguments passed to the extension
- * @param $parser Parser the wikitext parser.
- *
- * @return string An HTML quiz.
- */
-function renderQuiz( $input, $argv, $parser ) {
-       $parser->disableCache();
-       $quiz = new Quiz( $argv, $parser );
-       return $quiz->parseQuiz( $input );
-}
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..e530ae2
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,39 @@
+{
+       "name": "Quiz",
+       "version": "1.2.0",
+       "author": "Louis-RĂ©mi Babe",
+       "url": "https://www.mediawiki.org/wiki/Extension:Quiz";,
+       "descriptionmsg": "quiz_desc",
+       "license-name": "GPL-2.0+",
+       "type": "parserhook",
+       "MessagesDirs": {
+               "QuizExtension": [
+                       "i18n"
+               ]
+       },
+       "AutoloadClasses": {
+               "Quiz": "Quiz.class.php",
+               "Question": "Quiz.class.php",
+               "QuizHooks": "Quiz.hooks.php"
+       },
+       "ResourceModules": {
+               "ext.quiz": {
+                       "scripts": "ext.quiz.js",
+                       "styles": "ext.quiz.css",
+                       "position": "top"
+               }
+       },
+       "ResourceFileModulePaths": {
+               "localBasePath": "modules",
+               "remoteExtPath": "Quiz/modules"
+       },
+       "Hooks": {
+               "ParserFirstCallInit": [
+                       "QuizHooks::onParserFirstCallInit"
+               ],
+               "ParserClearState": [
+                       "Quiz::resetQuizID"
+               ]
+       },
+       "manifest_version": 1
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/257831
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I041814e2788f238c8840f60132784e2bda6a04bc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Quiz
Gerrit-Branch: master
Gerrit-Owner: Ananay <i...@ananayarora.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to