#ifndef SURVEY_H
#define SURVEY_H

#include <time.h>



/* define MAX size of some values */
#define MAX_SURVEY_TITLE 200 


/* define filenames */
#define SURVEY_DIR "surveys"
#define SURVEY_WWW_DIR "_www_"
#define SURVEY_XML_FNAME "survey.xml"
#define SURVEY_RELEASE_FNAME "release.dat"
#define SURVEY_RESULT_FNAME "result.xml"
#define SURVEY_SHARED_FNAME "shared_list"
#define SURVEY_END_TAG "</survey>\n"
#define SURVEY_INFO_END_TAG "</survey_list>\n"
#define SURVEY_INFO_FNAME "survey_info.xml"
#define SURVEY_CLIPBOARD_FNAME "survey_clipboard.xml"
#define SURVEY_DELIVER_INFO_FNAME "deliver_info.dat"
#define SURVEY_RESULT_END_TAG "</records>\n"


/* define tag name for survey_info.xml */
#define SURVEY_LIST_TAG "survey_list"
#define SURVEY_TAG "survey"
#define SURVEY_ID_ATTR "id"
#define SURVEY_TITLE_TAG "title"
#define SURVEY_STATE_TAG "state"
#define SURVEY_CREATE_TIME_TAG "create_time"
#define SURVEY_FINISH_TIME_TAG "finish_time"
#define SURVEY_RELEASE_TIME_TAG "release_time"
#define SURVEY_CLOSE_TIME_TAG "close_time"
#define SURVEY_AUTHOR_TAG "author"
#define SURVEY_AUTHOR_NAME_TAG "author_name"
#define SURVEY_PATH_TAG "survey_domain"
#define SURVEY_STATE_DEV "developing"
#define SURVEY_STATE_FIN "finished"
#define SURVEY_STATE_REL "released"
#define SURVEY_STATE_PUB "public"
#define SURVEY_STATE_SHARED "shared"
#define SURVEY_STATE_WWW "www"
#define SURVEY_STATE_CLO "closed"
#define SURVEY_CDATA_START "<![CDATA["
#define SURVEY_CDATA_END "]]>"





/* CHOICE TAG */
typedef struct ele_choice
{
    char *choice;
    struct ele_choice *next;
}ELE_CHOICE;



typedef struct survey_data
{
   char *tag_name;
   int id;
   char *caption;
   char *steps_bgcolor;    /* for likert tag & title tag*/
   char *left_cols;  /* likert and memo tag */
   char *right_rows; /* likert and memo tag */
   ELE_CHOICE *head;
   ELE_CHOICE *current;
   struct survey_data *next;
}SURVEY_DATA;



typedef struct survey_list
{
    SURVEY_DATA *head;
    SURVEY_DATA *current;
}SURVEY_LIST;

typedef struct survey_info
{
    char *id;              /* directory name - randomly generated */
    char *title;
    char *state;
    char *create_time;
    char *finish_time;
    char *release_time;
    char *close_time;
    char *author_id;
    char *author_name;
    char *survey_domain;     /* full relative path to directory*/
    struct survey_info *next;
}SURVEY_INFO;

typedef struct survey_info_list
{
   SURVEY_INFO *head;
   SURVEY_INFO *current;
}SURVEY_INFO_LIST;




typedef enum {ALL, STUDENTS, TEACHERS, STUDENTS_ONLY} TAKERS;

typedef struct common_survey_record
{ 
    char id[MAX_PATH +1];
    char title[MAX_SURVEY_TITLE +1];
    time_t sent_time;
    time_t release_time;
    time_t unrelease_time;
    time_t results_time;
    int course_count;
    int save_courseinfo;
} COMMON_SURVEY_RECORD;




typedef struct central_survey_record
{
    COMMON_SURVEY_RECORD record;
    TAKERS takers;
}CENTRAL_SURVEY_RECORD;




typedef struct indiv_survey_record
{
    COMMON_SURVEY_RECORD record;
    int store_result;

} INDIV_SURVEY_RECORD;




typedef struct survey_release_record
{
 time_t results_time;   /* when can the teacher see the results? */
 int student_view_results;   /* are students allowed to see the results? */
 int student_view_again;     /* are students allowed to view survey after they take it? */
 int student_answer_required; /* are students required to answer this survey? */
 int future2;
} SURVEY_RELEASE_RECORD;  



/*values for the 'mode' parameters used in several programs
**used to display the survey (survey_page) and to record the
**results (survey_results)
**/

#define MODE_TAKE_MYMANHATTAN         1   /* taking a survey delivered to My Manhattan page via an administrator */
#define MODE_TAKE_WEB_DELIVERED       2   /* taking a survey delivered outside of the Manhattan environment */
#define MODE_TAKE_CLASSROOM_DELIVERED 3   /* taking a survey delivered within a Manhattan classroom */
#define MODE_PREVIEW_PUBLIC           4   /* previewing a 'public' survey */
#define MODE_PREVIEW_PRIVATE          5   /* previewing a survey you own - 'private' */



#endif

