VerbTech/QCL Wikibook/An Outline of the Language

From Wikibooks, open books for an open world
Jump to navigation Jump to search

< User:VerbTech/QCL Wikibook

Questions Unrelated[edit | edit source]

In this section, we assume that the QApairs in your quiz are unrelated.

There are no common patterns to them.

There are no associated probabilities or difficulties with them.

You will effectively be learning how to make a single QApair.


Question and Answer Unrelated[edit | edit source]

In this section, we assume that in your QApair the Qpart is unrelated to the Apart.

This will make more sense once you have read the section where they are related.


Single Question[edit | edit source]

The Qpart of a QApair is made up of questions.

In this section, we assume your Qpart has just one question in it.


Simple Question[edit | edit source]

Here is the simplest possible sort of QApair you could make:

What is the capital of Australia?;;Canberra

Try it out by writing a quiz with 5 QApairs, as we have done below:

What is the capital of Australia?;;Canberra
The name of a baby goose is what?;;Gosling
// Next we will ask chemistry questions
What is the symbol for Hydrogen?;;H
What is the symbol for Helium?;;He
What is the symbol for Lithium?;;Li

Place this code in the QCL text box of the Quiz Content Tab.

Then click Begin Quiz in the Quiz Tab and try the test.

If you have not changed any of the default settings, then you will have to type the answer exactly and press return (or click the Submit button, if you are using a different Quiz app).

The line beginning with // is called a single-line comment.

Everything on that line is ignored by the interpreter.

A multi-line comment looks like this:

/* Here is my comment.
It goes over multiple lines.
Just three for now. */

The syntax is to begin it with /* and end it with */.

It is useful for commenting out blocks of QApairs. That is, turning off a group of QApairs.

The last thing to say about this is that if you want to use a semicolon ; in your question or answer, then you have to type \;

\ Is called an escape character.

These are needed because QCL uses some characters that you may want to put in your content.

In the following table, the characters on the left are ones that you can only use as part of your content, if you use the character sequence on the right instead:

Character Character Escape Sequence
; \;
{ \{
} \}
\ \\
[ \[
] \]

So, to make it clear, if we wanted the question:

Do {you} like; incorrect \ punctuation [use]?

We would have to use:

Do \{you\} like\; incorrect \\ punctuation \[use\]?


Single Varytag[edit | edit source]

A varytag is a part of a question that can change its contents at run time.

Run time is when the code is being processed and the quiz is being done.

Here is a simple example of a varytag in the Qpart of a QApair:

What is the {capital|capital city|seat of government} of Australia?;;Canberra

When this QApair is used in the quiz, it has a 1 in 3 chance of being asked as any of the following:

What is the capital of Australia?
What is the capital city of Australia?
What is the seat of government of Australia?

capital, capital city, and seat of government are possibilities of the varytag.

Notice that the following two questions are the same to the interpreter:

What is the capital of Australia?
What is the {capital} of {Australia}?
  • If you repeat a possibility like this:
What is the {capital|capital|capital|capital city|seat of government} of Australia?;;Canberra
then the chances of that possibility being chosen are increased correspondingly.
In this case, capital has a 3/5 chance of being chosen for that place.
  • If you substitute a varytag for a possibility like this:
What is the {{capital|capital city}|seat of government} of Australia?;;Canberra
then that also changes the chances that the more nested possibilities will be chosen.
In this case, {capital|capital city} is just as likely to be chosen as government.


Rather than nesting or repeating possibilities, it is better to assign probabilities, as we will see in the next section.


Single Varytag with Probabilities[edit | edit source]

The possibilities of a varytag can be assigned probabilities.

Here is an example of a varytag in a QApair with probabilities assigned:

What is the {[%2]capital|[%3]capital city|[%5]seat of government} of Australia?;;Canberra

2 is the raw probability of the possibility capital. Similarly, 3 is the raw probability of the possibility capital city.

If you add the raw probabilities of this varytag, you get 10.

2/10 (or 0.2 or 20%) is the probability of the possibility capital.

That is, there is a 2/10 likelihood of being asked this:

What is the capital of Australia?

If raw probabilities are missing, like this:

What is the {[%2]capital|[%3]capital city|seat of government} of Australia?;;Canberra

then the interpreter assumes the remaining ones have raw probabilities of 1, like this:

What is the {[%2]capital|[%3]capital city|[%1]seat of government} of Australia?;;Canberra

The raw probabilities must be non-zero positive integers (from the set: {1,2,3,...}).

[%2]capital is the first possibility of the varytag {[%2]capital|[%3]capital city|[%1]seat of government}.

capital is its content.

[%2] is its raw probability, and must come before its content.

[%2] is called a probability tag.

Probability tags are a type of structure tag. You will meet more of these along the way.


The first symbol inside the structure tag, which is % in this case, is important. It indicates the purpose of the structure tag.

Just remember that % is the Percentage sign and stands for Probability.


Multiple Varytags related by Anchors[edit | edit source]

Sometimes, you will want possibilities in different varytags to be tied together.

For instance, you might want an to come before words beginning with vowels, and a to come before words beginning with consonants.

For this, you will need anchors.

Here is a simple example of anchors in use below:

What is {[@1]a|[@2]an} {[@1]{cat|dog|horse|squirrel}|[@2]{elephant|aardvark|ocelot}}?

Anchors are another kind of structure tag, and so are placed in square brackets [ ], too.

They always begin with an at sign @, and can be any combination of letters or numbers or the underscore character _.

It is usual, though, to use numbers.

Just remember that @ is the At sign and stands for Anchor.

The interpreter reads it from left to right and works like this:

In the first varytag, it chooses a or an.

This is called evaluation of the varytag.

Supposing it chose a, the current construction of the question would be:

What is a

a has the anchor 1.

It tracks this in something called the ongoing anchor set.

The ongoing anchor set currently has only the element 1 in it.

When it meets the next varytag, it excludes some of the possibilities based on the ongoing anchor set.

To not be excluded and remain a possibility, the possibility must have:

  • No anchors
OR
  • At least one anchor which is in the ongoing anchor set.

In this case, the varytag would turn into {cat|dog|horse|squirrel}.

Which it might evaluate, with a 1 in 4 chance, to dog resulting in:

What is a dog?


Multiple Varytags with Forced Evaluation Order[edit | edit source]

In the previous section, we saw that the question wasn’t quite fair, because the 7 animals didn't each have a 1 in 7 chance of being chosen.

To solve this, we can force the order of evaluation of the varytags.

Here is how we do it:

What is [#2]{[@1]a|[@2]an} [#1]{[@1]{cat|dog|horse|squirrel}|[@2]{elephant|aardvark|ocelot}}?

This means that the second tag would be evaluated first.

This still doesn’t solve the problem. To do that we need to assign probabilities to the possibilities like this:

What is [#2]{[@1]a|[@2]an} [#1]{[@1][%4]{cat|dog|horse|squirrel}|[@2][%3]{elephant|aardvark|ocelot}}?

This type of structure tag, [#1], is called an index tag.

It must be of the form [#n], where n is a non-zero positive integer ({1,2,3,...}).

If there are some varytags with varytag indexes, and some without, then the varytags with them are evaluated first, in the correct order, followed by those without them, from left to right.

You can use repeated anchor tags to repeat a varytag like this:

If [#1]{John|Mark|Tom} has three beans and gives away two, how many does [#1] have left?

If the varytag was evaluated as Mark, then the question would appear as this:

If Mark has three beans and gives away two, how many does Mark have left?

You may have a lot of "what if...?" questions about this feature.

To answer them, you should try them out and understand how the interpreter works with the feature.

Here's what happens:

tsttststs  [#1]tsttsts  [#1]tsttsts [#1]{A|E|O} stssts [#1]stssst [#1]{R|P|L} sts [#1]stttst

The interpreter goes from left to right looking for the first index tag that has a varytag immediately after it.

It is [#1]{A|E|O}.

It then evaluates this. Suppose it evaluated it to be O.

Then it goes from left to right again and replaces all parts of the line that are [#1], like this:

tsttststs  Otsttsts  Otsttsts O stssts Ostssst O{R|P|L} sts Ostttst

Which it may carry on further to evaluate as:

tsttststs  Otsttsts  Otsttsts O stssts Ostssst OP sts Ostttst

Notice how it does not care about varytags with the index tag of [#1] that come after the first one.

It just looks for [#1] wherever it is and replaces it with O.

Finally, if for some odd reason you would like to have the actual piece of text [#1] in your question, then you have to use the escape characters mentioned earlier. Like this: \[#1\]


Multiple Questions[edit | edit source]

You can have multiple questions in the Qpart of the QApair. Here is an example:

What is A?;State what A is.;What type of symbol is A?;;A letter

There is a 1 in 3 chance that any of the questions in particular will be chosen.

To alter that probability, you can do the following trick:

{[%2]What is A?|[%3]State what A is.|[%5]What type of symbol is A?};;A letter

A QApair may be spanned over several lines, if it is felt to be easier on the eyes.

Here is an example:

{
	[%2]What is A?
	[%3]State what A is.
	[%5]What type of symbol is A?
	;;
	A letter.
}

Blank lines will be ignored.

The braces { } must be on their own lines.


Single Answer[edit | edit source]

So far we have only shown a QApair where the Apart has one answer in it:

What is the capital of Australia?;;Canberra


Multiple Lines in the Question or Answer[edit | edit source]

It is possible that your answer may have multiple lines in it.

Unfortunately, the enter button is used to make both a newline and to submit the answer.

To solve this problem, go in the Session Settings Tab and type the following code:

submit;;++

This tells the interpreter that in your next session, you will type ++ to submit your answer.

That is, as soon as the interpreter notices ++ in the Answer Box it takes all the text before ++ and evaluates the correctness of it.

Of course, there is no reason to choose ++. It can be what you like.

If it is blank, the interpreter only moves on to the next question, if the contents of the Answer Box are correct.

(You can find out more about how to change your quiz session, in the session settings section)

Back to the problem; a newline can be included in your character using the escape sequence \n

So in this QApair:

Type:\n1\n2\n3;;\n1\n2\n3

The question is asked as:

Type:
1
2
3

And the answer is expected to be:

1
2
3

(And of course, you would type ++ to submit that.)


Varytags[edit | edit source]

As with questions, you can include varytags in the answer:

What is Canberra?;;The {capital|capital city|seat of government} of Australia.

This means that The capital of Australia., The capital city of Australia., and The seat of government of Australia are all acceptable answers to the question What is Canberra?


Anchors[edit | edit source]

As with questions, you can use anchor tags to control the evaluation of the varytags and the range of acceptable answers:

Name an animal.;;{[@1]A|[@2]An} {[@1]{cat|dog|horse|squirrel}|[@2]{elephant|aardvark|ocelot}}.


Forced Evaluation Order[edit | edit source]

Currently, QCL does not support the index tags in answers.


Uppercase and Lowercase Insensitivity[edit | edit source]

For the QApair:

Name a fruit.;;{Apple|Orange|Banana|Grape|Kiwi}{.|}

We accept the answers Apple. and Apple

But, we may want to accept the answer apple

It is tedious to type:

Name a fruit.;;{Apple|apple|Orange|orange|Banana|banana|Grape|grape|Kiwi|kiwi}{.|}

We may be smart about this by typing something like:

Name a fruit.;;{{A|a}pple|{O|o}range|{B|b}anana|{G|g}rape|{K|k}iwi}{.|}

However, this makes the code hard to read, and it is a common enough problem for a shortcut to exist:

Name a fruit.;;[;Aa]{Apple|Orange|Banana|Grape|Kiwi}{.|}

The structure tag [;Aa] is a type of leniency tag. They feature in the Apart.

It applies to the varytag immediately following it.

It means that Apple., apple., and aPpLe. are all viewed as the same by QCL.


Substrings[edit | edit source]

It is very hard to predict what a user may answer in response to a question. For the question:

Name a fruit.

they may respond with Apple., An apple, Apple?.

A string in computing is just a sequence of characters, like abcde, and a substring is just a block contained within that sequence, like bc, cde, or even abcde itself.

We might care only if the answer is a substring of the user's attempted answer.

We can do that using the leniency tag [;sub] like this:

Name a fruit.;;[;Sub][;Aa]{Apple|Orange|Banana|Grape|Kiwi}

All of these would pass as answers:

An apple.
Kiwi
oRange.

Multiple Answers[edit | edit source]

Question and Answer Related[edit | edit source]

In this section, we assume that the Qpart and the Apart in your QApairs are related.


Substitutions[edit | edit source]

One common application for QCL is to be posed a sentence such as:

This 

List Answers[edit | edit source]

Questions Related[edit | edit source]

Templates and Replacements[edit | edit source]

Session Settings[edit | edit source]

Common Applications[edit | edit source]

General[edit | edit source]

In this section, we cover the several general types of questions that are frequently used in quizzes.

Multiple Choice[edit | edit source]

Multiple choice questions look like this:

Which is the largest number?
  ○ 31
  ○ 7
  ○ 23
  ○ 19


Checkboxes[edit | edit source]

True or False[edit | edit source]

Fill in the Blanks[edit | edit source]

Specific to the Writer's Kit that comes with Quizzer[edit | edit source]

SAT and GRE Vocabulary[edit | edit source]

Spellings and Misspellings[edit | edit source]

Prefixes, Suffixes, and Roots[edit | edit source]