#!/usr/local/bin/perl -- -*-perl-*- use CGI; $query = new CGI; print $query->header; print $query->start_html('Prototype Question_4-Logging&Commenting'); require "CleanUp.pl"; require "explain.pl"; require "count.pl"; require "reports.pl"; srand; $scriptname = $query->script_name();#this gives the question name #print $query->dump;#use this to check that it worked! Just remove comment(#). print "Anonymous access to the <a href=test_send_memo.pl?var=$scriptname>webmaster to send a message concerning errors in this question</a> is available here.<br>"; # this question was called via html?owner=Jones&name=SomeOne #$faculty_id = $query->param('faculty'); #$student_id = $query->param('student'); #print "<br>FACULTY(owner) = ",$query->param('owner'),", STUDENT(owner) = ",$query->param('name'),"<br>"; print "<a href=http://mmedia.ucc.uconn.edu/~cdavid//notation/notation.html>Click here to get a notation explanation</a>"; #print $query->dump; print "<hr>"; &count($scriptname); print "<hr>"; print $query->start_form; print $query->hidden('faculty',$query->param('owner')); print $query->hidden('student',$query->param('name')); #print $query->dump; $faculty_id = $query->param('faculty'); $student_id = $query->param('student'); print <<EOF; This is teacher created text concerning this particular question. Without explicit print statements, it must be entered using a special format. EOF print "<br>Answer = ",$query->textfield('ans','',50,80); print"<P> Query, is the above formula/number correct?",$query->submit; print $query->end_form; print "<hr>"; print $query->start_form; print $query->hidden('faculty',$query->param('owner')); print $query->hidden('student',$query->param('name')); #print $query->dump; $faculty_id = $query->param('faculty'); $student_id = $query->param('student'); print "If you wish to comment to your <em>instructor</em> about this question, assumptions you are making, inconsistencies in the phraseology of the question, objections to the question, etc., etc., etc., you may use this space for that purpose."; print "Nothing entered here will go to the webmaster, instead, it will go to your instructor!"; print $query->textarea('comments','',10,60); print "<br>"; print $query->submit('Submit2','Send the comment'); print $query->reset; print $query->end_form; if ($query->param('comments') ne '') { open (FACULTY,">>/home/cdavid/public_html/Master_teacher.dat")||die print "<br> Master_teacher.dat, Faculty File Troubles Encountered, please report to instructor"; $comments = $query->param('comments'); print FACULTY "<",$faculty_id,">,<",$student_id,">, comments=",$comments," "; close(FACULTY); } if ( $query->param('ans') ne '') { $faculty_id = $query->param('faculty'); $student_id = $query->param('student'); #print $query->dump; #print "<br>student_id = ",$student_id; $stu_ans = $query->param('ans'); $saved_stu_ans = $stu_ans; &CleanUp($stu_ans);#this removes potential hacker imbedded illegal commands $ans = "sqrt(4/x)"; $saved_ans = $ans; $x = rand; $ans =~s/x/$x/gi; $stu_ans =~s/x/$x/gi; print "student_answer = $saved_stu_ans"; $stu_ans = eval($stu_ans); $ans = eval($ans); #print "student_answer = $stu_ans <p>"; #print "student_answer evaluated = $stu_ans<p>"; #print "answer evaluated = $ans <p>"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); if (eval (($stu_ans - $ans)**2 - 0.0001 ) ge 0.0 ) { &reportstudent($faculty_id,$student_id,$saved_stu_ans,$saved_ans,$scriptname); &reportfaculty($faculty_id,$student_id,$saved_stu_ans,$saved_ans,$scriptname); print ", <EM> Wrong</EM>, <IMG SRC=../icons/checkno.gif>"} else {print ", <EM> Right! </EM>, <IMG SRC=../icons/check.gif>" ; &reportfaculty_right($faculty_id,$student_id,$saved_stu_ans,$saved_ans,$scriptname); print "<a href=proto_4_h.pl>Help is available for this question<br></a>"; } }; print $query->end_html;To try this out, click here and then look at `Master_teacher.dat' in the public_html directory. In this example, the question is being called with a teacher name = `Teacher_name' and a student name = `Student_name', and you will see in `Master_teacher.dat' that whatever message you entered is recorded there, and whatever answer you gave is recorded there, with the appropriate identifiers.
One last thing, we have added a help call for the wrong answer section, so that students always have the ability to ask for help if they get a question wrong. Commenting out this call will prevent it, but it is better to have it in the prototype than not (to have it).