#!/usr/ucb/perl
#
# Ryan J. Shaltry
# tech4@msue.msu.edu
# Guy Albertelli
# albertel@msu.edu
#
# CAPA Discussion Forum
# version 1.3.0
# Copyright (C) 1992-2000 Michigan State University
#
# The CAPA system is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# The CAPA system is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with the CAPA system; see the file COPYING. If not,
# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# As a special exception, you have permission to link this program
# with the TtH/TtM library and distribute executables, as long as you
# follow the requirements of the GNU GPL in regard to all of the
# software in the executable aside from TtH/TtM.
print "Content-type: text/html\n\n";
use Benchmark;
$BenchmarkT0 = new Benchmark;
#require "capadiscuss.setup";
require "../capadiscuss_html";
################################################
## Configuration - Change these appropriately ##
################################################
$discussurl = "capadiscuss";
$capasbin = "/capa-bin";
use Cwd;
$capabin = cwd();
@capabinparts = split /\//, $capabin;
$capabin = join "/", @capabinparts[0..$#capabinparts-1];
# capadiscuss.setup
$debug = 0;
################################################
## End Configuration ###########################
################################################
&form_info;
$yp = "19";
$validadmin = "unchecked";
# define variables
$class = $form{'CLASS'};
$snum = $form{'SNUM'};
$capaid = $form{'CAPAID'};
$setid = $form{'SETID'};
$action = $form{'ACTION'};
$file = $form{'FILE'};
$probnum = $form{'PROBNUM'};
$replynum = $form{'REPLYNUM'};
$psetid = $form{'PSETID'};
if ($snum eq "A12345678") {$debug=1;}
if ($snum eq "a12345678") {$debug=1;}
$debug=0;
if($psetid eq "") { $psetid = $setid; }
if ($debug) {print "GetTeacherInfo
";$BenchmarkTa = new Benchmark;}
&GetTeacherInfo;
if($debug) {$BenchmarkTb = new Benchmark;print "
",timestr(timediff($BenchmarkTb,$BenchmarkTa)),"\n";}
# check if student is banned from forum
if ($debug) {print "BanUser
";$BenchmarkTa = new Benchmark;}
if (&BanUser) {exit;}
if($debug) {$BenchmarkTb = new Benchmark;print "
",timestr(timediff($BenchmarkTb,$BenchmarkTa)),"\n";}
# check for valid studentnumber/capaid, an exit will occur here if the set wasn't open
if ($debug) {print "ValidateUser
";$BenchmarkTa = new Benchmark;}
&ValidateUser;
if($debug) {$BenchmarkTb = new Benchmark;print "
",timestr(timediff($BenchmarkTb,$BenchmarkTa)),"\n";}
# grab username from student number
if ($debug) {print "UserInfo
";$BenchmarkTa = new Benchmark;}
&UserInfo($snum);
if($debug) {$BenchmarkTb = new Benchmark;print "
",timestr(timediff($BenchmarkTb,$BenchmarkTa)),"\n";}
if ($debug) {print "GetDateTime
";$BenchmarkTa = new Benchmark;}
&GetDateTime;
if($debug) {$BenchmarkTb = new Benchmark;print "
",timestr(timediff($BenchmarkTb,$BenchmarkTa)),"\n";}
if ($debug) {print $action . "
";$BenchmarkTa = new Benchmark;}
# call appropriate sr
if($action eq "newset" ) { &NewSet; }
if($action eq "viewset" || $action eq "" ) { &ViewSet; }
if($action eq "viewproblem" ) { &ViewProblem; }
if($action eq "post" ) { &Post; }
if($action eq "postsubmit" ) { &PostSubmit; }
if($action eq "delmsgpre" ) { &DelMsgPre; }
if($action eq "delmsg" ) { &DelMsg; }
if($action eq "hidemsgpre" ) { &HideMsgPre; }
if($action eq "hidemsg" ) { &HideMsg; }
if($action eq "unhidemsgpre" ) { &UnHideMsgPre; }
if($action eq "unhidemsg" ) { &UnHideMsg; }
if($action eq "admin" ) { &AdminMain; }
if($action eq "adminusersearch" ) { &AdminUserSearch; }
if($action eq "adminusersearchsubmit" ) { &AdminUserSearchSubmit; }
if($action eq "viewinfofile" ) { &ViewInfoFile; }
if($action eq "topmsg" ) { &TopMsg("top"); }
if($action eq "untopmsg" ) { &TopMsg(""); }
if($debug) {$BenchmarkTb = new Benchmark;print "
",timestr(timediff($BenchmarkTb,$BenchmarkTa)),"\n";}
$BenchmarkT1 = new Benchmark;
if($debug) { print "
",timestr(timediff($BenchmarkT1,$BenchmarkT0)),"\n";}
exit;
#######################
## Begin Subroutines ##
#######################
sub GetSetList {
opendir(DDIR,"$capadir/$class/discussion");
@sets = grep(/^[0-9]+$/,sort(readdir(DDIR)));
closedir(DDIR);
if ($debug) {print "
Sets:". @sets ."
\n";}
}
sub SetListHeader {
$pdset = "\n";
}
sub GetInfoList {
local(@temp,@alldir,@setdir);
# if ($debug) {print "
GetInfoList
";}
opendir(DDIR,"$capadir/$class/discussion");
@alldir = sort(grep(/.info$/,readdir(DDIR)));
closedir(DDIR);
opendir(FORUM,"$capadir/$class/discussion/$setid");
@setdir = sort(grep(/.info$/,readdir(FORUM)));
closedir(FORUM);
foreach $file(@setdir) { @setdir2 = (@setdir2,"$setid/$file"); }
@infofiles = (@alldir,@setdir2);
$infostring = "";
# if ($debug) {print "
GetInfoList" . @infofiles."
";}
foreach $infofile(@infofiles) {
# if ($debug) {print "
GetInfoList" . $infofile."
";}
@temp = reverse split /\//, $infofile;
$infodesc = $temp[0];
$infodesc =~ s/.info//g;
$infodesc =~ s/_/ /g;
$infostring .= &InfoButtonHTML;
}
if ($infostring ne "") {
# $infostring = "