summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/eq2db/eq2db.dtx
blob: 8911e10db31b77bb441b13c8cc574564e70bb2cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
% \iffalse
%<*copyright>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Eq2DB.sty package,             2001-9-01             %%
%% Copyright (C) 2014  D. P. Story                      %%
%%   dpstory@uakron.edu                                 %%
%%                                                      %%
%% This program can redistributed and/or modified under %%
%% the terms of the LaTeX Project Public License        %%
%% Distributed from CTAN archives in directory          %%
%% macros/latex/base/lppl.txt; either version 1 of the  %%
%% License, or (at your option) any later version.      %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%</copyright>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{eq2db}
%<package> [2016/01/02 v2.0 Save Exerquiz results to a Database, Email, or text file (dps)]
%<*driver>
\documentclass{ltxdoc}
\usepackage[colorlinks,hyperindex]{hyperref}
\makeatletter
\renewcommand{\paragraph}{\@startsection{paragraph}{4}{0pt}{6pt}{-3pt}{\bfseries}}
\makeatother
\pdfstringdefDisableCommands{\let\\\textbackslash}%
\EnableCrossrefs \CodelineIndex
\let\pkg\textsf
\let\env\texttt
\let\opt\texttt
\def\AEBBook{\textsl{{Acro\negthinspace\TeX} eDucation System Tools:
    {\LaTeX} for interactive PDF documents}}
\begin{document}
  \GetFileInfo{eq2db.sty}
  \title{The \texttt{eq2db} Package}
  \author{D. P. Story\\
    Email: \texttt{dpstory@uakron.edu}}
  \date{processed \today}
  \maketitle
  \tableofcontents
  \let\Email\texttt
  \DocInput{eq2db.dtx}
  \PrintIndex
\end{document}
%</driver>
% \fi
%    \section{Introduction}
%
% The \pkg{eq2db} package is meant to be used with the \pkg{exerquiz} package, one
% of the components of the \textbf{{Acro\negthinspace\TeX} eDucation Bundle}.
% The package is used to convert a quiz created by the \env{quiz} environment
% of \pkg{exerquiz} to one that submits the quiz results to a server-side script.
%
% The package can be designed to submit PDF form data as FDF, HTML, or XML. In the latter
% case, there are no supporting scripts; for FDF and HTML, I've written simple scripts that
% can be used on the server-side.
% \begin{itemize}
% \item For FDF submittal, the FDF Toolkit is required. Server-side scripts for a Windows server are provided
% for the \opt{eqRecord}, \opt{eqEmail}, and \opt{eqText} options. Additional details are found
% in the \pkg{eq2db} documentation manual.
%
% \item For HTML submittal, I've written eight
% server-side scripts for both Windows and Linux servers are provided.
% The \opt{eqEmail} and \opt{eqText} options are supported. These are available from the
% CD-ROM of my yet-to-be-submitted book, \AEBBook.
% Refer to the \pkg{eq2db} documentation
% manual for additional details.
% \end{itemize}
% Whether you submit as FDF, HTML, or XML is determined by the \opt{submitAs} option.
%
%    \section{Package Options}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%    \begin{macrocode}
\RequirePackage{xkeyval}
\let\eq@optioncode\@empty
%    \end{macrocode}
%    \begin{macro}{eqRecord}
% An option to store exerquiz data in a database, see \hyperref[eqrecord]{eqRecord}.
%    \begin{macrocode}
\DeclareOptionX{eqRecord}{\def\eq@optioncode{\input{eqrecord.def}}}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{eqEmail}
% An option to email exerquiz data to an instructor, see \hyperref[eqemail]{eqEmail}.
%    \begin{macrocode}
\DeclareOptionX{eqEmail}{\def\eq@optioncode{\input{eqemail.def}}}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{eqText}
% Save exerquiz data to a tab-delimited text field, see \hyperref[eqtext]{eqText}.
%    \begin{macrocode}
\DeclareOptionX{eqText}{\def\eq@optioncode{\input{eqtext.def}}}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{taoas}
% Private option for TAOAS
%    \begin{macrocode}
\DeclareOptionX{taoas}{\def\eq@optioncode{\input{taoas.def}}}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{custom}
% A option so developers can create their own custom set up for their own script.
%    \begin{macrocode}
\DeclareOptionX{custom}[eq2dbcus]{\def\eq@optioncode{\input{#1.def}}}
\def\eq@optioncode{\input{eq2dbcus.def}}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{tagged}
% The exerquiz quiz results are put into a quasi-XML format.
%    \begin{macrocode}
\let\eqdb@YES=y \let\eqdb@NO=n
\DeclareOptionX{tagged}{\let\eqdb@tagged\eqdb@YES}
\let\eqdb@tagged\eqdb@NO
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{submitAs}
% Allow user to submit as FDF, HTML, or XML. The scripts provided by this package
% are designed FDF submittal. The other submittal types are offered for anyone wishing
% to use this package for submitting forms to personally developed server-side scripts.
%
% When submitting as HTML and using the \texttt{eqText} option, the distribution does supply a
% scripts \texttt{eqText\_html.asp} (windows) and \texttt{eqText\_html.ph}p (linux/unix).
%    \begin{macrocode}
\define@choicekey*+{eq2db.sty}{submitAs}[\val\nr]{FDF,HTML,XML}[FDF]{%
    \ifcase\nr\relax
    \def\eqdb@submitType{FDF}\or
    \def\eqdb@submitType{HTML}\or
    \def\eqdb@submitType{XML}\else
    \def\eqdb@submitType{FDF}\fi
    }{\PackageWarning{eq2db}{Bad choice for submitAs,
    permissible values are\MessageBreak FDF, HTML, and XML.\MessageBreak
    Using the default FDF}%
}
\def\eqdb@submitType{FDF}
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
\ProcessOptionsX
%    \end{macrocode}
%    \begin{macrocode}
\RequirePackage{exerquiz}
%    \end{macrocode}
%    \section{Main Code}
% This code creates a way of hiding text fields. These fields are typically
% used to hold data that is sent to server-side script on submission.
%
%\medskip\noindent
% This is a token list to hold the list of hidden fields to be inserted into
% the document. We also provide a command for initializing the token list.
%    \begin{macrocode}
\newtoks\addtohidden \addtohidden={}
%    \end{macrocode}
%\medskip\noindent
% The macro \cs{eq@addHiddenTextFields} will be used to hold the accumulated
% hidden fields as we add another hidden field to the token list.
%    \begin{macrocode}
\def\eq@addHiddenTextFields{}
%    \end{macrocode}
%    \begin{macro}{\addHiddenTextField}
% This macro adds a new hidden text field to the token list
% \cs{addtohidden}. The command takes three parameters,
% the first of which is optional. The command
% \cs{hiddenTextField} actually creates the text field.
%\paragraph*{Parameters:}
%\begin{verbatim}
%[#1] = parameter to modify the parameters of the text field
% #2  = field name of the field being constructed
% #3  = default value of the field
%\end{verbatim}
%    \begin{macrocode}
\renewcommand\addHiddenTextField[3][]{%
    \addtohidden=\expandafter{\eq@addHiddenTextFields
        \llap{\hiddenTextField[#1]{#2}{#3}}}%
    \edef\eq@addHiddenTextFields{\the\addtohidden}%
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\hiddenTextField}
%
% This command actually creates a hidden text field \texttt{10bp} wide
% and \texttt{10bp} high. It is used by \cs{addHiddenTextField}, but can
% be used be the macro author as well. The command takes three parameters,
% the first of which is optional.
%\paragraph*{Parameters:}
%\begin{verbatim}
%[#1] = parameter to modify the parameters of the text field
% #2  = field name of the field being constructed
% #3  = default value of the field
%\end{verbatim}
%    \begin{macrocode}
\newcommand\hiddenTextField[3][]{\textField
    [\DV{#3}\V{#3}\F2#1]{#2}{10bp}{10bp}}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\populateHiddenField}
% Command for populating the value of a (hidden) text field at run time. This is executed
% by the `End Quiz' button.
%\paragraph*{Parameters:}
%\begin{verbatim}
% #1 = field name of the field
% #2  = field value. Strings need to be enclosed in double quotes
%\end{verbatim}
%    \begin{macrocode}
\newtoks\populatehiddenfields \populatehiddenfields={}
\def\eq@populateHiddenFields{}
\def\eq@initializepopulate{\gdef\eq@populateHiddenFields{}%
    \global\populatehiddenfields={}}
\renewcommand\populateHiddenField[2]{%
    \populatehiddenfields=\expandafter{\eq@populateHiddenFields
        this.getField("#1").value=#2;\jsR\jsT\jsT}%
    \edef\eq@populateHiddenFields{\the\populatehiddenfields}%
}
\def\eq@clearHiddenFields{\global\let\eq@populateHiddenFields=\@empty
    \global\let\eq@addHiddenTextFields=\@empty
}
%    \end{macrocode}
%    \end{macro}
% These hidden fields are created under the `End Quiz' button or link, and are populated
% when the user clicks on `End Quiz'. The following flag, set to \texttt{n} will be set
% to \texttt{y} when the fields are created, in this way, we can avoid creating them
% more than once.
%    \begin{macrocode}
\let\basicFieldsSet\eqdb@NO
%    \end{macrocode}
% \DescribeMacro{\rtnURL} For a non-FDF submittal, after the user submits, he must return to some
% web page. Use \cs{rtnURL} to pass the return url to the server-side script. The command
% \cs{definePath} is defined in \textsf{eforms}. Usage:
%\begin{verbatim}
%   \rtnURL{http://www.math.uakron.edu/~dpstory}
%\end{verbatim}
%    \begin{macrocode}
\providecommand{\rtnURL}{\definePath{\thisRtnURL}}
\let\thisRtnURL\@empty
%    \end{macrocode}
% \paragraph*{Input option code.} Now input the chosen option.
%    \begin{macrocode}
\eq@optioncode
%    \end{macrocode}
% \section{Tagged Responses}
% An option for this package is \texttt{tagged}, when the document
% author takes this option, the quiz responses are sent out in an
% XML-like encoding.
%
% The JavaScript function \texttt{gatherTaggedQuizData} builds up a
% "tagged" response string, which contains various pieces of
% information about the quiz results.
%    \begin{macrocode}
\ifx\eqdb@tagged\eqdb@YES
\begin{insDLJS}[gatherTaggedQuizData]{eqtagged}%
{Eq2db: Gather Tagged Data}
function gatherTaggedQuizData(currQuiz,filename,nQuestions) {
    var hasGroupedResp=false;
    var xmlResp="";
    var cResponses="<results id=\""+currQuiz+"\" file=\""+filename%
+"\" n=\""+nQuestions+"\">";
    var eqCredit;
    for ( var i=1; i <= nQuestions; i++)
    {
        if (typeof RightWrong[i] == "undefined") RightWrong[i]=0;
        if (typeof Responses[i] == "undefined") { %
Responses[i]=""; eqCredit=0; }
        if ( typeof ProbDist[i] == "undefined" )  ProbDist[i]=0;
        if (typeof ProbType[i] == "undefined") ProbType[i]="na";
        else eqCredit=ProbDist[i];
%        eqCredit=(typeof ProbValue[i] == "number") ? 0 : %
%( ProbValue[i][0]==0 )? ProbValue[i][2] : ProbDist[i];
        hasGroupedResp=( (typeof ProbValue[i] == "object") &&  %
(ProbValue[i][0]==1) );
        cResponses += "<question n=\"" + i + "\" type=\""
            + aPointType[i][1]+"\"";
        cResponses += " ptype=\""+ProbType[i]+"\"";
        switch ( aPointType[i][1] ) {
            case "grp":
                if ( hasGroupedResp ) {
                    var f=this.getField("grpobj."+currQuiz+"."+i);
                    var l=f.getArray().length;
                    RightWrong[i].length=l+1;
                    Responses[i].length=l+1;
                    if (hasGroupedResp)
                        cResponses += %
" points=\""+ProbValue[i][2] + "\"";
                    else
                        cResponses += %
" points=\""+aPointType[i][0] + "\"";
                    cResponses += " credit=\""+eqCredit + "\"";
                    xmlResp="";
                    for ( var j=1; j < RightWrong[i].length; j++) {
                        if ( typeof RightWrong[i][j] == "undefined" ) %
RightWrong[i][j]=0;
                        xmlResp += %
( typeof Responses[i][j] == "undefined" ) ? %
"<grpvalue></grpvalue>" : "<grpvalue>"+Responses[i][j]+"</grpvalue>";
                }
                    cResponses += %
" correct=\"["+RightWrong[i].slice(1)+"]\">";
                    cResponses += "<value>"+xmlResp+"</value>";
                } else {
                    cResponses += " points=\""+aPointType[i][0] + "\"";
                    cResponses += " credit=\""+eqCredit + "\"";
                    cResponses += " correct=\""+RightWrong[i]+"\">";
                    cResponses += "<value>"+Responses[i]+"</value>";
                }
                break;
            case "ms":
                cResponses += " points=\""+aPointType[i][0] + "\"";
                cResponses += " credit=\""+eqCredit + "\"";
                if ( typeof RightWrong[i][2] == "undefined" ) {
                    cResponses += " correct=\"0\">";
                    cResponses += "<value></value>";
                } else {
                    var f=this.getField("mck."+currQuiz+"."+i);
                    var l=f.getArray().length;
                    RightWrong[i][2].length=l+1;
                    Responses[i].length=l+1;
                    RightWrong[i][2].shift();
                    cResponses += %
" correct=\""+RightWrong[i].toSource()+"\">";
                    xmlResp="";
                    for ( var j=1; j < RightWrong[i][2].length; j++) {
                        if (typeof RightWrong[i][2][j] == "undefined") %
RightWrong[i][2][j]=0;
                        xmlResp +=
( typeof Responses[i][j] == "undefined" ) ? %
"<msvalue></msvalue>" : "<msvalue>"+Responses[i][j]+"</msvalue>";
                    }
                    cResponses += "<value>"+xmlResp+"</value>";
                }
                break;
            default:
                cResponses += " points=\""+aPointType[i][0] + "\"";
                cResponses += " credit=\""+eqCredit + "\"";
                cResponses += " correct=\""+RightWrong[i]+"\">";
                cResponses += "<value>"+Responses[i]+"</value>";
        }
        cResponses += "</question>";
    }
    cResponses += "</results>";
    return cResponses;
}
\end{insDLJS}
\fi
%</package>
%    \end{macrocode}
% \section{eqRecord}\label{eqrecord}
% Save quiz results to a database. The \texttt{eqRecord} option is meant to
% be used with the ASP code \textsf{eqRecord.asp}.
%
% The form the macro \cs{eqSubmit} is
%\begin{verbatim}
%\eqSubmit{http://..../eqRecord.asp\#FDF}
%           {database_name}{table_name}
%\end{verbatim}
% The first parameter is the URL to the \textsf{eqRecord.asp} script. The second is the
% DNS of the database. The third parameter is the name of the table into which the
% quiz data is to be stored.
% For example,
%\begin{verbatim}
%\eqSubmit{http://localhost/scripts/eqRecord.asp\#FDF}
%   {eqQuiz}{Math101}
%\end{verbatim}
% As with \textsf{eqRecord}, the first parameter of the \texttt{quiz} environment is
% the name of the quiz begin taken.
%\begin{verbatim}
%\begin{quiz*}{Quiz1}
%...
%\end{quiz*}
%\end{verbatim}
%    \begin{macrocode}
%<*eqrecord>
%    \end{macrocode}
%    \begin{macro}{\eq@insertHiddenFields}
% Create and add the hidden text fields for this option. The macro
% \cs{eq@insert\-Hid\-den\-Fields} is defined in \textsf{exerquiz} as
% empty. Now we redefine it for the purpose of inserting hidden text
% fields.
%    \begin{macrocode}
\def\eq@insertHiddenFields{%
    \ifx\basicFieldsSet\eqdb@NO
        \addHiddenTextField{dbName}{}%
        \addHiddenTextField{dbTable}{}%
        \addHiddenTextField{quizName}{}%
        \global\let\basicFieldsSet\eqdb@YES
    \fi
    \addHiddenTextField{\curr@quiz.numQuestions}{\thequestionno}%
    \addHiddenTextField{\curr@quiz.numCorrect}{}%
    \addHiddenTextField{\curr@quiz.Responses}{}%
    \eq@addHiddenTextFields
    \eq@clearHiddenFields
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\eq@URL}
% The JavaScript of the `End Quiz' button has a command \cs{eq@submitURL}, which has
% an empty definition for quizzes that are not to be submitted.  We define this
% macro appropriately. We populate each of the hidden fields and submit.
%    \begin{macrocode}
\def\eq@submitURL{%
    this.getField("dbName").value="\db@Name";\jsR\jsT\jsT
    this.getField("dbTable").value="\db@Table";\jsR\jsT\jsT
    this.getField("quizName").value="\curr@quiz";\jsR\jsT\jsT
    this.getField("\curr@quiz.numCorrect").value=Score;\jsR\jsT\jsT
    var aPointType=new Array(\aPointType);\jsR\jsT\jsT
\ifx\eqdb@tagged\eqdb@YES
    var cResponses=gatherTaggedQuizData("\currQuiz",%
    this.documentFileName,\thequestionno);\jsR\jsT\jsT
\else
    var cResponses=Responses.toString().substr(1);\jsR\jsT\jsT
\fi
    this.getField("\curr@quiz.Responses").value=cResponses;\jsR\jsT\jsT
    \eq@populateHiddenFields
    var aSubmitFields=new Array("\curr@quiz","IdInfo",%
        "dbName","dbTable","quizName");\jsR\jsT\jsT
    \priorSubmitQuiz
    this.submitForm(\eq@CGI,true,false,aSubmitFields);\jsR\jsT\jsT
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
%</eqrecord>
%    \end{macrocode}
% \section{eqEmail}\label{eqemail}
%    \begin{macrocode}
%<*eqemail>
%    \end{macrocode}
% Report results via e-mail. The \texttt{eqEmail} option is meant to
% be used with the ASP code \textsf{eqEmail.asp}. When the user
% submits his/her quiz, \textsf{eqEmail} builds an e-mail message
% the body of which are the quiz results, and sends it to the
% instructor.
%
% The form the macro \cs{eqSubmit} is\vskip6pt
%\begin{verbatim}
%   \eqSubmit{http://..../eqEmail.asp\#FDF}
%       {instr@someedu.edu}{course}
%\end{verbatim}
% The first parameter is the URL to the \textsf{eqEmail.asp} script. The second is the
% e-mail address to which the quiz results is to be sent. The third parameter is the
% course name.
% For example,
%\begin{verbatim}
%   \eqSubmit{http://localhost/scripts/eqEmail.asp\#FDF}
%       {dpstory@uakron.edu}{Math101}
%\end{verbatim}
% As with \textsf{eqRecord}, the first parameter of the \texttt{quiz} environment is
% the name of the quiz begin taken.
%\begin{verbatim}
%   \begin{quiz*}{Quiz1}
%   ...
%   \end{quiz*}
%\end{verbatim}
%    \begin{macro}{\eq@insertHiddenFields}
% Create and add the hidden text fields for this option. The macro
% \cs{eq@insert\-Hid\-den\-Fields} is defined in \textsf{exerquiz} as
% empty. Now we redefine it for the purpose of inserting hidden text
% fields.
%    \begin{macrocode}
\def\htmlSubmitType{HTML}
\def\insertHTMLs{,"pdfFileName","rtnURL"}
\def\eq@insertHiddenFields{%
    \ifx\basicFieldsSet\eqdb@NO
        \addHiddenTextField{mailTo}{}%
        \addHiddenTextField{courseName}{}%
        \addHiddenTextField{quizName}{}%
%    \end{macrocode}
% If submitting as HTML, we'll include \texttt{pdfFileName} and \texttt{rtnURL}.
%    \begin{macrocode}
        \ifx\eqdb@submitType\htmlSubmitType
        \addHiddenTextField{pdfFileName}{}
        \addHiddenTextField{rtnURL}{\thisRtnURL}\fi
        \global\let\basicFieldsSet\eqdb@YES
    \fi
    \addHiddenTextField{\curr@quiz.ptScore}{}
    \addHiddenTextField{\curr@quiz.nPointTotal}{\theeqpointvalue}
    \addHiddenTextField{\curr@quiz.numQuestions}{\thequestionno}%
    \addHiddenTextField{\curr@quiz.numCorrect}{}%
    \addHiddenTextField{\curr@quiz.Responses}{}%
    \eq@addHiddenTextFields
    \eq@clearHiddenFields
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\eq@submitURL}
% The JavaScript of the `End Quiz' button has a command \cs{eq@submitURL}, which has
% an empty definition for quizzes that are not to be submitted.  We define this
% macro appropriately. We populate each of the hidden fields and submit.
%    \begin{macrocode}
\def\eq@submitURL{%
    this.getField("mailTo").value="\db@Name";\jsR\jsT\jsT
    this.getField("courseName").value="\db@Table";\jsR\jsT\jsT
    this.getField("quizName").value="\curr@quiz";\jsR\jsT\jsT
    this.getField("\curr@quiz.numCorrect").value=Score;\jsR\jsT\jsT
    this.getField("\curr@quiz.ptScore").value=ptScore;\jsR\jsT\jsT
%    \end{macrocode}
% When submitting as HTML, populate the field \texttt{pdfFileName}.
%    \begin{macrocode}
\ifx\eqdb@submitType\htmlSubmitType
    this.getField("pdfFileName").value=%
        this.documentFileName;\jsR\jsT\jsT
\fi
    var aPointType=new Array(\aPointType);\jsR\jsT\jsT
\ifx\eqdb@tagged\eqdb@YES
    var cResponses=gatherTaggedQuizData("\currQuiz",%
        this.documentFileName,\thequestionno);\jsR\jsT\jsT
\else
    var cResponses=Responses.toString().substr(1);\jsR\jsT\jsT
\fi
    this.getField("\curr@quiz.Responses").value=cResponses;\jsR\jsT\jsT
    \eq@populateHiddenFields
    var aSubmitFields=new Array("\curr@quiz","IdInfo",%
        "mailTo","courseName","quizName"%
%    \end{macrocode}
% If submitting as HTML, we include \cs{insertHTMLs} into the list
% of fields to submit.
%    \begin{macrocode}
\ifx\eqdb@submitType\htmlSubmitType\insertHTMLs\fi);\jsR\jsT\jsT
    \priorSubmitQuiz
    this.submitForm({cURL: \eq@CGI,bEmpty: false,%
        aFields: aSubmitFields,%
        cSubmitAs: "\eqdb@submitType" });\jsR\jsT\jsT
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
%</eqemail>
%    \end{macrocode}
% \section{eqText}\label{eqtext}
%    \begin{macrocode}
%<*eqtext>
%    \end{macrocode}
% Record the quiz results in a text tab delimited text file. The
% distribution provides three scripts: (1) \texttt{eqText.asp} submitting
% as FDF to a windows server; when submitting as HTML, (2)
% \texttt{eqText\_html.asp} (windows), and (3) \texttt{eqText\_html.ph}p
% (linux/unix).
%
%
% The form the macro \cs{eqSubmit} is\vskip6pt
%\begin{verbatim}
%\usepackage[eqText,tagged]{eq2db}
%\eqSubmit{http://..../eqText.asp\#FDF}
%       {<path to text file>}{<course name>}
%\end{verbatim}
% The first parameter is the URL to the \textsf{eqText.asp} script. The second is the
% path on the server to where the text file is located. The third parameter is the
% course name.
% For example,
%\begin{verbatim}
%   \eqSubmit{http://localhost/scripts/eqText.asp\#FDF}
%       {c:/Inetpub/DB/qResults.txt}{Math101}
%\end{verbatim}
% For submitting as HTML
%\begin{verbatim}
% \usepackage[submitAs=html,eqText,tagged]{eq2db}
%   \eqSubmit{http://..../eqText_h.asp}         % for window servers
%       {<path to text file>}{<course name>}
%or
%   \eqSubmit{http://..../eqText_h.php}         % for linux/unix servers
%       {<path to text file>}{<course name>}
%\end{verbatim}
% As with \textsf{eqRecord}, the first parameter of the \texttt{quiz} environment is
% the name of the quiz begin taken.
%\begin{verbatim}
%\begin{quiz*}{Quiz1}
%...
%\end{quiz*}
%\end{verbatim}
%    \begin{macro}{\eq@insertHiddenFields}
% Create and add the hidden text fields for this option. The macro
% \cs{eq@insert\-Hid\-den\-Fields} is defined in \textsf{exerquiz} as
% empty. Now we redefine it for the purpose of inserting hidden text
% fields.
%
% For HTML submittal, we define \DescribeMacro{\insertHTMLs}\cs{insertHTMLs}, additional fields to be
% submitted.
%    \begin{macrocode}
\def\htmlSubmitType{HTML}
\def\insertHTMLs{,"pdfFileName","rtnURL"}
\def\eq@insertHiddenFields{%
    \ifx\basicFieldsSet\eqdb@NO
        \addHiddenTextField{pathToTxtFile}{}%
        \addHiddenTextField{courseName}{}%
        \addHiddenTextField{quizName}{}%
%    \end{macrocode}
% If submitting as HTML, we'll include \texttt{pdfFileName} and \texttt{rtnURL}.
%    \begin{macrocode}
        \ifx\eqdb@submitType\htmlSubmitType
        \addHiddenTextField{pdfFileName}{}
        \addHiddenTextField{rtnURL}{\thisRtnURL}\fi
        \global\let\basicFieldsSet\eqdb@YES
    \fi
    \addHiddenTextField{\curr@quiz.ptScore}{}
    \addHiddenTextField{\curr@quiz.nPointTotal}{\theeqpointvalue}
    \addHiddenTextField{\curr@quiz.numQuestions}{\thequestionno}%
    \addHiddenTextField{\curr@quiz.numCorrect}{}%
    \addHiddenTextField{\curr@quiz.Responses}{}%
    \eq@addHiddenTextFields
    \eq@clearHiddenFields
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\eq@submitURL}
% The JavaScript of the `End Quiz' button has a command \cs{eq@submitURL}, which has
% an empty definition for quizzes that are not to be submitted.  We define this
% macro appropriately. We populate each of the hidden fields and submit.
%    \begin{macrocode}
\def\eq@submitURL{%
    this.getField("pathToTxtFile").value="\db@Name";\jsR\jsT\jsT
    this.getField("courseName").value="\db@Table";\jsR\jsT\jsT
    this.getField("quizName").value="\curr@quiz";\jsR\jsT\jsT
    this.getField("\curr@quiz.numCorrect").value=Score;\jsR\jsT\jsT
    this.getField("\curr@quiz.ptScore").value=ptScore;\jsR\jsT\jsT
%    \end{macrocode}
% When submitting as HTML, populate the field \texttt{pdfFileName}.
%    \begin{macrocode}
\ifx\eqdb@submitType\htmlSubmitType
    this.getField("pdfFileName").value=%
        this.documentFileName;\jsR\jsT\jsT
\fi
    var aPointType=new Array(\aPointType);\jsR\jsT\jsT
\ifx\eqdb@tagged\eqdb@YES
    var cResponses=gatherTaggedQuizData("\currQuiz",%
this.documentFileName,\thequestionno);\jsR\jsT\jsT
\else
    var cResponses=Responses.toString().substr(1);\jsR\jsT\jsT
\fi
    this.getField("\curr@quiz.Responses").value=cResponses;\jsR\jsT\jsT
    \eq@populateHiddenFields
    var aSubmitFields=new Array("IdInfo","\curr@quiz",%
    "pathToTxtFile","courseName","quizName"%
%    \end{macrocode}
% If submitting as HTML, we include \cs{insertHTMLs} into the list
% of fields to submit.
%    \begin{macrocode}
\ifx\eqdb@submitType\htmlSubmitType\insertHTMLs\fi);\jsR\jsT\jsT
    \priorSubmitQuiz
    this.submitForm({cURL: \eq@CGI,bEmpty: true,%
aFields: aSubmitFields,cSubmitAs: "\eqdb@submitType" });\jsR\jsT\jsT
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
%</eqtext>
%    \end{macrocode}
% \section{TAOAS}
%  TAOAS (The AcroTeX Online Assessment System) is an online quiz system under development.
% It is not publicly available.
%    \begin{macrocode}
%<*taoas>
%    \end{macrocode}
%    \begin{macro}{\eq@insertHiddenFields}
% Create and add the hidden text fields for this option. The macro
% \cs{eq@insert\-Hid\-den\-Fields} is defined in \textsf{exerquiz} as
% empty. Now we redefine it for the purpose of inserting hidden text
% fields.
%    \begin{macrocode}
\def\eq@insertHiddenFields{%
    \ifx\basicFieldsSet\eqdb@NO
        \addHiddenTextField{dbName}{}%
        \addHiddenTextField{dbTable}{}%
        \addHiddenTextField{quizName}{}%
        \addHiddenTextField{UserValid}{false}%
        \addHiddenTextField{SID}{}%
        \addHiddenTextField{randomID}{}%
        \addHiddenTextField{fileName}{\jobname}%
        \ifeq@noquizsolutions
            \addHiddenTextField{requestSolutions}{false}%
        \else
            \addHiddenTextField{requestSolutions}{true}%
        \fi
        \global\let\basicFieldsSet\eqdb@YES
    \fi
%    \end{macrocode}
% (4/28/10) Added the field \texttt{Admin} (possible values \texttt{Yes}, \texttt{No}, or empty)
%    \begin{macrocode}
    \addHiddenTextField{Admin}{}%
    \addHiddenTextField{\curr@quiz.numCorrect}{}%
    \addHiddenTextField{\curr@quiz.numQuestions}{\thequestionno}%
    \addHiddenTextField{\curr@quiz.ptScore}{}%
    \addHiddenTextField{\curr@quiz.nPointTotal}{\theeqpointvalue}
    \addHiddenTextField{\curr@quiz.Responses}{}%
    \eq@addHiddenTextFields
    \eq@clearHiddenFields
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\eq@submitURL}
% The JavaScript of the `End Quiz' button has a command \cs{eq@submitURL}, which has
% an empty definition for quizzes that are not to be submitted.  We define this
% macro appropriately. We populate each of the hidden fields and submit.
%    \begin{macrocode}
\def\eq@true{true}
\def\eq@submitURL{%
    this.getField("dbName").value=dbName;\jsR\jsT\jsT
    this.getField("dbTable").value="\db@Table";\jsR\jsT\jsT
    this.getField("quizName").value="\curr@quiz";\jsR\jsT\jsT
%    \end{macrocode}
% (05/03/10) When \cs{correctionsOn} is \texttt{false} (defined in the taoas package),
% the document is a survey, or some other document that does not require a score.
% So, we put in a large (in absolute value) negative number as a signal. The \texttt{manage.asp}
% and the \texttt{\_viewresults.asp} script files then look for a value of -1000 and replaces
% it in the Score field with \texttt{N/A}.
%    \begin{macrocode}
\ifx\correctionsOn\eq@true
    this.getField("\curr@quiz.numCorrect").value=Score;\jsR\jsT\jsT
    this.getField("\curr@quiz.ptScore").value=ptScore;\jsR\jsT\jsT
\else
    this.getField("\curr@quiz.numCorrect").value=-1000;\jsR\jsT\jsT
    this.getField("\curr@quiz.ptScore").value=-1000;\jsR\jsT\jsT
\fi
    var aPointType=new Array(\aPointType);\jsR\jsT\jsT
\ifx\eqdb@tagged\eqdb@YES
    var cResponses=gatherTaggedQuizData("\currQuiz",%
        this.documentFileName,\thequestionno);\jsR\jsT\jsT
\else
    var cResponses=Responses.toString().substr(1);\jsR\jsT\jsT
\fi
    this.getField("\curr@quiz.Responses").value=cResponses;\jsR\jsT\jsT
    \eq@populateHiddenFields
    var aSubmitFields=new Array("\curr@quiz","IdInfo",%
        "randomID","dbName","dbTable","quizName","fileName",%
        "requestSolutions");\jsR\jsT\jsT
    \priorSubmitQuiz
    this.submitForm(submitURL,true,false,aSubmitFields);\jsR\jsT\jsT
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
%</taoas>
%    \end{macrocode}
\endinput