Julio Montoya 13 anni fa
parent
commit
0eae615656

+ 26 - 4
main/coursecopy/classes/CourseBuilder.class.php

@@ -847,11 +847,17 @@ class CourseBuilder {
 		$table_thematic			= Database :: get_course_table(TABLE_THEMATIC);
 		$table_thematic_advance = Database :: get_course_table(TABLE_THEMATIC_ADVANCE);
 		$table_thematic_plan    = Database :: get_course_table(TABLE_THEMATIC_PLAN);
+        
+        $session_id = intval($session_id);
+        if ($with_base_content) {
+            $session_condition = api_get_session_condition($session_id, true, true);                
+        } else {
+            $session_condition = api_get_session_condition($session_id, true);
+        }
 		
 		$course_id = api_get_course_int_id();
 		
-		
-		$sql = 'SELECT * FROM '.$table_thematic.' WHERE c_id = '.$course_id.' AND session_id = 0 ';
+		$sql = "SELECT * FROM $table_thematic WHERE c_id = $course_id $session_condition ";
 		$db_result = Database::query($sql);
 		while ($row = Database::fetch_array($db_result,'ASSOC')) {
 			$thematic = new Thematic($row);
@@ -860,8 +866,24 @@ class CourseBuilder {
 			$result = Database::query($sql);
 			while ($sub_row = Database::fetch_array($result,'ASSOC')) {				
 				$thematic->add_thematic_advance($sub_row);
-			}			
-			$sql = 'SELECT * FROM '.$table_thematic_plan.' WHERE c_id = '.$course_id.' AND thematic_id = '.$row['id'];
+			}
+            
+            $items  = api_get_item_property_by_tool('thematic_plan', api_get_course_id(), $session_id);		
+            //$items_from_session = api_get_item_property_by_tool('thematic_plan', api_get_course_id(), api_get_session_id());
+            
+            $thematic_plan_id_list = array();
+            if (!empty($items)) {
+                foreach($items as $item) {				
+                    $thematic_plan_id_list[] = $item['ref'];
+                    //$thematic_plan_complete_list[$item['ref']] = $item;
+                }
+            }
+            //$sql = 'SELECT * FROM '.$table_thematic_plan.' WHERE c_id = '.$course_id.' AND thematic_id = '.$row['id'];
+            
+            $sql = "SELECT tp.*
+                FROM $table_thematic_plan tp INNER JOIN $table_thematic t ON (t.id=tp.thematic_id) 			        
+                WHERE  t.c_id = $course_id AND tp.c_id = $course_id  AND thematic_id = {$row['id']}  AND tp.id IN (".implode(', ', $thematic_plan_id_list).") ";
+
 				
 			$result = Database::query($sql);
 			while ($sub_row = Database::fetch_array($result,'ASSOC')) {

+ 6 - 18
main/coursecopy/classes/CourseRestorer.class.php

@@ -1342,16 +1342,11 @@ class CourseRestorer
 					Database::query($sql);
 					$new_id = Database::insert_id();
 					$this->course->resources[RESOURCE_SURVEY][$id]->destination_id = $new_id;
-					foreach ($survey->question_ids as $index => $question_id)
-					{
+					foreach ($survey->question_ids as $index => $question_id) {
 						$qid = $this->restore_survey_question($question_id, $new_id);
-						$sql = "UPDATE ".$table_que." " .
-								"SET survey_id = ".$new_id." WHERE " .
-								"question_id = ".$qid."";
+						$sql = "UPDATE $table_que SET survey_id = $new_id WHERE c_id = ".$this->destination_course_id." AND question_id = $qid";
 						Database::query($sql);
-						$sql = "UPDATE ".$table_ans." ".
-								"SET survey_id = ".$new_id." WHERE " .
-								"question_id = ".$qid."";
+						$sql = "UPDATE $table_ans SET survey_id = $new_id WHERE c_id = ".$this->destination_course_id." AND question_id = $qid";
 						Database::query($sql);
 					}
 				}
@@ -1363,8 +1358,7 @@ class CourseRestorer
 	/**
 	 * Check availability of a survey code
 	 */
-	function is_survey_code_available($survey_code)
-	{
+	function is_survey_code_available($survey_code)	{
 		$table_sur = Database :: get_course_table(TABLE_SURVEY);
 		$sql = "SELECT * FROM $table_sur WHERE c_id = ".$this->destination_course_id." AND code='".self::DBUTF8escapestring($survey_code)."'";
 		$result = Database::query($sql);
@@ -1375,8 +1369,7 @@ class CourseRestorer
 	/**
 	 * Restore survey-questions
 	 */
-	function restore_survey_question($id, $survey_id)
-	{
+	function restore_survey_question($id, $survey_id) {
 		$resources = $this->course->resources;
 		$question = $resources[RESOURCE_SURVEYQUESTION][$id];
 
@@ -1738,11 +1731,6 @@ class CourseRestorer
 		$destination='../../courses/'.$this->course->destination_path.'/work/';		
 		$origin='../../courses/'.$this->course->info['path'].'/work/';
 		self::allow_create_all_directory($origin,$destination,false);
-
-	
-	
-	
-
 	}
 
 /**
@@ -1888,7 +1876,7 @@ class CourseRestorer
 				$last_id = Database::insert($table_thematic, $thematic->params, false);
 				
 				if (is_numeric($last_id)) {
-					api_item_property_update($this->destination_course_info, 'thematic', $last_id,"ThematicAdded", api_get_user_id());
+					api_item_property_update($this->destination_course_info, 'thematic', $last_id, "ThematicAdded", api_get_user_id());
 					
 					foreach($thematic->thematic_advance_list as $thematic_advance) {						
 						unset($thematic_advance['id']);						

+ 1 - 1
main/coursecopy/copy_course_session.php

@@ -119,7 +119,7 @@ function display_form() {
     $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 .= '<input type="checkbox" id="copy_base_content_id" name="copy_only_session_items" /><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>';

+ 1 - 1
main/inc/lib/course.lib.php

@@ -3505,7 +3505,7 @@ class CourseManager {
      * @param id    url id
      * 
      **/    
-    public function update_course_ranking($course_id = null, $session_id = null, $url_id = null, $points_to_add = null, $add_access = true, $add_user = true) {        
+    public static function update_course_ranking($course_id = null, $session_id = null, $url_id = null, $points_to_add = null, $add_access = true, $add_user = true) {        
         //Course catalog stats modifications see #4191        
         $table_course_ranking       = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING);
                 

+ 2 - 2
main/inc/lib/database.lib.php

@@ -1194,7 +1194,7 @@ class Database {
      * @param   array
      * @todo lot of stuff to do here
     */
-    public function parse_conditions($conditions) {        
+    private static function parse_conditions($conditions) {        
         if (empty($conditions)) {
             return '';
         }
@@ -1286,7 +1286,7 @@ class Database {
         return $return_value;
     }
 
-    private function parse_where_conditions($coditions) {
+    public static function parse_where_conditions($coditions) {
         return self::parse_conditions(array('where'=>$coditions));
     }
 

+ 3 - 3
main/inc/lib/database.mysqli.lib.php

@@ -1076,7 +1076,7 @@ class Database {
      * @todo lot of stuff to do here
     */
 
-    public static function select($columns = '*' , $table_name,  $conditions = array(), $type_result = 'all', $option = 'ASSOC') {
+    public static function select($columns, $table_name,  $conditions = array(), $type_result = 'all', $option = 'ASSOC') {
         $conditions = self::parse_conditions($conditions);
 
         //@todo we could do a describe here to check the columns ...
@@ -1116,7 +1116,7 @@ class Database {
      * @param   array
      * @todo lot of stuff to do here
     */
-    private function parse_conditions($conditions) {
+    private static function parse_conditions($conditions) {
         if (empty($conditions)) {
             return '';
         }
@@ -1205,7 +1205,7 @@ class Database {
         return $return_value;
     }
 
-    private function parse_where_conditions($coditions){
+    public static function parse_where_conditions($coditions){
         return self::parse_conditions(array('where'=>$coditions));
     }
 

File diff suppressed because it is too large
+ 603 - 603
main/inc/lib/pear/HTML/QuickForm/advmultiselect.php


Some files were not shown because too many files changed in this diff