File:  [LON-CAPA] / capa / capa51 / Historic / bubblersurvey.c
Revision 1.1: download - view: text, annotated - select for diffs
Tue Sep 28 21:26:52 1999 UTC (24 years, 8 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
Initial revision

    1: #include <stdio.h>
    2: #include "Capa/capaCommon.h"
    3: #include "bubbler.h"
    4: #include <ctype.h>
    5: 
    6: #ifdef   F_DBUG
    7: extern FILE *dfp; 
    8: #endif
    9: 
   10: int main()
   11: {
   12:   T_entry grade;
   13:   FILE * inputFile, * outputFile;
   14:   int i=0,setnumber,score,section,setId,done=0,numQuestions;
   15:   char class[10],set[3],name[MAX_NAME_CHAR+1],buf,buffmt[128],
   16:       studentnumber[MAX_STUDENT_NUMBER+1],filename[128];
   17:   int q=0,r=0,answer[MAXQUEST][11];
   18:   Question questions[MAXQUEST];
   19:   
   20:   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");
   21:   printf("Covert form Bubbler output to survey results ");
   22:   printf("Version 0.1.00\n");
   23:   printf("Please enter the Set Id number.");
   24:   scanf("%d",&setId);
   25:   sprintf(filename,"bubbler.output.%d",setId);
   26:   inputFile=fopen(filename,"r");
   27: 
   28:   if (inputFile==NULL)
   29:     {
   30:       fprintf(stderr,"%s not found\n",filename);
   31:       exit(-1);
   32:     }
   33: 
   34:   fscanf(inputFile,"%s %s",class,set);
   35:   printf("%s %s\n",class,set);
   36:   setnumber=atoi(set);
   37: 
   38:   i=0;
   39:   fscanf(inputFile,"%c",&buf);
   40:   while(!done)
   41:     {
   42:       buf=fgetc(inputFile);
   43:       if (buf!='\n')
   44: 	{
   45: 	  questions[i].type=buf;
   46: 	  buf=fgetc(inputFile);
   47: 	  questions[i].points=questions[i].leafs=(int)(buf-'0');
   48: 	  i++;
   49: 	}
   50:       else
   51: 	{
   52: 	  done=1;
   53: 	}
   54:     }
   55:   
   56:   numQuestions=i;
   57: 
   58:   for(q=0;q<MAXQUEST;q++)
   59:     for(r=0;r<11;r++)
   60:       answer[q][r]=0;
   61: 
   62:   printf("Processing");
   63:   while(fscanf(inputFile,"%9c",studentnumber)!=EOF)
   64:     {
   65:       printf(".");
   66:       fflush(stdout);
   67:       fscanf(inputFile,"%32c",name);
   68:       sprintf(buffmt,"%%%dc",numQuestions);
   69:       fscanf(inputFile,buffmt,grade.answers);
   70:       fscanf(inputFile,"%d",&score);
   71:       fscanf(inputFile,"%d",&section);
   72:       buf='\0';
   73:       while(buf!='\n')
   74: 	{
   75: 	  buf=fgetc(inputFile);
   76: 	}
   77: #ifdef DEBUG
   78:       printf("%d %d\n",numQuestions,strlen(grade.answers));
   79: #endif /*DEBUG*/
   80:       for(i=0;i<numQuestions;i++)
   81: 	{
   82: 	  switch(questions[i].type)
   83: 	    {
   84: 	    case 'a':
   85: 	    case 'f':
   86: 	    case 'g':
   87: 	    case 'b':
   88: 	    case 'c':
   89: 	    case 'e':
   90: 	    case 'd':
   91: 	      if (isdigit(grade.answers[i]))
   92: 		answer[i][grade.answers[i]-'0']++;
   93: 	      else if(isspace(grade.answers[i]))
   94: 		{
   95: 		  answer[i][10]++;
   96: 		}
   97: 	      break;
   98: 	    default:
   99: 	      printf("Unknown question type\n");
  100: 	      break;
  101: 	    }
  102: 	}
  103:       grade.answers[i]='\0';
  104: #ifdef DEBUG
  105:       printf("%s\n",studentnumber);
  106: #endif /*DEBUG*/
  107:     }
  108: 
  109:   sprintf(filename,"survey.%d",setId);
  110:   outputFile=fopen(filename,"w");
  111:   if (outputFile==NULL)
  112:     {
  113:       fprintf(stderr,"%s not found\n",filename);
  114:       exit(-1);
  115:     }
  116: 
  117:   fprintf(outputFile,"Survey results for class: %s\n\n",class);
  118:   for(q=0;q<numQuestions;q++)
  119:     {
  120:       fprintf(outputFile,"Question: %d\n",q+1);
  121:       fprintf(outputFile,"  0   1   2   3   4   5   6   7   8   9   S\n");
  122:       for(r=0;r<11;r++)
  123: 	{
  124: 	  fprintf(outputFile,"%3d ",answer[q][r]);
  125: 	}
  126:       fprintf(outputFile,"\n");
  127:     }
  128:   printf("\nProcessing completed. Look in survey.%d for results.\n",
  129: 	 setId);
  130:   return 0;
  131: }

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