%% %% This is file `jeopardy.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% jeopardy.dtx (with options: `package') %% %% This is a generated file. %% %% Copyright (C) 2006 by Robert Marik %% %% This file may be distributed and/or modified under the conditions of %% the LaTeX Project Public License, either version 1.2 of this license %% or (at your option) any later version. The latest version of this %% license is in: %% %% http://www.latex-project.org/lppl.txt %% %% and version 1.2 or later is part of all distributions of LaTeX version %% 1999/12/01 or later. %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{jeopardy} [2007/03/12 v1.1 .dtx jeopardy file] \ifx\shortquiz\undefined \PackageWarning{Jeopardy}{!!!!!!!!!!!!! Load exerquiz package !!!!!!!!!!!} \def\finito{\@@end} \expandafter\finito\fi \ifx\dljsRegister\undefined \PackageWarning{Jeopardy}{!!!!!!!!!!!!! Load dljslib package !!!!!!!!!!!} \def\finito{\@@end} \expandafter\finito\fi \if\eq@drivernum1%%% pdftex \typeout{*** using pdftex option ***} \def\JeopardyNoPeekCommand{ \edef\ThisPage{/AA<> >>} \global\pdfpageattr=\expandafter{\ThisPage}% } \else \def\JeopardyNoPeekCommand{} \typeout{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!} \typeout{!!!!!!!! The package has been tested with pdflatex only.} \typeout{!!!!!!!! Use pdflatex drivers in eforms.sty and exerquiz.sty.} \typeout{!!!!!!!! On your own risk you can use other drivers with *allowpeeking* option.} \PackageWarning{Jeopardy}{No pdftex drivers for eforms and exerquiz} \fi \RequirePackage{multido} \DeclareOption{czech}{ \def\formessage{za} \def\Scoremessage{Body} \def\fairmsg{Nesidit! Odpovidate na jinou otazku!} \def\who@answers@msg#1{Odpovida hrac #1} \def\RightWrongMessages{ aCM = new Array\ ( "Spravne! Jen tak dal!", "Vyborne! Gratuluji!", "Dobre! Pokracujte ve spravne nacate praci!", "Ano, ano, ano, ano!", "Spravne! Zkuste i tezsi otazky", "Spravna odpoved!", "Presne tak! Ziskavate dalsi body" ); aEM = new Array\ ( "To neni spravne! Zkuste jinou otazku.", "Chyba. Nehadejte!", "Prosim! Prosim! Premyslejte nez odpovite!", "Dalsi chyba! Hadanim se daleko nedostanete!", "Ale ne! Kdepak! Body dolu.", "Ne, zkuste jinou otazku.", "Zase spatne! Bohuzel, vase konto se opet snizuje!" );} \def\NotAllowedMesssage{"Nesmite menit odpovedi!"} \def\RightMessage{Spravne} \def\WrongMessage{Spatne} \def\JeopardyTitle{Tituln\'\i{} strana} \def\ChampionMsg{Bravo! Mistr nad mistry!} } \def\formessage{for} \def\Scoremessage{Score} \def\NotAllowedMesssage{"Changing your answer is not allowed!"} \def\RightMessage{Right} \def\WrongMessage{Wrong} \def\fairmsg{Play Fair! Answer the question you have clicked!} \def\who@answers@msg#1{Player #1} \def\RightWrongMessages{ aCM = new Array ( "That's Right! Way to go, Kiddo!", "Wonderfully Done! Congrats!", "Very Good! Keep up the good work!", "Good, good, good, good!", "Gee, you're smart! Try a harder one!", "You're pretty sharp! Continuez, s'il vous pla\string\356t!", "You're the tops! But wait...try another." ); aEM = new Array ( "That's wrong! Sorry. Try Again.", "Error again. Don't guess, I'm watching!", "Please! Please! Work it out first!", "An error has insinuated itself into your calculations. Recalibrate your thinking!", "Bah! Humbug! You're haunted by Errors!", "Try again. This time with order and method.", "Wrong again! Use your little gray cells!" ); } \def\JeopardyTitle{Jeopardy Game} \def\ChampionMsg{You are a Champion!} \newif\ifJeopardyNoPeeking \JeopardyNoPeekingtrue \DeclareOption{allowpeeking}{\JeopardyNoPeekingfalse} \newif\ifEvalOnBlur \EvalOnBlurfalse \DeclareOption{evalonblur}{\EvalOnBlurtrue} \newif\ifdouble \doublefalse \def\JeopardyScaleFactor{1} \DeclareOption{double}{\doubletrue\def\JeopardyScaleFactor{2}} \newif\ifoneplayer \oneplayertrue \DeclareOption{twoplayers}{\oneplayerfalse} \newif\if@jeopardyFineTune \@jeopardyFineTunefalse \DeclareOption{finetune}{\@jeopardyFineTunetrue} \DeclareOption{proofing}{\eq@proofingtrue \JeopardyNoPeekingfalse} \definecolor{webgreen}{rgb}{0,.5,0} \newif\if@jeopardyBgPicture \@jeopardyBgPicturefalse \DeclareOption{bgpicture}{\@jeopardyBgPicturetrue \everyPushButton{\BC{}}} \newif\if@jeopardyPicture \@jeopardyPicturefalse \def\Picture{0} \DeclareOption{picture}{\def\Picture{1}\def\formessage#1.{}% \@jeopardyPicturetrue \@jeopardyBgPicturetrue \Celltoks{\BG{0 0 0}} \everyPushButton{\BC{}} } \newtoks\GrandPoohbahtoks \newtoks\Scoretoks \newtoks\Celltoks \newtoks\Radiotoks \newtoks\Playertoks \ProcessOptions \if@jeopardyBgPicture \RequirePackage{graphicx} \fi \sqTurnOffAlerts \newcount \CatCount \newcount \QuestCount \newcount \NumberOfCategories \newcount \NumberOfQuestions \newcount \QuestCountA \QuestCountA=-1 \newcount \AnswerCount \newcount \OQuestionCount \newcount \temporarycount \newcounter{tempcounter} \everyRespBoxMath{\BG{1 1 1}} \everyRespBoxTxt{\BG{1 1 1}} \newlength \GrandPoohbahHeight \GrandPoohbahHeight = 10pt \newlength\GameWidth \newlength\GameHeight \newlength\CellWidth \newlength\CellHeight \newlength\ScoreCellHeight \def\SetGameWidth#1{\GameWidth=#1\relax \CellWidth=\GameWidth \ifnum\NumberOfCategories=0 \divide\CellWidth by 10 \else \divide\CellWidth by \NumberOfCategories \fi } \def\SetGameHeight#1{\GameHeight=#1\relax \CellHeight=\GameHeight \ifnum\NumberOfCategories=0 \divide\CellHeight by 10 \else \divide\CellHeight by \NumberOfQuestions \fi \ScoreCellHeight=\CellHeight } \AtBeginDocument{ \SetGameWidth{0.8\linewidth} \SetGameHeight{0.6\textheight} } \newbox\JeopardyPictureBox \def\JeopardyPictureFile{picture.jpg} \def\insertJeopardyPicture{% \setbox\JeopardyPictureBox=% \hbox{\includegraphics[width=\GameWidth]{\JeopardyPictureFile}}% \SetGameHeight{1.02\ht\JeopardyPictureBox}% \dimen0=\CellHeight \dimen1=0.5\dimen0 \hbox to 0 pt{\vbox to 0 pt{\kern -\dimen1\box\JeopardyPictureBox\vss}\hss}% } \if@jeopardyPicture \def\CategoryNameDef#1#2{% \setcounter{tempcounter}{#1}% \expandafter\xdef\csname CategoryName#1\endcsname{% \Alph{tempcounter}\strut}}% \else \def\CategoryNameDef#1#2{% \expandafter\gdef\csname CategoryName#1\endcsname{#2}}% \fi \newenvironment{category}[1]{% \global\advance \CatCount by 1 \global\QuestCount=0 \immediate\write\@auxout{\string\CategoryNameDef{\the\CatCount}{#1}}% } {% \ifnum \QuestCountA=-1 \global\QuestCountA=\QuestCount \else \ifnum\QuestCountA=\QuestCount \else \PackageWarning{Jeopardy} {Bad number of questions in Category \the\CatCount.} \fi \fi } \newenvironment{question}{% \global\advance \QuestCount by 1\relax \AnswerCount=0 \ifJeopardyNoPeeking \JeopardyNoPeekCommand \fi \begin{center}% \hypertarget{\the\QuestCount\the\CatCount}% {\csname CategoryName\the\CatCount\endcsname{} % \formessage{} \the\QuestCount00.}% \end{center}% \def\Ans##1{\par \ifnum\AnswerCount=0 \vskip\medskipamount\fi \advance\AnswerCount by 1% \setcounter{tempcounter}{\the\AnswerCount}% \leavevmode\hbox to 0 pt{% \hss \ifeq@proofing \def\temp{##1}\if\temp1$\color{webgreen}\bullet$ \fi\fi \pushButton[\CA{\alph{tempcounter}}% \A{\JS{useranswer(##1,\the\QuestCount,\the\CatCount);}}]% {{Answer\the\AnswerCount-\the\QuestCount-\the\CatCount}}% {1.3em}{1.3em}% \hskip1em}% \leftskip2em}% \begin{oQuestion}{Q\the\QuestCount\the\CatCount}% }{\par\end{oQuestion}\newpage} \AtEndDocument{ \immediate\write\@auxout{\string\global\string\NumberOfCategories=\the\CatCount} \immediate\write\@auxout{\string\global\string\NumberOfQuestions=\the\QuestCount} } \ifEvalOnBlur \def\@@RespBoxMathActions {% \AA{ \AAFormat{\eqFormatArg}% \AAOnFocus{\JS{var retn = null;}}% \AAOnBlur{\JS{retn = \processJSfunc(\rbArgs,\compareJSfunc); if (event.shift){ if (retn==true) {useranswer(1,\the\QuestCount,\the\CatCount); } else {if (retn==false) {useranswer(0,\the\QuestCount,\the\CatCount);} else {app.alert("Probably a syntax error somewhere.");}}} else {app.alert("Exit the field with Shift+Click."); this.getField("obj.\oField.\thequestionno").setFocus(); }} } } } \def\@@RespBoxTxtActions {% \AA{\AAOnBlur{\JS{retn = ProcRespTxt(\rbTxtAlt); if (event.shift){ if (retn==true) {useranswer(1,\the\QuestCount,\the\CatCount); } else {if (retn==false) {useranswer(0,\the\QuestCount,\the\CatCount);} else {app.alert("Probably a syntax error somewhere.");}}} else {app.alert("Exit the field with Shift+Click."); this.getField("obj.\oField.\thequestionno").setFocus(); }} }% \AAOnFocus{\JS{var retn = null;}} } } \def\jsRespBox[#1]#2{% \def\compareJSfunc{#1}\def\processJSfunc{#2}% \ifeq@proofing\makebox[0pt][l]{\space\math@correctAnswer}\fi \eq@TextField % send to the driver-dependent macro \ \pushButton{button}{10bp}{10bp}}% \def\eq@@RespBoxTxt{% \ifeq@proofing\makebox[0pt][l]{\space\txt@correctAnswer}\fi \eq@TextField \ \pushButton{button}{10bp}{10bp}}% \else \def\@@RespBoxMathActions {% \AA{\AAKeystroke{if(event.willCommit) { retn = \processJSfunc(\rbArgs,\compareJSfunc); if (retn==true) {useranswer(1,\the\QuestCount,\the\CatCount); } else {if (retn==false) {useranswer(0,\the\QuestCount,\the\CatCount);} else {app.alert("Probably a syntax error somewhere.");}}} }% \AAFormat{\eqFormatArg}% \AAOnFocus{\JS{var retn = null;}}% }% }% \def\@@RespBoxTxtActions {% \AA{\AAKeystroke{if(event.willCommit) { retn = ProcRespTxt(\rbTxtAlt); if (retn==true) {useranswer(1,\the\QuestCount,\the\CatCount); } else {if (retn==false) {useranswer(0,\the\QuestCount,\the\CatCount);} else {app.alert("Probably a syntax error somewhere.");}}} }% \AAOnFocus{\JS{var retn = null;}} } } \fi %%% \ifEvalOnBlur \newtoks\everyCategoryHead \everyCategoryHead{}% \def\MakeGameBoard{% \begin{center}% \hypertarget{GameBoard}{\JeopardyTitle}% \edef\temp{\noexpand\textField[\noexpand\Ff{\noexpand\FfReadOnly}% \noexpand\F{\noexpand\FHidden}% \noexpand\Q{1}% \noexpand\textSize{0}% \noexpand\V{\ChampionMsg}\the\GrandPoohbahtoks% ]{GrandPoohbah}{\textwidth}{\the\GrandPoohbahHeight}}% \temp \leavevmode \ifnum\NumberOfQuestions>0% \ifnum\NumberOfCategories>0% \multido{\i=1+1}{\NumberOfCategories}{\leavevmode \vtop{\hsize=\CellWidth \centering \the\everyCategoryHead\csname CategoryName\i\endcsname }}\\% \leavevmode \if@jeopardyBgPicture\insertJeopardyPicture\fi \Multido{\i=1+1}{\NumberOfQuestions}% {\edef\j{\i}% \if@jeopardyPicture\hbox to 0 pt{\hss$\j$ }\fi {\Multido{\i=1+1}{\NumberOfCategories}{% \edef\temp{\noexpand\textField[% \noexpand\Ff{\noexpand\FfReadOnly}% \noexpand\S{S}% \noexpand\Q{1}% \the\Celltoks]{Field\j\i}{\CellWidth}{\CellHeight}}% \hbox to 0 pt{\temp\hss}% \if@jeopardyPicture \pushButton[\S{B}% \A{\JS{kliknuti(\j,\i);}}]{Button\j\i}{\CellWidth}{\CellHeight}% \else \pushButton[\S{B}\CA{\j00}% \A{\JS{kliknuti(\j,\i);}}]{Button\j\i}{\CellWidth}{\CellHeight}% \fi }\\\leavevmode}% }% \fi \fi \par \AfterGameBoard \if@jeopardyPicture \smallskip\leavevmode \hfill\pushButton[\A{\JS{hideall();}}\CA{Solution}]{Solution}{1.5cm}{12bp} \else \@makeScoreField \fi \end{center}% \newpage }% \def\@makeScoreField { \ifoneplayer \dimen0=\NumberOfCategories\CellWidth \edef\temp{\noexpand\textField[\noexpand\V{}\noexpand\textSize{0} \noexpand\Q{1} \noexpand\Ff{\noexpand\FfReadOnly} \the\Scoretoks ]{Total.1}{\dimen0}{\ScoreCellHeight}}% \temp \else%two players \dimen0=\NumberOfCategories\CellWidth \dimen1=0.5\dimen0 \edef\temp{\noexpand\textField[\noexpand\V{}\noexpand\textSize{0} \noexpand\Q{1} \noexpand\Ff{\noexpand\FfReadOnly} \the\Scoretoks ]{Total.1}{\dimen1}{\ScoreCellHeight}}% \temp \edef\temp{\noexpand\textField[\noexpand\V{}\noexpand\textSize{0} \noexpand\Q{1} \noexpand\Ff{\noexpand\FfReadOnly} \the\Scoretoks ]{Total.2}{\dimen1}{\ScoreCellHeight}}% \temp\\ \hbox to \hsize{\hss\hbox to \dimen0 {\hss \radioButton[\V{1}\Ff{\FfNoToggleToOff}\A{\JS{player=1;this.getField("whoanswers").value= "\who@answers@msg{A}";}}]{radio}{12pt}{12pt}{1} \hss \hbox % to 0 pt {\hss \edef\temp{% \noexpand\textField[\noexpand\Q{1}\noexpand\Ff{\noexpand\FfReadOnly}\noexpand\V{\who@answers@msg{A}}\the\Playertoks] {whoanswers}{0.6\dimen0}{10pt}}\temp\hss } \hss \radioButton[\Ff{\FfNoToggleToOff}\A{\JS{player=2;this.getField("whoanswers").value= "\who@answers@msg{B}";}}]{radio}{12pt}{12pt}{2} \hss}\hss }% \fi } \let\AfterGameBoard\relax \edef\Goal{45*(1+numQuestions)*numQuestions*numCategories*\JeopardyScaleFactor} \def\update@who@answers{ if (player==1) this.getField("whoanswers").value= "\who@answers@msg{A}"; else this.getField("whoanswers").value= "\who@answers@msg{B}"; } \edef\JeopardyUpdatescore { \ifoneplayer this.getField("Total.1").value="\Scoremessage: "+TotalScoreA; if (TotalScoreA>0) this.getField("Total.1").textColor=\correctColor; else this.getField("Total.1").textColor=\wrongColor; \else this.getField("Total.1").value="\Scoremessage: "+TotalScoreA; if (TotalScoreA>0) this.getField("Total.1").textColor=\correctColor; else this.getField("Total.1").textColor=\wrongColor; this.getField("Total.2").value="\Scoremessage: "+TotalScoreB; if (TotalScoreB>0) this.getField("Total.2").textColor=\correctColor; else this.getField("Total.2").textColor=\wrongColor; if (player==1) {player=2; this.getField("radio").value=2;} else {player=1; this.getField("radio").value=1}; \update@who@answers \fi } \begin{insDLJS}[dljslibRMb]{dljsliRMb}{RMb} numQuestions = \the\NumberOfQuestions; numCategories = \the\NumberOfCategories; var player=1; RowClick=0; ColClick=0; SaveRowClick=0; SaveColClick=0; totalQuestions = numQuestions * numCategories; var QAed =""; for (var i=0; i< totalQuestions; i++)QAed +="0"; nEM = 0; nCM = 0; var submitted = 0; TotalScoreA = 0; TotalScoreB = 0; NumQAed = 0; Goal = \Goal; \RightWrongMessages var Picture=\Picture; var JeopardyPass=0; function kontrola(row,col) { if (NumQAed 6) nCM=0; } else { if (Picture!=1) { this.getField("Field"+row+col).textColor=\wrongColor; this.getField("Field"+row+col).value="\WrongMessage"; } if (player==1) TotalScoreA -= \JeopardyScaleFactor*row*100; else TotalScoreB -= \JeopardyScaleFactor*row*100; app.alert(aEM[nEM],3); if (++nEM > 6) nEM=0; } if ((++NumQAed>=totalQuestions) && ((TotalScoreA+TotalScoreB)>=Goal)) { if (Picture!=1) this.getField("GrandPoohbah").hidden=false; } } else app.alert(\NotAllowedMesssage); gotoNamedDest("GameBoard"); if (Picture!=1) { \JeopardyUpdatescore } }; function hideall(){ NumQAed=totalQuestions; var i=0; var j=1; if (JeopardyPass==0) { JeopardyPass=1; for (var i=0; i< numQuestions; i++) { for (var j=0; j< numCategories; j++) { row=i+1; col=j+1; this.getField("Field"+row+col).hidden=true; this.getField("Button"+row+col).hidden=true; } } } else this.getField("GrandPoohbah").hidden=false; } function notifyField(success, flag, fieldname) { return success; } \end{insDLJS} \newlength\AditionalShift \AditionalShift=0pt \if@jeopardyFineTune \newlength \finetunelength \newlength \finetuneCellWidth \newlength \finetuneCellHeight \finetunelength=1pt \def\insertJeopardyPicture{% \dimen1=\finetunelength \multiply\dimen1 by \NumberOfCategories \advance\dimen1 by \GameWidth \setbox\JeopardyPictureBox=% \hbox{\includegraphics[width=\dimen1]{\JeopardyPictureFile}}% \dimen1=\finetunelength \multiply\dimen1 by \NumberOfQuestions \dimen2=\ht\JeopardyPictureBox \advance\dimen2 by -1.9\dimen1 \SetGameHeight{\dimen2}% \dimen0=\CellHeight \divide\dimen0 by 2 \hbox to 0 pt{\vbox to 0 pt{\kern -\dimen0\kern-\AditionalShift \box\JeopardyPictureBox\vss}\hss}% } \def\MakeGameBoard{% \begin{center}% \fboxsep=\finetunelength \fboxrule=0pt \hypertarget{GameBoard}{\JeopardyTitle}% \edef\temp{\noexpand\textField[\noexpand\Ff{\noexpand\FfReadOnly}% \noexpand\F{\noexpand\FHidden}% \noexpand\Q{1}% \noexpand\textSize{0}% \noexpand\V{\ChampionMsg}\the\GrandPoohbahtoks% ]{GrandPoohbah}{\textwidth}{\the\GrandPoohbahHeight}}% \temp \leavevmode \ifnum\NumberOfQuestions>0% \ifnum\NumberOfCategories>0% \multido{\i=1+1}{\NumberOfCategories}{\leavevmode \vtop{\hsize=\CellWidth \centering \the\everyCategoryHead\csname CategoryName\i\endcsname }}\\% \leavevmode \if@jeopardyBgPicture\insertJeopardyPicture\fi \finetuneCellWidth=\CellWidth \advance\finetuneCellWidth by -\finetunelength \finetuneCellHeight=\CellHeight \vtop{% \Multido{\i=1+1}{\NumberOfQuestions}% {\edef\j{\i}% \hbox{% \if@jeopardyPicture\hbox to 0 pt{\hss$\j$ }\fi \Multido{\i=1+1}{\NumberOfCategories}{% \edef\temp{\noexpand\textField[% \noexpand\Ff{\noexpand\FfReadOnly}% \noexpand\S{S}% \noexpand\Q{1}% \the\Celltoks]{Field\j\i}{\finetuneCellWidth}{\finetuneCellHeight}}% \fbox{\hbox to 0 pt{\temp\hss}% \if@jeopardyPicture \pushButton[\S{B}% \A{\JS{kliknuti(\j,\i);}}]{Button\j\i}{\finetuneCellWidth}{\finetuneCellHeight}% \else \pushButton[\S{B}\CA{\j00}% \A{\JS{kliknuti(\j,\i);}}]{Button\j\i}{\finetuneCellWidth}{\finetuneCellHeight}% \fi% }}}\kern-1pt }}% \fi %%% \ifnum\NumberOfQuestions>0% \fi %%% \ifnum\NumberOfCategories>0% \par \AfterGameBoard \if@jeopardyPicture \smallskip\leavevmode \hfill\pushButton[\A{\JS{hideall();}}\CA{Solution}]{Solution}{1.5cm}{12bp} \else%not picture \@makeScoreField \fi \end{center}% \newpage }% \fi \IfFileExists{jeopardy.cfg}{% \typeout{---------------------------------------------------} \typeout{jeopardy: Configuration from the file jeopardy.cfg.} \typeout{---------------------------------------------------} \input jeopardy.cfg}{} \endinput %% %% End of file `jeopardy.sty'.