Preview
Embed code
Paste the code where the quiz should appear on your page.
Good to know
- If your site uses a Content Security Policy, add to script-src: https://www.qwissit.com
- The widget sets no cookies and stores nothing in the browser. It only loads the script and the questions from Qwissit.
- The questions change automatically. To change colours or texts, create a new code here and replace the old one.
Optional: embedding through your own domain
If you do not want any requests to third-party servers, your web server delivers the quiz: it passes a path such as /qwissit/ on to Qwissit. Your visitors' browsers then only talk to your domain, and Qwissit only sees your server's address. Embedding directly as above stays the simple default.
1. Set up your web server: pass /qwissit/ on to https://www.qwissit.com/widget/v1/, without cookies, IP address or other details of your visitors.
nginx
location ^~ /qwissit/ {
proxy_pass https://www.qwissit.com/widget/v1/;
proxy_set_header Host www.qwissit.com;
proxy_ssl_server_name on;
proxy_set_header X-Forwarded-For "";
proxy_set_header X-Real-IP "";
proxy_set_header Cookie "";
proxy_set_header Referer "";
proxy_set_header User-Agent "qwissit-proxy";
proxy_hide_header Set-Cookie;
}Apache (mod_proxy, mod_ssl, mod_headers)
SSLProxyEngine On
<Location "/qwissit/">
ProxyPass "https://www.qwissit.com/widget/v1/"
ProxyAddHeaders Off
RequestHeader unset Cookie
RequestHeader unset Referer
RequestHeader set User-Agent "qwissit-proxy"
Header unset Set-Cookie
</Location>Caddy
handle_path /qwissit/* {
rewrite * /widget/v1{path}?{query}
reverse_proxy https://www.qwissit.com {
header_up Host {upstream_hostport}
header_up -X-Forwarded-For
header_up -Cookie
header_up -Referer
header_up User-Agent qwissit-proxy
header_down -Set-Cookie
}
}PHP (Shared Hosting)
No access to the server configuration (shared hosting)? Download the PHP file, save it as qwissit-proxy.php in your web folder and use /qwissit-proxy.php/qwissit-widget.js as the script address. It only passes on the widget's files.
2. Replace the script address in the code above:
<script src="/qwissit/qwissit-widget.js" async></script>
3. Self-test: the request with your domain must return 200 and content-type: text/javascript. A 404 points to an item under "If it does not work", an HTML page means your CMS took over the request.
curl -I https://example.org/qwissit/qwissit-widget.js
Then in the browser with the developer tools (F12), tab "Network": no request to www.qwissit.com may appear.
If it does not work
- nginx returns 404: rules for static files such as location ~* \.(js|css)$ take precedence over plain prefix rules, so nginx looks for qwissit-widget.js on your server. That is why the snippet says location ^~ /qwissit/ – the ^~ makes sure this path is always passed on.
- Changes only take effect after a reload: nginx -t && nginx -s reload, for Apache apachectl configtest && systemctl reload apache2. In Docker with a single mounted configuration file, the container keeps seeing the old version after the file is replaced (rsync, cp) – then only a restart of the container helps (docker compose restart <service>).
- Apache: the modules proxy, proxy_http, ssl and headers must be enabled (a2enmod proxy proxy_http ssl headers). The rules belong in the server or VirtualHost configuration, not in .htaccess. If you can only use .htaccess, use the PHP file.
- PHP file: it must really be in the web folder (for TYPO3 in public/), otherwise the CMS takes over the request. The server must pass the path after the file (PATH_INFO) to PHP: on Apache AcceptPathInfo On (the default at many hosts), on nginx in the PHP rule like this:
location ~ \.php(/|$) { fastcgi_split_path_info ^(.+\.php)(/.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; # … your usual fastcgi_pass / include fastcgi_params }
Optional: check results tamper-proof
Do you want to record on your website that someone passed the quiz – for example to tick off a lesson or award points? Then let Qwissit confirm the result. That way nobody can fake it.
How it works
- Your page gives the quiz a one-time code and remembers it.
- The visitor solves the quiz. Qwissit checks every answer itself; wrongly answered questions come back until all are right.
- At the end your page receives a proof that only Qwissit can issue and sends it to your server.
- Your server asks Qwissit whether the proof is genuine and matches your code and quiz. Only then does it save the result.
What you add
Two places, both in PHP. Your visitors need to be signed in (session), because the result is meant to belong to someone.
A) On the page with the quiz: This block replaces the normal snippet. Adjust data-set and data-course to your quiz – the values are in the code above.
<?php
session_start(); // your visitors are signed in
$nonce = $_SESSION['quiz_nonce']['http'] ??= rtrim(strtr(base64_encode(random_bytes(16)), '+/', '-_'), '=');
?>
<div id="quiz" data-qwissit-widget data-set="12" data-course="13" data-lang="de"
data-verify="<?= $nonce ?>"></div>
<script src="https://www.qwissit.com/widget/v1/qwissit-widget.js" async></script>
<script>
document.getElementById('quiz').addEventListener('qwissit:finish', function (e) {
if (!e.detail.passed || !e.detail.token) return;
fetch('quiz-complete.php', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: 'lesson=http&token=' + encodeURIComponent(e.detail.token)
}).then(function (r) {
if (r.ok) { /* done: e.g. show a tick */ }
});
});
</script>
B) A new file quiz-complete.php in the same folder. Enter the same values for set and course in QUIZZES and save the result at the marked line in whatever way suits your website.
<?php
// quiz-complete.php – checks the result with Qwissit and saves it only if everything matches
session_start();
const QUIZZES = ['http' => ['set' => 12, 'course' => 13]]; // same values as data-set / data-course
$lesson = (string)($_POST['lesson'] ?? '');
$token = (string)($_POST['token'] ?? '');
$quiz = QUIZZES[$lesson] ?? null;
$nonce = (string)($_SESSION['quiz_nonce'][$lesson] ?? '');
if (!$quiz || $nonce === '' || $token === '') { http_response_code(400); exit; }
$ch = curl_init('https://www.qwissit.com/widget/v1/verify');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query(['token' => $token]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 4,
]);
$r = json_decode((string)curl_exec($ch), true);
curl_close($ch);
if (!is_array($r)) { http_response_code(503); exit; } // Qwissit not reachable: save nothing
if (($r['valid'] ?? false) !== true
|| !hash_equals($nonce, (string)($r['nonce'] ?? ''))
|| (int)$r['set'] !== $quiz['set'] || (int)$r['course'] !== $quiz['course']) {
http_response_code(403); exit; // forged, already used, expired or another quiz
}
unset($_SESSION['quiz_nonce'][$lesson]); // the code counts only once
// ▶ save the result here, e.g. user + $lesson + date (+ $r['wrong'] = failed attempts)
header('Content-Type: application/json');
echo json_encode(['ok' => true]);
The file only saves if Qwissit confirms the proof, it belongs to your one-time code and comes from the right quiz. After that the code is used up, so each result counts only once. If Qwissit cannot be reached right now, nothing is saved – let the visitor try again later. The proof is valid for one hour.
Good to know
- Why the detour through your server? The widget also reports the end of the quiz directly in the browser (event qwissit:finish), but anyone with a little technical knowledge can trigger that themselves. It is enough for a display, not for points, certificates or unlocks.
- Only show the quiz with a one-time code to signed-in visitors and do not create a session for everyone else – otherwise every bot creates one.
- Protect quiz-complete.php like your other forms: check the login, only accept requests from your own site, limit the number of requests.
- After a success the visitor gets a new code on the next visit and can repeat the quiz.
- To test: a made-up proof, the same proof a second time and the proof of another quiz must all be rejected.
Text for your privacy policy
A suggestion you can adapt to your site. It is not legal advice.
Embedded directly
On this website we embed a quiz from Qwissit (www.qwissit.com). When it loads, your browser fetches the script and the questions from www.qwissit.com; this transmits your IP address. The quiz sets no cookies, stores nothing in your browser and does not store your answers. The legal basis is our legitimate interest in an interactive learning offer (Art. 6(1)(f) GDPR). More: https://www.qwissit.com/en/privacy#widget
Through your own domain (proxy)
On this website we embed a quiz from Qwissit. Our own server delivers the script and the questions, fetching them from Qwissit. Your browser does not connect to Qwissit, and Qwissit receives neither your IP address nor cookies or other details about you. The quiz sets no cookies, stores nothing in your browser and does not store your answers. More: https://www.qwissit.com/en/privacy#widget