*/
/**
 * Init
 */
$language_file = array('gradebook', 'exercice', 'link');
//$cidReset = true;
//require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/linkform.class.php';
require_once 'lib/fe/linkaddeditform.class.php';
api_block_anonymous_users();
block_students();
$tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
//selected name of database
$course_id = get_course_id_by_link_id($_GET['editlink']);
$tbl_forum_thread = Database::get_course_table(TABLE_FORUM_THREAD);
$tbl_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
$linkarray = LinkFactory::load($_GET['editlink']);
$link = $linkarray[0];
if ($link->is_locked() && !api_is_platform_admin()) {
    api_not_allowed();
}
$linkcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : '';
$linkedit = isset($_GET['editlink']) ? Security::remove_XSS($_GET['editlink']) : '';
$session_id = api_get_session_id();
if ($session_id == 0) {
    $cats = Category::load(null, null, $course_code, null, null, $session_id, false);
    //already init
} else {
}
// 	DISPLAY HEADERS AND MESSAGES
if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
    if (isset($_GET['studentoverview'])) {
        $interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . $my_selectcat, 'name' => get_lang('Gradebook'));
        Display::display_header(get_lang('FlatView'));
    } elseif (isset($_GET['search'])) {
        $interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . $my_selectcat, 'name' => get_lang('Gradebook'));
        Display::display_header(get_lang('SearchResults'));
    } else {
        $interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=1', 'name' => get_lang('Gradebook'));
        $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('EditAllWeights'));
        Display::display_header('');
    }
}
$course_id = get_course_id_by_link_id($my_selectcat);
$table_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$tbl_forum_thread = Database::get_course_table(TABLE_FORUM_THREAD);
$tbl_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
$table_evaluated[LINK_EXERCISE] = array(TABLE_QUIZ_TEST, 'title', 'id', get_lang('Exercise'));
$table_evaluated[LINK_DROPBOX] = array(TABLE_DROPBOX_FILE, 'name', 'id', get_lang('Dropbox'));
$table_evaluated[LINK_STUDENTPUBLICATION] = array(TABLE_STUDENT_PUBLICATION, 'url', 'id', get_lang('Student_publication'));
$table_evaluated[LINK_LEARNPATH] = array(TABLE_LP_MAIN, 'name', 'id', get_lang('Learnpath'));
$table_evaluated[LINK_FORUM_THREAD] = array(TABLE_FORUM_THREAD, 'thread_title_qualify', 'thread_id', get_lang('Forum'));
$table_evaluated[LINK_ATTENDANCE] = array(TABLE_ATTENDANCE, 'attendance_title_qualify', 'id', get_lang('Attendance'));
$table_evaluated[LINK_SURVEY] = array(TABLE_SURVEY, 'code', 'survey_id', get_lang('Survey'));
$submitted = isset($_POST['submitted']) ? $_POST['submitted'] : '';
if ($submitted == 1) {
    Display::display_confirmation_message(get_lang('GradebookWeightUpdated')) . '<br /><br />';