Adding expires and end date in works when copying course -refs #6599

1.9.x
Yoselyn Castillo 11 years ago
parent 86f04c97be
commit 88e7ba8c7e
  1. 22
      main/coursecopy/classes/CourseRestorer.class.php

@ -2025,10 +2025,12 @@ class CourseRestorer
// check resources inside html from fckeditor tool and copy correct urls into recipient course // check resources inside html from fckeditor tool and copy correct urls into recipient course
$obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($obj->params['description'], $this->course->code, $this->course->destination_path, $this->course->backup_path, $this->course->info['path']); $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($obj->params['description'], $this->course->code, $this->course->destination_path, $this->course->backup_path, $this->course->info['path']);
$id_work = $obj->params['id'];
$obj->params['id'] = null; $obj->params['id'] = null;
$obj->params['c_id'] = $this->destination_course_id; $obj->params['c_id'] = $this->destination_course_id;
$last_id = Database::insert($table_work, $obj->params); $last_id = Database::insert($table_work, $obj->params);
// re-create dir // re-create dir
// @todo check security against injection of dir in crafted course backup here! // @todo check security against injection of dir in crafted course backup here!
$path = $obj->params['url']; $path = $obj->params['url'];
@ -2040,6 +2042,26 @@ class CourseRestorer
} }
if (is_numeric($last_id)) { if (is_numeric($last_id)) {
$sql = 'SELECT *
FROM '.$table_work_assignment.'
WHERE c_id = '.$this->course_origin_id.' AND
publication_id = '.$id_work;
$result = Database::query($sql);
$cant = Database::num_rows($result);
$row = Database::fetch_assoc($result);
$expires_date = $row['expires_on'];
$end_date = $row['ends_on'];
$add_to_calendar = $row['add_to_calendar'];
$enable_calification = $row['enable_calification'];
$sql_add_homework = "INSERT INTO $table_work_assignment SET
c_id = $this->destination_course_id ,
expires_on = '$expires_date',
ends_on = '$end_date',
add_to_calendar = '$add_to_calendar',
enable_qualification = '$enable_calification',
publication_id = '$last_id'";
Database::query($sql_add_homework);
api_item_property_update($this->destination_course_info, 'work', $last_id,"DirectoryCreated", api_get_user_id()); api_item_property_update($this->destination_course_info, 'work', $last_id,"DirectoryCreated", api_get_user_id());
} }
} }

Loading…
Cancel
Save