Beispiel #1
0
function show_regrades($result)
{
    global $Conf, $Me, $Now, $LastPsetFix;
    $rows = $uids = [];
    while ($row = edb_orow($result)) {
        $row->notes = json_decode($row->notes);
        $latest = "";
        $uid = 0;
        foreach (get($row->notes, "flags", []) as $t => $v) {
            if (!get($v, "resolved") && $t > $latest) {
                $latest = $t;
                $uid = get($v, "uid");
            }
        }
        if ($latest) {
            $rows[] = [$latest, $uid, $row];
            $uids[$uid] = true;
        }
    }
    Dbl::free($result);
    if (empty($rows)) {
        return;
    }
    usort($rows, function ($a, $b) {
        return strcmp($a[0], $b[0]);
    });
    $contacts = [];
    $result = $Conf->qe("select * from ContactInfo where contactId?a", array_keys($uids));
    while ($c = Contact::fetch($result, $Conf)) {
        $contacts[$c->contactId] = $c;
    }
    Dbl::free($result);
    echo '<div id="_regrades">';
    echo "<h3>flagged commits</h3>";
    echo '<table class="s61"><tbody>';
    $trn = 0;
    $checkbox = false;
    $sprefix = "";
    $reqsort = req("sort");
    $reqanonymize = req("anonymize");
    $pcmembers = pcMembers();
    foreach ($rows as $rowx) {
        $uid = $rowx[1];
        $row = $rowx[2];
        $u = $contacts[$uid];
        ++$trn;
        echo '<tr class="k', $trn % 2, '">';
        if ($checkbox) {
            echo '<td class="s61checkbox">', Ht::checkbox("s61_" . urlencode($Me->user_idpart($u)), 1, array("class" => "s61check")), '</td>';
        }
        echo '<td class="s61rownumber">', $trn, '.</td>';
        $pset = $Conf->pset_by_id($row->pset);
        echo '<td class="s61pset">', htmlspecialchars($pset->title), '</td>';
        echo '<td class="s61username">', '<a href="', hoturl("pset", ["pset" => $pset->urlkey, "u" => $Me->user_linkpart($u), "commit" => $row->hash, "sort" => $reqsort]), '">', htmlspecialchars($Me->user_linkpart($u)), '</a></td>', '<td class="s61hash"><a href="', hoturl("pset", array("pset" => $pset->urlkey, "u" => $Me->user_linkpart($u), "commit" => $row->hash, "sort" => $reqsort)), '">', substr($row->hash, 0, 7), '</a></td>';
        if (get($row->notes, "gradercid") || $row->main_gradercid) {
            $gcid = get($row->notes, "gradercid") ?: $row->main_gradercid;
            if (isset($pcmembers[$gcid])) {
                echo "<td>" . htmlspecialchars($pcmembers[$gcid]->firstName) . "</td>";
            } else {
                echo "<td>???</td>";
            }
        } else {
            echo "<td></td>";
        }
        echo "<td>";
        if ($row->hash === $row->gradehash) {
            echo "✱";
        }
        if ($row->haslinenotes) {
            echo "♪";
        }
        echo "</td>";
        $total = "";
        if ($row->notes) {
            $garr = render_grades($pset, $row->notes, null);
            if ($garr->totalindex !== null) {
                $total = $garr->all[$garr->totalindex];
            }
        }
        echo '<td class="r">' . $total . '</td>';
        echo '</tr>';
    }
    echo "</tbody></table></div>\n";
}
Beispiel #2
0
function show_regrades($result)
{
    global $Conf, $Me, $Now, $LastPsetFix;
    $rows = array();
    echo '<div id="_regrades">';
    echo "<h3>regrade requests</h3>";
    echo '<table class="s61"><tbody>';
    $trn = 0;
    $checkbox = false;
    $sprefix = "";
    $pcmembers = pcMembers();
    while ($row = edb_orow($result)) {
        ++$trn;
        echo '<tr class="k', $trn % 2, '">';
        if ($checkbox) {
            echo '<td class="s61rownumber">', Ht::checkbox("s61_" . $Me->user_idpart($row->student), 1, array("class" => "s61check")), '</td>';
        }
        echo '<td class="s61rownumber">', $trn, '.</td>';
        $pset = Pset::$all[$row->pset];
        echo '<td class="s61pset">', htmlspecialchars($pset->title), '</td>';
        $row->usernames = explode(" ", $row->usernames);
        sort($row->usernames);
        $x = array();
        foreach ($row->usernames as $u) {
            $x[] = '<a href="' . hoturl("pset", array("pset" => $pset->urlkey, "u" => $u, "commit" => $row->hash, "sort" => @$_REQUEST["sort"])) . '">' . htmlspecialchars($u) . '</a>';
        }
        echo '<td class="s61username">', join(", ", $x), '</td>';
        echo '<td class="s61hash"><a href="', hoturl("pset", array("pset" => $pset->urlkey, "u" => $row->usernames[0], "commit" => $row->hash, "sort" => @$_REQUEST["sort"])), '">', substr($row->hash, 0, 7), '</a></td>';
        if (@$row->gradercid || @$row->main_gradercid) {
            $gcid = @$row->gradercid ?: $row->main_gradercid;
            if (isset($pcmembers[$gcid])) {
                echo "<td>" . htmlspecialchars($pcmembers[$gcid]->firstName) . "</td>";
            } else {
                echo "<td>???</td>";
            }
        } else {
            echo "<td></td>";
        }
        if ($row->haslinenotes) {
            echo "<td>♪</td>";
        } else {
            echo "<td></td>";
        }
        $total = "";
        if ($row->notes) {
            $garr = render_grades($pset, json_decode($row->notes), null);
            if ($garr->totalindex !== null) {
                $total = $garr->all[$garr->totalindex];
            }
        }
        echo '<td class="r">' . $total . '</td>';
        echo '</tr>';
    }
    echo "</tbody></table></div>\n";
}