function getAssignments($link, $table, $divisions) { // initialize data $semesterData = array(); foreach ($divisions as $index => $division) { $semesterData[$division] = 0; } // show all assignments $query = "select t.Task, t.Person, s.Division from {$table} as t inner join Students as s on s.Email = t.Person order by t.Task"; $statement = $link->prepare($query); $rc = $statement->execute(); if (!$rc) { $errNum = mysqli_errno($link); $errMsg = mysqli_error($link); print " ERROR - could not register selection: ErrNo=" . mysqli_errno($link) . ": " . mysqli_error($link) . "\n"; exit; } $statement->bind_result($task, $person, $division); while ($statement->fetch()) { $weight = 0; $myTask = new TeachingTask($task); if ($myTask->isTa() && $myTask->getEffort() == 'full') { $weight = 1.0; } if ($myTask->isTa() && $myTask->getEffort() == 'half') { $weight = 0.5; } $semesterData[$division] += $weight; } $statement->close(); return $semesterData; }
function showAssignment($link, $table, $option = "ALL") { // show all assignments $query = "select * from {$table} order by Task"; $statement = $link->prepare($query); $rc = $statement->execute(); if (!$rc) { $errNum = mysqli_errno($link); $errMsg = mysqli_error($link); print " ERROR - could not register selection: ErrNo=" . mysqli_errno($link) . ": " . mysqli_error($link) . "\n"; exit; } $statement->bind_result($task, $person); print "<table>\n"; print "<tr><th> Course </th><th> Type </th><th> Effort </th>"; print "<th> TA type </th><th> Person </th><th> Id </th></tr>\n"; $iF = 0; $iP = 0; while ($statement->fetch()) { $myTask = new TeachingTask($task); $display = 0; if ($option == "ALL") { $display = 1; } else { if ($option == "TA" && $myTask->isTa() && $person != "" && $person != "*****@*****.**") { $display = 1; } else { if ($option == "Unassigned" && ($person == "" || $person == "*****@*****.**")) { $display = 1; } } } if ($display) { print "<tr><td> " . "<a href=\"/showTaskSummary?number=" . $myTask->getCourse() . "\">" . $myTask->getCourse() . "</a>" . " </td><td>" . $myTask->getType() . " </td><td>" . $myTask->getEffort() . " </td><td>" . $myTask->getTaType() . " </td><td>" . "<a href=\"/showTaSummary?email=" . $person . "\">" . $person . "</a>" . " </td><td>" . $myTask->generateId() . " </td></tr>\n"; if ($myTask->isTa() && $myTask->getEffort() == 'full') { $iF = $iF + 1; } if ($myTask->isTa() && $myTask->getEffort() == 'half') { $iF = $iF + 0.5; } if ($myTask->isTa() && $myTask->getEffort() == 'part') { $iP = $iP + 1; } } } print "</table>"; print "<p> TA openings ({$option}): <b>{$iF}</b> (full time) <b>{$iP}</b> (part time).</p><br> \n"; }
$active = findActiveTable($link, 'Assignments'); print "Active tables: {$tasTable} (TAs), {$active['0']} (Assignments)</p>"; // start the form print '<form class="ta" action="/register" method="post">' . "\n"; // start the table print '<p>' . "\n"; print '<table>' . "\n"; // generate the options $options = array(); $query = "select * from {$active['0']} order by Task"; $statement = $link->prepare($query); $statement->execute(); $statement->bind_result($task, $email); while ($statement->fetch()) { $myTask = new TeachingTask($task); if ($myTask->isTa() && $myTask->getEffort() == 'full') { $option = $myTask->getTaTask(); $find = array_search($option, $options); if (!$find) { $options[$task] = $option; } } } // First preference print '<tr><td>What is your first preference?</td><td><select class="ta" name="pref1">' . "\n"; print ' <option value="">Select Preference 1</option>' . "\n"; foreach ($options as $key => $option) { print "<option value=\"" . $key . "\"> {$option} </option>"; } print '</select></td></tr>' . "\n"; // Second preference