For websites and blogs

A quiz for your website

Choose a question set, set colours and texts, and copy the code into your page. Every visit brings 9 different free questions, and each answer fills the mosaic.

Content
Question set
Look
Texts

Preview

Embed code

Paste the code where the quiz should appear on your page.

Good to know

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.

Download qwissit-proxy.php

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

  1. Your page gives the quiz a one-time code and remembers it.
  2. The visitor solves the quiz. Qwissit checks every answer itself; wrongly answered questions come back until all are right.
  3. At the end your page receives a proof that only Qwissit can issue and sends it to your server.
  4. 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

Text for your privacy policy

A suggestion you can adapt to your site. It is not legal advice.

Embedded directly

Through your own domain (proxy)

Certifications & exams

Which exam comes next?

You can already practise for 60 exams, and 7 are up for a vote. See all certifications with their official information, cast your vote or suggest your exam.

See all certifications