Esempio n. 1
0
}
// TODO implement gathering of these
$excluded_reviewers = [];
// when implemented, this will be a hash table of reviewer => [exclusions]
// make list of users' email addresses
$users = [];
foreach ($USERINVENTORY->get_users() as $u) {
    $users[] = $u->get_email_address();
}
$reviews_per_user = $_GET['num_reviews'];
// prevent greater number of reviews than there are papers to review
if ($reviews_per_user > count($users) - 1) {
    $reviews_per_user = count($users) - 1;
}
// TODO this whole thing should only be operating on people who have submitted papers; check for this when having admin assign reviewers?
$review_pairings = assign_reviewers($users, $reviews_per_user, $excluded_reviewers);
function generate_reviewer_assignment_table($review_list, $user_inv)
{
    function string_of_reviewers($user, $review_list, $user_inv)
    {
        $reviewer_string = '';
        foreach ($review_list[$user->get_email_address()] as $r) {
            $rev_user = $user_inv->get_user_by_email_address($r);
            $reviewer_string = $reviewer_string . $rev_user->get_first_name() . ' ' . $rev_user->get_last_name() . ' (' . $rev_user->get_email_address() . '), ';
        }
        return $reviewer_string;
    }
    $users = $user_inv->get_users();
    $table_string = '';
    $table_string .= "<table>\n" . "  <tr>\n" . "    <td>" . "First name" . "</td>\n" . "    <td>" . "Last name" . "</td>\n" . "    <td>" . "Email address" . "</td>\n" . "    <td>" . "Uploaded paper" . "</td>\n" . "    <td>" . "Reviewers" . "</td>\n" . "  </tr>\n";
    foreach ($users as $u) {
Esempio n. 2
0
function assign_reviewers($users, $reviews_per_user, $excluded_reviewer_list)
{
    // make hash table to keep track of how many reviews each user has been assigned
    $assigned_reviews = [];
    foreach ($users as $u) {
        $assigned_reviews[$u] = 0;
    }
    $authors_and_their_reviewers = [];
    // loop through users and assign n reviewers to each
    foreach ($users as $u) {
        $reviewer_pool = compile_valid_reviewers($u, $users, $excluded_reviewer_list);
        $reviewers_for_user = [];
        // TODO implement this as right kind of object for these pairs
        shuffle($reviewer_pool);
        $i = $reviews_per_user;
        while ($i > 0) {
            $r = array_pop($reviewer_pool);
            // has $reviewer_pool become empty?
            if (isset($r)) {
                if ($assigned_reviews[$r] < $reviews_per_user) {
                    $reviewers_for_user[] = $r;
                    $assigned_reviews[$r]++;
                } else {
                    continue;
                }
                $i--;
            } else {
                // $reviewer_pool is empty, so we can't find a match; recurse until we don't run into this problem
                return assign_reviewers($users, $reviews_per_user, $excluded_reviewer_list);
            }
        }
        $authors_and_their_reviewers[$u] = $reviewers_for_user;
    }
    return $authors_and_their_reviewers;
}