\documentclass{article} \usepackage[fleqn]{amsmath} \usepackage{graphicx} \usepackage [tight, designi,%forpaper, navibar ]{web} \usepackage{exerquiz} \usepackage[ImplMulti]{dljslib} \usepackage{pifont} % \previewOn \pmpvOn \title{Extending the Exerquiz Package Math Fillin Questions} \author{D. P. Story} \subject{Sample file} \keywords{LaTeX, PDF, derivative, calculus, JavaScript} \university{NORTHWEST FLORIDA STATE COLLEGE\\ Department of Mathematics} \email{dpstory@acrotex.net} \version{3.0} \copyrightyears{1999-\the\year} \norevisionLabel % Uncomment the lines below to create buttons % for "Begin Quiz", "End Quiz" instead of links \useBeginQuizButton[\textColor{blue}] \useEndQuizButton[\textColor{blue}] % Uncomment this line to require the student % to answer all questions in the quiz before % the quiz is evaluated. %\renewcommand\minQuizResp{highThreshold} % The following is to create a \js command in which JavaScript code % can be written, without the use of the \verb command. Merely cosmetic. \def\hvperk{\char`^} {\catcode`\^=\active \gdef\js{\bgroup\ttfamily\catcode`\^=\active \let^=\hvperk \jsi} }\def\jsi#1{#1\egroup} % Some convenience commands for differentiation. \def\D{\dfrac {\text{d}}{\text{d}x}} \def\dPose#1{$\D#1=$ } \begin{document} \maketitle \tableofcontents \section{Math Fill-In Question} The current version of \textsf{exerquiz} included only multiple choice questions. That's all well and good, but instructors would occasionally like to ask questions that would require the student to fill in the answer, whether it be numerical or symbolic. This new question type, the Math Fill-in, can be used in either the \texttt{shortquiz} or \texttt{quiz} environment. In the former case, there is immediate feedback as to right or wrong; in the latter case, correction is delayed until the quiz is completed and the user requests to be corrected. In either case, you can choose to include the correct answer, which can be obtained by the click of a button. The next section outlines the syntax for the user to enter the answer. \subsection{Instructions} When responding to a Math Fill-in question, you answer by typing in your answer. Use the following notation to enter your answers. \begin{itemize} \item Use \js{*} to indicate multiplication: Type \js{4*x} for $4x$; \item Use \js{^} to indicate powers: Type \js{4*x^3} for $4x^3$; \js{12*x^-6} for $12x^{-6}$. \item Use parentheses to delimit the argument of a function; i.e., type \js{sin(x)} rather than \js{sin x}. \item Use parentheses to define the {\it scope\/} of an operation: For example, type \js{4*x*(x^2+1)^3} for $4x(x^2+1)^3$; \js{ 4^(2*x+1)} for $4^{2x+1}$; \js{(sin(x))^2} for $(\sin(x))^2$. {\it Do not\/} type \js{sin^2(x)} for $\sin^2(x)$, type \js{(sin(x))^2} instead. \item You can also use brackets \js{[ ]} or braces \js{\{ \}}, to delimit a mathematics expression. \item Functions you may use: \begin{itemize} \item Trig: \js{sin}, \js{cos}, \js{tan}, \js{cot}, \js{sec}, \js{csc}; \item Inverse Trig: \js{asin}, \js{acos}, \js{atan}; \item Log: \js{ln} (natural log), or use \js{\tt log}; e.g. \js{ln(x)}; \item Exponential: The natural exponential function, $e^x$, can be entered as \js{exp(x)} or as \js{e^x}. \item The absolute function, \js{abs($\cdot$)} can also be written in the usual way \js{|$\cdot$|}; thus, you can type either \js{abs(x)} or \js{|x|}. \item Misc.: \js{sqrt}, usage \js{sqrt(x)} for $\sqrt{x}$ (or, use exponential notation: \js{x^(1/2)}). \end{itemize} \end{itemize} When you enter your response, some attempt will be made to determine whether the response is a valid mathematical expression. For example, if you say \js{san(x)}, the function `\js{san}' will not be recognized as a valid mathematical function; an error message is generated, and the user is not penalized for a possible typing error. The JavaScript routines will also check for unbalanced parentheses; thus, \js{((x^4+1) + sin(x)^2} will be flagged as a syntax error. \medskip\noindent\textcolor{red}{\textbf{Important:}} When you enter a function of a single variable---the only type currently supported---use as the independent variable implied by the statement of the problem. If the problem statement involves the variable $x$, use \js{x} as the independent variable; if the problem statement uses $t$, use \js{t} in your answer. To enter a function of $t$ when a function of $x$ is expected will, no doubt, result in missed problem. \subsection{Answers and Solutions} For fill-in questions, if the document author so wishes, answers and (optionally) solutions can be provided. The author provides an `\textsf{Ans}' button. This button is visible for a \texttt{shortquiz} and hidden for a \texttt{quiz}. For a \texttt{shortquiz}, the `\textsf{Ans}' button can be clicked at anytime. In the case of a \texttt{quiz}, after a \texttt{quiz} has been completed, the hidden `\textsf{Ans}' buttons appear. Click the button to get an answer to the problem. Concerning solutions. If the `\textsf{Ans}' button has a green boundary, that means that question has a solution. Performing a \textsf{Shift-Clicking} the `\textsf{Ans}' button causes the viewer to jump to the solution. For multiple choice questions, the boundary for the correct answer is colored green as well. \textsf{Click} the answer field to jump to the solution. Solutions to a \texttt{quiz} can be protected from prying eyes with the \texttt{\string\NoPeeking} command. See the \hyperref[s:quiz] {Section~\ref*{s:quiz}} for an example and a brief discussion. \subsection{Practice Example} \noindent\textcolor{blue}{\textbf{Example:}} Consider the following sample question. Practice by typing in the answer: \js{2*x^3*(x^4+1)^(-1/2)}. You can also type \js{2x^3(x^4+1)^(-1/2)} since the \texttt{ImplMulti} option is taken with the \textsf{dljslib} package. \medskip \begin{oQuestion}{example} \def\RBW{120pt}\def\DefaultHeightOfWidget{16pt}\def\TBW{18pt} \edef\STRUT{\noexpand\rule[\ifxetex-1bp\else-5bp\fi]{0pt}{0pt}} \noindent$\dfrac{\text{d}}{\text{d}x} {(x^4 + 1)^{1/2}} = \eqsanitize \underset{\text{\rotatebox{-45}{\rlap{The Response Box}}}} {\underbrace{\RespBoxMath{2*x^3*(x^4+1)^(-1/2)}{4}{.0001}{[1,2]}}} \underset{\text{\rotatebox{-45}{\rlap{Answer Button}}}} {\underbrace{\cgBdry\CorrAnsButton{2*x^3*(x^4+1)^(-1/2)}}} \underset{\text{\rotatebox{-45}{\rlap{Num.\ of incorrect tries}}}} {\underbrace{\olBdry\sqTallyBox\relax}}\olBdry\sqClearButton$ \end{oQuestion} \vspace{5\bigskipamount} \noindent When a correct answer is input into the response box, the color of the border surrounding the response box changes to \textcolor{webgreen}{green}. The answer can also be expressed correctly using the \js{sqrt} operator, try modifying the answer using \js{sqrt}. \newpage \subsection{Short Quiz Environment}\label{s:shortquiz} %In the following problems, answer by typing in your %response using the correct syntax. Problem \#2 illustrates how to define a problem with a variable other than the default $x$. \textsf{Click} the `\textsf{Ans}' button to get the answer, \textsf{shift-click} the `\textsf{Ans}' button that have a green boundary to get the solution. \begin{shortquiz*}[answer] Answer each of the following. Passing is 100\%. \answersEndHook{\hfill\makebox[0pt][r]{\sqTallyBox}} \begin{questions} \item If $f$ is differentiable, then $f$ is continuous. \begin{answers}[diff]{4} \Ans1 True & \Ans0 False \end{answers} \begin{solution} Yes, differentiability at a point implies continuity at that point. \end{solution} %If you want another variable other than $x$, then specify the variable immediately %following the correct answer in the \RespBoxMath command. Following the optional %variable specification is the optional named destination for the solution the %the problem. \item $\dfrac{\text{d}}{\text{d}t} {4 t^{-1/2}} = \RespBoxMath{-2*t^(-3/2)}(t)[diffprob]{4}{.0001}{[1,2]}$\hfill \CorrAnsButton{-2*t^(-3/2)}\cgBdry\sqTallyBox \begin{solution} We use the power rule: \begin{equation*} 4 t^{-1/2} = 4(-1/2) t^{-3/2} = \boxed{-2 t^{-3/2}} \end{equation*} Or, in the syntax of this quiz: \js{-2*t^(-3/2)}. \end{solution} \item \dPose{e^{x^2}}\RespBoxMath{2*x*e^(x^2)}{4}{.0001}{[0,1]}\hfill \CorrAnsButton{2*x*e^(x^2)}\olBdry\sqTallyBox \item $\displaystyle\int_0^\pi \sin(x)\,dx = \RespBoxMath{2}{1}{.0001}{[0,1]}$\hfill\CorrAnsButton{2}\olBdry\sqTallyBox \end{questions} \hfill\sqClearButton\olBdry\sqTallyTotal \end{shortquiz*} \subsection{Quiz Environment}\label{s:quiz} The example below illustrates multiple choice questions and objective math questions in the \texttt{quiz} environment and is protected by the \texttt{\string\NoPeeking} command. First, browse the solutions at the end of the file, when you encounter a solution protected by \texttt{\string\NoPeeking}, see what happens. Click on the `\textsf{Ans}' button to get answers, shift-click on `\textsf{Ans}' buttons that have a green boundary to get a solution. \NoPeeking % or put in preamble \begin{quiz*}{mathquiz} Answer each of the following. Passing is 100\%. \begin{questions} \item If $\lim_{x\to a} f(x) = f(a)$, then we say that $f$ is\dots \begin{answers}[cont]{3} \Ans0 differentiable &\Ans1 continuous &\Ans0 integrable \end{answers} \begin{solution} A function $f$ is said to be continuous at $x=a$ if $x\in\operatorname{Dom}(f)$, $\lim_{x\to a} f(x) $ exists and $\lim_{x\to a} f(x) = f(a)$. \end{solution} \item $\cos(\pi) = \RespBoxMath{-1}[cospi]{1}{.0001}{[2,4]}\cgBdry\kern1bp\CorrAnsButton{-1}$ \begin{solution} Of course, everyone knows that $\cos(\pi) = -1 $. \end{solution} \item \dPose{e^{x^2}}\RespBoxMath{2*x*e^(x^2)}[diffexp]{4}{.0001}{[0,1]}\cgBdry\kern1bp \CorrAnsButton{2*x*e^(x^2)} \begin{solution} First apply the rule for differentiating an the natural exponential, then apply the power rule: \begin{align*} \dfrac d{dx}\,e^{x^2} & = e^{x^2}\,\dfrac d{dx}\,x^2 \\& = e^{x^2}\,(2x) \\& = 2x e^{x^2} \end{align*} In the syntax of this document, \js{2*x*e^(x^2)}. \end{solution} \end{questions} \end{quiz*}\quad\ScoreField\currQuiz\olBdry\CorrButton\currQuiz \noindent Answers: \AnswerField\currQuiz \end{document}