Browse Source

Format code

jmontoyaa 8 years ago
parent
commit
0328a9890d

+ 54 - 44
main/coursecopy/classes/Announcement.class.php

@@ -10,25 +10,25 @@ require_once 'Resource.class.php';
  */
  */
 class Announcement extends Coursecopy\Resource
 class Announcement extends Coursecopy\Resource
 {
 {
-	/**
-	 * The title of the announcement
-	 */
+    /**
+     * The title of the announcement
+     */
     public $title;
     public $title;
-	/**
-	 * The content of the announcement
-	 */
+    /**
+     * The content of the announcement
+     */
     public $content;
     public $content;
-	/**
-	 * The date on which this announcement was made
-	 */
+    /**
+     * The date on which this announcement was made
+     */
     public $date;
     public $date;
-	/**
-	 * The display order of this announcement
-	 */
+    /**
+     * The display order of this announcement
+     */
     public $display_order;
     public $display_order;
-	/**
-	 * Has the e-mail been sent?
-	 */
+    /**
+     * Has the e-mail been sent?
+     */
     public $email_sent;
     public $email_sent;
 
 
     public $attachment_path;
     public $attachment_path;
@@ -39,36 +39,46 @@ class Announcement extends Coursecopy\Resource
 
 
     public $attachment_comment;
     public $attachment_comment;
 
 
-	/**
-	 * Create a new announcement
-	 * @param int $id
-	 * @param string $title
-	 * @param string $content
-	 * @param string $date
-	 * @param int display_order
-	 */
-    function __construct($id, $title, $content, $date, $display_order, $email_sent, $path, $filename, $size, $comment)
-    {
-		parent::__construct($id,RESOURCE_ANNOUNCEMENT);
+    /**
+     * Create a new announcement
+     * @param int $id
+     * @param string $title
+     * @param string $content
+     * @param string $date
+     * @param int display_order
+     */
+    public function __construct(
+        $id,
+        $title,
+        $content,
+        $date,
+        $display_order,
+        $email_sent,
+        $path,
+        $filename,
+        $size,
+        $comment
+    ) {
+        parent::__construct($id,RESOURCE_ANNOUNCEMENT);
 
 
-		$this->content	= $content;
-		$this->title 	= $title;
-		$this->date 	= $date;
-		$this->display_order	= $display_order;
-		$this->email_sent	 	= $email_sent;
+        $this->content	= $content;
+        $this->title 	= $title;
+        $this->date 	= $date;
+        $this->display_order	= $display_order;
+        $this->email_sent	 	= $email_sent;
 
 
-		$this->attachment_path 	= $path;
-		$this->attachment_filename = $filename;
-		$this->attachment_size 	= $size;
-		$this->attachment_comment 	= $comment;
-	}
+        $this->attachment_path 	= $path;
+        $this->attachment_filename = $filename;
+        $this->attachment_size 	= $size;
+        $this->attachment_comment 	= $comment;
+    }
 
 
-	/**
-	 * Show this announcement
-	 */
-	function show()
-	{
-		parent::show();
-		echo $this->date.': '.$this->title;
-	}
+    /**
+     * Show this announcement
+     */
+    function show()
+    {
+        parent::show();
+        echo $this->date.': '.$this->title;
+    }
 }
 }

+ 13 - 13
main/coursecopy/classes/Attendance.class.php

@@ -13,28 +13,28 @@ class Attendance extends Coursecopy\Resource
     public $params = array();
     public $params = array();
     public $attendance_calendar = array();
     public $attendance_calendar = array();
 
 
-	/**
-	 * Create a new Thematic
-	 *
-	 * @param array parameters
-	 */
+    /**
+     * Create a new Thematic
+     *
+     * @param array parameters
+     */
     public function __construct($params)
     public function __construct($params)
     {
     {
-		parent::__construct($params['id'], RESOURCE_ATTENDANCE);
-		$this->params = $params;
-	}
+        parent::__construct($params['id'], RESOURCE_ATTENDANCE);
+        $this->params = $params;
+    }
 
 
     /**
     /**
      * @inheritdoc
      * @inheritdoc
      */
      */
     public function show()
     public function show()
     {
     {
-		parent::show();
-		echo $this->params['name'];
-	}
+        parent::show();
+        echo $this->params['name'];
+    }
 
 
     public function add_attendance_calendar($data)
     public function add_attendance_calendar($data)
     {
     {
-		$this->attendance_calendar[] = $data;
-	}
+        $this->attendance_calendar[] = $data;
+    }
 }
 }

+ 36 - 33
main/coursecopy/classes/CourseDescription.class.php

@@ -1,6 +1,7 @@
 <?php
 <?php
 /* For licensing terms, see /license.txt */
 /* For licensing terms, see /license.txt */
 namespace Coursecopy;
 namespace Coursecopy;
+
 require_once 'Resource.class.php';
 require_once 'Resource.class.php';
 
 
 /**
 /**
@@ -10,39 +11,41 @@ require_once 'Resource.class.php';
  */
  */
 class CourseDescription extends Resource
 class CourseDescription extends Resource
 {
 {
-	/**
-	 * The title
-	 */
-	public $title;
-	/**
-	 * The content
-	 */
-	public $content;
-	/**
-	 * The description type
-	 */
-	public $description_type;
+    /**
+     * The title
+     */
+    public $title;
+    
+    /**
+     * The content
+     */
+    public $content;
+
+    /**
+     * The description type
+     */
+    public $description_type;
 
 
-	/**
-	 * Create a new course description
-	 * @param int $id
-	 * @param string $title
-	 * @param string $content
-	 */
-	public function __construct($id,$title,$content,$description_type)
-	{
-		parent::__construct($id,RESOURCE_COURSEDESCRIPTION);
-		$this->title = $title;
-		$this->content = $content;
-		$this->description_type = $description_type;
-	}
+    /**
+     * Create a new course description
+     * @param int $id
+     * @param string $title
+     * @param string $content
+     */
+    public function __construct($id, $title, $content, $description_type)
+    {
+        parent::__construct($id, RESOURCE_COURSEDESCRIPTION);
+        $this->title = $title;
+        $this->content = $content;
+        $this->description_type = $description_type;
+    }
 
 
-	/**
-	 * Show this Event
-	 */
-	function show()
-	{
-		parent::show();
-		echo $this->title;
-	}
+    /**
+     * Show this Event
+     */
+    public function show()
+    {
+        parent::show();
+        echo $this->title;
+    }
 }
 }

+ 1 - 2
main/coursecopy/classes/CourseSelectForm.class.php

@@ -16,7 +16,7 @@ class CourseSelectForm
 	 * @param array $hidden_fields Hidden fields to add to the form.
 	 * @param array $hidden_fields Hidden fields to add to the form.
 	 * @param boolean the document array will be serialize. This is used in the course_copy.php file
 	 * @param boolean the document array will be serialize. This is used in the course_copy.php file
 	 */
 	 */
-	static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
+	public static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
     {
     {
         global $charset;
         global $charset;
         $resource_titles[RESOURCE_GRADEBOOK] = get_lang('Gradebook');
         $resource_titles[RESOURCE_GRADEBOOK] = get_lang('Gradebook');
@@ -224,7 +224,6 @@ class CourseSelectForm
 
 
 						foreach ($resources as $id => $resource) {
 						foreach ($resources as $id => $resource) {
                             if ($resource) {
                             if ($resource) {
-								// Event obj in 1.9.x in 1.10.x the class is CalendarEvent
                                 Coursecopy\Resource::setClassType($resource);
                                 Coursecopy\Resource::setClassType($resource);
                                 echo '<label class="checkbox">';
                                 echo '<label class="checkbox">';
                                 echo '<input type="checkbox" name="resource['.$type.']['.$id.']"  id="resource['.$type.']['.$id.']" />';
                                 echo '<input type="checkbox" name="resource['.$type.']['.$id.']"  id="resource['.$type.']['.$id.']" />';

+ 19 - 18
main/coursecopy/classes/CourseSession.class.php

@@ -11,24 +11,25 @@ require_once 'Resource.class.php';
 class CourseSession extends Coursecopy\Resource
 class CourseSession extends Coursecopy\Resource
 {
 {
     // The title session
     // The title session
-	public $title;
+    public $title;
 
 
-	/**
-	 * Create a new Session
-	 * @param int $id
-	 * @param string $title
-	 */
-	public function __construct($id,$title)
-	{
-		parent::__construct($id, RESOURCE_SESSION_COURSE);
-		$this->title = $title;
-	}
+    /**
+     * Create a new Session
+     * @param int $id
+     * @param string $title
+     */
+    public function __construct($id,$title)
+    {
+        parent::__construct($id, RESOURCE_SESSION_COURSE);
+        $this->title = $title;
+    }
 
 
-	/**
-	 * Show this Event
-	 */
-	function show() {
-		parent::show();
-		echo $this->title;
-	}
+    /**
+     * Show this Event
+     */
+    public function show()
+    {
+        parent::show();
+        echo $this->title;
+    }
 }
 }

+ 284 - 283
main/coursecopy/classes/DummyCourseCreator.class.php

@@ -20,289 +20,290 @@ require_once 'CourseRestorer.class.php';
  */
  */
 class DummyCourseCreator
 class DummyCourseCreator
 {
 {
-	/**
-	 * The dummy course
-	 */
-	public $course;
-	/**
-	 *
-	 */
-	public $default_property = array();
+    /**
+     * The dummy course
+     */
+    public $course;
+    /**
+     *
+     */
+    public $default_property = array();
 
 
-	/**
-	 * Create the dummy course
-	 */
-	public function create_dummy_course($course_code)
-	{
-		$this->default_property['insert_user_id'] = '1';
-		$this->default_property['insert_date'] = date('Y-m-d H:i:s');
-		$this->default_property['lastedit_date'] = date('Y-m-d H:i:s');
-		$this->default_property['lastedit_user_id'] = '1';
-		$this->default_property['to_group_id'] = '0';
-		$this->default_property['to_user_id'] = null;
-		$this->default_property['visibility'] = '1';
-		$this->default_property['start_visible'] = '0000-00-00 00:00:00';
-		$this->default_property['end_visible'] =  '0000-00-00 00:00:00';
+    /**
+     * Create the dummy course
+     */
+    public function create_dummy_course($course_code)
+    {
+        $this->default_property['insert_user_id'] = '1';
+        $this->default_property['insert_date'] = date('Y-m-d H:i:s');
+        $this->default_property['lastedit_date'] = date('Y-m-d H:i:s');
+        $this->default_property['lastedit_user_id'] = '1';
+        $this->default_property['to_group_id'] = '0';
+        $this->default_property['to_user_id'] = null;
+        $this->default_property['visibility'] = '1';
+        $this->default_property['start_visible'] = '0000-00-00 00:00:00';
+        $this->default_property['end_visible'] =  '0000-00-00 00:00:00';
 
 
-		$course = api_get_course_info($course_code);
-		$this->course = new Course();
-		$tmp_path = api_get_path(SYS_COURSE_PATH).$course['directory'].'/document/tmp_'.uniqid('');
-		@mkdir($tmp_path, api_get_permissions_for_new_directories(), true);
-		$this->course->backup_path = $tmp_path;
-		$this->create_dummy_links();
-		$this->create_dummy_events();
-		$this->create_dummy_forums();
-		$this->create_dummy_announcements();
-		$this->create_dummy_documents();
-		$this->create_dummy_learnpaths();
-		$cr = new CourseRestorer($this->course);
-		$cr->set_file_option(FILE_OVERWRITE);
-		$cr->restore($course_code);
-		rmdirr($tmp_path);
-	}
-	/**
-	 * Create dummy documents
-	 */
-	function create_dummy_documents()
-	{
-		$course = api_get_course_info();
-		$course_doc_path = $this->course->backup_path.'/document/';
-		$number_of_documents = rand(10, 30);
-		$extensions = array ('html', 'doc');
-		$directories = array();
-		$property = $this->default_property;
-		$property['lastedit_type'] = 'DocumentAdded';
-		$property['tool'] = TOOL_DOCUMENT;
-		$doc_id = 0;
-		for ($doc_id = 1; $doc_id < $number_of_documents; $doc_id ++)
-		{
-			$path = '';
-			$doc_type = rand(0, count($extensions) - 1);
-			$extension = $extensions[$doc_type];
-			$filename = $this->get_dummy_content('title').'_'.$doc_id.'.'.$extension;
-			$content = $this->get_dummy_content('text');
-			$dirs = rand(0, 3);
-			for ($i = 0; $i < $dirs; $i ++)
-			{
-				$path .= 'directory/';
-				$directories[$path] = 1;
-			}
-			$dir_to_make = $course_doc_path.$path;
-			if (!is_dir($dir_to_make))
-			{
-				@mkdir($dir_to_make, api_get_permissions_for_new_directories(), true);
-			}
-			$file = $course_doc_path.$path.$filename;
-			$fp = fopen($file, 'w');
-			fwrite($fp, $content);
-			fclose($fp);
-			$size = filesize($file);
-			$document = new Document($doc_id, '/'.$path.$filename,$this->get_dummy_content('description'),$this->get_dummy_content('title'), 'file', $size);
-			$document->item_properties[] = $property;
-			$this->course->add_resource($document);
-		}
-		foreach($directories as $path => $flag)
-		{
-			$path = substr($path,0,strlen($path)-1);
-			$document = new Document($doc_id++,'/'.$path, $this->get_dummy_content('description'),$this->get_dummy_content('title'),'folder',0);
-			$property['lastedit_type'] = 'FolderCreated';
-			$document->item_properties[] = $property;
-			$this->course->add_resource($document);
-		}
-	}
-	/**
-	 * Create dummy announcements
-	 */
-	function create_dummy_announcements()
-	{
-		$property = $this->default_property;
-		$property['lastedit_type'] = 'AnnouncementAdded';
-		$property['tool'] = TOOL_ANNOUNCEMENT;
-		$number_of_announcements = rand(10, 30);
-		for ($i = 0; $i < $number_of_announcements; $i ++)
-		{
-			$time = mktime(rand(1, 24), rand(1, 60), 0, rand(1, 12), rand(1, 28), intval(date('Y')));
-			$date = date('Y-m-d', $time);
-			$announcement = new Announcement($i,$this->get_dummy_content('title'),$this->get_dummy_content('text'), $date,0);
-			$announcement->item_properties[] = $property;
-			$this->course->add_resource($announcement);
-		}
-	}
-	/**
-	 * Create dummy events
-	 */
-	function create_dummy_events()
-	{
-		$number_of_events = rand(10, 30);
-		$property = $this->default_property;
-		$property['lastedit_type'] = 'AgendaAdded';
-		$property['tool'] = TOOL_CALENDAR_EVENT;
-		for ($i = 0; $i < $number_of_events; $i ++)
-		{
-			$hour = rand(1,24);
-			$minute = rand(1,60);
-			$second = rand(1,60);
-			$day = rand(1,28);
-			$month = rand(1,12);
-			$year = intval(date('Y'));
-			$time = mktime($hour,$minute,$second,$month,$day,$year);
-			$start_date = date('Y-m-d H:m:s', $time);
-			$hour = rand($hour,24);
-			$minute = rand($minute,60);
-			$second = rand($second,60);
-			$day = rand($day,28);
-			$month = rand($month,12);
-			$year = intval(date('Y'));
-			$time = mktime($hour,$minute,$second,$month,$day,$year);
-			$end_date = date('Y-m-d H:m:s', $time);
-			$event = new CalendarEvent(
-				$i,
-				$this->get_dummy_content('title'),
-				$this->get_dummy_content('text'),
-				$start_date,
-				$end_date
-			);
-			$event->item_properties[] = $property;
-			$this->course->add_resource($event);
-		}
-	}
-	/**
-	 * Create dummy links
-	 */
-	function create_dummy_links()
-	{
-		// create categorys
-		$number_of_categories = rand(5, 10);
-		for ($i = 0; $i < $number_of_categories; $i ++)
-		{
-			$linkcat = new LinkCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'),$i);
-			$this->course->add_resource($linkcat);
-		}
-		// create links
-		$number_of_links = rand(5, 50);
-		$on_homepage = rand(0,20) == 0 ? 1 : 0;
-		$property = $this->default_property;
-		$property['lastedit_type'] = 'LinkAdded';
-		$property['tool'] = TOOL_LINK;
-		for ($i = 0; $i < $number_of_links; $i ++)
-		{
-			$link = new Link($i, $this->get_dummy_content('title'), 'http://www.google.com/search?q='.$this->get_dummy_content('title'), $this->get_dummy_content('description'), rand(0, $number_of_categories -1),$on_homepage);
-			$link->item_properties[] = $property;
-			$this->course->add_resource($link);
-		}
-	}
-	/**
-	 * Create dummy forums
-	 */
-	function create_dummy_forums()
-	{
-		$number_of_categories = rand(2, 6);
-		$number_of_forums = rand(5, 50);
-		$number_of_topics = rand(30, 100);
-		$number_of_posts = rand(100, 1000);
-		$last_forum_post = array ();
-		$last_topic_post = array ();
-		// create categorys
-		$order = 1;
-		for ($i = 1; $i <= $number_of_categories; $i ++)
-		{
-			$forumcat = new ForumCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), $order, 0, 0);
-			$this->course->add_resource($forumcat);
-			$order++;
-		}
-		// create posts
-		for ($post_id = 1; $post_id <= $number_of_posts; $post_id ++)
-		{
-			$topic_id = rand(1, $number_of_topics);
-			$last_topic_post[$topic_id] = $post_id;
-			$post = new ForumPost($post_id, $this->get_dummy_content('title'), $this->get_dummy_content('text'), date('Y-m-d H:i:s'), 1, 'Portal Administrator', 0, 0, $topic_id, 0, 1);
-			$this->course->add_resource($post);
-		}
-		// create topics
-		for ($topic_id = 1; $topic_id <= $number_of_topics; $topic_id ++)
-		{
-			$forum_id = rand(1, $number_of_forums);
-			$last_forum_post[$forum_id] = $last_topic_post[$topic_id];
-			$topic = new ForumTopic($topic_id, $this->get_dummy_content('title'), '2011-03-31 12:10:00', 'Chamilo', 'Administrator', 0, $forum_id, $last_topic_post[$topic_id]);
-			$this->course->add_resource($topic);
-		}
-		// create forums
-		for ($forum_id = 1; $forum_id <= $number_of_forums; $forum_id ++)
-		{
-			$forum = new Forum($forum_id, $this->get_dummy_content('title'),$this->get_dummy_content('description'), rand(1, $number_of_categories), $last_forum_post[$forum_id]);
-			$this->course->add_resource($forum);
-		}
-	}
-	/**
-	 * Create dummy learnpaths
-	 */
-	function create_dummy_learnpaths()
-	{
-		$number_of_learnpaths = rand(3,5);
-		$global_item_id = 1;
-		for($i=1; $i<=$number_of_learnpaths;$i++)
-		{
-		$chapters = array();
-		$number_of_chapters = rand(1,6);
-		for($chapter_id = 1; $chapter_id <= $number_of_chapters; $chapter_id++)
-		{
-			$chapter['name'] = $this->get_dummy_content('title');
-			$chapter['description'] = $this->get_dummy_content('description');
-			$chapter['display_order'] = $chapter_id;
-			$chapter['items'] = array();
-			$number_of_items = rand(5,20);
-			for( $item_id = 1; $item_id<$number_of_items; $item_id++)
-			{
-				$types = array(RESOURCE_ANNOUNCEMENT, RESOURCE_EVENT, RESOURCE_DOCUMENT,RESOURCE_LINK,RESOURCE_FORUM,RESOURCE_FORUMPOST,RESOURCE_FORUMTOPIC);
-				$type = $types[rand(0,count($types)-1)];
-				$resources = $this->course->resources[$type];
-				$resource = $resources[rand(0,count($resources)-1)];
-				$item = array();
-				$item['type'] = $resource->type;
-				$item['id'] = $resource->source_id;
-				$item['display_order'] = $item_id;
-				$item['title'] = $this->get_dummy_content('title');
-				$item['description'] = $this->get_dummy_content('description');
-				$item['ref_id'] = $global_item_id;
-				if( rand(0,5) == 1 && $item_id > 1)
-				{
-					$item['prereq_type'] = 'i';
-					$item['prereq'] = rand($global_item_id - $item_id,$global_item_id-1);
-				}
-				$chapter['items'][] = $item;
-				$global_item_id++;
-			}
-			$chapters[] = $chapter;
-		}
-		$lp = new CourseCopyLearnpath($i,$this->get_dummy_content('title'),$this->get_dummy_content('description'),1,$chapters);
-		$this->course->add_resource($lp);
-		}
-	}
-	/**
-	 * Get dummy titles, descriptions and texts
-	 */
-	function get_dummy_content($type)
-	{
-		$dummy_text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque lectus. Duis sodales. Vivamus et nunc. Phasellus interdum est a lorem. Fusce venenatis luctus lectus. Mauris quis turpis ac erat rhoncus suscipit. Phasellus elit dui, semper at, porta ut, egestas ac, enim. Quisque pellentesque, nisl nec consequat mollis, ipsum justo pellentesque nibh, non faucibus odio ante at lorem. Donec vitae pede ut felis ultricies semper. Suspendisse velit nibh, interdum quis, gravida nec, dapibus ac, leo. Cras id sem ut tellus tincidunt scelerisque. Aenean ac magna feugiat dolor accumsan dignissim. Integer eget nisl.
-		Ut sit amet nulla. Vestibulum venenatis posuere mauris. Nullam magna leo, blandit luctus, consequat quis, gravida nec, justo. Nam pede. Etiam ut nisl. In at quam scelerisque sapien faucibus commodo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Proin mattis lorem quis nunc. Praesent placerat ligula id elit. Aenean blandit, purus sit amet pharetra auctor, libero orci rutrum felis, sit amet sodales mauris ipsum ultricies sapien. Vivamus wisi. Cras elit elit, ullamcorper ac, interdum nec, pulvinar nec, lacus. In lacus. Vivamus auctor, arcu vitae tincidunt porta, eros lacus tristique justo, vitae semper risus neque eget massa. Vivamus turpis.
-		Aenean ac wisi non enim aliquam scelerisque. Praesent eget mi. Vestibulum volutpat pulvinar justo. Phasellus sapien ante, pharetra id, bibendum sed, porta non, purus. Maecenas leo velit, luctus quis, porta non, feugiat sit amet, sapien. Proin vitae augue ut massa adipiscing placerat. Morbi ac risus. Proin dapibus eros egestas quam. Fusce fermentum lobortis elit. Duis lectus tellus, convallis nec, lobortis vel, accumsan ut, nunc. Nunc est. Donec ullamcorper laoreet quam.
-		Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Suspendisse potenti. Mauris mi. Vivamus risus lacus, faucibus sit amet, sollicitudin a, blandit et, justo. In hendrerit. Sed imperdiet, eros at fringilla tempor, turpis augue semper enim, quis rhoncus nibh enim quis dui. Sed massa sapien, mattis et, laoreet sit amet, dignissim nec, urna. Integer laoreet quam quis lectus. Curabitur convallis gravida dui. Nam metus. Ut sit amet augue in nibh interdum scelerisque. Donec venenatis, lacus et pulvinar euismod, libero massa condimentum pede, commodo tristique nunc massa eu quam. Donec vulputate. Aenean in nibh. Phasellus porttitor. Donec molestie, sem ac porttitor vulputate, mauris dui egestas libero, ac lobortis dolor sem vel ligula. Nam vulputate pretium libero. Cras accumsan. Vivamus lacinia sapien sit amet elit.
-		Duis bibendum elementum justo. Duis posuere. Fusce nulla odio, posuere eget, condimentum nec, venenatis eu, elit. In hac habitasse platea dictumst. Aenean ac sem in enim imperdiet feugiat. Integer tincidunt lectus at elit. Integer magna lacus, vehicula quis, eleifend eget, suscipit vitae, leo. Nunc porta augue nec enim. Curabitur vehicula volutpat enim. Aliquam consequat. Vestibulum rhoncus tellus vitae erat. Integer est. Quisque fermentum leo nec odio. Suspendisse lobortis sollicitudin augue. Nullam urna mi, suscipit eu, sagittis laoreet, ultrices ac, sem. Aliquam enim tortor, hendrerit non, cursus a, tristique sit amet, sapien. Suspendisse potenti. Aenean semper placerat neque.';
-		switch($type)
-		{
-		 case 'description':
-		 	$descriptions = explode(".",$dummy_text);
-		 	return $descriptions[rand(0,count($descriptions)-1)];
-		 	break;
-		 case 'title':
-		 	$dummy_text = str_replace(array("\n",'.',',',"\t"),array(' ','','',' '),$dummy_text);
-		 	$titles = explode(" ",$dummy_text);
-		 	return trim($titles[rand(0,count($titles)-1)]);
-		 	break;
-		 case 'text':
-		 	$texts = explode("\n",$dummy_text);
-		 	return $texts[rand(0,count($texts)-1)];
-		 	break;
-		}
-	}
+        $course = api_get_course_info($course_code);
+        $this->course = new Course();
+        $tmp_path = api_get_path(SYS_COURSE_PATH).$course['directory'].'/document/tmp_'.uniqid('');
+        @mkdir($tmp_path, api_get_permissions_for_new_directories(), true);
+        $this->course->backup_path = $tmp_path;
+        $this->create_dummy_links();
+        $this->create_dummy_events();
+        $this->create_dummy_forums();
+        $this->create_dummy_announcements();
+        $this->create_dummy_documents();
+        $this->create_dummy_learnpaths();
+        $cr = new CourseRestorer($this->course);
+        $cr->set_file_option(FILE_OVERWRITE);
+        $cr->restore($course_code);
+        rmdirr($tmp_path);
+    }
+    
+    /**
+     * Create dummy documents
+     */
+    public function create_dummy_documents()
+    {
+        $course = api_get_course_info();
+        $course_doc_path = $this->course->backup_path.'/document/';
+        $number_of_documents = rand(10, 30);
+        $extensions = array ('html', 'doc');
+        $directories = array();
+        $property = $this->default_property;
+        $property['lastedit_type'] = 'DocumentAdded';
+        $property['tool'] = TOOL_DOCUMENT;
+        $doc_id = 0;
+        for ($doc_id = 1; $doc_id < $number_of_documents; $doc_id ++)
+        {
+            $path = '';
+            $doc_type = rand(0, count($extensions) - 1);
+            $extension = $extensions[$doc_type];
+            $filename = $this->get_dummy_content('title').'_'.$doc_id.'.'.$extension;
+            $content = $this->get_dummy_content('text');
+            $dirs = rand(0, 3);
+            for ($i = 0; $i < $dirs; $i ++)
+            {
+                $path .= 'directory/';
+                $directories[$path] = 1;
+            }
+            $dir_to_make = $course_doc_path.$path;
+            if (!is_dir($dir_to_make))
+            {
+                @mkdir($dir_to_make, api_get_permissions_for_new_directories(), true);
+            }
+            $file = $course_doc_path.$path.$filename;
+            $fp = fopen($file, 'w');
+            fwrite($fp, $content);
+            fclose($fp);
+            $size = filesize($file);
+            $document = new Document($doc_id, '/'.$path.$filename,$this->get_dummy_content('description'),$this->get_dummy_content('title'), 'file', $size);
+            $document->item_properties[] = $property;
+            $this->course->add_resource($document);
+        }
+        foreach($directories as $path => $flag)
+        {
+            $path = substr($path,0,strlen($path)-1);
+            $document = new Document($doc_id++,'/'.$path, $this->get_dummy_content('description'),$this->get_dummy_content('title'),'folder',0);
+            $property['lastedit_type'] = 'FolderCreated';
+            $document->item_properties[] = $property;
+            $this->course->add_resource($document);
+        }
+    }
+    /**
+     * Create dummy announcements
+     */
+    function create_dummy_announcements()
+    {
+        $property = $this->default_property;
+        $property['lastedit_type'] = 'AnnouncementAdded';
+        $property['tool'] = TOOL_ANNOUNCEMENT;
+        $number_of_announcements = rand(10, 30);
+        for ($i = 0; $i < $number_of_announcements; $i ++)
+        {
+            $time = mktime(rand(1, 24), rand(1, 60), 0, rand(1, 12), rand(1, 28), intval(date('Y')));
+            $date = date('Y-m-d', $time);
+            $announcement = new Announcement($i,$this->get_dummy_content('title'),$this->get_dummy_content('text'), $date,0);
+            $announcement->item_properties[] = $property;
+            $this->course->add_resource($announcement);
+        }
+    }
+    /**
+     * Create dummy events
+     */
+    function create_dummy_events()
+    {
+        $number_of_events = rand(10, 30);
+        $property = $this->default_property;
+        $property['lastedit_type'] = 'AgendaAdded';
+        $property['tool'] = TOOL_CALENDAR_EVENT;
+        for ($i = 0; $i < $number_of_events; $i ++)
+        {
+            $hour = rand(1,24);
+            $minute = rand(1,60);
+            $second = rand(1,60);
+            $day = rand(1,28);
+            $month = rand(1,12);
+            $year = intval(date('Y'));
+            $time = mktime($hour,$minute,$second,$month,$day,$year);
+            $start_date = date('Y-m-d H:m:s', $time);
+            $hour = rand($hour,24);
+            $minute = rand($minute,60);
+            $second = rand($second,60);
+            $day = rand($day,28);
+            $month = rand($month,12);
+            $year = intval(date('Y'));
+            $time = mktime($hour,$minute,$second,$month,$day,$year);
+            $end_date = date('Y-m-d H:m:s', $time);
+            $event = new CalendarEvent(
+                $i,
+                $this->get_dummy_content('title'),
+                $this->get_dummy_content('text'),
+                $start_date,
+                $end_date
+            );
+            $event->item_properties[] = $property;
+            $this->course->add_resource($event);
+        }
+    }
+    /**
+     * Create dummy links
+     */
+    function create_dummy_links()
+    {
+        // create categorys
+        $number_of_categories = rand(5, 10);
+        for ($i = 0; $i < $number_of_categories; $i ++)
+        {
+            $linkcat = new LinkCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'),$i);
+            $this->course->add_resource($linkcat);
+        }
+        // create links
+        $number_of_links = rand(5, 50);
+        $on_homepage = rand(0,20) == 0 ? 1 : 0;
+        $property = $this->default_property;
+        $property['lastedit_type'] = 'LinkAdded';
+        $property['tool'] = TOOL_LINK;
+        for ($i = 0; $i < $number_of_links; $i ++)
+        {
+            $link = new Link($i, $this->get_dummy_content('title'), 'http://www.google.com/search?q='.$this->get_dummy_content('title'), $this->get_dummy_content('description'), rand(0, $number_of_categories -1),$on_homepage);
+            $link->item_properties[] = $property;
+            $this->course->add_resource($link);
+        }
+    }
+    /**
+     * Create dummy forums
+     */
+    function create_dummy_forums()
+    {
+        $number_of_categories = rand(2, 6);
+        $number_of_forums = rand(5, 50);
+        $number_of_topics = rand(30, 100);
+        $number_of_posts = rand(100, 1000);
+        $last_forum_post = array ();
+        $last_topic_post = array ();
+        // create categorys
+        $order = 1;
+        for ($i = 1; $i <= $number_of_categories; $i ++)
+        {
+            $forumcat = new ForumCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), $order, 0, 0);
+            $this->course->add_resource($forumcat);
+            $order++;
+        }
+        // create posts
+        for ($post_id = 1; $post_id <= $number_of_posts; $post_id ++)
+        {
+            $topic_id = rand(1, $number_of_topics);
+            $last_topic_post[$topic_id] = $post_id;
+            $post = new ForumPost($post_id, $this->get_dummy_content('title'), $this->get_dummy_content('text'), date('Y-m-d H:i:s'), 1, 'Portal Administrator', 0, 0, $topic_id, 0, 1);
+            $this->course->add_resource($post);
+        }
+        // create topics
+        for ($topic_id = 1; $topic_id <= $number_of_topics; $topic_id ++)
+        {
+            $forum_id = rand(1, $number_of_forums);
+            $last_forum_post[$forum_id] = $last_topic_post[$topic_id];
+            $topic = new ForumTopic($topic_id, $this->get_dummy_content('title'), '2011-03-31 12:10:00', 'Chamilo', 'Administrator', 0, $forum_id, $last_topic_post[$topic_id]);
+            $this->course->add_resource($topic);
+        }
+        // create forums
+        for ($forum_id = 1; $forum_id <= $number_of_forums; $forum_id ++)
+        {
+            $forum = new Forum($forum_id, $this->get_dummy_content('title'),$this->get_dummy_content('description'), rand(1, $number_of_categories), $last_forum_post[$forum_id]);
+            $this->course->add_resource($forum);
+        }
+    }
+    /**
+     * Create dummy learnpaths
+     */
+    function create_dummy_learnpaths()
+    {
+        $number_of_learnpaths = rand(3,5);
+        $global_item_id = 1;
+        for($i=1; $i<=$number_of_learnpaths;$i++)
+        {
+        $chapters = array();
+        $number_of_chapters = rand(1,6);
+        for($chapter_id = 1; $chapter_id <= $number_of_chapters; $chapter_id++)
+        {
+            $chapter['name'] = $this->get_dummy_content('title');
+            $chapter['description'] = $this->get_dummy_content('description');
+            $chapter['display_order'] = $chapter_id;
+            $chapter['items'] = array();
+            $number_of_items = rand(5,20);
+            for( $item_id = 1; $item_id<$number_of_items; $item_id++)
+            {
+                $types = array(RESOURCE_ANNOUNCEMENT, RESOURCE_EVENT, RESOURCE_DOCUMENT,RESOURCE_LINK,RESOURCE_FORUM,RESOURCE_FORUMPOST,RESOURCE_FORUMTOPIC);
+                $type = $types[rand(0,count($types)-1)];
+                $resources = $this->course->resources[$type];
+                $resource = $resources[rand(0,count($resources)-1)];
+                $item = array();
+                $item['type'] = $resource->type;
+                $item['id'] = $resource->source_id;
+                $item['display_order'] = $item_id;
+                $item['title'] = $this->get_dummy_content('title');
+                $item['description'] = $this->get_dummy_content('description');
+                $item['ref_id'] = $global_item_id;
+                if( rand(0,5) == 1 && $item_id > 1)
+                {
+                    $item['prereq_type'] = 'i';
+                    $item['prereq'] = rand($global_item_id - $item_id,$global_item_id-1);
+                }
+                $chapter['items'][] = $item;
+                $global_item_id++;
+            }
+            $chapters[] = $chapter;
+        }
+        $lp = new CourseCopyLearnpath($i,$this->get_dummy_content('title'),$this->get_dummy_content('description'),1,$chapters);
+        $this->course->add_resource($lp);
+        }
+    }
+    /**
+     * Get dummy titles, descriptions and texts
+     */
+    function get_dummy_content($type)
+    {
+        $dummy_text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque lectus. Duis sodales. Vivamus et nunc. Phasellus interdum est a lorem. Fusce venenatis luctus lectus. Mauris quis turpis ac erat rhoncus suscipit. Phasellus elit dui, semper at, porta ut, egestas ac, enim. Quisque pellentesque, nisl nec consequat mollis, ipsum justo pellentesque nibh, non faucibus odio ante at lorem. Donec vitae pede ut felis ultricies semper. Suspendisse velit nibh, interdum quis, gravida nec, dapibus ac, leo. Cras id sem ut tellus tincidunt scelerisque. Aenean ac magna feugiat dolor accumsan dignissim. Integer eget nisl.
+        Ut sit amet nulla. Vestibulum venenatis posuere mauris. Nullam magna leo, blandit luctus, consequat quis, gravida nec, justo. Nam pede. Etiam ut nisl. In at quam scelerisque sapien faucibus commodo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Proin mattis lorem quis nunc. Praesent placerat ligula id elit. Aenean blandit, purus sit amet pharetra auctor, libero orci rutrum felis, sit amet sodales mauris ipsum ultricies sapien. Vivamus wisi. Cras elit elit, ullamcorper ac, interdum nec, pulvinar nec, lacus. In lacus. Vivamus auctor, arcu vitae tincidunt porta, eros lacus tristique justo, vitae semper risus neque eget massa. Vivamus turpis.
+        Aenean ac wisi non enim aliquam scelerisque. Praesent eget mi. Vestibulum volutpat pulvinar justo. Phasellus sapien ante, pharetra id, bibendum sed, porta non, purus. Maecenas leo velit, luctus quis, porta non, feugiat sit amet, sapien. Proin vitae augue ut massa adipiscing placerat. Morbi ac risus. Proin dapibus eros egestas quam. Fusce fermentum lobortis elit. Duis lectus tellus, convallis nec, lobortis vel, accumsan ut, nunc. Nunc est. Donec ullamcorper laoreet quam.
+        Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Suspendisse potenti. Mauris mi. Vivamus risus lacus, faucibus sit amet, sollicitudin a, blandit et, justo. In hendrerit. Sed imperdiet, eros at fringilla tempor, turpis augue semper enim, quis rhoncus nibh enim quis dui. Sed massa sapien, mattis et, laoreet sit amet, dignissim nec, urna. Integer laoreet quam quis lectus. Curabitur convallis gravida dui. Nam metus. Ut sit amet augue in nibh interdum scelerisque. Donec venenatis, lacus et pulvinar euismod, libero massa condimentum pede, commodo tristique nunc massa eu quam. Donec vulputate. Aenean in nibh. Phasellus porttitor. Donec molestie, sem ac porttitor vulputate, mauris dui egestas libero, ac lobortis dolor sem vel ligula. Nam vulputate pretium libero. Cras accumsan. Vivamus lacinia sapien sit amet elit.
+        Duis bibendum elementum justo. Duis posuere. Fusce nulla odio, posuere eget, condimentum nec, venenatis eu, elit. In hac habitasse platea dictumst. Aenean ac sem in enim imperdiet feugiat. Integer tincidunt lectus at elit. Integer magna lacus, vehicula quis, eleifend eget, suscipit vitae, leo. Nunc porta augue nec enim. Curabitur vehicula volutpat enim. Aliquam consequat. Vestibulum rhoncus tellus vitae erat. Integer est. Quisque fermentum leo nec odio. Suspendisse lobortis sollicitudin augue. Nullam urna mi, suscipit eu, sagittis laoreet, ultrices ac, sem. Aliquam enim tortor, hendrerit non, cursus a, tristique sit amet, sapien. Suspendisse potenti. Aenean semper placerat neque.';
+        switch($type)
+        {
+         case 'description':
+            $descriptions = explode(".",$dummy_text);
+            return $descriptions[rand(0,count($descriptions)-1)];
+            break;
+         case 'title':
+            $dummy_text = str_replace(array("\n",'.',',',"\t"),array(' ','','',' '),$dummy_text);
+            $titles = explode(" ",$dummy_text);
+            return trim($titles[rand(0,count($titles)-1)]);
+            break;
+         case 'text':
+            $texts = explode("\n",$dummy_text);
+            return $texts[rand(0,count($texts)-1)];
+            break;
+        }
+    }
 }
 }

+ 1 - 1
main/coursecopy/classes/Event.class.php

@@ -80,7 +80,7 @@ class CalendarEvent extends Coursecopy\Resource
     /**
     /**
      * Show this Event
      * Show this Event
      */
      */
-    function show()
+    public function show()
     {
     {
         parent::show();
         parent::show();
         echo $this->title.' ('.$this->start_date.' -> '.$this->end_date.')';
         echo $this->title.' ('.$this->start_date.' -> '.$this->end_date.')';

+ 3 - 2
main/coursecopy/classes/Forum.class.php

@@ -103,7 +103,7 @@ class Forum extends Coursecopy\Resource
     /**
     /**
      * Create a new Forum
      * Create a new Forum
      */
      */
-    function __construct($obj)
+    public function __construct($obj)
     {
     {
         parent::__construct($obj->forum_id, RESOURCE_FORUM);
         parent::__construct($obj->forum_id, RESOURCE_FORUM);
         $this->obj = $obj;
         $this->obj = $obj;
@@ -112,7 +112,8 @@ class Forum extends Coursecopy\Resource
     /**
     /**
      * Show this resource
      * Show this resource
      */
      */
-    function show() {
+    public function show()
+    {
         parent::show();
         parent::show();
         echo $this->obj->forum_title;
         echo $this->obj->forum_title;
     }
     }

+ 1 - 1
main/coursecopy/classes/ForumCategory.class.php

@@ -22,7 +22,7 @@ class ForumCategory extends Coursecopy\Resource
     /**
     /**
      * Show this resource
      * Show this resource
      */
      */
-    function show()
+    public function show()
     {
     {
         parent::show();
         parent::show();
         echo $this->obj->cat_title;
         echo $this->obj->cat_title;

+ 2 - 2
main/coursecopy/classes/ForumTopic.class.php

@@ -15,7 +15,7 @@ class ForumTopic extends Coursecopy\Resource
      */
      */
     /* function ForumTopic($id, $title, $time, $topic_poster_id, $topic_poster_name, $forum_id, $last_post, $replies, $views = 0, $sticky = 0, $locked = 0,
     /* function ForumTopic($id, $title, $time, $topic_poster_id, $topic_poster_name, $forum_id, $last_post, $replies, $views = 0, $sticky = 0, $locked = 0,
       $time_closed = null, $weight = 0, $title_qualify = null, $qualify_max = 0) */
       $time_closed = null, $weight = 0, $title_qualify = null, $qualify_max = 0) */
-    function __construct($obj)
+    public function __construct($obj)
     {
     {
         parent::__construct($obj->thread_id, RESOURCE_FORUMTOPIC);
         parent::__construct($obj->thread_id, RESOURCE_FORUMTOPIC);
         $this->obj = $obj;
         $this->obj = $obj;
@@ -39,7 +39,7 @@ class ForumTopic extends Coursecopy\Resource
     /**
     /**
      * Show this resource
      * Show this resource
      */
      */
-    function show()
+    public function show()
     {
     {
         parent::show();
         parent::show();
         $extra = api_convert_and_format_date($this->obj->thread_date);
         $extra = api_convert_and_format_date($this->obj->thread_date);

+ 25 - 25
main/coursecopy/classes/Glossary.class.php

@@ -10,33 +10,33 @@ require_once 'Resource.class.php';
  */
  */
 class Glossary extends Coursecopy\Resource
 class Glossary extends Coursecopy\Resource
 {
 {
-	public $glossary_id;
-	public $name;
-	public $description;
-	public $display_order;
+    public $glossary_id;
+    public $name;
+    public $description;
+    public $display_order;
 
 
-	/**
-	 * Create a new Glossary
-	 * @param int $id
-	 * @param string $name
-	 * @param string $description
-	 * @param int $display_order
-	 */
+    /**
+     * Create a new Glossary
+     * @param int $id
+     * @param string $name
+     * @param string $description
+     * @param int $display_order
+     */
     public function __construct($id,$name,$description,$display_order)
     public function __construct($id,$name,$description,$display_order)
-	{
-		parent::__construct($id,RESOURCE_GLOSSARY);
-		$this->glossary_id = $id;
-		$this->name = $name;
-		$this->description = $description;
-		$this->display_order = $display_order;
-	}
+    {
+        parent::__construct($id,RESOURCE_GLOSSARY);
+        $this->glossary_id = $id;
+        $this->name = $name;
+        $this->description = $description;
+        $this->display_order = $display_order;
+    }
 
 
-	/**
-	 * Show this glossary
-	 */
-	public function show()
+    /**
+     * Show this glossary
+     */
+    public function show()
     {
     {
-		parent::show();
-		echo $this->name;
-	}
+        parent::show();
+        echo $this->name;
+    }
 }
 }

+ 36 - 37
main/coursecopy/classes/Link.class.php

@@ -11,33 +11,33 @@ require_once 'Resource.class.php';
  */
  */
 class Link extends Coursecopy\Resource
 class Link extends Coursecopy\Resource
 {
 {
-	/**
-	 * The title
-	 */
+    /**
+     * The title
+     */
     public $title;
     public $title;
-	/**
-	 * The URL
-	 */
+    /**
+     * The URL
+     */
     public $url;
     public $url;
-	/**
-	 * The description
-	 */
+    /**
+     * The description
+     */
     public $description;
     public $description;
-	/**
-	 * Id of this links category
-	 */
+    /**
+     * Id of this links category
+     */
     public $category_id;
     public $category_id;
-	/**
-	 * Display link on course homepage
-	 */
+    /**
+     * Display link on course homepage
+     */
     public $on_homepage;
     public $on_homepage;
-	/**
-	 * Create a new Link
-	 * @param int $id The id of this link in the Chamilo-course
-	 * @param string $title
-	 * @param string $url
-	 * @param string $description
-	 */
+    /**
+     * Create a new Link
+     * @param int $id The id of this link in the Chamilo-course
+     * @param string $title
+     * @param string $url
+     * @param string $description
+     */
     public function __construct(
     public function __construct(
         $id,
         $id,
         $title,
         $title,
@@ -45,22 +45,21 @@ class Link extends Coursecopy\Resource
         $description,
         $description,
         $category_id,
         $category_id,
         $on_homepage
         $on_homepage
-    )
-	{
-		parent::__construct($id,RESOURCE_LINK);
-		$this->title = $title;
-		$this->url = $url;
-		$this->description = $description;
-		$this->category_id = $category_id;
-		$this->on_homepage = $on_homepage;
-	}
+    ) {
+        parent::__construct($id,RESOURCE_LINK);
+        $this->title = $title;
+        $this->url = $url;
+        $this->description = $description;
+        $this->category_id = $category_id;
+        $this->on_homepage = $on_homepage;
+    }
 
 
     /**
     /**
-	 * Show this resource
-	 */
+     * Show this resource
+     */
     public function show()
     public function show()
-	{
-		parent::show();
-		echo $this->title.' ('.$this->url.')';
-	}
+    {
+        parent::show();
+        echo $this->title.' ('.$this->url.')';
+    }
 }
 }

+ 33 - 33
main/coursecopy/classes/LinkCategory.class.php

@@ -10,39 +10,39 @@ require_once 'Resource.class.php';
  */
  */
 class LinkCategory extends Coursecopy\Resource
 class LinkCategory extends Coursecopy\Resource
 {
 {
-	/**
-	 * The title
-	 */
-	public $title;
-	/**
-	 * The description
-	 */
-	public $description;
-	/**
-	 * The display order
-	 */
-	public $display_order;
+    /**
+     * The title
+     */
+    public $title;
+    /**
+     * The description
+     */
+    public $description;
+    /**
+     * The display order
+     */
+    public $display_order;
 
 
-	/**
-	 * Create a new LinkCategory
-	 * @param int $id
-	 * @param string $title
-	 * @param string $description
-	 */
-	function __construct($id,$title,$description,$display_order)
-	{
-		parent::__construct($id,RESOURCE_LINKCATEGORY);
-		$this->title = $title;
-		$this->description = $description;
-		$this->display_order = $display_order;
-	}
+    /**
+     * Create a new LinkCategory
+     * @param int $id
+     * @param string $title
+     * @param string $description
+     */
+    public function __construct($id,$title,$description,$display_order)
+    {
+        parent::__construct($id,RESOURCE_LINKCATEGORY);
+        $this->title = $title;
+        $this->description = $description;
+        $this->display_order = $display_order;
+    }
 
 
-	/**
-	 * Show this LinkCategory
-	 */
-	function show()
-	{
-		parent::show();
-		echo $this->title.' '.$this->description.'<br />';
-	}
+    /**
+     * Show this LinkCategory
+     */
+    public function show()
+    {
+        parent::show();
+        echo $this->title.' '.$this->description.'<br />';
+    }
 }
 }

+ 4 - 0
main/coursecopy/classes/Quiz.class.php

@@ -21,6 +21,10 @@ class Quiz extends Coursecopy\Resource
      */
      */
     public $obj; //question
     public $obj; //question
 
 
+    /**
+     * Quiz constructor.
+     * @param int $obj
+     */
     public function __construct($obj)
     public function __construct($obj)
     {
     {
         $this->obj = $obj;
         $this->obj = $obj;

+ 11 - 11
main/coursecopy/classes/ScormDocument.class.php

@@ -13,18 +13,18 @@ class ScormDocument extends Coursecopy\Resource
     public $path;
     public $path;
     public $title;
     public $title;
 
 
-	/**
-	 * Create a new Scorm Document
-	 * @param int $id
-	 * @param string $path
-	 * @param string $title
-	 */
+    /**
+     * Create a new Scorm Document
+     * @param int $id
+     * @param string $path
+     * @param string $title
+     */
     public function __construct($id, $path, $title)
     public function __construct($id, $path, $title)
-	{
-		parent::__construct($id,RESOURCE_SCORM);
-		$this->path = 'scorm'.$path;
-		$this->title = $title;
-	}
+    {
+        parent::__construct($id,RESOURCE_SCORM);
+        $this->path = 'scorm'.$path;
+        $this->title = $title;
+    }
 
 
     /**
     /**
      * Show this document
      * Show this document

+ 103 - 103
main/coursecopy/classes/Survey.class.php

@@ -10,86 +10,86 @@ require_once 'Resource.class.php';
  */
  */
 class Survey extends Coursecopy\Resource
 class Survey extends Coursecopy\Resource
 {
 {
-	/**
-	 * The survey code
-	 */
+    /**
+     * The survey code
+     */
     public $code;
     public $code;
-	/**
-	 * The title and subtitle
-	 */
+    /**
+     * The title and subtitle
+     */
     public $title;
     public $title;
     public $subtitle;
     public $subtitle;
-	/**
-	 * The author's name
-	 */
+    /**
+     * The author's name
+     */
     public $author;
     public $author;
-	/**
-	 * The survey's language
-	 */
+    /**
+     * The survey's language
+     */
     public $lang;
     public $lang;
-	/**
-	 * The availability period
-	 */
+    /**
+     * The availability period
+     */
     public $avail_from;
     public $avail_from;
     public $avail_till;
     public $avail_till;
-	/**
-	 * Flag for shared status
-	 */
+    /**
+     * Flag for shared status
+     */
     public $is_shared;
     public $is_shared;
-	/**
-	 * Template used
-	 */
+    /**
+     * Template used
+     */
     public $template;
     public $template;
-	/**
-	 * Introduction text
-	 */
+    /**
+     * Introduction text
+     */
     public $intro;
     public $intro;
-	/**
-	 * Thanks text
-	 */
+    /**
+     * Thanks text
+     */
     public $surveythanks;
     public $surveythanks;
-	/**
-	 * Creation date
-	 */
+    /**
+     * Creation date
+     */
     public $creation_date;
     public $creation_date;
-	/**
-	 * Invitation status
-	 */
+    /**
+     * Invitation status
+     */
     public $invited;
     public $invited;
-	/**
-	 * Answer status
-	 */
+    /**
+     * Answer status
+     */
     public $answered;
     public $answered;
-	/**
-	 * Invitation and reminder mail contents
-	 */
+    /**
+     * Invitation and reminder mail contents
+     */
     public $invite_mail;
     public $invite_mail;
     public $reminder_mail;
     public $reminder_mail;
-	/**
-	 * Questions and invitations lists
-	 */
+    /**
+     * Questions and invitations lists
+     */
     public $question_ids;
     public $question_ids;
     public $invitation_ids;
     public $invitation_ids;
 
 
-	/**
-	 * Create a new Survey
-	 * @param string $code
-	 * @param string $title
-	 * @param string $subtitle
-	 * @param string $author
-	 * @param string $lang
-	 * @param string $avail_from
-	 * @param string $avail_till
-	 * @param char $is_shared
-	 * @param string $template
-	 * @param string $intro
-	 * @param string $surveythanks
-	 * @param string $creation_date
-	 * @param int $invited
-	 * @param int $answered
-	 * @param string $invite_mail
-	 * @param string $reminder_mail
-	 */
+    /**
+     * Create a new Survey
+     * @param string $code
+     * @param string $title
+     * @param string $subtitle
+     * @param string $author
+     * @param string $lang
+     * @param string $avail_from
+     * @param string $avail_till
+     * @param char $is_shared
+     * @param string $template
+     * @param string $intro
+     * @param string $surveythanks
+     * @param string $creation_date
+     * @param int $invited
+     * @param int $answered
+     * @param string $invite_mail
+     * @param string $reminder_mail
+     */
     public function __construct(
     public function __construct(
         $id,
         $id,
         $code,
         $code,
@@ -109,49 +109,49 @@ class Survey extends Coursecopy\Resource
         $invite_mail,
         $invite_mail,
         $reminder_mail
         $reminder_mail
     ) {
     ) {
-		parent::__construct($id,RESOURCE_SURVEY);
-		$this->code = $code;
-		$this->title = $title;
-		$this->subtitle = $subtitle;
-		$this->author = $author;
-		$this->lang = $lang;
-		$this->avail_from = $avail_from;
-		$this->avail_till = $avail_till;
-		$this->is_shared = $is_shared;
-		$this->template = $template;
-		$this->intro = $intro;
-		$this->surveythanks = $surveythanks;
-		$this->creation_date = $creation_date;
-		$this->invited = $invited;
-		$this->answered = $answered;
-		$this->invite_mail = $invite_mail;
-		$this->reminder_mail = $reminder_mail;
-		$this->question_ids = array();
-		$this->invitation_ids = array();
-	}
+        parent::__construct($id, RESOURCE_SURVEY);
+        $this->code = $code;
+        $this->title = $title;
+        $this->subtitle = $subtitle;
+        $this->author = $author;
+        $this->lang = $lang;
+        $this->avail_from = $avail_from;
+        $this->avail_till = $avail_till;
+        $this->is_shared = $is_shared;
+        $this->template = $template;
+        $this->intro = $intro;
+        $this->surveythanks = $surveythanks;
+        $this->creation_date = $creation_date;
+        $this->invited = $invited;
+        $this->answered = $answered;
+        $this->invite_mail = $invite_mail;
+        $this->reminder_mail = $reminder_mail;
+        $this->question_ids = array();
+        $this->invitation_ids = array();
+    }
 
 
-	/**
-	 * Add a question to this survey
-	 */
-	function add_question($id)
-	{
-		$this->question_ids[] = $id;
-	}
+    /**
+     * Add a question to this survey
+     */
+    public function add_question($id)
+    {
+        $this->question_ids[] = $id;
+    }
 
 
-	/**
-	 * Add an invitation to this survey
-	 */
-	function add_invitation($id)
-	{
-		$this->invitation_ids[] = $id;
-	}
+    /**
+     * Add an invitation to this survey
+     */
+    public function add_invitation($id)
+    {
+        $this->invitation_ids[] = $id;
+    }
 
 
-	/**
-	 * Show this survey
-	 */
-	function show()
-	{
-		parent::show();
-		echo $this->code.' - '.$this->title;
-	}
+    /**
+     * Show this survey
+     */
+    public function show()
+    {
+        parent::show();
+        echo $this->code.' - '.$this->title;
+    }
 }
 }

+ 46 - 46
main/coursecopy/classes/SurveyInvitation.class.php

@@ -10,52 +10,52 @@ require_once 'Resource.class.php';
  */
  */
 class SurveyInvitation extends Coursecopy\Resource
 class SurveyInvitation extends Coursecopy\Resource
 {
 {
-	/**
-	 * Survey code
-	 */
-	public $code;
-	/**
-	 * User info
-	 */
-	public $user;
-	/**
-	 * Invitation code
-	 */
-	public $invitation_code;
-	/**
-	 * Invitation date
-	 */
-	public $invitation_date;
-	/**
-	 * Reminder date
-	 */
-	public $reminder_date;
+    /**
+     * Survey code
+     */
+    public $code;
+    /**
+     * User info
+     */
+    public $user;
+    /**
+     * Invitation code
+     */
+    public $invitation_code;
+    /**
+     * Invitation date
+     */
+    public $invitation_date;
+    /**
+     * Reminder date
+     */
+    public $reminder_date;
 
 
-	/**
-	 * Create a new SurveyInvitation
-	 * @param	int	 $id
-	 * @param string $code
-	 * @param string $user
-	 * @param string $invitation_code
-	 * @param string $invitation_date
-	 * @param string $reminder_date
-	 */
-	public function __construct($id,$code,$user,$invitation_code,$invitation_date,$reminder_date)
-	{
-		parent::__construct($id, RESOURCE_SURVEYINVITATION);
-		$this->code = $code;
-		$this->user = $user;
-		$this->invitation_code = $invitation_code;
-		$this->invitation_date = $invitation_date;
-		$this->reminder_date = $reminder_date;
-	}
+    /**
+     * Create a new SurveyInvitation
+     * @param int	 $id
+     * @param string $code
+     * @param string $user
+     * @param string $invitation_code
+     * @param string $invitation_date
+     * @param string $reminder_date
+     */
+    public function __construct($id, $code, $user, $invitation_code, $invitation_date, $reminder_date)
+    {
+        parent::__construct($id, RESOURCE_SURVEYINVITATION);
+        $this->code = $code;
+        $this->user = $user;
+        $this->invitation_code = $invitation_code;
+        $this->invitation_date = $invitation_date;
+        $this->reminder_date = $reminder_date;
+    }
 
 
-	/**
-	 * Show this invitation
-	 */
-	function show()
-	{
-		parent::show();
-		echo $this->invitation_code;
-	}
+    /**
+     * Show this invitation
+     */
+    public function show()
+    {
+        parent::show();
+        echo $this->invitation_code;
+    }
 }
 }

+ 88 - 87
main/coursecopy/classes/SurveyQuestion.class.php

@@ -10,93 +10,94 @@ require_once 'Resource.class.php';
  */
  */
 class SurveyQuestion extends Coursecopy\Resource
 class SurveyQuestion extends Coursecopy\Resource
 {
 {
-	/**
-	 * Survey ID
-	 */
-	public $survey_id;
-	/**
-	 * Question and question comment
-	 */
-	public $survey_question;
-	public $survey_question_comment;
-	/**
-	 * Question type
-	 */
-	public $survey_question_type;
-	/**
-	 * Display ?
-	 */
-	public $display;
-	/**
-	 * Sorting order
-	 */
-	public $sort;
-	/**
-	 * Shared question ID
-	 */
-	public $shared_question_id;
-	/**
-	 * Maximum value for the vote
-	 */
-	public $max_value;
+    /**
+     * Survey ID
+     */
+    public $survey_id;
+    /**
+     * Question and question comment
+     */
+    public $survey_question;
+    public $survey_question_comment;
+    /**
+     * Question type
+     */
+    public $survey_question_type;
+    /**
+     * Display ?
+     */
+    public $display;
+    /**
+     * Sorting order
+     */
+    public $sort;
+    /**
+     * Shared question ID
+     */
+    public $shared_question_id;
+    /**
+     * Maximum value for the vote
+     */
+    public $max_value;
 
 
-	/**
-	 * Question's options
-	 */
-	public $options;
+    /**
+     * Question's options
+     */
+    public $options;
 
 
-	/**
-	 * Create a new SurveyQuestion
-	 * @param int	 $id
-	 * @param int 	 $survey_id
-	 * @param string $survey_question
-	 * @param string $survey_question_comment
-	 * @param string $type
-	 * @param string $display
-	 * @param int	 $sort
-	 * @param int	 $shared_question_id
-	 * @param int	 $max_value
-	 */
-	function __construct(
-		$id,
-		$survey_id,
-		$survey_question,
-		$survey_question_comment,
-		$type,
-		$display,
-		$sort,
-		$shared_question_id,
-		$max_value
-	) {
-		parent::__construct($id,RESOURCE_SURVEYQUESTION);
-		$this->survey_id = $survey_id;
-		$this->survey_question = $survey_question;
-		$this->survey_question_comment = $survey_question_comment;
-		$this->survey_question_type = $type;
-		$this->display = $display;
-		$this->sort = $sort;
-		$this->shared_question_id = $shared_question_id;
-		$this->max_value = $max_value;
-		$this->answers = array();
-	}
-	/**
-	 * Add an answer option to this SurveyQuestion
-	 * @param string $option_text
-	 * @param int	 $sort
-	 */
-	function add_answer($option_text,$sort)
-	{
-		$answer = array();
-		$answer['option_text'] = $option_text;
-		$answer['sort'] = $sort;
-		$this->answers[] = $answer;
-	}
-	/**
-	 * Show this question
-	 */
-	function show()
-	{
-		parent::show();
-		echo $this->survey_question;
-	}
+    /**
+     * Create a new SurveyQuestion
+     * @param int	 $id
+     * @param int 	 $survey_id
+     * @param string $survey_question
+     * @param string $survey_question_comment
+     * @param string $type
+     * @param string $display
+     * @param int	 $sort
+     * @param int	 $shared_question_id
+     * @param int	 $max_value
+     */
+    public function __construct(
+        $id,
+        $survey_id,
+        $survey_question,
+        $survey_question_comment,
+        $type,
+        $display,
+        $sort,
+        $shared_question_id,
+        $max_value
+    ) {
+        parent::__construct($id, RESOURCE_SURVEYQUESTION);
+        $this->survey_id = $survey_id;
+        $this->survey_question = $survey_question;
+        $this->survey_question_comment = $survey_question_comment;
+        $this->survey_question_type = $type;
+        $this->display = $display;
+        $this->sort = $sort;
+        $this->shared_question_id = $shared_question_id;
+        $this->max_value = $max_value;
+        $this->answers = array();
+    }
+
+    /**
+     * Add an answer option to this SurveyQuestion
+     * @param string $option_text
+     * @param int	 $sort
+     */
+    public function add_answer($option_text,$sort)
+    {
+        $answer = array();
+        $answer['option_text'] = $option_text;
+        $answer['sort'] = $sort;
+        $this->answers[] = $answer;
+    }
+    /**
+     * Show this question
+     */
+    public function show()
+    {
+        parent::show();
+        echo $this->survey_question;
+    }
 }
 }

+ 1 - 1
main/coursecopy/classes/Thematic.class.php

@@ -16,7 +16,7 @@ class Thematic extends Coursecopy\Resource
     /**
     /**
     * Create a new Thematic
     * Create a new Thematic
     *
     *
-    * @param array parameters
+    * @param array $params
     */
     */
     public function __construct($params)
     public function __construct($params)
     {
     {

+ 75 - 75
main/coursecopy/classes/ToolIntro.class.php

@@ -10,82 +10,82 @@ require_once 'Resource.class.php';
  */
  */
 class ToolIntro extends Coursecopy\Resource
 class ToolIntro extends Coursecopy\Resource
 {
 {
-	public $id;
+    public $id;
 
 
-	/**
-	 * intro text
-	 */
-	public $intro_text;
+    /**
+     * intro text
+     */
+    public $intro_text;
 
 
-	/**
-	 * Create a new text introduction
-	 * @param int $id The id of this tool introduction in the Chamilo-course
-	 * @param string $intro_text
-	 */
-	public function __construct($id, $intro_text)
-	{
-		parent::__construct($id, RESOURCE_TOOL_INTRO);
-		$this->id = $id;
-		$this->intro_text = $intro_text;
-	}
+    /**
+     * Create a new text introduction
+     * @param int $id The id of this tool introduction in the Chamilo-course
+     * @param string $intro_text
+     */
+    public function __construct($id, $intro_text)
+    {
+        parent::__construct($id, RESOURCE_TOOL_INTRO);
+        $this->id = $id;
+        $this->intro_text = $intro_text;
+    }
 
 
-	/**
-	 * Show this resource
-	 */
-	function show()
-	{
-		parent::show();
-		switch ($this->id)
-		{
-			case TOOL_DOCUMENT:
-				$lang_id = 'Documents';
-				break;
-			case TOOL_CALENDAR_EVENT:
-				$lang_id = 'Agenda';
-				break;
-			case TOOL_LINK:
-				$lang_id = 'Links';
-				break;
-			case TOOL_LEARNPATH:
-				$lang_id = 'LearningPath';
-				break;
-			case TOOL_ANNOUNCEMENT:
-				$lang_id = 'Announcements';
-				break;
-			case TOOL_FORUM:
-				$lang_id = 'Forums';
-				break;
-			case TOOL_DROPBOX:
-				$lang_id = 'Dropbox';
-				break;
-			case TOOL_QUIZ:
-				$lang_id = 'Exercises';
-				break;
-			case TOOL_USER:
-				$lang_id = 'Users';
-				break;
-			case TOOL_GROUP:
-				$lang_id = 'Group';
-				break;
-			case TOOL_WIKI:
-				$lang_id = 'Wiki';
-				break;
-			case TOOL_STUDENTPUBLICATION:
-				$lang_id = 'StudentPublications';
-				break;
-			case TOOL_COURSE_HOMEPAGE:
-				$lang_id = 'CourseHomepageLink';
-				break;
-			case TOOL_GLOSSARY:
-				$lang_id = 'Glossary';
-				break;
-			case TOOL_NOTEBOOK:
-				$lang_id = 'Notebook';
-				break;
-			default:
-				$lang_id = ucfirst($this->id); // This is a wild guess.
-		}
-		echo '<strong>'.get_lang($lang_id, '').':</strong><br />';
-		echo $this->intro_text;
-	}
+    /**
+     * Show this resource
+     */
+    public function show()
+    {
+        parent::show();
+        switch ($this->id)
+        {
+            case TOOL_DOCUMENT:
+                $lang_id = 'Documents';
+                break;
+            case TOOL_CALENDAR_EVENT:
+                $lang_id = 'Agenda';
+                break;
+            case TOOL_LINK:
+                $lang_id = 'Links';
+                break;
+            case TOOL_LEARNPATH:
+                $lang_id = 'LearningPath';
+                break;
+            case TOOL_ANNOUNCEMENT:
+                $lang_id = 'Announcements';
+                break;
+            case TOOL_FORUM:
+                $lang_id = 'Forums';
+                break;
+            case TOOL_DROPBOX:
+                $lang_id = 'Dropbox';
+                break;
+            case TOOL_QUIZ:
+                $lang_id = 'Exercises';
+                break;
+            case TOOL_USER:
+                $lang_id = 'Users';
+                break;
+            case TOOL_GROUP:
+                $lang_id = 'Group';
+                break;
+            case TOOL_WIKI:
+                $lang_id = 'Wiki';
+                break;
+            case TOOL_STUDENTPUBLICATION:
+                $lang_id = 'StudentPublications';
+                break;
+            case TOOL_COURSE_HOMEPAGE:
+                $lang_id = 'CourseHomepageLink';
+                break;
+            case TOOL_GLOSSARY:
+                $lang_id = 'Glossary';
+                break;
+            case TOOL_NOTEBOOK:
+                $lang_id = 'Notebook';
+                break;
+            default:
+                $lang_id = ucfirst($this->id); // This is a wild guess.
+        }
+        echo '<strong>'.get_lang($lang_id, '').':</strong><br />';
+        echo $this->intro_text;
+    }
 }
 }

+ 1 - 1
main/coursecopy/classes/Work.class.php

@@ -15,7 +15,7 @@ class Work extends Coursecopy\Resource
     /**
     /**
      * Create a new Work
      * Create a new Work
      *
      *
-     * @param array parameters
+     * @param array $params
      */
      */
     public function __construct($params)
     public function __construct($params)
     {
     {

+ 42 - 42
main/coursecopy/classes/wiki.class.php

@@ -9,43 +9,43 @@
  */
  */
 class Wiki extends Coursecopy\Resource
 class Wiki extends Coursecopy\Resource
 {
 {
-	public $id;
-	public $page_id;
-	public $reflink;
-	public $title;
-	public $content;
-	public $user_id;
-	public $group_id;
-	public $timestamp;
-	public $progress;
-	public $version;
+    public $id;
+    public $page_id;
+    public $reflink;
+    public $title;
+    public $content;
+    public $user_id;
+    public $group_id;
+    public $timestamp;
+    public $progress;
+    public $version;
 
 
-	/**
-	 * Wiki constructor.
-	 * @param int $id
-	 * @param int $page_id
-	 * @param $reflink
-	 * @param $title
-	 * @param $content
-	 * @param $user_id
-	 * @param $group_id
-	 * @param $timestamp
-	 * @param $progress
-	 * @param $version
-	 */
-	public function __construct(
-		$id,
-		$page_id,
-		$reflink,
-		$title,
-		$content,
-		$user_id,
-		$group_id,
-		$timestamp,
-		$progress,
-		$version
-	) {
-		parent::__construct($id,RESOURCE_WIKI);
+    /**
+     * Wiki constructor.
+     * @param int $id
+     * @param int $page_id
+     * @param $reflink
+     * @param $title
+     * @param $content
+     * @param $user_id
+     * @param $group_id
+     * @param $timestamp
+     * @param $progress
+     * @param $version
+     */
+    public function __construct(
+        $id,
+        $page_id,
+        $reflink,
+        $title,
+        $content,
+        $user_id,
+        $group_id,
+        $timestamp,
+        $progress,
+        $version
+    ) {
+        parent::__construct($id,RESOURCE_WIKI);
         $this->id = $id;
         $this->id = $id;
         $this->page_id = $page_id;
         $this->page_id = $page_id;
         $this->reflink = $reflink;
         $this->reflink = $reflink;
@@ -56,11 +56,11 @@ class Wiki extends Coursecopy\Resource
         $this->dtime = $timestamp;
         $this->dtime = $timestamp;
         $this->progress = $progress;
         $this->progress = $progress;
         $this->version = $version;
         $this->version = $version;
-	}
+    }
 
 
-	public function show()
-	{
-		parent::show();
-		echo $this->reflink.' ('. (empty($this->group_id) ? get_lang('Everyone') : get_lang('Group') . ' ' .  $this->group_id) .') ' . '<i>(' . $this->dtime . ')</i>';
-	}
+    public function show()
+    {
+        parent::show();
+        echo $this->reflink.' ('. (empty($this->group_id) ? get_lang('Everyone') : get_lang('Group') . ' ' .  $this->group_id) .') ' . '<i>(' . $this->dtime . ')</i>';
+    }
 }
 }