forked from science-ation/science-ation
Made the "Judge Registration Questions" page functional
This commit is contained in:
parent
db3819d11d
commit
e77fc688f0
@ -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"));
|
||||||
|
@ -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);
|
||||||
@ -111,9 +111,9 @@ function questions_print_answer_editor($section, &$u, $array_name)
|
|||||||
$keys = array_keys($qs);
|
$keys = array_keys($qs);
|
||||||
foreach ($keys as $qid) {
|
foreach ($keys as $qid) {
|
||||||
$required = $qs[$qid]['required'] == 'yes' ? '<span class="requiredfield" style="float:right"> *</span>' : '';
|
$required = $qs[$qid]['required'] == 'yes' ? '<span class="requiredfield" style="float:right"> *</span>' : '';
|
||||||
print ("<tr>\n");
|
print("<tr>\n");
|
||||||
print (" <td colspan=\"2\">$required" . i18n($qs[$qid]['question']) . "</td>\n");
|
print(" <td colspan=\"2\">$required" . i18n($qs[$qid]['question']) . "</td>\n");
|
||||||
print (' <td colspan="2">');
|
print(' <td colspan="2">');
|
||||||
$iname = "{$array_name}[{$qid}]";
|
$iname = "{$array_name}[{$qid}]";
|
||||||
switch ($qs[$qid]['type']) {
|
switch ($qs[$qid]['type']) {
|
||||||
case 'yesno':
|
case 'yesno':
|
||||||
@ -121,16 +121,16 @@ function questions_print_answer_editor($section, &$u, $array_name)
|
|||||||
$ch = 'checked="checked"';
|
$ch = 'checked="checked"';
|
||||||
else
|
else
|
||||||
$ch = '';
|
$ch = '';
|
||||||
print ("<input onclick=\"fieldChanged()\" $ch type=\"radio\" name=\"$iname\" value=\"yes\" />" . i18n('Yes'));
|
print("<input onclick=\"fieldChanged()\" $ch type=\"radio\" name=\"$iname\" value=\"yes\" />" . i18n('Yes'));
|
||||||
print (' ');
|
print(' ');
|
||||||
if ($ans[$qid] == 'no')
|
if ($ans[$qid] == 'no')
|
||||||
$ch = 'checked="checked"';
|
$ch = 'checked="checked"';
|
||||||
else
|
else
|
||||||
$ch = '';
|
$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;
|
break;
|
||||||
case 'int':
|
case 'int':
|
||||||
print ('<input onclick="fieldChanged()" type="text" '
|
print('<input onclick="fieldChanged()" type="text" '
|
||||||
. "name=\"$iname\" size=10 maxlen=11 "
|
. "name=\"$iname\" size=10 maxlen=11 "
|
||||||
. "value=\"{$ans[$qid]}\" >\n");
|
. "value=\"{$ans[$qid]}\" >\n");
|
||||||
break;
|
break;
|
||||||
@ -139,14 +139,14 @@ function questions_print_answer_editor($section, &$u, $array_name)
|
|||||||
$ch = 'checked="checked"';
|
$ch = 'checked="checked"';
|
||||||
else
|
else
|
||||||
$ch = '';
|
$ch = '';
|
||||||
print ("<input $ch type=\"checkbox\" name=\"$iname\" value=\"yes\">\n");
|
print("<input $ch type=\"checkbox\" name=\"$iname\" value=\"yes\">\n");
|
||||||
break;
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
print ("<input type=\"text\" name=\"$iname\" value=\"{$ans[$qid]}\">\n");
|
print("<input type=\"text\" name=\"$iname\" value=\"{$ans[$qid]}\">\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
print ("</td>\n");
|
print("</td>\n");
|
||||||
print ("</tr>\n");
|
print("</tr>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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);
|
||||||
}
|
}
|
||||||
@ -274,20 +282,25 @@ function questions_editor($section, $year, $array_name, $self)
|
|||||||
$q->execute();
|
$q->execute();
|
||||||
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>";
|
||||||
@ -483,10 +498,10 @@ function questions_editor($section, $year, $array_name, $self)
|
|||||||
if (count($keys) == 0) {
|
if (count($keys) == 0) {
|
||||||
$default_qs = questions_load_questions($section, -1);
|
$default_qs = questions_load_questions($section, -1);
|
||||||
if (count($default_qs) != 0) {
|
if (count($default_qs) != 0) {
|
||||||
print ('<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(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('<br>');
|
||||||
print ("<a title=\"Import\" href=\"$self?action=import&impyear=-1\">" . i18n('Import default questions') . '</a><br>');
|
print("<a title=\"Import\" href=\"$self?action=import&impyear=-1\">" . i18n('Import default questions') . '</a><br>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user