Learn more about Russian war crimes in Ukraine.

Inline quizzes

Stop and think of the last article you read and recite three facts from it. No? That article poured pearls of wisdom onto you, but they all rolled away. The article gave, but you could not even summon the effort to take.

Most of what I have learned has been through activity: exercises at school and university, problem-solving at work, writing blog posts at home. Effective writing encourages “active reading”. Our school textbooks knew how: every page is a mixture of description and exercises. The textbook gives a little, and asks a little in return. It’s a reciprocal, healthy relationship. In contrast, articles are pornography: attractive, short-term entertainment, asking for nothing, after which you feel empty.

The textbook’s paper is passive, unable to hide its secrets. But our webpages are active, and we can demand a little from our readers. At the start of this post, I asked you to recall the last article you read. Did you actually do it? No, I don’t believe you did! But I don’t blame you. Nothing stopped you skipping over the question to my conclusion!

That above redacted text is an example of an inline quiz. You’ll need to click it to see the answer. You can drop an inline quiz into most explanatory text. The following is an example of use, beginning an explanation of RSA.

An RSA private key consists of two primes, p and q. Its corresponding public key, n, is p × q. For example, if p=5 and q=7, then the public key is 5×7=35. Given the public key n, it’s hard to compute p and q. For example, if Alice’s public key n=143, what are p and q? 11 and 13, because 11×13=143. Even with these tiny numbers, this should have taken some thought! Alice also chooses a public exponent e, e.g. 7, then sends (n, e) to Bob, so her full public key is (n=143, e=7). Now Bob wants to send Alice the secret number m=42. To do so, Bob calculates ciphertext c=pow(m,e), modulo n. What ciphertext c should Bob send to Alice? 81. pow(42,7) = 230539333248, but modulo 143, c=81. ...

I believe the inline questions make the explanation more immersive. Even you didn’t answer all the questions yourself, you still had to participate to reveal the text. I’m going to try including these inline quizzes in most explanatory text I write on this blog.

These inline quizzes are implemented with:

What are <i>p</i> and <i>q</i>? <span class="answer">11 and 13.</span>
document.addEventListener("DOMContentLoaded", () =>
  Array.prototype.forEach.call(
    document.getElementsByClassName("answer"),
    el => el.addEventListener("click", () => el.classList.add("revealed"))));
.answer {
  border-color: #8ec58e;
  padding: 0 0.3rem;
  border-radius: 3px; border: 2px solid #8585d0;
}
.answer:not(.revealed) {
  color: rgba(0,0,0,0);
  background-image: url(/assets/question-mark.svg);
  cursor: pointer;
}

What can computers do? What are the limits of mathematics? And just how busy can a busy beaver be? This year, I’m writing Busy Beavers, a unique interactive book on computability theory. You and I will take a practical and modern approach to answering these questions — or at least learning why some questions are unanswerable!

It’s only $19, and you can get 50% off if you find the discount code ... Not quite. Hackers use the console!

After months of secret toil, I and Andrew Carr released Everyday Data Science, a unique interactive online course! You’ll make the perfect glass of lemonade using Thompson sampling. You’ll lose weight with differential equations. And you might just qualify for the Olympics with a bit of statistics!

It’s $29, but you can get 50% off if you find the discount code ... Not quite. Hackers use the console!

More by Jim

Tagged #blog. All content copyright James Fisher 2017. This post is not associated with my employer. Found an error? Edit this page.