'I', 'You', 'He/she/it', 'We', 'You', 'They'); $be = array(1 => 'am', 'are', 'is', 'are', 'are', 'are'); $words = explode(' ', $verb); // if there is a preposition after the verb $question = $persons[$person].' '; if ($negative) { if ($words[0]=='be') { $question .= $be[$person] . " not"; } else { if ($person==3) $question .= "does not $words[0]"; else $question .= "do not $words[0]"; } } else { if ($words[0]=='be') { $question .= $be[$person]; } else { if ($person==3) $question .= eng3sgVerb($words[0]); else $question .= $words[0]; } } for ($i=1; $i$id":"").";"); $verbCount = mysql_num_rows($r); $verb_ids = range(0, $verbCount-1); srand((float)microtime() * 1000000); $verb_ids = array_rand($verb_ids, 5); shuffle($verb_ids); $curVerb = 0; if ($id>0) { $rid = mysql_query("SELECT * FROM pvc_verbs WHERE isnew=0 AND level=1 AND translation IS NOT NULL".($id?" AND id=$id":"").";"); if (!$rid) { exit("The verb is not found"); } $verb_ids = array_merge(array($id), $verb_ids); $row = mysql_fetch_assoc($rid); } else { mysql_data_seek($r, $verb_ids[$curVerb]); // the first verb of 5 is the verb for the question $row = mysql_fetch_assoc($r); } $curVerb++; $verb_id = $row['id']; if ($isPersScript) { $randomVerb = $row['pers_inf']; $presStem = $row['pers_presstem']; } else { $randomVerb = $row['trans_inf']; $presStem = $row['trans_presstem']; } $presStemTrans = $row['trans_presstem']; $engVerb = str_replace('to ', '', $row['translation']); $engVerbs = explode(',', $engVerb); $engVerb = trim($engVerbs[array_rand($engVerbs)]); // Select one verb if there are synonyms //Make a list of answers - person numbers $persons = range(1, 6); shuffle($persons); //Negative - 1 or Positive - 0 $neg = array(0,0,0,1,1,1); shuffle($neg); $answers = array(); $qtypes = array(); $questions = array(); for ($i=0; $i<6; $i++) { // 1 - wrong tense; 2 - wrong person; 3 - wrong spelling, 4 - wrong verb if ($isPersScript) $qtypes2 = array(1,2,3,4); else $qtypes2 = array(1,2,4); shuffle($qtypes2); $qtypes[$i] = array(array_shift($qtypes2), array_shift($qtypes2), 0); shuffle($qtypes[$i]); //Shuffle 3 answers $temp = range(1, 6); $answer = $persons[$i]; unset($temp[$answer-1]); //Select a person but one in question if ($answer==2) unset($temp[5-1]); //exclude You (pl.) if You (sg.) is set if ($answer==5) unset($temp[2-1]); //exclude You (sg.) if You (pl.) is set shuffle($temp); $tenses = array(13, 15); // Imperfect and Present Perfect for ($j=0; $j<3; $j++) { switch ($qtypes[$i][$j]) { case 0: // correct answer $questions[$i][$j] = $answer; $answers[] = $j; break; case 1: // wrong tense $questions[$i][$j] = $tenses[array_rand($tenses, 1)]; break; case 2: // wrong person $questions[$i][$j] = array_shift($temp); break; case 3: // wrong spelling $questions[$i][$j] = 0; break; case 4: // wrong verb mysql_data_seek($r, $verb_ids[$curVerb]); $row = mysql_fetch_assoc($r); $curVerb++; if ($isPersScript) { $questions[$i][$j] = $row['pers_inf'].'|'.$row['pers_presstem'].'|'.$row['trans_presstem']; } else { $questions[$i][$j] = $row['trans_inf'].'|'.$row['trans_presstem'].'|'.$row['trans_presstem']; } break; } } } $data = $verb_id.":".$engVerb.":".implode(",", $persons).":".implode(",", $neg).":".implode(",", $answers).":"; for ($i=0; $i<6; $i++) $data .= implode(",", $qtypes[$i]).";"; $data = substr($data, 0, strlen($data)-1).':'; for ($i=0; $i<6; $i++) $data .= implode(",", $questions[$i]).";"; $data = substr($data, 0, strlen($data)-1); $data = str_replace(",;", ";", $data); $data = str_replace(";:", ":", $data); $data = base64_encode($data); } $pastStem = substr($randomVerb, 0, strlen($randomVerb)-2); ?> Present Indicative Test \n

Tenses

\n"; print "

You have answered all questions correctly. Try to conjugate another verb.\n"; exit("

Back to the Persian Tests"); } print "\n"; } else { print "\n"; } ?>

Tenses

Please translate to Persian:

".GetQuestion($persons[$i-1], $neg[$i-1], $engVerb); print ""; print ""; print "
".Answer($i, 0)."
".Answer($i, 1)."
".Answer($i, 2)."
"; } print "

"; function Answer($q, $a) { global $pastStem, $presStem, $presStemTrans, $qtypes, $questions, $persons, $neg, $isPersScript; switch ($qtypes[$q-1][$a]) { case 0: $t = ($neg[$q-1]) ? 17 : 7; return Conjugate($pastStem, $presStem, $presStemTrans, $t, $questions[$q-1][$a]); break; case 1: $t = $questions[$q-1][$a]; if ($neg[$q-1]==0) { $t = ($t==13) ? 2 : 5; } return Conjugate($pastStem, $presStem, $presStemTrans, $t, $persons[$q-1]); break; case 2: $t = ($neg[$q-1]) ? 17 : 7; return Conjugate($pastStem, $presStem, $presStemTrans, $t, $questions[$q-1][$a]); break; case 3: $s = Conjugate($pastStem, $presStem, $presStemTrans, 17, $persons[$q-1]); if (strpos($s, ' ')) { $s = explode(' ', $s); $s = $s[0].' '.substr($s[1], 0, 2).($isPersScript?'ه ':' ').substr($s[1], 2); } else { $s = substr($s, 0, 2).($isPersScript?'ه ':' ').substr($s, 2); } return $s; break; case 4: $t = ($neg[$q-1]) ? 17 : 7; $s = explode('|', $questions[$q-1][$a]); return Conjugate(substr($s[0], 0, strlen($s[0])-2), $s[1], $s[2], $t, $persons[$q-1]); break; default: break; } } ?>


Persian Verb Conjugator

Back to the Persian Tests