Quiz/High level quizwriting software

From Wikiversity
Jump to navigation Jump to search

Pseudo code for numerical testwriting[edit | edit source]

The user of this code needs to know the language well enough to pose and solve problems using the language. These skills are generally included in any introductory college course on that language. It is preferable, but not mandatory that the user know a few wikitext commands, such as the break, "<br>" , and .

The user needs only the most primitive knowledge of how the high level language handles strings. The creation of new lines, concatenation of strings, and the conversion of numbers to strings are all handled by the code.

Pseudocode[edit | edit source]

This pseudocode is flawed but does serve to illustrate the idea:

The testwriter needs to be aware of reserved variables:

 "ANSWER " and "ANSWERUNITS"  inform the code that this is the answer (and units) to a questions.

We also need some reserved functions.

% Mathematical pseudocode (as per matlab % denotes comment)

d = random(4,7); #pseudocode for a random number between two variables

dunits = "feet"

r = random(2,3);

runits = " inches"

area = 12*pi*r^2*d; % pi = 3.1415...

ANSWER=area % ANSWER is a reserved variable

% Another reserved variable is ANSWERUNITS

ANSWERUNITS = "in^3" # or use wikitext  "in<sup>3</sup>"

% Best practice is for the user to summarize the problem here to facilitate writing the text

%Textual pseudocode

%In this section write strings and calls functions to handle the conversion of

% numbers to strings and the concatenation of strings into the questions.

% This section uses approximately three functions  that must have very short names:

% For example

%  Q_ is the question, S_ is a string variable, and A_ is a function

% A_(Q_,x) concatenates x to Q_ if x is a string

% A_(Q_,x) converts x to a string and concatenates if x is a number, units pair

% This permits code that is easy to write and proofread.  We start by clearing the question:

Q_ = "";

S_=''You have a cylinder that is";      Q_=A_(Q_,S_)

x = d; S_=dunits;           Q_=A_(Q_,x;);Q_=A_(Q_,S_)

S_=''tall.  It has a radius of ";      Q_=A_(Q_,S_)

x = r; S_=runits;           Q_=A_(Q_,x;);Q_=A_(Q_,S_)

S_=''. What is the diameter?";      Q_=A_(Q_,S_)

Now we call a function that uses ANSWER and ANSWERUNITS to construct the question.