Quiz Building

Ken Levasseur
Mathematical Sciences
UMass Lowell
Lowell MA
Kenneth_Levasseur@uml.edu

\Note:  I've put all function definitions into initialization cells.\

\Here is possible "structure" for quizzes.  A quiz might be a list \of the form\>

{StudentName, StudentID, StudentPassword, DateTaken, QAFList}

Of course there may be a different mix of information that you might \decide to collect instead of the first four items.   QAFList represents a list of questions, student answers and feedback  (and maybe \more). 

 How would you build and use such a quiz?

Building a Quiz

The Header

The first four items in a list are easy to get

GetHeader[] := {InputString["Your name?"],         InputString["Your ID?"], InputString["Your Password?"],         Date[]}

Try it:

GetHeader[]

Although GetHeader[] functions alone, it won't be used that way.  It will be embedded in a \quiz making function later.

The Questions

\Although we think of a question as simply a question, the key to \organizing this data is to collect a response,"do the grading" and put \everything together in the finished quiz.  Naturally, this makes questions \more complicated, but it will pay off in the end.Here is a question asking for a simple addition that will serve as prototype \question.  The question builds a string that is going to represent the actual \question, then ask for a response, compute the correct answer, give a grade 	o the response, and build a response to the student.  All of this \information is stored in a list that can be used to keep records\>

\(SumQuestion[a_, b_] :=       Module[{s, r, score}, 
        	\ {s = ToString[a]<>" + "<>ToString[b]<>" = ?",           r = Input[s], a + b, score = If[r == a + b, 1, 0],           If[score == 1,             "Right! "<>ToString[a]<>" + "<>ToString[b]<>" = "<>              ToString[r], 
			            "Wrong, "<>ToString[a]<>" + "<>ToString[b]<>" = "<>              ToString[a + b]]}]\)

\Just as with GetHeader, SumQuestion can be evaluated alone, but \will usually be embedded in a quiz.  Here is the result of a correct esponse.\>

SumQuestion[4, 5]

Here is what happens if when a response is incorrect

SumQuestion[4, 5]

Before we finalize this question, we should ask whether the information 	hat is collected is sufficient for our needs for this type of question and \for any others we might ask.  This is important because we will want to \standardize all questions to have the same basic structure.  Let's assume 	hat it is sufficient.

To build what we called the QAFList above is simply a matter of making a list of these questions.

Maybe \you have a favorite, sequence of questions to ask. Every time the specificQList is evaluated, that particular list of questions will be asked.

specificQList       := {SumQuestion[4, 5], SumQuestion[6, -2], SumQuestion[5, 19],         SumQuestion[-19, -5], SumQuestion[40, 50]}

Or maybe you want to vary parts of your quiz.

randomQList :=       Module[{ran, p, q},         ran := Random[Integer, {5, 20}]; {SumQuestion[ran, 5],           SumQuestion[ran, -2], SumQuestion[p = ran, q = ran],           SumQuestion[-q, -p], SumQuestion[10  ran, 10  ran]}]

Building a Full Quiz

\With the parts that have been defined above, a quiz is very easy to \assemble\>

quiz1 := Append[GetHeader[], specificQList]

quiz2 := Append[GetHeader[], randomQList]

Ken1 = quiz1

Your turn to try a quiz!

YourTurn = quiz2

Using quizzes

\Here is the outcome of a quiz that will be used to illustrate the \following functions\>

Ken1       = {"Ken Levasseur", "AB1234",         "xxxx", {1998, 8, 11, 16, 37,           11}, {{"4 + 5 = ?", 9, 9, 1, "Right! 4 + 5 = 9"}, {            "6 + -2 = ?", 4, 4, 1, "Right! 6 + -2 = 4"}, {            "5 + 19 = ?", 23, 24, 0, "Wrong, 5 + 19 = 24"}, {            "-19 + -5 = ?", -23, -24, 0,             "Wrong, -19 + -5 = -24"}, {"40 + 50 = ?", 90, 90, 1,             "Right! 40 + 50 = 90"}}}

Computing grades

\The grade function relies on the fact that the grade for any \question is the fourth entry of the list and that the question list is the \last entry in a quiz.\>

Grade[quiz_] :=       quiz // Last // Transpose // Apply[Plus, #[[4]]]&

Grade[Ken1]

Grade[YourTurn]

Reporting results

Printing information for reading by humans is often messy and this is no \exception.  All it is is a bunch of print statements with StringJoin (<>) \used to put strings together.  Note: "\n" sends printing to a new line.

\(Report[quiz_] := 
	      \((Print["Report on quiz taken by "<>quiz[\([1]\)]<>"
Date: "<>            ToString[quiz[\([4]\)]]]; 
		        Map[\((Print[                "Question:"<>#[\([1]\)]<>"
Response "<>                  ToString[#[\([2]\)]]<>"
"<>#[\([5]\)]])\)&,           Last[quiz]]; 
		Print["Grade:"<>ToString[Grade[quiz]]])\)\)

Report[Ken1]

Report[YourTurn]

Another question

\(DifferentiationQuestion[exp_, var_] :=       Module[{s, r, ans, score}, 
        	\ {s =             "What is the derivative of "<>ToString[exp]<>              "  with respect to  "<>ToString[var]<>" ?",           r = Input[s], ans = D[exp, var],           score = If[Simplify[r] === Simplify[ans], 1, 0],           If[score == 1, "Right! ", 
			            "Wrong, The derivative of "<>ToString[exp]<>              " with respect to  "<>ToString[var]<>" is "<>              ToString[ans]]}]\)

This one works fine

DifferentiationQuestion[Sin[x], x]

This one brings out the shortcomings of the dialog box.

DifferentiationQuestion[4  x^5, x]

short = Append[GetHeader[], {DifferentiationQuestion[2  Cos[x], x]}]

Report[short]

Header?

Subtraction

State Capitals

Questions of your choice

Question Structure?