#include "shared_grade_book_menu.h"

void set_one_menu(const char *key, const char *crs, const char *program, const char *current_program)
{
      #define MAX_CS_NAME 50
      char url[MAX_URL +1];
      char name[MAX_CS_NAME];

      snprintf(name, MAX_CS_NAME, "gmenu.%s.url", program);
      snprintf(url, MAX_URL +1, "%s?crs=%s&amp;id=%s", program, crs, key);
      cs_set_value(name, url);

      if(strcmp(current_program, "grade_book") == 0)
          cs_set_int_value("current_is_grade_book", 1);
      
      if(strcmp(current_program, program) == 0)
      {
          snprintf(name, MAX_CS_NAME, "gmenu.%s.current", program);
          cs_set_int_value(name, 1);
          	    
      }

      #undef MAX_CS_NAME 

}


void set_grade_book_menu(const char *current_program, const char *key, const char *crs)
{

    
    char url[MAX_URL +1];
    snprintf(url, MAX_URL +1, "%s?crs=%s&amp;id=%s", "main_menu", crs, key);
    cs_set_value("back_url", url);

    set_one_menu(key, crs, "grade_book", current_program);
    set_one_menu(key, crs, "grade_book_items", current_program);
    set_one_menu(key, crs, "grade_book_categories", current_program);
    set_one_menu(key, crs, "grade_book_final", current_program);
    set_one_menu(key, crs, "grade_book_release", current_program);
    set_one_menu(key, crs, "grade_book_export", current_program);
      


}



