function get_nav_children($e) { $result = array(); foreach ($e->children() as $e) { if (!$e->visible()) { continue; } $class = ''; if ($e == $this->entity) { $class .= 'current '; if ($e->has_visible_children()) { $class .= 'ancestor '; } } else { if ($e->is_ancestor_of($this->entity)) { $class .= 'ancestor '; } } if ($e->submitable()) { $subm = Authentication::current_user()->status_of_last_submission_to($e); $class .= Status::to_css_class($subm) . ' '; } if (!$e->active()) { $class .= 'inactive '; } $result[] = array('title' => $e->title(), 'url' => $this->nav_script($e) . $e->path(), 'class' => $class); } return $result; }
function write_the_submission() { if (isset($_REQUEST['redirect'])) { echo '<a href="' . htmlspecialchars($_REQUEST['redirect']) . '">← back</a>'; } $this->write_block_begin("Submission", 'block submission ' . Status::to_css_class($this->subm), '', "submission-" . $this->subm->submissionid); write_submission($this->subm, $this->entity, true); $this->write_block_end(); }
function write_submissions() { $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0; $subms = $this->entity->latest_submissions($start, 10); foreach ($subms as $subm) { $entity = $subm->entity(); $this->write_block_begin($subm->submissionid . ': ' . $entity->title(), 'collapsable block submission ' . Status::to_css_class($subm), '', 'submission-' . $subm->submissionid); write_submission($subm, $entity, true); $this->write_block_end(); } if ($start > 0) { echo '<a href="admin_submissions.php?start=' . ($start - 10) . '">← prev</a> | '; } echo '<a href="admin_submissions.php?start=' . ($start + 10) . '">next →</a>'; }
function write_body() { echo '<a href="admin_results.php' . htmlspecialchars($this->entity->path()) . '">view all users</a>'; // list submissions $submissions = $this->user->submissions_to($this->entity); if (empty($submissions)) { echo "<em>no submissions have been made for this assignment by this user.</em>"; } else { $i = count($submissions); foreach ($submissions as $subm) { // is this an interesting submission? $is_interesting = true; if ($is_interesting) { $last_submission = $subm; } // write $this->write_block_begin('Submission ' . $i, 'collapsable block submission ' . ($is_interesting ? '' : 'collapsed ') . Status::to_css_class($subm), '', "submission-{$subm->submissionid}"); write_submission($subm, $this->entity); $this->write_block_end(); $i--; } } }
<?php require_once '../lib/bootstrap.inc'; require_once './submission_view.inc'; // ----------------------------------------------------------------------------- // Ajax utility: view a submission for autorefresh // ----------------------------------------------------------------------------- $submissionid = intval(@$_REQUEST['submissionid']); $subm = Submission::by_id($submissionid); $write_block = (isset($_GET['write_block']) and $_GET['write_block'] == "true"); // check access rights $user = Authentication::require_user(); if (!$user->is_admin && !$subm->is_made_by($user)) { die("You have no rights to view this submission"); } if ($write_block) { $entity = $subm->entity(); Template::write_block_begin($subm->submissionid . ': ' . $entity->title(), 'collapsable block submission ' . Status::to_css_class($subm), '', 'submission-' . $subm->submissionid); write_submission($subm); Template::write_block_end(); } else { echo "<div class=\"newstatus ", Status::to_css_class($subm), "\"></div>"; write_submission($subm); }
function write_submission_results($entities, $users) { echo "<table class=\"results\">\n"; // heading echo "<thead>"; $entity_layers = layered_descendants($this->entity); print_layers_header($entity_layers); echo "</thead><tbody>\n"; // user results $first = true; foreach ($users as $userinfo) { $subms = $userinfo['subms']; $user = $userinfo['user']; if ($first) { echo '<tr class="first-child">'; $first = false; } else { echo '<tr>'; } // username echo '<td><a href="admin_user.php?edit=' . urlencode($user->userid) . '">' . htmlspecialchars($user->name_and_login()) . '</a></td>'; // submissions foreach ($entities as $e => $entity) { $subm = isset($subms[$e]) ? $subms[$e] : false; $status = Status::to_status($subm); echo '<td class="' . Status::to_css_class($status) . '">'; if ($subm !== false) { echo '<a href="admin_user_submission.php' . htmlspecialchars($entity->path()) . '?userid=' . $user->userid . '">'; } echo Status::to_short_text($status); if ($subm !== false) { echo '</a>'; } echo '</td>'; } echo "</tr>\n"; } $this->write_submission_summary($entities, $users); echo "</tbody></table>\n"; }
function write_overview_item($e) { if (!$e->visible()) { return; } $class = ''; if ($e->submitable()) { $subm = Authentication::current_user()->status_of_last_submission_to($e); $class .= Status::to_css_class($subm) . ' '; } if (!$e->active()) { $class .= 'inactive '; } $this->write_block_begin($e->title(), 'collapsed linky block ' . $class, 'index.php' . $e->path()); $this->write_block_end(); }