/**********************************************************/ /* This header defines Application Interface to the */ /* CAPA system. It needs capaParser.h and capaToken.h */ /* CAPA version 4.3 */ /* Date Oct 23 1995 */ /* Isaac Tsai */ /* */ /* Get rid of old style structure definition *_t */ /* Make all structure definition begin with T_ */ /* 1997, 1998, 1999 Isaac Tsai */ /**********************************************************/ #ifndef CAPA_COMMON_H #define CAPA_COMMON_H #include #ifdef linux #include #endif #ifdef NeXT #include #include #else #include #include #endif #include #include #include #include /* lockf() */ #include /* flock() */ #include #include "capaParser.h" #ifndef MAX #define MAX(a,b) ((a>b)? (a):(b)) #endif #define MAX_SECTION_SIZE 10240 /* Max # of students in the class */ #define MAX_SECTION_COUNT 1024 #define MAX_NAME_CHAR 30 /* Student's name max length */ #define MAX_STUDENT_NUMBER 9 /* Student Number length */ #define MAX_EMAIL_CHAR 40 /* Email address */ #define FILE_NAME_LENGTH 1024 #define MAX_PIN_CHAR 4 #define MAX_BUFFER_SIZE 2048 #define TMP_LINE_LENGTH 2048 /* used to read in log.db set.db dates.db */ #define SMALL_LINE_BUFFER 128 /* used to read classl, active.db */ #define SETDB_BUF_SIZE (256*1024) /* user input string length now in capaParser.h*/ /*#define ANSWER_STRING_LENG 81*/ /*#define UNIT_STRING_LENG 64*/ #define FORMAT_STRING_LENG 32 /* -------- used in check_date() */ #define CHECK_OPEN_DATE 1 #define CHECK_DUE_DATE 2 #define CHECK_ANS_DATE 3 /******************************************************************************/ /* STRUCTURE FOR THE HEADER OF A DATABASE FILE */ /******************************************************************************/ typedef struct { char num_questions[FORMAT_STRING_LENG]; char *weight; char *partial_credit; } T_header; /******************************************************************************/ /* STRUCTURE FOR A NORMAL DATABASE FILE ENTRY */ /******************************************************************************/ typedef struct { char student_number[MAX_STUDENT_NUMBER+1]; /* Student number */ int e_probs; char *answers; /* String of answers */ char *tries; } T_entry; /******************************************************************************/ /* STRUCTURE FOR A STUDENT IN THE STUDENT ARRAY */ /******************************************************************************/ typedef struct _student { struct _student *s_next; struct _student *s_prev; int s_sec; int s_scores; char s_key[MAX_NAME_CHAR+MAX_NAME_CHAR+2]; /* sorting key */ char s_sn[MAX_STUDENT_NUMBER+1]; char s_nm[MAX_NAME_CHAR+1]; char s_email[MAX_EMAIL_CHAR+1]; int s_capaid; } T_student; /******************************************************************************/ /* STRUCTURE FOR Login dates for a set */ /******************************************************************************/ /*section number DATE_DEFAULTs contains the default dates an assignment is due*/ #define DATE_DEFAULTS 0 #define OPEN_OFFSET 0 #define DUE_OFFSET 17 #define ANSWER_OFFSET 34 #define DATE_LENGTH 16 #define DATE_BUFFER 17 #define OPTION_INHIBIT_RESPONSE 100 #define OPTION_VIEW_PROBLEMS_AFTER_DUE 101 typedef struct _date { struct _date *s_next; int section_start; int section_end; char open_date[DATE_BUFFER]; char due_date[DATE_BUFFER]; char answer_date[DATE_BUFFER]; char duration[DATE_BUFFER]; int inhibit_response; int view_problems_after_due; } T_dates; /******************************************************************************/ /* STRUCTURE FOR Login history for a student */ /******************************************************************************/ typedef struct { int count; /* Number of questions */ char *answers; /* String of answers */ } login_history_t; #define leap_year(yr) ((yr) <= 1752 ? !((yr) % 4) : !((yr) % 4) && (((yr) % 100) || !((yr) % 400))) #define centuries_since_1700(yr) ((yr) > 1700 ? (yr) / 100 - 17 : 0) #define quad_centuries_since_1700(yr) ((yr) > 1600 ? ((yr) - 1600) / 400 : 0) #define leap_years_since_year_1(yr) ((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr)) /*=============================================================================*/ /* CAPA PROTOTYPES FOR FUNCTIONS IN COMMON.C */ /*=============================================================================*/ /*-----------------------------------------------------------------------------*/ int capa_parse CAPA_ARG((int set,Problem_t **problem,char *filename,int *num_questions,void (*func_ptr)())); void send CAPA_ARG((char* text)); /*============================================================================*/ #endif /* CAPA_COMMON_H */