'I', 'You', 'He', 'We', 'You (pl.)', 'They'); $question = $persons[$person]." ______."; // if ($person==3) $question .= eng3sgVerb($verb); // else $question .= $verb; // $question .= ". ".$persons[$q_person]." ______."; return $question; } function EngConjugate($verb, $person) { if ($verb=='be') { if ($person==1) return 'am'; elseif ($person==3) return 'is'; else return 'are'; } elseif ($person==3) { return eng3sgVerb($verb); } return $verb; } function eng3sgVerb($verb) { $words = explode(' ', $verb); // if there is a preposition after the verb $vowels = 'aeiou'; $len = strlen($words[0]); if ($words[0]=='be') $verbform = 'is'; elseif ($words[0]=='have') $verbform = 'has'; elseif (substr($words[0], $len-1)=='y') { if (strpos($vowels, substr($words[0], $len-2, 1))===false) { $verbform = substr($words[0], 0, $len-1)."ies"; // deny -> denies } } elseif (substr($words[0], $len-1)=='o' || substr($words[0], $len-2)=='ss' || substr($words[0], $len-2)=='sh' || substr($words[0], $len-2)=='ch') { $verbform = $words[0]."es"; // go -> goes } if (empty($verbform)) $verbform = $words[0]."s"; if (count($words)>1) { // if there is a preposition after the verb for ($i=1; $i"; } */ // header("Location: http://students.washington.edu/irina/tests/emailer.php?mb=$mb&sbj=$subject&stname=$stname&email=$email&uri=$uri"); // exit(); $sent = mail($mailto, "Persian Test System - Tenses", $mailtext, $header); exit(' Tenses Test

'.($sent?"Your results have successfully been sent to your Instructor!":$error)."

Back to the Persian Tests "); } //#################################### // Question generation or retrieving $isPersScript = !isset($_GET['trans']); $part = 0; $verbCount = 6; if (isset($_POST['check'])) { $part = $_POST['part']; $data = $_POST['data']; $newdata = explode(":", $data); $newdata = explode(":", base64_decode($data)); $verbs_pers = explode(";", $newdata[0]); for ($i=0; $i<$verbCount*3; $i++) $verbs_pers[$i] = explode(",", $verbs_pers[$i]); $persons = explode(",", $newdata[1]); $questions_data = explode(";", $newdata[2]); $questions = array(); for ($i=0; $i<$verbCount*3; $i++) array_push($questions, explode(",", $questions_data[$i])); $answers = explode(",", $newdata[3]); $engVerbs = explode(",", $newdata[4]); $verbs = array(); for ($i=0; $i<$verbCount*3; $i++) { $query = "SELECT * FROM verb_list WHERE ".($isPersScript?"pers":"trans")."=\"{$verbs_pers[$i][0]}\";"; $r = mysql_query($query); $row = mysql_fetch_array($r, MYSQL_BOTH); $row = array($row, $verbs_pers[$i][1]); array_push($verbs, $row); } } else { $verbs_all = array(); $r = mysql_query("SELECT * FROM verb_list;"); while ($row = mysql_fetch_array($r, MYSQL_BOTH)) { if ($row['eng']!='have') array_push($verbs_all, $row); } // Select random verbs from all verbs srand((float)microtime() * 10000000); $inds = array_rand($verbs_all, $verbCount); $verbs = array(); for ($i=0; $i<$verbCount; $i++) { for ($j=0; $j<3; $j++) { $temp = array($verbs_all[$inds[$i]], $j); array_push($verbs, $temp); } } shuffle($verbs); $answers = array(); $questions = array(); $persons = array(); $engVerbs = array(); for ($i=0; $i<$verbCount*3; $i++) { $engVerb = $verbs[$i][0]['eng']; $temp = explode(',', $engVerb); array_push($engVerbs, trim($temp[array_rand($temp)])); // Select one verb if there are synonyms switch ($verbs[$i][1]) { case 0: $temp = range(1, 6); $answer_index = array_rand($temp); $answer = $temp[$answer_index]; // Select one person for a verb array_push($persons, $answer); unset($temp[$answer_index]); //Select 2 among all persons but one in question if ($answer==2) unset($temp[5-1]); //Show only one 'you'-form: singular if ($answer==5) unset($temp[2-1]); // or plural $ar_ind = array_rand($temp, 2); $temp = array($temp[$ar_ind[0]], $temp[$ar_ind[1]], $answer); shuffle($temp); //Shuffle 3 answers array_push($questions, $temp); for ($j=0; $j<3; $j++) { if ($questions[$i][$j]==$persons[$i]) { array_push($answers, $j); //Remember the number of the correct answer break; } } break; case 1: $temp = range(1, 6); $answer_index = array_rand($temp); $answer = $temp[$answer_index]; // Select one person for a verb array_push($persons, $answer); $temp = array(2, 5, 7); shuffle($temp); //Shuffle 3 tenses: 2 - Imperfect, 5 - Present Perfect, 7 - Present Indecative (correct) array_push($questions, $temp); for ($j=0; $j<3; $j++) { if ($questions[$i][$j]==7) { array_push($answers, $j); //Remember the number of the correct answer break; } } break; case 2: $temp = array(2, 5); $answer = $temp[array_rand($temp)]; // Select the correct answer - person 2 or 5 for Imperative array_push($persons, $answer); if ($answer==2) $wrong = array(1, 3, 4, 6); else $wrong = array(1, 2, 3, 4, 6); $inds = array_rand($wrong, 2); $temp = array('cor', $wrong[$inds[0]], $wrong[$inds[1]]); shuffle($temp); array_push($questions, $temp); for ($j=0; $j<3; $j++) { if ($questions[$i][$j]=='cor') { array_push($answers, $j); //Remember the number of the correct answer $questions[$i][$j] = $answer; break; } } } } $lang = ($isPersScript)?"pers":"trans"; $data = $verbs[0][0][$lang].",".$verbs[0][1]; for ($i=1; $i<$verbCount*3; $i++) $data .= ";".$verbs[$i][0][$lang].",".$verbs[$i][1]; $data .= ":".implode(",", $persons).":"; for ($i=0; $i<$verbCount*3; $i++) $data .= implode(",", $questions[$i]).";"; $data .= ":".implode(",", $answers).":".implode(",", $engVerbs); $data = str_replace(",;", ";", $data); $data = str_replace(";:", ":", $data); $data = base64_encode($data); } ?> Tenses Test \n

Tenses

\n"; $part++; if ($part==ceil($total/10)) { print "

You have answered all $total questions correctly. Fill the form and click the button to send the results to your instructor:

\n"; include("emailform.php"); exit(); } else { print "

You have completed $end out of $total, ".($total-$end)." left to go.

"; } } else { ?> \n

Tenses

You have answered $correct questions of $answcount correctly. Try again."; } } else { print "\n

Tenses

There are $total questions in this test. Answer the first 10:"; } ?>

"> 'I', 'You', 'He', 'We', 'You', 'They'); if ($isPersScript) $pers_persons = array(1 => 'من', 'تو', 'او', 'ما', 'شما', 'آنها'); else $pers_persons = array(1 => 'man', 'to', 'u', 'mā', 'shomā', 'ānhā'); $engVerb = $engVerbs[$i-1]; $pastStem = ($isPersScript)?$verbs[$i-1][0]['pers']:$verbs[$i-1][0]['trans']; $pastStem = substr($pastStem, 0, strlen($pastStem)-2); $presStem = ($isPersScript)?$verbs[$i-1][0]['pers_pres']:$verbs[$i-1][0]['trans_pres']; $presStemTrans = $verbs[$i-1][0]['trans_pres']; switch ($verbs[$i-1][1]) { case 0: print "

$i) Please translate \"".$eng_persons[$persons[$i-1]]." ".EngConjugate($engVerb, $persons[$i-1]).".\""; print ""; print ""; print "
".Conjugate($pastStem, $presStem, $presStemTrans, 7, $questions[$i-1][0])."
".Conjugate($pastStem, $presStem, $presStemTrans, 7, $questions[$i-1][1])."
".Conjugate($pastStem, $presStem, $presStemTrans, 7, $questions[$i-1][2])."
"; break; case 1: print "

$i) Please change this verb whose infinitive means \"to $engVerb\" from the Simple Past to the Present Indicative, keeping the same person: ".Conjugate($pastStem, $presStem, $presStemTrans, 1, $persons[$i-1]); print ""; print ""; print "
".Conjugate($pastStem, $presStem, $presStemTrans, $questions[$i-1][0], $persons[$i-1])."
".Conjugate($pastStem, $presStem, $presStemTrans, $questions[$i-1][1], $persons[$i-1])."
".Conjugate($pastStem, $presStem, $presStemTrans, $questions[$i-1][2], $persons[$i-1])."
"; break; case 2: print "

$i) Change 'to ".$engVerb."' (".($isPersScript?$verbs[$i-1][0]['pers']:$verbs[$i-1][0]['trans']).") to '".strtoupper(substr($engVerb, 0, 1)).substr($engVerb, 1)."!'"; $tense = ($answers[$i-1]==0)?11:9; print ""; $tense = ($answers[$i-1]==1)?11:9; print ""; $tense = ($answers[$i-1]==2)?11:9; print "
".Conjugate($pastStem, $presStem, $presStemTrans, $tense, $questions[$i-1][0])."
".Conjugate($pastStem, $presStem, $presStemTrans, $tense, $questions[$i-1][1])."
".Conjugate($pastStem, $presStem, $presStemTrans, $tense, $questions[$i-1][2])."
"; break; } } print "

"; ?>


Persian Verb Conjugator

Back to the Persian Tests