added function for updating item_property table for course progress tool - partial BT#578

skala
Cristian Fasanando 15 years ago
parent 544efbd98d
commit ac4a0b1b86
  1. 29
      main/inc/lib/thematic.lib.php

@ -223,7 +223,7 @@ class Thematic
* @return int last thematic id
*/
public function thematic_save() {
global $_course;
// definition database table
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
@ -232,6 +232,7 @@ class Thematic
$title = Database::escape_string($this->thematic_title);
$content = Database::escape_string($this->thematic_content);
$session_id = intval($this->session_id);
$user_id = api_get_user_id();
// get the maximum display order of all the glossary items
$max_thematic_item = $this->get_max_thematic_item();
@ -241,15 +242,23 @@ class Thematic
$sql = "INSERT INTO $tbl_thematic(title, content, active, display_order, session_id) VALUES ('$title', '$content', 1, ".(intval($max_thematic_item)+1).", $session_id) ";
Database::query($sql);
$last_id = Database::insert_id();
if (Database::affected_rows()) {
// save inside item property table
$last_id = Database::insert_id();
api_item_property_update($_course, TOOL_COURSE_PROGRESS, $last_id,"CourseProgressAdded", $user_id);
}
} else {
// update
$sql = "UPDATE $tbl_thematic SET title = '$title', content = '$content', session_id = $session_id WHERE id = $id ";
Database::query($sql);
$last_id = $id;
if (Database::affected_rows()) {
// save inside item property table
$last_id = Database::insert_id();
api_item_property_update($_course, TOOL_COURSE_PROGRESS, $last_id,"CourseProgressUpdated", $user_id);
}
}
return $last_id;
}
/**
@ -258,21 +267,30 @@ class Thematic
* @return int Affected rows
*/
public function thematic_destroy($thematic_id) {
global $_course;
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
$affected_rows = 0;
$user_id = api_get_user_id();
if (is_array($thematic_id)) {
foreach ($thematic_id as $id) {
$id = intval($id);
$sql = "UPDATE $tbl_thematic SET active = 0 WHERE id = $id";
Database::query($sql);
$affected_rows += Database::affected_rows();
if (!empty($affected_rows)) {
// update row item property table
api_item_property_update($_course, TOOL_COURSE_PROGRESS, $id,"delete", $user_id);
}
}
} else {
$thematic_id = intval($thematic_id);
$sql = "UPDATE $tbl_thematic SET active = 0 WHERE id = $thematic_id";
Database::query($sql);
$affected_rows = Database::affected_rows();
if (!empty($affected_rows)) {
// update row item property table
api_item_property_update($_course, TOOL_COURSE_PROGRESS, $thematic_id,"delete", $user_id);
}
}
return $affected_rows;
@ -329,7 +347,8 @@ class Thematic
$i = 1;
while ($thematic_advance = Database::fetch_row($res)) {
$thematic_advance[1] = api_get_local_time($thematic_advance[1]);
$thematic_advance[1] = api_convert_and_format_date($thematic_advance[1], DATE_TIME_FORMAT_LONG, date_default_timezone_get());
if (api_is_allowed_to_edit(null, true)) {
$actions = '';
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].$param_gradebook.'">'.Display::return_icon('edit.gif',get_lang('Edit')).'</a>&nbsp;';

Loading…
Cancel
Save