Ejemplo n.º 1
0
function saveTagIndexes($tag, $filename, &$settings, &$titles, &$linenos, &$errors)
{
    global $Conf, $Me, $Error;
    $result = $Conf->qe($Conf->paperQuery($Me, array("paperId" => array_keys($settings))));
    while ($row = PaperInfo::fetch($result, $Me)) {
        if ($settings[$row->paperId] !== null && !$Me->can_change_tag($row, $tag, null, 1)) {
            $errors[$linenos[$row->paperId]] = "You cannot rank paper #{$row->paperId}.";
            unset($settings[$row->paperId]);
        } else {
            if ($titles[$row->paperId] !== "" && strcmp($row->title, $titles[$row->paperId]) != 0 && strcasecmp($row->title, simplify_whitespace($titles[$row->paperId])) != 0) {
                $errors[$linenos[$row->paperId]] = "Warning: Title doesn’t match";
            }
        }
    }
    if (!$tag) {
        defappend($Error["tags"], "No tag defined");
    } else {
        if (count($settings)) {
            $x = array("paper,tag,lineno");
            foreach ($settings as $pid => $value) {
                $x[] = "{$pid},{$tag}#" . ($value === null ? "clear" : $value) . "," . $linenos[$pid];
            }
            $assigner = new AssignmentSet($Me);
            $assigner->parse(join("\n", $x) . "\n", $filename);
            $assigner->report_errors();
            $assigner->execute();
        }
    }
    $settings = $titles = $linenos = array();
}
Ejemplo n.º 2
0
     $text = file_get_contents($_FILES["bulk"]["tmp_name"]);
     $filename = $_FILES["bulk"]["name"];
 } else {
     $text = $_POST["bulkentry"];
     $filename = "";
 }
 if ($text === false) {
     Conf::msg_error("Internal error: cannot read file.");
 } else {
     $assignset = new AssignmentSet($Me, false);
     $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;
         }
     }
Ejemplo n.º 3
0
 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();
 }