1 && count($synonyms2)>1) { // while (count($synonyms1)>2) { // array_pop($synonyms1); // } // while (count($synonyms2)>2) { // array_pop($synonyms2); // } // } elseif (count($synonyms1)==1) { // while (count($synonyms2)>3) { // array_pop($synonyms2); // } // } else { // while (count($synonyms1)>2) { // array_pop($synonyms1); // } // } // if ($r = mysql_query("SELECT * FROM pvc_old_synonyms WHERE verb1=$verb_id1 OR verb2=$verb_id1")) { // $synonyms1 = array(); // while ($row = mysql_fetch_array($r)) { // if ($row[0]==$verb_id1) { // $synonyms1[] = $row[1]; // } else { // $synonyms1[] = $row[0]; // } // } // shuffle($synonyms1); // while (count($synonyms1)>2) { // array_pop($synonyms1); // } // } // if ($r = mysql_query("SELECT * FROM pvc_old_synonyms WHERE verb1=$verb_id2 OR verb2=$verb_id2")) { // $synonyms2 = array(); // while ($row = mysql_fetch_array($r)) { // if ($row[0]==$verb_id2) { // $synonyms2[] = $row[1]; // } else { // $synonyms2[] = $row[0]; // } // } // shuffle($synonyms2); // while (count($synonyms2)>2) { // array_pop($synonyms2); // } // } } $person = rand(1, 6); //Negative - 1 or Positive - 0 $neg = rand(0, 1); // 0 - Past (correct if neg=0), 1 - wrong vowels // 2 - Present, 3 - Present wrong vowels, // 4 - Negative (correct if neg=1), 5 - Negative wrong vowels, // 6 - Negative Present, 7 - Negative Present wrong vowels if ($syn) { if ($neg) { $answers = array(4, 5); $qtypes0 = array(2, 0, 6); $qtypes1 = array(3, 1, 7); } else { $answers = array(0, 1); $qtypes0 = array(2, 4, 6); $qtypes1 = array(3, 5, 7); } $answers[] = $qtypes0[array_rand($qtypes0)]; $answers[] = $qtypes1[array_rand($qtypes1)]; shuffle($answers); $synonyms = array(); // if there is only one synonym, copy it if (count($synonyms1)==1) { $synonyms1[] = $synonyms1[0]; } elseif (count($synonyms2)==1) { $synonyms2[] = $synonyms2[0]; } // $synonyms = array_merge($synonyms1, $synonyms2); for ($i=0; $i<=3; $i++) { if ($answers[$i] % 2) { $synonyms[] = array_shift($synonyms2); } else { if ($answers[$i]==0 && $neg==0 || $answers[$i]==4 && $neg==1) { $synonyms[] = array_shift($synonyms1); } else { $synonyms[] = array_pop($synonyms1); } } } } else { if ($neg) { $answers = array(4, 5); $qtypes = array(2, 3, 0, 1, 6, 7); } else { $answers = array(0, 1); $qtypes = array(2, 3, 4, 5, 6, 7); } $qtypes2 = array_rand($qtypes, 2); $answers[] = $qtypes[$qtypes2[0]]; $answers[] = $qtypes[$qtypes2[1]]; shuffle($answers); } } $data = "$verb_index:$homograph:$person:$neg:$engVerb1:$engVerb2:".implode(",", $answers); if ($syn) { for ($i=0; $i<=3; $i++) { $data .= ($i==0?":":",").$synonyms[$i]; if ($r = mysql_query("SELECT * FROM pvc_verbs WHERE id=".$synonyms[$i])) { $synonyms[$i] = mysql_fetch_assoc($r); } } } $data = base64_encode($data); ?> \n

$test_title

\n"; print "

You have answered the question correctly.
Try to ".($syn?"find the synonym for":"translate")." another verb.\n"; exit("

Back to the Persian Verb Conjugation Tests

"); } print "\n"; } else { print "\n"; } ?>

You are wrong! "; if ($answers[$_POST['R1']-1]%2==1) { print "\"$verb1[trans_inf]\" means \"to $engVerb1\" while \"$verb2[trans_inf]\" means \"to $engVerb2\"."; } } $isPersScript = true; if ($syn) print "

Please listen, then give the correct synonym: "; else print "

Please listen, then translate into English: "; print Conjugate($pastStem, $verb1['pers_presstem'], $verb1['trans_presstem'], ($neg?12:1), $person); print "

"; $isPersScript = false; $pastStemTrans = substr($verb1['trans_inf'], 0, strlen($verb1['trans_inf'])-2); $trans_form = Conjugate($pastStemTrans, $verb1['trans_presstem'], $verb1['trans_presstem'], ($neg?12:1), $person); ?> */ if ($syn) $isPersScript = true; print "".Answer($i, 0).""; print "".Answer($i, 1).""; print "".Answer($i, 2).""; print "".Answer($i, 3).""; } print "

"; function Answer($q, $a) { global $pastStem, $person, $neg, $verb1, $verb2, $engVerb1, $engVerb2, $answers, $syn, $synonyms; $persons = array(1 => 'I', 'You', 'He/she/it', 'We', 'You', 'They'); $be = array(1 => 'was', 'were', 'was', 'were', 'were', 'were'); $bePres = array(1 => 'am', 'are', 'is', 'are', 'are', 'are'); $engVerb = ($answers[$a]%2==1) ? $engVerb2 : $engVerb1; // Which homograph? $words = explode(' ', $engVerb); // if there is a preposition after the verb $answer = $persons[$person].' '; if ($syn) $pastStem = substr($synonyms[$a]['pers_inf'], 0, strlen($synonyms[$a]['pers_inf'])-2); if ($answers[$a]>3) { // Negatives switch ($answers[$a]) { case 0: // Past case 1: case 4: case 5: if ($syn) { $answer = Conjugate($pastStem, $synonyms[$a]['pers_presstem'], $synonyms[$a]['trans_presstem'], 12, $person); } else { if ($words[0]=='be') { $answer .= $be[$person] . " not"; } else { $answer .= "did not $words[0]"; } } break; default: // Present if ($syn) { $answer = Conjugate($pastStem, $synonyms[$a]['pers_presstem'], $synonyms[$a]['trans_presstem'], 17, $person); } else { if ($words[0]=='be') { $answer .= $bePres[$person] . " not"; } else { $answer .= ($person==3?"does":"do")." not $words[0]"; } } break; } } else { switch ($answers[$a]) { case 0: // Past case 1: case 4: case 5: if ($syn) { $answer = Conjugate($pastStem, $synonyms[$a]['pers_presstem'], $synonyms[$a]['trans_presstem'], 1, $person); } else { if ($words[0]=='be') { $answer .= $be[$person]; } else { $answer .= verbPast($words[0]); } } break; default: // Present if ($syn) { $answer = Conjugate($pastStem, $synonyms[$a]['pers_presstem'], $synonyms[$a]['trans_presstem'], 7, $person); } else { if ($words[0]=='be') { $answer .= $bePres[$person]; } else { $answer .= ($person==3) ? eng3sgVerb($words[0]) : $words[0]; } } break; } } if (!$syn) { for ($i=1; $i


Persian Verb Conjugator

Back to the Persian Verb Conjugation Tests