Annotation of capa/capa51/Historic/newbub.c, revision 1.3

1.2       albertel    1: /* start at reimplementing bubbler
                      2:    Copyright (C) 1992-2000 Michigan State University
                      3: 
                      4:    The CAPA system is free software; you can redistribute it and/or
1.3     ! albertel    5:    modify it under the terms of the GNU General Public License as
1.2       albertel    6:    published by the Free Software Foundation; either version 2 of the
                      7:    License, or (at your option) any later version.
                      8: 
                      9:    The CAPA system is distributed in the hope that it will be useful,
                     10:    but WITHOUT ANY WARRANTY; without even the implied warranty of
                     11:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1.3     ! albertel   12:    General Public License for more details.
1.2       albertel   13: 
1.3     ! albertel   14:    You should have received a copy of the GNU General Public
1.2       albertel   15:    License along with the CAPA system; see the file COPYING.  If not,
                     16:    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
                     17:    Boston, MA 02111-1307, USA.
                     18: 
                     19:    As a special exception, you have permission to link this program
                     20:    with the TtH/TtM library and distribute executables, as long as you
                     21:    follow the requirements of the GNU GPL in regard to all of the
                     22:    software in the executable aside from TtH/TtM.
                     23: */
                     24: 
1.1       albertel   25: #include <iostream.h>
                     26: 
                     27: void initScreen()
                     28: {
                     29:   printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                     30:   printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                     31:   printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                     32:   printf("Welcome to Bubbler, the Automated CAPA grader.\n");
                     33:   printf("By: Guy Albertelli II\n");
                     34:   printf("Version 0.10.00\n\n\n");
                     35: }
                     36: 
                     37: void getClassInfo(char* class,int* setId)
                     38: {
                     39:   printf("What is the class name?");
                     40:   scanf("%s",class);
                     41: 
                     42:   printf("What is the SetId?");
                     43:   scanf("%d",setId);
                     44: }
                     45: 
                     46: /*errr Guy this all needs some major thought put into it*/
                     47: void openOutputFile(filename[80], Questions questions[MAXQUEST],char* class,
                     48: 		    int setId,char problem)
                     49: {
                     50:   FILE *outputFile=fopen(filename,"r+");
                     51: 
                     52:   /*File already exists*/
                     53:   if (outputFile != NULL)
                     54:     {
                     55:       rewind(outputFile);
                     56:       /*read in the first line with problem description etc.*/
                     57:       fscanf(outputFile,"%s",buf);
                     58:     }
                     59:   
                     60:   /*File doesn't exist or is empty*/
                     61:   if (outputFile==NULL || buf[0]=='\0')
                     62:     {
                     63:       outputFile=fopen(filename,"w+");
                     64:       if (outputFile==NULL)
                     65: 	{
                     66: 	  fprintf(stderr,"Unable to open the output file %s",filename);
                     67: 	  exit(10);
                     68: 	}
                     69:       fprintf(outputFile,"%s %d ",class,setId);
                     70:       for(i=0;i<numQuestions;i++)
                     71:         {
                     72:           fprintf(outputFile,"%c%d",questions[i].type,questions[i].points);
                     73:         }
                     74:       fprintf(outputFile,"\n");
                     75:     }
                     76:   else
                     77:     {
                     78:       rewind(outputFile);
                     79:       fscanf(outputFile,"%s %d %s",outputFileClass,outputFileSetId,
                     80: 	     outputFileQuestions);      
                     81:     }
                     82: }
                     83: /* see comment above*/
                     84: void getProblemInfo(Question questions[MAXQUEST],char* class,
                     85: 		    int setId,Flags* flags,FILE** outputFile)
                     86: {
                     87:   char filename[80],buf[1024];
                     88: 
                     89:   sprintf(filename,"bubbler.output.%d",setId);
                     90:   outputFile=fopen(filename,"r+");
                     91:   
                     92:   printf("Should I compare the class name and SetId with each paper?(y or n)");
                     93:   scanf("%s",clear);
                     94:   if (clear[0]=='N' || clear[0]=='n')
                     95:     flags->CompareClassName=0;
                     96:   else
                     97:     flags->CompareClassName=1;
                     98: 
                     99:   printf("Should the PIN be checked? (y or n)");
                    100:   scanf("%s",clear);
                    101:   if (clear[0]=='N' || clear[0]=='n')
                    102:     flags->CheckPIN=0
                    103:   else
                    104:     {
                    105:       CheckPIN=1;
                    106:       printf("Should we run in Anonymous mode?");
                    107:       scanf("%s",clear);
                    108:       if (clear[0]=='N' || clear[0]=='n')
                    109: 	Anon=0;
                    110:       else
                    111: 	Anon=1;
                    112:     }  
                    113: }
                    114: 
                    115: int main(void)
                    116: {
                    117:   initScreen();
                    118:   getClassInfo();
                    119:   getProblemInfo();
                    120:   setupScantron();
                    121:   processForms();
                    122:   closeScantron();
                    123:   return 0;
                    124: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>