# QuizLib Plugin ## Content The QuizLib Plugin for Dokuwiki embeds the JavaScript library QuizLib (https://alpsquid.github.io/quizlib/) of Andrew Palmer. The library offers functions to parse quizzes written in well-defined HTML syntax and to evaluate the user answers. Furthermore the plugin provide a simple XML-like syntax with a generic CSS styling as a all-round carefree package. Therefore 3 ways to write quizzes exist: * XML syntax with generic styling and generic evaluation function (only one quiz per HTML page) * HTML syntax with individual styling and generic evaluation function (only one quiz per HTML page) * HTML syntax and individual evaluation function for total freedom ## Preconditions The plugin is tested with: * 2016-06-26a "Elenor of Tsort" * 2015-08-10a "Detritus" ## Usage There a three kinds of question formats you can use: * plain text * radio buttons (exactly one correct answer) * checkbox (one or more correct answers) ### XML style Every quiz starts with the tag "quizlib". This tag contains as attributes the array with the correct answers ("rightanswers") and the string for the submit button ("submit"). Each element of the rightanswers-array is either a string (for the plain text questions) or again an array with the zero-based indexes ('a0', 'a1', …) of the correct answers (for radio and checkbox). Please use double quotes for the rightanswers-array and single quotes inside. The questions itself are child elements of the quizlib-tag. Each "question" has an attribute "title" with the content of the question and an attribute "type" (text, radio, checkbox). The possible answers are a list separated by a vertical bar. If you want to use characters that are protected in XML you have to work with entity references (http://www.w3schools.com/xml/xml_syntax.asp): * `<` for < * `>` for > * `&` for & * `'` for ' * `"` for " ```xml is a hamster|smells of elderberries Global warming| The release of Linux 4.1.15| Cats| Advancements in artificial intelligence ``` ### HTML style The syntax is rather self-explanatory, if something is unclear read documentation of the JavaScript library https://alpsquid.github.io/quizlib/ The only difference to the original is the generic evaluation function "quizlibShowResults". It's the callback function for the onlick-event in the submit-button. Its first argument is the id of the quiz, the second is the array with the answers. ```html
1. What is the answer to life, the universe and everything?
2. Your enemy's father...
3. Which factors will contribute to the end of humanity as we know it?
You Scored % - /
``` ### Total freedom style Like HTML style but you have to write your own evaluation function. ## Download https://gitlab.hrz.tu-chemnitz.de/sse-public/quizlib/repository/archive.zip?ref=master