Advertisement
Bukz

Stupid Math Quiz Script Concept

Mar 15th, 2011
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.94 KB | None | 0 0
  1. alias math_operators [+ - * divf]
  2. alias noob_operator_names [plus minus times "divided by"]
  3. alias numbers [0 1 2 3 4 5 6 7 8 9]
  4. initialize [quiz_correct quiz_incorrect] 0
  5. alias quizme [
  6.   if (strcmp $arg1 c) [alias quiz_correct 0; alias quiz_incorrect 0; echo Your quiz scores have been cleared.] [
  7.     alias first_num []
  8.     alias second_num []
  9.     alias operator (at $math_operators (rnd 4))
  10.     alias opp (findlist $math_operators $operator)
  11.     loop fnl $arg1 [
  12.       alias first_num (concatword $first_num (at $numbers (rnd 10)))
  13.     ]
  14.     loop snl $arg1 [
  15.       alias second_num (concatword $second_num (at $numbers (rnd 10)))
  16.     ]
  17.     if (strcmp $operator divf) [
  18.       if (> $second_num $first_num) [tmp_quiz_number = $first_num; first_num = $second_num; second_num = $tmp_quiz_number]
  19.     ]
  20.     alias answer ($operator $first_num $second_num)
  21.     echo What is $first_num (at $noob_operator_names $opp) (concatword $second_num "?") Use the /ans command to give your answer...
  22.   ]
  23. ]
  24.  
  25. alias ans [
  26.   if (|| (strcmp $answer $arg1) (strcmp $answer (concatword $arg1 ".0"))) [
  27.     echo Correct!
  28.     += quiz_correct 1
  29.   ] [
  30.     echo Incorrect!
  31.     += quiz_incorrect 1
  32.   ]
  33.   echo The answer was: $answer   ||   Your new scores are: $quiz_correct correct, $quiz_incorrect incorrect total answers...
  34. ]
  35.  
  36. docsection [Math Quiz];
  37. docident [quizme] [Generates a random math question for you to answer.];
  38. docargument [S] [The size (in digits) of the numbers used in the questions of the script.];
  39. docexample [/quizme 1] [Example output: What is 3 times 6?];
  40. docexample [/quizme 2] [Example output: What is 16 plus 84?];
  41. docremark [If you use a single lowercase "c" as the first argument for this command, your total quiz scores will be "zero'd."];
  42. docident [ans] [Allows you to answer questions asked by the /quizme command.];
  43. docargument [A] [Your answer to the last question asked.];
  44. docexample [Previous question: What is 3 plus 9?] [/ans 12];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement