Annotation of loncom/homework/CAPA-converter/capaCommon.h, revision 1.3
1.1 albertel 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>
1.2 albertel 35: #include <stdarg.h>
1.1 albertel 36: #include "capaParser.h"
37:
38: #ifndef MAX
39: #define MAX(a,b) ((a>b)? (a):(b))
40: #endif
41:
42: #define MAX_SECTION_SIZE 10240 /* Max # of students in the class */
43: #define MAX_SECTION_COUNT 1024
44: #define MAX_NAME_CHAR 30 /* Student's name max length */
45: #define MAX_STUDENT_NUMBER 9 /* Student Number length */
46: #define MAX_EMAIL_CHAR 40 /* Email address */
47: #define FILE_NAME_LENGTH 1024
48: #define MAX_PIN_CHAR 4
49: #define MAX_BUFFER_SIZE 2048
50: #define TMP_LINE_LENGTH 2048 /* used to read in log.db set.db dates.db */
51: #define SMALL_LINE_BUFFER 128 /* used to read classl, active.db */
52: #define SETDB_BUF_SIZE (256*1024)
53: /* user input string length now in capaParser.h*/
54: /*#define ANSWER_STRING_LENG 81*/
55: /*#define UNIT_STRING_LENG 64*/
56: #define FORMAT_STRING_LENG 32
57:
58: /* -------- used in check_date() */
59: #define CHECK_OPEN_DATE 1
60: #define CHECK_DUE_DATE 2
61: #define CHECK_ANS_DATE 3
62:
63:
64:
65: /******************************************************************************/
66: /* STRUCTURE FOR THE HEADER OF A DATABASE FILE */
67: /******************************************************************************/
68:
69: typedef struct {
70: char num_questions[FORMAT_STRING_LENG];
71: char *weight;
72: char *partial_credit;
73: } T_header;
74:
75: /******************************************************************************/
76: /* STRUCTURE FOR A NORMAL DATABASE FILE ENTRY */
77: /******************************************************************************/
78:
79: typedef struct {
80: char student_number[MAX_STUDENT_NUMBER+1]; /* Student number */
81: int e_probs;
82: char *answers; /* String of answers */
83: char *tries;
84: } T_entry;
85:
86: /******************************************************************************/
87: /* STRUCTURE FOR A STUDENT IN THE STUDENT ARRAY */
88: /******************************************************************************/
89:
90: typedef struct _student {
91: struct _student *s_next;
92: struct _student *s_prev;
93: int s_sec;
94: int s_scores;
95: char s_key[MAX_NAME_CHAR+MAX_NAME_CHAR+2]; /* sorting key */
96: char s_sn[MAX_STUDENT_NUMBER+1];
97: char s_nm[MAX_NAME_CHAR+1];
98: char s_email[MAX_EMAIL_CHAR+1];
99: int s_capaid;
100: } T_student;
101:
102: /******************************************************************************/
103: /* STRUCTURE FOR Login dates for a set */
104: /******************************************************************************/
105: /*section number DATE_DEFAULTs contains the default dates an assignment is due*/
106: #define DATE_DEFAULTS 0
107: #define OPEN_OFFSET 0
108: #define DUE_OFFSET 17
109: #define ANSWER_OFFSET 34
110: #define DATE_LENGTH 16
111: #define DATE_BUFFER 17
112: #define OPTION_INHIBIT_RESPONSE 100
113: #define OPTION_VIEW_PROBLEMS_AFTER_DUE 101
114: typedef struct _date {
115: struct _date *s_next;
116: int section_start;
117: int section_end;
118: char open_date[DATE_BUFFER];
119: char due_date[DATE_BUFFER];
120: char answer_date[DATE_BUFFER];
121: char duration[DATE_BUFFER];
122: int inhibit_response;
123: int view_problems_after_due;
124: } T_dates;
125:
126: /******************************************************************************/
127: /* STRUCTURE FOR Login history for a student */
128: /******************************************************************************/
129: typedef struct {
130: int count; /* Number of questions */
131: char *answers; /* String of answers */
132: } login_history_t;
133:
134: #define leap_year(yr) ((yr) <= 1752 ? !((yr) % 4) : !((yr) % 4) && (((yr) % 100) || !((yr) % 400)))
135:
136: #define centuries_since_1700(yr) ((yr) > 1700 ? (yr) / 100 - 17 : 0)
137:
138: #define quad_centuries_since_1700(yr) ((yr) > 1600 ? ((yr) - 1600) / 400 : 0)
139:
140: #define leap_years_since_year_1(yr) ((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
141:
1.3 ! albertel 142: int mode;
! 143: #define MODE_NONE 0
! 144: #define MODE_COMMENT 1
! 145: #define MODE_BLOCK 2
! 146: #define MODE_SCRIPT 3
! 147: #define MODE_OUTTEXT 4
! 148:
! 149: struct dyn_string {
! 150: int len;
! 151: int max;
! 152: char *str;
! 153: };
! 154: struct dyn_string dyn_out;
! 155: struct dyn_string dyn_delayed;
! 156: extern int dyn_maxlen;
1.1 albertel 157: /*=============================================================================*/
158: /* CAPA PROTOTYPES FOR FUNCTIONS IN COMMON.C */
159: /*=============================================================================*/
160: /*-----------------------------------------------------------------------------*/
161: int capa_parse CAPA_ARG((int set,Problem_t **problem,char *filename,int *num_questions,void (*func_ptr)()));
1.2 albertel 162: void send CAPA_ARG((char* text,...));
1.3 ! albertel 163: void end_mode CAPA_ARG((void));
! 164: void start_mode CAPA_ARG((int newmode,char* args));
! 165: void dyn_init();
! 166: void dyn_free();
! 167: int append_message(struct dyn_string *dyn_msg,char *format,va_list ap);
! 168: void add_dealyed(char *format, ...);
! 169: void flush_delayed();
! 170: void start_delayed();
! 171: void end_delayed();
1.1 albertel 172: /*============================================================================*/
173:
174: #endif /* CAPA_COMMON_H */
175:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>