#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_grade_book_util.h"
#include "manhat-lib/shared_grade_book_db.h"


void
read_parameters ( char *course, char *key, int *cat_id)
{
     char temp[MAX_KEY +1];

     cs_get_required_parameter("crs", course, MAX_PATH);
     cs_get_required_parameter("id", key, MAX_KEY);
     cs_get_required_parameter("cat_id", temp, MAX_KEY);
     *cat_id = atoi(temp);

}




void
do_action(CONFIG_STRUCT *conf, int cat_id)
{
   
    get_cat_members(conf, cat_id, GRADE_BOOK_DB);   /* shared_grade_book_db.h */
    set_item_list_values(1, 0);   /* shared_grade_book_util.h */
    free_item_list(global_item_list);  /* shared_grade_book_util.h */
    cs_set_int_value("cat_members", 1);
    
	 
}

int
main ()
{
  char course[MAX_PATH +1];
  char key[MAX_KEY +1];
  int cat_id;
  SESSION user;
  CONFIG_STRUCT conf;
  
  cs_cgi_init();   /* shared_cs_util.h */
  read_parameters ( course, key, &cat_id);
  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_categories", key, course); /* shared_grade_book_menu.h */
  cs_load_lang("grade_book_menu_util");
  do_action(&conf, cat_id);
  cs_cgi_display ("grade_book_items", 1);
  cs_cgi_destroy();      

  return 0;			

}




