Added checking for required custom questions being answered on the Judge "other information" forms.

Also added asterisks to mark the required custom questions as such.
This commit is contained in:
james 2013-03-05 22:10:50 +00:00
parent 7d77c47614
commit 529491456c
2 changed files with 22 additions and 3 deletions

View File

@ -64,11 +64,29 @@ function judge_status_other(&$u)
/* They must select a language to judge in */
if(count($u['languages']) < 1) return 'incomplete';
return 'complete';
return judge_status_questions($u);
}
function judge_status_questions($u){
/* Logic:
- count the number of required questions and get their id's.
- count the questions answered by the user which match those id's
- if those counts are not the same, then the user has not answered all required questions
*/
global $config;
// get the questions we're looking for
$q = mysql_query("SELECT id FROM questions WHERE year=" . $config['FAIRYEAR'] . " AND required='yes'");
$idList = array();
while($row = mysql_fetch_assoc($q)) $idList[] = $row['id'];
$rval = 'complete';
if(count($idList)){
$q = mysql_query("SELECT COUNT(*) AS tally FROM question_answers WHERE questions_id IN(" . implode(',', $idList) . ") AND users_id=" . $u['id'] . " AND answer IS NOT NULL");
$row = mysql_fetch_assoc($q);
if(intval($row['tally']) != count($idList)) $rval = 'incomplete';
}
return $rval;
}
function judge_status_special_awards(&$u)
{

View File

@ -100,8 +100,9 @@ function questions_print_answer_editor($section, &$u, $array_name)
$qs = questions_load_questions($section, $u['year']);
$keys = array_keys($qs);
foreach($keys as $qid) {
$required = $qs[$qid]['required'] == 'yes' ? '<span class="requiredfield" style="float:right">&nbsp;*</span>' : '';
print("<tr>\n");
print(" <td colspan=\"2\">".i18n($qs[$qid]['question'])."</td>\n");
print(" <td colspan=\"2\">$required".i18n($qs[$qid]['question'])."</td>\n");
print(" <td colspan=\"2\">");
$iname = "{$array_name}[{$qid}]";
switch($qs[$qid]['type']) {