This is the opening panel which students will access directly.
We presume that it is located in the public_html subdirectory, accessible
via a call such as
open http://www.sp.uconn.edu/~cdavid/Jones.html
where this file has been stored as Jones.html.
Each person who wants records of his/her students access to the system
will have his/her own entry files, for instance, Jones1.html, Jones2.html,
Chemistry127.html, Chem127Sec5.html, etc., etc., etc..
This allows us to pass the owner's name to the system.
This name will be used to keep a file of the student's accesses.
<HTML>
<HEAD>
<title>Prof. Jones Examinations</title>
</HEAD>
<BODY>
<H1>This is the main entry point for Prof. J. Jones' students </H1>
<br>
In order to take an examination or do problems for homework,
you need to (guests are allowed)
<HR>
<A HREF="./cgi-bin/book/home_stuff/final_signin.pl?owner=Jones">sign in HERE!</A>
<hr>
Please address comments directly to me at the following address:
<br>jones@anydept.anyuniversity.edu
<br>
or
<br>Prof. John Jones
<br>Any Department
<br>Any University
<br>Any State
<br>Any phone
<br>Any fax
<br>or<br>
<a href="http://any-electronic-address/send_memo.html">(disabled)Click here to send a message concerning this manuscript.</a><br>
</BODY>
</HTML>
We pass the owner (faculty or course id) as a variable to final_signin.pl
using the argument
<A HREF="./cgi-bin/book/home_stuff/final_signin.pl?owner=Jones">sign in HERE!</A>
which means that we will need to retrieve this value when final_signin.pl
begins running.
Now, here is final_signin.pl:
#!/usr/local/bin/perl -- -*- C -*-
use CGI;
$query = new CGI;
print $query->header;
print $query->start_html('final_signin.pl');
# called via html?owner=Jones
$faculty_id = $query->param('owner');
if($facult_id ne ''){
print "This panel allows access to examinations of Prof. $faculty_id ";}
$SYSROOT = ".";
$SERIAL_BASE = "./";
$SERIAL = "final_signin.dat";
$SERIAL_FILE = $SERIAL_BASE.$SERIAL;
$ICONNDIR = "/~cdavid/A";
# NOTICE that this counter file is not locked.
if(open(SERIAL,"<$SERIAL_FILE")){
if (-s SERIAL){
chop($serialid = <SERIAL>);
$serialid++;
}
else{
$serialid = 1;
}
close(SERIAL);
open(SERIAL,">$SERIAL_FILE");
print(SERIAL "$serialid
");
close(SERIAL);
$serialstring = sprintf("%d",$serialid);
$strlength = length($serialstring);
print "<br>Student/Visitor/Access Number ";
for ($i=0;$i<$strlength;$i++){
$c = substr($serialstring,$i,1);
printf(qq[<img align=bottom src="
$ICONNDIR/%s.gif" ALT = "%s">],$c,$c);
if ((($strlength-$i)%3) == 1
&& ($strlength-$i) > 1){
print ",";
}
}
}
#last_name+first_name+password+counter, where '+' is the delimter
$filename = "students_fall_96.dat";
#now we abandon pseudo FORTRAN/BASIC/etc codes, and do it in Perl fashion
$i = 1;
open ( STUD_FILE , $filename) ;
while(<STUD_FILE>){
chop;
if($_ ne ''){
$line = $_;
$safety_line[$i] = $line;
# print "<br>DEBUG",$i,"->",$safety_line[$i];
$i++;
($last_name,$first_name,$password,$counter) = split(/+/,$line);
if($last_name ne ''){ $id{$last_name} = $password;}
push(@last_name,$last_name);
# print $id($last_name),"
";
}
}
$i--;
$nrec = $i;
close(STUD_FILE);
print $query->start_form;
print $query->hidden('fac',$query->param('owner'));
$faculty_id = $query->param('fac');
#print $query->radio_group('choice_of_login_mode',['from list',
# 'adding new student'],'from list','true');
print $query->scrolling_list('student_list', @last_name);
#if($query->param('sub1')){
$msg = "Student Registration";
print $query->submit('sub1',$msg);
if ($query->param('sub1')) {
$chosen_name = $query->param('student_list');
print "
Enter your password here:",$query->password_field('pswd','',5,8), " and resubmit by pressing `Student Registration' button.";
= CGI=HASH(0x5650b9250670)->param('pswd');
# print "<br>(DEBUG)$chosen_name $entered_passwd , $id{$chosen_name}";
if($entered_passwd eq $id{$chosen_name}){
# print "Got it";
# generate new password
$new_psswd = &make_rno(5);
# report it to student
print "<br>Your password next time will be (note it down): $new_psswd";
$id{$last_name} = $new_psswd;
open ( STUD_FILE , "< $filename")||die"Can't open newfile:$!" ;#open to over-write!
for($j=1;$j<$nrec+1;$j++){
($last_name,$first_name,$password) = split(/+/,$safety_line[$j]);
if ($last_name eq $chosen_name){$password = $new_psswd;
$counter++;};
$new_record = join('+',$last_name,$first_name,$password,$counter);
print STUD_FILE $new_record,"
";
# print "<br>",$j," -<",$new_record;
}
close (STUD_FILE);
# give clickable address for table of contents
$name = "$chosen_name".&make_rno(3);
$faculty_id = $query-<param('fac');
print "<br><a href=main_menu.pl?owner=$faculty_id&name=$name<Entry to Main Menu</a<";
# write new password to student file
}
}
print $query-<end_form;
print "<hr<
";
print $query-<start_form;
print $query-<hidden('fac',$query-<param('owner'));
$faculty_id = $query-<param('fac');
print "This panel allows access to examinations of Prof. $faculty_id as a
new student. ";
print "<br>Last Name = ",$query-<textfield('new_student_last_name','',20,40);
print "First Name = ",$query-<textfield('new_student_first_name','',20,40);
print $query-<submit('sub2','New Student Registration');
if ($query-<param('sub2')){
$new_passwd = &make_rno(5);
print "<br>Your password next time will be (note it down): $new_passwd";
$id{$last_name} = $new_psswd;
$new_name = $query-<param('new_student_last_name');
$new_1name = $query-<param('new_student_first_name');
open ( STUD_FILE , "<<$filename") ;#open to append!
$new_record = join('+',$new_name,$new_1name,$new_passwd,'1');
print STUD_FILE $new_record,"
";
# print "<br>DEBUG",$new_record,"
";
close (STUD_FILE);
$faculty_id = $query-<param('fac');
print "<br><a href=main_menu.pl?owner=$faculty_id&name=$new_name<Entry to Main Menu</a<";
}
print $query-<end_form;
print "<hr<
";
print $query-<start_form;
print $query-<hidden('fac',$query-<param('owner'));
$faculty_id = $query-<param('fac');
print "This panel allows access to examinations of Prof. $faculty_id as a guest. ";
#this is the guest login
print <<EOF;
There are two parts to guest registration, one part (obviously optional)
involves writing in a
guestbook, the second part allows the actual access. I would prefer if you use
the guestbook, but, feel free to do what you like.
No matter what you choose, you need to place something into the box marked `Last Name = ' and you need to press the `Guest Registration' button to continue.
<br>
<a href="book_guestbook.pl"<Please register in the guestbook.</a<<br>
EOF
print "Last Name = ",$query-<textfield('guest_last_name','',20,40);
print $query-<submit('sub3','Guest Registration');
if ($query-<param('sub3')){
if ($query-<param('guest_last_name') ne ''){
print $query-<hidden('fac',$faulty_id);
$name = $query-<param('guest_last_name').'GUEST';
$faculty_id = $query-<param('fac');
print "<br><a href=main_menu.pl?owner=$faculty_id&name=$name<Entry to Main Menu</a<";
}
}
print $query-<end_form;
print $query-<end_html;
#print "password = ",&make_rno(7);
# credit to shelden@spoke.law.cornell.edu
#
#srand;#this initializes the random number generator
# at the outset, while debugging, comment this out
#srand($$|time);#this initializes the random number generator
#$ascii_passwd = &make_rno(5);
#print $ascii_passwd;
sub make_rno{
srand($$|time);#this initializes the random number generator
local(@passset,$rnd_passwd,$randum_num);
local ($randum_num);
#since l = both el and one, do not use
#since 0 = both oh and zero, do not use
@passset = ('a'..'k','m'..'z','A'..'N','P'..'Z','2'..'9');
$rnd_passwd = "";
for ($i = 0; $i<$_[0];$i++){
$randum_num = int(rand($#passset+1));
$rnd_passwd .= @passset[$randum_num];
}
return $rnd_passwd;
}
We have made some slight changes here from earlier versions, so be careful.
First and foremost, we have added a student counter, $counter, which
allows us to keep track of how often this particular student has accessed
the system.
(When there are complaints later, perhaps proving that a student has not done
his homework this way will be useful?)
Once the student (or guest) has successfully traversed this screen,
we allow him/her to access the next screen which might be a set of
examinations or a set of questions.
The organization is to be determined by the faculty user.
#!/usr/local/bin/perl -- -*- C -*-
use CGI;
$query = new CGI;
print $query->header;
print $query->start_html('main_menu_html.pl');
# called via html?owner=Jones&name=dGUEST
$faculty_id = $query->param('owner');
$student_id = $query->param('name');
print "This panel allows access to examinations of Prof. $faculty_id ";
#this is the student whose answers will be recorded
print <