Adding option in the copy course in session to another course in session to copy the base content or not see BT#3591

skala
Julio Montoya 13 years ago
parent 35a47fbdf6
commit b230841a43
  1. 36
      main/coursecopy/classes/CourseRestorer.class.php
  2. 2
      main/coursecopy/classes/CourseSelectForm.class.php
  3. 20
      main/coursecopy/copy_course_session.php

@ -154,16 +154,12 @@ class CourseRestorer
// Encoding conversion of the course, if it is needed.
$this->course->to_system_encoding();
/*foreach ($this->tools_to_restore as $tool) {
foreach ($this->tools_to_restore as $tool) {
$function_build = 'restore_'.$tool;
switch($tool) {
case 'documents':
$this->$function_build($session_id, $destination_course_code);
default:
$this->$function_build($session_id, $respect_base_content);
}
$this->$function_build($session_id, $respect_base_content, $destination_course_code);
}
*/
/*
$this->restore_links($session_id);
$this->restore_documents($session_id, $destination_course_code);
$this->restore_quizzes($session_id, $respect_base_content);
@ -192,7 +188,7 @@ class CourseRestorer
//$this->restore_wiki();
//$this->restore_thematic();
//$this->restore_attendance();
}
}*/
if ($update_course_settings) {
$this->restore_course_settings($destination_course_code);
@ -286,7 +282,7 @@ class CourseRestorer
* @param int session id
*
*/
function restore_documents($session_id = 0, $destination_course_code = '') {
function restore_documents($session_id = 0, $respect_base_content = false, $destination_course_code = '') {
$perm = api_get_permissions_for_new_directories();
$course_info = api_get_course_info($destination_course_code);
@ -607,8 +603,7 @@ class CourseRestorer
* Restore scorm documents
* TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
*/
function restore_scorm_documents()
{
function restore_scorm_documents() {
$perm = api_get_permissions_for_new_directories();
if ($this->course->has_resources(RESOURCE_SCORM)) {
@ -723,8 +718,7 @@ class CourseRestorer
/**
* Restore forum-categories
*/
function restore_forum_category($id)
{
function restore_forum_category($id) {
$forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
$resources = $this->course->resources;
$forum_cat = $resources[RESOURCE_FORUMCATEGORY][$id];
@ -755,8 +749,7 @@ class CourseRestorer
/**
* Restore a forum-topic
*/
function restore_topic($id, $forum_id)
{
function restore_topic($id, $forum_id) {
$table = Database :: get_course_table(TABLE_FORUM_THREAD);
$resources = $this->course->resources;
$topic = $resources[RESOURCE_FORUMTOPIC][$id];
@ -803,8 +796,7 @@ class CourseRestorer
* Restore a forum-post
* @TODO Restore tree-structure of posts. For example: attachments to posts.
*/
function restore_post($id, $topic_id, $forum_id)
{
function restore_post($id, $topic_id, $forum_id) {
$table_post = Database :: get_course_table(TABLE_FORUM_POST);
$resources = $this->course->resources;
$post = $resources[RESOURCE_FORUMPOST][$id];
@ -1562,13 +1554,16 @@ class CourseRestorer
//local resource
$path = self::DBUTF8escapestring($item['path']);
if (strval(intval($path)) === $path) {
//@todo Check this validation, why if is session we leave the path the same?
/*if (strval(intval($path)) === $path) {
if (!empty($session_id)) {
$path = intval($path);
} else {
$path = $this->get_new_id($item['item_type'], $path);
}
}
}*/
$path = $this->get_new_id($item['item_type'], $path);
$sql = "INSERT INTO ".$table_item." SET
c_id = ".$this->destination_course_id." ,
@ -1791,6 +1786,7 @@ class CourseRestorer
//transform $tool into one backup/restore constant
//just in case you copy the tool in the same course
//error_log($this->course_origin_id .' - '.$this->destination_course_id);
if ($this->course_origin_id == $this->destination_course_id) {
return $ref;
}

@ -231,9 +231,7 @@ class CourseSelectForm
$course_id = $course_info['real_id'];
// Searching the documents resource that have been set to null because $avoid_serialize is true in the display_form() function
if ($from == 'copy_course') {
if (is_array($resource)) {
$resource = array_keys($resource);

@ -24,7 +24,6 @@ require_once 'classes/CourseBuilder.class.php';
require_once 'classes/CourseRestorer.class.php';
require_once 'classes/CourseSelectForm.class.php';
$xajax = new xajax();
$xajax->registerFunction('search_courses');
@ -114,10 +113,12 @@ function display_form() {
$html .= '</tr></table>';
$html .= '<h3>'.get_lang('TypeOfCopy').'</h3>';
$html .= '<input type="radio" class="checkbox" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>';
$html .= '<input type="radio" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>';
$html .= '<label for="copy_option_1"> '.get_lang('FullCopy').'</label><br/>';
$html .= '<input type="radio" class="checkbox" id="copy_option_2" name="copy_option" value="select_items" disabled="disabled"/>';
$html .= '<label for="copy_option_2"><span id="title_option2" style="color:#aaa"> '.get_lang('LetMeSelectItems').'</span></label><br/><br/>';
$html .= '<input type="radio" id="copy_option_2" name="copy_option" value="select_items" disabled="disabled"/>';
$html .= '<label for="copy_option_2"><span id="title_option2" style="color:#aaa"> '.get_lang('LetMeSelectItems').'</span></label><br/>';
$html .= '<input type="checkbox" id="copy_base_content_id" name="copy_only_session_items" checked="checked" /><label for="copy_base_content_id">'.get_lang('CopyOnlySessionItems').'</label><br /><br/>';
$html .= '<button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;">'.get_lang('CopyCourse').'</button>';
$html .= '</form>';
@ -284,6 +285,11 @@ $htmlHeadXtra[] = '<script type="text/javascript">
Display::display_header($nameTools);
$with_base_content = true;
if (isset($_POST['copy_only_session_items']) && $_POST['copy_only_session_items']) {
$with_base_content = false;
}
/* MAIN CODE */
@ -300,8 +306,6 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (is
$course = CourseSelectForm :: get_posted_course('copy_course', $origin_session, $origin_course);
//print_r($course);
$cr = new CourseRestorer($course);
//$cr->set_file_option($_POST['same_file_name_option']);
$cr->restore($destination_course, $destination_session);
@ -340,7 +344,7 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (is
$course_origin = api_get_course_info($course_code);
$cb = new CourseBuilder('', $course_origin);
$course = $cb->build($origin_session, $course_code);
$course = $cb->build($origin_session, $course_code, $with_base_content);
$cr = new CourseRestorer($course);
//$cr->set_file_option($_POST['same_file_name_option']);
$cr->restore($course_destinatination, $destination_session);
@ -382,7 +386,7 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (is
Display::display_normal_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
$course_origin = api_get_course_info($arr_course_origin[0]);
$cb = new CourseBuilder('', $course_origin);
$course = $cb->build($origin_session, $arr_course_origin[0]);
$course = $cb->build($origin_session, $arr_course_origin[0], $with_base_content);
//$hidden_fields['same_file_name_option'] = $_POST['same_file_name_option'];
$hidden_fields['destination_course'] = $arr_course_destination[0];
$hidden_fields['origin_course'] = $arr_course_origin[0];

Loading…
Cancel
Save