Should fix bug when teacher decides to share the student assignments see #4528

skala
Julio Montoya 13 years ago
parent 37dc8f282e
commit 4371b9822b
  1. 3
      main/inc/lib/main_api.lib.php
  2. 2
      main/inc/local.inc.php
  3. 7
      main/work/download.php
  4. 40
      main/work/work.lib.php

@ -1177,6 +1177,7 @@ function api_get_course_info($course_code = null) {
$_course['department_name'] = $course_data['department_name'];
$_course['department_url'] = $course_data['department_url' ];
$_course['legal_agreement'] = $course_data['legal_agreement' ];
$_course['show_score'] = $course_data['show_score']; //used in the work tool
// The real_id is an integer. It is mandatory for future implementations.
$_course['real_id' ] = $course_data['id' ];
@ -1251,6 +1252,8 @@ function api_get_course_info_by_id($id = null) {
$_course['title' ] = $course_data['title' ];
$_course['course_language'] = $course_data['course_language'];
$_course['activate_legal'] = $course_data['activate_legal'];
$_course['legal_agreement'] = $course_data['legal_agreement'];
$_course['show_score'] = $course_data['show_score']; //used in the work tool
if (file_exists(api_get_path(SYS_COURSE_PATH).$course_data['directory'].'/course-pic85x85.png')) {
$url_image = api_get_path(WEB_COURSE_PATH).$course_data['directory'].'/course-pic85x85.png';

@ -723,6 +723,8 @@ if (isset($cidReset) && $cidReset) {
$_course['subscribe_allowed'] = $course_data['subscribe'];
$_course['unubscribe_allowed'] = $course_data['unsubscribe'];
$_course['activate_legal'] = $course_data['activate_legal'];
$_course['legal_agreement'] = $course_data['legal_agreement'];
$_course['show_score'] = $course_data['show_score']; //used in the work tool
api_session_register('_cid');
api_session_register('_course');

@ -33,7 +33,6 @@ if (empty($course_info)) {
api_not_allowed(true);
}
$tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
if (!empty($course_info['real_id'])) {
@ -41,13 +40,13 @@ if (!empty($course_info['real_id'])) {
$result = Database::query($sql);
if ($result && Database::num_rows($result)) {
$row = Database::fetch_array($result, 'ASSOC');
$full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.$row['url'];
$full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.$row['url'];
$item_info = api_get_item_property_info(api_get_course_int_id(), 'work', $row['id']);
$item_info = api_get_item_property_info(api_get_course_int_id(), 'work', $row['id']);
if (empty($item_info)) {
exit;
}
if ($item_info['visibility'] == 1 && $row['accepted'] == 1 && ($row['user_id'] == api_get_user_id() || api_is_allowed_to_edit())) {
if ($course_info['show_score'] == 0 || $item_info['visibility'] == 1 && $row['accepted'] == 1 && ($row['user_id'] == api_get_user_id() || api_is_allowed_to_edit())) {
$title = str_replace(' ', '_', $row['title']);
event_download($title);
if (Security::check_abs_path($full_file_name, api_get_path(SYS_COURSE_PATH).api_get_course_path().'/')) {

@ -332,6 +332,8 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$course_id = api_get_course_int_id();
$group_id = api_get_group_id();
$course_info = api_get_course_info();
$sort_params = array();
if (isset($_GET['column'])) {
@ -351,8 +353,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$origin = Security::remove_XSS($origin);
// Getting the work data
$my_folder_data = get_work_data_by_id($id);
$my_folder_data = get_work_data_by_id($id);
$qualification_exists = false;
if (!empty($my_folder_data['qualification']) && intval($my_folder_data['qualification']) > 0) {
@ -411,17 +412,19 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
if (!empty($group_id)) {
$group_query = " WHERE c_id = $course_id AND post_group_id = '".intval($group_id)."' "; // set to select only messages posted by the user's group
} else {
$group_query = " WHERE c_id = $course_id AND post_group_id = '0' ";
$group_query = " WHERE c_id = $course_id AND post_group_id = '0' ";
}
$subdirs_query = "AND parent_id = $parent_id ";
if ($is_allowed_to_edit) {
//$subdirs_query .= " AND user_id = ".api_get_user_id()." ";
} else {
$subdirs_query .= " AND user_id = ".api_get_user_id()." ";
}
if (isset($course_info['show_score']) && $course_info['show_score'] == 1) {
$subdirs_query .= " AND user_id = ".api_get_user_id()." ";
} else {
$subdirs_query .= '';
}
}
$active_condition = ' AND active IN (1)';
$sql_get_publications_list = "SELECT * FROM $work_table $group_query $subdirs_query $add_in_where_query $active_condition $condition_session ORDER BY title";
@ -748,13 +751,17 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
if (api_is_allowed_to_edit()) {
$sql_document = "SELECT count(*) FROM $work_table WHERE c_id = $course_id AND parent_id = ".$work_data['id']." AND active IN (0, 1) ";
} else {
$user_filter = "user_id = ".api_get_user_id()." AND ";
if ($course_info['show_score'] == 0) {
$user_filter = null;
}
$sql_document = "SELECT count(*) FROM $work_table s, $iprop_table p
WHERE s.c_id = $course_id AND
p.c_id = $course_id AND
s.id = p.ref AND
p.tool='work' AND
s.accepted='1' AND
user_id = ".api_get_user_id()." AND
$user_filter
parent_id = ".$work_data['id']." AND
active = 1 AND
parent_id = ".$work_parent->id."";
@ -841,16 +848,20 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
//Get the author ID for that document from the item_property table
$is_author = false;
$can_read = false;
$item_property_data = api_get_item_property_info(api_get_course_int_id(), 'work', $work->id, api_get_session_id());
if (!$is_allowed_to_edit && $item_property_data['insert_user_id'] == api_get_user_id()) {
$is_author = true;
}
if ($course_info['show_score'] == 0 ) {
$can_read = true;
}
$user_info = api_get_user_info($item_property_data['insert_user_id']);
//display info depending on the permissions
if ($is_author && $work->accepted == '1' || $is_allowed_to_edit || CourseManager::is_course_teacher($item_property_data['insert_user_id'], $_course['code'])) {
if (($can_read && $work->accepted == '1') || ($is_author && $work->accepted == '1') || $is_allowed_to_edit || CourseManager::is_course_teacher($item_property_data['insert_user_id'], $_course['code'])) {
$row = array();
if ($work->accepted == '0') {
@ -874,8 +885,6 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$add_string = ' <b style="color:red">'.get_lang('Expired').'</b>';
}
// }
$row[] = '<a href="download.php?id='.$work->id.'">'.build_document_icon_tag('file', substr(basename($work->url), 13)).'</a>';
if ($work->contains_file) {
$row[] = '<a href="download.php?id='.$work->id.'"'.$class.'>'.Display::return_icon('save.png', get_lang('Save'),array('style' => 'float:right;'), ICON_SIZE_SMALL).' '.$work->title.'</a><br />'.$work->description;
@ -910,10 +919,9 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$action .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$my_folder_data['id'].'&origin='.$origin.'&gradebook='.$gradebook.'&amp;action=make_visible&item_id='.$work->id.'&amp;'.$sort_params.'" title="'.get_lang('Visible').'" >'.Display::return_icon('invisible.png', get_lang('Visible'),array(), ICON_SIZE_SMALL).'</a> ';
}
$action .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$my_folder_data['id'].'&origin='.$origin.'&gradebook='.$gradebook.'&amp;delete='.$work->id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('WorkDelete').'" >'.Display::return_icon('delete.png', get_lang('WorkDelete'),'',ICON_SIZE_SMALL).'</a>';
$row[] = $action;
$row[] = $action;
// the user that is not course admin can only edit/delete own document
} elseif ($is_author && empty($work->qualificator_id)) {
} elseif ($is_author && empty($work->qualificator_id)) {
if (!$table_has_actions_column) {
$table_header[] = array(get_lang('Actions'), false, 'style="width:90px"');
$table_has_actions_column = true;
@ -931,8 +939,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
} else {
$row[] = ' ';
}
$row[] = $work_sent_date_local;
$row[] = $work_sent_date_local;
$table_data[] = $row;
}
}
@ -1684,6 +1691,7 @@ function display_list_users_without_publication($task_id) {
$table_header[] = array(get_lang('Email'), true);
// table_data
$table_data = get_list_users_without_publication($task_id);
$sorting_options = array();
$sorting_options['column'] = 1;

Loading…
Cancel
Save