diff --git a/main/coursecopy/classes/CourseBuilder.class.php b/main/coursecopy/classes/CourseBuilder.class.php index bdcdd624f0..b0ff869905 100755 --- a/main/coursecopy/classes/CourseBuilder.class.php +++ b/main/coursecopy/classes/CourseBuilder.class.php @@ -74,9 +74,7 @@ class CourseBuilder { $this->build_links($session_id,$course_code); $this->build_course_descriptions($session_id,$course_code); $this->build_wiki($session_id,$course_code); - } else { - $table_link = Database :: get_course_table(TABLE_LINKED_RESOURCES); $table_properties = Database :: get_course_table(TABLE_ITEM_PROPERTY); @@ -106,13 +104,11 @@ class CourseBuilder { } } - foreach ($this->course->resources as $type => $resources) - { + foreach ($this->course->resources as $type => $resources) { foreach ($resources as $id => $resource) { $tool = $resource->get_tool(); - if ($tool != null) - { + if ($tool != null) { $sql = "SELECT * FROM $table_properties WHERE TOOL = '".$tool."' AND ref='".$resource->get_id()."'"; $res = Database::query($sql); $all_properties = array (); @@ -124,15 +120,13 @@ class CourseBuilder { } } } - - return $this->course; } + /** * Build the documents */ - function build_documents($session_id = 0,$course_code = '') - { + function build_documents($session_id = 0,$course_code = '') { if (!empty($course_code) && !empty($session_id)) { $course_info = api_get_course_info($course_code); @@ -176,8 +170,7 @@ class CourseBuilder { /** * Build the forums */ - function build_forums() - { + function build_forums() { $table = Database :: get_course_table(TABLE_FORUM); $sql = 'SELECT * FROM '.$table; $db_result = Database::query($sql); @@ -193,22 +186,20 @@ class CourseBuilder { /** * Build a forum-category */ - function build_forum_category($id) - { + function build_forum_category($id) { $table = Database :: get_course_table(TABLE_FORUM_CATEGORY); $sql = 'SELECT * FROM '.$table.' WHERE cat_id = '.$id; $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) - { + while ($obj = Database::fetch_object($db_result)) { $forum_category = new ForumCategory($obj->cat_id, $obj->cat_title, $obj->cat_comment, $obj->cat_order, $obj->locked, $obj->session_id); $this->course->add_resource($forum_category); } } + /** * Build the forum-topics */ - function build_forum_topics() - { + function build_forum_topics() { $table = Database :: get_course_table(TABLE_FORUM_THREAD); $sql = 'SELECT * FROM '.$table; $db_result = Database::query($sql); @@ -218,6 +209,7 @@ class CourseBuilder { $this->course->add_resource($forum_topic); } } + /** * Build the forum-posts * TODO: All tree structure of posts should be built, attachments for example. @@ -325,18 +317,15 @@ class CourseBuilder { } $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) - { - if (strlen($obj->sound) > 0) - { + while ($obj = Database::fetch_object($db_result)) { + if (strlen($obj->sound) > 0) { $doc = Database::fetch_object(Database::query("SELECT id FROM ".$table_doc." WHERE path = '/audio/".$obj->sound."'")); $obj->sound = $doc->id; } $quiz = new Quiz($obj->id, $obj->title, $obj->description, $obj->random, $obj->type, $obj->active, $obj->sound, $obj->max_attempt, $obj->results_disabled, $obj->access_condition, $obj->start_time, $obj->end_time, $obj->feedback_type, $obj->random_answers, $obj->expired_time); $sql = 'SELECT * FROM '.$table_rel.' WHERE exercice_id = '.$obj->id; $db_result2 = Database::query($sql); - while ($obj2 = Database::fetch_object($db_result2)) - { + while ($obj2 = Database::fetch_object($db_result2)) { $quiz->add_question($obj2->question_id, $obj2->question_order); } $this->course->add_resource($quiz); diff --git a/main/coursecopy/classes/CourseRestorer.class.php b/main/coursecopy/classes/CourseRestorer.class.php index 10d79eb82d..64c55ad965 100755 --- a/main/coursecopy/classes/CourseRestorer.class.php +++ b/main/coursecopy/classes/CourseRestorer.class.php @@ -71,6 +71,7 @@ class CourseRestorer $this->course->destination_path = $course_info['path']; } else { $course_info = Database :: get_course_info($destination_course_code); + $this->course->destination_db = $course_info['database']; $this->course->destination_path = $course_info['directory']; } @@ -969,7 +970,7 @@ class CourseRestorer $question_option_id = Database::insert($table_options, $item); $old_option_ids[$old_id] = $question_option_id; } - $new_answers = Database::find($table_ans,'id, correct', array('question_id = ?'=>$new_id)); + $new_answers = Database::select('id, correct', $table_ans, array('where'=>array('question_id = ?'=>$new_id))); foreach ($new_answers as $answer_item) { $params['correct'] = $old_option_ids[$answer_item['correct']]; $question_option_id = Database::update_query($table_ans, $params, array('id = ?'=>$answer_item['id']));