Ejemplo n.º 1
0
use Tsugi\Util\LTI;
use Tsugi\Util\Mersenne_Twister;
$MAX_UPLOAD_FILE_SIZE = 1024 * 1024;
require_once "sql_util.php";
$answer = array("iupui.edu" => 536, "umich.edu" => 491, "indiana.edu" => 178, "caret.cam.ac.uk" => 157, "vt.edu" => 110);
$oldgrade = $RESULT->grade;
if (isset($_FILES['database'])) {
    $fdes = $_FILES['database'];
    // Check to see if they left off the file
    if ($fdes['error'] == 4) {
        $_SESSION['error'] = 'Missing file, make sure to select a file before pressing submit';
        header('Location: ' . addSession('index.php'));
        return;
    }
    if ($fdes['size'] > $MAX_UPLOAD_FILE_SIZE) {
        $_SESSION['error'] = "Uploaded file must be < " . displaySize($MAX_UPLOAD_FILE_SIZE);
        header('Location: ' . addSession('index.php'));
        return;
    }
    if (!endsWith($fdes['name'], '.sqlite')) {
        $_SESSION['error'] = "Uploaded file must have .sqlite suffix: " . $fdes['name'];
        header('Location: ' . addSession('index.php'));
        return;
    }
    $file = $fdes['tmp_name'];
    $fh = fopen($file, 'r');
    $prefix = fread($fh, 100);
    fclose($fh);
    if (!startsWith($prefix, 'SQLite format 3')) {
        $_SESSION['error'] = "Uploaded file is not SQLite3 format: " . $fdes['name'];
        header('Location: ' . addSession('index.php'));
Ejemplo n.º 2
0
    return;
}
if ($LINK->grade > 0) {
    echo '<p class="alert alert-info">Your current grade on this assignment is: ' . $LINK->grade * 100.0 . '%</p>' . "\n";
}
if ($dueDate->message) {
    echo '<p style="color:red;">' . $dueDate->message . '</p>' . "\n";
}
?>
<p>
<form name="myform" enctype="multipart/form-data" method="post" >
To get credit for this assignment, perform the instructions below and 
upload your SQLite3 database here: <br/>
<input name="database" type="file"> 
(Must have a .sqlite suffix and be &lt; <?php 
echo displaySize($MAX_UPLOAD_FILE_SIZE);
?>
 in size)<br/>
<input type="submit">
<p>
You do not need to export or convert the database -  simply upload 
the <b>.sqlite</b> file that your program creates.  See the example code for
the use of the <b>connect()</b> statement.
</p>
</form>
</p>
<h1>Musical Track Database</h1>
<p>
This application will read an iTunes export file in XML and produce a properly
normalized database with this structure:
<pre>