500000) { // echo "Sorry, your file is too large."; $uploadOk = 0; } // allow certain file formats if ($imageFileType != "pdf") { // echo "Sorry, only PDF files are allowed."; $uploadOk = 0; } // check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { // echo "Sorry, your file was not uploaded."; // otherwise upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $targetFile)) { // echo "The file " . htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) . " has been uploaded."; } else { // echo "Sorry, there was an error uploading your file."; } } $fileName = htmlspecialchars(basename($_FILES["fileToUpload"]["name"])); // process file $output = shell_exec("java -jar TaskSheetChecker.jar " . $targetDirectory . $fileName); exec("rm " . $targetDirectory . $fileName); $keySeparator = ','; $delimiter = ';'; $keyArray = array(); $valueArray = array(); $currentString = ""; for ($i = 0; $i < strlen($output); $i++) { if ($output[$i] == $keySeparator) { array_push($keyArray, $currentString); $currentString = ""; } else if ($output[$i] == $delimiter) { array_push($valueArray, $currentString); $currentString = ""; } else $currentString = $currentString . $output[$i]; } // remove field that are not filled by student array_splice($keyArray, 0, 4); array_splice($valueArray, 0, 4); $emptyFields = 0; $filledFields = 0; foreach ($valueArray as $value) { if (strlen($value) == 0) $emptyFields++; else $filledFields++; } ?>
| Unfilled fields | |
|---|---|
| Filled fields |
| Field | Answer | Status | ' . $keyArray[$i] . ' | '; echo '' . $valueArray[$i] . ' | '; if (strlen($valueArray[$i]) == 0) echo 'EMPTY | ';
else
echo 'OK | ';
echo '';
}
?>
|---|