<%@ language="javascript"%> <% var NAV_ONLY = -1; var CHECK_ANSWERS = -2; var g_strTitle = "Geography & GIS Knowledge Quiz"; var g_strQuestionText; // text of the question to be asked var g_aAnswers; var g_strQuestionLink; var g_cCorrectAnswer; var g_strExhibit; var g_strAnnotation; var g_bDone = true; var g_iScore = 0; /// Takes a integer parameter and converts it to the appropriate letter function getLetterFromAnswerNumber( iInput ) { var strTemp strTemp = "-"; switch( iInput ) { case 0: strTemp = "A"; break; case 1: strTemp = "B"; break; case 2: strTemp = "C"; break; case 3: strTemp = "D"; break; case 4: strTemp = "E"; break; case 5: strTemp = "F"; break; } return strTemp } // Takes a letter parameter and converts it to the appropriate number function getNumberFromAnswerLetter( strInput ) { var iTemp switch( strInput ) { case "A": iTemp = 0; break; case "B": iTemp = 1; break; case "C": iTemp = 2; break; case "D": iTemp = 3; break; case "E": iTemp = 4; break; case "F": iTemp = 5; break; } return iTemp } function getAnswerFromAnswerString( questionNumber, answerString ) { questionIndex = answerString.lastIndexOf( '|'+ questionNumber.toString() + '|' ); if( questionIndex < 0 ) return "-" nextBarIndex = answerString.indexOf( '|', questionIndex + 1 ); return answerString.charAt( nextBarIndex + 1 ); } function showBanner() { // Show geoinfo.sdsu.edu/hightech banner for now... Response.Write( "\n" ); // DWLayoutTable Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( "
GIS In Action
spacer
line decor
line decor
\n" ); } function showQuizResult() { var iScore; var aAnswerLetter; showAnswerSheet( false ); showGradeSheet(); // Process results and show end quiz status report strAnswers = Session("AnswerString"); //Response.Write( strAnswers +"
\n"); Response.Write( "\n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); } else { Response.Write( "Congratulations! You correctly answered all the questions.\n\n" ); } Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( "
\n" ); if( g_iScore < iNumberOfQuestions ) { Response.Write( "Some questions were answered incorrectly. You may click on the question number above to try again, or take a look at the answers below.\n
\n" ); Response.Write( " You can clear your answers and take the test again by clicking here.
\n" ); Response.Write( "
\n" ); %> <% for( idx = 0; idx < iNumberOfQuestions; idx++ ) { initQuestion( Session("DayOfWeek"), idx ); aAnswerLetter = getAnswerFromAnswerString( idx, strAnswers ); %> <% } %>
<% if( g_strQuestionLink != "" ) { Response.Write( " <% if( g_strAnnotation != "" ) { %> <% } %>
Q<%= idx + 1%>
<%= g_strQuestionText %>
\n" ); Response.Write( " \n" ); } else { Response.Write( " \n" ); } %> <%= g_cCorrectAnswer %>) <%= g_aAnswers[getNumberFromAnswerLetter(g_cCorrectAnswer)]%>
<%= g_strAnnotation %>
<% } function showAnswerSheet( enableCheckAnswerButton ) { var idx; var aAnswerLetter; g_bDone = true; strAnswers = Session("AnswerString"); for( idx = 0; idx < iNumberOfQuestions ; idx++ ) { aAnswerLetter = getAnswerFromAnswerString( idx, strAnswers ); if( String(aAnswerLetter) == "-") { g_bDone = false; } } Response.Write( "\n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( "
Answer Sheet
\n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); for( idx = 1; idx <= iNumberOfQuestions ; idx++ ) { if( idx == iQuestionNumber+1 ) { Response.Write( " \n" ); } else { Response.Write( " \n" ); } } if( enableCheckAnswerButton == true && g_bDone == true ) { Response.Write( " \n" ); Response.Write( " \n" ); } Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); for( idx = 0; idx < iNumberOfQuestions ; idx++ ) { aAnswerLetter = getAnswerFromAnswerString( idx, strAnswers ); Response.Write( " \n" ); } Response.Write( " \n" ); Response.Write( "
\n" ); Response.Write( "
Question
\n" ); Response.Write( "
" + idx + "
" + idx + "
\n" ); Response.Write( " \n"); Response.Write( "
\n" ); Response.Write( "
Answer
\n" ); Response.Write( "
" + aAnswerLetter + "
\n" ); Response.Write( "
\n" ); } function showGradeSheet() { var idx; Response.Write( "\n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( "
\n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); g_iScore = 0; for( idx = 0; idx <= iNumberOfQuestions-1 ; idx++ ) { initQuestion( Session("DayOfWeek"), idx ); aAnswerLetter = getAnswerFromAnswerString( idx, strAnswers ); if( g_cCorrectAnswer == aAnswerLetter ) { ++g_iScore; Response.Write( " \n" ); } else { Response.Write( " \n" ); } } Response.Write( " \n" ); Response.Write( "
\n" ); Response.Write( "
Result
\n" ); Response.Write( "
\n" ); Response.Write( "
\n" ); } function dumpSessionVariables() { Response.Write( "DayOfWeek = " + Session("DayOfWeek") + "
\n" ); Response.Write( "NumberOfQuestions = " + Session("NumberOfQuestions") + "
\n" ); Response.Write( "Current Question Number = " + iQuestionNumber + "
\n" ); Response.Write( "AnswerString = " + Session("AnswerString") + "
\n" ); } //************************************************************************************ //** EXECUTION STARTS HERE //************************************************************************************ var idx var iNumberOfQuestions // the number of questions in the test var iQuestionNumber // the question we're currently on var bAbort // added after I had finished to account for closed sessions var aButtonUp // array of button up bitmaps for each answer button var aButtonDown // array of button down bitmaps for each answer button var date = new Date(); // holds data object bAbort = false // set it to false since we only want to abort in certain cases aButtonUp = new Array(5); aButtonUp[0] = "./images/A_UP.gif" aButtonUp[1] = "./images/B_UP.gif" aButtonUp[2] = "./images/C_UP.gif" aButtonUp[3] = "./images/D_UP.gif" aButtonUp[4] = "./images/E_UP.gif" aButtonDown = new Array(5); aButtonDown[0] = "./images/A_DOWN.gif" aButtonDown[1] = "./images/B_DOWN.gif" aButtonDown[2] = "./images/C_DOWN.gif" aButtonDown[3] = "./images/D_DOWN.gif" aButtonDown[4] = "./images/E_DOWN.gif" aButtonSelect = new Array(5); aButtonSelect[0] = "./images/A_DOWN_SEL.gif" aButtonSelect[1] = "./images/B_DOWN_SEL.gif" aButtonSelect[2] = "./images/C_DOWN_SEL.gif" aButtonSelect[3] = "./images/D_DOWN_SEL.gif" aButtonSelect[4] = "./images/E_DOWN_SEL.gif" //************************************************************************** // This banner info is common for all generated pages so put it here on top. %> <%= g_strTitle %> <% showBanner(); %>
<%= g_strTitle %>
<% // End of banner info //************************************************************************** // If this is the first call to the quiz then init everything // otherwise retrieve values we need. We check by looking for the // Question ID from the querystring. if( String(Request.QueryString("qid")) == "undefined" ) { // Retrieve and Set the Quiz Info Session("DayOfWeek") = date.getDay(); Session("NumberOfQuestions") = getNumQuestion( date.getDay() ); // Set our question counter to 0 and init our answer string iQuestionNumber = 0 Session("AnswerString") = "|" } else { // Check to be sure we've still got a session! if( String(Session("AnswerString")) == "undefined" ) { Response.Write( "I\'m sorry, but you\'ve taken too long. You can start over by " ); Response.Write( "clicking here.\n" ); bAbort = true; } else // We have valid session so initialize variables from Session and Query string. { // Get the number of the question we're processing from the query string iQuestionNumber = parseInt( Request.QueryString( "qid" ) ); // Check the selected answer from the query astring and if it is valid append it to the answer string. // The special value of 'NAV_ONLY' indicates that the question was not answered so don't store // anything in this case. The will happen when the user navigates the quiz without selecting an answer. if( parseInt( Request.QueryString( "sa" ) ) != NAV_ONLY ) { // Log selected answer to last question Session("AnswerString") = Session("AnswerString") + iQuestionNumber + "|" + getLetterFromAnswerNumber( parseInt( Request.QueryString( "sa" ) ) ) + "|"; // Increment question identifier if there are still more questions if( iQuestionNumber < Session("NumberOfQuestions") - 1 ) { ++iQuestionNumber; } } } } // If session has expired then skip all the code. if( !bAbort ) { iNumberOfQuestions = Session("NumberOfQuestions") // Check to see if the user selected the "check answers" button. If so then show // the results, otherwise ask the next question if( parseInt( Request.QueryString( "sa" ) ) == CHECK_ANSWERS ) { showQuizResult(); } else // Retrieve the question and answers { initQuestion( Session("DayOfWeek"), iQuestionNumber ); %>
<% strAnswers = Session("AnswerString"); aAnswerLetter = getAnswerFromAnswerString( iQuestionNumber, strAnswers ); var idx; var sLink; for( idx = 0; idx < g_aAnswers.length; idx++ ) { // Set the hyperlink text which includes the answer to this question and the number of the next // question. sLink = "\"" + Request.ServerVariables("URL") + "?qid=" + iQuestionNumber + "&sa=" + idx + "\""; // If the user's answer matches this answer, use the 'Selected' style of button. if( idx == getNumberFromAnswerLetter( aAnswerLetter ) ) { Response.Write( " \n"); Response.Write( " \n"); } // Otherwise use the normal button style with rollover functionality else { Response.Write( " \n"); Response.Write( " \n"); } Response.Write( " \n"); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); } if( g_strExhibit != "" ) { Response.Write( " \n" ); Response.Write( " \n" ); Response.Write( " \n" ); } %>
Q<%= iQuestionNumber + 1%>
<%= g_strQuestionText %>
\n" ); Response.Write( "
<% Response.Write( " \n" ); if( iQuestionNumber > 0 ) { Response.Write( " \n" ); } else { Response.Write( " \n" ); } if( g_strQuestionLink != "" ) { Response.Write( " \n" ); } else { Response.Write( " \n" ); } if( iQuestionNumber < iNumberOfQuestions - 1 ) { Response.Write( " \n" ); } else { Response.Write( " \n" ); } Response.Write( " \n" ); %>
<% showAnswerSheet( true ); } } %>