<%@ Language="VBScript" %> <% Dim QuestionNumber QuestionNumber = Request.QueryString("Question") 'get picture information Dim LineIn, Line Set FS = Server.CreateObject("Scripting.FileSystemObject") Set RS = FS.OpenTextFile(Server.MapPath("/SARG/17000-IDquiz/SARG_Quiz.XML"),1) Do Do LineIn = RS.Readline Loop Until (LineIn = "") OR (LineIn = "" ) If LineIn <> "" then LineIn = RS.Readline Line = RemoveXMLtag(LineIn) 'response.write("Line: " & Line & "
") if Cint(Line) = Cint(QuestionNumber) Then LineIn = RS.Readline 'class QuestionImage = RemoveXMLtag(RS.Readline) & "?imgmax=640" 'Image QuestionCommonName = RemoveXMLtag(RS.Readline) 'common name QuestionScientificName = RemoveXMLtag(RS.Readline) 'Scientific name QuestionGender = RemoveXMLtag(RS.Readline) 'gender QuestionLifeStage = RemoveXMLtag(RS.Readline) 'lifestage end if End if Loop Until (RS.AtEndOfStream) 'Tidy up resources by closing file RS.Close Set FS = Nothing 'get species ID information Dim SpeciesInfo SpeciesInfo = "" Set FS = Server.CreateObject("Scripting.FileSystemObject") Set RS = FS.OpenTextFile(Server.MapPath("/SARG/17000-IDquiz/SARG_Quiz_Guide.XML"),1) Do Do LineIn = RS.Readline Loop Until (LineIn = "<" & QuestionCommonName & ">") OR (LineIn = "" ) If LineIn <> "" then SpeciesInfo = RemoveXMLtag(RS.Readline) End if Loop Until (RS.AtEndOfStream) 'Tidy up resources by closing file RS.Close Set FS = Nothing %> SARG ID Quiz - Results Debrief

SARG Species Quiz - Question No.<%= QuestionNumber %>



Species: <%= QuestionCommonName %>
Scientific Name: <%= QuestionScientificName %>
Gender: <%= QuestionGender %>
Life Stage: <%= QuestionLifeStage %>

Most commonly mistaken for: <%= GetMistakenSpecies(QuestionCommonName) %>
(Based upon analysis of quiz results.)

<%= SpeciesInfo %>

<% %>
<% FUNCTION RemoveXMLtag(XMLstring) Position = Cint(InStr(1, Cstr(XMLstring), ">", 1)) Start = Position + 1 Length = Len(Cstr(XMLstring)) - Position - Position -1 RemoveXMLtag = mid(Cstr(XMLstring), Start, Length) END FUNCTION FUNCTION GetMistakenSpecies(Species) DIM KeyString, oHash, MistakenSpecies, Counter, KeyNames Set oHash = New HashTable Set FS1 = Server.CreateObject("Scripting.FileSystemObject") Set RS1 = FS1.OpenTextFile(Server.MapPath("/SARG/17000-IDquiz/SARG_Quiz_Goofs.XML"),1) KeyString = "" & Species & "" 'create dummy Hash table entry oHash.Add Species, 0 'Populate hash table with all wrong answers for target species Do LineIn = RS1.Readline If LineIn = KeyString Then 'found target species MistakenSpecies = RemoveXMLtag(RS1.Readline) 'read mistaken entry (next line in XML) If(MistakenSpecies<>"select") AND (MistakenSpecies<>"") then If oHash.Exists(MistakenSpecies) Then 'increment count Counter = oHash.GetValue(MistakenSpecies) + 1 'update value oHash.Remove(MistakenSpecies) oHash.Add MistakenSpecies, Counter Else oHash.Add MistakenSpecies, 1 End if 'does hash key exist check End if 'duff entry check End if 'Target species found check Loop Until (RS1.AtEndOfStream) 'Tidy up resources by closing file RS1.Close Set FS1 = Nothing 'determine most mistaken species MaxErrors = 0 'set default value to first entry KeyNames = oHash.NamesCollection Counter = oHash.Count() For F = 0 to Counter-1 'test all entries to find largest If oHash.GetValue(KeyNames(F)) > MaxErrors Then MaxErrors = oHash.GetValue(KeyNames(F)) GetMistakenSpecies = KeyNames(F) End if Next 'F If MaxErrors = 0 then GetMistakenSpecies = "Nothing" End if Set oHash = Nothing END FUNCTION %>