#!/usr/bin/perl use CGI qw(:standard); $numberOfQuestions = 15; $hexval = param("PID") || 0; $ShowWord = param("ShowWord") ; $MixUp = param("MixUp") || 0; if ($ShowWord eq "") { $ShowWord = 1; } @alreadyDone = hex2trits($hexval); $trits = ""; for ($i=0; $i<@alreadyDone; $i++) { $trits .= $alreadyDone[$i]; } $right = 0; $wrong = 0; foreach (@alreadyDone) { if ($_ == 1) { $wrong++; } elsif ($_ == 2) { $right++; } } $count = 0; do { if ($count++ > $numberOfQuestions * $numberOfQuestions) { @alreadyDone = hex2trits(0); } $questionNumber = int(rand($numberOfQuestions))+1; } while ($alreadyDone[$questionNumber-1]); $alreadyDone[$questionNumber-1] = 2; $ifCorrect = trits2hex(@alreadyDone); $alreadyDone[$questionNumber-1] = 1; $ifIncorrect = trits2hex(@alreadyDone); if ($questionNumber == 1) { $vocabImage = "hammer.jpg"; @answers = qw(KI N DA MA); $romaji = "kindama"; } elsif ($questionNumber == 2) { $vocabImage = "glasses.jpg"; @answers = qw(ME GA NE); $romaji = "megane"; } elsif ($questionNumber == 3) { $vocabImage = "clock.jpg"; @answers = qw(TO KE I); $romaji = "tokei"; } elsif ($questionNumber == 4) { $vocabImage = "phone.jpg"; @answers = qw(DE N WA); $romaji = "denwa"; } elsif ($questionNumber == 5) { $vocabImage = "shoes.jpg"; @answers = qw(KU TU); $romaji = "kutsu"; } elsif ($questionNumber == 6) { $vocabImage = "broom.jpg"; @answers = qw(HO U KI); $romaji = "houki"; } elsif ($questionNumber == 7) { $vocabImage = "bike.jpg"; @answers = qw(ZI TE N SI YA-small); $romaji = "jitensha"; } elsif ($questionNumber == 8) { $vocabImage = "scissors.jpg"; @answers = qw(HA SA MI); $romaji = "hasami"; } elsif ($questionNumber == 9) { $vocabImage = "pot.jpg"; @answers = qw(TU BO); $romaji = "tsubo"; } elsif ($questionNumber == 10) { $vocabImage = "cards.jpg"; @answers = qw(ME I SI); $romaji = "meishi"; } elsif ($questionNumber == 11) { $vocabImage = "stairs.jpg"; @answers = qw(KA I DA N); $romaji = "kaidan"; } elsif ($questionNumber == 12) { $vocabImage = "comb.jpg"; @answers = qw(KU SI); $romaji = "kushi"; } elsif ($questionNumber == 13) { $vocabImage = "books.jpg"; @answers = qw(HO N); $romaji = "hon"; } elsif ($questionNumber == 14) { $vocabImage = "comics.jpg"; @answers = qw(MA N GA); $romaji = "manga"; } elsif ($questionNumber == 15) { $vocabImage = "ricecooker.jpg"; @answers = qw(SU I HA N KI); $romaji = "suihanki"; } $IMAGEPATH = "/japanese/hweb_images/"; @chart_col = (0, 10, 50, 90, 130, 170); @chart_row = (0, 10, 50, 90, 130, 170, 210, 250, 290, 330, 370, 410, 450, 490); @chars = qw( A I U E O KA KI KU KE KO SA SI SU SE SO TA TI TU TE TO NA NI NU NE NO HA HI HU HE HO MA MI MU ME MO YA X YU X YO RA RI RU RE RO WA X X X WO X X X X N YA-small X YU-small X YO-small tenten maru X TU-small X ); if ($MixUp) { fisher_yates_shuffle(\@chars); } $MAXCHARS = @answers; $targetTop = 375; $targetLeft = 250; print "Content-type: text/html\n\n"; print ("\n"); print ("
\n"); print ("\n"); print ("\n"); print ("\n"); print ("\n"); print ("\n"); $left = $targetLeft; $top = 10; print ("