Annotation of capa/capa51/pProj/capaCommon.h, revision 1.3
1.3 ! albertel 1: /* This header defines Application Interface to the
! 2: CAPA system. It needs capaParser.h and capaToken.h
! 3: Copyright (C) 1992-2000 Michigan State University
! 4:
! 5: The CAPA system is free software; you can redistribute it and/or
! 6: modify it under the terms of the GNU Library General Public License as
! 7: published by the Free Software Foundation; either version 2 of the
! 8: License, or (at your option) any later version.
! 9:
! 10: The CAPA system is distributed in the hope that it will be useful,
! 11: but WITHOUT ANY WARRANTY; without even the implied warranty of
! 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! 13: Library General Public License for more details.
! 14:
! 15: You should have received a copy of the GNU Library General Public
! 16: License along with the CAPA system; see the file COPYING. If not,
! 17: write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
! 18: Boston, MA 02111-1307, USA. */
1.1 albertel 19:
20: /* Date Oct 23 1995 */
21: /* Isaac Tsai */
22: /* */
23: /* Get rid of old style structure definition *_t */
24: /* Make all structure definition begin with T_ */
25: /* 1997, 1998, 1999 Isaac Tsai */
26: /**********************************************************/
27:
28: #ifndef CAPA_COMMON_H
29: #define CAPA_COMMON_H
30:
31: #include <stdio.h>
32: #ifdef linux
33: #include <stdlib.h>
34: #endif
35: #ifdef NeXT
36: #include <stdlib.h>
37: #include <libc.h>
38: #else
39: #include <malloc.h>
40: #include <unistd.h>
41: #endif
42:
43: #include <math.h>
44: #include <string.h>
45: #include <time.h>
46: #include <sys/fcntl.h> /* lockf() */
47: #include <sys/file.h> /* flock() */
48: #include <sys/types.h>
49: #include "capaParser.h"
50:
51: #ifndef MAX
52: #define MAX(a,b) ((a>b)? (a):(b))
53: #endif
54:
55: #define MAX_SECTION_SIZE 10240 /* Max # of students in the class */
56: #define MAX_SECTION_COUNT 1024
57: #define MAX_NAME_CHAR 30 /* Student's name max length */
58: #define MAX_STUDENT_NUMBER 9 /* Student Number length */
59: #define MAX_EMAIL_CHAR 40 /* Email address */
60: #define FILE_NAME_LENGTH 1024
61: #define MAX_PIN_CHAR 4
62: #define MAX_BUFFER_SIZE 2048
63: #define TMP_LINE_LENGTH 2048 /* used to read in log.db set.db dates.db */
64: #define SMALL_LINE_BUFFER 128 /* used to read classl, active.db */
65: #define SETDB_BUF_SIZE (256*1024)
66: /* user input string length now in capaParser.h*/
67: /*#define ANSWER_STRING_LENG 81*/
68: /*#define UNIT_STRING_LENG 64*/
69: #define FORMAT_STRING_LENG 32
70:
71: /* -------- used in check_date() */
72: #define CHECK_OPEN_DATE 1
73: #define CHECK_DUE_DATE 2
74: #define CHECK_ANS_DATE 3
75:
76:
77:
78: /******************************************************************************/
79: /* STRUCTURE FOR THE HEADER OF A DATABASE FILE */
80: /******************************************************************************/
81:
82: typedef struct {
83: char num_questions[FORMAT_STRING_LENG];
84: char *weight;
85: char *partial_credit;
86: } T_header;
87:
88: /******************************************************************************/
89: /* STRUCTURE FOR A NORMAL DATABASE FILE ENTRY */
90: /******************************************************************************/
91:
92: typedef struct {
93: char student_number[MAX_STUDENT_NUMBER+1]; /* Student number */
94: int e_probs;
95: char *answers; /* String of answers */
96: char *tries;
97: } T_entry;
98:
99: /******************************************************************************/
100: /* STRUCTURE FOR A STUDENT IN THE STUDENT ARRAY */
101: /******************************************************************************/
102:
103: typedef struct _student {
104: struct _student *s_next;
105: struct _student *s_prev;
106: int s_sec;
107: int s_scores;
108: char s_key[MAX_NAME_CHAR+MAX_NAME_CHAR+2]; /* sorting key */
109: char s_sn[MAX_STUDENT_NUMBER+1];
110: char s_nm[MAX_NAME_CHAR+1];
111: char s_email[MAX_EMAIL_CHAR+1];
112: int s_capaid;
113: } T_student;
114:
115: /******************************************************************************/
116: /* STRUCTURE FOR Login dates for a set */
117: /******************************************************************************/
118: /*section number DATE_DEFAULTs contains the default dates an assignment is due*/
119: #define DATE_DEFAULTS 0
120: #define OPEN_OFFSET 0
121: #define DUE_OFFSET 17
122: #define ANSWER_OFFSET 34
123: #define DATE_LENGTH 16
124: #define DATE_BUFFER 17
125: #define OPTION_INHIBIT_RESPONSE 100
126: #define OPTION_VIEW_PROBLEMS_AFTER_DUE 101
127: typedef struct _date {
128: struct _date *s_next;
129: int section_start;
130: int section_end;
131: char open_date[DATE_BUFFER];
132: char due_date[DATE_BUFFER];
133: char answer_date[DATE_BUFFER];
134: char duration[DATE_BUFFER];
135: int inhibit_response;
136: int view_problems_after_due;
137: } T_dates;
138:
139: /******************************************************************************/
140: /* STRUCTURE FOR Login history for a student */
141: /******************************************************************************/
142: typedef struct {
143: int count; /* Number of questions */
144: char *answers; /* String of answers */
145: } login_history_t;
146:
147: #define leap_year(yr) ((yr) <= 1752 ? !((yr) % 4) : !((yr) % 4) && (((yr) % 100) || !((yr) % 400)))
148:
149: #define centuries_since_1700(yr) ((yr) > 1700 ? (yr) / 100 - 17 : 0)
150:
151: #define quad_centuries_since_1700(yr) ((yr) > 1600 ? ((yr) - 1600) / 400 : 0)
152:
153: #define leap_years_since_year_1(yr) ((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
154:
155: /*=============================================================================*/
156: /* CAPA PROTOTYPES FOR FUNCTIONS IN COMMON.C */
157: /*=============================================================================*/
158: /*-----------------------------------------------------------------------------*/
159: int capa_get_section CAPA_ARG((T_student **student_pp, int section));
160: int capa_sorted_section CAPA_ARG((T_student **student_pp, int section));
161: void msort_main CAPA_ARG((T_student **head_pp));
162: void msort_split CAPA_ARG((T_student *a_sp, T_student **b_pp));
163: void msort_merge CAPA_ARG((T_student *a_sp, T_student *b_sp, T_student **c_pp));
164: int capa_get_student CAPA_ARG((char *student_number,T_student *student_p));
165: int capa_student_byname CAPA_ARG((char *student_name,T_student *student_p));
166: int capa_pick_student CAPA_ARG((int section, T_student *student_p));
167: int capa_add_student CAPA_ARG((T_student *student_p));
168: int capa_parse CAPA_ARG((int set,Problem_t **problem,char *student_number,int *num_questions,void (*func_ptr)()));
169: int capa_parse_student CAPA_ARG((int set,Problem_t **problem,T_student *astudent,int *num_questions,void (*func_ptr)()));
170: void free_problems CAPA_ARG((Problem_t *problem_p));
171: void free_students CAPA_ARG((T_student *student_p));
172: void free_units CAPA_ARG(());
173: int read_capa_config CAPA_ARG((char* key_word, char *value));
174: int capa_access CAPA_ARG((const char *pathname, int mode));
175: /*-----------------------------------------------------------------------------*/
176: void capa_seed CAPA_ARG((long *seed1, long *seed2, char *student_number));
177: int capa_PIN CAPA_ARG((char *student_number, int set, int guess));
178: char* capa_id_plus CAPA_ARG((char *student_number, int set, int plus));
179: int capa_set_header CAPA_ARG((T_header *header, int set));
180: int capa_get_header CAPA_ARG((T_header *header, int set));
181:
182: int capa_set_entry CAPA_ARG((T_entry *entry, char *student_number, int set, long offset));
183: int capa_change_entry CAPA_ARG((T_entry *entry, char *student_number, int set));
184: long capa_append_entry CAPA_ARG((T_entry *entry, char *student_number, int set));
185: long capa_get_entry CAPA_ARG((T_entry *entry, char *student_number, int set));
186: int capa_excuse CAPA_ARG((int set, int prob, int section));
187: int capa_get_score CAPA_ARG((char *student_number, int set, int *valid_scores, char **answers_pp));
188: char* capa_get_seat CAPA_ARG((char *studentnum, char *seatfile));
189: /*-----------------------------------------------------------------------------*/
190: int capa_get_login_count CAPA_ARG((char *student_number,int set));
191: int capa_get_login_db CAPA_ARG((T_entry *login_item,int *num_probs,int set));
192: int capa_get_section_count CAPA_ARG((int *cnt_arry));
193: int login_check CAPA_ARG((char *student_number));
194: int logout_check CAPA_ARG((char *student_number));
195: /*-----------------------------------------------------------------------------*/
196: int flockstream_sh CAPA_ARG((FILE *fp));
197: int flockstream CAPA_ARG((FILE *fp));
198: int funlockstream CAPA_ARG((FILE *fp));
199: /*-----------------------------------------------------------------------------*/
200: time_t convertTime CAPA_ARG((char *dateStr,char *timeStr));
201: int weekday CAPA_ARG((int year, int month, int day));
202: int julianday CAPA_ARG((int year, int month, int day));
203: /*int compare_datetime CAPA_ARG((time_t time,char *datetime));*/
204: int capa_check_date CAPA_ARG((int which,char *student_number,int section,int set));
205: int capa_get_date CAPA_ARG((int which,char *student_number,int section,int set,char *date_str));
206: void free_dates CAPA_ARG((T_dates *dates));
207: int capa_get_all_dates CAPA_ARG((int set, T_dates **dates));
208: int capa_set_all_dates CAPA_ARG((int set, T_dates *dates));
209: int capa_get_section_dates CAPA_ARG((int section,int set,T_dates** dates));
210: T_dates* add_date_info CAPA_ARG((int lowsec,int highsec, char *dateinfo));
211: int capa_get_login_time CAPA_ARG((char *student_number,int set,time_t *logintime));
212: int capa_set_login_time CAPA_ARG((char *student_number,int set));
213: int capa_get_duration CAPA_ARG((char *student_number,int section,int set));
214: int capa_check_option CAPA_ARG((int option,int set,int section));
215: int check_int CAPA_ARG((char *an_int ));
216: int check_real CAPA_ARG((char *a_real ));
217: char *answers_string CAPA_ARG((int mode, Problem_t *p ));
1.2 albertel 218: int capa_check_ans CAPA_ARG((AnswerInfo_t *ai, char *answer, char **error));
219: int capa_check_answer CAPA_ARG((Problem_t *p, char *answer, char **error));
220: int capa_check_answers CAPA_ARG((Problem_t *p, char **answers,int cnt, char **error));
1.1 albertel 221: int check_formula_ans CAPA_ARG((char *fml_str,char *input_str,char *var_list,PointsList_t *pts_list,int tol_type,double tol));
222:
223: int is_all_ws CAPA_ARG((char *answer));
224: void trim_response_ws CAPA_ARG((char *answer));
225: void throwaway_line CAPA_ARG((FILE* fp));
226: void protect_log_string CAPA_ARG((char* log_string));
227: int calc_ansrange CAPA_ARG((int type,int calc_type,char *input,char *fmt,int tol_type,double tol,char *lower,char *upper));
228: /*-----------------------------------------------------------------------------*/
229: int capa_set_subjective CAPA_ARG((int set,int problem,char *student_num,char* response));
230: char* capa_get_subjective CAPA_ARG((int set,int problem,char *student_num));
231: /*============================================================================*/
232:
233: #endif /* CAPA_COMMON_H */
234:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>