function runProb() { global $pname, $uOutput, $filename, $uDir, $pDir, $language, $inputFile, $input; $filename = "code"; if (isset($pname)) { $filename = $pname; } // Write *input* file $userInputFile = $uDir . $filename . ".in"; write2File($uDir, $userInputFile, $input); $tag = "pre"; $uOutput = ""; // User's test case $output = runCode($language, $filename, $userInputFile); $uOutput = $uOutput . "<tr><td><" . $tag . ">"; $uOutput = $uOutput . $input; $uOutput = $uOutput . "</" . $tag . "></td>"; $uOutput = $uOutput . "<td><" . $tag . ">"; $uOutput = $uOutput . "Whatever you wanted it to output."; $uOutput = $uOutput . "</" . $tag . "></td>"; $uOutput = $uOutput . "<td><" . $tag . ">"; $uOutput = $uOutput . $output; $uOutput = $uOutput . "</" . $tag . "></td></tr>"; // Go through all test cases $allTestCases = getDirectoryList($pDir . "testCases/in/", false); foreach ($allTestCases as $t) { // Read *input* file $allTestCases = getDirectoryList($pDir . "testCases/in/", false); $inputFile = $pDir . "/testCases/in/" . $t; $probInput = readCode($pDir, $inputFile); // Read *output* file $outputFile = $pDir . "/testCases/out/" . $t; $probOutput = readCode($pDir, $outputFile); // Run code $output = runCode($language, $filename, $inputFile); // Check if $output is equal to correct $probOutput if ($output == $probOutput) { $s = "color:green;font-weight:bold;"; } else { $s = "color:red;font-style:italic;"; } // Display data $uOutput = $uOutput . "<tr style='" . $s . "' ><td><" . $tag . ">"; $uOutput = $uOutput . $probInput; $uOutput = $uOutput . "</" . $tag . "></td>"; $uOutput = $uOutput . "<td><" . $tag . ">"; $uOutput = $uOutput . $probOutput; $uOutput = $uOutput . "</" . $tag . "></td>"; $uOutput = $uOutput . "<td><" . $tag . ">"; $uOutput = $uOutput . $output; $uOutput = $uOutput . "</" . $tag . "></td></tr>"; } /* <table border="1" id="output"> <tr> <th>Input</th> <th>Desired Output</th> <th>Actual Output</th> </tr> <tr> <td><pre><?PHP echo $probInput; ?></pre></td> <td><pre><?PHP echo $probOutput; ?></pre></td> <td><pre><?PHP echo $uOutput; ?></pre></td> </tr> <tr> <td>Input2</td> <td>Output2</td> <td>UserOutput2</td> </tr> </table> */ }
function loadCode() { global $filename, $uDir, $code, $language, $input; // Write *input* file $userInputFile = $uDir . $filename . ".in"; $input = readCode($uDir, $userInputFile); // Save, compile, run via selected language if ($language == "Python") { //echo "PYTHON!!!"; // Save $code to file $ext1 = ".py"; $fullFile = $uDir . $filename . $ext1; $code = readCode($uDir, $fullFile); } else { if ($language == "Java") { // Save $code to file $ext1 = ".java"; $fullFile = $uDir . $filename . $ext1; //echo $fullFile; $code = readCode($uDir, $fullFile); } else { if ($language == "C++") { // Save $code to file $ext1 = ".cpp"; $fullFile = $uDir . $filename . $ext1; //echo $fullFile; $code = readCode($uDir, $fullFile); } } } }
function loadProb() { global $pname, $filename, $uDir, $pDir, $inputFile, $probInput, $outputFile, $probOutput, $infoFile, $probInfo, $code, $language, $topDir; $filename = "code"; if (isset($pname)) { $filename = $pname; } // Read *input* file $pDir = "{$topDir}/HYPC/ProblemZone/Problems/" . $pname . "/"; $allTestCases = getDirectoryList($pDir . "testCases/" . "in/", false); $inputFile = $pDir . "/testCases/in/" . $allTestCases[0]; $probInput = readCode($pDir, $inputFile); // Read *output* file $outputFile = $pDir . "/testCases/out/" . $allTestCases[0]; $probOutput = readCode($pDir, $outputFile); // Read *info* file $infoFile = $pDir . "info.txt"; $probInfo = readCode($pDir, $infoFile); }