function collect_pset_info(&$students, $pset, $where, $entries, $nonanonymous) { global $Conf, $Me; $result = $Conf->qe_raw("select c.contactId, c.firstName, c.lastName, c.email,\n\tc.huid, c.anon_username, c.seascode_username, c.github_username, c.extension,\n\tr.repoid, r.url, r.open, r.working, r.lastpset,\n\trg.gradehash, rg.gradercid\n\tfrom ContactInfo c\n\tleft join ContactLink l on (l.cid=c.contactId and l.type=" . LINK_REPO . " and l.pset={$pset->id})\n\tleft join Repository r on (r.repoid=l.link)\n\tleft join RepositoryGrade rg on (rg.repoid=r.repoid and rg.pset={$pset->id} and not rg.placeholder)\n\twhere ({$where})\n\tand (rg.repoid is not null or not c.dropped)\n\tgroup by c.contactId"); $sort = $Qreq->sort; while ($s = edb_orow($result)) { $s->is_anonymous = $pset->anonymous && !$nonanonymous; $username = $s->is_anonymous ? $s->anon_username : ($s->github_username ?: $s->seascode_username); Contact::set_sorter($s, $sort); $ss = get($students, $username); if (!$ss && $s->is_anonymous) { $students[$username] = $ss = (object) array("username" => $username, "extension" => $s->extension ? "Y" : "N", "sorter" => $username); } else { if (!$ss) { $students[$username] = $ss = (object) array("name" => trim("{$s->lastName}, {$s->firstName}"), "email" => $s->email, "username" => $username, "huid" => $s->huid, "extension" => $s->extension ? "Y" : "N", "sorter" => $s->sorter); } } $gi = null; if ($pset->gitless_grades) { $gi = $pset->contact_grade_for($s); } else { if (get($s, "gradehash")) { $gi = $pset->commit_notes($s->gradehash); } else { continue; } } $gi = $gi ? $gi->notes : null; $gd = ContactView::pset_grade($gi, $pset); if ($gd) { $k = $pset->psetkey; $ss->{$k} = $gd->total; $k .= "_noextra"; $ss->{$k} = $gd->total_noextra; if ($k = $pset->group) { $ss->{$k} = get_f($ss, $k) + $gd->total; $k .= "_noextra"; $ss->{$k} = get_f($ss, $k) + $gd->total_noextra; } if ($entries) { foreach ($pset->grades as $ge) { $k = $ge->name; if (get($gd, $k) !== null) { $ss->{$k} = $gd->{$k}; } } } } } Dbl::free($result); }
} else { $notdropped = "not c.dropped"; } $q = "select cn.notes, c.extension from ContactInfo c\n"; if ($Pset->gitless_grades) { $q .= "\t\tjoin ContactGrade cn on (cn.cid=c.contactId and cn.pset={$Pset->psetid})"; } else { $q .= "\t\tjoin ContactLink l on (l.cid=c.contactId and l.type=" . LINK_REPO . " and l.pset={$Pset->id})\n\t\tjoin RepositoryGrade rg on (rg.repoid=l.link and rg.pset={$Pset->id} and not rg.placeholder)\n\t\tjoin CommitNotes cn on (cn.hash=rg.gradehash and cn.pset=rg.pset)\n"; } $result = $Conf->qe_raw($q . " where {$notdropped}"); $series = new Series(); $xseries = new Series(); $noextra_series = $Pset->has_extra ? new Series() : null; $has_extra = false; while ($row = edb_row($result)) { if ($g = ContactView::pset_grade(json_decode($row[0]), $Pset)) { $series->add($g->total); if ($row[1]) { $xseries->add($g->total); } if ($noextra_series) { $noextra_series->add($g->total_noextra); if ($g->total_noextra != $g->total) { $has_extra = true; } } } } $r = $series->summary(); if ($xseries->n) { $r->extension = $xseries->summary();