Example #1
0
<?php

// test access rights
include "app/views/admin/header.php";
if (!isMaster()) {
    exitAccessError();
}
// connect to our database
$link = getLink();
// find the active tables and the last non active table
$tables = findTables($link, 'Evaluations');
print '<article class="page">' . "\n";
print '<h1>Show All TA Evaluations</h1>';
print ' ';
print "<table>\n";
print "<tr><th>Term</th><th>Actions</th>\n";
foreach ($tables as $key => $table) {
    $term = substr($table, -5, 5);
    print " <tr><td>&nbsp; {$term}\n";
    print " </td><td>&nbsp; <a href=\"/showEvaluations?term={$term}\">show</a></td></tr>\n";
}
print '</table>' . "\n";
print '</article>' . "\n";
include "app/views/admin/footer.php";
Example #2
0
<?php

include "app/views/admin/header.php";
// make sure we are dealing with a registered TA
if (!isMaster()) {
    exitAccessError();
}
print '<article class="page">' . "\n";
print '<h1>Show All TA Assignments</h1>';
print ' ';
// connect to our database
$link = getLink();
// find the active tables and the last non active table
$tables = findTables($link, 'Assignments');
print "<table>\n";
print "<tr><th>Term</th><th>Actions</th>\n";
foreach ($tables as $key => $table) {
    $term = substr($table, -5, 5);
    print " <tr><td>&nbsp; {$term}\n";
    print " </td><td>&nbsp; <a href=\"/showAssignments?term={$term}\">show</a>,";
    print "          &nbsp; <a href=\"/updateAssignments?term={$term}\">update</a></td></tr>\n";
}
print "</table>\n";
print '</article>' . "\n";
include "app/views/admin/footer.php";
Example #3
0
function copyAssignment($link, $source, $target)
{
    // copy the last assignment to the active one
    print "<h2> copy {$source} to {$target}</h2><hr>\n";
    // Check if target exists
    $tables = findTables($link, $target);
    if (sizeof($tables) == 0) {
        $query = "create table {$target} like {$source}";
        $statement = $link->prepare($query);
        $rc = $statement->execute();
        if (!$rc) {
            $errNum = mysqli_errno($link);
            $errMsg = mysqli_error($link);
            print " ERROR - could not read source ErrNo=" . mysqli_errno($link) . ": " . mysqli_error($link) . "\n";
            exit;
        }
    }
    // collect all inserts
    $query = "select * from {$source}";
    $statement = $link->prepare($query);
    $rc = $statement->execute();
    if (!$rc) {
        $errNum = mysqli_errno($link);
        $errMsg = mysqli_error($link);
        print " ERROR - could not read source ErrNo=" . mysqli_errno($link) . ": " . mysqli_error($link) . "\n";
        exit;
    }
    $statement->bind_result($task, $person);
    $inserts = '';
    $i = 0;
    while ($statement->fetch()) {
        $myTask = new TeachingTask($task);
        $inserts[$i] = "insert into {$target} (Task) values ('{$task}')";
        print " {$inserts[$i]}<br>";
        $i = $i + 1;
    }
    // Now perform the inserts
    foreach ($inserts as $key => $insert) {
        print " execute update: {$insert} <br>\n";
        $statement = $link->prepare($insert);
        $rc = $statement->execute();
        if (!$rc) {
            $errNum = mysqli_errno($link);
            $errMsg = mysqli_error($link);
            print " ERROR - could not insert assignment: ErrNo=" . mysqli_errno($link) . ": " . mysqli_error($link) . "\n";
            exit;
        } else {
            print " INFO - entry inserted.<br>\n";
        }
    }
}