This repository has been archived by the owner on Aug 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
297 lines (268 loc) · 8.74 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quizify – JavaScript Quiz Library</title>
<meta name="description" content="quizify is a javascript library that helps you to administer quizzes on your website">
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css" integrity="sha384-" crossorigin="anonymous">
<!--[if lte IE 8]>
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/grids-responsive-old-ie-min.css">
<![endif]-->
<!--[if gt IE 8]><!-->
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/grids-responsive-min.css">
<!--<![endif]-->
<!--[if lte IE 8]>
<link rel="stylesheet" href="site/css/site-old-ie.css">
<![endif]-->
<!--[if gt IE 8]><!-->
<link rel="stylesheet" href="site/css/site.css">
<!--<![endif]-->
</head>
<body>
<a href="https://github.com/jacojvv-dev/quizify">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"
alt="Fork me on GitHub">
</a>
<div id="layout" class="pure-g">
<div class="sidebar pure-u-1 pure-u-md-1-4">
<div class="header">
<h1 class="brand-title">Quizify</h1>
<h2 class="brand-tagline">JavaScript Quiz Library</h2>
<p>... that you probably should't use</p>
</div>
</div>
<div class="content pure-u-1 pure-u-md-3-4">
<div id="outline">
<h2>Page Outline</h2>
<a href="#demo">Demo</a>
<br>
<a href="#setup">Setup & Installation</a>
<br>
<a href="#initialization">Initialization</a>
<br>
<a href="#data-example">Example Quiz Data</a>
<br>
<a href="#options">Options</a>
<br>
<a href="#usage">Usage</a>
</div>
<div id="demo">
<h2>Demo</h2>
<p>This is a very simple presentation of quizify, it isn't flashy. Quizify does allow you to make it flashy
however.
</p>
<div id="quizContainer" style="background-color: #ecf0f1; padding: 15px;border-radius: 8px;"></div>
</div>
<!-- setup block -->
<div id="setup">
<h2>Setup & Installation</h2>
<p>Download from npm and then require into your project.</p>
<pre>
<code class="bash">
> npm install quizify
</code>
</pre>
<pre>
<code class="javascript">
const quizify = require('quizify');
</code>
</pre>
</div>
<!-- initilisation block -->
<div id="initialization">
<h2>Initialization</h2>
<p>Create a new quiz object by calling new on quizify. The
<a href="#data-example">data</a> argument is required, the
<a href="#options">options</a> argument is optional.</p>
<pre>
<code class="javascript">
const quiz = new quizify(data, options = null);
</code>
</pre>
</div>
<div id="data-example">
<h2>Example Quiz Data</h2>
<p>Here is an example of quiz data to initialise your quiz with.</p>
<pre>
<code class="javascript">
[
{
id: 1,
content: 'Which of the following will result in the answer 2?',
weight: 5,
answer_limit: null,
answers: [
{
id: 1,
content: '1 + 1',
is_correct: true
},
{
id: 2,
content: '2 - 1 + 3',
is_correct: false
},
{
id: 3,
content: '4 / 2',
is_correct: true
},
{
id: 4,
content: '42 / 42 + 2',
is_correct: false
}
]
},
...
];
</code>
</pre>
</div>
<!-- option block -->
<div id="options">
<h2>Options</h2>
<p>These are the options avaiable when constructing a new quiz via the quizify constructor. These are the defaults</p>
<pre>
<code class="javascript">
{
/**
* Should the questions be shuffled
*/
shuffle: true,
/**
* Should the answers be shuffled
*/
shuffleAnswers: true,
/**
* Limit the total questions presented to
*/
limitQuestionsTo : null,
/**
* The class to attach to the question container
*/
questionContainerClass : 'quizify-question-container',
/**
* The class to attach to the ul answer list
*/
answerListClass : 'quizify-answer-list',
/**
* The class to attach to the li answer
*/
answerListItemClass : 'quizify-answer-list-item',
/**
* The class to attach to the next button
*/
questionNextButtonClass : 'quizify-button-next'
}
</code>
</pre>
</div>
<div id="usage">
<h2>Usage</h2>
<p>This is an example usage of quizify.</p>
<pre>
<code class="javascript">
var simpleQuiz = [
{
id: 1,
content: 'True or false? Dogs are herbivores.',
weight: 5,
answer_limit: null,
answers: [
{
id: 1,
content: 'False, they are omnivores.',
is_correct: true
},
{
id: 2,
content: 'True, they are herbivores.',
is_correct: false
}
]
},
{
id: 2,
content: 'What is the chemical symbol for the element oxygen?',
weight: 5,
answer_limit: 6,
answers: [
{
id: 3,
content: 'Ox',
is_correct: false
},
{
id: 4,
content: 'O',
is_correct: true
},
{
id: 5,
content: 'Oxy',
is_correct: false
},
{
id: 6,
content: 'o2',
is_correct: false
}
]
}];
document.addEventListener('DOMContentLoaded', function () {
// the container that houses our quiz
var quizContainer = document.getElementById('quizContainer');
// a new quizify object
var quiz = new quizify(simpleQuiz, {
questionNextButtonClass: 'pure-button pure-button-primary'
});
// listen for an answer selected event on quizify, and then proceed to either the next
// question or the result
quiz.addEventListener('answerSelected', handleQuizMoveToNext);
function handleQuizMoveToNext() {
// get the next question from the quizfy object
var question = quiz.getNext();
// remove all children in container
while (quizContainer.hasChildNodes()) {
quizContainer.removeChild(quizContainer.lastChild);
}
// do logic specific to a question here
if (question.type === 'question')
quizContainer.appendChild(question.data.dom_node);
// do logic specific to a result here, you might for
// instance want to post the results to a server endpoint
else if (question.type === 'result'){
quizContainer.appendChild(question.data.dom_node);
}
}
// call once on startup
handleQuizMoveToNext();
});
</code>
</pre>
</div>
<div class="footer">
<div class="pure-menu pure-menu-horizontal">
<ul>
<li class="pure-menu-item">
<a href="https://github.com/jacojvv-dev/quizify" class="pure-menu-link">GitHub Page</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<script src="dist/quizify.min.js"></script>
<script src="site/js/site.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>
hljs.configure({
tabReplace: '', // 4 spaces
})
hljs.initHighlightingOnLoad();
</script>
</body>
</html>