forked from science-ation/science-ation
Fix judging registration
This commit is contained in:
parent
f978216b43
commit
c6eaf1089f
@ -80,8 +80,11 @@ switch (get_value_from_array($_GET, 'action')) {
|
||||
$u['flagged_judge'] = '1';
|
||||
}
|
||||
|
||||
user_save($u);
|
||||
questions_save_answers('judgereg', $u['id'], $_POST['questions']);
|
||||
user_save($u);
|
||||
|
||||
if($POST['questions'])
|
||||
questions_save_answers('judgereg', $u['id'], $_POST['questions']);
|
||||
|
||||
happy_('Preferences successfully saved');
|
||||
|
||||
$u = user_load($eid);
|
||||
|
@ -43,7 +43,7 @@ function questions_load_answers($section, $users_id)
|
||||
}
|
||||
|
||||
function questions_load_questions($section, $year)
|
||||
{
|
||||
{
|
||||
global $pdo;
|
||||
$q = $pdo->prepare('SELECT * FROM questions '
|
||||
. "WHERE year='$year' "
|
||||
@ -63,16 +63,20 @@ function questions_load_questions($section, $year)
|
||||
$qs[$r->id]['required'] = $r->required;
|
||||
$qs[$r->id]['question'] = $r->question;
|
||||
}
|
||||
|
||||
return $qs;
|
||||
}
|
||||
|
||||
function questions_save_answers($section, $id, $answers)
|
||||
{
|
||||
global $config, $pdo;
|
||||
|
||||
$qs = questions_load_questions($section, $config['FAIRYEAR']);
|
||||
$keys = array_keys($answers);
|
||||
$q = $pdo->prepare("SELECT * FROM questions WHERE year='{$config['FAIRYEAR']}'");
|
||||
$q->execute();
|
||||
|
||||
|
||||
while ($r = $q->fetch(PDO::FETCH_OBJ)) {
|
||||
$stmt = $pdo->prepare("DELETE FROM question_answers WHERE users_id='$id' AND questions_id='$r->id'");
|
||||
$stmt->execute();
|
||||
@ -109,21 +113,24 @@ function questions_print_answer_editor($section, &$u, $array_name)
|
||||
$ans = questions_load_answers($section, $u['id']);
|
||||
$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"> *</span>' : '';
|
||||
print("<tr>\n");
|
||||
print(" <td colspan=\"2\">$required" . i18n($qs[$qid]['question']) . "</td>\n");
|
||||
print(' <td colspan="2">');
|
||||
$iname = "{$array_name}[{$qid}]";
|
||||
|
||||
switch ($qs[$qid]['type']) {
|
||||
case 'yesno':
|
||||
if ($ans[$qid] == 'yes')
|
||||
if ($ans[$qid]->answer == 'yes')
|
||||
$ch = 'checked="checked"';
|
||||
else
|
||||
$ch = '';
|
||||
print("<input onclick=\"fieldChanged()\" $ch type=\"radio\" name=\"$iname\" value=\"yes\" />" . i18n('Yes'));
|
||||
print(' ');
|
||||
if ($ans[$qid] == 'no')
|
||||
if ($ans[$qid]->answer == 'no')
|
||||
$ch = 'checked="checked"';
|
||||
else
|
||||
$ch = '';
|
||||
@ -135,14 +142,14 @@ function questions_print_answer_editor($section, &$u, $array_name)
|
||||
. "value=\"{$ans[$qid]}\" >\n");
|
||||
break;
|
||||
case 'check':
|
||||
if ($ans[$qid] == 'yes')
|
||||
if ($ans[$qid]->answer == 'yes')
|
||||
$ch = 'checked="checked"';
|
||||
else
|
||||
$ch = '';
|
||||
print("<input $ch type=\"checkbox\" name=\"$iname\" value=\"yes\">\n");
|
||||
break;
|
||||
case 'text':
|
||||
print("<input type=\"text\" name=\"$iname\" value=\"{$ans[$qid]}\">\n");
|
||||
print("<input type=\"text\" name=\"$iname\" value=\"{$ans[$qid]->answer}\">\n");
|
||||
break;
|
||||
}
|
||||
print("</td>\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user