#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <time.h>

#include "ClearSilver.h"
#include "sqlite3.h"
#include "global.h"
#include "custom.h"		/* for date FORMAT strings */
#include "grade.h"		/* for date FORMAT strings */
#include "manhat-lib/shared_util.h"
#include "manhat-lib/shared_grade_book_menu.h"
#include "manhat-lib/shared_file_util.h"

void
read_parameters ( char *course, char *key)
{
     cs_get_required_parameter("crs", course, MAX_PATH);
     cs_get_required_parameter("id", key, MAX_KEY);

}




int
main ()
{
  char course[MAX_PATH +1];
  char key[MAX_KEY +1];
  char path[MAX_PATH +1];

  SESSION user;
  CONFIG_STRUCT conf;
  
  cs_cgi_init();   /* shared_cs_util.h */
  read_parameters ( course, key);
  read_configuration_file (course, &conf);	
  validate_key (key, &user, &conf);	
  
  if(user.group != FACULTY)
       cs_critical_error(ERR_REQUEST_DENIED, "");

   
  cs_set_course_info(&conf);  


  set_grade_book_menu("grade_book_export", key, course); /* shared_grade_book_menu.h */
  cs_load_lang("grade_book_menu_util");
 
  snprintf(path, MAX_PATH +1, "%s%s/%s", conf.course_path, GRADE_BOOK_DIR, GRADE_BOOK_DB);
  if(file_exists(path))
      cs_set_int_value("export_button", 1);

  cs_cgi_display ("grade_book_export", 1);
  cs_cgi_destroy();      

  return 0;			

}




