Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chamilo-lms/main/gradebook/gradebook_edit_link.php

63 lines
2.8 KiB

<?php
/* For licensing terms, see /license.txt */
$language_file = array('gradebook','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();
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
//selected name of database
$my_db_name=get_database_name_by_link_id(Security::remove_XSS($_GET['editlink']));
$tbl_forum_thread = Database :: get_course_table(TABLE_FORUM_THREAD,$my_db_name);
$tbl_work = Database :: get_course_table(TABLE_STUDENT_PUBLICATION,$my_db_name);
$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE,$my_db_name);
$linkarray = LinkFactory :: load(Security::remove_XSS($_GET['editlink']));
$link = $linkarray[0];
$linkcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']):'';
$linkedit = isset($_GET['editlink']) ? Security::remove_XSS($_GET['editlink']):'';
$form = new LinkAddEditForm(LinkAddEditForm :: TYPE_EDIT,
null,
null,
$link,
'edit_link_form',
api_get_self() . '?selectcat=' . $linkcat
. '&editlink=' . $linkedit);
if ($form->validate()) {
$values = $form->exportValues();
$link->set_weight($values['weight']);
$link->set_visible(empty ($values['visible']) ? 0 : 1);
$link->save();
//Update weight for attendance
$sql = 'SELECT ref_id FROM '.$tbl_grade_links.' WHERE id = '.intval($_GET['editlink']).' AND type='.LINK_ATTENDANCE;
$rs_attendance = Database::query($sql);
if (Database::num_rows($rs_attendance) > 0) {
$row_attendance = Database::fetch_array($rs_attendance);
$attendance_id = $row_attendance['ref_id'];
$upd_attendance = 'UPDATE '.$tbl_attendance.' SET attendance_weight ='.floatval($values['weight']).' WHERE id = '.intval($attendance_id);
Database::query($upd_attendance);
}
//Update weight into forum thread
$sql_t='UPDATE '.$tbl_forum_thread.' SET thread_weight='.$values['weight'].' WHERE thread_id=(SELECT ref_id FROM '.$tbl_grade_links.' where id='.intval($_GET['editlink']).' and type=5);';
Database::query($sql_t);
//Update weight into student publication(work)
$sql_t='UPDATE '.$tbl_work.' SET weight='.$values['weight'].' WHERE id=(SELECT ref_id FROM '.$tbl_grade_links.' where id='.intval($_GET['editlink']).' and type=3);';
Database::query($sql_t);
header('Location: '.$_SESSION['gradebook_dest'].'?linkedited=&selectcat=' . $link->get_category_id());
exit;
}
$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.$linkcat,'name' => get_lang('Gradebook'));
Display :: display_header(get_lang('EditLink'));
$form->display();
Display :: display_footer();