<?php

/* For licensing terms, see /license.txt */
/**
 * Script
 * @package chamilo.gradebook
 */
//$cidReset = true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
GradebookUtils::block_students();
$tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
//selected name of database
$course_id = GradebookUtils::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 {
    $cats = Category::load_session_categories(null, $session_id);
}
 */
$cidReset = true;
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script(true);
api_block_anonymous_users();
if (!api_is_allowed_to_edit()) {
    header('Location: /index.php');
    exit;
}
$my_selectcat = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : '';
if (empty($my_selectcat)) {
    api_not_allowed();
}
$course_id = GradebookUtils::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 />';