[svn r17257] minor - logic changes - edit all weights in my gradebook tool - (partial FS#3319)

skala
Isaac Flores 16 years ago
parent e145cd5410
commit b72247fd68
  1. 13
      main/gradebook/gradebook_edit_all.php
  2. 10
      main/gradebook/lib/fe/gradebooktable.class.php
  3. 5
      main/gradebook/lib/gradebook_functions.inc.php

@ -1,4 +1,4 @@
<?php // $Id: $ <?php
/* /*
============================================================================== ==============================================================================
Dokeos - elearning and course management software Dokeos - elearning and course management software
@ -36,8 +36,7 @@ require_once ('lib/fe/gradebooktable.class.php');
require_once ('lib/fe/displaygradebook.php'); require_once ('lib/fe/displaygradebook.php');
api_block_anonymous_users(); api_block_anonymous_users();
if (!api_is_allowed_to_create_course()) {
if (!api_is_allowed_to_edit()) {
header('Location: /index.php'); header('Location: /index.php');
} }
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
@ -74,7 +73,9 @@ if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
$table_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); $table_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION); $table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$table_forum_thread=Database::get_course_table(TABLE_FORUM_THREAD); //$table_forum_thread=Database::get_course_table(TABLE_FORUM_THREAD);
$my_db_name=name_database_by_link($_GET['selectcat']);
$table_forum_thread = Database :: get_course_table(TABLE_FORUM_THREAD,$my_db_name);
/* /*
if($_SERVER['REQUEST_METHOD']=='POST'): if($_SERVER['REQUEST_METHOD']=='POST'):
foreach($_POST['link'] as $key => $value){ foreach($_POST['link'] as $key => $value){
@ -124,11 +125,11 @@ $output='';
$sql='SELECT * FROM '.$table_link.' WHERE category_id = '.$category_id; $sql='SELECT * FROM '.$table_link.' WHERE category_id = '.$category_id;
$result = api_sql_query($sql,__FILE__,__LINE__); $result = api_sql_query($sql,__FILE__,__LINE__);
while($row = Database ::fetch_array($result)){ while($row = Database ::fetch_array($result)){
//update only if value changed //update only if value changed
if(isset($_POST['link'][$row['id']]) && $_POST['link'][$row['id']] != $row['weight']) { if(isset($_POST['link'][$row['id']]) && $_POST['link'][$row['id']] != $row['weight']) {
api_sql_query('UPDATE '.$table_link.' SET weight = '."'".trim($_POST['link'][$row['id']])."'".' WHERE id = '.$row['id'],__FILE__,__LINE__); api_sql_query('UPDATE '.$table_link.' SET weight = '."'".trim($_POST['link'][$row['id']])."'".' WHERE id = '.$row['id'],__FILE__,__LINE__);
api_sql_query('UPDATE '.$table_forum_thread.' SET thread_weight='.$_POST['link'][$row['id']].' WHERE thread_id='.$row['ref_id']); $sql='UPDATE '.$table_forum_thread.' SET thread_weight='.$_POST['link'][$row['id']].' WHERE thread_id='.$row['ref_id'];
api_sql_query($sql);
AbstractLink::add_link_log($row['id']); AbstractLink::add_link_log($row['id']);
$row['weight'] = trim($_POST['link'][$row['id']]); $row['weight'] = trim($_POST['link'][$row['id']]);
} }

@ -180,7 +180,13 @@ class GradebookTable extends SortableTable
//admins get an edit column //admins get an edit column
if (api_is_allowed_to_create_course() && ($_SESSION['studentview']<>'studentview' || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='false'))) { if (api_is_allowed_to_create_course() && ($_SESSION['studentview']<>'studentview' || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='false'))) {
$row[] = $this->build_edit_column ($item); $cat=new Category();
$show_message=$cat->show_message_resource_delete($item->get_course_code());
if ($show_message===false) {
$row[] = $this->build_edit_column ($item);
}
} else { } else {
//students get the results and certificates columns //students get the results and certificates columns
if (count($this->evals_links)>0) { if (count($this->evals_links)>0) {
@ -261,7 +267,7 @@ private function build_id_column ($item) {
. '<a href="gradebook_view_result.php?selecteval=' . $item->get_id() . '">' . '<a href="gradebook_view_result.php?selecteval=' . $item->get_id() . '">'
. $item->get_name() . $item->get_name()
. '</a>&nbsp;['.get_lang('Evaluation').']'; . '</a>&nbsp;['.get_lang('Evaluation').']';
} elseif (ScoreDisplay :: instance()->is_custom()) { } elseif (ScoreDisplay :: instance()->is_custom() && $show_message===false) {
// students can go to the statistics page (if custom display enabled) // students can go to the statistics page (if custom display enabled)
return '&nbsp;' return '&nbsp;'
. '<a href="gradebook_statistics.php?selecteval=' . $item->get_id() . '">' . '<a href="gradebook_statistics.php?selecteval=' . $item->get_id() . '">'

@ -185,7 +185,6 @@ function build_edit_icons_cat($cat, $selectcat) {
if ($show_message===false) { if ($show_message===false) {
$visibility_icon= ($cat->is_visible() == 0) ? 'invisible' : 'visible'; $visibility_icon= ($cat->is_visible() == 0) ? 'invisible' : 'visible';
$visibility_command= ($cat->is_visible() == 0) ? 'set_visible' : 'set_invisible'; $visibility_command= ($cat->is_visible() == 0) ? 'set_visible' : 'set_invisible';
$modify_icons= '<a href="gradebook_edit_cat.php?editcat=' . $cat->get_id() . '"><img src="../img/edit.gif" border="0" title="' . get_lang('Modify') . '" alt="" /></a>'; $modify_icons= '<a href="gradebook_edit_cat.php?editcat=' . $cat->get_id() . '"><img src="../img/edit.gif" border="0" title="' . get_lang('Modify') . '" alt="" /></a>';
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deletecat=' . $cat->get_id() . '&amp;selectcat=' . $selectcat . '" onclick="return confirmation();"><img src="../img/delete.gif" border="0" title="' . get_lang('DeleteAll') . '" alt="" /></a>'; $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deletecat=' . $cat->get_id() . '&amp;selectcat=' . $selectcat . '" onclick="return confirmation();"><img src="../img/delete.gif" border="0" title="' . get_lang('DeleteAll') . '" alt="" /></a>';
@ -315,7 +314,7 @@ function name_database_by_link($id_link) {
$course_table = Database::get_main_table(TABLE_MAIN_COURSE); $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$res=api_sql_query('SELECT db_name from '.$course_table.' c inner join '.$tbl_grade_links.' l $res=api_sql_query('SELECT db_name from '.$course_table.' c inner join '.$tbl_grade_links.' l
on c.code=l.course_code WHERE l.id='.$id_link); on c.code=l.course_code WHERE l.id='.$id_link.' OR l.category_id='.$id_link);
$my_db_name=Database::fetch_array($res,'ASSOC'); $my_db_name=Database::fetch_array($res,'ASSOC');
return $my_db_name['db_name']; return $my_db_name['db_name'];
} }

Loading…
Cancel
Save