forked from science-ation/science-ation
Fix mentor selection for 0
This commit is contained in:
parent
1b5e267d8b
commit
642e16dd22
@ -39,13 +39,13 @@ if (!($_SESSION['registration_number'] && $_SESSION['registration_id'])) {
|
||||
global $pdo;
|
||||
|
||||
$q = $pdo->prepare('SELECT registrations.id AS regid, students.id AS studentid, students.firstname FROM registrations,students '
|
||||
. "WHERE students.email=?"
|
||||
. "AND registrations.num=?"
|
||||
. "AND registrations.id=?"
|
||||
. 'WHERE students.email=?'
|
||||
. 'AND registrations.num=?'
|
||||
. 'AND registrations.id=?'
|
||||
. 'AND students.registrations_id=registrations.id '
|
||||
. 'AND registrations.year=?'
|
||||
. 'AND students.year=?');
|
||||
$q->execute([$_SESSION['email'],$_SESSION['registration_number'],$_SESSION['registration_id'],$config['FAIRYEAR'],$config['FAIRYEAR']]);
|
||||
$q->execute([$_SESSION['email'], $_SESSION['registration_number'], $_SESSION['registration_id'], $config['FAIRYEAR'], $config['FAIRYEAR']]);
|
||||
show_pdo_errors_if_any($pdo);
|
||||
|
||||
if ($q->rowCount() == 0) {
|
||||
@ -111,10 +111,10 @@ if (get_value_from_array($_GET, 'action') == 'removementor') {
|
||||
echo error(i18n('Cannot make changes to forms once they have been received by the fair'));
|
||||
} else {
|
||||
// first make sure this is one belonging to this registration id
|
||||
$q = $pdo->prepare("SELECT id FROM mentors WHERE id=? AND registrations_id=?");
|
||||
$q = $pdo->prepare('SELECT id FROM mentors WHERE id=? AND registrations_id=?');
|
||||
$q->execute([$_GET['removementor'], $_SESSION['registration_id']]);
|
||||
if ($q->rowCount() == 1) {
|
||||
$stmt = $pdo->prepare("DELETE FROM mentors WHERE id=? AND registrations_id=?");
|
||||
$stmt = $pdo->prepare('DELETE FROM mentors WHERE id=? AND registrations_id=?');
|
||||
$stmt->execute([$_GET['removementor'], $_SESSION['registration_id']]);
|
||||
echo notice(i18n('Mentor successfully removed'));
|
||||
} else {
|
||||
@ -125,17 +125,17 @@ if (get_value_from_array($_GET, 'action') == 'removementor') {
|
||||
|
||||
// now query and display
|
||||
|
||||
$q = $pdo->prepare("SELECT nummentors FROM registrations WHERE id=? AND year=?");
|
||||
$q = $pdo->prepare('SELECT nummentors FROM registrations WHERE id=? AND year=?');
|
||||
$q->execute([$_SESSION['registration_id'], $config['FAIRYEAR']]);
|
||||
$r = $q->fetch(PDO::FETCH_OBJ);
|
||||
$registrations_nummentors = $r->nummentors;
|
||||
|
||||
$q = $pdo->prepare("SELECT * FROM mentors WHERE registrations_id=? AND year=?");
|
||||
$q = $pdo->prepare('SELECT * FROM mentors WHERE registrations_id=? AND year=?');
|
||||
$q->execute([$_SESSION['registration_id'], $config['FAIRYEAR']]);
|
||||
$numfound = $q->rowCount();
|
||||
|
||||
if (isset($_GET['nummentors'])) {
|
||||
$stmt = $pdo->prepare("UPDATE registrations SET nummentors=? WHERE id=?");
|
||||
$stmt = $pdo->prepare('UPDATE registrations SET nummentors=? WHERE id=?');
|
||||
$stmt->execute([$_GET['nummentors'], $_SESSION['registration_id']]);
|
||||
$registrations_nummentors = $_GET['nummentors'];
|
||||
$numtoshow = $_GET['nummentors'];
|
||||
@ -151,28 +151,41 @@ if ($newstatus != 'complete') {
|
||||
echo happy(i18n('Mentor Information Complete'));
|
||||
}
|
||||
|
||||
echo "<p>If a mentor—such as a scientist, parent, or peer—provided guidance, training, or technical support for your project, you must disclose their involvement. Mentors may offer advice, teach techniques, or ensure safety but should not conduct research or analyze data for you. If the work is entirely your own (you had no mentor), please select \"0\"</p>";
|
||||
|
||||
echo '<form name="nummentorsform" method="get" action="register_participants_mentor.php">';
|
||||
echo i18n('Number of mentors that helped with the project: ');
|
||||
echo "<select name=\"nummentors\" onchange=\"document.forms.nummentorsform.submit()\">\n";
|
||||
|
||||
if ($registrations_nummentors === -1 or $registrations_nummentors == null) {
|
||||
if ($registrations_nummentors === -1 || $registrations_nummentors == null) {
|
||||
$sel = 'selected="selected"';
|
||||
} else
|
||||
echo "<option $sel value=\"-1\">" . i18n('Choose') . "</option>\n";
|
||||
|
||||
for ($x = $config['minmentorsperproject']; $x <= $config['maxmentorsperproject']; $x++) {
|
||||
// dont let them go less than the number we found. to go less, they must delete each record individually
|
||||
if ($x < $numfound)
|
||||
continue;
|
||||
|
||||
echo "<option value=\"$x\">$x</option>\n";
|
||||
}
|
||||
} else {
|
||||
$sel = '';
|
||||
echo "<option $sel value=\"-1\">" . i18n('Choose') . "</option>\n";
|
||||
echo "<option $sel value=\"-1\">" . i18n('Choose') . "</option>\n";
|
||||
|
||||
for ($x = $config['minmentorsperproject']; $x <= $config['maxmentorsperproject']; $x++) {
|
||||
// dont let them go less than the number we found. to go less, they must delete each record individually
|
||||
if ($x < $numfound)
|
||||
continue;
|
||||
for ($x = $config['minmentorsperproject']; $x <= $config['maxmentorsperproject']; $x++) {
|
||||
// dont let them go less than the number we found. to go less, they must delete each record individually
|
||||
if ($x < $numfound)
|
||||
continue;
|
||||
|
||||
if ($numtoshow == $x && $registrations_nummentors !== -1)
|
||||
$selected = 'selected="selected"';
|
||||
else
|
||||
$selected = '';
|
||||
if ($numtoshow == $x)
|
||||
$selected = 'selected="selected"';
|
||||
else
|
||||
$selected = '';
|
||||
|
||||
echo "<option $selected value=\"$x\">$x</option>\n";
|
||||
echo "<option $selected value=\"$x\">$x</option>\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo '</select>';
|
||||
echo '</form>';
|
||||
|
||||
@ -182,7 +195,7 @@ for ($x = 1; $x <= $numtoshow; $x++) {
|
||||
$mentorinfo = $q->fetch(PDO::FETCH_OBJ);
|
||||
echo '<h3>' . i18n('Mentor %1 Details', array($x)) . '</h3>';
|
||||
// if we have a valid mentor, set their ID, so we can UPDATE when we submit
|
||||
// if there is no record for this mentor, then set the ID to 0, so we will INSERT when we submit
|
||||
// if there is no record for thismentor, then set the ID to 0, so we will INSERT when we submit
|
||||
if ($mentorinfo->id)
|
||||
$id = $mentorinfo->id;
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user