Skip to content

Commit

Permalink
Student manual enrolment now allows enter to submit search and
Browse files Browse the repository at this point in the history
autofocusses search input
  • Loading branch information
moodler committed Aug 5, 2004
1 parent fdfefb6 commit bbcef61
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
12 changes: 9 additions & 3 deletions course/student.html
@@ -1,14 +1,15 @@

<form name="studentform" id="studentform" method="post" action="student.php">
<input type="hidden" name="previoussearch" value="<?php echo $previoussearch ?>">
<input type="hidden" name="id" value="<?php echo $id?>">
<table align="center" border="0" cellpadding="5" cellspacing="0">
<tr>
<td valign="top">
<?php p($strexistingstudents) ?>
<?php echo count($students) . " ". $strexistingstudents ?>
</td>
<td></td>
<td valign="top">
<?php p($strpotentialstudents) ?>
<?php echo $usercount . " " . $strpotentialstudents ?>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -57,7 +58,12 @@
onFocus ="document.studentform.add.disabled=true;
document.studentform.remove.disabled=true;
document.studentform.removeselect.selectedIndex=-1;
document.studentform.addselect.selectedIndex=-1;">
document.studentform.addselect.selectedIndex=-1;"
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
if (keyCode == 13) {
document.studentform.previoussearch.value=1;
document.studentform.submit();
} " />
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>" />
<?php
if (!empty($searchusers)) {
Expand Down
27 changes: 14 additions & 13 deletions course/student.php
Expand Up @@ -86,10 +86,11 @@
}
} else if (!empty($frm->showall)) {
unset($frm->searchtext);
$frm->previoussearch = 0;
}

}

$previoussearch = (!empty($frm->search) or ($frm->previoussearch == 1)) ;

/// Get all existing students for this course.
if (!$students = get_course_students($course->id, "u.firstname ASC, u.lastname ASC", "", 0, 99999,
Expand All @@ -102,31 +103,31 @@
$studentarray[] = $student->id;
}
$studentlist = implode(',', $studentarray);

unset($studentarray);


/// Get search results excluding any users already in this course
if (!empty($frm->searchtext)) {
if ($searchusers = get_users(true, $frm->searchtext, true, $studentlist, 'firstname ASC, lastname ASC',
'', '', 0, 99999, 'id, firstname, lastname, email')) {
foreach ($searchusers as $student) {
$studentarray[] = $student->id;
}
$studentlist = implode(',', $studentarray);
}
if (!empty($frm->searchtext) and $previoussearch) {
$searchusers = get_users(true, $frm->searchtext, true, $studentlist, 'firstname ASC, lastname ASC',
'', '', 0, 99999, 'id, firstname, lastname, email');
$usercount = get_users(false, '', true, $studentlist);
}

unset($studentarray);

/// Get potential students for this course excluding users already in course or
/// users in the search results
/// If no search results then get potential students for this course excluding users already in course
if (empty($searchusers)) {
if (!$users = get_users(true, '', true, $studentlist, 'firstname ASC, lastname ASC', '', '',
0, 99999, 'id, firstname, lastname, email') ) {
$users = array();
}
$usercount = count($users);
}




$searchtext = (isset($frm->searchtext)) ? $frm->searchtext : "";
$previoussearch = ($previoussearch) ? '1' : '0';

print_simple_box_start("center", "", "$THEME->cellheading");

Expand Down

0 comments on commit bbcef61

Please sign in to comment.