diff --git a/main/gradebook/index.php b/main/gradebook/index.php
index 44a4582436..8e7aa941f8 100644
--- a/main/gradebook/index.php
+++ b/main/gradebook/index.php
@@ -811,7 +811,8 @@ if ($first_time==1 && api_is_allowed_to_edit(null,true)) {
Display::display_normal_message($grading_string);
}
}
- $gradebooktable = new GradebookTable($cat, $allcat, $alleval,$alllink, $addparams);
+
+ $gradebooktable = new GradebookTable($cat, $allcat, $alleval, $alllink, $addparams);
$gradebooktable->display();
//DisplayGradebook :: display_reduce_header_gradebook($cat,$is_course_admin, $is_platform_admin, $simple_search_form, false, false);
diff --git a/main/gradebook/lib/be/studentpublicationlink.class.php b/main/gradebook/lib/be/studentpublicationlink.class.php
index 1f72f68ded..cd87b498a5 100644
--- a/main/gradebook/lib/be/studentpublicationlink.class.php
+++ b/main/gradebook/lib/be/studentpublicationlink.class.php
@@ -1,4 +1,4 @@
-get_course_code());
- $database_name = (empty($course_info['db_name']))?$course_info['dbName']:$course_info['db_name'];
- $tbl_stats = Database :: get_course_table(TABLE_STUDENT_PUBLICATION, $database_name);
- if (is_null($database_name)===true) {
- return false;
- }
+ public function calc_score($stud_id = null) {
+ $stud_id = intval($stud_id);
+
+ $course_info = Database::get_course_info($this->get_course_code());
+ $tbl_stats = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$sql = 'SELECT * FROM '.$tbl_stats."
WHERE c_id = {$course_info['real_id']} AND
id = '".intval($this->get_ref_id())."' AND
@@ -144,39 +142,35 @@ class StudentPublicationLink extends AbstractLink
$query = Database::query($sql);
$assignment = Database::fetch_array($query);
- if(count($assignment)==0) {
+ if (count($assignment)==0) {
$v_assigment_id ='0';
} else {
$v_assigment_id = $assignment['id'];
}
$sql = 'SELECT * FROM '.$tbl_stats.' WHERE parent_id ="'.$v_assigment_id.'" AND session_id='.api_get_session_id().'';
- if (isset($stud_id)){
- $sql1='SELECT firstname, lastname FROM '.Database::get_main_table(TABLE_MAIN_USER)." WHERE user_id = '".((int)$stud_id)."'";
- $query = Database::query($sql1);
- $student = Database::fetch_array($query);
- $sql .= ' AND author = '."'".Database::escape_string(api_get_person_name($student['firstname'], $student['lastname'], null, null, $course_info['course_language']))."'";
+ if (!empty($stud_id)) {
+ $sql .= " AND user_id = $stud_id ";
}
// order by id, that way the student's first attempt is accessed first
- $sql .= ' ORDER BY id';
+ $sql .= ' ORDER BY id';
$scores = Database::query($sql);
// for 1 student
- if (isset($stud_id)) {
+ if (!empty($stud_id)) {
if ($data=Database::fetch_array($scores)) {
return array ($data['qualification'], $assignment['qualification']);
} else {
return '';
}
} else {
- $students=array(); // user list, needed to make sure we only
+ $students = array(); // user list, needed to make sure we only
// take first attempts into account
$rescount = 0;
$sum = 0;
-
- while ($data=Database::fetch_array($scores)) {
- if (!(array_key_exists($data['author'],$students))) {
+ while ($data = Database::fetch_array($scores)) {
+ if (!(array_key_exists($data['user_id'], $students))) {
if ($assignment['qualification'] != 0) {
- $students[$data['author']] = $data['qualification'];
+ $students[$data['user_id']] = $data['qualification'];
$rescount++;
$sum += ($data['qualification'] / $assignment['qualification']);
}
@@ -191,35 +185,20 @@ class StudentPublicationLink extends AbstractLink
}
}
-// INTERNAL FUNCTIONS
+ // INTERNAL FUNCTIONS
/**
* Lazy load function to get the database table of the student publications
*/
- private function get_studpub_table () {
- $course_info = Database :: get_course_info($this->get_course_code());
- $database_name = isset($course_info['db_name']) ? $course_info['db_name'] : '';
- if ($database_name!='') {
- if (!isset($this->studpub_table)) {
- $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION, $database_name);
- }
- return $this->studpub_table;
- } else {
- return false;
- }
-
+ private function get_studpub_table() {
+ return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
}
/**
* Lazy load function to get the database table of the item properties
*/
private function get_itemprop_table () {
- if (!isset($this->itemprop_table)) {
- $course_info = Database :: get_course_info($this->get_course_code());
- $database_name = isset($course_info['db_name']) ? $course_info['db_name'] : '';
- $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY, $database_name);
- }
- return $this->itemprop_table;
+ return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY);
}
public function needs_name_and_description() {
@@ -227,8 +206,8 @@ class StudentPublicationLink extends AbstractLink
}
public function get_name() {
- $this->get_exercise_data();
- return (isset($this->exercise_data['url'])&&(substr($this->exercise_data['url'],0,1)=='/')? substr($this->exercise_data['url'], 1) : null);
+ $this->get_exercise_data();
+ return (isset($this->exercise_data['title']) && !empty($this->exercise_data['title'])) ? $this->exercise_data['title'] : get_lang('Untitled');
}
public function get_description() {
@@ -241,21 +220,17 @@ class StudentPublicationLink extends AbstractLink
}
public function get_link() {
- $url = api_get_path(WEB_PATH)
- .'main/work/work.php?cidReq='.$this->get_course_code().'&id='.$this->exercise_data['id'].'&gradebook=view&curdirpath='.substr($this->exercise_data['url'], 1);
- if (!api_is_allowed_to_create_course()
- && $this->calc_score(api_get_user_id()) == null) {
- //$url .= '&curdirpath=/'.$this->get_ref_id();
- }
+ $url = api_get_path(WEB_PATH).'main/work/work.php?cidReq='.$this->get_course_code().'&id='.$this->exercise_data['id'].'&gradebook=view';
return $url;
}
private function get_exercise_data() {
- $tbl_name=$this->get_studpub_table();
+ $tbl_name = $this->get_studpub_table();
+ $course_info = Database :: get_course_info($this->get_course_code());
if ($tbl_name=='') {
return false;
} elseif (!isset($this->exercise_data)) {
- $sql = 'SELECT * FROM '.$this->get_studpub_table()." WHERE id = '".intval($this->get_ref_id())."' AND session_id=".api_get_session_id()."";
+ $sql = 'SELECT * FROM '.$this->get_studpub_table()." WHERE c_id ='".$course_info['real_id']."' AND id = '".intval($this->get_ref_id())."' AND session_id=".api_get_session_id()."";
$query = Database::query($sql);
$this->exercise_data = Database::fetch_array($query);
}
@@ -271,8 +246,10 @@ class StudentPublicationLink extends AbstractLink
}
public function is_valid_link() {
- $sql = 'SELECT count(id) from '.$this->get_studpub_table()
- .' WHERE id = '.intval($this->get_ref_id()).' AND session_id='.api_get_session_id().'';
+ $course_info = Database :: get_course_info($this->get_course_code());
+
+ $sql = 'SELECT count(id) from '.$this->get_studpub_table().'
+ WHERE c_id = "'.$course_info['real_id'].'" AND id = '.intval($this->get_ref_id()).' AND session_id='.api_get_session_id();
$result = Database::query($sql);
$number=Database::fetch_row($result);
return ($number[0] != 0);
diff --git a/main/gradebook/lib/fe/gradebooktable.class.php b/main/gradebook/lib/fe/gradebooktable.class.php
index d6f3600e8e..37e7516c92 100644
--- a/main/gradebook/lib/fe/gradebooktable.class.php
+++ b/main/gradebook/lib/fe/gradebooktable.class.php
@@ -34,7 +34,7 @@ class GradebookTable extends SortableTable {
$this->currentcat = $currentcat;
$this->datagen = new GradebookDataGenerator($cats, $evals, $links);
-
+
if (isset($addparams)) {
$this->set_additional_parameters($addparams);
}
@@ -46,19 +46,12 @@ class GradebookTable extends SortableTable {
$this->set_header($column++, get_lang('Type'),'','width="35px"');
$this->set_header($column++, get_lang('Name'), false);
- //$this->set_header($column++, get_lang('Description'));
if (api_is_allowed_to_edit(null, true)) {
$this->set_header($column++, get_lang('Weight'),'','width="50px"');
} else {
$this->set_header($column++, get_lang('Weight'), false);
$this->set_header($column++, get_lang('Evaluation'), false);
- /*
- if (empty($_GET['selectcat']) ) {
- $this->set_header($column++, get_lang('Evaluation'), false);
- } else {
- $this->set_header($column++, get_lang('Weight'), false);
- }*/
}
if (api_is_allowed_to_edit(null, true)) {
@@ -137,7 +130,7 @@ class GradebookTable extends SortableTable {
$user_id = api_get_user_id();
$course_code = api_get_course_id();
$status_user = api_get_status_of_user_in_course($user_id, $course_code);
- $data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
+ $data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
// generate the data to display
@@ -160,13 +153,14 @@ class GradebookTable extends SortableTable {
if (api_is_allowed_to_edit(null, true)) {
$row[] = $this->build_id_column($item);
}
+
$row[] = $this->build_type_column($item);
//Name
if (get_class($item) == 'Category') {
$row[] = $invisibility_span_open.'
'.$item->get_name().'
'.$invisibility_span_close;
} else {
- $row[] = $invisibility_span_open.$this->build_name_link ($item) . $invisibility_span_close;
+ $row[] = $invisibility_span_open.$this->build_name_link($item) . $invisibility_span_close;
}
//Description
@@ -384,7 +378,13 @@ class GradebookTable extends SortableTable {
private function build_type_column ($item) {
return build_type_icon_tag($item->get_icon_name());
}
-
+
+ /**
+ *
+ * Generate name column
+ * @param unknown_type $item
+ * @return string
+ */
private function build_name_link ($item) {
switch ($item->get_item_type()) {
@@ -417,23 +417,12 @@ class GradebookTable extends SortableTable {
// course/platform admin can go to the view_results page
if (api_is_allowed_to_create_course() && $show_message===false) {
-
- if ($item->get_type() == 'presence')
- {
+ if ($item->get_type() == 'presence') {
return ' '
. ''
. $item->get_name()
- . '';
- /*return ' '
- . ''
- . $item->get_name()
- . '';
- */
- }
- else
- {
-
-
+ . '';
+ } else {
return ' '
. ''
. $item->get_name()
@@ -457,15 +446,16 @@ class GradebookTable extends SortableTable {
}
// link
case 'L' :
- $cat=new Category();
- //$dblib=new Database();
-
- $category_id=Security::remove_XSS($_GET['selectcat']);
- $course_id=Database::get_course_by_category($category_id);
- $show_message=$cat->show_message_resource_delete($course_id);
+ $cat = new Category();
+ $category_id = intval($_GET['selectcat']);
+ $course_id = Database::get_course_by_category($category_id);
+ $show_message = $cat->show_message_resource_delete($course_id);
+
$url = $item->get_link();
+
if (isset($url) && $show_message===false) {
+
$text = ' '
. $item->get_name()
. '';
@@ -493,7 +483,6 @@ class GradebookTable extends SortableTable {
// link
case 'L' :
return build_edit_icons_link($item, $this->currentcat->get_id());
-
}
}
}
diff --git a/main/gradebook/lib/gradebook_data_generator.class.php b/main/gradebook/lib/gradebook_data_generator.class.php
index 13c699023c..f36b58752d 100644
--- a/main/gradebook/lib/gradebook_data_generator.class.php
+++ b/main/gradebook/lib/gradebook_data_generator.class.php
@@ -36,17 +36,13 @@ class GradebookDataGenerator
$this->evals_links = array_merge($allevals, $alllinks);
}
-
/**
* Get total number of items (rows)
*/
public function get_total_items_count() {
return count($this->items);
}
-
-
-
-
+
/**
* Get actual array data
* @return array 2-dimensional array - each array contains the elements:
@@ -87,7 +83,7 @@ class GradebookDataGenerator
//status de user in course
$user_id = api_get_user_id();
$course_code = api_get_course_id();
- $status_user = api_get_status_of_user_in_course ($user_id,$course_code);
+ $status_user = api_get_status_of_user_in_course($user_id, $course_code);
// generate the data to display
$data = array();
foreach ($visibleitems as $item) {
diff --git a/main/work/work.lib.php b/main/work/work.lib.php
index 1524173e1e..30d72a4554 100644
--- a/main/work/work.lib.php
+++ b/main/work/work.lib.php
@@ -30,9 +30,11 @@ function display_action_links($id, $cur_dir_path, $always_show_tool_options, $al
$display_output = '';
$origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '';
- if (!empty($cur_dir_path)) {
- $parent_dir = dirname($cur_dir_path);
- $display_output .= ''.Display::return_icon('back.png', get_lang('BackToWorksList'),'','32').'';
+ if ($always_show_upload_form) {
+ $parent_id = $id;
+ }
+ if (!empty($cur_dir_path)) {
+ $display_output .= ''.Display::return_icon('back.png', get_lang('BackToWorksList'),'','32').'';
}
if (!$always_show_tool_options && api_is_allowed_to_edit(null, true) && $origin != 'learnpath') {
@@ -275,8 +277,9 @@ function get_work_data_by_path($path) {
function get_work_data_by_id($id) {
$id = intval($id);
- $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
- $sql = "SELECT * FROM ".$work_table." WHERE id = $id";
+ $course_id = api_get_course_int_id();
+ $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
+ $sql = "SELECT * FROM ".$work_table." WHERE id = $id AND c_id = $course_id";
$result = Database::query($sql);
$return = array();
if (Database::num_rows($result)) {
@@ -285,6 +288,22 @@ function get_work_data_by_id($id) {
return $return;
}
+function get_work_count_by_student($user_id, $work_id) {
+ $user_id = intval($user_id);
+ $work_id = intval($work_id);
+ $course_id = api_get_course_id();
+
+ $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
+ $sql = "SELECT COUNT(*) as count FROM $work_table WHERE parent_id = $work_id AND user_id = $user_id AND active = 1 ";
+ $result = Database::query($sql);
+ $return = 0;
+ if (Database::num_rows($result)) {
+ $return = Database::fetch_row($result,'ASSOC');
+ $return = intval($return[0]);
+ }
+ return $return;
+}
+
function get_work_assignment_by_id($id) {
$id = intval($id);
$table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
@@ -336,7 +355,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
// Getting the work data
$my_folder_data = get_work_data_by_id($id);
-
+
$work_in_gradebook_link_id = is_resource_in_course_gradebook(api_get_course_id(), 3 , $id, api_get_session_id());
if ($work_in_gradebook_link_id) {
if ($is_allowed_to_edit)
@@ -373,35 +392,42 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$parent_id = isset($my_folder_data['id']) ? $my_folder_data['id'] : 0;
if (!empty($sub_course_dir)) {
- $contains_file_query = " OR (url = '' AND contains_file = 0 AND parent_id = $parent_id ) ";
+ $contains_file_query = " OR (contains_file = 0 AND parent_id = $parent_id ) ";
}
+
+
//Get list from database
if ($is_allowed_to_edit) {
+ $active_condition = ' active IN (0, 1)';
$sql_get_publications_list = "SELECT * FROM $work_table
- WHERE c_id = $course_id $add_in_where_query $condition_session AND
- ( url LIKE BINARY '$sub_course_dir%' AND url NOT LIKE BINARY '$sub_course_dir%/%' AND contains_file = 1 AND parent_id = $parent_id)
+ WHERE c_id = $course_id $add_in_where_query $condition_session AND $active_condition AND
+ ( contains_file = 1 AND parent_id = $parent_id)
$contains_file_query
ORDER BY sent_date DESC";
$sql_get_publications_num = "SELECT count(*) FROM ".$work_table."
- WHERE c_id = $course_id $add_in_where_query $condition_session AND
- ( url LIKE BINARY '$sub_course_dir%' AND url NOT LIKE BINARY '$sub_course_dir%/%' AND contains_file = 1 AND parent_id = $parent_id )
+ WHERE c_id = $course_id $add_in_where_query $condition_session AND $active_condition AND
+ ( contains_file = 1 AND parent_id = $parent_id )
$contains_file_query
ORDER BY sent_date DESC";
} else {
+
+
if (!empty($_SESSION['toolgroup'])) {
$group_query = " WHERE c_id = $course_id AND post_group_id = '".intval($_SESSION['toolgroup'])."' "; // set to select only messages posted by the user's group
- $subdirs_query = "AND url NOT LIKE BINARY '$sub_course_dir%/%' AND url LIKE BINARY '$sub_course_dir%'";
+ $subdirs_query = "AND parent_id = $parent_id";
} else {
$group_query = " WHERE c_id = $course_id AND post_group_id = '0' ";
- $subdirs_query = "AND url NOT LIKE '$sub_course_dir%/%' AND url LIKE '$sub_course_dir%'";
+ $subdirs_query = "AND parent_id = $parent_id";
}
+
+ $active_condition = ' AND active IN (1)';
- $sql_get_publications_list = "SELECT * FROM $work_table $group_query $subdirs_query ".$add_in_where_query." $condition_session ORDER BY id";
- $sql_get_publications_num = "SELECT count(url) FROM ".$work_table." " .
- " WHERE c_id = $course_id AND url LIKE BINARY '$sub_course_dir%' AND url NOT LIKE BINARY '$sub_course_dir%/%' " .$add_in_where_query.$condition_session." ORDER BY id";
+ $sql_get_publications_list = "SELECT * FROM $work_table $group_query $subdirs_query $add_in_where_query $active_condition $condition_session ORDER BY id";
+ $sql_get_publications_num = "SELECT count(url) FROM $work_table $group_query $subdirs_query $add_in_where_query $active_condition $condition_session
+ ORDER BY id";
}
//echo $sql_get_publications_list;
@@ -456,14 +482,14 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$sql_select_directory = "SELECT prop.insert_date, prop.lastedit_date, work.id, author, has_properties, view_properties, description, qualification, weight, allow_text_assignment
FROM ".$iprop_table." prop INNER JOIN ".$work_table." work ON (prop.ref=work.id)
- WHERE ";
+ WHERE active IN (0, 1) AND ";
if (!empty($_SESSION['toolgroup'])) {
$sql_select_directory .= " work.post_group_id = '".$_SESSION['toolgroup']."' "; // set to select only messages posted by the user's group
} else {
$sql_select_directory .= " work.post_group_id = '0' ";
}
- $sql_select_directory .= " AND prop.c_id = $course_id AND work.c_id = $course_id AND work.url LIKE BINARY '".$mydir_temp."' AND work.filetype = 'folder' AND prop.tool='work' $condition_session";
+ $sql_select_directory .= " AND prop.c_id = $course_id AND work.c_id = $course_id AND work.url LIKE BINARY '".$mydir_temp."' AND work.filetype = 'folder' AND prop.tool='work' $condition_session";
$result = Database::query($sql_select_directory);
$row = Database::fetch_array($result);
@@ -496,8 +522,6 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$form_folder -> addGroupRule('my_group', get_lang('ThisFieldIsRequired'), 'required');
$defaults = array('my_group[dir_name]' => html_entity_decode($dir), 'description' => api_html_entity_decode($row['description']));
-
- //$form_folder-> addElement('textarea', 'description', get_lang('Description'), array('rows' => 5, 'cols' => 50));
$form_folder->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'work', 'Width' => '80%', 'Height' => '200'));
$there_is_a_end_date = false;
@@ -727,7 +751,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$session_id = api_get_session_id();
if (api_is_allowed_to_edit()) {
- $sql_document = "SELECT count(*) FROM $work_table WHERE parent_id = ".$work_data['id']." ";
+ $sql_document = "SELECT count(*) FROM $work_table WHERE c_id = $course_id AND parent_id = ".$work_data['id']." AND active IN (0, 1) ";
} else {
// gets admin_course
$table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@@ -749,6 +773,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
s.accepted='1' AND
user_id = ".api_get_user_id()." AND
parent_id = ".$work_data['id']." AND
+ active = 1 AND
url LIKE 'work/".$dir."/%'";
} else {
$sql_document = "SELECT count(*) FROM $work_table s, $iprop_table p
@@ -758,7 +783,8 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
s.id = p.ref AND
p.tool='work' AND
s.accepted='1' AND
- parent_id = ".$work_data['id']." AND
+ parent_id = ".$work_data['id']." AND
+ active = 1 AND
url LIKE 'work/".$dir."/%'";
}
}
@@ -767,25 +793,13 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$res_document = Database::query($sql_document);
$count_document = Database::fetch_row($res_document);
$cant_files = $count_document[0];
-
- //count directories
- /*
- $sql_directory = "SELECT count(*) FROM $work_table WHERE session_id = $session_id AND c_id = $course_id AND (url NOT LIKE '/".$mydir."/%/%' AND url LIKE '/".$mydir."/%') OR (parent_id = ".$work_data['id']." )";
- $res_directory = Database::query($sql_directory);
- $count_directory = Database::fetch_row($res_directory);
- $cant_dir = $count_directory[0];
-*/
+
$text_file = get_lang('FilesUpload');
- //$text_dir = get_lang('Directories');
if ($cant_files == 1) {
$text_file = api_strtolower(get_lang('FileUpload'));
}
- if ($cant_dir == 1) {
- //$text_dir = get_lang('directory');
- }
-
$icon = Display::return_icon('work.png', get_lang('Assignment'), array(), 22);
if (!empty($display_edit_form) && isset($clean_edit_dir) && $clean_edit_dir == $mydir) {
@@ -919,7 +933,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
if ($is_allowed_to_edit) {
$action = '';
if ($qualification_exists) {
- $action .= ''.
+ $action .= ''.
Display::return_icon('rate_work.png', get_lang('CorrectAndRate'),array(), 22).'';
}
if ($work->contains_file) {
@@ -932,6 +946,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
}
$action .= ''.Display::return_icon('delete.png', get_lang('WorkDelete'),'',22).'';
$row[] = $action;
+
// the user that is not course admin can only edit/delete own document
} elseif ($is_author && empty($work->qualificator_id)) {
if (!$table_has_actions_column) {
@@ -939,7 +954,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$table_has_actions_column = true;
}
$action = '';
- $action .= ''.Display::return_icon('edit.png', get_lang('Modify'),array(), 22).'';
+ $action .= ''.Display::return_icon('edit.png', get_lang('Modify'),array(), 22).'';
if (api_get_course_setting('student_delete_own_publication') == 1) {
$action .= ''.Display::return_icon('delete.png',get_lang('WorkDelete'),'',22).'';
}
@@ -1225,10 +1240,11 @@ function del_dir($base_work_dir, $dir, $id) {
if (!empty($url_path) && $url_path != -1) {
//Deleting all contents inside the folder
- $sql = "DELETE FROM $table WHERE c_id = $course_id AND url LIKE BINARY 'work/".$dir."/%'";
+ //@todo replace to parent_id
+ $sql = "UPDATE $table SET active = 2 WHERE c_id = $course_id AND url LIKE BINARY 'work/".$dir."/%'";
$res = Database::query($sql);
- $sql = "DELETE FROM $table WHERE c_id = $course_id AND filetype = 'folder' AND id = $id";
+ $sql = "UPDATE $table SET active = 2 WHERE c_id = $course_id AND filetype = 'folder' AND id = $id";
$res = Database::query($sql);
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
diff --git a/main/work/work.php b/main/work/work.php
index 3f6178fdcc..1f80ece813 100644
--- a/main/work/work.php
+++ b/main/work/work.php
@@ -63,8 +63,8 @@ require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
-$course_id = api_get_course_int_id();
-$user_id = api_get_user_id();
+$course_id = api_get_course_int_id();
+$user_id = api_get_user_id();
// Section (for the tabs)
$this_section = SECTION_COURSES;
@@ -123,16 +123,13 @@ $currentUserFirstName = $_user['firstName'];
$currentUserLastName = $_user['lastName'];
$currentUserEmail = $_user['mail'];
-$authors = isset($_POST['authors']) ? Database::escape_string($_POST['authors']) : '';
$delete = isset($_REQUEST['delete']) ? Database::escape_string($_REQUEST['delete']) : '';
$description = isset($_REQUEST['description']) ? Database::escape_string($_REQUEST['description']) : '';
$item_id = isset($_REQUEST['item_id']) ? strval(intval($_REQUEST['item_id'])) : '';
-$edit = isset($_REQUEST['edit']) ? intval($_REQUEST['edit']) : '';
$parent_id = isset($_REQUEST['parent_id']) ? Database::escape_string($_REQUEST['parent_id']) : '';
-
-$edit = isset($_REQUEST['id']) ? intval($_REQUEST['edit']) : null;
$origin = isset($_REQUEST['origin']) ? Security::remove_XSS($_REQUEST['origin']) : '';
+
$submitGroupWorkUrl = isset($_REQUEST['submitGroupWorkUrl']) ? Security::remove_XSS($_REQUEST['submitGroupWorkUrl']) : '';
$title = isset($_REQUEST['title']) ? Database::escape_string($_REQUEST['title']) : '';
$uploadvisibledisabled = isset($_REQUEST['uploadvisibledisabled']) ? Database::escape_string($_REQUEST['uploadvisibledisabled']) : '';
@@ -201,6 +198,10 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && !sizeof($_POST)) {
}
//}
+$display_upload_form = false;
+if ($action == 'upload_form') {
+ $display_upload_form = true;
+}
/* Header */
@@ -227,16 +228,9 @@ if (!empty($_SESSION['toolgroup'])) {
$interbreadcrumb[] = array ('url' =>'#','name' => get_lang('StudentPublications'));
- $dir_array = explode('/', $curdirpath);
- $array_len = count($dir_array);
-
- $dir_acum = '';
- for ($i = 0; $i < $array_len; $i++) {
- $url_dir = 'work.php?&curdirpath=' . $dir_acum . $dir_array[$i];
- $interbreadcrumb[] = array ('url' => $url_dir,'name' => $dir_array[$i]);
- $dir_acum .= $dir_array[$i] . '/';
- }
-
+ $url_dir = 'work.php?&id=' . $work_id;
+ $interbreadcrumb[] = array ('url' => $url_dir,'name' => $my_folder_data['title']);
+
if ($display_upload_form) {
$interbreadcrumb[] = array ('url' => 'work.php','name' => get_lang('UploadADocument'));
@@ -254,27 +248,15 @@ if (!empty($_SESSION['toolgroup'])) {
Display :: display_header(null);
} else {
if (isset($origin) && $origin != 'learnpath') {
- $url_dir = '';
-
+
if (isset($_GET['id']) && !empty($_GET['id']) || $display_upload_form || $action == 'settings' || $action == 'create_dir') {
- $interbreadcrumb[] = array ('url' => 'work.php', 'name' => get_lang('StudentPublications'));
- } else {
+ $interbreadcrumb[] = array ('url' => 'work.php', 'name' => get_lang('StudentPublications'));
+ } else {
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('StudentPublications'));
- }
-
- $dir_array = explode('/', $curdirpath);
- $array_len = count($dir_array);
-
- $dir_acum = '';
- for ($i = 0; $i < $array_len; $i++) {
- $url_dir = 'work.php?gradebook='.$gradebook.'&curdirpath=' . $dir_acum . $dir_array[$i];
- if (isset($_REQUEST['curdirpath']) && $_REQUEST['curdirpath'] != '.' || $display_upload_form || $action == 'settings' || $action == 'create_dir') {
- $interbreadcrumb[] = array ('url' => $url_dir ,'name' => $dir_array[$i]);
- } else {
- $interbreadcrumb[] = array ('url' => '#','name' => $dir_array[$i]);
- }
- $dir_acum .= $dir_array[$i] . '/';
- }
+ }
+
+ $url_dir = 'work.php?id=' . $work_id;
+ $interbreadcrumb[] = array ('url' => $url_dir,'name' => $my_folder_data['title']);
if ($display_upload_form) {
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('UploadADocument'));
@@ -308,7 +290,6 @@ if ($origin == 'learnpath') {
echo '
';
}
-
/* Display links to upload form and tool options */
if ($is_special) {
@@ -341,43 +322,73 @@ if ($is_special) {
$expires_on = api_convert_and_format_date($homework['expires_on']);
if ($has_ended) {
- display_action_links($work_id, $curdirpath, $always_show_tool_options, true);
+ display_action_links($work_id, $curdirpath, $always_show_tool_options, $display_upload_form);
Display :: display_error_message(get_lang('EndDateAlreadyPassed').' '.$ends_on);
} elseif ($has_expired) {
- display_action_links($work_id,$curdirpath, $always_show_tool_options, $always_show_upload_form);
+ display_action_links($work_id,$curdirpath, $always_show_tool_options, $display_upload_form);
Display :: display_warning_message(get_lang('ExpiryDateAlreadyPassed').' '.$expires_on);
} else {
- display_action_links($work_id,$curdirpath, $always_show_tool_options, $always_show_upload_form);
+ display_action_links($work_id,$curdirpath, $always_show_tool_options, $display_upload_form);
if ($has_expiry_date) {
Display :: display_normal_message(get_lang('ExpiryDateToSendWorkIs').' '.$expires_on);
}
}
} else {
- display_action_links($work_id,$curdirpath, $always_show_tool_options, $always_show_upload_form);
+ display_action_links($work_id,$curdirpath, $always_show_tool_options, $display_upload_form);
}
} else {
- display_action_links($work_id, $curdirpath, $always_show_tool_options, $always_show_upload_form);
+ display_action_links($work_id, $curdirpath, $always_show_tool_options, $display_upload_form);
}
-switch ($action) {
+switch ($action) {
+ case 'mark_work':
case 'upload_form':
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
- }
+ }
+
+ if (empty($item_id)) {
+
+ $parent_data = get_work_data_by_id($work_id);
+ $parent_data['qualification'] = intval($parent_data['qualification']);
+
+ if (!empty($parent_data) && !empty($parent_data['qualification'])) {
+ $count = get_work_count_by_student($user_id, $work_id);
+ if ($count >= 1 ) {
+ if (api_get_course_setting('student_delete_own_publication') == '1') {
+ Display::display_warning_message(get_lang('CantUploadDeleteYourPaperFirst'));
+ } else {
+ Display::display_warning_message(get_lang('CantUpload'));
+ }
+ Display::display_footer();
+ exit;
+ }
+ }
+ }
+
$is_author = false;
- if ($edit) {
+ if ($item_id) {
+ //we found the current user is the author
+ $sql = "SELECT * FROM $work_table WHERE c_id = $course_id AND id = $item_id";
+ $result = Database::query($sql);
+ $work_item = array();
+ if ($result) {
+ $work_item = Database::fetch_array($result);
+ }
+
//Get the author ID for that document from the item_property table
$author_sql = "SELECT * FROM $iprop_table
- WHERE c_id = $course_id AND tool = 'work' AND insert_user_id = '$user_id' AND ref=" . $edit;
+ WHERE c_id = $course_id AND tool = 'work' AND insert_user_id = '$user_id' AND ref = " . $item_id;
$author_qry = Database::query($author_sql);
if (Database :: num_rows($author_qry)) {
$is_author = true;
}
- }
+ }
+
$form = new FormValidator('form', 'POST', api_get_self() . "?action=upload&id=".$work_id."curdirpath=" . rtrim(Security :: remove_XSS($curdirpath),'/') . "&gradebook=".Security::remove_XSS($_GET['gradebook'])."&origin=$origin", '', 'enctype="multipart/form-data"');
// form title
- if ($edit) {
+ if ($item_id) {
$form_title = get_lang('EditMedia');
} else {
$form_title = get_lang('UploadADocument');
@@ -396,7 +407,7 @@ switch ($action) {
$text_document = & $form->addElement('text', 'document', get_lang('Document'));
$defaults['document'] = '' . $realUrl . '';
$text_document->freeze();
- } elseif ($edit && ($is_allowed_to_edit or $is_author)) {
+ } elseif ($item_id && ($is_allowed_to_edit or $is_author)) {
$workUrl = $currentCourseRepositoryWeb . $workUrl;
//$form->addElement('hidden', 'id', $edit);
@@ -412,37 +423,37 @@ switch ($action) {
// else standard upload option
$form->addElement('file', 'file', get_lang('UploadADocument'), 'size="40" onchange="updateDocumentTitle(this.value)"');
$show_progress_bar = true;
+ }
+ $form->addElement('hidden', 'id', $item_id);
+ if (empty($item_id)) {
+ $form->addElement('checkbox', 'contains_file', null, get_lang('ContainsAfile'), array('id'=>'contains_file_id'));
}
+ $form->addElement('text', 'title', get_lang('TitleWork'), 'id="file_upload" style="width: 350px;"');
+ $form->addElement('textarea', 'description', get_lang("Description"), 'style="width: 350px; height: 60px;"');
- $form->addElement('hidden', 'id', $work_id);
-
- $form->addElement('checkbox', 'contains_file', null, get_lang('ContainsAfile'), array('id'=>'contains_file_id'));
- $titleWork = $form->addElement('text', 'title', get_lang('TitleWork'), 'id="file_upload" style="width: 350px;"');
- $defaults['title'] = $edit ? stripslashes($workTitle) : stripslashes($title);
-
- $authors = api_get_person_name($_user['firstName'], $_user['lastName']);
-
- //$defaults["authors"] = ($edit ? stripslashes($workAuthor) : stripslashes($authors));
- $titleAuthors = $form->addElement('textarea', 'description', get_lang("Description"), 'style="width: 350px; height: 60px;"');
- $defaults["description"] = ($edit ? stripslashes($workDescription) : stripslashes($description));
+ if ($item_id && !empty($work_item)) {
+ $defaults['title'] = $work_item['title'];
+ $defaults["description"] = $work_item['description'];
+ $defaults['qualification'] = $work_item['qualification'];
+ }
- if ($is_allowed_to_edit && !empty($edit)) {
+ if ($is_allowed_to_edit && !empty($item_id)) {
// Get qualification from parent_id that'll allow the validation qualification over
- $sql = "SELECT qualification FROM $work_table WHERE c_id = $course_id AND id='$work_id'";
+ $sql = "SELECT qualification FROM $work_table WHERE c_id = $course_id AND id ='$parent_id' ";
$result = Database::query($sql);
- $row = Database::fetch_array($result);
- $qualification_over = $row['qualification'];
+ $row = Database::fetch_array($result);
$form->addElement('text', 'qualification', get_lang('Qualification'), 'size="10"');
- $form->addElement('html', ''.get_lang('QualificationNumeric').' : '.$qualification_over.'
');
- $form->addElement('hidden', 'qualification_over', $qualification_over);
+ $form->addElement('html', ''.get_lang('QualificationNumeric').' : '.$row['qualification'].'
');
+ $form->addElement('hidden', 'qualification_over', $row['qualification']);
}
- $defaults['qualification'] = $qualification_number;//($edit ? stripslashes($qualification_number) : stripslashes($qualification_number));
- $form->addElement('hidden', 'active', 1);
+
+ $form->addElement('hidden', 'active', 1);
$form->addElement('hidden', 'accepted', 1);
- $form->addElement('hidden', 'item_to_edit', $edit);
+ $form->addElement('hidden', 'item_to_edit', $item_id);
$form->addElement('hidden', 'sec_token', $stok);
- if (isset($_GET['edit'])) {
+
+ if (isset($item_id)) {
$text = get_lang('UpdateWork');
$class = 'save';
} else {
@@ -452,15 +463,18 @@ switch ($action) {
// fix the Ok button when we see the tool in the learn path
if ($origin == 'learnpath') {
- $form->addElement('html', '');
- $form->addElement('style_submit_button', 'submitWork', $text, array('class="'.$class.'"', 'value="submitWork"'));
+ $form->addElement('html', '
');
+ $form->addElement('style_submit_button', 'submitWork', $text, array('class'=> $class, 'value' => "submitWork"));
$form->addElement('html', '
');
} else {
- //$form->addElement('submit','submitWork', get_lang('SendFile'));
- $form->addElement('style_submit_button', 'submitWork', $text, array('class="'.$class.'"', 'value="submitWork"'));
+ if ($item_id) {
+ $form->addElement('style_submit_button', 'editWork', $text, array('class'=> $class, 'value' => "editWork"));
+ } else {
+ $form->addElement('style_submit_button', 'submitWork', $text, array('class'=> $class, 'value' => "submitWork"));
+ }
}
- if (!empty($_POST['submitWork']) || $edit) {
+ if (!empty($_POST['submitWork']) || $item_id) {
$form->addElement('style_submit_button', 'cancelForm', get_lang('Cancel'), 'class="cancel"');
}
@@ -469,12 +483,12 @@ switch ($action) {
}
$form->setDefaults($defaults);
//fixes bug when showing modification form
- if (empty($edit) || (!empty($edit) && ($is_allowed_to_edit or $is_author))) {
+ if (empty($item_id) || (!empty($item_id) && ($is_allowed_to_edit or $is_author))) {
$form->display();
}
break;
- //download of an completed folder
+ //download of an completed folder
case 'downloadfolder':
//require 'downloadfolder.inc.php';
break;
@@ -691,9 +705,9 @@ switch ($action) {
// insert into student_publication_assignment
//return something like this: 2008-02-45 00:00:00
+ $enable_calification = isset($_POST['qualification_value']) ? 1 : 0;
+
if (!empty($_POST['type1']) || !empty($_POST['type2'])) {
-
- $enable_calification = isset($_POST['enable_calification']) ? (int)$_POST['enable_calification'] : null;
$sql_add_homework = "INSERT INTO $TSTDPUBASG SET
c_id = $course_id ,
expires_on = '".((isset($_POST['type1']) && $_POST['type1']==1) ? api_get_utc_datetime(get_date_from_select('expires')) : '0000-00-00 00:00:00'). "',
@@ -701,8 +715,7 @@ switch ($action) {
add_to_calendar = '$agenda_id',
enable_qualification = '".$enable_calification."',
publication_id = '".$id."'";
- Database::query($sql_add_homework);
-
+ Database::query($sql_add_homework);
$sql_add_publication = "UPDATE ".$work_table." SET "."has_properties = ".Database::insert_id().", view_properties = 1 ".' where id = '.$id;
Database::query($sql_add_publication);
} else {
@@ -711,7 +724,7 @@ switch ($action) {
expires_on = '0000-00-00 00:00:00',
ends_on = '0000-00-00 00:00:00',
add_to_calendar = '$agenda_id',
- enable_qualification = '".(isset($_POST['enable_calification'])?(int)$_POST['enable_calification']:'')."',
+ enable_qualification = '".$enable_calification."',
publication_id = '".$id."'";
Database::query($sql_add_homework);
@@ -729,8 +742,7 @@ switch ($action) {
//$resource_name = (empty($_POST['qualification_name'])) ? $_POST['new_dir'] : $_POST['qualification_name'];
$resource_name = $_POST['new_dir'];
add_resource_to_course_gradebook(api_get_course_id(), 3, $id, $resource_name, $_POST['weight'], $_POST['qualification_value'], $_POST['description'], time(), 1, api_get_session_id());
- }
-
+ }
// end features
if (api_get_course_setting('email_alert_students_on_new_homework') == 1) {
@@ -744,12 +756,10 @@ switch ($action) {
if (isset($_POST['sec_token']) && $ctok == $_POST['sec_token']) {
//check the token inserted into the form
- if (!empty($_POST['submitWork']) && !empty($is_course_member)) {
-
+ if (isset($_POST['submitWork']) && !empty($is_course_member)) {
$authors = api_get_person_name($currentUserFirstName, $currentUserLastName);
$url = null;
- if ($_POST['contains_file'] && !empty($_FILES['file']['size'])) {
-
+ if ($_POST['contains_file'] && !empty($_FILES['file']['size'])) {
$updir = $currentCourseRepositorySys . 'work/'; //directory path to upload
// Try to add an extension to the file if it has'nt one
@@ -812,13 +822,14 @@ switch ($action) {
parent_id = '".$work_id."' ,
session_id = '".intval($id_session)."' ,
user_id = '".$user_id."'";
-
+ var_dump($sql_add_publication);
Database::query($sql_add_publication);
-
- $id = Database::insert_id();
- api_item_property_update($_course, 'work', $id, 'DocumentAdded', $user_id);
- $succeed = true;
-
+ $id = Database::insert_id();
+ if ($id) {
+ api_item_property_update($_course, 'work', $id, 'DocumentAdded', $user_id);
+ $succeed = true;
+ }
+
// update all the parents in the table item propery
$list_id = get_parent_directories($my_cur_dir_path);
for ($i = 0; $i < count($list_id); $i++) {
@@ -853,8 +864,8 @@ switch ($action) {
author = '" . Database::escape_string($authors) . "',
post_group_id = '".$post_group_id."',
sent_date = '".api_get_utc_datetime()."',
- session_id = '".intval($id_session)."',
- user_id = '".$user_id."'";
+ session_id = '".intval($id_session)."',
+ user_id = '".$user_id."'";
Database::query($sql);
@@ -867,15 +878,16 @@ switch ($action) {
for ($i = 0; $i < count($list_id); $i++) {
api_item_property_update($_course, 'work', $list_id[$i], 'FolderUpdated', $user_id);
}*/
- } else {
+ } elseif (isset($_POST['editWork'])) {
+
/*
* SPECIAL CASE ! For a work edited
*/
//Get the author ID for that document from the item_property table
- $is_author = false;
- $item_to_edit_id = intval($_POST['item_to_edit']);
- $item_to_edit_data = api_get_item_property_info(api_get_course_int_id(), 'work', $item_to_edit_id);
+ $is_author = false;
+ $item_to_edit_id = intval($_POST['item_to_edit']);
+ $item_to_edit_data = api_get_item_property_info(api_get_course_int_id(), 'work', $item_to_edit_id);
if ($is_allowed_to_edit) {
$is_author = true;
@@ -886,9 +898,12 @@ switch ($action) {
}
if ($is_author) {
- if (!$title) {
- $title = basename($newWorkUrl);
- }
+
+ $work_data = get_work_data_by_id($item_to_edit_id);
+ if (!empty($_POST['title']))
+ $title = isset($_POST['title']) ? $_POST['title'] : $work_data['title'];
+ $description = isset($_POST['description']) ? $_POST['description'] : $work_data['description'];
+
if ($is_allowed_to_edit && ($_POST['qualification'] !='' )) {
$add_to_update = ', qualificator_id ='."'".api_get_user_id()."',";
@@ -903,7 +918,7 @@ switch ($action) {
SET title = '" . Database::escape_string($title) . "',
description = '" . Database::escape_string($description) . "'
".$add_to_update."
- WHERE id = $item_to_edit_id";
+ WHERE c_id = $course_id AND id = $item_to_edit_id";
Database::query($sql);
}
api_item_property_update($_course, 'work', $item_to_edit_id, 'DocumentUpdated', $user_id);
@@ -1000,13 +1015,18 @@ switch ($action) {
}
case 'make_visible':
case 'make_invisible':
+ case 'mark_work':
case 'move':
case 'move_to':
case 'list':
+
+ if ($action == 'mark_work') {
+
+ }
/* Move file command */
- if ($action == 'move_to') {
+ if ($action == 'move_to') {
$move_to_path = get_work_path($_REQUEST['move_to_id']);
@@ -1101,7 +1121,6 @@ switch ($action) {
}
-
/* Delete dir command */
if (!empty($_REQUEST['delete_dir'])) {
@@ -1145,9 +1164,12 @@ switch ($action) {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
+
if ($delete == 'all' && api_is_allowed_to_edit(null, true)) {
+
//we can't delete all documents
- return false;
+
+ /*
$path = $currentCourseRepositorySys;
$t_agenda = Database::get_course_table(TABLE_AGENDA);
@@ -1192,7 +1214,7 @@ switch ($action) {
rename($path.$url, $new_file);
}
}
- }
+ }*/
} else {
$file_deleted = false;
@@ -1202,18 +1224,18 @@ switch ($action) {
if ((Database :: num_rows($author_qry) == 1 AND api_get_course_setting('student_delete_own_publication') == 1) || api_is_allowed_to_edit(null,true)) {
//we found the current user is the author
- $queryString1 = "SELECT url, contains_file FROM " . $work_table . " WHERE c_id = $course_id AND id = '$delete'";
- $result1 = Database::query($queryString1);
- $row = Database::fetch_array($result1);
+ $queryString1 = "SELECT url, contains_file FROM " . $work_table . " WHERE c_id = $course_id AND id = $delete";
+ $result1 = Database::query($queryString1);
+ $row = Database::fetch_array($result1);
if (Database::num_rows($result1) > 0) {
- $queryString2 = "DELETE FROM " . $work_table . " WHERE c_id = $course_id AND id = '$delete'";
- $queryString3 = "DELETE FROM " . $TSTDPUBASG . " WHERE c_id = $course_id AND publication_id = '$delete'";
- $result2 = Database::query($queryString2);
- $result3 = Database::query($queryString3);
-
+ $queryString2 = "UPDATE " . $work_table . " SET active = 2 WHERE c_id = $course_id AND id = $delete";
+ $queryString3 = "DELETE FROM " . $TSTDPUBASG . " WHERE c_id = $course_id AND publication_id = $delete";
+ $result2 = Database::query($queryString2);
+ $result3 = Database::query($queryString3);
api_item_property_update($_course, 'work', $delete, 'DocumentDeleted', $user_id);
$work = $row['url'];
+
if ($row['contains_file'] == 1) {
if (!empty($work)) {
if (api_get_setting('permanently_remove_deleted_files') == 'true') {
@@ -1226,9 +1248,12 @@ switch ($action) {
$extension = pathinfo($work, PATHINFO_EXTENSION);
$basename_file = basename($work, '.'.$extension);
$new_dir = $work.'_DELETED_'.$delete.'.'.$extension;
- rename($currentCourseRepositorySys.'/'.$work, $currentCourseRepositorySys.'/'.$new_dir);
- Display::display_confirmation_message(get_lang('TheDocumentHasBeenDeleted'));
- $file_deleted = true;
+
+ if (file_exists($currentCourseRepositorySys.'/'.$work)) {
+ rename($currentCourseRepositorySys.'/'.$work, $currentCourseRepositorySys.'/'.$new_dir);
+ Display::display_confirmation_message(get_lang('TheDocumentHasBeenDeleted'));
+ $file_deleted = true;
+ }
}
}
} else {
@@ -1262,8 +1287,7 @@ switch ($action) {
$admin_course .='\''.api_get_person_name($row[0], $row[1]).'\',';
}
- //If I'm student & I'm in a special work and check the work setting: "New documents are visible for all users"
-
+ //If I'm student & I'm in a special work and check the work setting: "New documents are visible for all users"
if (!$is_allowed_to_edit && $is_special && $uploadvisibledisabled == 1) {
$add_query = ' AND author IN('.$admin_course.'\''.api_get_person_name($_user['firstName'], $_user['lastName']).'\')';
}
@@ -1301,67 +1325,12 @@ switch ($action) {
}
if ($display_list_users_without_publication) {
display_list_users_without_publication($my_folder_data['id']);
- } else {
- //$base_work_dir . '/' . $my_cur_dir_path, 'work/' . $my_cur_dir_path,
+ } else {
display_student_publications_list($work_id, $link_target_parameter, $dateFormatLong, $origin, $add_query);
}
break;
}
-
-/* EDIT COMMAND WORK COMMAND */
-
-$qualification_number = 0;
-if (!empty($edit)) {
-
- if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
- api_not_allowed();
- }
-
- $sql = "SELECT * FROM " . $work_table . " WHERE id='" . $edit . "'";
- $result = Database::query($sql);
-
- if (!empty($result)) {
- $row = Database::fetch_array($result);
- $workTitle = $row['title'];
- $workAuthor = $row['author'];
- $workDescription = $row['description'];
- $workUrl = $row['url'];
- $qualification_number = $row['qualification'];
- }
-}
-
-
-/* COMMANDS SECTION (reserved for others - check they're authors each time) */
-
-
-
-/* EDIT COMMAND WORK COMMAND */
-
-if ($edit) {
-
- if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
- api_not_allowed();
- }
-
- //Get the author ID for that document from the item_property table
- $author_sql = "SELECT * FROM $iprop_table WHERE c_id = $course_id AND tool = 'work' AND insert_user_id='$user_id' AND ref=" . $edit;
- $author_qry = Database::query($author_sql);
- if (Database :: num_rows($author_qry) == 1) {
- //we found the current user is the author
- $sql = "SELECT * FROM " . $work_table . " WHERE id='" . $edit . "'";
- $result = Database::query($sql);
- if ($result) {
- $row = Database::fetch_array($result);
- $workTitle = $row['title'];
- $workAuthor = $row['author'];
- $workDescription = $row['description'];
- $workUrl = $row['url'];
- $qualification_number = $row['qualification'];
- }
- }
-}
-
if ($origin != 'learnpath') {
//we are not in the learning path tool
Display :: display_footer();