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 = $pdo->prepare("UPDATE signaturepage SET `use`='$usepa', `text`='" . get_value_from_array($_POST, 'postamble') . "' WHERE name='postamble'");
$stmt->execute(); $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 = $pdo->prepare("UPDATE signaturepage SET `use`='$userf', `text`='' WHERE name='regfee'");
$stmt->execute(); $stmt->execute();
echo happy(i18n("$sentence_begin_participationform text successfully saved")); echo happy(i18n("$sentence_begin_participationform text successfully saved"));

View File

@ -33,7 +33,7 @@ function questions_load_answers($section, $users_id)
$ans = array(); $ans = array();
$qs = questions_load_questions($section, $yearr->year); $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 = $pdo->prepare("SELECT * FROM question_answers WHERE users_id='$users_id' AND questions_id='$id'");
$q->execute(); $q->execute();
$r = $q->fetch(PDO::FETCH_OBJ); $r = $q->fetch(PDO::FETCH_OBJ);
@ -182,12 +182,20 @@ function questions_update_question($qs)
global $pdo; global $pdo;
$qs['ord'] = $qs['ord'] ?? ''; $qs['ord'] = $qs['ord'] ?? '';
$stmt = $pdo->prepare("UPDATE questions SET $stmt = $pdo->prepare("UPDATE questions SET
`question`='" . $qs['question'] . "', `question` = :question,
`type`='" . $qs['type'] . "', `type` = :type,
`db_heading`='" . $qs['db_heading'] . "', `db_heading` = :db_heading,
`required`='" . $qs['required'] . "', `required` = :required,
`ord`=" . intval($qs['ord'] . " `ord` = :ord
WHERE id='{$qs['id']}' ")); 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(); $stmt->execute();
show_pdo_errors_if_any($pdo); show_pdo_errors_if_any($pdo);
} }
@ -275,19 +283,24 @@ function questions_editor($section, $year, $array_name, $self)
while ($r = $q->fetch(PDO::FETCH_OBJ)) { while ($r = $q->fetch(PDO::FETCH_OBJ)) {
$x++; $x++;
$stmt = $pdo->prepare("INSERT INTO questions (id, year, section, db_heading, question, type, required, ord) $stmt = $pdo->prepare("INSERT INTO questions (id, year, section, db_heading, question, type, required, ord)
VALUES ( VALUES (NULL, :year, :section, :db_heading, :question, :type, :required, :ord)");
'', '$year',
'" . $r->section . "',
'" . $r->db_heading . "', $stmt->bindParam(':year', $year);
'" . $r->question . "', $stmt->bindParam(':section', $r->section);
'" . $r->type . "', $stmt->bindParam(':db_heading', $r->db_heading);
'" . $r->required . "', $stmt->bindParam(':question', $r->question);
'" . $r->ord) . "')"; $stmt->bindParam(':type', $r->type);
$stmt->bindParam(':required', $r->required);
$stmt->bindParam(':ord', $r->ord);
$stmt->execute(); $stmt->execute();
} }
echo happy(i18n('%1 question(s) successfully imported', echo happy(i18n(
array($x))); '%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>'; . '<th width=10%>' . i18n('Actions') . '</th></tr>';
$keys = array_keys($qs); $keys = array_keys($qs);
$types = array('check' => i18n('Check box'), $types = array(
'check' => i18n('Check box'),
'yesno' => i18n('Yes/No'), 'yesno' => i18n('Yes/No'),
'text' => i18n('Text'), 'text' => i18n('Text'),
'int' => i18n('Number')); 'int' => i18n('Number')
);
foreach ($keys as $qid) { foreach ($keys as $qid) {
echo "<tr><td>{$qs[$qid]['ord']}</td>"; echo "<tr><td>{$qs[$qid]['ord']}</td>";