private function result_html()
 {
     global $Conf, $Me, $Qreq, $SSel, $pcsel;
     $assignments = $this->autoassigner->assignments();
     ReviewAssigner::$prefinfo = $this->autoassigner->prefinfo;
     ob_start();
     if (!$assignments) {
         $Conf->warnMsg("Nothing to assign.");
         return ob_get_clean();
     }
     $assignset = new AssignmentSet($Me, true);
     $assignset->parse(join("\n", $assignments));
     list($atypes, $apids) = $assignset->types_and_papers(true);
     $badpairs_inputs = $badpairs_arg = array();
     for ($i = 1; $i <= 20; ++$i) {
         if ($Qreq["bpa{$i}"] && $Qreq["bpb{$i}"]) {
             array_push($badpairs_inputs, Ht::hidden("bpa{$i}", $Qreq["bpa{$i}"]), Ht::hidden("bpb{$i}", $Qreq["bpb{$i}"]));
             $badpairs_arg[] = $Qreq["bpa{$i}"] . "-" . $Qreq["bpb{$i}"];
         }
     }
     echo Ht::form_div(hoturl_post("autoassign", ["saveassignment" => 1, "assigntypes" => join(" ", $atypes), "assignpids" => join(" ", $apids), "xbadpairs" => count($badpairs_arg) ? join(" ", $badpairs_arg) : null, "profile" => $Qreq->profile, "XDEBUG_PROFILE" => $Qreq->XDEBUG_PROFILE, "seed" => $Qreq->seed]));
     $atype = $assignset->type_description();
     echo "<h3>Proposed " . ($atype ? $atype . " " : "") . "assignment</h3>";
     Conf::msg_info("Select “Apply changes” if this looks OK.  (You can always alter the assignment afterwards.)  Reviewer preferences, if any, are shown as “P#”.");
     $assignset->report_errors();
     $assignset->echo_unparse_display();
     // print preference unhappiness
     if ($Qreq->profile && $this->atype_review) {
         $umap = $this->autoassigner->pc_unhappiness();
         sort($umap);
         echo '<p style="font-size:65%">Preference unhappiness: ';
         $usum = 0;
         foreach ($umap as $u) {
             $usum += $u;
         }
         if (count($umap) % 2 == 0) {
             $umedian = ($umap[count($umap) / 2 - 1] + $umap[count($umap) / 2]) / 2;
         } else {
             $umedian = $umap[(count($umap) - 1) / 2];
         }
         echo 'mean ', sprintf("%.2f", $usum / count($umap)), ', min ', $umap[0], ', 10% ', $umap[(int) (count($umap) * 0.1)], ', 25% ', $umap[(int) (count($umap) * 0.25)], ', median ', $umedian, ', 75% ', $umap[(int) (count($umap) * 0.75)], ', 90% ', $umap[(int) (count($umap) * 0.9)], ', max ', $umap[count($umap) - 1], '<br/>Time: ', sprintf("%.6f", microtime(true) - $this->start_at);
         foreach ($this->autoassigner->profile as $name => $time) {
             echo ', ', sprintf("%s %.6f", htmlspecialchars($name), $time);
         }
         echo '</p>';
     }
     echo "<div class='g'></div>", "<div class='aahc'><div class='aa'>\n", Ht::submit("submit", "Apply changes"), "\n&nbsp;", Ht::submit("download", "Download assignment file"), "\n&nbsp;", Ht::submit("cancel", "Cancel"), "\n";
     foreach (array("t", "q", "a", "revtype", "revaddtype", "revpctype", "cleartype", "revct", "revaddct", "revpcct", "pctyp", "balance", "badpairs", "rev_roundtag", "method", "haspap") as $t) {
         if (isset($Qreq[$t])) {
             echo Ht::hidden($t, $Qreq[$t]);
         }
     }
     echo Ht::hidden("pcs", join(" ", array_keys($pcsel))), join("", $badpairs_inputs), Ht::hidden("p", join(" ", $SSel->selection())), "\n";
     // save the assignment
     echo Ht::hidden("assignment", join("\n", $assignments)), "\n";
     echo "</div></div></div></form>";
     return ob_get_clean();
 }
示例#2
0
function requestReviewChecks($themHtml, $reqId)
{
    global $Me, $prow;
    // check for outstanding review request
    $result = Dbl::qe_raw("select reviewId, firstName, lastName, email, password from PaperReview join ContactInfo on (ContactInfo.contactId=PaperReview.requestedBy) where paperId={$prow->paperId} and PaperReview.contactId={$reqId}");
    if (!$result) {
        return false;
    } else {
        if ($row = edb_orow($result)) {
            return Conf::msg_error(Text::user_html($row) . " has already requested a review from {$themHtml}.");
        }
    }
    // check for outstanding refusal to review
    $result = Dbl::qe_raw("select paperId, '<conflict>' from PaperConflict where paperId={$prow->paperId} and contactId={$reqId} union select paperId, reason from PaperReviewRefused where paperId={$prow->paperId} and contactId={$reqId}");
    if (edb_nrows($result) > 0) {
        $row = edb_row($result);
        if ($row[1] === "<conflict>") {
            return Conf::msg_error("{$themHtml} has a conflict registered with paper #{$prow->paperId} and cannot be asked to review it.");
        } else {
            if ($Me->override_deadlines($prow)) {
                Conf::msg_info("Overriding previous refusal to review paper #{$prow->paperId}." . ($row[1] ? "  (Their reason was “" . htmlspecialchars($row[1]) . "”.)" : ""));
                Dbl::qe_raw("delete from PaperReviewRefused where paperId={$prow->paperId} and contactId={$reqId}");
            } else {
                return Conf::msg_error("{$themHtml} refused a previous request to review paper #{$prow->paperId}." . ($row[1] ? " (Their reason was “" . htmlspecialchars($row[1]) . "”.)" : "") . ($Me->allow_administer($prow) ? " As an administrator, you can override this refusal with the “Override...” checkbox." : ""));
            }
        }
    }
    return true;
}
 public function compile_combine_functions(Contact $contact)
 {
     $this->check();
     $state = new FormulaCompiler($contact);
     $this->_parse && $this->_parse->compile_fragments($state);
     $t = self::compile_body($contact, $state, null);
     if (count($state->fragments) == 1) {
         $t .= "  return " . $state->fragments[0] . ";\n";
     } else {
         $t .= "  return [" . join(", ", $state->fragments) . "];\n";
     }
     $args = '$prow, $rrow_cid, $contact, $format = 0, $forceShow = false';
     self::DEBUG && Conf::msg_info(Ht::pre_text("function ({$args}) {\n  // fragments " . simplify_whitespace($this->expression) . "\n  {$t}}\n"));
     $outf = create_function($args, $t);
     // regroup function
     $state->clear();
     $state->combining = 0;
     $expr = $this->_parse ? $this->_parse->compile($state) : "0";
     $t = self::compile_body(null, $state, $expr);
     $args = '$groups, $format = null, $forceShow = false';
     self::DEBUG && Conf::msg_info(Ht::pre_text("function ({$args}) {\n  // combine " . simplify_whitespace($this->expression) . "\n  {$t}}\n"));
     $inf = create_function($args, $t);
     return [$outf, $inf];
 }