/* The LearningOnline Network with CAPA * Definitons of the convertor API * $Id: capaCommon.h,v 1.7 2001/12/04 15:17:57 albertel Exp $ * * Copyright Michigan State University Board of Trustees * * This file is part of the LearningOnline Network with CAPA (LON-CAPA). * * LON-CAPA 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. * * LON-CAPA 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 LON-CAPA; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * /home/httpd/html/adm/gpl.txt * * http://www.lon-capa.org/ */ /**********************************************************/ /* 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 #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)) struct dyn_string { int len; int max; char *str; }; struct dyn_string dyn_out; struct dyn_string dyn_delayed; extern int dyn_maxlen; extern char *import_prefix; #define MAX_CACHE 100 #define CACHE_ERROR 100 extern struct dyn_string cached_data[MAX_CACHE]; extern int current_cache; extern int do_cache[MAX_CACHE]; #define MAX_STREAMS 100 #define ALL_STREAMS -1 extern struct dyn_string streams[MAX_STREAMS]; extern int num_streams; int mode[MAX_STREAMS]; #define MODE_NONE 0 #define MODE_COMMENT 1 #define MODE_BLOCK 2 #define MODE_SCRIPT 3 #define MODE_OUTTEXT 4 #define MODE_ANSWER 5 #define MODE_HINT 6 #define MODE_IMPORT 7 /* end_mode always sets this to 0, if you want to check if any other mode has been entered. Set this to 1 and check again if it has been set back to zero. */ extern int watch_mode[MAX_STREAMS]; /*=============================================================================*/ /* CAPA PROTOTYPES FOR FUNCTIONS IN COMMON.C */ /*=============================================================================*/ /*-----------------------------------------------------------------------------*/ int capa_parse(int set,Problem_t **problem,char *filename,int *num_questions,void (*func_ptr)()); void send(char* text,...); void end_mode(void); void end_mode_stream(int which); void start_mode(int newmode,char* args); void start_mode_stream(int which,int newmode,char* args); void dyn_init(struct dyn_string *dyn); void dyn_free(struct dyn_string *dyn); int append_message(struct dyn_string *dyn_msg,char *format,va_list ap); void add_delayed(char *format, ...); void flush_delayed(); void start_delayed(); void end_delayed(); void send_stream(int which,char* text,...); void start_streams(int num); void end_streams(int which); void new_cache(); void delete_cache(); void start_cache(); void stop_cache(); /*============================================================================*/ #endif /* CAPA_COMMON_H */