1:
2: /**********************************************************/
3: /* This header defines Application Interface to the */
4: /* CAPA system. It needs capaParser.h and capaToken.h */
5: /* CAPA version 4.3 */
6: /* Date Oct 23 1995 */
7: /* Isaac Tsai */
8: /* */
9: /* Get rid of old style structure definition *_t */
10: /* Make all structure definition begin with T_ */
11: /* 1997, 1998, 1999 Isaac Tsai */
12: /**********************************************************/
13:
14: #ifndef CAPA_COMMON_H
15: #define CAPA_COMMON_H
16:
17: #include <stdio.h>
18: #ifdef linux
19: #include <stdlib.h>
20: #endif
21: #ifdef NeXT
22: #include <stdlib.h>
23: #include <libc.h>
24: #else
25: #include <malloc.h>
26: #include <unistd.h>
27: #endif
28:
29: #include <math.h>
30: #include <string.h>
31: #include <time.h>
32: #include <sys/fcntl.h> /* lockf() */
33: #include <sys/file.h> /* flock() */
34: #include <sys/types.h>
35: #include "capaParser.h"
36:
37: #ifndef MAX
38: #define MAX(a,b) ((a>b)? (a):(b))
39: #endif
40:
41: #define MAX_SECTION_SIZE 10240 /* Max # of students in the class */
42: #define MAX_SECTION_COUNT 1024
43: #define MAX_NAME_CHAR 30 /* Student's name max length */
44: #define MAX_STUDENT_NUMBER 9 /* Student Number length */
45: #define MAX_EMAIL_CHAR 40 /* Email address */
46: #define FILE_NAME_LENGTH 1024
47: #define MAX_PIN_CHAR 4
48: #define MAX_BUFFER_SIZE 2048
49: #define TMP_LINE_LENGTH 2048 /* used to read in log.db set.db dates.db */
50: #define SMALL_LINE_BUFFER 128 /* used to read classl, active.db */
51: #define SETDB_BUF_SIZE (256*1024)
52: /* user input string length now in capaParser.h*/
53: /*#define ANSWER_STRING_LENG 81*/
54: /*#define UNIT_STRING_LENG 64*/
55: #define FORMAT_STRING_LENG 32
56:
57: /* -------- used in check_date() */
58: #define CHECK_OPEN_DATE 1
59: #define CHECK_DUE_DATE 2
60: #define CHECK_ANS_DATE 3
61:
62:
63:
64: /******************************************************************************/
65: /* STRUCTURE FOR THE HEADER OF A DATABASE FILE */
66: /******************************************************************************/
67:
68: typedef struct {
69: char num_questions[FORMAT_STRING_LENG];
70: char *weight;
71: char *partial_credit;
72: } T_header;
73:
74: /******************************************************************************/
75: /* STRUCTURE FOR A NORMAL DATABASE FILE ENTRY */
76: /******************************************************************************/
77:
78: typedef struct {
79: char student_number[MAX_STUDENT_NUMBER+1]; /* Student number */
80: int e_probs;
81: char *answers; /* String of answers */
82: char *tries;
83: } T_entry;
84:
85: /******************************************************************************/
86: /* STRUCTURE FOR A STUDENT IN THE STUDENT ARRAY */
87: /******************************************************************************/
88:
89: typedef struct _student {
90: struct _student *s_next;
91: struct _student *s_prev;
92: int s_sec;
93: int s_scores;
94: char s_key[MAX_NAME_CHAR+MAX_NAME_CHAR+2]; /* sorting key */
95: char s_sn[MAX_STUDENT_NUMBER+1];
96: char s_nm[MAX_NAME_CHAR+1];
97: char s_email[MAX_EMAIL_CHAR+1];
98: int s_capaid;
99: } T_student;
100:
101: /******************************************************************************/
102: /* STRUCTURE FOR Login dates for a set */
103: /******************************************************************************/
104: /*section number DATE_DEFAULTs contains the default dates an assignment is due*/
105: #define DATE_DEFAULTS 0
106: #define OPEN_OFFSET 0
107: #define DUE_OFFSET 17
108: #define ANSWER_OFFSET 34
109: #define DATE_LENGTH 16
110: #define DATE_BUFFER 17
111: #define OPTION_INHIBIT_RESPONSE 100
112: #define OPTION_VIEW_PROBLEMS_AFTER_DUE 101
113: typedef struct _date {
114: struct _date *s_next;
115: int section_start;
116: int section_end;
117: char open_date[DATE_BUFFER];
118: char due_date[DATE_BUFFER];
119: char answer_date[DATE_BUFFER];
120: char duration[DATE_BUFFER];
121: int inhibit_response;
122: int view_problems_after_due;
123: } T_dates;
124:
125: /******************************************************************************/
126: /* STRUCTURE FOR Login history for a student */
127: /******************************************************************************/
128: typedef struct {
129: int count; /* Number of questions */
130: char *answers; /* String of answers */
131: } login_history_t;
132:
133: #define leap_year(yr) ((yr) <= 1752 ? !((yr) % 4) : !((yr) % 4) && (((yr) % 100) || !((yr) % 400)))
134:
135: #define centuries_since_1700(yr) ((yr) > 1700 ? (yr) / 100 - 17 : 0)
136:
137: #define quad_centuries_since_1700(yr) ((yr) > 1600 ? ((yr) - 1600) / 400 : 0)
138:
139: #define leap_years_since_year_1(yr) ((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
140:
141: /*=============================================================================*/
142: /* CAPA PROTOTYPES FOR FUNCTIONS IN COMMON.C */
143: /*=============================================================================*/
144: /*-----------------------------------------------------------------------------*/
145: int capa_parse CAPA_ARG((int set,Problem_t **problem,char *filename,int *num_questions,void (*func_ptr)()));
146: void send CAPA_ARG((char* text));
147: /*============================================================================*/
148:
149: #endif /* CAPA_COMMON_H */
150:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>