--- capa/capa51/Discuss/Ver1.3/Attic/capadiscuss 1999/09/28 21:27:46 1.1
+++ capa/capa51/Discuss/Ver1.3/Attic/capadiscuss 1999/10/14 18:47:01 1.3
@@ -54,7 +54,7 @@ if ($debug) {print "GetTeacherInfo
";
&GetTeacherInfo;
if($debug) {$BenchmarkTb = new Benchmark;print "
",timestr(timediff($BenchmarkTb,$BenchmarkTa)),"\n";}
- # check for valid studentnumber/capaid
+ # 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";}
@@ -100,12 +100,57 @@ 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 = "
" . $infostring;
+ }
+# if ($debug) {print "
GetInfoList" . $infostring."
";}
+}
sub NewSet {
&Log("NewSet");
if($setid <= $psetid) { #grab capaid
- if ($debug) {print "ViewSet
";$BenchmarkTa = new Benchmark;}
+ if ($debug) {print "NewSet
";$BenchmarkTa = new Benchmark;}
@allcapaid = `allcapaid -s $setid -e $setid -stu $snum -c $capadir/$class -i`;
$capaid = $allcapaid[2];
@@ -116,18 +161,10 @@ if($debug) {$BenchmarkTb = new Benchmark
return;
}
- opendir(DDIR,"$capadir/$class/discussion");
- @sets = grep(/[0-9]/,sort(readdir(DDIR)));
- closedir(DDIR);
-
- $pdset = "\n";
-
+ if ($debug) { print "
GetSetList\n"; }
+ &GetSetList;
+ if ($debug) { print "
EndGetSetList\n"; }
+ &SetListHeader;
&NewSetHTML;
#exit;
}
@@ -143,20 +180,13 @@ sub ViewSet {
$capasbin = "$capasbin/$teachdir/capasbin";
&SetJumpBox;
+ $backfunction="viewset";
+ &GetInfoList;
+
opendir(FORUM,"$capadir/$class/discussion/$setid");
@dir = sort(readdir(FORUM));
closedir(FORUM);
- @infofiles = grep(/.info/,@dir);
- $infostring = "";
- $backfunction = "viewset";
- foreach $infofile(@infofiles) {
- $infodesc = $infofile;
- $infodesc =~ s/.info//g;
- $infodesc =~ s/_/ /g;
- $infostring .= &InfoButtonHTML;
- }
-
foreach $i(@dir) {
$probnum = &RemZero(substr($i,0,6));
$found[$probnum]++;
@@ -263,6 +293,7 @@ sub ViewProblem {
}
if($msgcount eq "1") {
+ &GetInfoList;
$postbutton = &ReplyButtonHTML;
&ProblemJumpBox;
&ViewProblemTopHTML;
@@ -304,6 +335,7 @@ sub ViewProblem {
}
if($msgfind eq "no") {
+ &GetInfoList;
$postbutton = &PostNewButtonHTML;
&ProblemJumpBox;
&ViewProblemTopHTML;
@@ -317,7 +349,7 @@ sub ViewProblem {
}
sub ViewInfoFile {
- open(INFOFILE,"$capadir/$class/discussion/$setid/$file");
+ open(INFOFILE,"$capadir/$class/discussion/$file");
@file = ;
closedir(INFOFILE);
@@ -653,16 +685,29 @@ sub ValidateUser {
if($valid eq "no") { &InvalidVarsHTML; }
# check w/ allcapaid program
- @allcapaid = `allcapaid -s $setid -e $setid -stu $snum -c $capadir/$class -i`;
+ @allcapaid = `allcapaid51 -s $setid -e $setid -stu $snum -c $capadir/$class -i -checkopen`;
chop $allcapaid[2];
chop $allcapaid[2];
+ if ($debug) {print "capaid:" . $allcapaid[2] . "
\n";}
if($allcapaid[2] ne $capaid) {
- if($action ne "newset") { &BadPassHTML; }
+ if ($allcapaid[2] =~ /Open/) { &NotOpen; exit; }
+ if($action ne "newset") { &BadPassHTML; exit; }
#&NewSet;
}
}
+sub NotOpen {
+ &GetSetList;
+ &SetListHeader;
+ &ViewSetTitleHTML;
+print <
+