$defaults = assignment_defaults();
        $text = convert_to_utf8($text);
        $assignset->parse($text, $filename, $defaults, "keep_browser_alive");
        finish_browser_alive();
        if ($assignset->has_errors()) {
            $assignset->report_errors();
        } else {
            if ($assignset->is_empty()) {
                $Conf->warnMsg("That assignment file makes no changes.");
            } else {
                $atype = $assignset->type_description();
                echo '<h3>Proposed ', $atype ? $atype . " " : "", 'assignment</h3>';
                $Conf->infoMsg("Select “Apply changes” if this looks OK. (You can always alter the assignment afterwards.)");
                list($atypes, $apids) = $assignset->types_and_papers(true);
                echo Ht::form_div(hoturl_post("bulkassign", ["saveassignment" => 1, "assigntypes" => join(" ", $atypes), "assignpids" => join(" ", $apids)]));
                $assignset->echo_unparse_display();
                echo '<div class="g"></div>', '<div class="aahc"><div class="aa">', Ht::submit("Apply changes"), ' &nbsp;', Ht::submit("cancel", "Cancel"), Ht::hidden("default_action", $defaults["action"]), Ht::hidden("rev_roundtag", $defaults["round"]), Ht::hidden("file", $text), Ht::hidden("assignment_size_estimate", $csv_lineno), Ht::hidden("filename", $filename), Ht::hidden("requestreview_notify", req("requestreview_notify")), Ht::hidden("requestreview_subject", req("requestreview_subject")), Ht::hidden("requestreview_body", req("requestreview_body")), Ht::hidden("bulkentry", req("bulkentry")), '</div></div></div></form>', "\n";
                $Conf->footer();
                exit;
            }
        }
    }
}
if (isset($_REQUEST["saveassignment"]) && check_post() && isset($_POST["file"]) && get($_POST, "assignment_size_estimate") >= 1000) {
    complete_assignment("keep_browser_alive");
    finish_browser_alive();
}
echo Ht::form_div(hoturl_post("bulkassign", "upload=1"), array("divstyle" => "margin-top:1em"));
// Upload
echo '<div class="f-contain"><div class="f-i"><div class="f-e">', Ht::textarea("bulkentry", req_s("bulkentry"), ["rows" => 1, "cols" => 80, "placeholder" => "Enter assignments"]), '</div></div></div>';
echo '<div class="g"><strong>OR</strong> &nbsp;', '<input type="file" name="bulk" accept="text/plain,text/csv" size="30" /></div>';
 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();
 }