(count($modal_verbs)-1) || $modalTest<0) $modalTest = -1; $title = "Combined Impersonal Modal Verb Test (".($isSpoken?"spoken":"written")." style, ".($isPersScript?"Persian script":"transcription").")"; $bodyParams = ($isSpoken?'text="#FFFFFF" bgcolor="#808080"':'text="#000000" bgcolor="#CC99FF"'); $total = 50; //#################################### // Sending a letter to the instructor if (isset($_POST['sendinfo'])) { $link = mysql_connect("localhost", $login, $pass) or die("Could not connect: " . mysql_error()); mysql_select_db($db) or die("Could not select database"); $stname = htmlspecialchars($_POST['stname']); $email = htmlspecialchars($_POST['email']); // if ($_POST['univer']=='University of Texas at Austin') { // $sql = "INSERT INTO test_results (`date`, `name`, `email`, `othertest_id`, `grade`, comment) // VALUES ('".date('Y-m-d H:i:s')."', '$stname', '$email', 36, 'A', '');"; // mysql_query($sql); // } $mailtext = "This is the letter from the $title. $stname from {$_POST['univer']} has successfully answered all the questions of this test! His/her e-mail is $email Best regards, Persian Test System {$_SERVER['HTTP_REFERER']}"; $uri = $_SERVER['HTTP_REFERER']; $header = "From: {$_POST['email']}\n" ."MIME-Version: 1.0\n" ."Content-Type: text/plain; charset=\"windows-1252\"\n" ."Content-Transfer-Encoding: 7bit\n"; if ($_POST['univer']=='University of Michigan') { $mb = 0; $mailto = "aghaeib@umich.edu"; } elseif ($_POST['univer']=='South Orange County Community College District') { $mb = 1; $mailto = "monird@cox.net"; } elseif ($_POST['univer']=='UT Informal Class') { $mb = 2; $mailto = "blake.atwood@gmail.com"; } else { $mb = 3; $mailto = "connieb@gmail.com"; } $subject = $title; $uri = base64_encode($uri); $error = "Sorry. This service is unavailable right now. Try to send a e-mail later."; /* $PostData = "mb=$mb&sbj=$subject&stname=$stname&email=$email&uri=$uri"; $len = strlen($PostData); $fp = fsockopen("students.washington.edu", 80, $errno, $errstr, 30); if ($fp) { fputs($fp, "POST /irina/tests/emailer.php HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;.NET CLR 1.1.4322; .NET CLR 2.0.50215) Host: students.washington.edu Connection: close Content-Type: application/x-www-form-urlencoded Content-Length: $len $PostData"); $page = ""; while (!feof($fp)) $page .= fgets($fp, 128); fclose($fp); if (substr($page, strlen($page)-6)=="SENDOK") { $sent = true; $error = ""; } // echo ""; } */ // 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 - $title", $mailtext, $header); exit(' '.$title.'

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

Back to the Persian Tests "); } function GetQuestion($person, $negative, $verb) { global $isPersScript; $persons = array(1 => 'I', 'You', 'He/she/it', 'We', 'You', 'They'); $persons2 = array(1 => 'me', 'you', 'him/her/it', 'us', 'you', 'them'); $be = array(1 => 'am', 'are', 'is', 'are', 'are', 'are'); $verb = str_replace(",", "", $verb); $words = explode(' ', $verb); // if there is a preposition after the verb if ($verb=='be possible') $question = 'It '; else $question = 'One '; if ($negative) { if ($words[0]=='be') { if ($verb=='be possible for') $question .= $be[3] . " not"; else { $question .= $be[$person] . " not"; } } elseif ($words[0]=='must') { $question .= $words[0] . " not"; } else { if ($person==3) $question .= "does not $words[0]"; else $question .= "do not $words[0]"; if ($words[0]=='let') { $question .= ', '.array_pop($words); } } } else { if ($words[0]=='be') { if ($verb=='be possible') $question .= $be[3]; else { $question .= $be[$person]; } } else { if ($person==3 && $words[0]!='must') $question .= eng3sgVerb($words[0]); else $question .= $words[0]; if ($words[0]=='let') { $question .= ', '; $verb2 = array_pop($words); if ($person==3) $question .= eng3sgVerb($verb2); else $question .= $verb2; } } } for ($i=1; $i .css"> 321".($id?"":" AND (e1.hassnd=1 OR e1.hassndtest=1)")." AND e2.style=0".($id?" AND e1.id=$id":" ORDER BY RAND()").";"); else $r = mysql_query("SELECT * FROM pvc_verbs WHERE id<>26 AND isnew=0 AND level=1 AND style=0".($id?"":" AND (hassnd=1 OR hassndtest=1)")." AND translation IS NOT NULL".($id?" AND id=$id":" ORDER BY RAND()").";"); $row = mysql_fetch_assoc($r); if ($row===false) exit("The verb is not found"); $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 = $row['translation']; $engVerbs = explode(',', $engVerb); $engVerb = $engVerbs[0]; if (substr($engVerb, 0, 3)=='to ') $engVerb = substr($engVerb, 3); // $tags = explode(',', $row['tags']); // if (!empty($row['tags'])) { // for ($i=0; $i4) { $modals[] = $modal_ar[rand(0, count($modal_ar)-1)]; } else { $modals[] = $modal; } if (in_array($qtypes[$j], array(3, 5))) { $persons[$j] = $persons[$answer]; } if (in_array($qtypes[$j], array(1, 2, 3, 4))) { $mpersons[$j] = $mpersons[$answer]; } elseif ($qtypes[$j]==5) { if ($modals[$j]==1) $mpersons[$j] = 0; else $mpersons[$j] = 3; } if ($modals[$j]==2) { $mpersons[$j] = 3; } // only one YOU should be among answers if ($qtypes[$j]==2) { if ($persons[$answer]==2 && $persons[$j]==5) { $persons[$j] = array_pop($persons); } if ($persons[$answer]==5 && $persons[$j]==2) { $persons[$j] = array_pop($persons); } } // if ($modals[$j]==2) { // $persons[$j] = 3; // $tenses[$j] = $neg[$j] ? 17 : 7; // } switch ($qtypes[$j]) { case 1: // correct answer case 2: // wrong person case 5: // wrong modal verb case 6: // wrong modal verb and person $tenses[] = 1; $mtenses[] = 7; break; case 3: case 4: do { if (count($wrong_tenses)==0) { $tense = 1; break; } else $tense = array_shift($wrong_tenses); } while (Conjugate(substr($randomVerb, 0, strlen($randomVerb)-2), $presStem, $presStemTrans, $tense, $persons[$j])==""); $tenses[] = $tense; $mtenses[] = 7; break; case 7: $cnt = 0; do { $cnt++; if ($cnt>7) { $tense = 1; break; } else $tense = array_shift($mwrong_tenses); if (Conjugate($modal_verbs[$modals[$j]][0], $modal_verbs[$modals[$j]][1], $modal_verbs[$modals[$j]][2], $tense, $mpersons[$j])=="") { array_push($mwrong_tenses, $tense); } else break; } while (true); // print ""; $mtenses[] = $tense; $tenses[] = 1; break; } } $data = "$verb_id:$engVerb:".implode(",", $modals).":$answer:".implode(",", $persons).":".implode(",", $mpersons).":".implode(",", $tenses).":".implode(",", $mtenses).":".implode(",", $qtypes).":".implode(",", $neg).":$question"; $data = base64_encode($data); } $pastStem = substr($randomVerb, 0, strlen($randomVerb)-2); if (!$correct) { print "\n"; } else { print "\n"; } ?>

$total) { 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 "

Question $question out of $total"; } print "

"; if (isset($_POST['check']) && $correct==0) { print "

You are wrong! "; } ?> Please translate to Persian:

".GetQuestion($persons[$answer], $neg[$answer], $modal_verbs[$modal][3])." $engVerb."; print ""; for ($j=1; $j<=4; $j++) { $modal_verb = Conjugate($modal_verbs[$modals[$j-1]][0], $modal_verbs[$modals[$j-1]][1], $modal_verbs[$modals[$j-1]][2], ($neg[$j-1]?neg($mtenses[$j-1]):$mtenses[$j-1]), ($modals[$j-1]==2?3:$mpersons[$j-1])); print ""; } print "
$modal_verb ".Conjugate($pastStem, $presStem, $presStemTrans, $tenses[$j-1], $persons[$j-1])."
"; } print "

"; ?>

Back to the Persian Verb Conjugator Basic Verb Conjugation Tests"; ?>

Back to the Persian Tests