 | admin on 1/11/10 @ 4:12 amESTHow to use it (The package has more examples):
define('ZAPI_DIRECTORY', dirname(__FILE__). DIRECTORY_SEPARATOR);
include_once ZAPI_DIRECTORY . 'lib'. DIRECTORY_SEPARATOR . 'zAPI.php';
$myUsername = "testing_username" ;
$myKey = "5866887b22b194862fce17a8ec594fe0" ;
// create a api class
$zApi = new zTrainingAPI ($myUsername, $myKey);
$cSolution =
"#include <stdio.h>\n" .
"int main() { \n".
"int a,b; ".
"scanf(\"%d %d\", &a, &b); ".
"printf(\"%d\", a + b); return 0; }";
$result = $zApi->gradeSolution("zbir", zLangs ::C, $cSolution);
echo $result->passed? "Passed\n\n":"Didn't pass\n\n";
$scmSolution = "(let ((a (read)) (b (read))) (display (+ a b)))";
$result = $zApi->gradeSolution("zbir", zLangs ::SCHEME, $scmSolution);
echo $result->passed? "Passed\n\n":"Didn't pass\n\n";
$pSolution =
"import sys, string\n".
"x = string.split(sys.stdin.readline().strip(), \" \")\n".
"print int(x[0])+int(x[1])";
$result = $zApi->gradeSolution("zbir", zLangs ::PYTHON, $pSolution);
echo $result->passed? "Passed\n\n":"Didn't pass\n\n"; |