prepare('SELECT * FROM judges_timeslots WHERE ' . " year=?" . " AND `type`='divisional1'"); $q->execute([$config['FAIRYEAR']]); if ($q->rowCount()) { $round = $q->fetch(PDO::FETCH_OBJ); $q = $pdo->prepare("SELECT * FROM judges_timeslots WHERE round_id=? AND type='timeslot'"); $q->execute([$round->id]); return $q->rowCount(); } else return 0; } function judges_scheduler_check_timeslots_sa() { global $config, $pdo; $rows = 0; $q = $pdo->prepare('SELECT * FROM judges_timeslots WHERE ' . " year=?" . " AND `type`='special'"); $q->execute([$config['FAIRYEAR']]); if ($q->rowCount()) { while (($round = $q->fetch(PDO::FETCH_OBJ))) { $rq = $pdo->prepare("SELECT * FROM judges_timeslots WHERE round_id=? AND type='timeslot'"); $rq->execute([$round->id]); $rows += $rq->rowCount(); } } return $rows; } function judges_scheduler_check_awards() { global $config, $pdo; $q = $pdo->prepare("SELECT * FROM projectdivisions WHERE year=? ORDER BY id"); $q->execute([$config['FAIRYEAR']]); while ($r = $q->fetch(PDO::FETCH_OBJ)) $div[$r->id] = $r->division; $q = $pdo->prepare("SELECT * FROM projectcategories WHERE year=? ORDER BY id"); $q->execute([$config['FAIRYEAR']]); while ($r = $q->fetch(PDO::FETCH_OBJ)) $cat[$r->id] = $r->category; $dkeys = array_keys($div); $ckeys = array_keys($cat); if ($config['filterdivisionbycategory'] == 'yes') { $q = $pdo->prepare("SELECT * FROM projectcategoriesdivisions_link WHERE year=? ORDER BY projectdivisions_id,projectcategories_id"); $q->execute([$config['FAIRYEAR']]); $divcat = array(); while ($r = $q->fetch(PDO::FETCH_OBJ)) { $divcat[] = array('c' => $r->projectcategories_id, 'd' => $r->projectdivisions_id); } } else { $divcat = array(); foreach ($dkeys AS $d) { foreach ($ckeys AS $c) { $divcat[] = array('c' => $c, 'd' => $d); } } } $missing_awards = array(); foreach ($divcat AS $dc) { $d = $dc['d']; $c = $dc['c']; $q = $pdo->prepare("SELECT award_awards.id FROM award_awards, award_awards_projectcategories, award_awards_projectdivisions WHERE award_awards.year=? AND award_awards_projectcategories.year=? AND award_awards_projectdivisions.year=? AND award_awards.id=award_awards_projectcategories.award_awards_id AND award_awards.id=award_awards_projectdivisions.award_awards_id AND award_awards_projectcategories.projectcategories_id=? AND award_awards_projectdivisions.projectdivisions_id=? AND award_awards.award_types_id='1' "); $q->execute([$config['FAIRYEAR'],$config['FAIRYEAR'],$config['FAIRYEAR'],$c,$d]); show_pdo_errors_if_any($pdo); if ($q->rowCount() != 1) { $missing_awards[] = "{$cat[$c]} - {$div[$d]} (" . i18n('%1 found', array($q->rowCount())) . ')'; } } return $missing_awards; } function judges_scheduler_check_jdivs() { global $config, $pdo; $q = $pdo->prepare('SELECT DISTINCT jdiv_id FROM judges_jdiv '); $q->execute(); $rows = $q->rowCount(); return $rows; } function judges_scheduler_check_judges() { global $config, $pdo; $ok = 1; $jdiv = array(); $projectlanguagetotal = array(); $projecttotal = 0; $q = $pdo->prepare('SELECT * FROM judges_jdiv ORDER BY jdiv_id'); $q->execute(); while ($r = $q->fetch(PDO::FETCH_OBJ)) { /* Ignore any div/cat with jdiv 0 */ if ($r->jdiv_id == 0) continue; $d = $r->projectdivisions_id; $c = $r->projectcategories_id; $l = $r->lang; $qp = $pdo->prepare('SELECT COUNT(projects.id) as cnt FROM projects, registrations WHERE ' . " projects.year=? AND " . " projectdivisions_id=? AND " . " projectcategories_id=? AND " . " language=? AND " . ' registrations.id = projects.registrations_id ' . getJudgingEligibilityCode()); $qp->execute([$config['FAIRYEAR'],$d,$c,$l]); $qr = $qp->fetch(PDO::FETCH_OBJ); // if (get_value_from_3d_array($jdiv, $r->jdiv_id, 'num_projects', 'total') !== null){ $jdiv[$r->jdiv_id]['num_projects']['total'] += $qr->cnt; // } $jdiv[$r->jdiv_id]['num_projects'][$l] += $qr->cnt; $projectlanguagetotal[$l] += $qr->cnt; $projecttotal += $qr->cnt; } $totalteams['total'] = 0; echo '' . '' . ''; echo ''; echo ''; foreach ($config['languages'] AS $lkey => $lname) echo ""; echo ''; foreach ($config['languages'] AS $lkey => $lname) echo ""; echo "\n"; foreach ($jdiv AS $jdiv_id => $jd) { $c = $jd['num_projects']['total']; // total judge teams calculation $t['total'] = ceil($c / $config['max_projects_per_team'] * $config['times_judged']); if ($t['total'] < $config['times_judged'] && $c > 0) $t['total'] = $config['times_judged']; $jdiv[$jdiv_id]['num_jteams']['total'] = $t['total']; $totalteams['total'] += $t['total']; // language teams calculation foreach ($config['languages'] AS $lkey => $lname) { $c = $jd['num_projects'][$lkey]; $t['total_' . $lkey] = ceil($c / $config['max_projects_per_team'] * $config['times_judged']); if ($t['total_' . $lkey] < $config['times_judged'] && $c > 0) $t['total_' . $lkey] = $config['times_judged']; $jdiv[$jdiv_id]['num_jteams']['total_' . $lkey] = $t['total_' . $lkey]; $totalteams['total_' . $lkey] += $t['total_' . $lkey]; } echo ""; echo ""; $langstr = ''; foreach ($config['languages'] AS $lkey => $lname) { $clang = ($jd['num_projects'][$lkey] ? $jd['num_projects'][$lkey] : 0); echo ""; } echo ""; foreach ($config['languages'] AS $lkey => $lname) { $clang = ($jd['num_projects'][$lkey] ? $jd['num_projects'][$lkey] : 0); // echo ""; echo ""; } echo ''; } echo '
' . i18n('Projects') . '' . i18n('Estimated Required Teams') . '
' . i18n('Total') . '$lkey' . i18n('Total') . '$lkey
Judging Division Group $jdiv_id{$jd['num_projects']['total']}$clang{$t['total']}{$t['total']}{$t['total_' . $lkey]}
'; echo '
'; echo ''; echo i18n('Total judging teams required: %1', array($totalteams['total'])); echo '
'; echo '
'; $minjudges['total'] = ($totalteams['total'] * $config['min_judges_per_team']); $maxjudges['total'] = ($totalteams['total'] * $config['max_judges_per_team']); echo i18n('Minimum number of judges required: %1', array($minjudges['total'])) . '
'; foreach ($config['languages'] AS $lkey => $lname) { if ($minjudges['total'] && $projecttotal) $minjudges[$lkey] = round($totalteams['total_' . $lkey] * $config['min_judges_per_team']); // $projectlanguagetotal[$lkey]/$projecttotal*$minjudges['total']); else $minjudges[$lkey] = 0; echo '   ' . i18n('Minimum number of %1 judges required: %2', array($lname, $minjudges[$lkey])) . '
'; } echo i18n('Maximum number of judges needed: %1', array($maxjudges['total'])); echo '
'; echo '
'; /* $jq=mysql_query("SELECT COUNT(judges.id) AS num FROM judges,judges_years WHERE complete='yes' AND deleted='no' AND judges_years.year='{$config['FAIRYEAR']}' AND judges_years.judges_id=judges.id"); $jr=mysql_fetch_object($jq); $currentjudges=$jr->num;*/ /* FIXME: this his highly inefficient :), but won't be done very often */ $judges = judges_load_all(); $currentjudges = count($judges); echo "Current number of registered judges: $currentjudges"; echo '
'; echo '
'; if ($currentjudges < $minjudges['total']) { echo error(i18n('You do not have sufficient number of total judges based on your parameters')); $ok = false; } foreach ($config['languages'] AS $lkey => $lname) { $lcount = 0; foreach ($judges AS $j) { foreach ($j['languages'] AS $jlang) { if ($jlang == $lkey) $lcount++; } } $currentjudges = $lcount; echo '  ' . i18n('Current number of registered judges that can judge in %1: %2', array($lname, $currentjudges)) . ''; echo '
'; if ($currentjudges < $minjudges[$lkey]) { echo error(i18n('You do not have sufficient number of %1 judges based on your parameters', array($lname))); $ok = false; } } if (!$ok) { echo '  '; echo '' . i18n('Update Scheduler Configuration') . ' (' . i18n('or get more judges!') . ')'; } else echo happy(i18n('You have a sufficient number of judges based on your parameters')); // now check if we can find a divisional award for each division and category return $ok; } ?>