Made the "Judge Registration Questions" page functional

This commit is contained in:
arman 2025-02-03 01:04:45 +00:00
parent db3819d11d
commit e77fc688f0
2 changed files with 55 additions and 35 deletions

View File

@ -68,6 +68,11 @@ if (get_value_from_array($_POST, 'action') == 'save') {
$stmt = $pdo->prepare("UPDATE signaturepage SET `use`='$usepa', `text`='" . get_value_from_array($_POST, 'postamble') . "' WHERE name='postamble'");
$stmt->execute();
echo $_POST['useteacherdeclaration'];
$stmt = $pdo->prepare("UPDATE signaturepage SET `use`='$usete', `text`='" . get_value_from_array($_POST, 'useteacherdeclaration') . "' WHERE name='useteacherdeclaration'");
$stmt->execute();
$stmt = $pdo->prepare("UPDATE signaturepage SET `use`='$userf', `text`='' WHERE name='regfee'");
$stmt->execute();
echo happy(i18n("$sentence_begin_participationform text successfully saved"));

View File

@ -33,7 +33,7 @@ function questions_load_answers($section, $users_id)
$ans = array();
$qs = questions_load_questions($section, $yearr->year);
foreach ($qs AS $id => $question) {
foreach ($qs as $id => $question) {
$q = $pdo->prepare("SELECT * FROM question_answers WHERE users_id='$users_id' AND questions_id='$id'");
$q->execute();
$r = $q->fetch(PDO::FETCH_OBJ);
@ -111,9 +111,9 @@ function questions_print_answer_editor($section, &$u, $array_name)
$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\">$required" . i18n($qs[$qid]['question']) . "</td>\n");
print (' <td colspan="2">');
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':
@ -121,16 +121,16 @@ function questions_print_answer_editor($section, &$u, $array_name)
$ch = 'checked="checked"';
else
$ch = '';
print ("<input onclick=\"fieldChanged()\" $ch type=\"radio\" name=\"$iname\" value=\"yes\" />" . i18n('Yes'));
print ('&nbsp; &nbsp; ');
print("<input onclick=\"fieldChanged()\" $ch type=\"radio\" name=\"$iname\" value=\"yes\" />" . i18n('Yes'));
print('&nbsp; &nbsp; ');
if ($ans[$qid] == 'no')
$ch = 'checked="checked"';
else
$ch = '';
print ("<input onclick=\"fieldChanged()\" $ch type=\"radio\" name=\"$iname\" value=\"no\" />" . i18n('No'));
print("<input onclick=\"fieldChanged()\" $ch type=\"radio\" name=\"$iname\" value=\"no\" />" . i18n('No'));
break;
case 'int':
print ('<input onclick="fieldChanged()" type="text" '
print('<input onclick="fieldChanged()" type="text" '
. "name=\"$iname\" size=10 maxlen=11 "
. "value=\"{$ans[$qid]}\" >\n");
break;
@ -139,14 +139,14 @@ function questions_print_answer_editor($section, &$u, $array_name)
$ch = 'checked="checked"';
else
$ch = '';
print ("<input $ch type=\"checkbox\" name=\"$iname\" value=\"yes\">\n");
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]}\">\n");
break;
}
print ("</td>\n");
print ("</tr>\n");
print("</td>\n");
print("</tr>\n");
}
}
@ -182,12 +182,20 @@ function questions_update_question($qs)
global $pdo;
$qs['ord'] = $qs['ord'] ?? '';
$stmt = $pdo->prepare("UPDATE questions SET
`question`='" . $qs['question'] . "',
`type`='" . $qs['type'] . "',
`db_heading`='" . $qs['db_heading'] . "',
`required`='" . $qs['required'] . "',
`ord`=" . intval($qs['ord'] . "
WHERE id='{$qs['id']}' "));
`question` = :question,
`type` = :type,
`db_heading` = :db_heading,
`required` = :required,
`ord` = :ord
WHERE id = :id");
$stmt->bindValue(':question', $qs['question']);
$stmt->bindValue(':type', $qs['type']);
$stmt->bindValue(':db_heading', $qs['db_heading']);
$stmt->bindValue(':required', $qs['required']);
$stmt->bindValue(':ord', intval($qs['ord']));
$stmt->bindValue(':id', $qs['id']);
$stmt->execute();
show_pdo_errors_if_any($pdo);
}
@ -274,20 +282,25 @@ function questions_editor($section, $year, $array_name, $self)
$q->execute();
while ($r = $q->fetch(PDO::FETCH_OBJ)) {
$x++;
$stmt = $pdo->prepare("INSERT INTO questions (id,year,section,db_heading,question,type,required,ord)
VALUES (
'', '$year',
'" . $r->section . "',
'" . $r->db_heading . "',
'" . $r->question . "',
'" . $r->type . "',
'" . $r->required . "',
'" . $r->ord) . "')";
$stmt = $pdo->prepare("INSERT INTO questions (id, year, section, db_heading, question, type, required, ord)
VALUES (NULL, :year, :section, :db_heading, :question, :type, :required, :ord)");
$stmt->bindParam(':year', $year);
$stmt->bindParam(':section', $r->section);
$stmt->bindParam(':db_heading', $r->db_heading);
$stmt->bindParam(':question', $r->question);
$stmt->bindParam(':type', $r->type);
$stmt->bindParam(':required', $r->required);
$stmt->bindParam(':ord', $r->ord);
$stmt->execute();
}
echo happy(i18n('%1 question(s) successfully imported',
array($x)));
echo happy(i18n(
'%1 question(s) successfully imported',
array($x)
));
}
/*
@ -455,10 +468,12 @@ function questions_editor($section, $year, $array_name, $self)
. '<th width=10%>' . i18n('Actions') . '</th></tr>';
$keys = array_keys($qs);
$types = array('check' => i18n('Check box'),
$types = array(
'check' => i18n('Check box'),
'yesno' => i18n('Yes/No'),
'text' => i18n('Text'),
'int' => i18n('Number'));
'int' => i18n('Number')
);
foreach ($keys as $qid) {
echo "<tr><td>{$qs[$qid]['ord']}</td>";
@ -483,10 +498,10 @@ function questions_editor($section, $year, $array_name, $self)
if (count($keys) == 0) {
$default_qs = questions_load_questions($section, -1);
if (count($default_qs) != 0) {
print ('<br>');
print (i18n('There are no questions for year %1, but there are %2 default questions. To import the default questions to year %1 click on the link below.', array($year, count($default_qs))));
print ('<br>');
print ("<a title=\"Import\" href=\"$self?action=import&amp;impyear=-1\">" . i18n('Import default questions') . '</a><br>');
print('<br>');
print(i18n('There are no questions for year %1, but there are %2 default questions. To import the default questions to year %1 click on the link below.', array($year, count($default_qs))));
print('<br>');
print("<a title=\"Import\" href=\"$self?action=import&amp;impyear=-1\">" . i18n('Import default questions') . '</a><br>');
}
}
}