private function get_pset_info() { if (!$this->_info && $this->pset) { $this->_info = ContactView::user_pset_info($this->recipient, $this->pset); $this->_info->set_commit(null); } return $this->_info; }
function user_pset_info() { global $Conf, $User, $Pset, $Info, $Commit, $Qreq; $Info = ContactView::user_pset_info($User, $Pset); if (($Commit = $Qreq->newcommit) == null) { $Commit = $Qreq->commit; } if (!$Info->set_commit($Commit)) { $Conf->ajaxExit(array("ok" => false, "error" => $Info->repo ? "No repository." : "Commit " . htmlspecialchars($Commit) . " isn’t connected to this repository.")); } return $Info; }
// HotCRP and Peteramati are Copyright (c) 2006-2015 Eddie Kohler and others // See LICENSE for open-source distribution terms require_once "src/initweb.php"; ContactView::set_path_request(array("/@", "/@/p", "/@/p/h", "/@/p/h/h", "/p/h/h")); if ($Me->is_empty()) { $Me->escape(); } global $User, $Pset, $Info; $User = $Me; if (isset($_REQUEST["u"]) && !($User = ContactView::prepare_user($_REQUEST["u"]))) { redirectSelf(array("u" => null)); } assert($User == $Me || $Me->isPC); Ht::stash_script("peteramati_uservalue=" . json_encode($Me->user_linkpart($User))); $Pset = ContactView::find_pset_redirect(@$_REQUEST["pset"]); $Info = ContactView::user_pset_info($User, $Pset); if (!get($_GET, "commit") || !get($_GET, "commit1") || $Pset->gitless) { $Me->escape(); } $diff_options = ["wdiff" => false]; $hasha = $hashb = $hasha_mine = $hashb_mine = null; $hrecent = $Pset->handout_commits(); if ($hasha = git_commit_in_list($hrecent, $_GET["commit"])) { $diff_options["hasha_hrepo"] = true; } else { $hasha = $hasha_mine = $Info->set_commit($_GET["commit"]); } if ($hashb = git_commit_in_list($hrecent, $_GET["commit1"])) { $diff_options["hashb_hrepo"] = true; } else { $hashb = $hashb_mine = $Info->set_commit($_GET["commit1"]);
function render_pset_row(Pset $pset, $students, Contact $s, $row, $pcmembers, $anonymous) { global $Conf, $Me, $Now, $Profile; $row->sortprefix = ""; $ncol = 0; $t0 = $Profile ? microtime(true) : 0; $j = []; $j["username"] = $s->github_username ?: $s->seascode_username ?: ($s->email ?: $s->huid); if ($anonymous) { $j["anon_username"] = $s->anon_username; } $j["sorter"] = $s->sorter; ++$ncol; $j["name"] = Text::name_text($s); if ($s->extension) { $j["x"] = true; } if (!$anonymous) { ++$ncol; } if ($s->gradercid) { $j["gradercid"] = $s->gradercid; } ++$ncol; // are any commits committed? if (!$pset->gitless_grades) { if (($s->placeholder || $s->gradehash === null) && $s->repoid && ($s->placeholder_at < $Now - 3600 && rand(0, 2) == 0 || $s->placeholder_at < $Now - 600 && rand(0, 10) == 0) && (!$s->repoviewable || !$s->gradehash)) { // XXX this is slow given that most info is already loaded $info = ContactView::user_pset_info($s, $pset); $info->set_commit(null); $s->gradehash = $info->commit_hash() ?: null; $s->placeholder = 1; Dbl::qe("insert into RepositoryGrade (repoid, pset, gradehash, placeholder, placeholder_at) values (?, ?, ?, 1, ?) on duplicate key update gradehash=(if(placeholder=1,values(gradehash),gradehash)), placeholder_at=values(placeholder_at)", $s->repoid, $pset->id, $s->gradehash, $Now); if (!$s->repoviewable) { $s->repoviewable = $s->can_view_repo_contents($info->repo); } } if (!$s->gradehash || $s->dropped) { $row->sortprefix = "~1 "; } } if (count($pset->grades)) { $gi = null; if ($pset->gitless_grades) { $gi = $pset->contact_grade_for($s); } else { if ($s->gradehash && !$s->placeholder) { $gi = $pset->commit_notes($s->gradehash); } } $gi = $gi ? $gi->notes : null; if (!$pset->gitless_grades) { if ($gi && get($gi, "linenotes")) { $j["has_notes"] = true; } else { if ($Me->contactId == $s->gradercid) { $s->incomplete = true; } } if ($gi && $s->gradercid != get($gi, "gradercid") && $Me->privChair) { $j["has_nongrader_notes"] = true; } ++$ncol; } $garr = render_grades($pset, $gi, $s); $ncol += count($garr->all); $j["grades"] = $garr->allv; $j["total"] = $garr->totalv; if ($garr->differentk) { $j["highlight_grades"] = $garr->differentk; } } //echo "<td><a href=\"mailto:", htmlspecialchars($s->email), "\">", //htmlspecialchars($s->email), "</a></td>"; if (!$pset->gitless && $s->url) { $j["repo"] = RepositorySite::make_web_url($s->url, $Conf); if (!$s->working) { $j["repo_broken"] = true; } else { if (!$s->repoviewable) { $j["repo_unconfirmed"] = true; } } if ($s->open) { $j["repo_too_open"] = true; } if ($s->pcid != $s->rpcid || $s->pcid && (!isset($students[$s->pcid]) || $students[$s->pcid]->repoid != $s->repoid)) { $j["repo_partner_error"] = true; } } ++$ncol; if (!get($row, "ncol") || $ncol > $row->ncol) { $row->ncol = $ncol; } $s->visited = true; return $j; }
function render_pset_row($pset, $students, $s, $row, $pcmembers) { global $Me, $Now, $Profile; $row->sortprefix = ""; $ncol = 0; $t0 = $Profile ? microtime(true) : 0; $t = "<td class=\"s61username\">"; if ($pset->anonymous) { $x = $s->anon_username; } else { $x = $s->seascode_username ?: ($s->huid ?: $s->email); } $t .= "<a href=\"" . hoturl("pset", array("pset" => $pset->urlkey, "u" => $x, "sort" => @$_REQUEST["sort"])) . "\">" . htmlspecialchars($x) . "</a>"; if ($Me->privChair) { $t .= " " . become_user_link($x, Text::name_html($s)); } $t .= "</td>"; ++$ncol; if (!$pset->anonymous) { $t .= "<td>" . Text::name_html($s) . ($s->extension ? " (X)" : "") . "</td>"; ++$ncol; } $t .= "<td>"; if ($s->gradercid) { if (isset($pcmembers[$s->gradercid])) { $t .= htmlspecialchars($pcmembers[$s->gradercid]->firstName); } else { $t .= "???"; } } $t .= "</td>"; ++$ncol; // are any commits committed? if (!$pset->gitless_grades) { if (($s->placeholder || $s->gradehash === null) && $s->repoid && ($s->placeholder_at < $Now - 3600 && rand(0, 2) == 0 || $s->placeholder_at < $Now - 600 && rand(0, 10) == 0) && (!$s->repoviewable || !$s->gradehash)) { // XXX this is slow given that most info is already loaded $info = ContactView::user_pset_info($s, $pset); $info->set_commit(null); $s->gradehash = $info->commit_hash() ?: null; $s->placeholder = 1; Dbl::qe("insert into RepositoryGrade (repoid, pset, gradehash, placeholder, placeholder_at) values (?, ?, ?, 1, ?) on duplicate key update gradehash=(if(placeholder=1,values(gradehash),gradehash)), placeholder_at=values(placeholder_at)", $s->repoid, $pset->id, $s->gradehash, $Now); if (!$s->repoviewable) { $s->repoviewable = $s->can_view_repo_contents($s); } } if (!$s->gradehash || $s->dropped) { $row->sortprefix = "~1 "; } } if (count($pset->grades)) { if ($pset->gitless_grades) { $gi = Contact::contact_grade_for($s, $pset); $gi = $gi ? $gi->notes : null; } else { if ($s->gradehash && !$s->placeholder) { $gi = $Me->commit_info($s->gradehash, $pset); } else { $gi = null; } } if (!$pset->gitless_grades) { $t .= "<td>"; if ($gi && @$gi->linenotes) { $t .= "♪"; } else { if ($Me->contactId == $s->gradercid) { $s->incomplete = true; } } if ($gi && $s->gradercid != @$gi->gradercid && $Me->privChair) { $t .= "<sup>*</sup>"; } $t .= "</td>"; ++$ncol; } $garr = render_grades($pset, $gi, $s); $t .= '<td class="r">' . join('</td><td class="r">', $garr->all) . '</td>'; $ncol += count($garr->all); } //echo "<td><a href=\"mailto:", htmlspecialchars($s->email), "\">", //htmlspecialchars($s->email), "</a></td>"; $t .= "<td>"; if ($s->url) { $t .= $s->repo_link($s->url, "repo"); if (!$s->working) { $t .= ' <strong class="err">broken</strong>'; } else { if (!$s->repoviewable) { $t .= ' <strong class="err">unconfirmed</strong>'; } } if ($s->open) { $t .= ' <strong class="err">open</strong>'; } if ($s->pcid != $s->rpcid || $s->pcid && (!isset($students[$s->pcid]) || $students[$s->pcid]->repoid != $s->repoid)) { $t .= ' <strong class="err">partner</strong>'; } } $t .= "</td>"; ++$ncol; if ($Profile) { $t .= sprintf("<td class=\"r\">%.06f</td>", microtime(true) - $t0); ++$ncol; } if (!@$row->ncol || $ncol > $row->ncol) { $row->ncol = $ncol; } $s->printed = true; return $t; }