#! /usr/local/bin/perl -- ######################################################################## # qa-ann.pl Version 4.1 January 22, 1997 # Copyright (c) 1996-1997 Matthew J. Walker # Written for the UCLA Virtual Office Hours Project # Code can be freely distributed for educational use, as long as header # remains intact. See included Copyright and Licensing information. # For info send email to voh@chem.ucla.edu # # Edit this file, replacing "/" with ":" for Mac in paths ######################################################################## require 'voh-lib.pl'; &SetupVOH; $file_number = 0 ; # initial value $lecture_path ="$root_path/$in{lecture}"; $qa_file_name = "$lecture_path/qa.html"; $announcement_file ="$lecture_path/announcements.html"; if ($in{request}) { # coming from qaarf.html ($in{request} eq "announcement") && (&CreateAnnForm); #announcement? ($in{verification} !~ /$verification_string/) && (&Failure(24)); &GetQuestion ; &CreateAnswerForm("None"); } elsif ($in{question_file}) { # coming from qa form if ($in{killit} eq "killit") { # delete the question? if (-e "$questions_path/$in{question_file}") { unlink "$questions_path/$in{question_file}"; } $file_number = $in{file_number} ; &GetQuestion; &CreateAnswerForm("Deleted"); } elsif ($in{skip} eq "skip") { # skip the question? $file_number = ++$in{file_number} ; &GetQuestion; &CreateAnswerForm("Skipped"); } else { # answer the question. unless ($in{answer}) { &Failure(04) ;} &WriteFile(Question_Answer); if (-e "$questions_path/$in{question_file}") { unlink "$questions_path/$in{question_file}"; } $file_number = $in{file_number} ; &GetQuestion; &CreateAnswerForm("Answered Successfully"); } } elsif ($in{announcement}) { # coming from announcement form &WriteFile(Announcement); $success = "Announcement Posted Successfully"; &Success; } else { # shouldn't get here, but... &Failure(07) ; } # CreateAnswerForm # Generates Question Answer Form and sends it to the client # The HTML Generated by this subroutine will need to be edited to # reflect the content of your site! sub CreateAnswerForm { local($html); $html = <<"EOC"; $HTTP_header