/* early version of some statistics for CAPA 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. */ #include #include #include #include #ifdef __sun #include #endif #ifdef NeXT #include #endif #include /*--------------------------------------------------------------*/ /* Constant Values for "hgr*.out". */ /*--------------------------------------------------------------*/ #define MAX_SECTION_NUMBER 3 /* maximum number of char for section number */ #define MAX_STUDENT_NUMBER 9 /* maximum number of char for student number */ #define MAX_STUDENT_NAME 30 /* maximum number of char for student name */ #define MAX_PROBLEM_NUMBER 150 /* maximum number of problems in a set */ #define FILE_NAME_LENGTH 256 /* maximum length of file name */ #define MAX_CLASS_SIZE 1024 /* maximum number of students in a class */ /*--------------------------------------------------------------*/ /* Constant Values for "set*.db". */ /*--------------------------------------------------------------*/ #define MAX_TRIES 100 /* tries 0..99 */ /*--------------------------------------------------------------*/ /* One line of record in "hgr*.out". */ /*--------------------------------------------------------------*/ typedef struct{ char section[MAX_SECTION_NUMBER+1]; char s_number[MAX_STUDENT_NUMBER+1]; char s_name[MAX_STUDENT_NAME+1]; char problem_number[MAX_PROBLEM_NUMBER]; char problem_score[MAX_PROBLEM_NUMBER]; } HGR_record; int GradedProblems=0; /* The number of problems in a HG'd record */ int NumberOfUpdates=0; /* The number of records need updated in hgr*.db */ int NumberOfProblems=0; char *progname; HGR_record hgr_record[MAX_CLASS_SIZE]; /*--------------------------------------------------------------*/ /* One line of record in "set*.out". */ /*--------------------------------------------------------------*/ typedef struct{ int valid; /* if a registered student */ char s_number[MAX_STUDENT_NUMBER+1]; /* student number */ char answer[MAX_PROBLEM_NUMBER]; /* a string of answers */ char tries[3*MAX_PROBLEM_NUMBER]; } SET_record; char line1[512],line2[512],line3[512]; /* The first three lines in set*.db */ int NumberOfStudents=0; /* Number of students in set*.db */ int ValidStudents=0; /* No. of Valid students in set*.db */ SET_record set_record[MAX_CLASS_SIZE]; /*--------------------------------------------------------------*/ /* */ /* Statistics for the number of tries in "set*.db". */ /* */ /*--------------------------------------------------------------*/ int s[MAX_PROBLEM_NUMBER][MAX_TRIES]; int t[MAX_CLASS_SIZE][MAX_PROBLEM_NUMBER]; int YesCnt[MAX_PROBLEM_NUMBER]; int yesCnt[MAX_PROBLEM_NUMBER]; int correct[MAX_PROBLEM_NUMBER]; int Weight[MAX_PROBLEM_NUMBER]; int TotalTries[MAX_PROBLEM_NUMBER]; typedef struct{ int total; int score[MAX_PROBLEM_NUMBER]; }Student; int GuyNumberOfStudents; Student student[MAX_CLASS_SIZE]; #define PARTIAL 0 #define NOPARTIAL 1 /*--------------------------------------------------------------*/ /* */ /* */ /*--------------------------------------------------------------*/ void usage() { printf("USAGE: %s [-s set] [-t LargeTry] [-n NumberLargeTry]\n", progname); } /*--------------------------------------------------------------*/ /* */ /* Return the maximum score of a problem. */ /* */ /*--------------------------------------------------------------*/ int Problem_Score(score_ptr,problem_number) char *score_ptr; char problem_number; { char *tmp_ptr; char score; tmp_ptr=strchr(score_ptr,problem_number); tmp_ptr=tmp_ptr+2; sscanf(tmp_ptr, "%c", &score); return(score-'0'); } /*--------------------------------------------------------------*/ /* */ /* Check if the list of scores is valid */ /* */ /*--------------------------------------------------------------*/ int Valid_Score(scorelist,score_ptr) char *scorelist; char *score_ptr; { char *problem; int score=-1; int value=1; GradedProblems=0; problem = scorelist; while (*problem == '('){ GradedProblems++; problem++; score=Problem_Score(score_ptr,*problem); problem=problem+2; if (*problem != '*'&&((*problem-'0')>score)){ value=0; } problem=problem+3; } return(value); } /*--------------------------------------------------------------*/ /* */ /* Open the hand graded file "./record/set`set`.out", */ /* and return the file pointer. */ /* */ /*--------------------------------------------------------------*/ FILE *Open_Read(filename) char filename[FILE_NAME_LENGTH]; { FILE *fp; if ((fp=fopen(filename,"r"))==NULL) { printf("Error: can't open %s\n",filename); exit(1); } return(fp); } /*--------------------------------------------------------------*/ /* */ /* Open the hand graded file "./record/set`set`.out", */ /* and return the file pointer. */ /* */ /*--------------------------------------------------------------*/ FILE *Open_Write(filename) char filename[FILE_NAME_LENGTH]; { FILE *fp; if ((fp=fopen(filename,"w"))==NULL) { printf("Error: can't open %s\n",filename); exit(1); } return(fp); } int studentCompare(const void *a,const void *b) { Student *voida,*voidb; voida=(Student *)a; voidb=(Student *)b; if (voida->total < voidb->total) return 1; if (voida->total > voidb->total) return -1; return 0; } /*--------------------------------------------------------------*/ /* */ /* */ /*--------------------------------------------------------------*/ void Read_Record(fp_set) FILE *fp_set; { int count,i,j; int done,len; int problem; int problem_cnt; char fmtbuf[128]; char nextline[512]; char temp; fgets(line1,511,fp_set); sscanf(line1,"%d",&problem_cnt); fgets(line2,511,fp_set); len=strlen(line2); /* weight line */ for(i=0;i=0) && (try <=99)){ s[j][try]++; t[i][j]=try; TotalTries[j]=TotalTries[j]+try; } } } } double GetDegreeOfDiscrim(int problem,int mode) { int i,numTopRight=0,numBottomRight=0,twentySevenPercent; double dd; twentySevenPercent=(int)ceil(.27*(double)GuyNumberOfStudents); for(i=0;i 0) { numTopRight++; } if (student[GuyNumberOfStudents-i].score[problem]>0){numBottomRight++;} break; case NOPARTIAL: if (student[i].score[problem] == Weight[problem]) { numTopRight++; } if (student[GuyNumberOfStudents-i].score[problem] == Weight[problem]) { numBottomRight++; } break; } } dd=(((((double)numTopRight)/((double)twentySevenPercent))- (((double)numBottomRight)/((double)twentySevenPercent)))); return 100.0*dd; } double GetDifficulty(int problem, int mode) { int i,numWrong=0; for(i=0;im[i]){ m[i]=t[j][i]; } } } for (i=0;i= '0' && set_record[i].answer[j] <= '9' ) { correct[i]=correct[i]+1; total_scores=total_scores+(set_record[i].answer[j]-'0'); } break; } } } } percentage = (float)total_scores / (float)total_weight; percentage = percentage * 100.0; printf("\nThe percentage score for set%d.db is %7.2f%%\n",set,percentage); /*printf("Total Number of Students in set%d.db is %d\n",set,ValidStudents);*/ } /*--------------------------------------------------------------*/ /* */ /* */ /*--------------------------------------------------------------*/ void Large_Tries(LargeTry, NumberLargeTry) int LargeTry, NumberLargeTry; { int i,j; int count; int credit; /* Number of credits should be taken off */ printf("\nHere is a list of students who have %d tries more than %d times: \n\n", LargeTry, NumberLargeTry); for (i=0;i=LargeTry){ count++; if (set_record[i].answer[j]=='Y' || set_record[i].answer[j]=='y') credit ++; } } if (count >= NumberLargeTry){ printf("(%d) %s \n",credit, set_record[i].s_number); printf("%s %s \n", set_record[i].answer, set_record[i].tries); } } } /*--------------------------------------------------------------*/ /* */ /* */ /*--------------------------------------------------------------*/ int main(argc,argv) int argc; char *argv[]; { int set=1; int inputNotOK=1; int LargeTry=0,NumberLargeTry=0; FILE *fp_set; char set_file[FILE_NAME_LENGTH]; char path[FILE_NAME_LENGTH]; char filename[FILE_NAME_LENGTH]; for( progname = *argv++; --argc; argv++) { if ( argv[0][0] == '-' ) { switch(argv[0][1]) { case 's': set = atoi(argv[1]); break; case 't': LargeTry = atoi(argv[1]); break; case 'n': NumberLargeTry = atoi(argv[1]); break; default: usage(); break; } } } while ( inputNotOK ) { puts("Enter the ABSOLUTE path of class"); scanf("%s", path); if( access(path, F_OK) == -1 ) { } else { sprintf(filename,"%s/records",path); if( access(filename, F_OK) == -1 ) { puts("There isn't a records dir in this CLASS directory"); puts("Please Specify another calss"); } else { inputNotOK = 0; } } } chdir(path); sprintf(set_file, "records/set%d.db",set); /* sprintf(out_file, "records/set%d.out",set); */ fp_set=Open_Read(set_file); /* fp_out=Open_Write(out_file); */ Read_Record(fp_set); Sort_By_Tries(); /* Print_Tries(); */ Percentage_Scores(set); Average_Tries(); Large_Tries(LargeTry, NumberLargeTry); return 0; }