--- capa/capa51/pProj/allcapaid.c 1999/09/28 21:26:21 1.1 +++ capa/capa51/pProj/allcapaid.c 2000/07/07 18:33:03 1.4 @@ -1,8 +1,29 @@ +/* Generate all CAPA Ids for a class + 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 Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library 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. +*/ -/* ========================================================================== */ /* ========================================================================== */ /* allcapaid.c created by Isaac Tsai */ -/* 1998, 1999 copyrighted by Isaac Tsai */ /**************************************************************************** */ #ifdef NeXT #include @@ -104,6 +125,9 @@ void usage() printf(" -Sec 3:7 : from section 3 to section 7\n"); printf(" -i : don't create files, print to the screen\n"); printf(" -p 2 : output 6 charatcer capaidplus instead of capaid\n"); + printf(" -checkopen : check if set is open, fail if it isn't.\n"); + printf(" -checkdue : check if set is due, fail if it isn't.\n"); + printf(" -checkans : check if set's answers are available, fail if they aren't.\n"); printf(" -h : prints this message\n"); printf(" CAPA version %s, %s\n",CAPA_VER,COMPILE_DATE); } @@ -112,14 +136,14 @@ void usage() #define F_STUDENT 3 int main (int argc, char **argv) { - T_student *students_p,*s_p; + T_student *students_p,*s_p,student_data; int i, setIdx, numStudents, count, tmp_num, StartSec=1,EndSec=999; int StartSet = 1, EndSet = 10, classnameOK=0,outputDir=0,plus=0; int SecCntArry[MAX_SECTION_COUNT], sectionIdx; char filename[MAX_BUFFER_SIZE], path[MAX_BUFFER_SIZE], outputPath[MAX_BUFFER_SIZE], fullpath[MAX_BUFFER_SIZE]; - char StuNum[MAX_STUDENT_NUMBER+1]; - int ForWhat=F_CLASS, interactive=0; + char StuNum[MAX_STUDENT_NUMBER+1], fmt[16]; + int ForWhat=F_CLASS, interactive=0,CheckOpen=0,CheckDue=0,CheckAns=0; FILE *dfp; if( argc == 0 ) { @@ -155,6 +179,9 @@ int main (int argc, char **argv) if( EndSet > 999 ) EndSet = 99; break; case 'c': + if (strcmp(argv[0],"-checkopen")==0) { CheckOpen=1; break; } + if (strcmp(argv[0],"-checkdue" )==0) { CheckDue=1; break; } + if (strcmp(argv[0],"-checkans" )==0) { CheckAns=1; break; } strcpy(path,argv[1]); if( capa_access(path, F_OK) == -1 ) { printf("No such class [%s] please specify it again:\n",path); @@ -211,7 +238,26 @@ int main (int argc, char **argv) printf("%4d ", setIdx ); } printf("\n"); + if (CheckOpen || CheckDue || CheckAns) { + sprintf(fmt,"%%%ds ",plus+4); + if ( capa_get_student(StuNum,&student_data) == 0 ) { + fprintf(stderr,"Unable to find student, %s.\n",StuNum); + exit(1); + } + } for(setIdx = StartSet; setIdx <= EndSet; setIdx++) { + if ( CheckOpen && ( capa_check_date(CHECK_OPEN_DATE,StuNum, + student_data.s_sec,setIdx) < 0)) { + printf(fmt,"Open");continue; + } + if ( CheckDue && ( capa_check_date(CHECK_DUE_DATE,StuNum, + student_data.s_sec,setIdx) < 0)) { + printf(fmt,"Due");continue; + } + if ( CheckAns && ( capa_check_date(CHECK_ANS_DATE,StuNum, + student_data.s_sec,setIdx) < 0)) { + printf(fmt,"Ans");continue; + } if (plus) print_capaidplus(stdout,StuNum,setIdx,plus); else @@ -222,6 +268,9 @@ int main (int argc, char **argv) case F_CLASS: StartSec=1;EndSec=999; case F_SECTIONS: + if (CheckOpen || CheckDue || CheckAns) { + printf("Can only check dates in single student mode\n"); + } if ((count = capa_get_section_count( SecCntArry )) != 0 ) { if (count == -1 ) { printf("classl file not found in %s\n",path);