$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); } $form = new LinkAddEditForm(LinkAddEditForm::TYPE_EDIT, $cats, null, $link, 'edit_link_form', api_get_self() . '?selectcat=' . $linkcat . '&editlink=' . $linkedit . '&' . api_get_cidreq()); if ($form->validate()) { $values = $form->exportValues(); $parent_cat = Category::load($values['select_gradebook']); $final_weight = null; /* if ($parent_cat[0]->get_parent_id() == 0) { $final_weight = $values['weight_mask']; } else { $cat = Category :: load($parent_cat[0]->get_parent_id()); $global_weight = $cat[0]->get_weight(); $final_weight = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight(); }*/ $final_weight = $values['weight_mask']; $link->set_weight($final_weight); if (!empty($values['select_gradebook'])) {
} else { $all_categories = Category::load_session_categories(null, $session_id); } $category = Category::load($_GET['selectcat']); $url = api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&newtypeselected=' . $typeSelected . '&course_code=' . api_get_course_id() . '&' . api_get_cidreq(); $typeform = new LinkForm(LinkForm::TYPE_CREATE, $category[0], null, 'create_link', null, $url, $typeSelected); // if user selected a link type if ($typeform->validate() && isset($_GET['newtypeselected'])) { // reload page, this time with a parameter indicating the selected type header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&typeselected=' . $typeform->exportValue('select_link') . '&course_code=' . Security::remove_XSS($_GET['course_code']) . '&' . api_get_cidreq()); exit; } // link type selected, show 2nd form to retrieve the link data if (isset($typeSelected) && $typeSelected != '0') { $url = api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&typeselected=' . $typeSelected . '&course_code=' . $courseCode . '&' . api_get_cidreq(); $addform = new LinkAddEditForm(LinkAddEditForm::TYPE_ADD, $all_categories, $typeSelected, null, 'add_link', $url); if ($addform->validate()) { $addvalues = $addform->exportValues(); $link = LinkFactory::create($typeSelected); $link->set_user_id(api_get_user_id()); $link->set_course_code(api_get_course_id()); $link->set_category_id($addvalues['select_gradebook']); if ($link->needs_name_and_description()) { $link->set_name($addvalues['name']); } else { $link->set_ref_id($addvalues['select_link']); } $parent_cat = Category::load($addvalues['select_gradebook']); $global_weight = $category[0]->get_weight(); $link->set_weight($addvalues['weight_mask']); if ($link->needs_max()) {